pub struct Rsa;Expand description
Namespace wrapper for the core RSA construction.
Implementations§
Source§impl Rsa
impl Rsa
Sourcepub fn from_primes_with_exponent(
p: &BigUint,
q: &BigUint,
exponent: &BigUint,
) -> Option<(RsaPublicKey, RsaPrivateKey)>
pub fn from_primes_with_exponent( p: &BigUint, q: &BigUint, exponent: &BigUint, ) -> Option<(RsaPublicKey, RsaPrivateKey)>
Derive a raw RSA key pair from explicit primes and an explicit exponent.
Returns None if the inputs are equal, composite, the exponent is not
greater than one, or the exponent is not invertible modulo
lambda = lcm(p - 1, q - 1).
Sourcepub fn from_primes(
p: &BigUint,
q: &BigUint,
) -> Option<(RsaPublicKey, RsaPrivateKey)>
pub fn from_primes( p: &BigUint, q: &BigUint, ) -> Option<(RsaPublicKey, RsaPrivateKey)>
Derive a raw RSA key pair from explicit primes using the Python reference’s default exponent search.
The search starts at 2^16 + 1 = 65_537, the standard sparse public
exponent: it is prime, has only two set bits, and therefore keeps the
public operation cheap. The loop then increments the power until it
finds a value coprime to lambda = lcm(p - 1, q - 1). This terminates
quickly in practice because lambda has only finitely many prime
factors, so some Fermat-like exponent in the sequence must be coprime
to it.
Sourcepub fn generate_with_exponent<R: Csprng>(
rng: &mut R,
bits: usize,
exponent: &BigUint,
) -> Option<(RsaPublicKey, RsaPrivateKey)>
pub fn generate_with_exponent<R: Csprng>( rng: &mut R, bits: usize, exponent: &BigUint, ) -> Option<(RsaPublicKey, RsaPrivateKey)>
Generate an RSA key pair from a CSPRNG and explicit public exponent.
This keeps the arithmetic primitive usable without forcing callers to provide their own prime search. The generated primes are screened with the in-tree Miller-Rabin helper rather than a dedicated external multiprecision backend, so this remains the crate’s built-in reference key-generation path rather than a substitute for a hardened PKI stack.
Sourcepub fn generate<R: Csprng>(
rng: &mut R,
bits: usize,
) -> Option<(RsaPublicKey, RsaPrivateKey)>
pub fn generate<R: Csprng>( rng: &mut R, bits: usize, ) -> Option<(RsaPublicKey, RsaPrivateKey)>
Generate an RSA key pair using the Python reference’s default exponent search.