This project is part of the practical coursework for the Network Security course in the Master’s program in Engineering and Computer Science at the University of Verona.
This project simulates communication between a Python Client and Server that use the Triple Diffie-Hellman (3-DH) protocol to securely establish a shared key.
The 3-DH Protocol implementation works as follows:
- Each Party Generates Key Pairs:
- Both the client and server generate a long-term and an ephemeral key pair.
- Exchange of Public Keys:
- The client and server exchange their long-term and ephemeral public keys.
- Calculation of Shared Secrets:
- Using the exchanged public keys and their own private keys, both the client and server compute three shared secrets
- Derivation of the Final Shared Key:
- The three shared secrets are concatenated and hashed to generate the final shared key.
- server.py: Python script that acts as the server. It generates the necessary parameters for the DH protocol and listens for incoming connections. Once a connection is established, it sends the parameters to the client. The two then establish a shared key using the Triple Diffie-Hellman protocol.
- client.py: Python script that acts as the client. It connects to the server, receives the parameters, and establishes a shared key using the Triple Diffie-Hellman protocol.
- functions.py (optional): Python module with auxiliary functions for key generation, encryption, and decryption.
- Open two terminals in the
src
directory. - Run the server with the command:
python3 server.py
. The server will generate the necessary parameters for the Triple Diffie-Hellman protocol and start listening for incoming connections on port12345
. - Run the client with the command:
python3 client.py
. The client will connect to the server, receive the generated parameters, and calculate the shared secret. - The client will send an encrypted message to the server, which will decrypt and display it.
pycryptodome
library for encryption.
This implementation is intended for educational purposes and to demonstrate how the Triple Diffie-Hellman protocol works. It is not intended for production use. For secure communication, it is recommended to use established cryptographic libraries and protocols.