IPSec
Slide deck 22. The IP security framework, services, transport and tunnel modes, security associations, ESP, anti-replay and SA bundles.
IPSec Explained Visually | AH, ESP, Tunnel Mode, IKE & OSI Layers SimplifiedCyber connect · IPSec overview: AH, ESP, tunnel mode and IKE, 6 min
IP Sec Fundamentals ESP Tunnel and Transport ModeFirewall Experts · ESP in transport mode and tunnel mode, 15 min
IPSec Fundamentals -Authentication Header Introduction Deep DriveFirewall Experts · the Authentication Header in both modes, 14 minIP security basicsSearch on YouTube
Why IPSec existsSearch on YouTube
There are many application-specific security mechanisms, for example S/MIME, PGP, Kerberos and SSL/HTTPS. But some security concerns cut across protocol layers. Thus, we want the network to supply security for all applications.
IPSec is the general IP security mechanism. It provides:
- Authentication.
- Confidentiality.
- Key management.
You can use IPSec over LANs, across public and private WANs, and for the Internet. A 1994 report identified the need. It asked for authentication and encryption in IPv4 and IPv6.
IP security usesSearch on YouTube
The slide figure shows two places where IPSec can run:
| Where IPSec runs | What happens |
|---|---|
| A user system with IPSec | The host sends packets with an IP header, an IPSec header and a secure IP payload |
| A networking device with IPSec | The device protects the traffic between sites. Behind the device, the LAN carries plain IP packets |
On the public (Internet) or private network, each packet has an IP header, an IPSec header and a secure IP payload. On the local Ethernet behind the device, each packet has only an IP header and an IP payload.
Benefits of IPSecSearch on YouTube
The slides give six benefits:
- In a firewall or router, IPSec gives strong security to all traffic that crosses the perimeter.
- In a firewall or router, IPSec is resistant to bypass.
- IPSec is below the transport layer. Thus, it is transparent to applications.
- IPSec can be transparent to end users.
- IPSec can give security to individual users.
- IPSec secures the routing architecture.
Architecture and servicesSearch on YouTube
IP security architectureSearch on YouTube
The specification is quite complex. It has these groups:
| Group | Document |
|---|---|
| Architecture | RFC 4301, Security Architecture for Internet Protocol |
| Authentication Header (AH) | RFC 4302, IP Authentication Header |
| Encapsulating Security Payload (ESP) | RFC 4303, IP Encapsulating Security Payload (ESP) |
| Internet Key Exchange (IKE) | RFC 4306, Internet Key Exchange (IKEv2) Protocol |
| Cryptographic algorithms | — |
| Other | — |
AH gives authentication and integrity, but no encryption. ESP gives encryption, and it can also give authentication. IKE makes and exchanges the keys for AH and ESP.
RFC ladder: 4301 Architecture, 4302 AH, 4303 ESP, 4306 IKE. The numbers go up in the same order as the slide list.
IPSec servicesSearch on YouTube
The slides list six services:
- Access control.
- Connectionless integrity.
- Data origin authentication.
- Rejection of replayed packets. This is a form of partial sequence integrity.
- Confidentiality (encryption).
- Limited traffic flow confidentiality.
Transport and tunnel modesSearch on YouTube
Mode comparisonSearch on YouTube
| Transport mode | Tunnel mode | |
|---|---|---|
| Purpose | Encrypts and optionally authenticates the IP data | Encrypts the entire IP packet |
| Header | Keeps the original IP header | Adds a new IP header for the next hop |
| Visibility | The slide says: "can do traffic analysis but is inefficient" | No router on the way can examine the inner IP header |
| Good for | ESP host-to-host traffic | VPNs and gateway-to-gateway security |
The slide figures show the two uses:
- Transport-level security: an encrypted TCP session between two hosts, across an internal and an external network.
- A virtual private network through tunnel mode: encrypted tunnels carry IP traffic between corporate networks across the Internet.
Mode packet layoutsSearch on YouTube
The protocol figure builds each packet layer by layer. Application data gets a TCP header, then an IP header, then IPSec.
ESP in transport mode:
orig IP hdr | ESP hdr | TCP hdr | Data | ESP trlr | ESP authESP in tunnel mode:
new IP hdr | ESP hdr | orig IP hdr | TCP hdr | Data | ESP trlr | ESP authTunnel mode puts the full original packet, with its header, inside a new IP packet. The outer header gives the tunnel endpoints. The inner header gives the true source and destination.
Security associationsSearch on YouTube
What an SA definesSearch on YouTube
A security association (SA) defines how the communication is secured. An SA is a logical connection. It defines:
- The encryption algorithm, for example AES or DES.
- The authentication algorithm, for example SHA or MD5.
- The keys.
- The lifetime.
An SA is one-way. Two-way traffic needs one SA in each direction.
SA parametersSearch on YouTube
Three parameters define an SA:
| Parameter | Meaning |
|---|---|
| Security Parameters Index (SPI) | A tag in the AH or ESP header. The receiver uses it to find the SA |
| IP Destination Address | The destination endpoint of the SA |
| Security Protocol Identifier | Shows if the SA is for AH or ESP |
An SA also has other parameters, for example the sequence number, AH and ESP information, and the lifetime. Each IPSec system keeps a database of security associations.
Encapsulating Security PayloadSearch on YouTube
ESP servicesSearch on YouTube
ESP provides these services:
- Message content confidentiality.
- Data origin authentication.
- Connectionless integrity.
- An anti-replay service.
- Limited traffic flow confidentiality.
The services depend on the options that you select when you establish the SA. They also depend on the network location. ESP can use a variety of encryption and authentication algorithms.
ESP packet formatSearch on YouTube
| Field | Notes |
|---|---|
| Security parameters index (SPI) | Identifies the SA |
| Sequence number | Used by the anti-replay service |
| Initialization value - IV (optional) | At the start of the payload data, if the cipher needs it |
| Rest of payload data (variable) | The protected data |
| TFC padding (optional, variable) | Traffic flow confidentiality padding |
| Padding (0 to 255 bytes) | Fills the plaintext to the necessary length |
| Pad length | The size of the padding |
| Next header | The type of data in the payload |
| Integrity check value - ICV (variable) | The integrity value |
The figure shows two spans. The encrypted span covers the payload data, the padding, the pad length and the next header. The ICV coverage starts at the SPI and stops before the ICV.
Encryption and paddingSearch on YouTube
- ESP can encrypt the payload data, padding, pad length and next header fields.
- If the cipher needs an IV, the IV is at the start of the payload data.
- ESP can have an optional ICV for integrity.
- ESP computes the ICV after encryption.
ESP uses padding for two reasons:
- To expand the plaintext to the necessary length.
- To align the pad length and next header fields.
Encrypt first, then compute the ICV. The ICV covers the ESP header and the ciphertext. Thus, the receiver can check the ICV before it decrypts.
Anti-replay serviceSearch on YouTube
In a replay, an attacker sends a copy of an authenticated packet again. ESP uses the sequence number to stop this attack:
- The sender sets the sequence number to 0 when a new SA is established.
- The sender increments the number for each packet.
- The number must not exceed .
- The receiver accepts packets with a sequence number in the window to .
is the highest sequence number received so far. is the window size.
| Received number | Receiver action |
|---|---|
| In the window and not seen before | Accept the packet and mark the number |
| In the window and seen before | Reject the packet |
| Less than | Reject the packet |
| More than | Accept the packet and move the window forward |
ESP in IPv4 and IPv6Search on YouTube
Before ESP, the packets are:
IPv4: orig IP hdr | TCP | Data
IPv6: orig IP hdr | extension headers (if present) | TCP | DataTransport mode with ESP:
IPv4: orig IP hdr | ESP hdr | TCP | Data | ESP trlr | ESP auth
IPv6: orig IP hdr | hop-by-hop, dest, routing, fragment | ESP hdr | dest | TCP | Data | ESP trlr | ESP auth- The authenticated span starts at the ESP header and stops before the ESP auth field.
- The encrypted span starts after the ESP header and ends with the ESP trailer.
- In IPv6, the hop-by-hop, destination, routing and fragment headers come before the ESP header. They are not authenticated or encrypted.
- A second destination header can come after the ESP header. ESP encrypts it.
Tunnel mode with ESP:
IPv4: new IP hdr | ESP hdr | orig IP hdr | TCP | Data | ESP trlr | ESP auth
IPv6: new IP hdr | ext headers | ESP hdr | orig IP hdr | ext headers | TCP | Data | ESP trlr | ESP auth- The authenticated span starts at the ESP header and stops before the ESP auth field.
- The encrypted span covers the full inner packet and the ESP trailer.
Combining security associationsSearch on YouTube
SA bundlesSearch on YouTube
One SA can implement either AH or ESP. To implement both, you must combine SAs:
- The combined SAs form a security association bundle.
- The SAs in a bundle can end at different or the same endpoints.
- Two methods combine SAs: transport adjacency and iterated tunneling.
Transport adjacency applies more than one security protocol to the same IP packet, with no tunnel. Iterated tunneling puts one tunnel inside another tunnel.
There are three ways to combine authentication and encryption:
- ESP with authentication.
- A bundle of inner ESP and outer AH.
- A bundle of inner transport and outer ESP.
Four combination casesSearch on YouTube
| Case | Shape on the slide |
|---|---|
| Case 1 | One or more SAs between two hosts, through routers and the Internet |
| Case 2 | One tunnel SA between two security gateways |
| Case 3 | A tunnel SA between two gateways, plus one or two SAs between the hosts |
| Case 4 | A tunnel SA from a remote host to a gateway, plus one or two SAs to the host behind the gateway |
Case order: host-host, gateway-gateway, both, remote user. Case 4 is a remote user who connects across the Internet to a host on a company intranet.
Quick self-testSearch on YouTube
Why does IPSec exist when S/MIME, PGP, Kerberos and SSL/HTTPS already give security?
Those mechanisms are application-specific. Some security concerns cut across protocol layers. Thus, we want the network to supply security for all applications. IPSec gives authentication, confidentiality and key management at the IP layer.
List the six benefits of IPSec.
In a firewall or router, it gives strong security to all traffic that crosses the perimeter. There, it is also resistant to bypass. It is below the transport layer, so it is transparent to applications. It can be transparent to end users. It can give security to individual users. It secures the routing architecture.
Give the RFCs of the IPSec architecture groups.
RFC 4301 is the architecture. RFC 4302 is the Authentication Header. RFC 4303 is the Encapsulating Security Payload. RFC 4306 is Internet Key Exchange (IKEv2). The other groups are cryptographic algorithms and other documents.
Name the six IPSec services.
Access control, connectionless integrity and data origin authentication. Rejection of replayed packets, a form of partial sequence integrity. Confidentiality (encryption) and limited traffic flow confidentiality.
Compare transport mode and tunnel mode.
Transport mode encrypts and optionally authenticates the IP data. It keeps the original IP header and is good for ESP host-to-host traffic. Tunnel mode encrypts the entire IP packet and adds a new IP header for the next hop. No router on the way can examine the inner IP header. It is good for VPNs and gateway-to-gateway security.
Which three parameters define an SA, and what does an SA define?
The SPI, the IP destination address and the security protocol identifier define an SA. The SA defines the encryption algorithm, the authentication algorithm, the keys and the lifetime.
Which ESP fields are encrypted, and when does ESP compute the ICV?
ESP encrypts the payload data, the padding, the pad length and the next header. The SPI and the sequence number stay in clear. ESP computes the optional ICV after encryption.
How does the anti-replay window work?
The sender starts the sequence number at 0 for each new SA and increments it for each packet. The number must not exceed . The receiver accepts new numbers in the window to . It rejects numbers that it saw before and numbers to the left of the window.
How do SAs combine, and what are the three ways to combine authentication and encryption?
SAs combine into a security association bundle by transport adjacency or iterated tunneling. The three ways are ESP with authentication, inner ESP with outer AH, and inner transport with outer ESP.
- IPSec gives authentication, confidentiality and key management at the IP layer, for all applications.
- The architecture has RFC 4301 (architecture), 4302 (AH), 4303 (ESP) and 4306 (IKEv2), plus cryptographic algorithms.
- IPSec has six services, from access control to limited traffic flow confidentiality.
- Transport mode protects the IP data, for host-to-host traffic. Tunnel mode protects the full packet under a new header, for VPNs.
- An SA defines algorithms, keys and lifetime. The SPI, destination address and protocol identifier define the SA.
- ESP encrypts the payload, padding, pad length and next header. It computes the ICV after encryption.
- The anti-replay service uses sequence numbers from 0 to and a receiver window.
- SA bundles use transport adjacency or iterated tunneling.