Struct nettle::rsa::PrivateKey[][src]

pub struct PrivateKey { /* fields omitted */ }

A private RSA key.

Implementations

impl PrivateKey[src]

pub fn new<'a, O: Into<Option<&'a [u8]>>>(
    d: &[u8],
    p: &[u8],
    q: &[u8],
    inv: O
) -> Result<Self>
[src]

Creates a new private key with the private exponent d and the two primes p/q. If the inverse inv for q in Z_p is None the function computes it.

Notes

This function does time-variable computation on the private key that may leak it. See new_crt for a time-constant way to create a PrivateKey.

pub fn new_crt<'a, O: Into<Option<&'a [u8]>>>(
    dp: &[u8],
    dq: &[u8],
    p: &[u8],
    q: &[u8],
    inv: O
) -> Result<Self>
[src]

Creates a new private key with the two primes p/q. The private exponent d is given as dp = d mod p - 1 and dq = d mod q - 1. If the inverse inv of q in Z_p is None the function computes it.

Notes

If inv is None the function does time-variable computation on the private key that may leak it.

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

Computes the public key to this private key. This only works if the private key was created with new instead of new_crt.

Notes

This function does time-variable computation on the private key that may leak it.

pub fn as_rfc4880(&self) -> (Box<[u8]>, Box<[u8]>, Box<[u8]>)[src]

Returns the tuple a, b, c. a and b are the two RSA primes p/q with a < b and c = a^-1 mod b.

pub fn primes(&self) -> (Box<[u8]>, Box<[u8]>)[src]

Returns the primes p/q as big endian integers.

pub fn d_crt(&self) -> (Box<[u8]>, Box<[u8]>, Box<[u8]>)[src]

Returns the private exponent d as pair of big endian integers dp = d mod p - 1 and dq = d mod q - 1 and the inverse of q in Z_p as third value.

pub fn d(&self) -> Box<[u8]>[src]

Returns the private exponent d as big endian integer.

Trait Implementations

impl Clone for PrivateKey[src]

impl Drop for PrivateKey[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

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

impl<T, U> Into<U> for T where
    U: From<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.