Cryptography and Data Protection
Cryptography questions test two things: choosing the right primitive for a stated goal, and the operational discipline of keys - generation, storage, rotation, destruction and agility.
Core rules and concepts
- Symmetric ciphers (AES-GCM) are fast and, as AEAD modes, give confidentiality plus integrity. Asymmetric algorithms (RSA, ECC) solve key distribution and enable signatures.
- Key exchange: ECDHE provides forward secrecy in TLS 1.3, so a later key compromise does not decrypt past sessions.
- Hashes (SHA-256, SHA-384, SHA-3) are one-way and serve integrity. Salt each password to defeat rainbow tables and use a memory-hard KDF (Argon2, PBKDF2, bcrypt); a pepper adds a secret stored separately.
- HMAC combines a hash with a shared key for integrity and authenticity. A digital signature is a hash encrypted with the private key: integrity, authenticity and non-repudiation, but not confidentiality.
- PKI: root CA, intermediate, leaf. Validation checks the chain, validity dates, name match and revocation via CRL or OCSP.
- Key management: generate in a compliant RNG or HSM, separate duties, rotate and version, destroy securely, retain escrow or recovery paths.
- Envelope encryption: a data key encrypts the data, and a KMS or HSM master key wraps the data key. Rotation re-wraps keys instead of re-encrypting bulk data.
- States: at rest (encryption, tokenisation, masking), in transit (TLS 1.2+ with strong ciphers), in use (TEEs, confidential computing).
Worked example
A payments team stores social security numbers. Encrypt the field with AES-256-GCM using a per-record data key, wrap each data key with a KMS customer-managed key that never leaves the HSM, and grant decrypt permission only to the payment service role. Rotate the CMK annually, which re-wraps data keys without bulk re-encryption. Show only a masked value in the UI and tokenise the number for analytics so analysts never hold ciphertext. TLS with mutual authentication still covers the transit path; at-rest encryption alone would not.
Traps that cost marks
- Confusing hashing with encryption, or implying hashes are reversible.
- Assuming encryption provides integrity when it is not an AEAD or MACed mode.
- Swapping signing and encryption key usage.
- Rotating passwords diligently but never rotating or versioning keys.