Struct nettle::rsa::PrivateKey [−][src]
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]
d: &[u8],
p: &[u8],
q: &[u8],
inv: O
) -> Result<Self>
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]
dp: &[u8],
dq: &[u8],
p: &[u8],
q: &[u8],
inv: O
) -> Result<Self>
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]
fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Drop for PrivateKey
[src]
Auto Trait Implementations
impl RefUnwindSafe for PrivateKey
[src]
impl !Send for PrivateKey
[src]
impl !Sync for PrivateKey
[src]
impl Unpin for PrivateKey
[src]
impl UnwindSafe for PrivateKey
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,