pub struct ToyRsa {
pub n: u64,
pub e: u64,
pub d: u64,
}Expand description
Toy RSA key pair (n, e, d).
§WARNING
This is a toy implementation for education only. It uses tiny parameters and is completely insecure. NEVER use for real data.
Fields§
§n: u64RSA modulus n = p * q
e: u64Public exponent e (typically 65537 in real RSA)
d: u64Private exponent d (e^{-1} mod λ(n))
Implementations§
Source§impl ToyRsa
impl ToyRsa
Sourcepub fn generate(p: u64, q: u64) -> Option<Self>
pub fn generate(p: u64, q: u64) -> Option<Self>
Generate a toy RSA key pair from two small primes p and q.
Computes n = p*q, λ(n) = lcm(p-1, q-1), chooses e=65537 (or 3 as fallback), and derives d = e^{-1} mod λ(n).
Returns None if the primes are unsuitable (e.g., gcd(e, λ(n)) ≠ 1).
§WARNING
Educational only. Real RSA requires 2048-bit+ primes.
Auto Trait Implementations§
impl Freeze for ToyRsa
impl RefUnwindSafe for ToyRsa
impl Send for ToyRsa
impl Sync for ToyRsa
impl Unpin for ToyRsa
impl UnsafeUnpin for ToyRsa
impl UnwindSafe for ToyRsa
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
Mutably borrows from an owned value. Read more