pub struct SecretKey(pub RsaPrivateKey);Expand description
An RSA secret key
Tuple Fields§
§0: RsaPrivateKeyImplementations§
Methods from Deref<Target = RsaPrivateKey>§
Sourcepub fn to_public_key(&self) -> RsaPublicKey
pub fn to_public_key(&self) -> RsaPublicKey
Get the public key from the private key, cloning n and e.
Generally this is not needed since RsaPrivateKey implements the PublicKey trait,
but it can occasionally be useful to discard the private information entirely.
Sourcepub fn crt_coefficient(&self) -> Option<BigUint>
pub fn crt_coefficient(&self) -> Option<BigUint>
Compute CRT coefficient: (1/q) mod p.
Sourcepub fn validate(&self) -> Result<(), Error>
pub fn validate(&self) -> Result<(), Error>
Performs basic sanity checks on the key.
Returns Ok(()) if everything is good, otherwise an appropriate error.
Sourcepub fn decrypt<P>(
&self,
padding: P,
ciphertext: &[u8],
) -> Result<Vec<u8>, Error>where
P: PaddingScheme,
pub fn decrypt<P>(
&self,
padding: P,
ciphertext: &[u8],
) -> Result<Vec<u8>, Error>where
P: PaddingScheme,
Decrypt the given message.
Sourcepub fn decrypt_blinded<R, P>(
&self,
rng: &mut R,
padding: P,
ciphertext: &[u8],
) -> Result<Vec<u8>, Error>where
R: CryptoRngCore,
P: PaddingScheme,
pub fn decrypt_blinded<R, P>(
&self,
rng: &mut R,
padding: P,
ciphertext: &[u8],
) -> Result<Vec<u8>, Error>where
R: CryptoRngCore,
P: PaddingScheme,
Decrypt the given message.
Uses rng to blind the decryption process.
Sourcepub fn sign<S>(&self, padding: S, digest_in: &[u8]) -> Result<Vec<u8>, Error>where
S: SignatureScheme,
pub fn sign<S>(&self, padding: S, digest_in: &[u8]) -> Result<Vec<u8>, Error>where
S: SignatureScheme,
Sign the given digest.
Sourcepub fn sign_with_rng<R, S>(
&self,
rng: &mut R,
padding: S,
digest_in: &[u8],
) -> Result<Vec<u8>, Error>where
R: CryptoRngCore,
S: SignatureScheme,
pub fn sign_with_rng<R, S>(
&self,
rng: &mut R,
padding: S,
digest_in: &[u8],
) -> Result<Vec<u8>, Error>where
R: CryptoRngCore,
S: SignatureScheme,
Sign the given digest using the provided rng, which is used in the
following ways depending on the SignatureScheme:
Pkcs1v15Signpadding: uses the RNG to mask the private key operation with random blinding, which helps mitigate sidechannel attacks.Pssalways requires randomness. UsePss::newfor a standard RSASSA-PSS signature, orPss::new_blindedfor RSA-BSSA blind signatures.
Methods from Deref<Target = RsaPublicKey>§
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 AsRef<RsaPrivateKey> for SecretKey
impl AsRef<RsaPrivateKey> for SecretKey
Source§fn as_ref(&self) -> &RsaPrivateKey
fn as_ref(&self) -> &RsaPrivateKey
Converts this type into a shared reference of the (usually inferred) input type.
Source§impl<'de> Deserialize<'de> for SecretKey
impl<'de> Deserialize<'de> for SecretKey
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<RsaPrivateKey> for SecretKey
impl From<RsaPrivateKey> for SecretKey
Source§fn from(value: RsaPrivateKey) -> Self
fn from(value: RsaPrivateKey) -> Self
Converts to this type from the input type.
Source§impl From<SecretKey> for RsaPrivateKey
impl From<SecretKey> for RsaPrivateKey
Auto Trait Implementations§
impl Freeze for SecretKey
impl RefUnwindSafe for SecretKey
impl Send for SecretKey
impl Sync for SecretKey
impl Unpin for SecretKey
impl UnwindSafe for SecretKey
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