Secondary encryption system of IPSec VPN

By deploying a secondary encryption system in the IPSec VPN gateway, the encrypted data output by the gateway is secondary encryption, which solves the problem of using unsafe algorithms and man-in-the-middle attack risks in the prior art, and realizes efficient and secure transparent encryption protection of data.

CN119561731APending Publication Date: 2025-03-04CHINA YANGTZE POWER
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411610547.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-12
Publication Date
2025-03-04

AI Technical Summary

Technical Problem

Due to hardware or historical limitations, existing IPSec VPN gateways still use algorithms with high security risks, such as DES, MD5, SHA1, etc., and there is a risk of man-in-the-middle attack during key exchange, and the system is old and unable to be upgraded, resulting in the replacement of domestic password algorithms that cannot be implemented.

Method used

Deploy a secondary encryption system of IPSec VPN, including a secondary encryption unit and a decryption unit of a transparent encryption and decryption device, secondary encryption of the encrypted data output by the IPSec VPN gateway and decrypt it on the receiving end to ensure secondary security protection of the encrypted data.

Benefits of technology

By secondary encryption of encrypted data on the IPSec VPN gateway, the security of the data is improved, the risk of using insecure algorithms and man-in-the-middle attacks is avoided, and the transparent encryption protection of the data is achieved without destroying the protocol process and data format of the IPSec VPN.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119561731A_ABST
    Figure CN119561731A_ABST
Patent Text Reader

Abstract

The invention discloses a secondary encryption system of an IPSec VPN (Internet Protocol Security Virtual Private Network), which comprises a transparent encryption and decryption device connected with each IPSec VPN gateway, the transparent encryption and decryption device comprises a secondary encryption unit and a decryption unit, the secondary encryption unit carries out secondary encryption on encrypted data output by the IPSec VPN gateway and sends out the data subjected to secondary encryption; the decryption unit is used for decrypting the received data subjected to secondary encryption, and transmitting the decrypted encrypted data to the IPSec VPN gateway; the length of the encrypted data after the secondary encryption is the same as that of the encrypted data output by the IPSec VPN gateway, and the data length of the authentication data formed based on the secondary encryption is the same as that of the authentication data formed after the primary encryption. Secondary security protection is carried out on IPSec VPN gateway encrypted data, the protocol flow, the data format and the data packet length of the IPSec VPN are not damaged in the secondary protection process, and transparent encryption protection of the data can be achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of random number generation, and more specifically, to a secondary encryption system of an IPSec VPN. Background Art

[0002] IPSec VPN gateway is an effective technical means to protect data security in networks and communications. It can realize source authentication, data encryption, anti-tampering and anti-replay during data transmission.

[0003] It is deployed at the network entrance and exit to encrypt and decrypt past data for security protection. However, in some cases, such IPSec VPN gateways are limited by hardware or historical reasons and are still using algorithms with great security risks, such as DES, MD5, SHA1, etc. In addition, the use of non-standard protocols during the key exchange process poses risks such as man-in-the-middle attacks.

[0004] In addition, the old system does not support upgrades, which makes it impossible to implement the current domestic cryptographic algorithm replacement. These IPSecVPN gateways cannot be directly replaced because their service has not expired or for other reasons, so the potential risks for users are extremely high. Summary of the invention

[0005] The present invention provides a secondary encryption system for IPSec VPN, aiming to improve the above-mentioned problem.

[0006] The present invention is implemented in this way: a secondary encryption system for IPSec VPN, the system comprising:

[0007] A transparent encryption and decryption device connected to each IPSec VPN gateway, the transparent encryption and decryption device includes a secondary encryption unit and a decryption unit, wherein the secondary encryption unit is used to perform secondary encryption on the encrypted data output by the IPSec VPN gateway and send the secondary encrypted data; the decryption unit is used to decrypt the received secondary encrypted data and transmit the decrypted encrypted data to the IPSec VPN gateway;

[0008] The length of the encrypted data after the second encryption is the same as the length of the encrypted data output by the IPSec VPN gateway, and the length of the authentication data formed after the second encryption is the same as the length of the authentication data formed after the first encryption.

[0009] Furthermore, when the data message is encapsulated in ESP, the secondary encryption process of the secondary encryption unit is as follows:

[0010] (1) After receiving a data packet sent by the IPSec VPN gateway, after detecting that the current data packet is an ESP data packet, the SA corresponding to the data packet is determined based on the security parameter index SPI in the ESP header, the destination address in the IP header, and the IPSec protocol type;

[0011] (2) The encrypted data EnData0 in the ESP data packet is re-encrypted to obtain the encrypted data EnData1, the digest value of the ESP header and the encrypted data EnData1 is calculated, and the digest value is XORed with the ESP authentication data EspICV0 at the end of the data packet to generate new ESP authentication data EspICV1, and a re-encrypted ESP data packet is formed based on the encrypted data EnData1 and the ESP authentication data EspICV1;

[0012] (3) Send the twice-encrypted ESP data packet through the WAN port;

[0013] The data length of the encrypted data EnData1 is the same as that of the encrypted data EnData0, and the data length of the ESP authentication data EspICV1 is the same as that of the ESP authentication data EspICV0.

[0014] Furthermore, when the data message is encapsulated in ESP, the decryption process of the decryption unit is as follows:

