2.10. IPsec

2.10.1. Introduction

IPsec (IP Security) is a three-layer tunnel encryption protocol formulated by the IETF, which provides high-quality, interoperable, cryptography-based security guarantees for data transmitted on the Internet. The following security services are provided between specific communication parties through encryption and data source authentication at the IP layer:

  • Data Confidentiality

    -The IPsec sender encrypts packets before transmitting them over the network.

  • Data Integrity

    -The IPsec receiver authenticates the packets sent by the sender to ensure that the data has not been tampered with during transmission.

  • Data Authentication

    -At the receiving end, IPsec can verify whether the sending end of the IPsec packet is legitimate.

  • Anti-Replay

    -IPsec receivers can detect and reject outdated or duplicate packets.

2.10.2. Advantages

IPsec has the following advantages:

  • It supports IKE (Internet Key Exchange, Internet Key Exchange), which can realize the automatic negotiation function of keys and reduce the overhead of key negotiation. The service of SA can be established and maintained through IKE, which simplifies the use and management of IPsec.

  • All application systems and services that use IP protocol for data transmission can use IPsec without any modification to these application systems and services themselves.

  • The encryption of data is based on data packets instead of the entire data flow, which is not only flexible but also helps to further improve the security of IP data packets and can effectively prevent network attacks.

2.10.3. Composition

IPsec consists of four parts:

  • Internet Key Exchange Protocol IKE (Internet Key Exchange Protocol) responsible for key management

  • Security Associations (SAs) responsible for associating a security service with the communication flow that uses the service

  • Directly manipulate the authentication header protocol AH (IP Authentication Header) and the security payload protocol ESP (IP Encapsulating Security Payload) of the data packet

  • Several algorithms for encryption and authentication

2.10.4. Security Association,SA

IPsec provides secure communication between two endpoints, which are called IPsec peers.

SA is the foundation of IPsec and the essence of IPsec. SA is an agreement between communicating peers on certain elements, such as which protocol to use (AH, ESP, or a combination of both), the protocol’s encapsulation mode (transport mode and tunnel mode), encryption algorithms (DES, 3DES, and AES), a shared key to protect the data in a specific stream, and the lifetime of the key, etc. There are two ways to establish SA: manual configuration and IKE automatic negotiation.

SAs are unidirectional. For bidirectional communication between two peers, at least two SAs are required to secure data flows in two directions respectively. At the same time, if two peers wish to use AH and ESP for secure communication, each peer will construct an independent SA for each protocol.

SA is uniquely identified by a triple, which includes SPI (Security Parameter Index, security parameter index), destination IP address, and security protocol number (AH or ESP).

SPI is a 32-bit value used to uniquely identify the SA, which is transmitted in the AH and ESP headers. When manually configuring the SA, you need to manually specify the value of the SPI. When using IKE negotiation to generate SA, the SPI will be randomly generated.

2.10.5. IKE

IKE (RFC2407, RFC2408, RFC2409) is a hybrid protocol consisting of Internet Security Association and Key Management Protocol (ISAKMP) and two key exchange protocols, OAKLEY and SKEME. IKE is created on the framework defined by ISAKMP, follows OAKLEY’s key exchange mode and SKEME’s sharing and key update technology, and also defines its own two key exchange methods.

IKE uses two phases of ISAKMP:

In the first stage, a communication channel (IKE SA) is created through negotiation, and the channel is verified to provide confidentiality, message integrity and message source verification services for further IKE communication between the two parties; In the second stage, the established IKE SA is used. Establish an IPsec SA (called Child SA in V2).