This is a learning project about the Diffie-Hellman (DH) key-exchange and Advanced Encryption Standard (AES).
Goal of the project is to implement following Features
- Encrypt and save text files in an encrypted state, as well as vice versa
- Send text files via TCP using (EC) DH for key exchange followed up by AES for encryption
The subdirectory prim_roots contains a module named primitive_roots for verification of prime numbers and calculation of their primitive roots and is used for DH.
The subdirectory aes contains a module named pyaes which contains function definitions for key-expansion from key to round keys, as well as encryption and decryption of sixteen bytes, formatted as 4x4 matrix.
The aesify.py script encrypts and decrypts textfiles.
The ecdhify.py script exchanges keys per ECDH and sends a via AES encrypted file from host to client afterwards.
- Operating System: Fedora Linux 41 (Workstation Edition)
- Python: 3.12.3
- g++ (GCC): 14.2.1 (Red Hat 14.2.1-7)
build 1.2.2.post1
numpy 2.2.4
packaging 24.2
pip 25.0.1
pybind11 2.13.6
pyproject_hooks 1.2.0
setuptools 78.0.1
To install dependencies for building the C++ extensions (on Fedora) run
sudo dnf install python3-develTo install the necessary packages from the Python package index run
pip install -r requirements.txtTo build the C++ extensions run
python -m build cryptology/aes/ -n -wTo install the extensions as Python packages run
pip install cryptology/aes/dist/*.whlGiven a textfile called lore.txt containing plaintext
After running
python aesify.py -en lore.txt crypted_lore.txt you will be prompted to enter a passkey, which is expected to be expected to be 16 hexadecimal numbers in the range between 0 and FF separated by commas, like for example
0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f
To just print the contents of a previously encrypted file into the terminal run
python aesify.py -de crypted_lore.txt -pTo save the contents of a previously encrypted file as plaintext run
python aesify.py -de crypted_lore.txt decrypted_lore.txtpython ecdhify.py hpython ecdhify.py cThis project is licensed under the MIT license.