[0015] (1) After receiving the double-encrypted ESP data packet, the corresponding SA is determined based on the security parameter index SPI in the ESP header, the destination address in the IP header, and the IPSec protocol type;

[0016] (2) Check whether the sequence number SN in the ESP header of the currently received data packet is the same as the sequence number SN of the received data packet. If the detection result is no, execute step (3);

[0017] (3) Calculate the digest value of the ESP header and the encrypted data EnData1, and perform an XOR operation with the ESP authentication data EspICV1 at the end of the ESP data packet to obtain the ESP authentication data EspICVt;

[0018] (4) Decrypt the encrypted data EnData1 to obtain the encrypted data EnData0, calculate the summary value EspICV0 of the ESP header and the encrypted data EnData0, and if the ESP authentication data EspICVt is consistent with the summary value EspICV0, forward the data packet formed by the group of encrypted data EnData0 and ESP authentication data EspICV0 to the IPSec VPN gateway connected to it.

[0019] Furthermore, when the data message is ESP encapsulated under AH authentication and ESP authentication, the secondary encryption process of the secondary encryption unit is as follows:

[0020] (1) When the type of the currently received data packet is an AH data packet and the next header type in the AH header is ESP encapsulation, the SA corresponding to the data packet is determined by the security parameter index SPI in the ESP header, the destination address in the IP header, and the IPSec protocol type;

[0021] (2) The encrypted data EnData0 in the ESP data packet is re-encrypted to obtain the encrypted data EnData1, the digest value of the ESP header and the encrypted data EnData1 is calculated, and the digest value is XORed with the ESP authentication data EspICV0 at the end of the AH data packet to generate the ESP authentication data EspICV1;

[0022] (3) Calculate the digest value of the entire IP message and perform an XOR operation with the digest value AhICV0 of the AH header to generate a digest value AhICV1, and send out a double-encrypted data packet formed by the AH header based on the digest value AhICV1, the encrypted data EnData1, and the ESP authentication data EspICV1;

[0023] The encrypted data EnData1 has the same data length as the encrypted data EnData0, the ESP authentication data EspICV1 has the same data length as the ESP authentication data EspICV0, and the digest value AhICV1 has the same data length as the digest value AhICV0.

[0024] Furthermore, the decryption process of the decryption unit is as follows:

[0025] (1) When the data packet type currently received by the decryption unit is an AH data packet and the next header type in the AH header is ESP encapsulation, the corresponding SA is determined by the security parameter index SPI in the ESP header, the destination address in the IP header, and the IPSec protocol type;

[0026] (2) Check whether the sequence number SN in the ESP header of the currently received data packet is the same as the sequence number SN of the received data packet. If the detection result is no, execute step (3);

[0027] (3) Calculate the digest value of the entire IP message and perform an XOR operation with the digest value AhICV1 of the AH header to obtain the digest value AhICVt; calculate the digest value of the ESP header and encrypted data EnData1, and perform an XOR operation with the ESP authentication data EspICV1 at the end of the data packet to obtain the ESP authentication data EspICVt;

[0028] (4) Decrypt the encrypted data EnData1 to obtain the encrypted data EnData0, calculate the digest value EspICV0 of the ESP header and the encrypted data EnData0, and if the digest value EspICVt is consistent with the digest value EspICV0, calculate the digest value AhICV0 of the entire IP message composed of the data EnData0 and the digest value EspICV0, and if the digest value AhICVt is consistent with the digest AhICV0, forward the data packet formed by the AH header based on the digest value AhICV0, the encrypted data EnData0, and the ESP authentication data EspICV0 to the IPSec VPN gateway connected to it.

[0029] Furthermore, when the data message is ESP encapsulated under AH authentication but without ESP authentication, the secondary encryption process of the secondary encryption unit is as follows:

[0030] (1) When the type of the currently received data packet is an AH data packet and the next header type in the AH header is ESP encapsulation, the SA corresponding to the data packet is determined by the security parameter index SPI of the ESP header, the destination address in the IP header, and the IPSec protocol type;

[0031] (2) The encrypted data EnData0 in the data packet is re-encrypted to obtain the encrypted data EnData1, the digest value of the entire IP message is calculated, and the digest value AhICV0 of the AH header in the data packet is XORed to generate the digest value AhICV1, and the AH data packet composed of the AH header based on the digest value AhICV1 and the encrypted data EnData1 is sent out;

[0032] The data length of the encrypted data EnData1 is the same as that of the encrypted data EnData0, and the data length of the digest value AhICV1 is the same as that of the digest value AhICV0.

[0033] Furthermore, the decryption process of the decryption unit is as follows:

[0034] (1) When the type of the currently received data packet is an AH data packet and the next header type in the AH header is ESP encapsulation, the corresponding SA is determined by the security parameter index SPI of the ESP header, the destination address in the IP header, and the IPSec protocol type;

[0035] (2) Check whether the sequence number SN in the ESP header of the currently received data packet is the same as the sequence number SN of the received data packet. If the detection result is no, execute step (3);

[0036] (3) Calculate the digest value of the entire IP message and perform an XOR operation with the digest AhICV1 in the AH header to obtain the digest value AhICVt; decrypt the encrypted data EnData1 to obtain the encrypted data EnData0;

