CSS411 Cryptography

IPSec

Slide deck 22. The IP security framework, services, transport and tunnel modes, security associations, ESP, anti-replay and SA bundles.

14 min read

IP 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 runsWhat happens
A user system with IPSecThe host sends packets with an IP header, an IPSec header and a secure IP payload
A networking device with IPSecThe 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:

  1. In a firewall or router, IPSec gives strong security to all traffic that crosses the perimeter.
  2. In a firewall or router, IPSec is resistant to bypass.
  3. IPSec is below the transport layer. Thus, it is transparent to applications.
  4. IPSec can be transparent to end users.
  5. IPSec can give security to individual users.
  6. IPSec secures the routing architecture.

Architecture and servicesSearch on YouTube

IP security architectureSearch on YouTube

The specification is quite complex. It has these groups:

GroupDocument
ArchitectureRFC 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:

  1. Access control.
  2. Connectionless integrity.
  3. Data origin authentication.
  4. Rejection of replayed packets. This is a form of partial sequence integrity.
  5. Confidentiality (encryption).
  6. Limited traffic flow confidentiality.

Transport and tunnel modesSearch on YouTube

Mode comparisonSearch on YouTube

Transport modeTunnel mode
PurposeEncrypts and optionally authenticates the IP dataEncrypts the entire IP packet
HeaderKeeps the original IP headerAdds a new IP header for the next hop
VisibilityThe slide says: "can do traffic analysis but is inefficient"No router on the way can examine the inner IP header
Good forESP host-to-host trafficVPNs 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 auth

ESP in tunnel mode:

new IP hdr | ESP hdr | orig IP hdr | TCP hdr | Data | ESP trlr | ESP auth
Transport modeorig IP hdrESP hdrTCP hdrDataESP trlrESP authencryptedauthenticatedTunnel modenew IP hdrESP hdrorig IP hdrTCP hdrDataESP trlrESP authencryptedauthenticated
ESP packets: transport mode keeps the original IP header; tunnel mode wraps the whole original packet behind a new IP header.

Tunnel 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:

ParameterMeaning
Security Parameters Index (SPI)A tag in the AH or ESP header. The receiver uses it to find the SA
IP Destination AddressThe destination endpoint of the SA
Security Protocol IdentifierShows 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

FieldNotes
Security parameters index (SPI)Identifies the SA
Sequence numberUsed 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 lengthThe size of the padding
Next headerThe 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:

  1. To expand the plaintext to the necessary length.
  2. 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:

  1. The sender sets the sequence number to 0 when a new SA is established.
  2. The sender increments the number for each packet.
  3. The number must not exceed 232−12^{32} - 1.
  4. The receiver accepts packets with a sequence number in the window (N−W+1)(N - W + 1) to NN.

NN is the highest sequence number received so far. WW is the window size.

Received numberReceiver action
In the window and not seen beforeAccept the packet and mark the number
In the window and seen beforeReject the packet
Less than N−W+1N - W + 1Reject the packet
More than NNAccept 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 | Data

Transport 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:

  1. ESP with authentication.
  2. A bundle of inner ESP and outer AH.
  3. A bundle of inner transport and outer ESP.

Four combination casesSearch on YouTube

CaseShape on the slide
Case 1One or more SAs between two hosts, through routers and the Internet
Case 2One tunnel SA between two security gateways
Case 3A tunnel SA between two gateways, plus one or two SAs between the hosts
Case 4A 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 232−12^{32}-1. The receiver accepts new numbers in the window (N−W+1)(N-W+1) to NN. 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 232−12^{32}-1 and a receiver window.
  • SA bundles use transport adjacency or iterated tunneling.