Struct pkcs1::RsaPrivateKey
source · [−]pub struct RsaPrivateKey<'a> {
pub version: Version,
pub modulus: UIntBytes<'a>,
pub public_exponent: UIntBytes<'a>,
pub private_exponent: UIntBytes<'a>,
pub prime1: UIntBytes<'a>,
pub prime2: UIntBytes<'a>,
pub exponent1: UIntBytes<'a>,
pub exponent2: UIntBytes<'a>,
pub coefficient: UIntBytes<'a>,
}
Expand description
PKCS#1 RSA Private Keys as defined in RFC 8017 Appendix 1.2.
ASN.1 structure containing a serialized RSA private key:
RSAPrivateKey ::= SEQUENCE {
version Version,
modulus INTEGER, -- n
publicExponent INTEGER, -- e
privateExponent INTEGER, -- d
prime1 INTEGER, -- p
prime2 INTEGER, -- q
exponent1 INTEGER, -- d mod (p-1)
exponent2 INTEGER, -- d mod (q-1)
coefficient INTEGER, -- (inverse of q) mod p
otherPrimeInfos OtherPrimeInfos OPTIONAL
}
Fields
version: Version
Version number: two-prime
or multi
modulus: UIntBytes<'a>
n
: RSA modulus
public_exponent: UIntBytes<'a>
e
: RSA public exponent
private_exponent: UIntBytes<'a>
d
: RSA private exponent
prime1: UIntBytes<'a>
p
: first prime factor of n
prime2: UIntBytes<'a>
q
: Second prime factor of n
exponent1: UIntBytes<'a>
First exponent: d mod (p-1)
exponent2: UIntBytes<'a>
Second exponent: d mod (q-1)
coefficient: UIntBytes<'a>
CRT coefficient: (inverse of q) mod p
Implementations
sourceimpl<'a> RsaPrivateKey<'a>
impl<'a> RsaPrivateKey<'a>
sourcepub fn public_key(&self) -> RsaPublicKey<'a>
pub fn public_key(&self) -> RsaPublicKey<'a>
Get the public key that corresponds to this RsaPrivateKey
.
sourcepub fn to_der(&self) -> RsaPrivateKeyDocument
pub fn to_der(&self) -> RsaPrivateKeyDocument
Encode this RsaPrivateKey
as ASN.1 DER.
sourcepub fn to_pem(&self) -> Result<Zeroizing<String>>
pub fn to_pem(&self) -> Result<Zeroizing<String>>
Encode this RsaPrivateKey
as PEM-encoded ASN.1 DER.
sourcepub fn to_pem_with_le(
&self,
line_ending: LineEnding
) -> Result<Zeroizing<String>>
pub fn to_pem_with_le(
&self,
line_ending: LineEnding
) -> Result<Zeroizing<String>>
Encode this RsaPrivateKey
as PEM-encoded ASN.1 DER using the given
LineEnding
.
Trait Implementations
sourceimpl<'a> Clone for RsaPrivateKey<'a>
impl<'a> Clone for RsaPrivateKey<'a>
sourcefn clone(&self) -> RsaPrivateKey<'a>
fn clone(&self) -> RsaPrivateKey<'a>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<'a> Debug for RsaPrivateKey<'a>
impl<'a> Debug for RsaPrivateKey<'a>
sourceimpl From<&'_ RsaPrivateKey<'_>> for RsaPrivateKeyDocument
impl From<&'_ RsaPrivateKey<'_>> for RsaPrivateKeyDocument
sourcefn from(private_key: &RsaPrivateKey<'_>) -> RsaPrivateKeyDocument
fn from(private_key: &RsaPrivateKey<'_>) -> RsaPrivateKeyDocument
Converts to this type from the input type.
sourceimpl<'a> From<&'_ RsaPrivateKey<'a>> for RsaPublicKey<'a>
impl<'a> From<&'_ RsaPrivateKey<'a>> for RsaPublicKey<'a>
sourcefn from(private_key: &RsaPrivateKey<'a>) -> RsaPublicKey<'a>
fn from(private_key: &RsaPrivateKey<'a>) -> RsaPublicKey<'a>
Converts to this type from the input type.
sourceimpl From<RsaPrivateKey<'_>> for RsaPrivateKeyDocument
impl From<RsaPrivateKey<'_>> for RsaPrivateKeyDocument
sourcefn from(private_key: RsaPrivateKey<'_>) -> RsaPrivateKeyDocument
fn from(private_key: RsaPrivateKey<'_>) -> RsaPrivateKeyDocument
Converts to this type from the input type.
sourceimpl<'a> From<RsaPrivateKey<'a>> for RsaPublicKey<'a>
impl<'a> From<RsaPrivateKey<'a>> for RsaPublicKey<'a>
sourcefn from(private_key: RsaPrivateKey<'a>) -> RsaPublicKey<'a>
fn from(private_key: RsaPrivateKey<'a>) -> RsaPublicKey<'a>
Converts to this type from the input type.
sourceimpl<'a> Message<'a> for RsaPrivateKey<'a>
impl<'a> Message<'a> for RsaPrivateKey<'a>
Auto Trait Implementations
impl<'a> RefUnwindSafe for RsaPrivateKey<'a>
impl<'a> Send for RsaPrivateKey<'a>
impl<'a> Sync for RsaPrivateKey<'a>
impl<'a> Unpin for RsaPrivateKey<'a>
impl<'a> UnwindSafe for RsaPrivateKey<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<'a, T> Choice<'a> for T where
T: Decodable<'a> + Encodable + Tagged,
impl<'a, T> Choice<'a> for T where
T: Decodable<'a> + Encodable + Tagged,
sourcefn can_decode(tag: Tag) -> bool
fn can_decode(tag: Tag) -> bool
Is the provided Tag
decodable as a variant of this CHOICE
?
sourceimpl<'a, M> Encodable for M where
M: Message<'a>,
impl<'a, M> Encodable for M where
M: Message<'a>,
sourcefn encoded_len(&self) -> Result<Length, Error>
fn encoded_len(&self) -> Result<Length, Error>
Compute the length of this value in bytes when encoded as ASN.1 DER.
sourcefn encode(&self, encoder: &mut Encoder<'_>) -> Result<(), Error>
fn encode(&self, encoder: &mut Encoder<'_>) -> Result<(), Error>
Encode this value as ASN.1 DER using the provided Encoder
.
sourcefn encode_to_slice(&self, buf: &'a mut [u8]) -> Result<&'a [u8], Error>
fn encode_to_slice(&self, buf: &'a mut [u8]) -> Result<&'a [u8], Error>
Encode this value to the provided byte slice, returning a sub-slice containing the encoded message. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more