IPsec

From Wikipedia, the free encyclopedia

IPsec (IP security) is a suite of protocols for securing Internet Protocol (IP) communications by encrypting and/or authenticating each IP packet in a data stream. IPsec also includes protocols for cryptographic key establishment.

There are two modes of IPsec operation: transport mode and tunnel mode.

In transport mode only the payload (message) of the IP packet is encrypted. It is fully routable since the IP header is sent as plain text; however, it cannot cross NAT interfaces, as this will invalidate its hash value. Transport mode is used for host-to-host communications.

In tunnel mode, the entire IP packet is encrypted. It must then be encapsulated into a new IP packet for routing to work. Tunnel mode is used for network-to-network communications (secure tunnels between routers) or host-to-network and host-to-host communications over the Internet.

IPsec is implemented by a set of cryptographic protocols for (1) securing packet flows and (2) internet key exchange. Of the former, there are two:

It may be easier to understand the difference between AH and ESP by thinking of AH as an open envelope that lists the sender and recipient whereas ESP would do the same but the envelope would be closed and sealed.

In some countries message encryption is prohibited by law and ESP protocol may not be used. In this case AH provides entire IPsec functionality (without confidentiality).

Originally AH was only used for integrity and ESP was used only for encryption; authentication functionality was added subsequently to ESP due to performance advantages. The key exchange protocols, as defined by IPsec, include the IKE (Internet Key Exchange) protocol and its successor, IKEv2.

IPsec protocols operate at the network layer, layer 3 of the OSI model. Other Internet security protocols in widespread use, such as SSL and TLS, operate from the transport layer up (OSI layers 4 - 7). This makes IPsec more flexible, as it can be used for protecting both TCP- and UDP-based protocols, but increases its complexity and processing overhead, as it cannot rely on TCP (OSI layer 4) to manage reliability and fragmentation.

Contents

[edit] Current status as a standard

IPsec is an obligatory part of IPv6, and is optional for use with IPv4. While the standard is designed to be indifferent to IP versions, current widespread deployment and experience concerns IPv4 implementations. IPsec protocols were originally defined by RFCs 1825–1829, published in 1995. In 1998, these documents were obsoleted by RFCs 2401–2412. 2401–2412 are not compatible with 1825–1829, although they are conceptually identical. In December 2005, third-generation documents, RFCs 4301–4309, were produced. They are largely a superset of 2401–2412, but provide a second Internet Key Encryption standard. These third-generation documents standardized the abbreviation of IPsec to uppercase “IP” and lowercase “sec”.

It is unusual to see any product that offers RFC1825–1829 support. “ESP” generally refers to 2406, while ESPbis refers to 4303.

[edit] Design intent

IPsec was intended to provide either transport mode: end-to-end security of packet traffic in which the end-point computers do the security processing, or tunnel mode: portal-to-portal communications security in which security of packet traffic is provided to several machines (even to whole LANs) by a single node.

IPsec can be used to create Virtual Private Networks (VPN) in either mode, and this is the dominant use. Note, however, that the security implications are quite different between the two operational modes.

End-to-end communication security on an Internet-wide scale has been slower to develop than many had expected. Part of the reason is that no universal, or universally trusted, Public Key Infrastructure (PKI) has emerged (DNSSEC was originally envisioned for this); part is that many users understand neither their needs nor the available options well enough to promote inclusion in vendors' products.

Since the Internet Protocol does not inherently provide any security capabilities, IPsec was introduced to provide security services such as:

  1. Encrypting traffic (so it cannot be read by parties other than those for whom it is intended)
  2. Integrity validation (ensuring traffic has not been modified along its path)
  3. Authenticating the peers (ensuring that traffic is from a trusted party)
  4. Anti-replay (protection against replay of the secure session)

[edit] Technical details

[edit] Authentication Header (AH)

Authentication Header (AH) is intended to guarantee connectionless integrity and data origin authentication of IP datagrams. Further, it can optionally protect against replay attacks by using the sliding window technique and discarding old packets. AH protects the IP payload and all header fields of an IP datagram except for mutable fields, i.e. those that might be altered in transit. Mutable, therefore unauthenticated, IP header fields include TOS, Flags, Fragment Offset, TTL and Header Checksum. AH operates directly on top of IP using IP protocol number 51.

An AH packet diagram:

0 1 2 3
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
Next Header Payload Length RESERVED
Security Parameters Index (SPI)
Sequence Number

Authentication Data (variable)

Field meanings:

Next Header 
Identifies the protocol of the transferred data.
Payload Length 
Size of AH packet.
RESERVED 
Reserved for future use (all zero until then).
Security Parameters Index (SPI) 
Identifies the security parameters in combination with IP address.
Sequence Number 
A monotonically increasing number, used to prevent replay attacks.
Authentication Data 
Contains the data necessary to authenticate the packet.

[edit] Encapsulating Security Payload (ESP)

The Encapsulating Security Payload (ESP) extension header provides origin authenticity, integrity, and confidentiality protection of a packet. ESP also supports encryption-only and authentication-only configurations, but using encryption without authentication is strongly discouraged. Unlike the AH header, the IP packet header is not accounted for. ESP operates directly on top of IP using IP protocol number 50.

An ESP packet diagram:

0 1 2 3
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
Security Parameters Index (SPI)
Sequence Number

Payload * (variable)

  Padding (0-255 bytes)
    Pad Length Next Header

Authentication Data (variable)

Field meanings:

