Sub topic 6
Confidentiality, integrity and authentication
This chapter assumes you know basic IP addressing, the difference between TCP and UDP, and how encapsulation wraps one packet inside another. A plain tunnel such as GRE moves packets across a network, but it gives no protection. A VPN adds three properties to that tunnel. This chapter defines them and shows how each one is built.
The three properties
- Confidentiality means that someone who captures the packets cannot read the contents. Encryption provides it.
- Integrity means that the receiver can detect any change made to a packet in transit. A message authentication code (MAC) provides it.
- Authentication means that each side can prove who it is talking to. Keys, certificates or pre-shared secrets provide it.
The three are separate. A tunnel can encrypt without checking integrity, and then an attacker can flip bits in the ciphertext and corrupt the result without ever reading it. A tunnel can also encrypt perfectly while talking to the wrong peer. A VPN needs all three.
| Property | Question it answers | Typical mechanism |
|---|---|---|
| Confidentiality | Can an eavesdropper read this? | Symmetric cipher (AES, ChaCha20) |
| Integrity | Was this changed on the way? | MAC or authenticated encryption |
| Authentication | Is the other end who it claims to be? | Public keys, certificates, pre-shared keys |
Confidentiality: symmetric encryption
VPN data traffic uses symmetric encryption, where both peers hold the same secret key. It is fast enough to run on every packet. Common ciphers are AES and ChaCha20.
Public-key cryptography is much slower, so a VPN uses it only at the start, to authenticate the peers and agree on the symmetric key. The next chapter covers that exchange.
Integrity: MACs and AEAD
A MAC is a short tag computed from the message and a secret key. The sender attaches the tag. The receiver recomputes it and drops the packet if the tags differ. Without the key, an attacker cannot forge a valid tag.
Modern VPNs use authenticated encryption with associated data (AEAD). Examples are AES-GCM and ChaCha20-Poly1305. One operation encrypts the payload and produces the tag. The "associated data" is the part that stays readable but is still covered by the tag, such as a packet header.
Replay is a related problem. An attacker who cannot read or modify a packet can still record it and send it again. VPN protocols guard against this by numbering packets and rejecting numbers they have already seen.
Authentication: who is on the other end
Encryption alone does not tell you who holds the other key. An attacker who sits between the peers can run a separate encrypted session with each. This is a man-in-the-middle attack. Authentication prevents it by tying the key exchange to an identity. Common methods:
- Pre-shared key (PSK): both sides already hold the same secret. It is simple, but every peer must be given the secret by some other channel.
- Public keys: each peer has a key pair and knows the other's public key in advance. WireGuard works this way.
- Certificates: a certificate authority signs a statement that a public key belongs to a named peer. TLS-based VPNs and many IPsec deployments use this.
Common errors
- Treating encryption as enough. Without integrity and authentication, you may encrypt traffic to an attacker.
- Accepting any certificate or skipping peer verification to "get it working". This removes the authentication property while the tunnel still appears to be up.
- Reusing a PSK across many peers. One leak compromises all of them.
Exercise
An attacker records an encrypted VPN packet and resends it ten seconds later. Which property and which mechanism stops the replay from being accepted?
Show answer
Integrity, together with replay protection. The receiver tracks sequence numbers, which are covered by the authentication tag. It drops a packet whose number it has already accepted or that falls outside its window.
Exercise
A tunnel encrypts with AES in a mode that has no MAC. Which of the three properties is missing, and what can an attacker still do without reading the data?
Show answer
Integrity is missing. The attacker can modify ciphertext, which can corrupt or in some cases predictably alter the decrypted data, and the receiver cannot detect it.