Encryption and keys
0-day streakReview

Your progress

Level 1

0 XP100 XP to level 2
0day streak
0best streak
0topics started
0cards reviewed
    Review cards

    Progress is stored only in this browser. No account is required.

    Encryption and key management: the 60-second story

    Encryption

    A bank locker’s small key sits sealed in an envelope on the door.

    One machine opens envelopes and logs each opening. Destroy a customer’s master key, and their lockers never open again.

    Data has three states, and each has its own attacker.

    In transit: a sniffer on the path. At rest: whoever gets a copy. In use: whoever owns the app server, which reads plaintext.

    Each layer decrypts at a different point.

    Disk encryption stops a stolen drive. TDE adds leaked backups. Field-level adds DBAs and SQL injection. Only end-to-end survives a compromised app server.

    Random 96-bit GCM nonces, one key, 20,000 encryptions a second.

    The limit

    NIST caps one key at 2³² encryptions. At that rate you hit it in about 2.5 days. Use many keys.

    Envelope encryption: the KMS only ever sees a small key.

    Encrypt the claim PDF locally with a fresh data key. The KMS wraps that key under the tenant’s KEK; store the wrapped key beside the ciphertext.

    67/s

    KMS calls, down from 12,000

    A data key per record means 12,000 Decrypt calls a second, over the 10,000 default. One key per tenant per day, cached 5 minutes in 40 pods, needs 67.

    Does key rotation re-encrypt all your data?

    Bad: Rotate means re-encrypt

    Rewrite every object, replica and backup.

    Good: Rotate means new version

    New wraps use v2; v1 only decrypts. Re-wrapping 200M DEKs takes ≈ 11 hours.

    Destroy one tenant’s key, and every backup becomes noise.

    Erasing a tenant from 35 snapshots, a replica and a data-lake export is hard. Destroy its KEK, and every copy becomes unreadable.

    Find a row by an encrypted ID

    1. Randomised AEAD: no queries, leaks only length
    2. Blind index: an HMAC column for equality
    3. Tokenize card numbers; only the vault maps back
    4. Never deterministic on low-entropy columns

    Remember

    TLS in transit; pick the at-rest layer by attacker. AEAD with unique nonces, data keys wrapped by a per-tenant KEK in a KMS, rotation by version, and crypto-shredding to delete.