Cryptography fundamentals: 50 cards on ciphers, hashes and TLS
Cryptography flashcards: AES modes, RSA, elliptic curves, Diffie–Hellman, hashing, HMAC, signatures, password hashing, TLS 1.3 and common pitfalls.
Practice now
Study without an account
Scheduled with the default Askesis timings. Progress is saved in this browser.
All 50 cards
- 1Kerckhoffs’s principleA cryptosystem should stay secure even if everything about it except the key is publicSecurity has to come from the secrecy of the key, not of the algorithm. Shannon put it as “the enemy knows the system”.
- 2Symmetric vs asymmetric encryptionSymmetric encryption uses one shared secret key to encrypt and decrypt; asymmetric encryption uses a key pair, a public key to encrypt and a private key to decryptSymmetric ciphers are far faster, so real systems use public-key cryptography only to agree on a symmetric key, then encrypt the data with it (hybrid encryption).
- 3One-time padXOR the message with a truly random key as long as the message, used only once; done right, it is unbreakable even in principle (perfect secrecy)Reusing the pad breaks it: XORing two ciphertexts cancels the key and leaves the XOR of the two plaintexts.
- 4Block cipher vs stream cipherA block cipher encrypts fixed-size blocks and needs a mode of operation for longer messages; a stream cipher XORs the message with a keystream generated from a key and a nonceAES is a block cipher; ChaCha20 is a stream cipher.
- 5AES block size and key sizes128-bit blocks; 128-, 192- or 256-bit keysIt runs 10, 12 or 14 rounds depending on the key size. NIST standardized AES (the Rijndael cipher) in 2001.
- 6Why is ECB mode insecure?It encrypts each block independently, so identical plaintext blocks give identical ciphertext blocks and patterns in the data show throughThe classic demonstration is an image encrypted in ECB mode whose outline is still clearly visible.
- 7CBC modeEach plaintext block is XORed with the previous ciphertext block before encryption; the first block uses a random, unpredictable IVCBC provides confidentiality only. Without a MAC it is open to padding oracle attacks.
- 8Padding oracle attackIf a system reveals whether the padding of decrypted CBC ciphertext is valid, through an error message or timing, an attacker can decrypt data byte by byte without the keyPrevent it by verifying a MAC before decrypting, or by using an AEAD mode.
- 9CTR modeEncrypts successive counter blocks (a nonce plus a block number) to make a keystream, then XORs it with the plaintextIt needs no padding and runs in parallel, but a nonce must never repeat under the same key.
- 10Does encryption alone stop tampering?No. Without authentication, ciphertext is malleable: flipping a bit of CTR or stream-cipher ciphertext flips the same bit of the plaintextThat is why modern designs use authenticated encryption.
- 11Authenticated encryption with associated data (AEAD)Encryption that guarantees both confidentiality and integrity, and can also authenticate unencrypted associated data such as headersDecryption fails if the ciphertext, tag or associated data were changed. TLS 1.3 allows only AEAD ciphers.
- 12AES-GCMAES in counter mode plus a GHASH authentication tag: the most widely used AEAD modeIts standard nonce is 96 bits, and its tag is usually 128 bits.
- 13What happens if an AES-GCM nonce repeats under the same key?The keystream repeats, revealing the XOR of the two plaintexts, and an attacker can recover the authentication key and forge messagesWith random 96-bit nonces, NIST limits one key to messages.
- 14ChaCha20-Poly1305An AEAD that pairs the ChaCha20 stream cipher with the Poly1305 authenticator; fast and constant-time in software, even without AES hardwareUsed in TLS 1.3, SSH and WireGuard, and specified in RFC 8439.
- 15Encrypt-then-MACEncrypt first, then compute a MAC over the ciphertext and IV; the receiver checks the MAC before decrypting anythingOf the ways to combine a cipher with a MAC, it is the one that is secure in general. AEAD modes handle this for you.
- 16What hard problem is RSA based on?Factoring: recovering the primes and from their productUse keys of at least 2048 bits; 3072 bits gives about 128-bit security.
- 17Textbook RSA encryption and decryptionand , whereRaw RSA is deterministic and malleable, so real systems always add padding. The public exponent e is usually 65537.
- 18RSA padding for encryption and for signaturesOAEP for encryption, PSS for signaturesThe older PKCS #1 v1.5 encryption padding is open to Bleichenbacher’s padding oracle attack.
- 19Elliptic-curve cryptography (ECC)Public-key cryptography based on the elliptic-curve discrete logarithm problem: given points and , finding is infeasibleKeys are much smaller than RSA keys of the same strength: a 256-bit curve such as P-256 gives about 128-bit security, like 3072-bit RSA.
- 20X25519 and Ed25519X25519 is Diffie–Hellman key agreement on Curve25519; Ed25519 is a signature scheme on an equivalent form of the same curveBoth were designed to be fast and hard to implement wrongly. Ed25519 signatures are deterministic, so they need no random nonce.
- 21Diffie–Hellman key exchangeEach side picks a secret exponent and sends or ; both then compute , which an eavesdropper can’tIts security rests on the discrete logarithm problem. ECDH is the same idea on an elliptic curve.
- 22Why must a Diffie–Hellman exchange be authenticated?Otherwise a man-in-the-middle can run a separate exchange with each side and read everything; signatures and certificates prove who sent each public value
- 23Why would a large quantum computer break RSA and elliptic curves?Shor’s algorithm factors integers and solves discrete logarithms efficientlyNIST published post-quantum standards in 2024: ML-KEM for key exchange and ML-DSA for signatures. Symmetric ciphers are far less affected; AES-256 stays secure.
- 24Cryptographic hash functionMaps input of any length to a fixed-length digest; it is deterministic and fast, but infeasible to invert or to find two inputs with the same outputSHA-256 produces a 256-bit (32-byte) digest.
- 25Preimage, second-preimage and collision resistancePreimage: given a digest, you can’t find an input for it. Second preimage: given an input, you can’t find another with the same digest. Collision: you can’t find any two inputs with the same digest
- 26Birthday bound for hash collisionsCollisions in an -bit hash turn up after about tries, so SHA-256 offers about 128-bit collision resistance
- 27SHA-2 familySHA-224, SHA-256, SHA-384 and SHA-512, plus the truncated SHA-512/224 and SHA-512/256, built on the Merkle–Damgård constructionSHA-256 remains a sound default; no practical attacks on the full SHA-2 functions are known.
- 28SHA-3The hash standard based on Keccak, published in 2015 (FIPS 202); it uses a sponge construction and was chosen as an alternative to SHA-2, not because SHA-2 was brokenIt resists length-extension attacks, and its SHAKE128 and SHAKE256 variants produce output of any length.
- 29Length-extension attackWith SHA-256 or SHA-512, anyone who knows can compute for any without knowing the secretThey only need the secret’s length, which is easy to guess. Use HMAC instead of hashing a secret prefix.
- 30Status of MD5 and SHA-1Broken: practical collisions exist for both, so never use them for signatures, certificates or anything that needs collision resistanceThe first public SHA-1 collision (SHAttered) was announced in 2017; MD5 collisions take seconds on a laptop.
- 31Message authentication code (MAC)A tag computed from a message and a shared secret key; it proves the message came from a key holder and wasn’t alteredUnlike a signature, it can’t prove to a third party who made it: anyone who can verify a MAC can also create one.
- 32HMACThe nested hashing makes it immune to length extension. Compare tags in constant time: an early-exit comparison leaks through timing how many bytes matched.
- 33Digital signatureMade with a private key and checked with the matching public key; it proves who signed and that the data hasn’t changed, and the signer can’t later deny itCommon schemes: RSA-PSS, ECDSA and Ed25519.
- 34What happens if an ECDSA nonce is reused or predictable?Anyone with the signatures can compute the private keyThis is how the PlayStation 3 signing key was recovered in 2010. Deterministic nonces (RFC 6979) or Ed25519 avoid the problem.
- 35Why not store passwords as SHA-256 hashes?General-purpose hashes are built to be fast, so attackers with GPUs can test billions of guesses per second; passwords need a slow, salted password-hashing function
- 36Which password-hashing algorithm should you choose?Argon2id; scrypt if Argon2id is unavailable; bcrypt for legacy systems; PBKDF2 when FIPS-140 compliance is requiredThis is the order OWASP recommends.
- 37Argon2The winner of the 2015 Password Hashing Competition: a memory-hard function whose cost is tuned by memory, iterations and parallelismUse the Argon2id variant. OWASP’s minimum is 19 MiB of memory, 2 iterations and a parallelism of 1.
- 38bcryptA password hash based on the Blowfish cipher, with a cost factor that doubles the work for each incrementIt only uses the first 72 bytes of a password. OWASP recommends a cost of at least 10.
- 39scryptA memory-hard key derivation function by Colin Percival (2009), tuned by N (CPU and memory cost), r (block size) and p (parallelism)Needing lots of memory makes GPU and ASIC cracking expensive. OWASP’s minimum is , , .
- 40SaltA unique random value stored with each password hash, so identical passwords hash differently and precomputed tables such as rainbow tables are uselessSalts aren’t secret. A pepper is an extra secret kept outside the database, for example in a key vault.
- 41NonceA “number used once”: a value that must never repeat under the same key, though it usually needn’t be secretSome schemes need more: a CBC IV must also be unpredictable.
- 42Where should keys and other secret random values come from?The operating system’s cryptographically secure random number generator, never a general-purpose generator such as
Math.random()or the Mersenne TwisterFor examplegetrandom()on Linux,crypto.getRandomValues()in browsers and thesecretsmodule in Python. - 43HKDFAn HMAC-based key derivation function: it extracts a uniform key from input key material such as a Diffie–Hellman output, then expands it into as many keys as neededTLS 1.3 derives all its keys with HKDF (RFC 5869).
- 44TLS 1.3 full handshake, in outlineThe client sends ClientHello with its key shares; the server replies with ServerHello and its key share, then, already encrypted, its certificate, a CertificateVerify signature and Finished; the client answers with Finished. One round trip in allBoth sides derive the session keys from an ephemeral (EC)DHE exchange.
- 45TLS 1.3 0-RTT dataWhen resuming a session, a client can send application data in its first message, but an attacker can replay it, so it should only carry requests that are safe to repeat
- 46What did TLS 1.3 remove?Static RSA and static Diffie–Hellman key exchange, all non-AEAD ciphers (such as CBC modes and RC4), compression and renegotiationWith static RSA gone, every full handshake uses ephemeral key exchange and so has forward secrecy.
- 47Forward secrecyStealing a server’s long-term private key later doesn’t expose past sessions, because each session key came from an ephemeral key exchange and was then discarded
- 48X.509 certificateA signed document that binds a public key to an identity such as a domain name, issued by a certificate authority, with a validity period and extensionsBrowsers check the hostname against the Subject Alternative Name extension, not the Common Name.
- 49Chain of trustThe server sends its certificate and any intermediates; the client checks each signature up to a root CA certificate already in its trust storeRoot keys are kept offline; intermediate CAs do the day-to-day signing.
- 50“Don’t roll your own crypto”: what to do insteadUse well-reviewed libraries and high-level APIs, such as libsodium or your platform’s crypto library, with standard algorithms and protocolsMost real-world breaks come from misuse, such as repeated nonces, missing authentication or unchecked certificates, rather than from broken algorithms.
Frequently asked questions
Do I need advanced math for this deck?
No. RSA and Diffie–Hellman appear as short formulas, but the cards focus on what each tool does and when to use it.
Is the advice up to date?
Yes: AEAD ciphers such as AES-GCM, Argon2id for passwords, TLS 1.3 and the 2024 post-quantum standards. Outdated choices like ECB, MD5 and SHA-1 appear only as things to avoid.
Who is this deck for?
Developers and security engineers who need to choose and use cryptography correctly, and students preparing for security courses, certifications or interviews.
More in Computer science
Computer science
CS fundamentals: binary and hex, two’s complement, Big-O, stack vs heap, threads and deadlocks, CPU caches, compilers, UTF-8 and floating point.
50 cardsMorse code
Learn International Morse code: all 26 letters, the 10 digits, common punctuation and signals like SOS, each with its rhythm and a memory aid.
50 cardsDS & Algorithms
Big-O for arrays, hash maps, heaps, trees and graphs, sorting trade-offs, and the patterns behind interview problems: two pointers, sliding windows, BFS, Dijkstra and DP.
50 cardsDesign patterns
SOLID, DRY, KISS and YAGNI, plus the Gang of Four patterns used most: singleton, factory, builder, adapter, decorator, observer, strategy, command and more.
50 cardsSoftware testing
Software testing fundamentals: the test pyramid, unit, integration and E2E tests, TDD, mocks vs stubs vs fakes, coverage, mutation and property-based testing.
50 cardsAPI design
API design fundamentals: REST, HTTP methods, status codes, pagination, versioning, OAuth 2.0 and JWT, CORS, OpenAPI, GraphQL, gRPC and webhooks.
50 cardsSystem design
System design fundamentals: load balancers, caching, CDNs, replication and sharding, CAP, consistency, queues, rate limiting and back-of-the-envelope math.
50 cards