pub struct RsaPublicKey { /* private fields */ }
Expand description
RSA Public Key used in OpenTitan signing operations.
This is a wrapper for handling RSA public keys as they’re used in OpenTitan images.
Implementations§
Source§impl RsaPublicKey
impl RsaPublicKey
Sourcepub fn new(n: Modulus) -> Result<RsaPublicKey>
pub fn new(n: Modulus) -> Result<RsaPublicKey>
Construct a new public key with modulus = n and e = 65537.
Sourcepub fn from_pkcs1_der_file<P: Into<PathBuf>>(
der_file: P,
) -> Result<RsaPublicKey>
pub fn from_pkcs1_der_file<P: Into<PathBuf>>( der_file: P, ) -> Result<RsaPublicKey>
Construct a new public key from a PKCS1 encoded DER file.
Sourcepub fn to_pkcs1_der_file<P: Into<PathBuf>>(&self, der_file: P) -> Result<()>
pub fn to_pkcs1_der_file<P: Into<PathBuf>>(&self, der_file: P) -> Result<()>
Write public key to a PKCS1 encoded DER file.
Sourcepub fn from_private_key(private_key: &RsaPrivateKey) -> Self
pub fn from_private_key(private_key: &RsaPrivateKey) -> Self
Extract the public key components from a given private key.
Sourcepub fn modulus_num_bits(&self) -> usize
pub fn modulus_num_bits(&self) -> usize
Bit length for this key.
Methods from Deref<Target = RsaPublicKey>§
pub fn encrypt<R, P>(
&self,
rng: &mut R,
padding: P,
msg: &[u8],
) -> Result<Vec<u8>, Error>where
R: CryptoRngCore,
P: PaddingScheme,
pub fn encrypt<R, P>(
&self,
rng: &mut R,
padding: P,
msg: &[u8],
) -> Result<Vec<u8>, Error>where
R: CryptoRngCore,
P: PaddingScheme,
Encrypt the given message.
pub fn verify<S>(
&self,
scheme: S,
hashed: &[u8],
sig: &[u8],
) -> Result<(), Error>where
S: SignatureScheme,
pub fn verify<S>(
&self,
scheme: S,
hashed: &[u8],
sig: &[u8],
) -> Result<(), Error>where
S: SignatureScheme,
Verify a signed message.
hashed
must be the result of hashing the input using the hashing function
passed in through hash
.
If the message is valid Ok(())
is returned, otherwise an Err
indicating failure.
pub const MIN_PUB_EXPONENT: u64 = 2u64
pub const MAX_PUB_EXPONENT: u64 = 8_589_934_591u64
pub const MAX_SIZE: usize = 4_096usize
Trait Implementations§
Source§impl Debug for RsaPublicKey
impl Debug for RsaPublicKey
Source§impl Deref for RsaPublicKey
impl Deref for RsaPublicKey
Source§impl TryFrom<&RsaPublicKey> for RsaRawPublicKey
impl TryFrom<&RsaPublicKey> for RsaRawPublicKey
Source§impl TryFrom<RsaPublicKey> for RsaRawPublicKey
impl TryFrom<RsaPublicKey> for RsaRawPublicKey
Auto Trait Implementations§
impl Freeze for RsaPublicKey
impl RefUnwindSafe for RsaPublicKey
impl Send for RsaPublicKey
impl Sync for RsaPublicKey
impl Unpin for RsaPublicKey
impl UnwindSafe for RsaPublicKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more