[0037] (4) Calculate the digest value AhICV0 of the entire IP message composed of the encrypted data EnData0. If the digest value AhICVt is consistent with the digest value AhICV0, forward the data packet composed of the AH header based on the digest value AhICV0 and the encrypted data EnData0 to the IPSec VPN gateway connected to it.

[0038] Furthermore, the packet length of the encryption algorithm configured by the IPSec VPN gateway is an integer multiple of the packet length of the encryption algorithm configured by the transparent encryption and decryption device.

[0039] Furthermore, the system also includes:

[0040] A local key pool is configured for each transparent encryption and decryption device. The transparent encryption and decryption device obtains keys from the local key pool. The keys in the key pool are pre-filled.

[0041] The key pool key is divided into AH authentication key, ESP authentication key and ESP encryption key. Among them, the AH authentication key is divided into AH authentication input key and AH authentication output key, the ESP authentication key is divided into ESP authentication input key and ESP authentication output key, and the ESP encryption key is divided into ESP encryption input key and ESP encryption output key.

[0042] The decryption unit performs authentication and decryption on the received encrypted data during the decryption process based on the AH authentication input key and / or the ESP authentication input key and the ESP encryption input key; the secondary encryption unit performs authentication and encryption on the data to be sent during the encryption process based on the AH authentication output key and / or the ESP authentication output key and the ESP encryption output key.

[0043] Furthermore, after the transparent encryption and decryption device identifies the stream of interest based on the security parameter index SPI of the ESP header, the destination address in the IP header, and the IPSec protocol type, it establishes different encryption channels for different streams of interest and sets the parameters SA of the corresponding channels, including: SPI, destination address, IPSec protocol type, encryption algorithm and data authentication algorithm, related keys in the key pool, key life cycle, etc.

[0044] The present invention deploys a set of secondary encryption devices between IPSec VPN gateways to achieve secondary security protection of IPSec VPN gateway encrypted data, that is, the original ciphertext part is secondary encrypted, the IPSec VPN gateway performs the first encryption on the sent data, and the secondary encryption device performs the second encryption on the encrypted data after the first encryption to form secondary encrypted data, the length of the new ciphertext after the second encryption is consistent with the length of the ciphertext after the first encryption, the original authentication range data is secondary authenticated, and the authentication data length is consistent with the original authentication data length. The secondary protection process does not destroy the protocol flow, data format and data packet length of IPSec VPN, and transparent encryption protection of data can be achieved. The key adopts a preset mode, because it does not involve the IKE process, and does not do too much parsing and unpacking of the data message, so it is highly efficient and highly secure. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1 A schematic diagram of the structure of a secondary encryption system for an IPSec VPN provided by an embodiment of the present invention;

[0046] Figure 2 A schematic diagram of the field format of ESP encapsulation provided by an embodiment of the present invention;

[0047] Figure 3 A schematic diagram of the field format of the AH header provided in an embodiment of the present invention;

[0048] Figure 4 A schematic diagram of data changes before and after secondary encryption of ESP encapsulated data provided by an embodiment of the present invention;

[0049] Figure 5 A schematic diagram of data changes before and after secondary encryption of AH authentication + ESP encapsulated data with ESP authentication provided in an embodiment of the present invention;

[0050] Figure 6 A schematic diagram of data changes before and after secondary encryption of ESP encapsulated data with AH authentication + no ESP authentication provided by an embodiment of the present invention. Implementation

[0051] The specific implementation modes of the present invention are further explained in detail below by describing the embodiments with reference to the accompanying drawings, so as to help those skilled in the art to have a more complete, accurate and in-depth understanding of the inventive concept and technical solution of the present invention.

[0052] In order to avoid changes and impacts on the use of IPSec VPN gateways, the present invention deploys a set of secondary encryption devices between IPSec VPN gateways to achieve secondary security protection of IPSec VPN gateway encrypted data, that is, secondary encryption of the original ciphertext part. The IPSec VPN gateway encrypts the sent data for the first time, and the secondary encryption device encrypts the encrypted data after the first encryption for the second time to form secondary encrypted data. The length of the new ciphertext after the second encryption is consistent with the length of the ciphertext after the first encryption. The original authentication range data is authenticated twice, and the authentication data length is consistent with the original authentication data length. The secondary protection process does not destroy the protocol flow, data format and data packet length of IPSec VPN, and can achieve transparent encryption protection of data. The key is preset because it does not involve the IKE process and does not perform too much parsing and unpacking of data messages, so it is efficient and secure.

[0053] Figure 1 The schematic diagram of the structure of the secondary encryption system of the IPSec VPN provided by the embodiment of the present invention only shows the part related to the embodiment of the present invention for the convenience of description. The system includes:

[0054] A transparent encryption and decryption device connected to each IPSec VPN gateway, the transparent encryption and decryption device includes a secondary encryption unit and a decryption unit, wherein:

[0055] A secondary encryption unit, used to perform secondary encryption on the encrypted data output by the IPSec VPN gateway, and send the secondary encrypted data to the IPSec VPN gateway corresponding to the target address through the network;

[0056] The decryption unit is used to decrypt the received secondary encrypted data and pass the decrypted encrypted data to the IPSec VPN gateway, and the IPSec VPN gateway decrypts the encrypted data again;

[0057] The length of the encrypted data after the second encryption is the same as the length of the encrypted data output by the IPSec VPN gateway, and the length of the authentication data formed after the second encryption is the same as the length of the authentication data formed after the first encryption.

