Skip to content

About

Interoperable C and Python examples using OpenSSL and PyCA cryptography for authenticated encryption, key establishment, and digital signatures. Includes post-quantum ML-KEM and ML-DSA.

Topics

Resources

Stars

72 stars

Watchers

8 watching

Forks

Repository files navigation

Practical Cryptography Engineering

Encrypt a file in Python and open it in C. Sign a message in C and verify it in Python. These examples use PyCA cryptography and the OpenSSL EVP API to teach the same operations on the same bytes.

Read the documentation for setup instructions and C/Python walkthroughs.

Task Examples
Authenticated encryption AES-256-GCM and ChaCha20-Poly1305
Key establishment X25519 with HKDF-SHA-256 and post-quantum ML-KEM-768
Digital signatures Ed25519 and post-quantum ML-DSA-65
Deriving a key from a password Argon2id

Try it

Follow the prerequisite installation guide for macOS, Windows, or Ubuntu/Debian. Then try encrypting in Python and decrypting in C. From the repository root in a POSIX shell, run:

make install
make test
mkdir -p lab
printf 'Hello from Python\n' > lab/message
uv run python examples/pce.py symkey lab/key
uv run python examples/pce.py encrypt aes256gcm lab/key lab/message lab/sealed 'lesson 1'
build/pce decrypt aes256gcm lab/key lab/sealed lab/opened 'lesson 1'
cmp lab/message lab/opened

PowerShell users can run the native Windows walkthrough. Use a fresh lab directory for each run. Commands create new output files and refuse to overwrite existing ones.

Run make docs to browse the Zensical site locally. Run make help for a list of targets and descriptions.

The original examples and slides remain available for readers following the earlier presentation.

About

Interoperable C and Python examples using OpenSSL and PyCA cryptography for authenticated encryption, key establishment, and digital signatures. Includes post-quantum ML-KEM and ML-DSA.

Topics

Resources

Stars

72 stars

Watchers

8 watching

Forks

Releases

Packages

Used by

Contributors

Languages