Security Notes
Cryptography & Identity

Cryptography — Practical Fundamentals

This file is the interview-ready fundamentals: what each thing is in plain English, the problem it solves, where it's actually used today, and what you should recommend. No code, no heavy math — just the things an interviewer will actually ask you to explain out loud.

26 min read 15 sections 12 model answers verified 2026-06

Last verified2026-06 Breadth layer: notes-security-core-knowledge.md Also see: TLS & Encryption


The Big Picture: what crypto is for

Almost every interview question reduces to one of four jobs. If you can name the job, you can pick the tool.

The job (plain English)The technical nameThe tool you reach for
"Keep this secret"ConfidentialitySymmetric encryption (AES-GCM, ChaCha20)
"Prove it wasn't changed"IntegrityHashing (SHA-256)
"Prove who sent it"AuthenticityMAC (shared secret) or signature (key pair)
"Agree on a secret over an open wire"Key exchangeDiffie-Hellman (ECDHE)

The one rule that ties it together: asymmetric crypto is slow, so we only use it to establish trust and agree on a shared key. Then fast symmetric crypto does the actual bulk encryption. That is TLS in a single sentence — the handshake is asymmetric, the conversation is symmetric.


Symmetric Encryption

What is it?One shared key encrypts and decrypts. Like a physical key that both locks and unlocks the same box. Fast — it's what actually encrypts your data.

Why it mattersThis is the workhorse. Every HTTPS page, every encrypted disk, every VPN tunnel is symmetric encryption doing the heavy lifting. The hard part isn't the cipher; it's getting the shared key to both sides safely — which is why the rest of cryptography exists.

Where it's usedTLS sessions, disk encryption (BitLocker, FileVault, LUKS), VPNs (WireGuard, IPsec), Wi-Fi (WPA2/WPA3), SSH sessions, cloud storage at rest.

The two ciphers you need to know

AES-GCM

the default. AES is the standard block cipher; GCM is the mode that adds built-in tamper-detection (it both encrypts and authenticates in one pass). Fast on any modern CPU because the hardware has a dedicated AES instruction.

ChaCha20-Poly1305

the alternative for devices without AES hardware acceleration (older phones, embedded/IoT). Faster than AES in pure software and naturally resistant to timing side-channels.

Both are AEAD ciphers — "Authenticated Encryption with Associated Data." AEAD means the cipher also detects tampering; if even one bit of the ciphertext is flipped, decryption fails loudly instead of returning garbage. Always use AEAD. The bare cipher modes that don't authenticate (ECB, CBC, CTR on their own) are how padding-oracle and bit-flipping attacks happen.

Memory hook

"Use AES-GCM, and never reuse a nonce." A nonce is a "number used once" — a small value that must be unique for every message under the same key. Reusing a nonce with GCM is catastrophic: it leaks the relationship between two plaintexts and lets an attacker forge valid messages. If nonce uniqueness is hard to guarantee (e.g. random generation across many servers), use AES-GCM-SIV, which is designed to survive accidental reuse.

Why you'll hear "never use ECB"ECB encrypts each chunk independently, so identical input chunks produce identical output chunks. The famous "ECB penguin" image is still recognizable after encryption because the pattern leaks straight through. ECB is the canonical "you did encryption wrong" answer.

Recommendation

Use AES-256-GCM by default; use ChaCha20-Poly1305 where there's no AES hardware. Never roll your own mode, never use ECB, never reuse a nonce.


Asymmetric Encryption

What is it?A pair of mathematically linked keys: a public key you hand out freely and a private key you guard. What one key does, only the other can undo. It's slow, so it's never used for bulk data — only for two jobs: agreeing on a key and signatures.

Why it mattersIt solves the problem symmetric crypto can't: how do two strangers who never met establish a secret over a wire an attacker is watching? The public key can be shouted across the room; only the private-key holder can act on it.

The mirror-image roles (the part that trips people up):

Encrypt for secrecy

encrypt with the recipient's public key, so only their private key can read it.

Sign for proof

sign with your own private key, so anyone with your public key can verify it was you.

You cannot sign with a public key. Encrypt-to-public, sign-with-private.

RSA vs Elliptic Curve