[0058] In the embodiment of the present invention, the security protection between IPSec VPN gateways adopts the tunnel mode. In the tunnel mode, there are three types of data message structures: ESP encapsulation, AH authentication + ESP encapsulation with ESP authentication, and AH authentication + ESP encapsulation without ESP authentication.

[0059] The format of the ESP encapsulated fields is as follows: Figure 2 As shown, Table 1 gives an introduction to the length of each field in the ESP encapsulation field format. Table 1 is as follows:

[0060] Table 1 ESP encapsulation field format

[0061] Serial number Fields length 1 Security Parameters Index (SPI) 32 bits 2 Serial Number (SN) 32 bits 3 Payload Lengthening 4 Padding 0-255 bytes 5 Pad length 8 bits 6 Next header 8 bits 7 Authentication data (ICV) Lengthening

[0062] The fields in the AH header are as follows: Figure 3 As shown, Table 2 gives an introduction to the length of each field in the field format of the AH header, as shown in Table 2:

[0063] Table 2 Field format of the AH header

[0064] Serial number Fields length 1 Next header 8 bits 2 Pad length 8 bits 3 Reserved Fields 16 bits 4 Security Parameters Index (SPI) 32 bits 5 Serial Number (SN) 32 bits 6 Authentication data (ICV) Lengthening

[0065] For the ESP padding field, since the selected encryption algorithm may be block encryption, if the length of the payload data is not an integer multiple of the block length of the selected encryption algorithm, the insufficient part needs to be padded. The specific length of the authentication data part depends on the integrity check algorithm used.

[0066] With respect to the IPSec VPN gateway data encapsulation format, the secondary security protection mechanism proposed in the present invention is as follows: Taking the IPSec VPN gateway encryption algorithm AES128-CBC and the authentication algorithm HMAC-SHA1 as examples for explanation, the encrypted data length after the first encryption is an integer multiple of 128 bits, and the authentication data length is 96 bits. Secondary encryption and secondary verification are performed on the basis of the primary encryption of the IPSec VPN gateway. Different encryption mechanisms are used for secondary encryption to improve the security of the data. If the secondary encryption uses the SM4-CBC encryption algorithm, since the SM4 packet length is also 128 bits, there is no need to pad the ciphertext after the first encryption, and the original ciphertext can be directly encrypted. If the secondary encryption uses the AES256 encryption algorithm, and the encryption constant length after the first encryption is an odd multiple of 128 bits, it is necessary to pad the encrypted data after the first encryption. After padding until the output encrypted data is an integer multiple of 256 bits, secondary encryption can be performed. In order to ensure that the length of the encrypted data after the secondary encryption is the same as the length of the encrypted data output by the IPSec VPN gateway, the packet length of the encryption algorithm configured by the IPSec VPN gateway is an integer multiple of the packet length of the encryption algorithm configured by the transparent encryption and decryption device. When the IPSec VPN gateway uses the AES256 encryption algorithm, the encryption algorithm used by the secondary encryption unit can be the SM1 (128-bit) encryption algorithm, the SM4 (128-bit) encryption algorithm, or the GOST (256-bit) encryption algorithm. When the IPSec VPN gateway uses the AES128 encryption algorithm, the encryption algorithm used by the secondary encryption unit can only be a 128-bit encryption algorithm such as SM1 or SM4. When the packet length of the primary authentication algorithm is shorter than the packet length of the secondary authentication algorithm, the result output by the secondary authentication algorithm is intercepted until it is consistent with the packet length of the primary authentication algorithm, and then an XOR is performed. For example, if the secondary authentication uses the HMAC-SM3 algorithm, its output length is 256 bits, and it is truncated to 96 bits and then XORed with the original authentication data; when the packet length of the primary authentication algorithm is longer than the packet length of the secondary authentication algorithm, the result output by the secondary authentication algorithm is partially circulated until it is consistent with the packet length of the primary authentication algorithm, and then an XOR is performed.

[0067] SA creation process: After the transparent encryption and decryption device identifies the flow of interest based on the security parameter index SPI in the ESP header, the destination address in the IP header, and the IPSec protocol type, it establishes different encryption channels for different flows of interest and establishes a security alliance SA; SA is unidirectional, and two-way communication between two communicating IPSec VPN gateways requires two SAs. SA parameters include encryption algorithm, data verification algorithm, key lifetime, and key, among which the encryption algorithm, data verification algorithm, and key lifetime are pre-configured, and the key uses a pre-set key pool, which reduces the key online negotiation time and improves efficiency.

[0068] In an embodiment of the present invention, a local key pool is configured for each transparent encryption and decryption device. The transparent encryption and decryption device obtains keys from the local key pool. The keys in the key pool are pre-filled. The preset keys are filled between two transparent encryption and decryption devices of the system. The preset keys are pre-generated at both ends by a quantum key distribution device, or are manually filled at both ends manually. The key pool key is divided into an AH authentication key, an ESP authentication key and an ESP encryption key, wherein the AH authentication key is divided into an AH authentication input key and an AH authentication output key, the ESP authentication key is divided into an ESP authentication input key and an ESP authentication output key, and the ESP encryption key is divided into an ESP encryption input key and an ESP encryption output key. The decryption unit performs corresponding decryption authentication on the received encrypted data based on the AH authentication input key, the ESP authentication input key and the ESP encryption input key; the secondary encryption unit performs corresponding encryption authentication on the data to be sent based on the AH authentication output key, the ESP authentication output key and the ESP encryption output key; for any two transparent encryption and decryption devices, the AH authentication input key of the first transparent encryption and decryption device is the AH authentication output key of the second transparent encryption and decryption device, and the AH authentication input key of the second transparent encryption and decryption device is the AH authentication output key of the first transparent encryption and decryption device, and the setting of the ESP authentication key and the ESP encryption key is the same, which will not be repeated again.

