pub struct ToyDiffieHellman {
pub p: u64,
pub g: u64,
}Expand description
Toy Diffie-Hellman parameters (prime p, generator g).
§WARNING
Educational only. Real DH requires carefully chosen safe primes and generators. This implementation is NOT secure.
Fields§
§p: u64A prime modulus p
g: u64A generator g of the multiplicative group mod p
Implementations§
Source§impl ToyDiffieHellman
impl ToyDiffieHellman
Sourcepub fn public_key(&self, private: u64) -> u64
pub fn public_key(&self, private: u64) -> u64
Compute the shared secret their_public^my_private mod p.
Both parties derive the same value: (g^a)^b = (g^b)^a mod p.
§WARNING
Educational only. Does not defend against MITM attacks without authentication.
Auto Trait Implementations§
impl Freeze for ToyDiffieHellman
impl RefUnwindSafe for ToyDiffieHellman
impl Send for ToyDiffieHellman
impl Sync for ToyDiffieHellman
impl Unpin for ToyDiffieHellman
impl UnsafeUnpin for ToyDiffieHellman
impl UnwindSafe for ToyDiffieHellman
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