↓ Skip to main content
Security

My cryptography cheat sheet

While writing about the locks behind HTTPS and the quantum threat, I kept opening the same tabs to check what GCM was, which curve prime256v1 is, or how big a SHA-384 is. This page is those tabs, folded into one sheet.
A one-page cheat sheet in five panels. The three jobs: agree a key, prove who’s talking, encrypt the data, with hashes throughout. AES modes: ECB repeats patterns, CBC chains blocks, CTR uses a counter, GCM adds a tag; never reuse an IV with the same key. Reading TLS_AES_128_GCM_SHA256: protocol, cipher and key size, mode, hash for HKDF. Hashes: SHA-256, SHA-384, SHA-512 sizes. New locks: ML-KEM, ML-DSA, SLH-DSA.
The tabs I kept open, on one page

It’s a refresher, not a course: one line per word, and the standard it comes from. The story behind most of these starts in The locks I use without noticing. If symmetric, asymmetric, cipher and mode are new words, the update to my SSL/TLS post explains them properly, and the update to my Handshake post shows them in a real capture.

The three jobs
#

JobFamilyNames you’ll meet
Agree a key with a strangerPublic-keyDiffie-Hellman, ECDH, X25519, RSA, ML-KEM
Prove who’s talkingPublic-keyRSA, ECDSA, EdDSA (Ed25519), ML-DSA, SLH-DSA
Encrypt the dataShared-key (symmetric)AES, ChaCha20
Prove nothing changedShared-key sideSHA-256, HMAC, the GCM tag

Rule of thumb: a large quantum computer threatens the first two rows, not the last two.

AES and its modes
#

AES comes in three sizes, AES-128, AES-192 and AES-256; each “transforms data in blocks of 128 bits”, and the number is the key length (FIPS 197). A block cipher on its own handles one 16-byte block. A mode says how to use it on a whole message.

ModeOne lineWatch out
ECB (Electronic Codebook)Each block encrypted on its own, like looking it up in a codebookThe same block always gives the same output, so patterns show
CBC (Cipher Block Chaining)Each block mixed with the previous encrypted blockNeeds an IV that is unpredictable
CTR (Counter)Encrypts a counter and XORs the result with the dataEvery counter must be different, across all messages under one key
GCM (Galois/Counter Mode)Counter mode for secrecy plus a tag that proves nothing changedNever reuse an IV with the same key

ECB, CBC and CTR come from SP 800-38A, which warns that in ECB “any given plaintext block always gets encrypted to the same ciphertext block”. GCM comes from SP 800-38D:

  • What it gives: confidentiality “using a variation of the Counter mode”, and authenticity “using a universal hash function”.
  • Sizes: an IV of 96 bits is recommended; the tag is normally 128, 120, 112, 104 or 96 bits.
  • The one rule: if an IV is ever repeated under the same key, the implementation “may be vulnerable to the forgery attacks”; the rule “is almost as important as the secrecy of the key”.

AEAD: lock and seal in one step
#

AEAD (authenticated encryption with associated data) is what GCM is an example of. “Both confidentiality and message authentication are provided”, and the associated data is information “that needs to be authenticated, but does not need to be kept confidential”, such as a header (RFC 5116). ChaCha20-Poly1305 is the other common AEAD: a stream cipher plus an authenticator (RFC 8439).

In TLS 1.3 “all ciphers are modeled as” AEAD (RFC 9846, section 5.2). Each record’s nonce is the record’s sequence number XORed with a fixed IV, so it never repeats under one key (section 5.3).

Reading a TLS 1.3 cipher suite
#

“A cipher suite defines the pair of the AEAD algorithm and hash algorithm to be used with HKDF” (RFC 9846, appendix B.4). So TLS_AES_128_GCM_SHA256 reads as:

PartMeaning
TLSThe protocol
AES_128_GCMThe AEAD: AES with a 128-bit key in GCM mode
SHA256The hash used to derive keys (HKDF) and fingerprint the handshake
SuiteStatus in RFC 9846
TLS_AES_128_GCM_SHA256MUST implement
TLS_AES_256_GCM_SHA384SHOULD
TLS_CHACHA20_POLY1305_SHA256SHOULD
TLS_AES_128_CCM_SHA256, TLS_AES_128_CCM_8_SHA256Also defined

No key exchange or signature in the name: in TLS 1.3 those are agreed separately (the Peer Temp Key and Peer signature type lines in OpenSSL’s output).

Hashes and what’s built on them
#

NameOutputOne lineStandard
SHA-256256 bitsThe everyday fingerprintFIPS 180-4
SHA-384384 bitsSame family, longer outputFIPS 180-4
SHA-512512 bitsSame family, longest outputFIPS 180-4
SHA-3 (SHA3-256 etc.)224 to 512 bitsA different design, a second familyFIPS 202
SHAKE128 / SHAKE256As long as you ask“Extendable-output functions” from the SHA-3 familyFIPS 202
HMACThe hash’s sizeA hash mixed with a shared key, to prove who sent a messageRFC 2104
HKDFAs long as you askTurns a shared secret into keys, by “extract-then-expand”; TLS 1.3 derives all its keys this wayRFC 5869
MGF1As long as you ask“A mask generation function based on a hash function”, used inside RSA-OAEP and RSA-PSSRFC 8017

SHA-2 is the family name for SHA-256, SHA-384 and SHA-512.

Agreeing a key
#

