pub struct RsaPrivateKey { /* private fields */ }Expand description
Private key for the core RSA primitive.
Implementations§
Source§impl RsaPrivateKey
impl RsaPrivateKey
Sourcepub fn decrypt_raw(&self, ciphertext: &BigUint) -> BigUint
pub fn decrypt_raw(&self, ciphertext: &BigUint) -> BigUint
Apply the raw private operation with CRT recombination.
This path is intentionally heavier than encrypt_raw: it uses large
private exponents (dP, dQ) and two CRT exponentiations to recover
throughput. Even with CRT, public encrypt is usually faster because the
public exponent is sparse.
Source§impl RsaPrivateKey
impl RsaPrivateKey
Sourcepub fn to_pkcs1_der(&self) -> Vec<u8> ⓘ
pub fn to_pkcs1_der(&self) -> Vec<u8> ⓘ
Encode the private key as the PKCS #1 RSAPrivateKey structure in DER.
§Panics
Panics only if the cached CRT values are internally inconsistent.
Sourcepub fn to_pkcs8_der(&self) -> Vec<u8> ⓘ
pub fn to_pkcs8_der(&self) -> Vec<u8> ⓘ
Encode the private key as PrivateKeyInfo (PKCS #8) in DER.
Sourcepub fn to_pkcs1_pem(&self) -> String
pub fn to_pkcs1_pem(&self) -> String
Encode the private key as PKCS #1 RSA PRIVATE KEY PEM.
Sourcepub fn to_pkcs8_pem(&self) -> String
pub fn to_pkcs8_pem(&self) -> String
Encode the private key as PRIVATE KEY PEM (PKCS #8).
Sourcepub fn to_xml(&self) -> String
pub fn to_xml(&self) -> String
Encode the private key as the crate’s flat XML form.
The XML form mirrors the stored key fields directly. PKCS #1 / PKCS #8 remain the preferred interoperable formats.
Sourcepub fn from_pkcs1_der(der: &[u8]) -> Option<Self>
pub fn from_pkcs1_der(der: &[u8]) -> Option<Self>
Decode a PKCS #1 RSAPrivateKey structure from DER.
Sourcepub fn from_pkcs8_der(der: &[u8]) -> Option<Self>
pub fn from_pkcs8_der(der: &[u8]) -> Option<Self>
Decode PrivateKeyInfo (PKCS #8) from DER.
Sourcepub fn from_pkcs1_pem(pem: &str) -> Option<Self>
pub fn from_pkcs1_pem(pem: &str) -> Option<Self>
Decode a PKCS #1 RSA PRIVATE KEY PEM document.
Sourcepub fn from_pkcs8_pem(pem: &str) -> Option<Self>
pub fn from_pkcs8_pem(pem: &str) -> Option<Self>
Decode a PRIVATE KEY PEM document (PKCS #8).
Trait Implementations§
Source§impl Clone for RsaPrivateKey
impl Clone for RsaPrivateKey
Source§fn clone(&self) -> RsaPrivateKey
fn clone(&self) -> RsaPrivateKey
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RsaPrivateKey
impl Debug for RsaPrivateKey
Source§impl PartialEq for RsaPrivateKey
impl PartialEq for RsaPrivateKey
Source§fn eq(&self, other: &RsaPrivateKey) -> bool
fn eq(&self, other: &RsaPrivateKey) -> bool
self and other values to be equal, and is used by ==.