Applied Cryptography and Key Management Questions
Selecting and applying cryptographic primitives correctly: symmetric and asymmetric encryption, hashing, digital signatures, key derivation, secure random number generation, and public key infrastructure. Covers key lifecycle management, key exchange and distribution, choosing appropriate algorithms for a given constraint set including resource-constrained environments, and the forward-looking side of algorithm lifecycle: cryptographic agility and algorithm-migration strategy, forward secrecy, and the post-quantum cryptography transition and planning upgrades without breaking existing data or interoperability. The applied-crypto engineering layer, distinct from compliance-driven crypto standards.
You're starting a greenfield system expected to run for more than 10 years. List the factors you'd weigh when selecting cryptographic algorithms and key sizes for symmetric encryption, public-key encryption, signatures, and key exchange. How would you build in algorithm agility from day one, and how would you document these choices so a future team can safely migrate them?
Sample Answer
Direct answer: For a system meant to run 10+ years, do not just pick "the strongest algorithm available today." Pick current, NIST-recommended algorithms with a comfortable security margin, design the ciphertext and protocol formats so the algorithm itself is a swappable, versioned field rather than baked into the wire format, and write down every choice with its assumptions and a review date. Agility and documentation matter as much as the initial algorithm choice, because you cannot predict what will need to change in year 6.
Factors per primitive
- Symmetric encryption: use AES-256-GCM (or ChaCha20-Poly1305 where hardware AES acceleration is unavailable). Rationale: Grover's algorithm gives quantum computers a quadratic speedup against brute-force key search, so a key of length k bits gives only about k/2 bits of security against a quantum attacker. AES-128 would degrade to roughly 64-bit post-quantum security, too thin for a decade-plus horizon. AES-256 still leaves roughly 128-bit margin. This is the cheapest form of "future-proofing" available: symmetric algorithms do not need new math, just a bigger key.
- Public-key encryption / key exchange: classical RSA-2048 or ECC (elliptic-curve cryptography, the main alternative to RSA) (X25519, P-256) is fine against today's computers but carries zero quantum margin: Shor's algorithm breaks the underlying math outright rather than merely halving it. For anything that must stay confidential for a decade, this is the "harvest now, decrypt later" risk: an adversary records ciphertext today and decrypts it once a cryptographically relevant quantum computer exists. Architect for a hybrid classical-plus-post-quantum key encapsulation mechanism (KEM) from day one, even if you cannot deploy it yet, so the wire format already has a slot for it.
- Signatures: ECDSA P-256 or Ed25519 (both elliptic-curve signature schemes; Ed25519 is a solid modern default) today, but if the data or documents being signed need long-term non-repudiation (contracts, archival records), plan a migration path to a post-quantum signature and consider independent timestamping, since a signature's cryptographic strength only needs to hold up to the moment it is verified, but verification might happen decades later.
- Key exchange: always use ephemeral exchange (ECDHE/DHE, the elliptic-curve and classical variants of ephemeral Diffie-Hellman key agreement), never static, for forward secrecy. This has nothing to do with the quantum question and everything to do with limiting the blast radius of any future key compromise.
Building in algorithm agility
- Version every ciphertext, token, and certificate format with an explicit algorithm identifier and key-version field up front (the way TLS cipher suites or a JOSE
algheader work), never a fixed-width blob with an implicit algorithm. - Put crypto operations behind a narrow internal interface (a
Signer, aKeyExchange) so callers never depend on one library's concrete types directly. Swapping an implementation becomes a change behind that interface, not a project-wide find-and-replace. - Support the current and previous algorithm simultaneously during any migration window (dual-read, single-write for new data), never a hard cutover.
- Reuse a standard container format that already treats algorithm identity as first-class (X.509, JOSE/COSE, TLS) instead of inventing your own byte layout.
Documentation
- Keep a living cryptographic inventory (sometimes called a cryptographic bill of materials): every algorithm, key size, library, and where each is used.
- Write an architecture decision record for each choice capturing the threat model assumed and an explicit "review by" date (for example, tied to a known deprecation milestone such as NIST's phased retirement of 112-bit-security algorithms).
- Maintain, and actually rehearse, a migration runbook rather than leaving it as an untested design document.
Worked example. The Grover's-algorithm halving is the one number worth internalizing: a k-bit symmetric key gives roughly 2^(k/2) post-quantum brute-force operations. For AES-128, that is 2^64, within reach of a well-resourced, patient attacker even setting aside classical improvements. For AES-256, that is 2^128, comfortably out of reach for the foreseeable future. That single fact is why "use AES-256, not AES-128" is close to a free future-proofing decision, while the same logic does not rescue RSA or ECC, whose underlying math (factoring, discrete log) is broken outright by Shor's algorithm rather than merely weakened.
Trade-offs and pitfalls. A common wrong turn is defaulting to the mathematically largest option everywhere (RSA-4096 for every signature) without addressing agility: a bigger classical key buys you nothing against a quantum adversary and costs real performance. The opposite failure is designing "agility" as an open-ended plugin architecture supporting dozens of algorithm combinations; that makes testing and certification infeasible. Bound agility to a short, deliberately curated allow-list with a clear default, not an unbounded menu.
Design an internal PKI to issue and manage TLS certificates for a large fleet of microservices across multiple clusters and cloud providers (tens to hundreds of thousands of services, potentially millions of devices). Address CA hierarchy and certificate templates, automated enrollment and renewal (ACME for public-facing certs, a private CA or bespoke protocol internally), revocation at scale (CRL vs OCSP vs short-lived certs), trust distribution, and monitoring of certificate health. If you were hardening the CA itself for internet-facing services, what would Certificate Transparency logging and OCSP-responder scaling add, and what's your incident-response plan if the CA's own key is compromised?
Sample Answer
Direct answer
Build a two- or three-tier hierarchy: an offline, HSM-protected root CA (an HSM, or hardware security module, is tamper-resistant hardware that generates and holds keys so they never leave in plaintext) that almost never signs directly, one or more online issuing CAs that do the actual work, and automated enrollment so no human ever manually requests a certificate. Use ACME for anything internet-facing, since it interoperates with the standard tooling ecosystem, and either an ACME-compatible private CA or a bespoke enrollment protocol for internal workloads where you control both ends. The two hardest parts are keeping the blast radius small if an issuing CA (not the root) is ever compromised, and making renewal automatic enough that revocation checking becomes a secondary defense rather than the primary one.
Structured elaboration
CA hierarchy and certificate templates
- Root CA: offline, HSM-backed, ideally air-gapped and brought online only for scheduled signing ceremonies, signs intermediate CA certificates only, never leaf certificates. Its private key is the single highest-value asset in the system, deliberately used as rarely as possible.
- Issuing (intermediate) CAs: online, HSM-backed, one per environment or region, so that revoking or losing one issuing CA only takes down issuance in its own blast radius, not the whole fleet.
- Certificate templates: predefined profiles (key usage, extended key usage, validity period, allowed names) per workload class, for example a short-validity, narrowly name-constrained template for service-mesh mTLS (mutual TLS, where both sides of a connection present certificates) versus a different one for public TLS termination, so policy is enforced at issuance, not by after-the-fact review.
Automated enrollment and renewal
- Public-facing certificates: ACME (RFC 8555), the protocol Let's Encrypt popularized, buys interoperability with existing load balancers and a mature renewal-tooling ecosystem.
- Internal workloads at this scale (tens to hundreds of thousands of services, potentially millions of devices): run a private CA behind an ACME-compatible endpoint where possible, so the same client tooling works internally and externally, falling back to a bespoke enrollment protocol only where ACME's standard challenge types don't fit, for example devices with no public DNS or exposed HTTP port, which typically enroll instead using a manufacturing-time bootstrap identity certificate presented to an internal registration authority.
- Renew well before expiry (a common pattern renews at roughly two-thirds of the certificate's lifetime) with automatic retry and alerting on repeated failure, a human should never be the one who notices an expiring certificate.
Revocation at scale
- CRL is fine as a low-frequency, offline-verifiable fallback, but its list grows large and its freshness is bounded by publish interval.
- OCSP is closer to real time but puts your own responders in the hot path of every relying party's handshake, so it has to be built and scaled as a first-class, horizontally-scaled service, not a side feature.
- Short-lived certificates are the strongest lever at this scale: if internal workloads re-certify every few days, a compromised or decommissioned certificate ages out fast enough that live revocation checking becomes defense in depth rather than the primary control.
- Practical default: OCSP stapling wherever a live check is still needed, short validity on internal certificates so the issuance automation doubles as the revocation strategy.
Trust distribution
- Distribute only the root CA's public certificate, never an intermediate, to every client and workload's trust store, so intermediates stay freely rotatable without ever touching a trust store.
- Bake the root into the standard fleet bootstrap (base OS or container image, or a versioned trust-bundle distribution job) so a newly launched service can validate the mesh with no separate manual step.
Monitoring certificate health
- Track days-until-expiry as a real-time fleet-wide metric, alert well before expiry, and alert specifically on failed renewal attempts, not only on the resulting expiry.
- Track issuance volume per issuing CA; a sudden spike is either an expected mass-rotation event or a sign that something is enrolling certificates it shouldn't be.
Certificate Transparency and OCSP-responder scaling
- CT logging (publishing every issued certificate to public, append-only, cryptographically verifiable logs) lets anyone, including you, detect mis-issuance for your own domains by a CA you never authorized, whether from a compromise or a process failure. Monitor the public CT logs for your own domains as a standing detective control, independent of what your own CA reports about itself.
- Treat OCSP responders as a normal high-QPS, read-heavy service: horizontally scaled behind a load balancer, backed by a fast read replica of revocation state rather than the CA's primary signing database, capacity-planned against total active-certificate count, not just issuance rate.
Incident response if the CA's own key is compromised
- Root compromise: because the root is used so rarely and kept offline, treat any indication of compromise as an emergency root-rotation event, generate a new root, re-issue new intermediates under it, and migrate trust stores. This is slow and disruptive by design, which is exactly why the root stays offline and rarely used in the first place.
- Issuing-CA compromise: revoke that specific issuing CA's certificate (propagated from the still-trusted root), which immediately invalidates every leaf certificate it ever issued. The practical response is emergency mass re-issuance of that entire population from a different, unaffected issuing CA, using the same automation that already handles routine renewal, triggered immediately and at full scale instead of on the normal rolling schedule.
- Have this as a written runbook before it's needed: which issuing CA covers which workloads, how to trigger emergency re-issuance for exactly that blast radius, and how CT logs and OCSP will surface any certificates an attacker issued that you don't already know about.
flowchart TD
Root[Root CA - offline, HSM, air-gapped] -->|signs| Int1[Issuing CA: production]
Root -->|signs| Int2[Issuing CA: staging]
Int1 -->|ACME| Pub[Public-facing services]
Int1 -->|private enrollment| Svc[Internal microservices]
Int1 -->|bootstrap credential| Dev[Constrained devices]
Int1 -->|publishes issuance| CT[(CT logs)]
Int1 --> OCSP[OCSP responder pool]
Int1 --> CRL[CRL distribution point]
Monitor[Cert health monitor] -->|alerts| Ops[On-call / renewal automation]
Int1 -.telemetry.-> Monitor
Worked example
With 200,000 internal service certificates on a 7-day validity, renewed at day 5 (a 2-day safety margin), steady-state renewal volume is 200,000 divided by 5, or 40,000 certificates a day. If an issuing-CA compromise forces emergency reissuance of the entire population within a single day instead of the normal 5-day cadence, that is 200,000 certificates in that one day, a 200,000 divided by 40,000, or 5x, spike over steady state that the enrollment endpoint's capacity and rate limits need to survive, not just an average day.
Trade-offs and pitfalls
Common wrong turn: putting the root CA online "for convenience," turning your single highest-value key into a routinely exposed one; keep it offline even though that makes root rotation genuinely painful, that pain is the point. Common wrong turn: trusting an intermediate certificate directly in client trust stores instead of only the root, which forces every intermediate rotation to touch every trust store, defeating the reason for the hierarchy. Relying on revocation as the primary compromise defense at this scale is weaker than making certificates short-lived enough that compromise self-heals quickly, treat revocation as defense in depth, not the plan. Senior signal: distinguishing "issuing CA compromised, revoke and mass-reissue" from "root CA compromised, start over," these are very different blast radii and response times, and conflating them in a runbook is a real production risk.
Walk through the TLS handshake step by step (TLS 1.2 or 1.3) and explain what each message accomplishes. Cover how confidentiality, integrity, authentication, and (where applicable) forward secrecy are achieved, and the role certificates, key exchange, and session-key derivation play.
Sample Answer
Direct answer
TLS establishes a shared session key and authenticates the server (and optionally the client) before any application data flows. TLS 1.3 does this in one round trip using mandatory ephemeral key exchange; TLS 1.2 typically needs two round trips and only gets forward secrecy if the negotiated cipher suite chooses it.
Step by step (TLS 1.3, the current default version)
sequenceDiagram
participant C as Client
participant S as Server
C->>S: ClientHello plus key_share
S->>C: ServerHello plus key_share
Note over C,S: Both derive the same ECDH shared secret
S->>C: EncryptedExtensions, Certificate, CertificateVerify, Finished
C->>S: Finished
Note over C,S: Application data, encrypted both directions
- ClientHello: the client proposes supported cipher suites and sends a key_share, its half of one or more Diffie-Hellman exchanges (for example over curve X25519), guessing which group the server will accept so the exchange completes without a wasted round trip.
- ServerHello: the server picks a cipher suite and a key group and sends its own key_share. Both sides now independently compute the same shared secret via elliptic-curve Diffie-Hellman (ECDH). Confidentiality effectively begins here: everything in the server's next flight is encrypted under a key derived from this shared secret.
- EncryptedExtensions, Certificate, CertificateVerify: the server sends its certificate chain and a signature over the whole handshake transcript so far, made with its certificate's private key. This is authentication: proof the server holds the private key matching the certificate it presented.
- Finished (server, then client): each side sends a MAC over the entire transcript, keyed by a handshake secret derived from the shared secret, proving both sides computed the same session keys and that no message was tampered with (integrity).
- Application data: both sides derive traffic keys from the shared secret via HKDF and start exchanging encrypted data. Because a fresh key pair was generated for the key_share exchange and then discarded, this session's traffic keys cannot be reconstructed later even if the server's long-term certificate key is later stolen; forward secrecy holds by construction.
Property by property
- Confidentiality: symmetric encryption (AES-GCM or ChaCha20-Poly1305) using a key derived from the ECDH shared secret.
- Integrity: the authenticated-encryption mode's tag on every record, plus each side's Finished transcript MAC.
- Authentication: the server's (and, for mutual TLS, the client's) certificate-backed signature over the transcript.
- Forward secrecy: guaranteed in TLS 1.3 because the key_share exchange is always ephemeral; the long-term certificate key only ever signs, it never directly encrypts session data.
TLS 1.2 contrast
TLS 1.2 adds a ServerKeyExchange message, present only when the cipher suite uses (EC)DHE, absent for static RSA key transport, and a separate ChangeCipherSpec signal before each side's Finished message. It typically needs an extra round trip and only provides forward secrecy when the negotiated suite actually uses (EC)DHE rather than plain RSA key transport.
Trade-offs and pitfalls
0-RTT resumption in TLS 1.3 trades lower latency for a mild replay risk on the first flight of application data, since there is no fresh randomness there to prevent an attacker from resending it; avoid enabling it for non-idempotent requests without additional replay protection. Do not assume a TLS 1.2 server has forward secrecy by default; verify its cipher-suite priority list actually puts ECDHE suites first.
What is a Key Management Service, and what does the full key-management lifecycle look like for symmetric and asymmetric keys in an enterprise environment? For each stage (generation, provisioning, storage/usage, rotation, revocation, archival, secure destruction), name concrete controls and automation options you'd expect a KMS or HSM to provide, and the audit/logging you'd want at each stage. Compare cloud-managed KMS, HSM-backed KMS, and self-hosted key stores (like HashiCorp Vault) from an operational and decision-criteria standpoint: when would you reach for each?
Sample Answer
Direct answer
A key-management service (KMS) generates, stores, and controls the use of cryptographic keys without ever handing raw key material to the applications that use it: applications send data (or a wrapped key) and get back a result, never the key itself. Whether that KMS is a cloud-managed service, an on-premises hardware security module (HSM), or a self-hosted secrets manager is a decision about who controls the boundary the key never crosses, not about whether encryption happens.
The key lifecycle, stage by stage (the stages are the same for symmetric and asymmetric keys; only the storage/usage operations differ)
| Stage | What happens | Controls and automation | Audit and logging |
|---|---|---|---|
| Generation | Key material is created with a cryptographically secure random number generator, ideally inside the HSM/KMS boundary | Hardware random-number generator inside the HSM; enforced key-length/algorithm policy | Who requested generation, for what purpose, and the resulting key identifier and version |
| Provisioning | The key is made available to authorized services | Access policy binding the key to specific roles/services (least privilege); for asymmetric keys, distributing only the public half where possible | Every policy grant or change |
| Storage and usage | The key sits encrypted at rest, often wrapped by a KMS/HSM master key, and is used via API calls (encrypt/decrypt/sign/verify) rather than exported | Usage restricted to specific operations (a signing key that can only sign, never decrypt); rate limiting and anomaly detection on usage volume | Every single use: caller identity, operation, timestamp, and key version |
| Rotation | The active key is periodically replaced by a new version while old versions remain available to decrypt or verify data they already protected | Automated rotation schedules; for symmetric data-encryption keys, a key-encryption-key hierarchy so rotating the top key does not require touching the data | Rotation events and which version range remains valid for verification |
| Revocation | A key is marked untrusted before its normal retirement, typically on suspected compromise | Immediate propagation to every relying party's trust/verification list | Revocation reason, initiator, and propagation confirmation across systems |
| Archival | Retired keys are kept, encrypted, for as long as needed to decrypt or verify historical data, but are no longer used for new operations | Read-only access policy; a separate, more restrictive storage tier | Every archival access, since it is rarer and more suspicious by default |
| Secure destruction | Key material is irrecoverably deleted; cryptographic shredding is often the practical version of "destroying" data you cannot otherwise find and erase | Dual control (two-person authorization) before permanent deletion; a mandatory waiting or appeal window | The destruction request, dual-control approvals, and a permanent record that the key existed and was destroyed on a given date |
Comparing the three approaches
| Option | Where the key boundary lives | Best when |
|---|---|---|
| Cloud-managed KMS | Inside the cloud provider's infrastructure; you control policy, not physical hardware | You want low operational overhead and tight integration with the rest of a cloud provider's services, and accept its shared-responsibility model for the hardware layer |
| HSM-backed KMS | A dedicated hardware module, often validated against FIPS 140-3 (the current U.S. federal cryptographic-module standard; FIPS 140-2 certificates move to historical status by September 2026) | Regulatory or contractual requirements demand a specific, auditable hardware assurance level, or you need "hold your own key" control where the provider never sees the key at all |
| Self-hosted key store (for example HashiCorp Vault) | Entirely within your own infrastructure | You need full control over the software stack and deployment model, operate outside a single cloud provider, or have requirements a shared multi-tenant service cannot satisfy, at the cost of owning the operational burden yourself |
Worked example
A data platform storing per-tenant records typically holds a small number of key-encryption keys in the KMS/HSM (one or a handful per tenant, or a shared key with per-tenant data-encryption keys) and generates a fresh data-encryption key per object or per batch; only that small key ever needs to be sent to the KMS to unwrap, so the KMS's per-operation cost stays proportional to the number of distinct data-encryption keys, not the volume of underlying data.
Trade-offs and pitfalls
Do not conflate "we use a cloud KMS" with "we have a FIPS 140-3 validated system": the certification applies to a specific hardware/firmware module at a specific validation level (1 through 4), not automatically to every service built on top of it or to your own key-management practices. The most common real-world gap is not choosing the wrong option above, it is under-provisioning the audit-logging stage: if you cannot answer who used a key, when, and for what, after the fact, the KMS choice does not matter.
Describe the core components and trust model of an enterprise Public Key Infrastructure: root CA, intermediate CAs, issuing CAs, certificate profiles and validity periods, registration authorities, and the strategies (offline root, short-lived certs, cross-certification) used to limit blast radius if a CA is compromised. Then walk through what actually happens end to end for one certificate: how it's requested and issued (CSR, CA validation), how a client validates the resulting chain (chain verification, hostname checks), and how automated issuance (e.g. Let's Encrypt / ACME) changes that story at scale.
Sample Answer
Direct answer
A production public key infrastructure (PKI) is a tree of trust: an offline root certificate authority (CA) signs one or a few intermediate CAs, which in turn sign the issuing CAs that actually hand out end-entity certificates. Nobody trusts an end-entity certificate directly; they trust it because it chains up to a root their software already trusts.
Trust model and components
- Root CA: the ultimate trust anchor, pre-installed in operating systems' and browsers' trust stores. Because compromising it would let an attacker mint a trusted certificate for anything, it is kept offline (air-gapped, powered on only to sign new intermediates) and used as rarely as possible.
- Intermediate CA: signed by the root, does the actual day-to-day signing directly or through issuing CAs beneath it. Splitting root from intermediate means a compromised or misused intermediate can be revoked without touching the root already baked into every trust store, avoiding a mass client update.
- Issuing CA: the online intermediate (or sub-CA) that actually processes certificate requests. Large organizations often run separate issuing CAs per purpose (TLS server certs, code-signing certs, client-auth certs), so a problem in one issuing path does not force revoking every certificate type at once.
- Registration authority (RA): the component, sometimes separate, sometimes folded into the issuing CA, that verifies a requester actually controls the domain or identity being certified before the CA signs anything.
- Certificate profiles and validity periods: a profile defines the fields and extensions a given certificate type must carry (key usage, extended key usage, subject alternative names). Shorter validity periods shrink the window a compromised or mis-issued certificate stays dangerous: the CA/Browser Forum's baseline requirements capped public web TLS certificates at 398 days for years, but a phased reduction already dropped that ceiling to 200 days in March 2026, with 100 days due in March 2027 and 47 days by March 2029.
Limiting blast radius if a CA is compromised
- Offline root: the root's private key never touches a network-connected machine, so remote compromise of issuing infrastructure cannot reach it directly.
- Short-lived certificates: if certificates expire in days rather than years, a compromised issuing CA's damage window is bounded by how quickly you detect and revoke it, and even undetected mis-issuance ages out fast.
- Cross-certification: having two independent CAs certify the same intermediate, or maintaining alternate trusted paths, means a single CA's revocation does not instantly break every relying party, giving a rollover path instead of a hard outage.
End-to-end walkthrough for one certificate
- Request and issuance: the requester generates a key pair and a certificate signing request (CSR), a self-signed message asserting "I hold the private key matching this public key, and I am requesting a certificate for this identity." The RA/CA validates control of the domain (a DNS record, an HTTP file, or an out-of-band check) or identity, then the issuing CA signs the CSR's public key and identity into a certificate.
- Client validation: a client receiving the certificate walks the chain up to a trusted root (chain verification), checks the certificate has not expired or been revoked, and checks the hostname it connected to matches a name listed in the certificate (hostname/Subject Alternative Name check). Any one of those failing should hard-fail the connection.
- Automated issuance at scale: the Automatic Certificate Management Environment (ACME) protocol, used by Let's Encrypt and most modern CAs, replaces manual CSR handling with an API: the client proves domain control programmatically (an HTTP or DNS challenge) and gets a certificate issued and renewed automatically, often on a 90-day lifetime. This is what makes short-lived certificates operationally viable at scale; doing this by hand across a large fleet would be a full-time job, but ACME turns it into unattended automation.
Worked example
example.com's certificate might be signed by "Acme Issuing CA G2," which is signed by "Acme Intermediate CA," which is signed by the offline "Acme Root CA X1" baked into an operating system's trust store; verifying the chain means checking each of those two signatures in turn before trusting example.com at all.
Trade-offs and pitfalls
Relying only on the default trust-store setup without your own operational monitoring for renewal and revocation is exactly what causes expired-certificate outages. OCSP stapling (the server proactively attaches a signed revocation-status response) exists because live client-side OCSP lookups add latency and leak browsing metadata to the CA; understanding why matters more than memorizing the acronym.
Unlock Full Question Bank
Get access to all 24 Applied Cryptography and Key Management interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.