pub struct PrivateKey(/* private fields */);
Expand description
Private Key for RSA.
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
:
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.
Trait Implementations§
Source§impl Debug for PrivateKey
impl Debug for PrivateKey
Source§impl Decryptor for PrivateKey
impl Decryptor for PrivateKey
Source§impl Deref for PrivateKey
impl Deref for PrivateKey
Source§impl Drop for PrivateKey
impl Drop for PrivateKey
Source§impl From<RsaPrivateKey> for PrivateKey
impl From<RsaPrivateKey> for PrivateKey
Source§fn from(key: RsaPrivateKey) -> Self
fn from(key: RsaPrivateKey) -> Self
Converts to this type from the input type.
Source§impl KeyParams for PrivateKey
impl KeyParams for PrivateKey
Source§impl Signer for PrivateKey
impl Signer for PrivateKey
Source§fn sign(
&self,
hash: HashAlgorithm,
digest: &[u8],
pub_params: &PublicParams,
) -> Result<Vec<Vec<u8>>>
fn sign( &self, hash: HashAlgorithm, digest: &[u8], pub_params: &PublicParams, ) -> Result<Vec<Vec<u8>>>
Sign using RSA, with PKCS1v15 padding.
Auto Trait Implementations§
impl Freeze for PrivateKey
impl RefUnwindSafe for PrivateKey
impl Send for PrivateKey
impl Sync for PrivateKey
impl Unpin for PrivateKey
impl UnwindSafe for PrivateKey
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