[][src]Struct rsa::RSAPrivateKey

pub struct RSAPrivateKey { /* fields omitted */ }

Represents a whole RSA key, public and private parts.

Methods

impl RSAPrivateKey[src]

pub fn new<R: Rng>(rng: &mut R, bit_size: usize) -> Result<RSAPrivateKey>[src]

Generate a new RSA key pair of the given bit size using the passed in rng.

pub fn from_components(
    n: BigUint,
    e: BigUint,
    d: BigUint,
    primes: Vec<BigUint>
) -> RSAPrivateKey
[src]

Constructs an RSA key pair from the individual components.

pub fn to_public_key(&self) -> RSAPublicKey[src]

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 occationally be useful to discard the private information entirely.

pub fn precompute(&mut self)[src]

Performs some calculations to speed up private key operations.

pub fn d(&self) -> &BigUint[src]

Returns the private exponent of the key.

pub fn primes(&self) -> &[BigUint][src]

Returns the prime factors.

pub fn validate(&self) -> Result<()>[src]

Performs basic sanity checks on the key. Returns Ok(()) if everything is good, otherwise an approriate error.

pub fn decrypt(
    &self,
    padding: PaddingScheme,
    ciphertext: &[u8]
) -> Result<Vec<u8>>
[src]

Decrypt the given message.

pub fn decrypt_blinded<R: Rng>(
    &self,
    rng: &mut R,
    padding: PaddingScheme,
    ciphertext: &[u8]
) -> Result<Vec<u8>>
[src]

Decrypt the given message. Uses rng to blind the decryption process.

pub fn sign<H: Hash>(
    &self,
    padding: PaddingScheme,
    hash: Option<&H>,
    digest: &[u8]
) -> Result<Vec<u8>>
[src]

Sign the given digest.

pub fn sign_blinded<R: Rng, H: Hash>(
    &self,
    rng: &mut R,
    padding: PaddingScheme,
    hash: Option<&H>,
    digest: &[u8]
) -> Result<Vec<u8>>
[src]

Sign the given digest. Use rng for blinding.

Trait Implementations

impl PublicKey for RSAPrivateKey[src]

impl<'a> PublicKey for &'a RSAPrivateKey[src]

impl Drop for RSAPrivateKey[src]

impl From<RSAPrivateKey> for RSAPublicKey[src]

impl Clone for RSAPrivateKey[src]

impl Eq for RSAPrivateKey[src]

impl PartialEq<RSAPrivateKey> for RSAPrivateKey[src]

impl Debug for RSAPrivateKey[src]

impl Zeroize for RSAPrivateKey[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<Z> Zeroize for Z where
    Z: DefaultIsZeroes
[src]