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.
Walk through the steps you would take to validate an X.509 certificate chain presented by a server. Include signature verification, trust anchor validation, subject alternative name checks, expiration, key usage and extended key usage checks, and handling intermediate and self-signed certificates.
Sample Answer
Direct answer
Validating an X.509 certificate chain (the standard format for public-key certificates) means confirming, step by step from the server's leaf certificate up through any intermediates to a certificate authority (CA) already trusted by the client, that every certificate in the chain is properly signed, currently valid, actually authorized for the purpose it's being used for, and correctly identifies the server you intended to connect to. Skipping or getting any one of these checks wrong is how real-world certificate validation bugs (accepting an expired certificate, accepting a certificate for the wrong hostname, trusting a certificate that was never actually issued by a real CA) turn into exploitable vulnerabilities.
The chain, concretely
A typical chain looks like: leaf certificate (the server's own) -> intermediate certificate authority certificate -> root certificate authority certificate. The root is self-signed (its issuer field equals its own subject field) and is trusted only because it is already present in the client's trust store, nothing about a self-signed certificate is trustworthy on its own, trust comes entirely from the trust store, not from the certificate's structure.
Validation steps
- Build the chain. Starting from the leaf certificate the server presented, find the certificate that issued it (usually sent alongside it), then that certificate's issuer, and so on, until reaching either a certificate already in the trust store or a dead end (no further issuer found, which fails validation).
- Signature verification. For each certificate in the chain except the trust anchor itself, verify its signature using the issuing certificate's public key. If any signature fails to verify, the chain is invalid, someone tampered with a certificate or it was never actually issued by the claimed issuer.
- Trust anchor validation. Confirm the top of the built chain is a certificate the client already trusts (present in its trust store as a trusted root), and, for a self-signed root, that self-signature check is really just confirming internal consistency, actual trust comes from the certificate's presence in the trust store, not from anything provable about the certificate alone.
- Subject Alternative Name (SAN) checks. Confirm the hostname you intended to connect to appears in the leaf certificate's SAN extension. Modern validation relies on SAN, not the older, deprecated practice of matching against the certificate's Common Name field, a certificate with the right Common Name but no matching SAN entry should be rejected.
- Expiration. Every certificate in the chain, not just the leaf, has a validity window (
notBefore/notAfter). If any certificate in the chain, leaf, intermediate, or root, is expired or not yet valid at the time of the check, the whole chain fails. - Key usage and extended key usage checks. The
keyUsageextension states what a certificate's key is cryptographically allowed to do (e.g.digitalSignature,keyCertSign), andextendedKeyUsagenarrows the purpose further (e.g.serverAuthfor TLS server authentication). A certificate authority certificate should carrykeyCertSignand theCA:TRUEbasic-constraints flag; a leaf server certificate should carryserverAuthand should not itself be a CA certificate. Rejecting a leaf certificate that was actually issued as a CA certificate (or vice versa) prevents an attacker from misusing a mis-scoped certificate to mint fraudulent certificates of its own. - Handling intermediate certificates. Multiple intermediates can appear between the leaf and the root, each one needs the same signature, expiration, and key-usage checks applied, a chain isn't valid just because its endpoints check out.
- Handling self-signed certificates. A self-signed certificate presented anywhere except as an already-trusted root (for example, a server presenting a self-signed leaf certificate with no path to any trusted root) should be rejected outright in normal validation, unless it has been explicitly and separately pinned or added to the trust store out of band, which is a deliberate operational decision, not something automatic chain validation should silently accept.
Trade-offs and pitfalls
The most common real-world mistake is validating only the leaf certificate's properties and assuming a signature check on it alone is sufficient, every certificate in the chain needs its own expiration, key-usage, and signature checks, and a server that fails to send its full intermediate chain (a very common misconfiguration) will validate correctly in browsers that cache intermediates from other sites but fail for clients and application programming interface (API) consumers that don't, which is why "it works in my browser" is not evidence a certificate chain is correctly configured.
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.
Compare AES and DES/3DES: key and block sizes, why DES is considered insecure today, and what you'd need to consider when migrating a system that still has legacy DES-encrypted data.
Sample Answer
Direct answer
AES (Advanced Encryption Standard) uses a 128-bit block with 128, 192, or 256-bit keys and is
the current standard. DES (Data Encryption Standard) uses a 64-bit block with an effective
56-bit key, small enough to brute-force with commodity hardware today, which is why it is
considered broken. 3DES applies DES three times to stretch the effective key strength but
keeps DES's small 64-bit block, which is itself now a weakness.
Structured elaboration
- Key and block sizes: AES: 128-bit block, 128/192/256-bit key. DES: 64-bit block,
56-bit effective key (the stored key is 64 bits but 8 are parity bits). 3DES: same 64-bit
block, keying options up to an effective ~112-bit security level (not the naive 168 bits
three 56-bit keys would suggest, because of a known meet-in-the-middle attack against
simple triple encryption). - Why DES is insecure: a 56-bit keyspace is small enough that a dedicated brute-force
machine (the EFF's "Deep Crack" demonstrated this publicly in 1998) can exhaust it; modern
hardware makes this dramatically cheaper and faster. Separately, 3DES's 64-bit block is
small enough that encrypting large volumes of data under one key risks a birthday-bound
collision (the "Sweet32" attack), which is a practical concern even where the key itself is
not brute-forced. - Migrating legacy DES-encrypted data: you cannot just start writing new data with AES
and leave old DES ciphertext sitting there, since that ciphertext is only as strong as
DES's already-weak key. Decrypt each record with the legacy DES key inside a controlled,
audited process, re-encrypt it with AES-256-GCM under a freshly generated key, verify the
round trip before deleting the old ciphertext, and then securely destroy (zero out) the old
DES key material so it cannot be used to decrypt any remaining copies or backups.
Worked example
A payments system storing card-adjacent data under 3DES for a legacy compliance reason
migrates by: generating one new AES-256 key per data-encryption-key tier (following the same
envelope-encryption pattern used for any modern secret), running a batch job that reads each
3DES record, decrypts it in memory, re-encrypts with AES-256-GCM and a fresh nonce, writes
the new ciphertext, and only after a verified re-read does it mark the row migrated and
schedule the old key for destruction. Doing this as an in-place batch (rather than a
big-bang cutover) lets you roll back a partial migration if something goes wrong mid-run.
Trade-offs & pitfalls
- Backups and archives are the most commonly forgotten copies of DES-encrypted data during a
migration; the old key must be destroyed everywhere the ciphertext exists, or migrating the
live database accomplishes nothing. - 3DES is noticeably slower than AES (it runs the DES algorithm three times), which is
itself a good practical reason, beyond security, to retire it.
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.
Give a high-level walkthrough of a TLS handshake: what happens at each step, which cryptographic primitives are used where (certificates, asymmetric key exchange, symmetric session keys, MAC/AEAD), and what properties TLS is actually trying to guarantee. What's one common way this can fail in practice?
Sample Answer
Direct answer
A TLS (Transport Layer Security) handshake lets a client and server who have never met agree
on a shared symmetric key, authenticate the server (and optionally the client), and start
exchanging data, with confidentiality, integrity, and (with modern configuration) forward
secrecy. It works by combining asymmetric key exchange and certificate-based identity checks
up front, then switching to fast symmetric encryption for the actual traffic.
Structured elaboration
sequenceDiagram
participant C as Client
participant S as Server
C->>S: ClientHello (supported versions, cipher suites, key share, random)
S->>C: ServerHello (chosen cipher suite, key share, random)
S->>C: Certificate (server public key, signed by a CA)
S->>C: Finished (proves possession of the certificate's private key)
Note over C,S: Both derive the same shared secret via ECDHE, then a session key via a KDF
C->>S: Finished (handshake integrity check)
C->>S: Application data (encrypted with the negotiated AEAD cipher)
S->>C: Application data (encrypted with the negotiated AEAD cipher)
- ClientHello / ServerHello: negotiate protocol version, cipher suite, and exchange
ephemeral key-exchange material (an elliptic-curve public value for ECDHE) plus random
nonces that feed the key derivation. - Certificate: the server presents its certificate, a public key bound to an identity and
signed by a certificate authority (CA), so the client can authenticate who it is actually
talking to (see PKI/certificate chains for how that trust is validated). - Key derivation: both sides combine the ECDHE exchange output through a KDF (key
derivation function) to produce the actual symmetric session keys, never sending the
session key itself over the wire. - Application data: all subsequent traffic is encrypted and authenticated with an AEAD
cipher (typically AES-GCM or ChaCha20-Poly1305) under the derived session key; older TLS
versions could instead pair a plain block cipher with a separate MAC (message
authentication code) computed over each record, a split that AEAD replaces with one
combined operation. - Properties TLS is guaranteeing: confidentiality (only the endpoints can read the data),
integrity/authenticity (tampering is detected), server authentication (the certificate
chain proves identity), and, with an ephemeral key-exchange suite, forward secrecy.
Worked example / common failure
The most common real-world failure is not a cryptographic break, it is trust management:
an expired certificate. Everything about the handshake's math can be flawless and the
connection will still be rejected (or a warning shown) the moment the leaf certificate's
validity window has passed, because clients check expiration as part of chain validation
before they will trust the negotiated key exchange at all. This is a frequent cause of
sudden, otherwise-unexplained outages, and is why certificate expiry monitoring is treated as
an operational, not just a security, concern.
Trade-offs & pitfalls
- TLS 1.3 (RFC 8446) simplified this flow and removed insecure options entirely (no more
static-RSA key exchange, no more weak cipher suites), which is why upgrading from TLS 1.2
is itself a meaningful security improvement, not just a version bump. - A valid, unexpired certificate chain proves identity, it does not by itself prove the
identity is trustworthy; certificate validation and business-level trust are separate
concerns.
Unlock Full Question Bank
Get access to all 11 Cryptography Fundamentals interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.