Cryptography & TLS
Symmetric vs asymmetric crypto, TLS/HTTPS handshake, certificates and the chain of trust, secure password storage.
21 questions
JuniorTheoryVery commonWhat is a digital certificate and how does it differ from a key?
What is a digital certificate and how does it differ from a key?
A certificate binds an identity (domain, organization) to a public key, signed by a trusted Certificate Authority (CA). A raw public key proves nothing about who owns it; the certificate adds the CA-vouched binding. Browsers trust it by validating the signature up a chain to a root CA they already trust.
Common mistakes
- ✗Thinking a certificate contains the private key
- ✗Believing the browser trusts any self-signed certificate
- ✗Not understanding the role of the CA signature in verifying authenticity
Follow-up questions
- →How does the browser build the chain of trust from the site's certificate up to the root CA?
- →Why does a self-signed certificate trigger a warning in the browser?
JuniorTheoryVery commonHow should passwords be stored in a DB? Can you use MD5 or SHA-1?
How should passwords be stored in a DB? Can you use MD5 or SHA-1?
Never store plaintext, and never use fast hashes like MD5/SHA-1 — they are brute-forced at billions/sec. Use a slow, salted password hash built for the job: bcrypt, scrypt, or Argon2. The unique per-user salt defeats rainbow tables; the slowness makes mass guessing infeasible.
Common mistakes
- ✗Considering salted MD5/SHA-1 sufficient — they are too fast for passwords
- ✗Encrypting passwords instead of hashing (gives reversibility and a key as a point of failure)
- ✗Using one shared salt instead of a unique one per user
Follow-up questions
- →Why is a unique salt needed if the hash is already irreversible?
- →What is the work factor in bcrypt and how should you choose it?
JuniorTheoryVery commonHow does symmetric encryption differ from asymmetric?
How does symmetric encryption differ from asymmetric?
Symmetric encryption uses one shared secret key to encrypt and decrypt (AES) — fast, but the key must be delivered securely. Asymmetric uses a key pair: a public key encrypts, a private key decrypts (RSA) — solves key delivery but is much slower.
Common mistakes
- ✗Considering asymmetric encryption faster than symmetric — it is orders of magnitude slower
- ✗Confusing asymmetric encryption with hashing (a hash is irreversible)
- ✗Thinking a symmetric key can be sent safely over an open channel without key exchange
Follow-up questions
- →Why is the connection encrypted symmetrically in practice, with the key pair used only at the start?
- →What happens if the symmetric key is intercepted during transmission?
SeniorTheoryVery commonWhat does a client actually verify before it trusts a server certificate?
What does a client actually verify before it trusts a server certificate?
It builds a chain from the leaf up to a root in its own trust store, checking every signature and that each intermediate is a CA allowed to sign certificates. It also checks validity dates, the hostname against the SAN entries, and revocation status. One failed link invalidates the chain.
Common mistakes
- ✗Forgetting the hostname must match a SAN entry rather than the legacy Common Name
- ✗Assuming any CA-signed certificate is valid for any hostname
- ✗Treating an unreachable revocation responder as a check that passed
Follow-up questions
- →Why is the legacy Common Name field no longer sufficient for hostname matching?
- →What does certificate pinning add, and what operational risk does it introduce?
JuniorTheoryCommonWhat does authenticated encryption add over plain encryption?
What does authenticated encryption add over plain encryption?
Encryption alone hides data but detects no tampering — altered ciphertext still decrypts, into plaintext the attacker influenced. AEAD modes such as AES-GCM or ChaCha20-Poly1305 add an authentication tag, so any modification makes decryption fail instead of returning data.
Common mistakes
- ✗Assuming encryption alone protects against modification
- ✗Computing a MAC over the plaintext instead of over the ciphertext
- ✗Using the decrypted output even though the authentication tag failed
Follow-up questions
- →Why is encrypt-then-MAC the correct composition order?
- →What should an application do when the authentication tag fails to verify?
JuniorTheoryCommonHow do hashing, encryption and encoding differ, and where does base64 fit?
How do hashing, encryption and encoding differ, and where does base64 fit?
Hashing is one-way — a fixed-size digest that cannot be turned back into the input. Encryption is reversible with a key and is what gives confidentiality. Encoding is a keyless, reversible change of format, so base64 hides nothing and protects nothing.
Common mistakes
- ✗Treating base64 as a way to hide or protect data
- ✗Believing a hash can be reversed if the salt is kept
- ✗Using a hash where reversible encryption is actually required
Follow-up questions
- →Why is a hash function still useful when it cannot be reversed?
- →Which of the three would you pick for a value you must read back later?
JuniorTheoryCommonWhat is the difference between a salt and a pepper in password hashing?
What is the difference between a salt and a pepper in password hashing?
A salt is a unique per-user random value stored next to the hash; it makes identical passwords hash differently and defeats precomputed tables. A pepper is one secret held outside the database, in config or a KMS, so a stolen dump alone cannot be used to test guesses.
Common mistakes
- ✗Believing the salt itself must be kept secret
- ✗Using one shared salt for every user
- ✗Storing the pepper in the same database as the hashes it protects
Follow-up questions
- →Why is it acceptable to store the salt in plaintext next to the hash?
- →Where should a pepper live so a database dump does not expose it?
MiddleTheoryCommonWhat is forward secrecy and how does transport protocol TLS 1.3 guarantee it?
What is forward secrecy and how does transport protocol TLS 1.3 guarantee it?
Forward secrecy means that recording traffic now and stealing the server key later still will not decrypt it. TLS 1.3 makes every handshake an ephemeral (EC)DHE exchange whose private values are discarded, and the certificate key only signs it — static RSA key transport is gone.
Common mistakes
- ✗Thinking forward secrecy comes from the cipher rather than the key exchange
- ✗Assuming a stolen certificate key can decrypt past recorded sessions
- ✗Confusing rekeying inside a live session with forward secrecy
Follow-up questions
- →What role does the certificate private key still play in a TLS 1.3 handshake?
- →Why does session resumption need care if forward secrecy must be preserved?
MiddleDesignCommonYou are designing encryption at rest for a multi-tenant SaaS that stores customer documents in one object store and one PostgreSQL cluster shared by thousands of tenants. Constraints — each tenant must be cryptographically separated, so a key compromised for one tenant cannot expose another; keys must be rotatable without re-encrypting terabytes of documents; when a tenant offboards, their data must become unrecoverable within one day; application servers are stateless and autoscaled, so nothing may be pinned to a host; auditors require a record of every key use. Describe the key hierarchy, where each key lives, how encryption and rotation work, and how tenant deletion is enforced.
You are designing encryption at rest for a multi-tenant SaaS that stores customer documents in one object store and one PostgreSQL cluster shared by thousands of tenants. Constraints — each tenant must be cryptographically separated, so a key compromised for one tenant cannot expose another; keys must be rotatable without re-encrypting terabytes of documents; when a tenant offboards, their data must become unrecoverable within one day; application servers are stateless and autoscaled, so nothing may be pinned to a host; auditors require a record of every key use. Describe the key hierarchy, where each key lives, how encryption and rotation work, and how tenant deletion is enforced.
Use envelope encryption — a per-tenant key in a KMS or HSM wraps a per-object data key generated fresh for each document and stored beside its ciphertext. Rotation rewraps data keys, not data. Offboarding destroys the tenant key, so the wrapped data keys become useless. The KMS logs every unwrap.
Common mistakes
- ✗Using one global key and treating tenant isolation as an application-level filter
- ✗Planning rotation as bulk re-encryption of all stored data
- ✗Storing key material in the same database as the data it protects
Follow-up questions
- →What still protects the data if an application server is compromised while running?
- →How would you prove to an auditor that an offboarded tenant's data is unrecoverable?
MiddleTheoryCommonWhy does signing not make data confidential, and how do you combine the two?
Why does signing not make data confidential, and how do you combine the two?
A signature covers a hash of the data and verifies with a public key, so the payload stays readable — signing gives integrity, authenticity and non-repudiation, never secrecy. Encrypt-then-MAC is the safe symmetric order, and signature schemes must bind both parties inside the data.
Common mistakes
- ✗Thinking a signature hides the contents of the message
- ✗Assuming the order of signing and encrypting is irrelevant
- ✗Treating a shared-key MAC as if it gave non-repudiation
Follow-up questions
- →Why does a message authentication code (
MAC) not provide non-repudiation? - →What goes wrong if the integrity check is verified only after decryption?
MiddleTheoryCommonWhat happens during the TLS handshake when establishing HTTPS?
What happens during the TLS handshake when establishing HTTPS?
Client and server agree on a cipher suite; the server then presents a certificate the client validates up the chain to a trusted CA. Asymmetric crypto derives a shared symmetric session key, and all bulk data is encrypted symmetrically — confidentiality plus server authentication.
Common mistakes
- ✗Thinking all HTTPS traffic is encrypted asymmetrically (only the key exchange is)
- ✗Believing the server sends its private key to the client
- ✗Forgetting about certificate validation as part of the handshake
Follow-up questions
- →Why switch to symmetric encryption after the key exchange?
- →What is forward secrecy and how does the key exchange provide it?
JuniorTheoryOccasionalWhy is block-cipher mode ECB unsafe, and what do CBC and CTR change?
Why is block-cipher mode ECB unsafe, and what do CBC and CTR change?
ECB encrypts every block independently, so identical plaintext blocks give identical ciphertext and structure survives. CBC chains blocks and needs a random, unpredictable IV per message; CTR builds a keystream and needs a never-repeating nonce.
Common mistakes
- ✗Thinking a strong key makes ECB acceptable
- ✗Reusing a fixed or predictable IV with CBC
- ✗Believing a CTR nonce may repeat under the same key
Follow-up questions
- →Why must a CBC initialisation vector be unpredictable and not merely unique?
- →What security property do these modes still not provide on their own?
JuniorTheoryOccasionalWhy does one shared symmetric key stop working as the number of parties grows?
Why does one shared symmetric key stop working as the number of parties grows?
A symmetric key must reach every party over an already-secure channel, and each holder can both read and forge messages. Pairwise secrecy among n parties needs n(n-1)/2 keys, and removing one member rekeys everyone. A public key may be published — only its authenticity must be assured.
Common mistakes
- ✗Overlooking that a shared key needs an already-secure channel to distribute
- ✗Forgetting that every holder of a symmetric key can also forge messages
- ✗Thinking a public key must be kept secret rather than merely authentic
Follow-up questions
- →What must still be guaranteed about a public key before you rely on it?
- →How does removing one member differ between a shared-key and a public-key scheme?
JuniorTheoryOccasionalWhat are a public and a private key and how are they related?
What are a public and a private key and how are they related?
A key pair is mathematically linked: the public key can be shared freely, the private key is kept secret. What one key encrypts, only the other can decrypt. Encrypt with the recipient's public key for confidentiality; sign with your private key (verified by your public key) for authenticity.
Common mistakes
- ✗Thinking the private key can be recovered from the public key
- ✗Confusing which key encrypts for confidentiality and which one signs
- ✗Believing that distributing the public key compromises the system
Follow-up questions
- →Which key creates a digital signature and which one verifies it?
- →Why is confidentiality provided specifically by the recipient's public key?
JuniorTheoryOccasionalWhy does a 256-bit elliptic-curve key match a 3072-bit RSA key in strength?
Why does a 256-bit elliptic-curve key match a 3072-bit RSA key in strength?
Key length is comparable only inside one algorithm family. RSA rests on integer factoring, which sub-exponential methods attack, so its keys must be large. Elliptic curves rest on a discrete-log problem whose best attacks are square-root, so 256 bits give about 128-bit strength.
Common mistakes
- ✗Comparing key lengths across different algorithm families
- ✗Assuming the longer key is always the stronger one
- ✗Confusing key size with the resulting security level in bits
Follow-up questions
- →What does a security level expressed in bits actually mean?
- →Why does a larger
RSAkey cost more per operation than a curve key of matching strength?
SeniorDebuggingOccasionalA service encrypts every record with AEAD cipher AES-GCM under one fixed IV — what breaks?
A service encrypts every record with AEAD cipher AES-GCM under one fixed IV — what breaks?
Repeating a GCM nonce under one key is catastrophic, not merely weak. The keystream repeats, so relationships between plaintexts leak, and the authentication subkey becomes recoverable, so integrity is lost for every message under that key. Fix with a per-message nonce and a new key.
Open full question →Common mistakes
- ✗Treating a repeated nonce as a minor entropy loss rather than a key-wide failure
- ✗Assuming a longer key compensates for a reused nonce
- ✗Believing the nonce affects only the authentication tag and not the keystream
Follow-up questions
- →Which nonce-generation strategies stay safe across restarts and multiple writers?
- →What does a nonce-misuse-resistant mode change about this failure?
JuniorTheoryRareHow do revocation list CRL, status protocol OCSP and OCSP stapling differ?
How do revocation list CRL, status protocol OCSP and OCSP stapling differ?
A CRL is a signed list the client downloads periodically — bulky, and stale between publications. OCSP asks the CA about one certificate, costing a round trip and revealing browsing to the CA. Stapling has the server attach a fresh signed OCSP response, removing both drawbacks.
Common mistakes
- ✗Believing revocation reliably blocks a compromised certificate
- ✗Confusing which party answers an OCSP status request
- ✗Overlooking the privacy cost of live OCSP queries
Follow-up questions
- →Why do browsers usually soft-fail when a revocation check cannot complete?
- →What does a short certificate lifetime achieve that revocation does not?
JuniorTheoryRareWhy is an encryption key hardcoded in source code as bad as no encryption?
Why is an encryption key hardcoded in source code as bad as no encryption?
A hardcoded key shares the trust boundary of the code: it lives in the repository, in every build artifact and container image, and in the clone history of everyone who ever checked it out. It cannot be rotated without a redeploy, and one leak exposes everything encrypted under it.
Common mistakes
- ✗Assuming a private repository makes an embedded key safe
- ✗Forgetting that keys persist in git history, images and backups
- ✗Treating a move to an environment variable as real key management
Follow-up questions
- →What has to happen once a hardcoded key is found in repository history?
- →Where should application keys live instead, and how are they delivered at runtime?
MiddleTheoryRareWhy is sensitive data transmitted using hybrid encryption?
Why is sensitive data transmitted using hybrid encryption?
Asymmetric crypto is slow and limited to small payloads (message ≤ key size), while symmetric is fast but needs the key delivered securely. Hybrid encryption combines them: generate a random symmetric key, encrypt the data with it, encrypt that key with the recipient's public key, and send both. This is how CMS/TLS protect bulk data.
Common mistakes
- ✗Believing an asymmetric cipher can efficiently encrypt large volumes of data
- ✗Thinking hybrid encryption is double symmetric encryption
- ✗Not understanding that asymmetry encrypts only the symmetric key itself
Follow-up questions
- →What limits the maximum message size in pure RSA encryption?
- →How does the hybrid scheme relate to what the TLS handshake does?
SeniorTheoryRareWhat weakens the Certificate Authority (CA) trust model, and what does Certificate Transparency add?
What weakens the Certificate Authority (CA) trust model, and what does Certificate Transparency add?
Any trusted root may vouch for any domain, so the system is only as strong as its weakest CA — one mis-issuance produces a valid certificate for a site you own. Certificate Transparency records every issuance in public append-only logs, so owners spot certificates they never requested.
Common mistakes
- ✗Assuming a CA can only issue for domains it already serves
- ✗Believing Certificate Transparency prevents mis-issuance rather than exposing it
- ✗Thinking the CA holds a copy of the server private key
Follow-up questions
- →How does an operator use CT logs to notice an unauthorised certificate for their domain?
- →What does a
CAA(Certification Authority Authorization) DNS record restrict?
SeniorTheoryRareWhat is harvest-now-decrypt-later, and how is a post-quantum migration staged?
What is harvest-now-decrypt-later, and how is a post-quantum migration staged?
An adversary stores encrypted traffic today and decrypts it once RSA and ECC fall, so data with a long secrecy lifetime is already at risk. Migration starts with hybrid key exchange pairing a classical and a post-quantum KEM, then signatures; symmetric crypto only needs larger parameters.
Common mistakes
- ✗Assuming only future traffic is at risk, so migration can safely wait
- ✗Believing symmetric ciphers are threatened as badly as RSA and ECC
- ✗Treating post-quantum algorithms as drop-in replacements with unchanged key and signature sizes
Follow-up questions
- →Why is a hybrid key exchange preferred over a purely post-quantum one during migration?
- →Which of your systems hold data with a confidentiality lifetime long enough to migrate first?