KomuraSoft LLC
Chapter 2

The crypto toolbox — symmetric, public-key, hash, signature

Distinguish symmetric encryption, public-key encryption, hashes, and digital signatures by what each solves, and see why TLS is a hybrid scheme.

Line up the four tools by what each solves

Chapter 1 established that TLS is a combination of three guarantees. This chapter opens the four tools that deliver them. Textbooks tend to start from how each tool works; this course starts every time from "what goes wrong in a world without it."

ToolProblem it solvesGuarantee it serves
Symmetric encryptionEncrypt lots of data, fastConfidentiality
Public-key encryptionShare a key with someone you have never metConfidentiality (its entrance)
HashNotice when content has been alteredIntegrity
Digital signatureConfirm "the real owner produced this"Authenticity

Symmetric encryption — fast, but how do you hand over the key?

Symmetric ciphers (such as AES) encrypt and decrypt with the same key. They are very fast and suited to protecting bulk traffic — in TLS, it is essentially symmetric encryption that protects your data.

The one weakness: how do you get that key to the other side safely? E-mail the key and it gets eavesdropped; if you had a wiretap-proof channel, you would not need encryption in the first place. This is the key-distribution problem. Worse, you need a key per communicating pair, so the key count grows with the square of the head count.

Public-key encryption — split the key into "lock" and "unlock"

Public-key cryptography uses a matched pair — a public key and a private key. What the public key encrypts, only the matching private key can decrypt.

Public key = a padlock
Hand it out to anyone. Anyone can snap it shut on a box
Private key = the only key that opens that padlock
Held by the owner alone. Only the owner can open the closed box

This transforms key distribution: each party publishes a "padlock," and anyone can start a secret conversation with them — no shared secret needed in advance. The catch is that public-key operations are orders of magnitude slower than symmetric ones, so encrypting all traffic this way is impractical.

TLS's answer — the hybrid scheme: use public-key techniques to establish a shared symmetric key (Chapter 3's key agreement), then protect the body with fast symmetric encryption. The slow tool for one instant; the fast tool for the main event.

Diagram of the hybrid scheme: public-key techniques establish the shared key, then symmetric encryption protects the traffic at speed

The hybrid division of labor. The TLS 1.3 handshake in Chapter 5 is the procedure that finishes that "one instant" in a single round trip.

Practice 2-1 — Count the key-distribution problem

Confirm the limits of symmetric keys, and how public keys change the picture, by working the numbers.

Q1. A group of 10 people all want to communicate secretly with each of the other 9 using symmetric encryption, one distinct key per pair. How many keys are needed in total?

keys

Q2. Using public-key encryption, you want to send a message that only A can read. Which key do you encrypt with?

Hashes — taking a fingerprint of the content

A hash function (such as SHA-256) turns input of any length into a fixed-length value, one-way. Three properties together make it usable as a fingerprint:

  • Same input → always the same output. Usable for comparison
  • Even one different bit → a completely different output. The smallest tampering breaks the match
  • The input cannot be computed back from the output. The fingerprint does not reveal the body

But note: sending a hash along with the data does not by itself detect tampering — an attacker who rewrites the body can simply recompute and replace the hash. Real protocols therefore mix a key into the hash: a fingerprint only the key holders can produce. That is a MAC (message authentication code), and TLS uses it in the form of authenticated encryption (AEAD), which performs encryption and tamper detection as one operation (it returns in Chapter 5).

Digital signatures — proof that the owner produced it

The key pair also works in the opposite direction: sign with the private key, verify with the public key. Since only the owner holds the private key, a successful verification says "the private-key holder approved exactly this content, and it has not changed since."

Encryption (confidentiality)Signature (authenticity)
Producer usesThe peer's public keyTheir own private key
Receiver usesTheir own private keyThe peer's public key
ProtectsContent from being readAuthor identity and content integrity

Signatures carry the rest of this course: Chapter 4's certificate is "a CA's signature over a domain owner's public key," and in Chapter 5's handshake the server proves possession of its private key with a signature.

Practice 2-2 — Don't mix up the tools

Each of the four tools answers a different question. Check which tool solves what.

Q3. TLS encrypts the traffic body with symmetric encryption rather than public-key encryption. The main reason is:

Q4. Which of these is not a property of a cryptographic hash function?

Q5. When verifying a digital signature, which key does the verifier use?

What to take from this chapter

  • Symmetric encryption is fast but stuck with key distribution — n(n−1)/2 keys for n people, pairwise
  • Public-key encryption solves distribution but is slow; TLS runs a hybrid of the two
  • A hash is a one-way fingerprint; only with a key mixed in (MAC / AEAD) does it detect tampering
  • Signatures: created with the private key, verified with the public key — the reverse direction from encryption

Next we hand-compute "creating a shared key with someone you have never met." Verify with your own hands that public-key techniques are not magic.