➗ Math
The mathematics I need to understand what my security tools actually do: why an SSH key can prove who you are, how an authenticator app makes its six digits, why a password must be stretched before it becomes a key. Every page works with small numbers you can check by hand (or with pow() in Python), and most have exercises with hidden answers.
🧭 Where to start
| If you want to… | Read |
|---|---|
| understand what SSH, PGP, HTTPS and S/MIME keys really do | Public-key cryptography: from the mathematics to SSH, PGP and HTTPS |
| practise until it clicks | the ✏️ practice pages, starting with clock arithmetic |
| know why primes are everywhere in cryptography | Prime numbers |
| know why real keys have 77 to 925 digits | Why 77 to 925 digits? |
| see how an authenticator app calculates its codes | How a TOTP code is calculated |
| know how a password becomes an encryption key | Key derivation functions |
🔑 The public-key cryptography series
- The mathematics: clock arithmetic, RSA, Diffie–Hellman, elliptic curves, signatures
- How an SSH connection is built
- How OpenPGP (GnuPG) encrypts and signs
- TLS, WireGuard, FIDO2 and Signal
- S/MIME: email encryption with certificates
✏️ How to use the exercises
- Work out each exercise on paper first, then click Answer.
- Every page has a PDF button (top right): a LaTeX-style print version, with all answers shown. Handy to work through offline.
- Check any number yourself in Python 3.8 or later:
pow(5, 13, 23) # 5^13 mod 23 = 21 (clock arithmetic)
pow(17, -1, 2668) # the inverse of 17 = 157 (RSA private exponent)
import math; math.gcd(2773, 2491) # 47 (a shared prime)
🔗 Where this is used
- SSH notes and SSL/OpenSSL notes: the commands that use this mathematics
- YubiKey on Linux: keeping private keys in hardware
- Contact: how to send me something confidential