Part 8 · 2 chapters · ~12 min

Common Misuse

Homemade schemes, unauthenticated encryption and padding oracles, nonce and IV reuse, weak randomness, keys stored beside data, disabled verification, timing leaks, encoding confused with encryption (base64, JWT payloads), and safe high-level libraries.

15

Six ways good primitives fail

Cryptographic maths is rarely what breaks. Implementations and usage are. A short list of rules prevents most real-world crypto bugs: use high-level libraries, use AEAD, never reuse nonces, use a CSPRNG, keep keys in a KMS, and never skip verification.

COMMON CRYPTO MISUSE
how good primitives fail in real code
homemade cryptoXOR "encryption", custom ciphers,clever schemes. Use vettedlibraries and constructions.no authenticationEncryption without integrity (CBC,CTR alone) allows tampering andpadding oracles.nonce or IV reuseRepeated GCM nonces or ECDSAnonces leak keys or plaintext.weak randomnessMath.random() or time-seeded RNGsfor tokens. Use the OS CSPRNG.keys next to dataEncryption keys in the samedatabase or repository as theciphertext.not verifyingSkipping certificate or signaturechecks "temporarily"(verify=False).
swipe the figure sideways, or tap expand for full screen
1/6
homemade crypto
Designing your own scheme is the classic mistake: real cryptosystems fail in subtle ways experts take years to find. Use libsodium, Tink, or your platform's high-level APIs.
never design your ownlibsodium, Tink, platform APIs
16

Encoding is not encryption

code
base64("22212345678")       → "MjIyMTIzNDU2Nzg="     anyone can decode it
a JWT payload               → base64url JSON         anyone can read it (Auth part 2)
hash("08031234567")         → reversible by guessing all phone numbers (part 0)
// only AEAD with a protected key makes data confidential

Safe defaults: libsodium (secretbox, box, sign), Google Tink, the Web Crypto API, Go's x/crypto, Rust's RustCrypto and ring. They expose constructions, not raw primitives, which is exactly the point.