ciphers.diffie_hellman¶
Attributes¶
Classes¶
Class to represent the Diffie-Hellman key exchange protocol |
Module Contents¶
- class ciphers.diffie_hellman.DiffieHellman(group: int = 14)¶
Class to represent the Diffie-Hellman key exchange protocol
>>> alice = DiffieHellman() >>> bob = DiffieHellman()
>>> alice_private = alice.get_private_key() >>> alice_public = alice.generate_public_key()
>>> bob_private = bob.get_private_key() >>> bob_public = bob.generate_public_key()
>>> # generating shared key using the DH object >>> alice_shared = alice.generate_shared_key(bob_public) >>> bob_shared = bob.generate_shared_key(alice_public)
>>> assert alice_shared == bob_shared
>>> # generating shared key using static methods >>> alice_shared = DiffieHellman.generate_shared_key_static( ... alice_private, bob_public ... ) >>> bob_shared = DiffieHellman.generate_shared_key_static( ... bob_private, alice_public ... )
>>> assert alice_shared == bob_shared
- generate_public_key() str ¶
- get_private_key() str ¶
- is_valid_public_key(key: int) bool ¶
- static is_valid_public_key_static(remote_public_key_str: int, prime: int) bool ¶
- __private_key¶
- generator = 2¶
- prime¶
- ciphers.diffie_hellman.primes¶