Tool 3 of 8

Symmetric encryption

One secret key, shared by sender and receiver, both locks (encrypts) and unlocks (decrypts) the message. Without that key, the message is unreadable.

Your challengeFind out what happens when Bob uses the wrong key, or when an attacker changes the encrypted message, and why modern encryption refuses to decrypt instead of giving a wrong result.
Visualise

One key to lock and unlock

Genuine AES-GCM Simulated network
Alice
sender
Plaintext
(empty)
Network Simulated
Eve
listens to everything
Nothing sent yet
Bob
receiver
Experiment

Encryption lab

Genuine AES-256-GCM Simulated network and attacker
Alice
encrypts
Shared secret key (AES-256)
Network Simulated
Nonce (IV) random, not secret
(nothing sent)
Ciphertext (incl. authentication tag)
(nothing sent)

Bob
decrypts
Bob's key

What happened

Visualise

Block ciphers and stream ciphers

Simplified view

Encryption algorithms process data in one of two ways. You do not need to know what happens inside, only how the data is cut up.

Block cipher (for example AES)

The message is cut into fixed-size blocks (16 bytes for AES). Each block goes through the cipher with the key.

Stream cipher (for example ChaCha20)

The key generates a long stream of pseudo-random bytes. Each byte of the message is combined with the next byte of the stream, one by one.

Both kinds are secure when used correctly, and both are used in HTTPS. AES-GCM, used in this tool, is the block cipher AES used in a mode (GCM) that also adds an authentication tag.

Explain

Key ideas

Plaintext and ciphertext

The readable message is the plaintext. After encryption it becomes ciphertext: unreadable without the key.

One shared key

The same secret key encrypts and decrypts. That is why it is called symmetric. Anyone who has the key can read everything.

Fast

Symmetric encryption is very fast. It protects almost all data in practice: disks, Wi-Fi, VPNs and HTTPS traffic.

Authenticated encryption

Modern modes such as AES-GCM add an authentication tag, which plays the role of a MAC (Tool 2). Any change to the ciphertext, or a wrong key, is detected, and decryption is refused.

Nonce (IV)

Each encryption uses a fresh random value, the nonce. Encrypting the same message twice therefore gives different ciphertexts, so Eve cannot see that a message is repeated.

The key distribution problem

Alice and Bob must share the key before they can communicate securely. Sending it over the network would expose it. Tool 4 and Tool 6 solve this.

Common misconceptions

"With the wrong key, you get a scrambled message."
With authenticated encryption like AES-GCM you get an error, not a result. Only old, unauthenticated modes produce garbage.
"Encrypted means nobody can change it."
Without an authentication tag, an attacker can modify ciphertext in ways that change the plaintext. That is why the tag matters.
"Keeping the algorithm secret makes it safer."
AES is public and studied by experts worldwide. Only the key must be secret (Kerckhoffs's principle).
"A password is a key."
A key is 256 random bits. When you type a password, software first derives a key from it with a slow function such as PBKDF2 or Argon2 (see Tool 1).
Apply

Where you meet symmetric encryption

Disk encryption

BitLocker (Windows), FileVault (macOS) and LUKS (Linux) encrypt the whole disk with AES. A stolen laptop reveals nothing.

Wi-Fi

WPA2 and WPA3 encrypt every frame with AES. Everyone who knows the network password can derive keys for it.

HTTPS and VPNs

After the handshake, all the data of a website or VPN tunnel is encrypted with AES-GCM or ChaCha20-Poly1305.

Encrypted archives

7-Zip and similar tools can encrypt files with AES-256, using a key derived from a password.

Challenges

1. Same message, same ciphertext?

Encrypt the same message twice with the same key. Compare the two ciphertexts. Why are they different, and why is that a good thing?

Show answer
A fresh random nonce is used each time, so the ciphertexts differ. Otherwise Eve could recognise repeated messages, such as "yes" or "no".
2. The tampered message

Encrypt a message, flip one bit of the ciphertext, then decrypt with the correct key. What does Bob get? Which tool explains the mechanism behind this?

Show answer
Bob gets an error: the authentication tag no longer matches. This works like the HMAC tag in Tool 2. Bob knows the message was changed, but cannot recover it.
3. How do you send the key?

Alice is in Luxembourg, Bob in Montreal. They have never met. How can they agree on a key without Eve learning it? Write down your idea, then continue with Tools 4 and 6.

Continue the journey