Skip to content

Commit

Permalink
Implement PublicKeyComponents::build_encrypting_key
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadmeme committed Nov 10, 2024
1 parent 314d12b commit d0a9354
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aws-lc-rs/src/rsa/encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl Clone for PrivateDecryptingKey {
pub struct PublicEncryptingKey(LcPtr<EVP_PKEY>);

impl PublicEncryptingKey {
fn new(evp_pkey: LcPtr<EVP_PKEY>) -> Result<Self, Unspecified> {
pub(crate) fn new(evp_pkey: LcPtr<EVP_PKEY>) -> Result<Self, Unspecified> {
Self::validate_key(&evp_pkey)?;
Ok(Self(evp_pkey))
}
Expand Down
11 changes: 11 additions & 0 deletions aws-lc-rs/src/rsa/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use crate::io;
use crate::ptr::ConstPointer;
use crate::{
digest::{self},
rsa::{PublicEncryptingKey},
encoding::{AsDer, Pkcs8V1Der},
error::{KeyRejected, Unspecified},
fips::indicator_check,
Expand Down Expand Up @@ -432,6 +433,16 @@ where
Ok(pkey)
}

/// Builds a `PublicEncryptingKey` from the public key components.
///
/// # Errors
/// `error::Unspecified` if the key failed to verify.
pub fn build_encrypting_key(&self) -> Result<PublicEncryptingKey, Unspecified> {
let rsa = self.build_rsa()?;

PublicEncryptingKey::new(rsa)
}

/// Verifies that `signature` is a valid signature of `message` using `self`
/// as the public key. `params` determine what algorithm parameters
/// (padding, digest algorithm, key length range, etc.) are used in the
Expand Down

0 comments on commit d0a9354

Please sign in to comment.