Applied Cryptography · 4 Lessons · Python & C · Free
Crypto Boundary Lab: Why Encryption Bugs Happen Around the Math
Real-world encryption failures almost never break AES (the shared-key data scrambler) or SHA-256 (the one-way digital fingerprint) math itself—they break the software boundary around it. A sender process that reboots can accidentally reuse the same one-time number (nonce) with the same key, exposing secret data. A receiver can trust an unverified packet length before checking the tamper-check stamp (authentication tag), or let an attacker replay an old signed firmware update onto a device. Using a weather station’s firmware updater as a concrete lab, you build the durable nonce log, verify-before-parse receipt gate, and C admission policy that seal every boundary.
Start the lab on your computerWhy a valid signature can still install the wrong update
Even after AES-256-GCM (an encrypted, tamper-stamped envelope) verifies that bytes were not corrupted in transit and an Ed25519 public-key sender signature proves the real publisher signed the file, the device still has to check whether the update is meant for this hardware model and carries a strictly newer version number than the software already installed.
In lesson 1 you inspect four sender requests separated by a process restart and predict which (key, nonce) pairs may be issued before writing your durable journal in boundaries.py.
Clone and start
Welcome to the weather station workshop. A weather station measures conditions outside. Today it needs new software. The sender hides each update with a shared secret, called a key, and a number it has never used with that key. Repeating the pair can expose information about the hidden contents. Your first job is to help the sender remember which numbers it used before it restarted.
You need Git and Python 3.10 or newer for the starter exercises, plus a C compiler and OpenSSL 3 headers/library (openssl@3 on macOS) for the native receiver checks:
git clone https://github.com/itsHabib/free-to-learn.git
cd free-to-learn
git switch -c my-crypto-boundary 1184b8c278c7222d9b280cd29453865719fced7c
cd courses/crypto-boundary-lab
python3 workshop.py queue
python3 lab.py preflightRecord your prediction for the four queued rows before running python3 workshop.py nonce. Read lesson 1 (download the revised lesson text) and the project README, or open reader/01.html and the offline Web Crypto byte bench at index.html directly from your clone.
From byte boundaries to a blind two-station dispatch
Across four lessons, you persist per-key nonces across restarts, verify AES-256-GCM tamper-check stamps before parsing sealed bytes, separate outer delivery labels from the publisher’s signed Ed25519 manifest, and write allow_update in policy.c to resolve a held-out two-station dispatch.
All keys, envelopes and the 956-byte compiled Linux/embedded program file (ARM ELF diagnostic payload) are synthetic classroom fixtures for offline inspection.