[0069] In the embodiment of the present invention, after receiving the encrypted data packet outputted by the IPSec VPN gateway, the transparent encryption and decryption device needs to read the encrypted data after the encryption from the encrypted data message before performing secondary encryption on the encrypted data after the encryption. The three message structures of the data in the tunnel mode are described respectively:

[0070] Obtaining encrypted data encapsulated by ESP: Parse the Total length Tlen and the IP header length IPHlen from the IP header. Based on the received encrypted data message after one encryption, remove the IP header at the head, the 8-bit ESP header and the ESP integrity authentication data at the tail in sequence to obtain the encrypted data after one encryption. The encrypted data after one encryption Len = Tlen-IPHlen-8 (ESP header length)-ALen (ESP integrity verification length).

[0071] Acquisition of encrypted data encapsulated with AH+ESP and authenticated by ESP: parse the Total length Tlen and the IP header length IPHlen from the IP header, and remove the IP header at the head, the 12-bit AH header excluding the integrity check, the AH integrity authentication data, the 8-bit ESP header and the ESP integrity authentication data at the tail in sequence based on the received encrypted data message after one encryption, and obtain the encrypted data after one encryption. The encrypted data after one encryption Len = Tlen-IPHlen-12 (the length of the AH header excluding the integrity check)-AHlen (the integrity verification length of the AH header)-8 (the length of the ESP header)-ALen (the ESP integrity verification length).

[0072] Acquisition of encrypted data without ESP authentication by AH+ESP encapsulation: Total length Tlen and IP header length IPHlen are parsed from the IP header. Based on the received encrypted data message after one encryption, the IP header at the head, the 12-bit AH header excluding the integrity check, the AH integrity authentication data and the ESP integrity authentication data at the tail are removed in sequence to obtain the encrypted data after one encryption. The encrypted data Len after one encryption = Tlen-IPHlen-12 (length of the AH header excluding the integrity check)-AHlen (integrity verification length of the AH header)-8 (ESP header length).

[0073] When a tunnel data packet consisting of a new destination address and SPI appears, a new SA needs to be created. IPSec VPN will re-establish SA due to timeout or traffic reaching the upper limit, but the transparent encryption and decryption device does not care about the IKE protocol of IPSec VPN, so it cannot know that IPSec VPN has created a new SA. Therefore, when the transparent encryption and decryption device finds that the original destination address and IPSec protocol type are combined with the new SPI, it is considered that IPSec VPN has created a new SA. At this time, the transparent encryption device needs to create a new SA and wait for a timeout period before destroying the original SA.

[0074] Combination Figure 4 To illustrate, the secondary encryption process of ESP encapsulated data is as follows:

[0075] (1) The LAN port of the secondary encryption unit receives a data packet sent by the IPSec VPN gateway and finds that the protocol type is 50, indicating that the current data packet is an ESP data packet; the corresponding SA is determined by the security parameter index SPI in the ESP header, the destination address in the IP header, and the IPSec protocol type. If the corresponding SA does not exist, an SA is created. The creation process is described above;

[0076] (2) The encrypted data EnData0 in the ESP data packet is encrypted twice to obtain the encrypted data EnData1, the digest value of the ESP header and the encrypted data EnData1 is calculated, and the digest value is XORed with the ESP authentication data EspICV0 at the end of the data packet to generate new ESP authentication data EspICV1. The IP header, ESP header, encrypted data EnData1 and ESP authentication data EspICV1 are combined into a twice encrypted data message. The encryption process does not change the message data length;

[0077] (3) The encrypted data after the second encryption is sent out through the WAN port.

[0078] The encryption algorithm, digest algorithm and key used in the above process are given by SA. Any slight change to the data in the network will lead to a huge change in the authentication data, and the data after XOR will also have a huge change, and the authentication data will not match due to tampering with the transmission data and will be discovered.

[0079] Combination Figure 4 To illustrate, the decryption process of ESP encapsulated data is as follows:

[0080] (1) After the WAN port of the transparent encryption and decryption device receives the IP packet, it finds that the protocol type is 50, indicating that this is an ESP data packet; the SA corresponding to the data packet is determined by the security parameter index SPI in the ESP header, the destination address in the IP header, and the IPSec protocol type. If there is no corresponding SA, an SA is created. The creation process is as described above;

[0081] (2) Check whether the sequence number SN in the ESP header of the currently received data packet is the same as the sequence number SN of the received data packet. If so, it indicates duplicate reception and the message is discarded. If not, execute step (3).

