Concepts

Cryptography for Secure Networks

How a handful of mathematical primitives become the trust fabric of the internet: shared-key speed, public-key reach, certificates that bind keys to names, and the protocol that stitches them together every time a padlock appears.

01What cryptography buys you

Networks are shared, observable, and hostile by default. Anyone on the path can read, copy, alter, replay, or inject traffic. Cryptography does not stop them from touching the bits; it makes reading useless and tampering detectable.

GoalPrimitiveQuestion it answers
confidentialityEncryption (symmetric or asymmetric)Can an eavesdropper understand this?
integrityHash, MAC, authenticated encryptionWas this changed in transit?
authenticityMAC, digital signature, certificateDid this really come from who it claims?
non-repudiationDigital signatureCan the sender later deny sending it?

Notice what is missing: availability. Encryption protects data, not uptime. Ransomware is, ironically, encryption used against you.

02Symmetric encryption

One secret key both locks and unlocks. Symmetric ciphers are fast enough to encrypt gigabits per second on commodity CPUs, especially with hardware AES instructions, which makes them the workhorse for all bulk data: disks, VPN tunnels, and the body of every TLS session.

attack at 9 EncryptAES 9f3a…c27e DecryptAES same key K on both ends ciphertext crosses the untrusted network without K it is indistinguishable from random noise
Speed is the strength; getting K to both ends safely is the weakness.

Modes matter as much as the cipher

AES encrypts one 128-bit block. A mode of operation decides how to chain blocks for longer messages, and choosing badly leaks information even with a perfect cipher.

ECB

Each block independent. Identical plaintext blocks yield identical ciphertext, so patterns show through. Never use.

CBC / CTR

Hide patterns but provide no integrity on their own; an attacker can flip bits undetected without a separate MAC.

GCM / ChaCha20-Poly1305

Authenticated encryption (AEAD): confidentiality and tamper detection in one step. The modern default and the only kind TLS 1.3 allows.

03The key distribution problem

If every pair of parties needs its own shared secret, the number of keys grows quadratically: n(n−1)/2. And each key must somehow be delivered over a channel that is not yet secure, which is exactly the thing you were trying to build.

4 users → 6 keys 8 users → 28 keys 1,000 users ≈ 499,500 keys each needing a safe first delivery
The bootstrapping trap: you need a secure channel to create a secure channel.

Before 1976 the answers were couriers, pre-loaded devices, and trusted key-distribution centers (the model Kerberos still uses). Public-key cryptography broke the trap.

04Asymmetric (public-key) cryptography

Each party owns a mathematically linked pair: a public key anyone may hold, and a private key that never leaves its owner. What one key does, only the other can undo. Security rests on problems that are easy one way and infeasible in reverse:

RSA

Multiplying two large primes is trivial; factoring the product back is not. Typical keys: 2048–4096 bits.

Elliptic curves (ECC)

Discrete logarithm on a curve. A 256-bit ECC key matches roughly 3072-bit RSA, so it is smaller and faster.

Diffie–Hellman

Not encryption at all: two strangers derive the same secret over a public channel. The basis of modern key exchange.

AliceBobpublic channel shared public color secret a secret b public + a public + b mixes swapped in the open (public + b) + a (public + a) + b same secret
Mixing paint is easy; un-mixing it is not. An eavesdropper sees only the public color and the two mixes, never a or b.

The price is speed: public-key operations are orders of magnitude slower than AES. So real systems use them sparingly, just long enough to agree on a symmetric key, which is the hybrid pattern behind TLS, SSH, IPsec, and Signal.

Diffie–Hellman alone does not tell you who you agreed with. A man-in-the-middle can run two exchanges and sit between you. That gap is filled by signatures and certificates.

05Hashes, MACs, and signatures

Three tools for integrity, each proving a little more than the last. They are often confused with each other and with encoding.

Hash H(msg) no key detects accidental change anyone can recompute it MAC HMAC(K, msg) shared secret key proves "someone with K" either side could forge Signature Sign(priv, H(msg)) private key signs anyone verifies with public non-repudiation stronger guarantees →
Only signatures let a third party verify who created a message.
OperationReversible?Needs a key?Purpose
Encoding (Base64, hex)Yes, by anyoneNoFormat conversion. Zero security.
Hashing (SHA-256)NoNoFingerprint / integrity
Encryption (AES, RSA)Yes, with keyYesConfidentiality

06PKI and certificates

A public key is just a number. A certificate binds that number to an identity (a domain name, a person, a device) and is signed by a Certificate Authority the verifier already trusts. Browsers and operating systems ship with a few hundred root CA keys; everything else chains back to them.

Root CAself-signed · in your trust store · offline Intermediate CAsigned by root · issues daily Leaf: example.comsigned by intermediate · sent by server signssigns Client checks ✓ chain to trusted root ✓ name matches host ✓ not expired ✓ not revoked logged publicly in Certificate Transparency
A single compromised CA can issue a valid-looking certificate for any domain, which is why public CT logs now record every issuance.

Revocation is the weak spot: CRLs are large and stale, OCSP leaks browsing to the CA and often fails open. The industry response has been short-lived certificates (90 days and shrinking) issued automatically via ACME.

