Cryptography and Key Management
Cryptography and key management tests whether you can choose a primitive for a purpose and keep keys safe across their lifecycle. Most exam failures are not about algorithm choice but about misuse: wrong mode, reused nonce, missing integrity, or a key stored beside the data it protects.
Choosing primitives
- Symmetric encryption (AES) for bulk data; AES-GCM gives confidentiality and integrity. Never reuse a nonce with the same key in GCM or CTR mode.
- Asymmetric algorithms (RSA, ECC) for key exchange and signatures, not bulk data; ECDSA and EdDSA give smaller, faster signatures at equal strength.
- Hashing (SHA-256, SHA-384) for integrity, never for confidentiality. Salt passwords and use a memory-hard KDF such as Argon2id or scrypt.
- HMAC for message authenticity with a shared key; digital signatures for non-repudiation using a private key.
PKI and key lifecycle
A CA hierarchy issues certificates; validity is checked by CRL or OCSP, and revocation must actually be consulted. Key management covers generation in a trusted environment such as an HSM or KMS, distribution, storage, rotation, archival for later decryption, and destruction with evidence. Envelope encryption protects data keys with a master key in an HSM, so rotating the master key does not re-encrypt all data. Ephemeral Diffie-Hellman gives perfect forward secrecy, so a stolen long-term key does not decrypt past sessions.
Worked example
An application encrypts customer notes with AES-256-GCM using a per-record data key wrapped by a KMS master key. A developer instead derives each data key from a fixed salt and the record identifier. Every record now uses a predictable key and the same nonce, so GCM integrity collapses and ciphertext relationships leak plaintext. The fix is a random 96-bit nonce per encryption and a random data key per record, wrapped and stored with the ciphertext, with rotation of the master key handled by the KMS.
Traps
- Treating encryption as complete without integrity; AES-CBC alone is malleable.
- Storing keys in the same repository or configuration file as the encrypted data.
- Assuming hashing is encryption, or that Base64 is protection.
- Ignoring certificate expiry and revocation checking.