Skip to content

Try “polymorphism”, “TCP handshake” or “git rebase”.

    Computer Basics / Networking 3: DNS, HTTP and HTTPS

    Encryption Basics: Just Enough for HTTPS

    This chapter teaches only the four ideas HTTPS needs. 08securityfundamentals.md goes much deeper (hashing,

    Chapter 10 of 135 min read

    This chapter teaches only the four ideas HTTPS needs. Security Fundamentals goes much deeper (hashing, password storage, key management).

    10.1 Symmetric encryption — one key#

    Plain picture: a lockbox with one key. The same key locks and unlocks. You and your friend each need a copy. Problem: how do you give your friend the key, if anyone might be watching you hand it over?

    Real name: symmetric encryption — the same secret key encrypts (scrambles) and decrypts (unscrambles). The standard is AES. It's extremely fast (modern CPUs have special instructions for it), so it's used for all the actual data.

    10.2 Asymmetric encryption — a padlock and its key#

    Plain picture: you mail out open padlocks to anyone who asks. Anyone can snap one shut on a box. Only you have the key that opens it. Nobody can make that key just by studying the padlock.

    Real name: asymmetric (or public-key) cryptography. Each party has a key pair:

    • a public key (the padlock) — share it with everyone;

    • a private key (the key) — never share it.

    It's much slower than symmetric encryption, so it's used only for setting things up — like agreeing on a symmetric key. Common algorithms: RSA and elliptic-curve cryptography (ECDHE for agreeing keys, ECDSA for signatures).

    Key exchange: there's an even cleverer trick — two parties can each contribute a random value and, by exchanging only public pieces over an open channel, both arrive at the same secret symmetric key that an eavesdropper can't work out. This is Diffie–Hellman key exchange (ECDHE is its modern form), and it's what TLS 1.3 uses.

    10.3 Digital signatures — a wax seal#

    Plain picture: a king's wax seal. Only the king has the seal stamp, but anyone who knows what the seal looks like can check a letter really came from him, unaltered.

    Real name: a digital signature: made with a private key, checked with the matching public key. It proves who created a message and that it wasn't changed.

    10.4 Certificates — a passport#

    Plain picture: a stranger says "I'm Priya." Anyone can say that. So you ask for a passport: a document stating her name, issued and sealed by a government you trust.

    Real names:

    • A certificate (an X.509 certificate) says "the public key for studybuddy.app is this", signed by a Certificate Authority (CA).

    • Your operating system and browser ship with a list of about a hundred-odd trusted root CAs — the governments you trust.

    • In practice there's a chain: the root CA signs an intermediate CA, which signs StudyBuddy's certificate. Your browser checks each signature up the chain to a root it trusts.

      Root CA  (pre-installed in your OS/browser, trusted)
         │  signs
         ▼
      Intermediate CA
         │  signs
         ▼
      studybuddy.app certificate:  "public key = 04:a1:9c…, valid until …, for studybuddy.app"

    Let's Encrypt is a free, automated CA that issues most of the web's certificates. Public certificate lifetimes are being shortened in stages under industry rules (to a maximum of 47 days by 2029), so renewals must be automated.

    Check yourself

    4 questions
    1

    Symmetric vs asymmetric encryption: which is faster, and what is each used for in HTTPS?

    Show answer

    Symmetric is much faster — used for all the data. Asymmetric is used to set up the connection (key exchange, proving identity).

    2

    What can you share, and what must you keep secret, in a key pair?

    Show answer

    Share the public key; keep the private key secret.

    3

    What does a digital signature prove?

    Show answer

    Who created the message, and that it wasn't changed.

    4

    What does a certificate say, and who vouches for it?

    Show answer

    "This public key belongs to this domain", signed by a Certificate Authority your system trusts (through a chain).