pub struct RsaPublicKey { /* private fields */ }rsa only.Expand description
Represents the public part of an RSA key.
Implementations§
Source§impl RsaPublicKey
impl RsaPublicKey
Sourcepub fn encrypt<R, P>(
&self,
rng: &mut R,
padding: P,
msg: &[u8],
) -> Result<Vec<u8>, Error>
pub fn encrypt<R, P>( &self, rng: &mut R, padding: P, msg: &[u8], ) -> Result<Vec<u8>, Error>
Encrypt the given message.
Sourcepub 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.
Source§impl RsaPublicKey
impl RsaPublicKey
Sourcepub const MIN_PUB_EXPONENT: u64 = 2u64
pub const MIN_PUB_EXPONENT: u64 = 2u64
Minimum value of the public exponent e.
Sourcepub const MAX_PUB_EXPONENT: u64 = 8_589_934_591u64
pub const MAX_PUB_EXPONENT: u64 = 8_589_934_591u64
Maximum value of the public exponent e.
Sourcepub fn new(n: BoxedUint, e: BoxedUint) -> Result<RsaPublicKey, Error>
pub fn new(n: BoxedUint, e: BoxedUint) -> Result<RsaPublicKey, Error>
Create a new public key from its components.
This function accepts public keys with a modulus size up to 4096-bits,
i.e. RsaPublicKey::MAX_SIZE.
Sourcepub fn new_with_max_size(
n: BoxedUint,
e: BoxedUint,
max_size: usize,
) -> Result<RsaPublicKey, Error>
pub fn new_with_max_size( n: BoxedUint, e: BoxedUint, max_size: usize, ) -> Result<RsaPublicKey, Error>
Create a new public key from its components.
Sourcepub fn new_unchecked(n: BoxedUint, e: BoxedUint) -> RsaPublicKey
pub fn new_unchecked(n: BoxedUint, e: BoxedUint) -> RsaPublicKey
Create a new public key, bypassing checks around the modulus and public exponent size.
This method is not recommended, and only intended for unusual use cases.
Most applications should use RsaPublicKey::new or
RsaPublicKey::new_with_max_size instead.
Trait Implementations§
Source§impl AsRef<RsaPublicKey> for RsaPrivateKey
impl AsRef<RsaPublicKey> for RsaPrivateKey
Source§fn as_ref(&self) -> &RsaPublicKey
fn as_ref(&self) -> &RsaPublicKey
Source§impl Clone for RsaPublicKey
impl Clone for RsaPublicKey
Source§fn clone(&self) -> RsaPublicKey
fn clone(&self) -> RsaPublicKey
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more