Struct pkcs1::RsaPrivateKey
source · pub struct RsaPrivateKey<'a> {
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>,
pub other_prime_infos: Option<OtherPrimeInfos<'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
}
Note: the version field is selected automatically based on the absence or
presence of the other_prime_infos field.
Fields§
§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.
other_prime_infos: Option<OtherPrimeInfos<'a>>Additional primes r_3, …, r_u, in order, if this is a multi-prime
RSA key (i.e. version is multi).
Implementations§
source§impl<'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 version(&self) -> Version
pub fn version(&self) -> Version
Get the Version for this key.
Determined by the presence or absence of the
RsaPrivateKey::other_prime_infos field.
sourcepub fn to_der(&self) -> Result<RsaPrivateKeyDocument>
pub fn to_der(&self) -> Result<RsaPrivateKeyDocument>
Encode this RsaPrivateKey as ASN.1 DER.
sourcepub fn to_pem(&self, line_ending: LineEnding) -> Result<Zeroizing<String>>
pub fn to_pem(&self, line_ending: LineEnding) -> Result<Zeroizing<String>>
Encode this RsaPrivateKey as PEM-encoded ASN.1 DER using the given
LineEnding.
Trait Implementations§
source§impl<'a> Clone for RsaPrivateKey<'a>
impl<'a> Clone for RsaPrivateKey<'a>
source§fn clone(&self) -> RsaPrivateKey<'a>
fn clone(&self) -> RsaPrivateKey<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl<'a> Debug for RsaPrivateKey<'a>
impl<'a> Debug for RsaPrivateKey<'a>
source§impl<'a> Decodable<'a> for RsaPrivateKey<'a>
impl<'a> Decodable<'a> for RsaPrivateKey<'a>
source§impl<'a> From<&RsaPrivateKey<'a>> for RsaPublicKey<'a>
impl<'a> From<&RsaPrivateKey<'a>> for RsaPublicKey<'a>
source§fn from(private_key: &RsaPrivateKey<'a>) -> RsaPublicKey<'a>
fn from(private_key: &RsaPrivateKey<'a>) -> RsaPublicKey<'a>
source§impl<'a> From<RsaPrivateKey<'a>> for RsaPublicKey<'a>
impl<'a> From<RsaPrivateKey<'a>> for RsaPublicKey<'a>
source§fn from(private_key: RsaPrivateKey<'a>) -> RsaPublicKey<'a>
fn from(private_key: RsaPrivateKey<'a>) -> RsaPublicKey<'a>
source§impl<'a> Sequence<'a> for RsaPrivateKey<'a>
impl<'a> Sequence<'a> for RsaPrivateKey<'a>
source§impl<'a> TryFrom<&'a [u8]> for RsaPrivateKey<'a>
impl<'a> TryFrom<&'a [u8]> for RsaPrivateKey<'a>
source§impl TryFrom<&RsaPrivateKey<'_>> for RsaPrivateKeyDocument
impl TryFrom<&RsaPrivateKey<'_>> for RsaPrivateKeyDocument
source§fn try_from(private_key: &RsaPrivateKey<'_>) -> Result<RsaPrivateKeyDocument>
fn try_from(private_key: &RsaPrivateKey<'_>) -> Result<RsaPrivateKeyDocument>
source§impl TryFrom<RsaPrivateKey<'_>> for RsaPrivateKeyDocument
impl TryFrom<RsaPrivateKey<'_>> for RsaPrivateKeyDocument
source§fn try_from(private_key: RsaPrivateKey<'_>) -> Result<RsaPrivateKeyDocument>
fn try_from(private_key: RsaPrivateKey<'_>) -> Result<RsaPrivateKeyDocument>
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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Encodable for Twhere
T: EncodeValue + Tagged,
impl<T> Encodable for Twhere
T: EncodeValue + Tagged,
source§fn 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.
source§fn 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.