Cryptography Fundamentals Questions
Core concepts and vocabulary of cryptography: confidentiality, integrity, authentication, and non-repudiation; the difference between symmetric and asymmetric primitives; and how standard algorithms, libraries, and protocols fit together. Covers threat models, common standards, and applying primitives and cryptographic libraries correctly to real-world security problems. The entry point for the cryptography track.
State recommended key length guidance for common algorithms: AES (symmetric), RSA (classical public-key), and elliptic curve algorithms (ECDSA/ECDH). Explain why key length matters and what operational considerations (performance, lifespan, algorithm migration) influence your choice of length.
Sample Answer
Direct answer
Roughly: AES-128 or AES-256 for symmetric keys, at least RSA-2048 with RSA-3072 preferred for
longer-lived data, and a 256-bit elliptic curve (like P-256) for ECDSA/ECDH. These are not
interchangeable "bit strengths": because the underlying hard problems differ, RSA needs a
much larger key than AES or ECC to reach the same practical security level.
Structured elaboration
Key length matters because it determines how expensive the best known attack is. For a
symmetric cipher, the best general attack is brute force over the key space, so security
scales directly and exponentially with key bits. RSA's security instead rests on integer
factorization, which has sub-exponential algorithms (the General Number Field Sieve), so RSA
needs a much larger key to match a given symmetric strength. Elliptic-curve cryptography
relies on the discrete logarithm problem over an elliptic curve, which has no known
sub-exponential attack, so it reaches strong security with much smaller keys than RSA.
Roughly matched security levels (NIST SP 800-57 style guidance):
| Symmetric-equivalent strength | AES | RSA | ECC (ECDSA/ECDH) |
|---|---|---|---|
| ~128-bit | AES-128 | RSA-3072 | P-256 |
| ~192-bit | AES-192 | RSA-7680 | P-384 |
| ~256-bit | AES-256 | RSA-15360 | P-521 |
Operational considerations that influence the choice:
- Performance: RSA key generation and private-key operations get noticeably slower as key
size grows; ECC stays comparatively cheap even at higher security levels, which is why TLS
handshakes favor ECDHE over large-RSA key exchange today. - Lifespan: a key protecting data that must stay confidential for decades (a root CA, an
archival encryption key) should sit at a higher security margin than a short-lived TLS
session key, since attacker capability only improves over time. - Algorithm migration headroom: teams often deliberately keep some headroom above the
current minimum recommendation, so that a future algorithm migration (moving to a larger
key size, or off an algorithm entirely) can happen on a planned schedule rather than as an
emergency re-key after a break is announced.
Worked example
A document-signing service needs signatures that remain verifiable for 20-year regulatory
retention. A TLS session key, by contrast, only needs to resist attack for the minutes the
connection is open. Both could technically use "128-bit class" security today, but the
signing service deliberately picks RSA-3072 over RSA-2048 (or a 384-bit curve over a 256-bit
one) precisely because of the lifespan consideration: a 20-year window gives attacker capability
two decades to improve, so the team spends a bit more compute per signature now to buy margin
that a short-lived session key does not need.
Trade-offs & pitfalls
- RSA-2048 is still widely deployed and considered acceptable for most near-term use, but
guidance is trending toward RSA-3072 for anything expected to remain secure for many years;
treat any bare "RSA-2048 is fine forever" claim with suspicion. - Bumping AES from 128 to 256 bits has essentially no practical performance cost on modern
hardware (AES-NI accelerates both equally), so the "just use AES-256 to be safe" instinct is
cheap here in a way it is not for RSA.
What is authenticated encryption (AEAD) in practical terms? Describe the API shape (plaintext, associated data, nonce in; ciphertext and authentication tag out), the security properties it provides, and give a concrete example of an attack that becomes possible if you use plain (unauthenticated) encryption instead.
Sample Answer
Direct answer
Authenticated encryption (AEAD, authenticated encryption with associated data) is encryption
that also proves the ciphertext was not tampered with. The API takes plaintext, a nonce (a
number used once), and optional associated data (AD, extra context that must be visible and
authenticated but not itself encrypted, like a protocol version byte); it returns ciphertext
plus an authentication tag. On decrypt, if the tag does not verify, you get no plaintext at
all, not a corrupted one.
Structured elaboration
- Inputs: plaintext, a nonce (unique per encryption under a given key, does not need to
be secret), and associated data (AD): data you want authenticated but left in cleartext,
for example a message header or routing metadata a middlebox needs to read. - Outputs: ciphertext (same length as the plaintext) and an authentication tag (a fixed
size, typically 16 bytes for AES-GCM), which travels alongside the ciphertext. - Security properties: confidentiality of the plaintext, and integrity/authenticity of
both the ciphertext and the associated data. Decryption is a single atomic operation:
verify the tag first, and only release plaintext if it matches. Common real
implementations are AES-GCM and ChaCha20-Poly1305.
Worked example
Contrast this with plain, unauthenticated encryption, say AES in CBC mode (CBC, Cipher Block Chaining, is a mode that splits the data into fixed-size chunks called blocks and chains each block onto the previous one) with no separate
integrity check. CBC decryption XORs each ciphertext block with the previous ciphertext block
(or the IV for the first block, where IV means initialization vector, a random starting block used because the very first block has no previous ciphertext block to chain onto) after a block-cipher decrypt (a block cipher, such as AES, is the core algorithm that transforms one fixed-size block at a time). An attacker who can flip bits in
a ciphertext block causes a predictable, corresponding bit flip in the next decrypted
plaintext block, with no error raised, because CBC decryption has no way to detect tampering
on its own. This is the mechanism behind real padding-oracle attacks (Vaudenay's 2002 attack,
and the 2014 POODLE attack on SSLv3's CBC handling): by sending crafted ciphertexts and
watching whether the server complains about bad padding, an attacker recovers the plaintext
one byte at a time without ever learning the key. AEAD closes this off structurally: any bit
flip anywhere in the ciphertext or associated data changes the tag, so a tampered message is
rejected before any plaintext is returned, and there is no padding-error side channel to
probe in the first place.
Trade-offs & pitfalls
- AD is authenticated but not confidential: do not put anything secret in it expecting
encryption; it is meant for routing/context fields that must stay legible. - Reusing a nonce under the same key breaks the security guarantee entirely for most AEAD
modes (this is worse for GCM specifically, where it can also leak the authentication
subkey). - "Encrypt, then separately compute an HMAC yourself" (encrypt-then-MAC) achieves the same
goal as AEAD but pushes the correctness burden onto you; AEAD ciphers bundle it so there is
one call to get right instead of two to sequence correctly.
Describe Public Key Infrastructure (PKI) fundamentals: what a certificate is, what a Certificate Authority (CA) does, certificate chains and trust anchors, and a typical use of certificates in TLS. Keep the explanation high-level but include how trust is established and how certificate expiration affects secure channels.
Sample Answer
Direct answer
Public Key Infrastructure (PKI) is the system of certificates, certificate authorities, and
trust chains that lets a stranger's public key be trusted without meeting them first. A
certificate authority (CA) signs a certificate binding a public key to an identity; anyone who
already trusts that CA can then trust the certificate, and by extension the key inside it.
Structured elaboration
flowchart TD
Root["Root CA (trust anchor, pre-installed in OS/browser)"]
Inter["Intermediate CA (signed by Root)"]
Leaf["Server certificate (signed by Intermediate)"]
Root -->|signs| Inter
Inter -->|signs| Leaf
Leaf -->|presented during TLS handshake| Client["Client validates the whole chain"]
- Certificate: a data structure containing a public key, an identity (like a domain
name), a validity window, and a signature from whoever issued it. - Certificate authority (CA): a party trusted to verify identity claims before signing a
certificate. Trust in a CA is not proven cryptographically from scratch each time, it comes
from the CA's root certificate being pre-installed as a trust anchor in operating systems
and browsers. - Certificate chains: in practice, a root CA rarely signs end-entity (leaf) certificates
directly; it signs intermediate CAs, which sign the leaf certificates servers actually
present. Validating a certificate means walking this chain, checking each signature, until
reaching a root the client already trusts. - Use in TLS: during the handshake, the server presents its certificate (and usually the
intermediate chain); the client verifies the signature chain up to a trusted root, checks
the domain name matches, and checks the validity window, before it will trust the public
key for the key exchange.
Worked example
A browser connecting to example.com receives a leaf certificate for example.com signed by
"Intermediate CA X," which is itself signed by "Root CA R." The browser already has Root CA
R's certificate baked into its trust store. It verifies Intermediate CA X's signature using
Root CA R's public key, then verifies the leaf certificate's signature using Intermediate CA
X's public key. Only after both signatures check out, the domain name matches, and the
current date falls inside the leaf certificate's validity window does the browser proceed to
trust that public key for the handshake.
Trade-offs & pitfalls
- Certificate expiration: every certificate in the chain has a validity window; if the
leaf certificate's window ends and it is not renewed, clients will refuse the connection (or
warn loudly) even though nothing about the underlying keys has actually changed. This is a
frequent, entirely avoidable cause of production outages, which is why certificate expiry is
tracked as an operational alert, not just a one-time setup step. - Self-signed certificates skip the CA entirely (the certificate signs itself), which is fine
for internal testing but provides no independent identity verification for anyone who
hasn't been told in advance to trust that specific certificate.
Explain the fundamental differences between symmetric and asymmetric encryption. Name real algorithms in each category, describe typical enterprise use cases for each (data at rest, key exchange, code signing, TLS), and give one concrete advantage and one limitation of each approach.
Sample Answer
Direct answer
Symmetric encryption uses one shared secret key for both encrypting and decrypting; it is
fast but requires that key to somehow reach every party who needs it. Asymmetric (public-key)
encryption uses a mathematically linked key pair, a public key anyone can have and a private
key only the owner holds, which solves the distribution problem but at a real performance
cost.
Structured elaboration
- Symmetric algorithms: AES (Advanced Encryption Standard), ChaCha20. Typical enterprise
use: encrypting data at rest (a database, a disk volume) and encrypting bulk traffic once a
session key exists.- Advantage: very fast, cheap enough to encrypt gigabytes of data with negligible overhead.
- Limitation: both sides need the same key beforehand; there is no built-in mechanism for
two parties who have never met to agree on one safely over an open channel.
- Asymmetric algorithms: RSA, ECDSA/ECDH (elliptic curve variants). Typical enterprise
use: key exchange (establishing a shared secret over an untrusted network), and code/document
signing (proving who published something, and that it was not altered).- Advantage: solves key distribution; the public key can be published openly and only the
matching private key can decrypt or sign. - Limitation: orders of magnitude slower than symmetric ciphers and produces much larger
ciphertext relative to the data size, which makes it impractical for encrypting bulk data
directly.
- Advantage: solves key distribution; the public key can be published openly and only the
Worked example
TLS (the protocol behind HTTPS) is the everyday case: a browser and a server have never
shared a secret in advance, so they use asymmetric key exchange (ECDHE, backed by the
server's certificate) to agree on a fresh symmetric session key, then switch to a symmetric
AEAD cipher like AES-GCM for the actual page data. Neither algorithm family alone does the
whole job well: symmetric alone cannot solve "how do two strangers agree on a key," and
asymmetric alone is too slow to encrypt a multi-megabyte response.
Trade-offs & pitfalls
- Almost no production system uses pure asymmetric encryption for bulk data; if you see it
proposed, that is usually a design smell. - Symmetric key management (rotating and distributing shared secrets safely) is its own hard
problem and does not disappear just because the algorithm is fast; it is why systems like
KMS (key management service) and PKI (public key infrastructure) exist.
Explain the core security properties a cryptographic hash function must have (preimage resistance, second-preimage resistance, collision resistance), name a couple of common algorithms, and give one example each of where a hash is the right tool (integrity checks, content-addressing) and where it is not (storing passwords without salting and stretching).
Sample Answer
Direct answer
A cryptographic hash function must be preimage resistant (given an output, you cannot find
an input that produces it), second-preimage resistant (given one input, you cannot find a
different input with the same output), and collision resistant (you cannot find any two
distinct inputs that share an output at all). Common algorithms today are SHA-256 and SHA-3;
MD5 and SHA-1 are broken for collision resistance and should not be used where that property
matters.
Structured elaboration
- Preimage resistance: given
H(m) = h, it should be computationally infeasible to find
anymthat producesh. This is what makes a hash "one-way." - Second-preimage resistance: given a specific
m1, it should be infeasible to find a
differentm2withH(m1) = H(m2). - Collision resistance: it should be infeasible to find any pair
m1 != m2with
H(m1) = H(m2), without fixing either input in advance. This is the property MD5 and SHA-1
have both practically broken (real collision attacks have been demonstrated for both). - Where a hash is the right tool: integrity checks (comparing a downloaded file's hash
against a published one to detect corruption or tampering), content-addressing (Git commit
hashes, package registries keying content by its digest so identical content always maps to
the same address), and as the digest step inside a digital signature: signing algorithms
sign a fixed-size hash of a message rather than the message itself, since asymmetric
operations are expensive on large inputs. - Where it is not the right tool: storing passwords with a bare, unsalted hash. Hash
functions are deliberately fast, which is exactly wrong for password storage: an attacker
with a stolen hash dump can try billions of guesses per second on commodity GPUs. Password
storage needs a slow, memory-hard key derivation function (Argon2id, scrypt, bcrypt), not a
general-purpose hash used directly.
Worked example
To see why collision resistance is the strongest property, compare a real hash to a toy,
clearly-broken one: H(x) = x mod 97. Take m1 = 5 and m2 = 102. 102 mod 97 = 5, so
H(5) = H(102) = 5: a collision found by inspection, with no search at all. That is exactly
what "not collision resistant" looks like. A real hash like SHA-256 produces a 256-bit output,
so the best known way to find any colliding pair is a generic birthday-bound search of roughly
2^128 attempts (the square root of 2^256 possible outputs), which is computationally out
of reach with current or foreseeable hardware. The mod-97 toy fails instantly because its
output space is only 97 values; a cryptographic hash needs both a large output space and no
structural shortcut into it.
Trade-offs & pitfalls
- Collision resistance and preimage resistance are different properties; a function can lose
one without immediately losing the other, which is why "MD5 has collisions" does not
automatically mean "MD5 leaks passwords," but it does mean you should not trust MD5 for
anything where an attacker choosing two colliding inputs would matter (like forging a signed
document). - "Hashing" and "encryption" are often confused: hashing is one-way and not meant to be
reversed at all, encryption is two-way and meant to be reversed with the right key. A hash
cannot be "decrypted" back to the original input, by design.
Unlock Full Question Bank
Get access to all 26 Cryptography Fundamentals interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.