[0082] (3) Calculate the digest value of the ESP header and encrypted data EnData1, and perform an XOR operation with the ESP authentication data EspICV1 at the end of the data packet to obtain the ESP authentication data EspICVt; decrypt the secondary encrypted data EnData1 to obtain the encrypted data EnData0, calculate the digest value EspICV0 of the ESP header and encrypted data EnData0, if the ESP authentication data EspICVt is consistent with the digest value EspICV0, then forward the data packet formed by the IP header, ESP header, encrypted data EnData0 and ESP authentication data EspICV0 to the IPSec VPN gateway through the LAN port; if the ESP authentication data EspICVt is inconsistent with the digest value EspICV0, it means that the data has been tampered with, and the data packet is discarded.

[0083] The encryption algorithm, digest algorithm and key used are given by SA, and the operation process does not change the message data length.

[0084] Combination Figure 5 To illustrate, the secondary encryption process of AH authentication + ESP-encapsulated data with ESP authentication is as follows:

[0085] (1) After the LAN port of the transparent encryption and decryption device receives an IP packet, it finds that the protocol type is 51, indicating that the current data packet type is an AH data packet. If the next header type in the AH header is 50, it means that the packet is encapsulated using ESP. Then the ESP header is checked, and the SA corresponding to the data packet is determined through the security parameter index SPI in the ESP header, the destination address in the IP header, and the IPSec protocol type. If there is no corresponding SA, an SA is created. The creation process is described above.

[0086] (2) Perform secondary encryption on the encrypted data EnData0 in the AH data packet to obtain the encrypted data EnData1, calculate the digest value of the ESP header and the encrypted data EnData1, and perform an XOR operation on the digest value and the ESP authentication data EspICV0 at the end of the data packet to generate the ESP authentication data EspICV1; calculate the digest value of the entire IP message and perform an XOR operation on the digest value AhICV0 in the AH header to generate the digest value AhICV1, and send the secondary encrypted data packet consisting of the IP header, the AH header with the digest value AhICV1, the ESP header, the encrypted data EnData1, and the ESP authentication data EspICV1 through the WAN port;

[0087] The encryption algorithm, digest algorithm and key used are given by SA, and the operation process does not change the message data length.

[0088] Combination Figure 5 To illustrate, the decryption process of the AH authentication + ESP-authenticated ESP encapsulated data decryption unit is as follows:

[0089] (1) After the WAN port of the transparent encryption and decryption device receives a data packet, it finds that the protocol type is 51, indicating that the current data packet is an AH data packet. If the next header type in the AH header is 50, it means that the data packet is ESP encapsulated. The SA corresponding to the data packet is determined by the security parameter index SPI in the ESP header, the destination address in the IP header, and the IPSec protocol type. If there is no corresponding SA, an SA is created. The creation process is as described above.

[0090] (2) Check whether the sequence number SN in the ESP header of the currently received data packet is the same as the sequence number SN of the received data packet. If so, it indicates duplicate reception and the message is discarded. If not, execute step (3).

[0091] (3) Calculate the digest value of the entire IP message, and perform an XOR operation with the digest value AhICV1 in the AH header to obtain the digest value AhICVt; calculate the digest value of the ESP header and encrypted data EnData1, and perform an XOR operation with the ESP authentication data EspICV1 at the end of the data packet to obtain the ESP authentication data EspICVt; decrypt the encrypted data EnData1 to obtain the encrypted data EnData0, calculate the digest value EspICV0 of the ESP header and encrypted data EnData0, if the digest value EspICVt is inconsistent with the digest value EspICV0 It indicates that the data has been tampered with and the message is discarded; if the digest value EspICVt is consistent with the digest value EspICV0, the digest value AhICV0 of the entire IP message composed of the data EnData0 and the authentication data EspICV0 is calculated. If the digest value AhICVt and the digest value AhICV0 are inconsistent, it indicates that the data has been tampered with and the data packet is discarded. If they are consistent, the data packet composed of the IP header, the AH header with the digest AhICV0, the ESP header, the encrypted data EnData0, and the ESP authentication data EspICV0 is forwarded to the IPSec VPN gateway connected to it.

[0092] The encryption algorithm, digest algorithm and key used above are provided by SA, and the operation process does not change the message data length.

[0093] Combination Figure 6 To illustrate, the secondary encryption process of ESP encapsulated data with AH authentication + no ESP authentication is as follows:

[0094] (1) After the LAN port of the transparent encryption and decryption device receives the IP packet, it finds that the protocol type is 51, indicating that the current data packet is an AH data packet. If the next header type in the AH header is 50, it means that the data packet is encapsulated using ESP. The SA corresponding to the data packet is determined by the security parameter index SPI of the ESP header, the destination address in the IP header, and the IPSec protocol type. If there is no corresponding SA, an SA is created. The creation process is described above.

[0095] (2) The encrypted data EnData0 in the ESP data packet is re-encrypted to obtain the encrypted data EnData1. The summary value of the entire IP message is calculated and XORed with the summary value AhICV0 of the AH header in the data packet to generate the summary value AhICV1. The re-encrypted data packet consisting of the IP header, the AH header with the summary value AhICV1, the ESP header, and the encrypted data EnData1 is sent out through the WAN port.

[0096] The encryption algorithm, digest algorithm and key used are given by SA, and the operation process does not change the message data length.

[0097] Combination Figure 6 To illustrate, the decryption process of ESP encapsulated data with AH authentication + no ESP authentication is as follows:

