Struct rsa::RSAPrivateKey
source · pub struct RSAPrivateKey { /* private fields */ }
Expand description
Represents a whole RSA key, public and private parts.
Implementations§
source§impl RSAPrivateKey
impl RSAPrivateKey
sourcepub fn new<R: Rng>(rng: &mut R, bit_size: usize) -> Result<RSAPrivateKey>
pub fn new<R: Rng>(rng: &mut R, bit_size: usize) -> Result<RSAPrivateKey>
Generate a new RSA key pair of the given bit size using the passed in rng
.
sourcepub fn from_components(
n: BigUint,
e: BigUint,
d: BigUint,
primes: Vec<BigUint>
) -> RSAPrivateKey
pub fn from_components(
n: BigUint,
e: BigUint,
d: BigUint,
primes: Vec<BigUint>
) -> RSAPrivateKey
Constructs an RSA key pair from the individual components.
sourcepub fn precompute(&mut self)
pub fn precompute(&mut self)
Performs some calculations to speed up private key operations.
sourcepub fn validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
Performs basic sanity checks on the key.
Returns Ok(())
if everything is good, otherwise an approriate error.
sourcepub fn decrypt(
&self,
padding: PaddingScheme,
ciphertext: &[u8]
) -> Result<Vec<u8>>
pub fn decrypt(
&self,
padding: PaddingScheme,
ciphertext: &[u8]
) -> Result<Vec<u8>>
Decrypt the given message.
sourcepub fn decrypt_blinded<R: Rng>(
&self,
rng: &mut R,
padding: PaddingScheme,
ciphertext: &[u8]
) -> Result<Vec<u8>>
pub fn decrypt_blinded<R: Rng>(
&self,
rng: &mut R,
padding: PaddingScheme,
ciphertext: &[u8]
) -> Result<Vec<u8>>
Decrypt the given message.
Uses rng
to blind the decryption process.
Trait Implementations§
source§impl Clone for RSAPrivateKey
impl Clone for RSAPrivateKey
source§fn clone(&self) -> RSAPrivateKey
fn clone(&self) -> RSAPrivateKey
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for RSAPrivateKey
impl Debug for RSAPrivateKey
source§impl From<RSAPrivateKey> for RSAPublicKey
impl From<RSAPrivateKey> for RSAPublicKey
source§fn from(private_key: RSAPrivateKey) -> Self
fn from(private_key: RSAPrivateKey) -> Self
Converts to this type from the input type.