Modern cryptosystems
Computers changed everything. Ciphers now work on bits rather than letters, keys are hundreds of bits long, and in 1976 a new idea solved the problem that had dogged cryptography for 3,000 years: how to agree a secret with someone you've never met.
Milestones
- 1949
Claude Shannon's Communication Theory of Secrecy Systems puts cryptography on a mathematical footing. - 1977
DES becomes the US federal standard, based on IBM's Lucifer (Horst Feistel). - 1976–1977
Diffie and Hellman publish public-key key exchange, and Rivest, Shamir and Adleman publish RSA. GCHQ's James Ellis, Clifford Cocks and Malcolm Williamson had found the same ideas a few years earlier, but their work stayed classified until 1997. - 1985
Koblitz and Miller independently propose elliptic-curve cryptography. - 1998
The EFF's "Deep Crack" machine brute-forces a DES key in 56 hours. - 2001
AES (Rijndael, by Belgian cryptographers Daemen and Rijmen) replaces DES after an open international competition. - 2017
Google and CWI publish SHAttered, the first practical SHA-1 collision. - 2024
NIST publishes its first post-quantum standards: FIPS 203 (ML-KEM), 204 (ML-DSA) and 205 (SLH-DSA).
Symmetric ciphers
| Algorithm | Type | Key | Status |
|---|---|---|---|
| DES | 64-bit block, Feistel network, 16 rounds | 56-bit | broken Brute-forceable. |
| 3DES | DES three times (encrypt-decrypt-encrypt) | 112/168-bit | retired NIST disallowed it for encryption after 2023. Its 64-bit block is open to Sweet32. |
| RC4 | Stream cipher | 40–2048-bit | broken Biased keystream. Used in WEP, WPA-TKIP and old TLS. |
| AES | 128-bit block, substitution-permutation network | 128/192/256-bit | standard Hardware-accelerated (AES-NI) on almost every CPU. |
| ChaCha20 | Stream cipher (add-rotate-XOR) | 256-bit | standard Fast in software on phones without AES hardware. |
What happens inside an AES round?
AES arranges each 16-byte block as a 4×4 grid and repeats four steps 10, 12 or 14 times:
- SubBytes: every byte goes through a fixed substitution table, the S-box (confusion).
- ShiftRows: each row is rotated by a different amount (diffusion across columns).
- MixColumns: each column is mixed so every output byte depends on all four input bytes (diffusion).
- AddRoundKey: the block is XORed with a round key derived from the main key.
After two rounds every output bit depends on every input bit. That's the avalanche effect from Chapter 02.
Salt · IV (nonce) · ciphertext + 128-bit authentication tag
Encrypt the same text twice and you get different ciphertext, thanks to the random salt and IV. Tamper with it and GCM's tag check rejects the whole message. That's authenticated encryption at work.
Public-key (asymmetric) cryptography
Think of a padlock you can hand out freely. Anyone can snap it shut (encrypt with your public key), but only you have the key that opens it (decrypt with your private key). Run it the other way round and you get signatures: only you can make a mark with your private key, and anyone can check it with your public key.
This works because of trapdoor functions: maths that's easy one way and practically impossible to reverse without a secret.
- RSA: multiplying two large primes is easy, but factoring the product back into those primes is very hard.
- Diffie-Hellman: raising a number to a power modulo a prime is easy, but recovering the exponent (the discrete logarithm) is very hard.
- Elliptic curves: the same idea on the points of a curve, which gives much smaller keys for the same strength.
Diffie-Hellman key exchange
DH lets two people agree a shared secret over a channel an eavesdropper can watch. It's often explained with paint. Mixing colours is easy, but un-mixing them is practically impossible.
👩 Alice
👨 Bob
👁 Eve sees the public colour and both mixes, but she can't separate the secret colours out of them. Alice and Bob end up with the same final colour.
Now with real (tiny) numbers
Real DH uses 2048-bit or larger primes, or elliptic curves like X25519. At that size, working back from A to a is far beyond any computer.
RSA
Real RSA uses primes over 1,000 bits each, and always pads messages (OAEP for encryption, PSS for signatures). Without padding it's insecure.
Elliptic-curve cryptography (ECC)
ECC gives the same security as RSA with far smaller keys. That means faster handshakes, less bandwidth and less battery drain, which is why modern TLS, SSH, Signal and WPA3 prefer it. Common curves include X25519/Ed25519 (Curve25519) and NIST P-256/P-384.
| Security level | Symmetric | RSA / DH | ECC |
|---|---|---|---|
| 112-bit | 3DES | 2048-bit | 224-bit |
| 128-bit | AES-128 | 3072-bit | 256-bit |
| 192-bit | AES-192 | 7680-bit | 384-bit |
| 256-bit | AES-256 | 15360-bit | 512-bit |
Comparable strengths from NIST SP 800-57 Part 1.
Hashing, MACs and AEAD
A cryptographic hash turns any input into a fixed-length digest. A good hash is:
- Pre-image resistant: you can't find an input from its hash (one-way).
- Second pre-image resistant: you can't find a different input with the same hash as a given one.
- Collision resistant: you can't find any two inputs with the same hash. Thanks to the birthday paradox, an n-bit hash gives only about n/2 bits of collision resistance, so SHA-256 gives about 128.
Change one character and every digest changes completely. MD5 (128-bit) and SHA-1 (160-bit) are broken for collisions and aren't available in the browser's Web Crypto API. Use the SHA-2 or SHA-3 families.
MAC / HMAC
A hash mixed with a secret key. It proves integrity and that the sender knows the key. HMAC-SHA256 is everywhere, from API signatures to TLS 1.2 record protection.
AEAD
Authenticated Encryption with Associated Data, such as AES-GCM or ChaCha20-Poly1305, encrypts and authenticates in one step. TLS 1.3 allows only AEAD ciphers.
Password hashing
Plain SHA-256 is far too fast for passwords. Use Argon2id, scrypt, bcrypt or PBKDF2 with a unique salt for each user.
Post-quantum cryptography
A large enough quantum computer running Shor's algorithm could solve factoring and discrete logarithms efficiently, which would break RSA, DH and ECC. Symmetric crypto and hashes are much less exposed: Grover's algorithm roughly halves their effective strength, which AES-256 easily absorbs.
No such quantum computer exists yet, but there's a "harvest now, decrypt later" threat. An adversary can record encrypted traffic today and decrypt it years from now. So migration has already started:
- ML-KEM (FIPS 203, formerly Kyber), a lattice-based key encapsulation mechanism that replaces DH/ECDH for key exchange.
- ML-DSA (FIPS 204, formerly Dilithium) and SLH-DSA (FIPS 205, formerly SPHINCS+) for signatures.
- Hybrid key exchange (for example
X25519MLKEM768) combines classical and post-quantum algorithms, so the connection stays safe if either one holds. Major browsers and CDNs, including Cloudflare, already use it by default for a large share of TLS traffic.