Skip to content

bro256/SimpleDiffieHellmanKeyExchange

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SimpleDiffieHellmanKeyExchange

Python implementation of X25519 elliptic-curve Diffie-Hellman (ECDH) key exchange with HKDF-SHA256 key derivation, for educational purposes only.

Not production-ready. This demonstrates the math of key agreement and key derivation - it does not implement a secure protocol. In particular:

  • No authentication: nothing verifies that a public key actually belongs to the party who claims to own it. A real attacker sitting between Alice and Bob can swap in their own public keys and silently man-in-the-middle the whole exchange - ECDH's math offers zero protection against this by itself. Real-world protocols always pair ECDH with signatures, certificates, or pre-shared identity keys to bind public keys to identities.
  • No identity or transcript binding. The derived keys are bound to the two exchanged public keys via the HKDF context, but not to verified identities or a full handshake transcript - so key derivation alone still cannot detect a substituted key or a tampered handshake.
  • No replay or freshness guarantees - there's no nonce/session ID exchanged, so this alone can't detect a replayed handshake.

Use this to learn how ECDH + HKDF work mechanically. Don't use it as a template for anything that needs to resist an active attacker.

About

Python implementation of Diffie-Hellman key exchange using X25519 and HKDF key derivation, for educational purposes only. Note: this demo has no authentication and is vulnerable to man-in-the-middle attacks - it is not a secure protocol. Designed for learners exploring the core principles of key exchange.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages