Struct blind_rsa_signatures::SecretKey
source · pub struct SecretKey(pub RsaPrivateKey);
Expand description
An RSA secret key
Tuple Fields§
§0: RsaPrivateKey
Implementations§
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, Global>, Error>where
P: PaddingScheme,
pub fn decrypt<P>( &self, padding: P, ciphertext: &[u8] ) -> Result<Vec<u8, Global>, 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, Global>, Error>where
R: CryptoRngCore,
P: PaddingScheme,
pub fn decrypt_blinded<R, P>( &self, rng: &mut R, padding: P, ciphertext: &[u8] ) -> Result<Vec<u8, Global>, 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, Global>, Error>where
S: SignatureScheme,
pub fn sign<S>( &self, padding: S, digest_in: &[u8] ) -> Result<Vec<u8, Global>, 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, Global>, 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, Global>, 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
:
Pkcs1v15Sign
padding: uses the RNG to mask the private key operation with random blinding, which helps mitigate sidechannel attacks.Pss
always requires randomness. UsePss::new
for a standard RSASSA-PSS signature, orPss::new_blinded
for 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 From<RsaPrivateKey> for SecretKey
impl From<RsaPrivateKey> for SecretKey
source§fn from(original: RsaPrivateKey) -> SecretKey
fn from(original: RsaPrivateKey) -> SecretKey
Converts to this type from the input type.