Installing prerequisites¶
The C examples require a C11 compiler, CMake 3.18 or newer, and the OpenSSL
development headers and libraries 3.5 or newer. That OpenSSL version
provides ML-KEM and ML-DSA. CI tests the C examples against Ubuntu's OpenSSL
3.5.x and Homebrew's OpenSSL 4.x. Run build/pce --openssl-version after
building to see which library your executable loads.
The Python examples use Python 3.11 or newer. The steps below use uv to install Python 3.14 and the project's locked dependencies, including cryptography, pytest, prek, and Zensical.
Follow the section for your system. If you already have a checkout, use it where the instructions say to clone the repository.
macOS¶
- In Terminal, install Apple's Command Line Tools. Complete the installation dialog and wait for it to finish. The tools provide Clang, Git, and Make.
-
Install Homebrew using the Install Homebrew command on its home page. Follow the installer's Next steps to put
brewon your shell's PATH. Homebrew installation -
Install CMake, uv, and OpenSSL. Use Homebrew's prefix so the same commands work on Apple silicon and Intel Macs.
brew install cmake uv openssl@4
export OPENSSL_ROOT_DIR="$(brew --prefix openssl@4)"
"$OPENSSL_ROOT_DIR/bin/openssl" version
cc --version
cmake --version
uv --version
- In the same terminal, continue to Build and test on macOS or Linux.
Linux (Ubuntu and Debian)¶
- Check your distribution, then install the compiler, Make, CMake, Git, and
OpenSSL development files. Ubuntu 26.04 LTS and Debian 13 (trixie) ship
suitable OpenSSL packages. These commands use
sudo. In a root shell, omit it. Ubuntu package versions · Debian package versions
cat /etc/os-release
sudo apt update
sudo apt install build-essential cmake git curl ca-certificates pkg-config libssl-dev
pkg-config --modversion libcrypto
Check that the last command prints 3.5 or newer. Ubuntu 24.04 LTS and Debian 12 ship OpenSSL 3.0 in their standard repositories. On those releases you can install a newer OpenSSL alongside the system copy. Install Homebrew for Linux, follow its shell setup instructions, then run:
brew install openssl@3
export OPENSSL_ROOT_DIR="$(brew --prefix openssl@3)"
"$OPENSSL_ROOT_DIR/bin/openssl" version
- Install uv with Astral's installer. The second command makes uv available in the current shell when using its default installation directory. uv installation guide
- In the same shell, continue with the build below.
Build and test on macOS or Linux¶
git clone https://github.com/tleonhardt/practical_cryptography_engineering.git
cd practical_cryptography_engineering
uv python install 3.14
UV_PYTHON=3.14 make install
make test
make help
make install also installs the prek Git hook in this checkout. During
make test, look for the Found OpenSSL line in the first CMake configure
and the pytest summary at the end. If a previous configure cached an older
SDK, point CMake at the new prefix and clear its cached OpenSSL entries before
retrying:
The prefix in that command is the one exported in the Homebrew instructions.
On a distribution using the system SDK, omit the -DOPENSSL_ROOT_DIR=...
argument. After the tests pass, try authenticated encryption.
Windows¶
These instructions use native x64 Windows, PowerShell, and the Visual Studio compiler. The CMake and uv commands run directly in PowerShell.
-
Install Build Tools for Visual Studio using the Visual Studio Installer. Select Desktop development with C++ and include the x64/x86 MSVC tools, a Windows SDK, and C++ CMake tools for Windows. Microsoft Build Tools installation
-
In PowerShell, install Git, uv, and the full x64 OpenSSL development package. The development package includes the headers and import libraries CMake needs to link the C programs. OpenSSL Windows package · uv installation guide
winget install --id Git.Git --exact
winget install --id astral-sh.uv --exact
winget install --id ShiningLight.OpenSSL.Dev --exact --architecture x64
- Open a Developer PowerShell for Visual Studio from the Start menu to pick up the installed tools. Set the SDK prefix and put its DLL directory on PATH for this session. If you chose a different OpenSSL installation directory, substitute that path on the first line.
$env:OPENSSL_ROOT_DIR = "$env:ProgramFiles\OpenSSL-Win64"
$env:Path = "$env:OPENSSL_ROOT_DIR\bin;$env:Path"
Test-Path "$env:OPENSSL_ROOT_DIR\include\openssl\evp.h"
& "$env:OPENSSL_ROOT_DIR\bin\openssl.exe" version
cmake --version
uv --version
The header check should print True and the OpenSSL version should be
3.5 or newer. Use the same shell for the remaining commands.
- Clone the repository, install its locked Python dependencies and Git hook, then compile and run the interoperability tests.
git clone https://github.com/tleonhardt/practical_cryptography_engineering.git
cd practical_cryptography_engineering
uv python install 3.14
uv sync --locked --python 3.14
uv run --locked prek install
cmake -S . -B build -A x64
cmake --build build --config Release --parallel
uv run --locked pytest
- Try the README's encryption example in PowerShell. Use a new, private lab directory so the key inherits your directory permissions. The two file hashes should match.
New-Item -ItemType Directory lab
Set-Content lab/message -Value 'Hello from Python'
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.exe decrypt aes256gcm lab/key lab/sealed lab/opened 'lesson 1'
Get-FileHash lab/message, lab/opened