07TLS: everything combined

TLS is the hybrid pattern made concrete. An ephemeral Diffie–Hellman exchange creates fresh shared secrets, a certificate plus signature proves the server's identity, and an AEAD cipher protects the actual traffic. TLS 1.3 does all of that in a single round trip.

ClientServer ClientHello supported ciphers · random · DH key share (public) ServerHello chosen cipher · DH key share → both derive handshake keys encrypted from here Certificate + CertificateVerify identity + signature over the transcript Finished Finished + application data AES-GCM / ChaCha20 bulk traffic ⇄ 1 RTT
Signing the whole transcript means a tampered ClientHello (e.g., forcing a weak cipher) is detected.

Forward secrecy

Session keys come from throwaway DH keys, so stealing the server's long-term key later cannot decrypt recorded past traffic. Mandatory in TLS 1.3.

Cipher suite

The negotiated bundle of key exchange, authentication, bulk cipher, and hash. TLS 1.3 cut the menu to five AEAD suites.

What TLS does not hide

IP addresses, timing, sizes, and usually the server name (SNI). Encrypted Client Hello (ECH) is closing that last gap.

08Key management

Strong algorithms are the easy part. Most real cryptographic failures are key-handling failures.

Generate Distribute Store & use Rotate Revoke Destroy new key strong RNG HSM / KMS, not source code
Every stage is an attack point: weak randomness at birth, keys emailed in plaintext, private keys committed to Git, certificates that silently expire.

09When it goes wrong

DigiNotar (2011)

A breached Dutch CA issued fraudulent certificates, including one for Google, used to intercept users' traffic. Every browser distrusted the CA and it went bankrupt. Lesson: trust is only as strong as the weakest CA, which drove Certificate Transparency.

Heartbleed (2014)

A missing bounds check in OpenSSL's heartbeat extension let anyone read server memory, including private keys. The math was fine; the implementation was not.

Logjam (2015)

Many servers shared the same small Diffie–Hellman groups and still accepted export-grade parameters, enabling downgrade and precomputation attacks.

Common misconceptions

MythLonger keys always mean more security.
RealityPast a threshold, key handling, randomness, and implementation bugs dominate. AES-128 is ample for most uses.
MythThe padlock means the site is legitimate.
RealityIt means the connection is encrypted to whoever controls that domain. Phishing sites get free certificates too.
MythAsymmetric is better than symmetric.
RealityThey solve different problems. Every practical protocol uses both.
MythEncrypted means secure.
RealityEncryption gives confidentiality. Stolen credentials, deletion, and denial of service walk right past it.

10Looking ahead: post-quantum

A large enough quantum computer running Shor's algorithm would break RSA, Diffie–Hellman, and ECC outright. Symmetric ciphers and hashes survive with larger sizes (AES-256). Because adversaries can harvest now, decrypt later, migration is already underway.

StandardReplacesBasis
FIPS 203 · ML-KEM (Kyber)DH / RSA key exchangeModule lattices
FIPS 204 · ML-DSA (Dilithium)RSA / ECDSA signaturesModule lattices
FIPS 205 · SLH-DSA (SPHINCS+)Signatures (conservative backup)Hash functions only

Major browsers and CDNs already negotiate hybrid key exchange (classical X25519 plus ML-KEM), so a session stays safe if either one holds.

—References

Peer-reviewed

  1. Adrian, D. et al. (2015). Imperfect forward secrecy. ACM CCS. doi:10.1145/2810103.2813707
  2. Bellare, M. & Namprempre, C. (2000). Authenticated encryption. ASIACRYPT. doi:10.1007/3-540-44448-3_41
  3. Bernstein, D. & Lange, T. (2017). Post-quantum cryptography. Nature, 549. doi:10.1038/nature23668
  4. Clark, J. & van Oorschot, P. (2013). SoK: SSL and HTTPS. IEEE S&P. doi:10.1109/SP.2013.41
  5. Cohn-Gordon, K. et al. (2017). A formal security analysis of the Signal messaging protocol. IEEE EuroS&P. doi:10.1109/EuroSP.2017.27
  6. Cremers, C. et al. (2017). A comprehensive symbolic analysis of TLS 1.3. ACM CCS. doi:10.1145/3133956.3134063
  7. Diffie, W. & Hellman, M. (1976). New directions in cryptography. IEEE Trans. IT, 22(6). doi:10.1109/TIT.1976.1055638
  8. Durumeric, Z. et al. (2014). The matter of Heartbleed. ACM IMC. doi:10.1145/2663716.2663755
  9. Heninger, N. et al. (2012). Mining your Ps and Qs. USENIX Security. usenix.org
  10. Laurie, B. (2014). Certificate transparency. CACM, 57(10). doi:10.1145/2659897
  11. Rivest, R., Shamir, A. & Adleman, L. (1978). A method for obtaining digital signatures and public-key cryptosystems. CACM, 21(2). doi:10.1145/359340.359342
  12. Shor, P. (1997). Polynomial-time algorithms for prime factorization and discrete logarithms on a quantum computer. SIAM J. Comput., 26(5). doi:10.1137/S0097539795293172

Standards