NameOne lineSize to remember
Diffie-Hellman (1976)Mixing paint in public; both sides end with the same secret
ECDHDiffie-Hellman on an elliptic curve
X25519 / X448The modern ECDH functions from RFC 7748X25519: 32-byte keys
RSA (1977)Open padlocks: anyone can lock, only the key holder can open
RSA-OAEPThe padding for RSA encryption, “REQUIRED to be supported for new applications” (RFC 8017)
KEMKey-encapsulation mechanism: I lock a fresh secret with your public key and send it
ML-KEM-768The post-quantum KEM (FIPS 203)Public key 1,184 bytes, ciphertext 1,088, secret 32
X25519MLKEM768The hybrid: X25519 and ML-KEM together, safe if either holds

Proving who’s talking
#

NameOne lineSize to remember
RSA-PSSRSA signatures with randomised padding, “REQUIRED in new applications” (RFC 8017)
ECDSASignatures on an elliptic curve, usually P-256 or P-384
Ed25519 / Ed448EdDSA signatures (RFC 8032)Ed25519: 32-byte key, 64-byte signature
ML-DSA-65The main post-quantum signature (FIPS 204)Public key 1,974 bytes, signature 3,309
SLH-DSAThe hash-based backup (FIPS 205)SLH-DSA-SHA2-128s: 50-byte key, 7,856-byte signature
LMS / XMSSOlder hash-based signatures; “stateful”, so the signer must track which keys it has used (SP 800-208)

The post-quantum sizes are from my own runs with Go and OpenSSL 3.5.

One curve, three names. Tools print the same curves differently (RFC 8422, table 4):

SECGANSI X9.62NIST
secp256r1prime256v1P-256
secp384r1P-384

So ecdsa_secp256r1_sha256 in OpenSSL’s output means ECDSA on P-256 with SHA-256.

The new locks
#

NameWasJobStatus
ML-KEM (FIPS 203)CRYSTALS-KyberAgree a keyStandard, August 2024
ML-DSA (FIPS 204)CRYSTALS-DilithiumSignStandard, August 2024
SLH-DSA (FIPS 205)SPHINCS+Sign, hash-based backupStandard, August 2024
FN-DSA (FIPS 206)FALCONSignAnnounced
HQCAgree a key, a backup built on different mathsSelected March 2025
FrodoKEM, Classic McEliece, BIKEAgree a keyAlternatives in Open Quantum Safe
WordOne line
Shor’s algorithmThe quantum algorithm that breaks factoring and discrete logarithms, so RSA, ECDH and ECDSA
CRQCA cryptographically relevant quantum computer: one big enough to run Shor on real keys
Harvest now, decrypt laterRecording encrypted traffic today to read it once a CRQC exists
2030 / 2035NIST plans to deprecate today’s public-key algorithms after 2030 and disallow them after 2035 (IR 8547)
HybridClassic and post-quantum together, during the move
Crypto agilityBeing able to swap algorithms without rewriting the application

TLS and trust
#

WordOne line
TLS 1.3The protocol behind HTTPS; first RFC 8446 (2018), now RFC 9846 (July 2026), same version
Key shareEach side’s half of the key exchange in the first messages
Key updateChanging keys during a long connection
Certificate chainSignatures linking a server’s key to a root you already trust
Root certificate / trust storeThe roots your system trusts, and the list that holds them
mTLSThe client presents a certificate too
HTTPS interceptionA product that ends your connection and opens its own to the server (what that did to my test)
RFCA numbered internet document; replaced by a new number, never edited (TLS 1.3’s new edition)

Finding the crypto you use
#

WordOne line
SBOMA list of the software components in a product
CBOMThe same idea for cryptography: algorithms, keys, certificates and protocols, and where they’re used
CycloneDXThe SBOM format that CBOM is part of
bom-refThe ID one entry in the list uses to point to another
OIDA dotted number that names an algorithm unambiguously
CBOMkitThe PQCA’s toolset for making and checking CBOMs
OPA / RegoA policy engine and its language, used to grade a CBOM
PQCAThe Post-Quantum Cryptography Alliance, under the Linux Foundation
liboqsOpen Quantum Safe’s library of post-quantum algorithms, for experiments rather than production

Takeaways
#

  • Three jobs: agree a key, prove who’s talking, protect the data. Quantum threatens the first two.
  • A mode turns AES into something usable; GCM encrypts and seals at once, and must never reuse an IV with one key.
  • A TLS 1.3 cipher suite names only the AEAD and the hash; the key exchange and signature are agreed separately.
  • secp256r1, prime256v1 and P-256 are the same curve.
  • The new locks are ML-KEM, ML-DSA and SLH-DSA, with HQC and FN-DSA to follow.

References
#

Author
Samarthya
Engineer, learner, tinkerer. This is my trophy shelf of everyday work and leisure.

Related

My antivirus answered for GitHub

··7 mins
I wrote a small program to check whether GitHub already uses post-quantum key exchange. It said yes. I was about to write that down as a fact when a different tool gave me a different answer, and the reason was sitting on my own machine. Two connections, one of them hidden A result that looked too good # While writing about the locks I use without noticing I wanted one line of evidence: which key exchange does a real site use today? Go makes that easy. Since Go 1.25 a connection reports the key-exchange group it used, and Python can do the same since 3.15, so this is the whole program in either:

The locks I use without noticing

··9 mins
I type gh pr list dozens of times a day. The answer comes back in under a second from a server I’ve never met, and nobody in between can read it or change it. One evening I got curious about what actually happens in that second. Three jobs, four families Following one command onto the wire # First, where does gh go? Its debug switch shows every request:

Saved today, read tomorrow

In 1943 the US Army started keeping copies of Soviet telegrams it couldn’t read. Some of them were read years later, and they named spies. I think of that story every time someone tells me quantum computers are “still years away”. If names like RSA, X25519 or ECDSA are new to you, the primer explains what each one does, in plain words.