Security Parameters Index (SPI) 
Identifies the security parameters in combination with IP address
Sequence Number 
A monotonically increasing number, used to prevent replay attacks.
Payload Data 
The data to be transferred.
Padding 
Used with some block ciphers to pad the data to the full length of a block.
Pad Length 
Size of padding in bytes.
Next Header 
Identifies the protocol of the transferred data.
Authentication Data 
Contains the data used to authenticate the packet.

[edit] Implementations

IPsec support is usually implemented in the kernel with key management and ISAKMP/IKE negotiation carried out from user-space. Existing IPsec implementations tend to include both of these functionalities. However, as there is a standard interface for key management, it is possible to control one kernel IPsec stack using key management tools from a different implementation.

Because of this, there is confusion as to the origins of the IPsec implementation that is in the Linux kernel. The FreeS/WAN project made the first complete and open source implementation of IPsec for Linux. It consists of a kernel IPsec stack (KLIPS), as well as a key management daemon (pluto) and many shell scripts. The FreeS/WAN project was disbanded in March 2004. Openswan and strongSwan are continuations of FreeS/WAN. The KAME project also implemented complete IPsec support for NetBSD, FreeBSD. Its key management daemon is called racoon. OpenBSD made its own ISAKMP/IKE daemon, simply named isakmpd (that was also ported to other systems, including Linux).

However, none of these kernel IPsec stacks was integrated into the Linux kernel. Alexey Kuznetsov and David S. Miller wrote a kernel IPsec implementation from scratch for the Linux kernel around the end of 2002. This stack was subsequently released as part of Linux 2.6, and is referred variously as "native" or "NETKEY".

Therefore, contrary to popular belief, the Linux IPsec stack did not originate from the KAME project. As it supports the standard PF_KEY protocol (RFC 2367) and the native XFRM interface for key management, the Linux IPsec stack can be used in conjunction with either pluto from Openswan/strongSwan, isakmpd from OpenBSD project, racoon from the KAME project or without any ISAKMP/IKE daemon (using manual keying).

There are a number of implementations of IPsec and ISAKMP/IKE protocols. These include:

[edit] See also

[edit] Overview of IPsec-related RFCs

RFC 2367
PF_KEY Interface
RFC 2401 (obsoleted by RFC 4301)
Security Architecture for the Internet Protocol
RFC 2402 (obsoleted by RFC 4302 and RFC 4305)
Authentication Header
RFC 2403
The Use of HMAC-MD5-96 within ESP and AH
RFC 2404
The Use of HMAC-SHA-1-96 within ESP and AH
RFC 2405
The ESP DES-CBC Cipher Algorithm With Explicit IV
RFC 2406 (obsoleted by RFC 4303 and RFC 4305)
Encapsulating Security Payload
RFC 2407 (obsoleted by RFC 4306)
IPsec Domain of Interpretation for ISAKMP (IPsec DoI)
RFC 2408 (obsoleted by RFC 4306)
Internet Security Association and Key Management Protocol (ISAKMP)
RFC 2409 (obsoleted by RFC 4306)
Internet Key Exchange (IKE)
RFC 2410
The NULL Encryption Algorithm and Its Use With IPsec
RFC 2411
IP Security Document Roadmap
RFC 2412
The OAKLEY Key Determination Protocol
RFC 2451
The ESP CBC-Mode Cipher Algorithms
RFC 2857
The Use of HMAC-RIPEMD-160-96 within ESP and AH
RFC 3526
More Modular Exponential (MODP) Diffie-Hellman groups for Internet Key Exchange (IKE)
RFC 3706
A Traffic-Based Method of Detecting Dead Internet Key Exchange (IKE) Peers
RFC 3715
IPsec-Network Address Translation (NAT) Compatibility Requirements
RFC 3947
Negotiation of NAT-Traversal in the IKE
RFC 3948
UDP Encapsulation of IPsec ESP Packets
RFC 4106
The Use of Galois/Counter Mode (GCM) in IPsec Encapsulating Security Payload (ESP)
RFC 4301 (obsoletes RFC 2401)
Security Architecture for the Internet Protocol
RFC 4302 (obsoletes RFC 2402)
IP Authentication Header
RFC 4303 (obsoletes RFC 2406)
IP Encapsulating Security Payload (ESP)
RFC 4304
Extended Sequence Number (ESN) Addendum to IPsec Domain of Interpretation (DOI) for Internet Security Association and Key Management Protocol (ISAKMP)
RFC 4305 (obsoletes RFC 2404 and RFC 2406)
Cryptographic Algorithm Implementation Requirements for Encapsulating Security Payload (ESP) and Authentication Header (AH)
RFC 4306 (obsoletes RFC 2407, RFC 2408, and RFC 2409)
Internet Key Exchange (IKEv2) Protocol
RFC 4307
Cryptographic Algorithms for Use in the Internet Key Exchange Version 2 (IKEv2)
RFC 4308
Cryptographic Suites for IPsec
RFC 4309
Using Advanced Encryption Standard (AES) CCM Mode with IPsec Encapsulating Security Payload (ESP)
RFC 4478
Repeated Authentication in Internet Key Exchange (IKEv2) Protocol
RFC 4543
The Use of Galois Message Authentication Code (GMAC) in IPsec ESP and AH
RFC 4555
IKEv2 Mobility and Multihoming Protocol (MOBIKE)
RFC 4621
Design of the IKEv2 Mobility and Multihoming (MOBIKE) Protocol

[edit] External links