[0098] (1) After the WAN port of the transparent encryption and decryption device receives the IP packet, it finds that the protocol type is 51, indicating that the data packet is an AH data packet. If the next header type in the AH header is 50, it means that the data packet is encapsulated using ESP. The SA corresponding to the data packet is determined by the security parameter index SPI of the ESP header, the destination address in the IP header, and the IPSec protocol type. If there is no corresponding SA, an SA is created. The creation process is described above.

[0099] (2) Check whether the sequence number SN in the ESP header of the currently received data packet is the same as the sequence number SN of the received data packet. If so, it indicates duplicate reception and the message is discarded. If not, execute step (3).

[0100] (3) Calculate the digest of the entire IP message, and XOR it with the digest value AhICV1 in the AH header to obtain the digest value AhICVt; decrypt the encrypted data EnData1 to obtain the encrypted data EnData0. Calculate the digest value AhICV0 of the entire IP message composed of the encrypted data EnData0. If the digest value AhICVt and the digest value AhICV0 are inconsistent, it means that the data has been tampered with, and the data packet is discarded. If the digest value AhICVt and the digest value AhICV0 are consistent, the data packet composed of the IP header, the AH header with the digest value AhICV0, the ESP header, and the encrypted data EnData0 is forwarded to the connected IPSec VPN gateway.

[0101] The encryption algorithm, digest algorithm and key used above are provided by SA, and the operation process does not change the message data length.

[0102] The present invention has been described exemplarily. Obviously, the specific implementation of the present invention is not limited to the above-mentioned method. As long as various non-substantial improvements are made using the method concept and technical solution of the present invention, or the concept and technical solution of the present invention are directly applied to other occasions without improvement, they are all within the protection scope of the present invention.

Claims

1. A secondary encryption system for IPSec VPN, characterized in that: The system comprises: A transparent encryption and decryption device connected to each IPSec VPN gateway, the transparent encryption and decryption device includes a secondary encryption unit and a decryption unit, wherein the secondary encryption unit is used to perform secondary encryption on the encrypted data output by the IPSec VPN gateway and send the secondary encrypted data; the decryption unit is used to decrypt the received secondary encrypted data and transmit the decrypted encrypted data to the IPSec VPN gateway; The length of the encrypted data after the second encryption is the same as the length of the encrypted data output by the IPSec VPN gateway, and the length of the authentication data formed after the second encryption is the same as the length of the authentication data formed after the first encryption.

2. The secondary encryption system of IPSec VPN as claimed in claim 1, characterized in that: When the data message is encapsulated in ESP, the secondary encryption process of the secondary encryption unit is as follows: (1) After receiving a data packet sent by the IPSec VPN gateway, after detecting that the current data packet is an ESP data packet, the SA corresponding to the data packet is determined based on the security parameter index SPI in the ESP header, the destination address in the IP header, and the IPSec protocol type; (2) The encrypted data EnData0 in the ESP data packet is re-encrypted to obtain the encrypted data EnData1, the digest value of the ESP header and the encrypted data EnData1 is calculated, and the digest value is XORed with the ESP authentication data EspICV0 at the end of the data packet to generate new ESP authentication data EspICV1, and a re-encrypted ESP data packet is formed based on the encrypted data EnData1 and the ESP authentication data EspICV1; (3) Send the twice-encrypted ESP data packet through the WAN port; The data length of the encrypted data EnData1 is the same as that of the encrypted data EnData0, and the data length of the ESP authentication data EspICV1 is the same as that of the ESP authentication data EspICV0.

3. The secondary encryption system of IPSec VPN as claimed in claim 2, characterized in that: When the data message is encapsulated in ESP, the decryption process of the decryption unit is as follows: (1) After receiving the double-encrypted ESP data packet, the corresponding SA is determined based on the security parameter index SPI in the ESP header, the destination address in the IP header, and the IPSec protocol type; (2) Check whether the sequence number SN in the ESP header of the currently received data packet is the same as the sequence number SN of the received data packet. If the detection result is no, execute step (3); (3) Calculate the digest value of the ESP header and the encrypted data EnData1, and perform an XOR operation with the ESP authentication data EspICV1 at the end of the ESP data packet to obtain the ESP authentication data EspICVt; (4) Decrypt the encrypted data EnData1 to obtain the encrypted data EnData0, calculate the summary value EspICV0 of the ESP header and the encrypted data EnData0, and if the ESP authentication data EspICVt is consistent with the summary value EspICV0, forward the data packet formed by the group of encrypted data EnData0 and ESP authentication data EspICV0 to the IPSec VPN gateway connected to it.

4. The secondary encryption system of IPSec VPN as claimed in claim 1, characterized in that: When the data message is ESP encapsulated under AH authentication and ESP authentication, the secondary encryption process of the secondary encryption unit is as follows: (1) When the type of the currently received data packet is an AH data packet and the next header type in the AH header is ESP encapsulation, the SA corresponding to the data packet is determined by the security parameter index SPI in the ESP header, the destination address in the IP header, and the IPSec protocol type; (2) The encrypted data EnData0 in the ESP data packet is re-encrypted to obtain the encrypted data EnData1, the digest value of the ESP header and the encrypted data EnData1 is calculated, and the digest value is XORed with the ESP authentication data EspICV0 at the end of the AH data packet to generate the ESP authentication data EspICV1; (3) Calculate the digest value of the entire IP message and perform an XOR operation with the digest value AhICV0 of the AH header to generate a digest value AhICV1, and send out a double-encrypted data packet formed by the AH header based on the digest value AhICV1, the encrypted data EnData1, and the ESP authentication data EspICV1; The encrypted data EnData1 has the same data length as the encrypted data EnData0, the ESP authentication data EspICV1 has the same data length as the ESP authentication data EspICV0, and the digest value AhICV1 has the same data length as the digest value AhICV0.