RSAElliptic Curve (ECC)
Based onFactoring big numbers is hardElliptic-curve discrete log is hard
Key size for ~128-bit security3072 bits256 bits
SpeedSlower, biggerFaster, smaller
StatusFine but legacy-leaningThe modern default

ECC gets the same security with far smaller keys — a 256-bit ECC key ≈ a 3072-bit RSA key. Smaller and faster is why everything new (TLS, SSH, Signal, modern certificates) leans elliptic-curve.

The curves to know

Curve25519 / X25519

modern default for key exchange. Fast, hard to implement wrong.

Ed25519

modern default for signatures. Deterministic (see below), no random-number footguns.

P-256 / P-384

older NIST curves; still everywhere in TLS and required for some government/compliance use.

secp256k1

Bitcoin and Ethereum (not used in TLS).

Memory hook

ECDSA vs Ed25519 — the "k" footgun. Traditional elliptic-curve signing (ECDSA) needs a fresh random number per signature. If that random number ever repeats or is predictable, the private key falls right out of two signatures — this is exactly how the Sony PS3 was hacked and how Bitcoin wallets have been drained. Ed25519 removes the random number entirely by deriving it deterministically from the message and key, so there's no RNG to fail. Interview line: "ECDSA's safety depends on a perfect random generator; Ed25519 removes that dependency."

Recommendation

Prefer Ed25519 / X25519 for new systems. RSA (2048-bit minimum, 4096 for long-lived keys) is fine where you need broad compatibility. Never use raw "textbook" RSA — encryption needs OAEP padding, signatures need PSS padding.


Diffie-Hellman and Forward Secrecy

What is it?A way for two people to agree on a shared secret while everyone is listening, without ever sending the secret. Each side mixes a public value with their own private value; the math works out so both arrive at the same answer but an eavesdropper can't.

Memory hook

The paint analogy (interviewers love this). Both sides start with a public, shared paint colour. Each secretly adds their own colour and swaps the mixed buckets in the open. Each then adds their secret colour to the other's bucket — and both end up with the identical final mix. An eavesdropper saw the two mixed buckets but can't "un-mix" paint to recover either secret. Mixing is easy; separating is hard. That's the whole trick.

Why it matters — Forward SecrecyThe "E" in ECDHE (Elliptic-Curve Diffie-Hellman Ephemeral) means a brand-new throwaway key pair every session, discarded right after. This gives forward secrecy: if an attacker records your encrypted traffic today and steals the server's private key a year from now, they still can't decrypt the old recordings, because the keys that protected them no longer exist.

