pub struct RsaPublicKey { /* private fields */ }Expand description
Public key for the core RSA primitive.
Implementations§
Source§impl RsaPublicKey
impl RsaPublicKey
Sourcepub fn encrypt_raw(&self, message: &BigUint) -> BigUint
pub fn encrypt_raw(&self, message: &BigUint) -> BigUint
Apply the raw public operation m^e mod n.
This is textbook RSA’s deterministic trapdoor permutation. It performs no padding or randomness, so equal messages produce equal ciphertexts; that lack of semantic security is exactly why OAEP exists on top of the raw arithmetic.
In this crate’s generated keys, e is chosen near 65_537 (0x10001),
a sparse exponent with two set bits. That is why this operation is often
much faster than private-key decrypt_raw.
Source§impl RsaPublicKey
impl RsaPublicKey
Sourcepub fn to_pkcs1_der(&self) -> Vec<u8> ⓘ
pub fn to_pkcs1_der(&self) -> Vec<u8> ⓘ
Encode the public key as the PKCS #1 RSAPublicKey structure in DER.
Sourcepub fn to_spki_der(&self) -> Vec<u8> ⓘ
pub fn to_spki_der(&self) -> Vec<u8> ⓘ
Encode the public key as SubjectPublicKeyInfo in DER.
Sourcepub fn to_pkcs1_pem(&self) -> String
pub fn to_pkcs1_pem(&self) -> String
Encode the public key as the PKCS #1 RSA PUBLIC KEY PEM label.
Sourcepub fn to_spki_pem(&self) -> String
pub fn to_spki_pem(&self) -> String
Encode the public key as PUBLIC KEY PEM (SubjectPublicKeyInfo).
Sourcepub fn to_xml(&self) -> String
pub fn to_xml(&self) -> String
Encode the public key as the crate’s flat XML form.
This is a convenience export that mirrors the in-memory Rust fields directly. Standards-based interchange should still prefer PKCS #1 or SPKI.
Sourcepub fn from_pkcs1_der(der: &[u8]) -> Option<Self>
pub fn from_pkcs1_der(der: &[u8]) -> Option<Self>
Decode a PKCS #1 RSAPublicKey structure from DER.
Sourcepub fn from_spki_der(der: &[u8]) -> Option<Self>
pub fn from_spki_der(der: &[u8]) -> Option<Self>
Decode SubjectPublicKeyInfo 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 PUBLIC KEY PEM document.
Sourcepub fn from_spki_pem(pem: &str) -> Option<Self>
pub fn from_spki_pem(pem: &str) -> Option<Self>
Decode a PUBLIC KEY PEM document (SubjectPublicKeyInfo).
Trait Implementations§
Source§impl Clone for RsaPublicKey
impl Clone for RsaPublicKey
Source§fn clone(&self) -> RsaPublicKey
fn clone(&self) -> RsaPublicKey
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 RsaPublicKey
impl Debug for RsaPublicKey
Source§impl PartialEq for RsaPublicKey
impl PartialEq for RsaPublicKey
Source§fn eq(&self, other: &RsaPublicKey) -> bool
fn eq(&self, other: &RsaPublicKey) -> bool
self and other values to be equal, and is used by ==.