Skip to main content

Rsa

Struct Rsa 

Source
pub struct Rsa;
Expand description

Namespace wrapper for the core RSA construction.

Implementations§

Source§

impl Rsa

Source

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).

Source

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.

Source

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.

Source

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.

Auto Trait Implementations§

§

impl Freeze for Rsa

§

impl RefUnwindSafe for Rsa

§

impl Send for Rsa

§

impl Sync for Rsa

§

impl Unpin for Rsa

§

impl UnsafeUnpin for Rsa

§

impl UnwindSafe for Rsa

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.