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.
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.
Your SIEM shows repeated TLS handshake failures to an internal service after a certificate rotation. Failures indicate 'bad_certificate' from several clients. Explain your investigation steps: what logs and systems you inspect, how to verify certificate chain and private key correctness, and quick mitigations to restore service while preserving forensic data.
Sample Answer
Framing
A bad_certificate alert is Transport Layer Security's (TLS) way of saying the client rejected something specific about the certificate the server presented during the handshake, it is a symptom, not a diagnosis. Given that this started right after a certificate rotation, the investigation should assume the rotation itself introduced the problem until proven otherwise, and the response needs to restore service without destroying the evidence needed to confirm what actually broke.
Investigation steps
- Confirm the timeline. Check when the failures started against the exact deployment time of the certificate rotation across your fleet, a rollout that wasn't atomic (some nodes updated, some not) often shows up as intermittent failures rather than a hard outage, which is itself a diagnostic clue.
- Inspect what's actually being served. Connect directly to an affected node's Transport Layer Security endpoint and retrieve the certificate chain it presents (most TLS tooling can dump the full chain, not just the leaf). Compare it against what you intended to deploy: is the leaf certificate the new one? Is the full intermediate chain present, or did the rotation deploy the new leaf certificate without updating the intermediate bundle, a very common rotation mistake?
- Verify the certificate and private key actually match. A rotation that swaps a certificate file but not its paired private key (or vice versa) produces exactly this kind of failure. Compute a fingerprint of the public key embedded in the certificate and compare it against a fingerprint of the public key derived from the private key file on disk, if they don't match, the server is presenting a certificate for a key it doesn't actually hold, and the handshake will fail every time.
- Check certificate validity and identity fields. Confirm the new certificate's validity window has actually started (a certificate rotated slightly early, before its
notBeforedate, would be rejected), and confirm its Subject Alternative Name entries match the hostnames clients are actually connecting to, a rotation that regenerated a certificate with the wrong hostname list is a common human error. - Check trust store propagation on the client side. If the rotation introduced a new intermediate certificate authority or changed the root, clients (or upstream proxies, load balancers, or internal services) that haven't been updated with the new trust chain will reject the new certificate as untrusted even though the server side is configured correctly, this shows up specifically as failures from some clients, not others.
- Correlate logs across layers. Server-side TLS termination logs, load balancer or reverse proxy logs, and client-side error logs each show a different part of the picture, the exact alert reason and which specific check failed is usually visible in at least one of these, don't stop at the first log source that mentions
bad_certificate.
Quick mitigations that preserve forensic data
- Roll back to the previous, known-good certificate and key pair on affected nodes to restore service immediately, but copy the failing certificate, key, and relevant logs to a separate location before overwriting them on the live nodes, don't let a rollback destroy the only evidence of what went wrong.
- If a full rollback isn't immediately possible everywhere, route traffic away from affected nodes (via load balancer health checks or manual removal from the pool) rather than restarting services repeatedly, repeated restarts can overwrite log buffers and make root-causing harder.
- Avoid regenerating a "fixed" certificate in a hurry before you've confirmed exactly what was wrong with the previous one, a rushed second rotation risks introducing a second, different mistake on top of the first.
Trade-offs and pitfalls
The single most common root cause behind this exact symptom is an incomplete rollout, a certificate and its matching intermediate bundle deployed to some nodes but not others, or a private key file that didn't get updated in lockstep with its certificate. Treat certificate rotation as an atomic, verifiable deployment (verify the live chain and key match on every node before declaring the rotation complete) rather than a file copy, since the failure here is silent until a client actually tries to validate the result.
Explain forward secrecy (and perfect forward secrecy): what does it protect against, and what doesn't it protect against (e.g. server long-term key compromise vs a single session key's exposure)? Describe how ephemeral Diffie-Hellman (ECDHE) achieves it in TLS, and what a server operator must configure correctly for it to actually apply.
Sample Answer
Direct answer
Forward secrecy (also called perfect forward secrecy, PFS) means that if an attacker later
steals a server's long-term private key, they still cannot decrypt traffic they recorded in
the past, because each past session used its own key that was never derivable from the
long-term key in the first place. It does not protect a session whose own key is compromised
while that session is still relevant, or protect anything on either endpoint after
decryption.
Structured elaboration
- What it protects against: mass retroactive decryption. An attacker who passively
records encrypted traffic for years, then later compromises the server's long-term private
key (via a breach, subpoena, or key-extraction bug), gains nothing from the recording: the
long-term key was only ever used to authenticate, not to directly encrypt. - What it does not protect against: compromise of a specific session's own ephemeral key
or the derived session key while that session's data is still sensitive; endpoint
compromise (malware reading plaintext directly on a client or server); and metadata (who
talked to whom, when, how much data), which forward secrecy says nothing about. - How ECDHE achieves it in TLS: ECDHE (elliptic-curve Diffie-Hellman, ephemeral) means
both sides generate a brand-new elliptic-curve key pair for every handshake, exchange the
public halves, and derive a shared secret via elliptic-curve Diffie-Hellman. The server's
long-term certificate key is only used to sign that ephemeral exchange (proving "this really
is me"), never to encrypt anything directly. Once the handshake finishes, both sides discard
the ephemeral private keys, so nothing recoverable from the long-term key remains. - What an operator must actually configure: enable and prefer cipher suites containing
ECDHE (or classic DHE), for exampleTLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, and disable
static-RSA key-exchange suites (TLS_RSA_WITH_...), where the session key is directly
RSA-encrypted with the server's long-term public key and is therefore fully recoverable if
that private key ever leaks. TLS 1.3 (RFC 8446) removes static-RSA key exchange entirely and
makes ephemeral exchange mandatory, so upgrading to it is itself a forward-secrecy fix.
Session resumption is the other place this quietly breaks: if session tickets are encrypted
under a long-lived ticket key, compromising that ticket key can undo forward secrecy for
every resumed session, so ticket keys need their own rotation schedule.
Worked example
An attacker passively records two years of encrypted traffic between a client and
bank.example.com. In year three, the bank suffers a breach and its long-term certificate
private key leaks. If the bank's TLS configuration used ECDHE, the attacker's two-year
recording is still worthless: every one of those sessions used its own ephemeral key pair,
generated and discarded at handshake time, and the leaked long-term key was never used to
encrypt anything, only to sign the ephemeral exchange. If the bank had instead used a static-RSA
key-exchange suite, the same leaked key directly decrypts every recorded session key from the
last two years, because in that mode the session key was RSA-encrypted straight to the server's
long-term public key and never expires on its own.
Trade-offs & pitfalls
- A server can support ECDHE in principle and still fail to get forward secrecy in practice
if a legacy static-RSA suite is still enabled and a client or load balancer negotiates down
to it. - Forward secrecy adds a small amount of per-handshake computation (a fresh key exchange
every time versus a single static RSA operation), which is why it was historically seen as
a cost/security trade rather than a default; TLS 1.3 settled that trade by removing the
alternative.
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.
Discuss the operational concerns when choosing randomness sources in cloud VMs, containers, and hardware. Explain entropy starvation, how to bootstrap entropy on new instances, and practical mitigations (e.g., rngd, getrandom/URANDOM behavior, provisioning entropy via cloud agent or HSM).
Sample Answer
Direct answer
Entropy starvation happens when a freshly booted virtual machine (VM), container, or device has not
yet gathered enough unpredictable input to safely seed its cryptographically secure pseudorandom
number generator (CSPRNG), which is the source every key, nonce, and token generation call relies
on. Cloud and container environments make this worse than physical hardware because a VM can be
cloned or restored from a snapshot with an already-seeded-looking generator that is, in fact,
identical to another instance's; the fix is to feed real, instance-unique entropy in early rather
than trust the guest kernel's default boot-time sources alone.
Structured elaboration
- How the kernel behaves. On Linux, the
getrandom()system call blocks (or, with a
non-blocking flag, returns an error) until the kernel's internal CSPRNG has been seeded once
after boot;/dev/urandomis meant to behave the same way on modern kernels, but on VM images
built from older kernels or minimal boot paths, that seeding event can be slow if the only inputs
are interrupt timing jitter that a virtualized, otherwise-quiet guest does not generate much of. - Why cloning is the cloud-specific risk. A snapshot or cloned image can, in the worst case,
carry over CSPRNG state from before the clone, so two "freshly booted" instances derived from the
same image can end up seeded almost identically. This is not hypothetical: a widely cited 2012
academic study (Heninger, Durumeric, Wustrow, and Halderman, "Mining Your Ps and Qs") found a
meaningful population of RSA and DSA keys generated on freshly booted embedded Linux devices that
shared factors, traced back to exactly this kind of boot-time entropy shortfall. - Sources available. A hardware random number generator, either a physical Trusted Platform
Module (TPM)/secure element or a paravirtualizedvirtio-rngdevice that channels the host's
hardware entropy into the guest, is the strongest available source in a VM;rngd(a user-space
daemon that feeds a hardware source into the kernel's pool) is the standard way to wire it up.
Worked example
Picture a fleet auto-scaling event: 200 new VM instances boot from the same golden image within a
few seconds of each other. If that image's kernel has no virtio-rng attached and relies solely on
interrupt-timing jitter to seed its CSPRNG, every one of those 200 instances is drawing from the
same class of low-diversity, low-volume noise source at nearly the same wall-clock moment, which is
exactly the "identically seeded clones" risk the 2012 study above found in the wild, just produced
by autoscaling instead of manual imaging. Attaching virtio-rng to the image and running rngd
against it before any cryptographic material is generated removes the shared bottleneck: each
instance now draws from the host hypervisor's own hardware entropy source, which is independent
per host and not tied to how many guest VMs happen to boot in the same second.
Trade-offs & pitfalls
- Bootstrap mitigation. Attach
virtio-rng(or equivalent) to every VM image rather than
relying on interrupt jitter alone; runrngdagainst it; have cloud-init or an equivalent
provisioning agent inject additional per-instance-unique material (instance ID, a fresh
provider-supplied random value fetched over an authenticated channel) mixed into the pool as a
supplement, never as a replacement for real entropy. - Delay, don't fake it. If a service must generate a long-term key at first boot, gate that
generation on confirmation that the kernel's CSPRNG has actually been seeded, rather than
falling back to a weaker, always-available source "so boot doesn't hang." A slow, correct key
beats a fast, predictable one. - Containers usually share the host kernel's entropy pool, so a container does not need its own
hardware RNG in most deployments, but a container started from a frozen, long-cached image on a
host that has not yet accumulated entropy inherits the same startup risk as a VM. - Monitoring. Alert on unusually long blocking on cryptographic syscalls at boot and on
entropy-pool health metrics where the kernel exposes them; a fleet-wide pattern of slow key
generation at scale-out time is a real operational signal, not noise.
Unlock Full Question Bank
Get access to all 17 Cryptography Fundamentals interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.