5. The secondary encryption system of IPSec VPN as claimed in claim 4, characterized in that: The decryption process of the decryption unit is as follows: (1) When the data packet type currently received by the decryption unit is an AH data packet and the next header type in the AH header is ESP encapsulation, the corresponding SA is determined by the security parameter index SPI in the ESP header, the destination address in the IP header, and the IPSec protocol type; (2) Check whether the sequence number SN in the ESP header of the currently received data packet is the same as the sequence number SN of the received data packet. If the detection result is no, execute step (3); (3) Calculate the digest value of the entire IP message and perform an XOR operation with the digest value AhICV1 of the AH header to obtain the digest value AhICVt; calculate the digest value of the ESP header and encrypted data EnData1, and perform an XOR operation with the ESP authentication data EspICV1 at the end of the data packet to obtain the ESP authentication data EspICVt; (4) Decrypt the encrypted data EnData1 to obtain the encrypted data EnData0, calculate the digest value EspICV0 of the ESP header and the encrypted data EnData0, and if the digest value EspICVt is consistent with the digest value EspICV0, calculate the digest value AhICV0 of the entire IP message composed of the data EnData0 and the digest value EspICV0, and if the digest value AhICVt is consistent with the digest AhICV0, forward the data packet formed by the AH header based on the digest value AhICV0, the encrypted data EnData0, and the ESP authentication data EspICV0 to the IPSec VPN gateway connected to it.

6. The secondary encryption system of IPSec VPN as claimed in claim 1, characterized in that: When the data message is ESP encapsulated under AH authentication but without ESP authentication, the secondary encryption process of the secondary encryption unit is as follows: (1) When the type of the currently received data packet is an AH data packet and the next header type in the AH header is ESP encapsulation, the SA corresponding to the data packet is determined by the security parameter index SPI of the ESP header, the destination address in the IP header, and the IPSec protocol type; (2) The encrypted data EnData0 in the data packet is re-encrypted to obtain the encrypted data EnData1, the digest value of the entire IP message is calculated, and the digest value AhICV0 of the AH header in the data packet is XORed to generate the digest value AhICV1, and the AH data packet composed of the AH header based on the digest value AhICV1 and the encrypted data EnData1 is sent out; The data length of the encrypted data EnData1 is the same as that of the encrypted data EnData0, and the data length of the digest value AhICV1 is the same as that of the digest value AhICV0.

7. The secondary encryption system of IPSec VPN as claimed in claim 6, characterized in that: The decryption process of the decryption unit is as follows: (1) When the type of the currently received data packet is an AH data packet and the next header type in the AH header is ESP encapsulation, the corresponding SA is determined by the security parameter index SPI of the ESP header, the destination address in the IP header, and the IPSec protocol type; (2) Check whether the sequence number SN in the ESP header of the currently received data packet is the same as the sequence number SN of the received data packet. If the detection result is no, execute step (3); (3) Calculate the digest value of the entire IP message and perform an XOR operation with the digest AhICV1 in the AH header to obtain the digest value AhICVt; decrypt the encrypted data EnData1 to obtain the encrypted data EnData0; (4) Calculate the digest value AhICV0 of the entire IP message composed of the encrypted data EnData0. If the digest value AhICVt is consistent with the digest value AhICV0, forward the data packet composed of the AH header based on the digest value AhICV0 and the encrypted data EnData0 to the IPSec VPN gateway connected to it.

8. The secondary encryption system of IPSec VPN according to any one of claims 1 to 7, characterized in that: The packet length of the encryption algorithm configured by the IPSec VPN gateway is an integer multiple of the packet length of the encryption algorithm configured by the transparent encryption and decryption device.

9. The secondary encryption system of IPSec VPN as claimed in claim 1, characterized in that: The system further comprises: A local key pool is configured for each transparent encryption and decryption device, and the transparent encryption and decryption device obtains keys from the local key pool, and the keys in the key pool are pre-filled; The key pool key is divided into AH authentication key, ESP authentication key and ESP encryption key. Among them, the AH authentication key is divided into AH authentication input key and AH authentication output key, the ESP authentication key is divided into ESP authentication input key and ESP authentication output key, and the ESP encryption key is divided into ESP encryption input key and ESP encryption output key. The decryption unit performs authentication and decryption on the received encrypted data during the decryption process based on the AH authentication input key and / or the ESP authentication input key and the ESP encryption input key; the secondary encryption unit performs authentication and encryption on the data to be sent during the encryption process based on the AH authentication output key and / or the ESP authentication output key and the ESP encryption output key.

10. The secondary encryption system of IPSec VPN as claimed in claim 1, characterized in that: After the transparent encryption and decryption device identifies the stream of interest based on the security parameter index SPI in the ESP header, the destination address in the IP header and the IPSec protocol type, it establishes different encryption channels for different streams of interest and sets the parameters SA of the corresponding channels, including: SPI, destination address, IPSec protocol type, encryption algorithm and data authentication algorithm, keys in the key pool, and key life cycle.