This is the single biggest security win of TLS 1.3: it requires ephemeral Diffie-Hellman, so every connection has forward secrecy automatically. (Old TLS 1.2 allowed a mode where the client encrypted the session key to the server's long-term RSA key — steal that key later and all recorded traffic unlocks. TLS 1.3 deleted that mode.)


Hashing

What is it?A one-way function that turns any input into a fixed-size fingerprint (a "digest"). Same input always gives the same fingerprint; you can't run it backwards; and you can't find two inputs with the same fingerprint.

Why it mattersHashing is how we check integrity ("did this file/message change?") and how we build fingerprints for signatures, certificates, and version control. When you verify a download's checksum or Git identifies a commit, that's hashing.

Where it's usedTLS and certificate signatures, HMAC, Git commit IDs, file integrity checks, blockchain proof-of-work, password storage (with special slow hashes — see below).

AlgorithmStatusUse it for
MD5BrokenNothing security-related; non-security checksums only
SHA-1Broken (collision found 2017)Avoid; being removed everywhere
SHA-256SecureThe default for almost everything
SHA-384 / SHA-512SecureHigher-security or 64-bit-optimized use
SHA-3SecureAlternative design; backup if SHA-2 ever falls
BLAKE3SecureVery fast; modern tooling and checksums
Memory hook

Why hash security is "half" the bit length — the birthday paradox. In a room of just 23 people, there's a >50% chance two share a birthday — surprising, because you're comparing every pair, not matching one specific date. The same math means finding a collision in an n-bit hash takes ~2^(n/2) tries, not 2^n. So a 256-bit hash gives only ~128-bit collision resistance. This is why 128-bit MD5 (only ~64-bit collision strength) fell so easily, and why you want generously sized digests.

Recommendation

SHA-256 for general integrity and signatures. Never use a plain hash for passwords — that's a different problem (next section).


Password Storage

Last verified2026-06 — Argon2id is the current OWASP first choice.

The problemIf your user database leaks, the attacker has every password hash and unlimited time to guess offline. A fast hash like SHA-256 does billions of guesses per second on a GPU — so a fast hash is a bad password hash.

The fix: deliberately slow, memory-hungry hashesPassword hashes are engineered to be expensive so an attacker can only try a few hundred or thousand guesses per second instead of billions.

FunctionNotes
Argon2idModern winner. Memory-hard — forces each guess to use lots of RAM, which defeats cheap GPU/ASIC cracking farms. First choice for new systems.
scryptAlso memory-hard; good, slightly older.
bcryptStill acceptable; CPU-hard but uses little memory, so easier to parallelize than Argon2id.
PBKDF2Legacy/compliance; weakest of these because it's not memory-hard.

Always add a salt — a unique random value per password, stored alongside the hash. The salt means two users with the same password get different hashes, so one precomputed "rainbow table" can't crack everyone at once. (A pepper — a secret added to all passwords and kept out of the database — is an optional extra layer.)

Memory hook

"a fast hash is a bad password hash." General hashes are built for speed; password hashes are built to be slow on purpose. bcrypt is slow; scrypt and Argon2id are also memory-hard so attackers can't just throw cheap parallel hardware at them.

Recommendation

Argon2id for new systems; bcrypt is acceptable for existing ones. Always per-password salt. Never SHA-256/MD5 for passwords.


MACs and Digital Signatures

Both answer "who sent this, and was it tampered with?" — but they trust differently.

MAC (Message Authentication Code)

What is it?A keyed fingerprint. Both sides share one secret key; the sender attaches a tag, the receiver recomputes it. If the tags match, the message is authentic and unmodified. The common one is HMAC (e.g. HMAC-SHA256).

Where it's usedAPI request signing (AWS signs requests with HMAC-SHA256), session tokens, JWT "HS256", inside TLS.

The catch — symmetric trustBecause both sides hold the same key, a MAC proves the message came from someone who has the key — but the receiver could have forged it too. So a MAC gives integrity + authenticity between two trusting parties, but not non-repudiation (you can't prove to a third party which of the two sent it).

⚠️

Don't roll your own MAC by writing hash(secret + message). With SHA-256 that's vulnerable to a "length-extension attack" — an attacker who sees the tag can append data and produce a valid tag without knowing the secret. HMAC's nested design prevents this. Use HMAC, not naive concatenation.

Digital Signature

What is it?Same goal, but with a key pair. You sign with your private key; anyone verifies with your public key. Since only you have the private key, a valid signature proves you specifically signed it — and you can't deny it later (non-repudiation).

Where it's usedTLS certificates (the CA signs your cert), code signing (Windows/macOS apps, software updates), Git commit signing, JWT "RS256/ES256", document signing.

MAC (HMAC)Signature (RSA/Ed25519)
KeysOne shared secretPublic/private pair
SpeedVery fastSlower
Non-repudiationNoYes
Use whenBoth parties trust each otherA third party must verify; identity matters

How TLS Works

What is it?TLS ("Transport Layer Security," the "S" in HTTPS) is the protocol that turns an open internet connection into a private, authenticated one. It does three things: encrypts the traffic, proves the server's identity (via its certificate), and detects tampering.

The whole idea in four steps

Agree on keys

without sending them → Diffie-Hellman (ECDHE).

Prove the server is who it claims

the server presents a certificate and signs the handshake with its private key.

Switch to fast encryption

both sides derive the same symmetric keys and use AES-GCM/ChaCha20 for the rest.

Detect tampering

AEAD ciphers reject any modified data.

So: asymmetric to set up trust and a shared key, symmetric for the actual conversation.

TLS 1.3 handshake (1 round trip)

Client                                         Server
  │── ClientHello ──────────────────────────────►│
  │   "here are the ciphers I support,            │
  │    and here's my ECDHE key share already"     │
  │                                               │
  │◄───────────────────────── ServerHello ────────│
  │   "picked this cipher, here's my key share"   │
  │◄──── {Certificate} ───────────────────────────│  ← from here on, encrypted
  │◄──── {CertificateVerify} ─────────────────────│  signature proving it owns the cert
  │◄──── {Finished} ──────────────────────────────│
  │                                               │
  │── {Finished} ────────────────────────────────►│
  │                                               │
  │════════ encrypted application data ══════════ │

The clever bitthe client sends its key share in the very first message — it doesn't ask permission first. Because both sides can derive the shared secret right after ServerHello, the server can encrypt the certificate itself, so a passive eavesdropper can't even see which site you're visiting from the certificate.


TLS 1.3 vs TLS 1.2

Last verified2026-06 — TLS 1.3 (RFC 8446, 2018) is the default in all major browsers and servers; TLS 1.0/1.1 are disabled.

The honest interview answer is: TLS 1.3 is faster and removed all the ways to do it insecurely.

TLS 1.2TLS 1.3
Handshake speed2 round trips1 round trip (0 with resumption)
Forward secrecyOptionalMandatory
Cipher choicesDozens, including weak/broken ones5, all modern AEAD
Old broken stuff (RC4, 3DES, MD5, RSA key transport)Still allowedRemoved
CertificateSent in the clearEncrypted
Downgrade attacks (POODLE, etc.)PossibleDesigned out

Why this matters in one sentenceTLS 1.2 was insecure mostly through bad configuration — leaving weak ciphers enabled. TLS 1.3 deletes the bad options entirely, so you can't misconfigure your way into a weak handshake.

Memory hook

Why 1.3 is one round tripin 1.2 the client first asks which key exchange to use, waits, then sends its key. In 1.3 there's only one key-exchange family (ECDHE), so the client just sends its key share immediately. 1.2 negotiates-then-acts; 1.3 acts because there's nothing left to negotiate.

0-RTT caveat (a common follow-up)TLS 1.3 can resume a previous session with zero round trips by sending data in the first packet. The risk is replay — a network attacker can capture and re-send that early data. So 0-RTT is only safe for idempotent requests (a GET that just reads), never for "transfer money."


Certificates and PKI

The problem certificates solvePublic-key crypto lets a server hand you a public key — but how do you know it's really bank.com's key and not an attacker's? Anyone can generate a key pair and claim any name.

The passport analogy (the best way to explain PKI):

  • You don't personally verify every traveler. You trust the government (the Certificate Authority, CA) that issued the passport.
  • The passport (the certificate) binds an identity (a domain name) to a tamper-proof government signature (the CA's signature).
  • Border control (your browser) carries a list of trusted governments (the root store) and checks the passport against it.
  • If a country starts issuing fake passports, everyone stops trusting it (a CA gets distrusted — this has really happened).

So a certificate is just: a public key + an identity + an expiry date, all signed by a CA your browser already trusts. That's the whole idea.

The chain of trust

Root CA          (self-signed, kept offline in a vault, pre-installed in your device)
   └── Intermediate CA   (signed by the root; does the day-to-day issuing)
          └── Your server's certificate   (signed by the intermediate)

Your browser trusts the root. The root vouches for the intermediate. The intermediate vouches for the server. The root key stays offline so it can't be stolen; if an intermediate is compromised it can be revoked without burning the root.

Types of certificate (what an interviewer probes)

By how much identity was checked

DV (Domain Validated)

CA only checks you control the domain. Automated, seconds, free (all Let's Encrypt certs). The vast majority of HTTPS today.

OV / EV (Organization / Extended Validation)

CA also verifies the legal organization. Slower, manual, for corporates and banks.

Memory hook

The old EV "green bar" with the company name is gone — browsers removed it around 2019 because users never noticed it and it gave no real anti-phishing benefit. Today a DV and EV cert look identical: a plain padlock. The padlock means "encrypted," not "trustworthy" — phishing sites have valid certificates too.

By how many names they cover

Single name

www.example.com.

SAN (Subject Alternative Name)

a list, e.g. example.com, api.example.com, mail.example.com in one cert. This is what browsers actually check — the old CN field is ignored.

Wildcard

*.example.com covers all direct subdomains. Convenient, but one stolen key impersonates every subdomain, and it doesn't cover deeper levels (a.b.example.com).

Let's Encrypt and short lifetimes

Free, automated DV certs (via the ACME protocol) made HTTPS universal. Their certs last only ~90 days (and the industry is moving toward even shorter). Short lifetimes are a feature: a stolen key is only useful briefly, and broken revocation matters less because the cert expires soon anyway. This only works because renewal is fully automated.

Revocation (when a cert must die early)

If a private key is stolen before expiry, you need to revoke the cert. This is the genuinely weak part of PKI:

CRL

a big list of revoked certs; stale and bulky.

OCSP

ask the CA in real time; but this leaks your browsing to the CA and adds latency, so browsers often "soft-fail" (skip the check if it's slow).

OCSP Stapling

the server fetches a fresh signed "still valid" proof and attaches it to the handshake. Fixes the privacy leak and latency. This is the preferred approach.

The practical reality: revocation is unreliable, which is the real reason the industry chose short-lived certificates instead.

Certificate Transparency (CT)

Every publicly trusted certificate must be recorded in public, append-only logs, and browsers reject certs that aren't. Why it exists: in 2011 the CA DigiNotar was hacked and secretly issued a fake *.google.com cert used to spy on ~300,000 users in Iran — and nobody could see it. CT makes secret mis-issuance visible: you can monitor the logs (via crt.sh) for any certificate issued for your domain. The trade-off: CT also lets attackers enumerate your subdomains, since every cert you get publicly reveals a hostname.


How to Verify a Certificate (as a user)

A very common practical question: "You visit a site — how do you actually know the certificate is legit?" Walk through what the browser checks, in order:

Is it signed by a trusted CA?

Follow the chain from the server's cert up through the intermediate(s) to a root that's in the device's trust store. If the chain doesn't reach a trusted root → untrusted (this is what a self-signed cert fails).

Does the name match?

The hostname you typed must appear in the cert's SAN list. bank.com's cert must actually say bank.com. Mismatch → error.

Is it still valid in time?

Current date must be between the cert's "not before" and "not after." Expired → error.

Has it been revoked?

Check via OCSP stapling / CRL where available.

Is it in the CT logs?

Browsers require proof the cert was publicly logged.

As a human double-checking manuallyclick the padlock → "Connection is secure" → view the certificate. Confirm the issuer is a real CA, the subject/SAN matches the domain exactly (watch for look-alikes like bank-secure.com), and the validity dates are current. But remember the limit: a valid cert only proves "this is really the domain in the address bar and the traffic is encrypted." It does not prove the site is honest — a phishing domain can hold a perfectly valid DV certificate.

Memory hook

The key insight interviewers wantthe certificate authenticates the domain name, not the intentions of whoever owns it. Verifying the cert stops a man-in-the-middle; it doesn't stop you from voluntarily visiting a scam site.


mTLS (Mutual TLS)

What is it?Normal TLS proves only the server's identity to the client — you verify the bank, the bank doesn't cryptographically verify you (you log in with a password instead). mTLS makes it two-way: the client also presents a certificate, so both sides prove their identity with keys.

Normal TLS:   Client ──checks──► Server's cert      (only server proves identity)
mTLS:         Client ──checks──► Server's cert
              Client ◄──checks── presents own cert  (both prove identity)

The problem it solvesPasswords and API keys can be phished, leaked, or replayed. A client certificate is a cryptographic identity that can't be guessed and can be tightly scoped and rotated. mTLS answers "is this really an authorized service/device, not just someone who got hold of a token?"

Where it's used (this is the practical part):

Service-to-service / microservices

service A proves its identity to service B inside a cluster. This is the backbone of zero-trust networking and service meshes (Istio, Linkerd, SPIFFE/SPIRE).

Kubernetes

control-plane components authenticate to each other with mTLS.

B2B APIs and banking/open-banking

partners are issued client certs instead of just API keys.

Device authentication

IoT fleets and corporate laptops carry client certs to prove they're managed.

VPN / zero-trust access

the device cert is one factor proving the endpoint is trusted.

Why not use it everywhere?Every client needs its own cert, and you need to issue, distribute, rotate, and revoke all of them — that's a lot of PKI plumbing. So mTLS shines for machine-to-machine identity (a fixed, managed set of clients) and is rare for ordinary human web users, where passwords + MFA are easier to manage.

Recommendation

Use mTLS for internal service-to-service auth and machine identity, ideally automated by a service mesh or a workload-identity system (SPIFFE) so cert rotation isn't manual. For human users, stick with passwords + phishing-resistant MFA (FIDO2/passkeys).


The Quantum Question

Last verified2026-06 — NIST published the first post-quantum standards in 2024 (FIPS 203/204/205); hybrid TLS key exchange is shipping in major browsers.

You'll get one quantum question. Keep it simple — there are two quantum algorithms and they do different damage:

Shor's algorithmGrover's algorithm
HitsAsymmetric cryptoSymmetric crypto and hashes
DamageBreaks RSA, Diffie-Hellman, ECDH, ECDSA completely (efficient factoring and discrete logs)Halves effective strength: AES-128 → ~64-bit, AES-256 → ~128-bit
FixReplace the algorithm: ML-KEM (FIPS 203) for key exchange, ML-DSA (FIPS 204) for signaturesUse 256-bit keys and SHA-256 or better; nothing to replace
UrgencyHigh — this is the real threatLow
Warning

Harvest now, decrypt laterAn attacker can record encrypted traffic today and decrypt it once a large quantum computer exists. Any data that must stay secret for a decade is already at risk, which is why key exchange is being migrated first.

The responseTLS is rolling post-quantum key exchange out as a hybrid (X25519 + ML-KEM-768 together), so the session stays safe as long as either algorithm holds. Post-quantum signatures in certificates come later, because they make certificate chains several kilobytes larger.


Recommendations Cheat Sheet

Last verified2026-06

JobUse this
Encrypt data (general)AES-256-GCM
Encrypt without AES hardware (mobile/IoT)ChaCha20-Poly1305
Encrypt with risky nonce uniquenessAES-GCM-SIV
Key exchangeECDHE with X25519
Signatures (new systems)Ed25519
Signatures (broad compatibility)RSA-2048+ with PSS padding
General hashing / integritySHA-256
Password storageArgon2id (bcrypt acceptable)
Shared-secret authenticationHMAC-SHA256
Web encryption + identityTLS 1.3
Service-to-service identitymTLS (automated via service mesh)
Disk encryptionAES-XTS-256
SSH keysEd25519 (-sk hardware-backed for high value)

Universal rulesnever invent your own crypto, never use ECB, never reuse a nonce, always salt passwords, prefer authenticated (AEAD) encryption, and prefer the elliptic-curve / TLS 1.3 / Argon2id "modern defaults" unless compatibility forces otherwise.


Interview Questions

Q
In one sentence, why do we use both asymmetric and symmetric crypto in TLS?
Model answer

Asymmetric crypto is slow but solves trust and key distribution, so we use it only to verify the server's identity and agree on a shared key; then fast symmetric crypto (AES-GCM) encrypts the actual conversation. You get the trust benefits of public-key crypto with the speed of symmetric — that combination is TLS.

Q
What problem does Diffie-Hellman solve, and what is forward secrecy?
Model answer

Diffie-Hellman lets two parties agree on a shared secret over a channel an attacker is watching, without ever transmitting the secret — like mixing paint where the mixed colours are public but you can't un-mix them. Using ephemeral Diffie-Hellman (ECDHE), a fresh throwaway key pair per session, gives forward secrecy: if the server's long-term key is stolen later, previously recorded traffic still can't be decrypted because those session keys no longer exist. TLS 1.3 makes this mandatory.

Q
Walk me through how TLS 1.3 works at a high level.
Model answer

The client sends a ClientHello that already includes its ephemeral ECDHE key share, guessing the server will accept — which is what cuts it to one round trip. The server replies with its own key share, and from that point both sides derive the shared keys, so the server can already encrypt its certificate, a signature proving it owns that certificate, and a Finished message. The client verifies the certificate chain and sends its own Finished, then encrypted application data flows. TLS 1.3 mandates forward secrecy, encrypts the certificate, and removed all the legacy weak algorithms.

Q
What actually changed between TLS 1.2 and 1.3?
Model answer

TLS 1.3 is one round trip instead of two, makes forward secrecy mandatory, encrypts the certificate, and — most importantly — deleted all the weak options: RSA key transport, RC4, 3DES, MD5, and the dozens of negotiable cipher suites are gone, leaving five modern AEAD suites. The deeper point is that most TLS 1.2 breaches came from misconfiguration — leaving weak ciphers enabled — and 1.3 removes the weak options entirely so you can't misconfigure your way into them.

Q
You visit a site — how does your browser decide the certificate is valid?
Model answer

It checks five things: the certificate chains up to a CA in the device's trusted root store; the hostname you typed matches the certificate's Subject Alternative Name list; the current date is within the validity window; it hasn't been revoked (via OCSP stapling or a CRL); and it's present in the public Certificate Transparency logs. The crucial caveat is that all this proves is "this really is the domain in the address bar and the connection is encrypted" — it does not prove the site is honest, since phishing domains can hold perfectly valid certificates.

Q
What's the difference between a MAC and a digital signature?
Model answer

Both prove a message is authentic and untampered, but a MAC like HMAC uses a single shared secret, so either party could have produced it — it gives integrity and authenticity between two trusting sides but not non-repudiation. A digital signature uses a private/public key pair: you sign with your private key and anyone verifies with your public key, so it proves you specifically signed it and you can't deny it later. Use a MAC for fast authentication between trusting parties, and a signature when a third party must verify identity, like a CA signing a certificate.

Q
What is mTLS and where would you actually use it?
Model answer

Mutual TLS is two-way authentication — on top of the server proving its identity, the client also presents a certificate, so both sides prove who they are with keys instead of just a password or API token that could be phished or replayed. It's the backbone of zero-trust service-to-service auth: microservices in a mesh, Kubernetes control-plane components, B2B and open-banking APIs, and device identity for IoT or managed laptops. It's great for machine-to-machine identity because the client set is fixed and manageable, but it's rare for human web users because issuing and rotating a certificate per user is heavy compared to passwords plus MFA.

Q
Why can't you just use SHA-256 to store passwords?
Model answer

SHA-256 is built to be fast — billions of hashes per second on a GPU — so if your password database leaks, an attacker brute-forces it almost for free. Password storage needs a deliberately slow, memory-hungry function: Argon2id is the modern choice because it's memory-hard, which defeats cheap parallel GPU and ASIC cracking, with bcrypt as an acceptable alternative. Always add a unique per-password salt so one rainbow table can't crack everyone at once. The whole goal is to drop the attacker from billions of guesses per second to a few hundred.

Q
What does "never reuse a nonce" mean and why does it matter?
Model answer

A nonce is a number used once — a value that must be unique for every message encrypted under the same key. With AES-GCM, reusing a nonce is catastrophic: the two messages get XORed against the same keystream, leaking the relationship between the plaintexts, and worse, it lets an attacker recover the authentication key and forge valid messages. So a single reuse breaks both confidentiality and integrity. Use a fresh random or counter-based nonce, or AES-GCM-SIV if guaranteeing uniqueness is hard, since it's designed to survive accidental reuse.

Q
Why is elliptic-curve crypto preferred over RSA today?
Model answer

Elliptic-curve crypto gives the same security as RSA with far smaller keys — a 256-bit curve roughly equals a 3072-bit RSA key — so it's faster and uses less bandwidth, which matters for TLS handshakes and constrained devices. The modern defaults are X25519 for key exchange and Ed25519 for signatures; Ed25519 is also deterministic, which removes the random-number weakness that has leaked ECDSA and RSA-era keys. RSA is still fine for compatibility, but new systems lean elliptic-curve.

Q
What's the quantum threat to cryptography, and what do we do about it?
Model answer

There are two quantum algorithms. Shor's would efficiently break all the asymmetric crypto we rely on — RSA, Diffie-Hellman, ECDH, ECDSA — so that's the serious threat. Grover's only halves symmetric strength, so AES-256 stays safe and you just avoid AES-128. The urgency comes from "harvest now, decrypt later": attackers can record encrypted traffic today and decrypt it once quantum computers exist. The response is NIST's post-quantum standards — ML-KEM for key exchange and ML-DSA for signatures — now being deployed in TLS as hybrids alongside X25519, so you're safe even if one scheme is later broken.

Q
What problem does Certificate Transparency solve?
Model answer

It makes certificate mis-issuance visible. Every publicly trusted certificate must be recorded in public append-only logs, and browsers reject certs that aren't, so anyone — including you, monitoring your own domains via crt.sh — can detect a certificate issued without authorization. It exists because of DigiNotar in 2011, a CA that was hacked and secretly issued a fake Google certificate used to spy on hundreds of thousands of users, with no way to detect it at the time. The trade-off is that the logs also expose all your subdomains to attackers doing reconnaissance.