当前位置:网站首页>Packaging and unpacking process of ESP message under IPSec transmission mode

Packaging and unpacking process of ESP message under IPSec transmission mode

2022-06-23 12:47:00 Mengfei

First map

Packaging process

  1. In the original IP In the message payload( It may be carrying TCP message ) Add later ESP trailer Information .
  • ESP trailer Including three parts :Padding, Pad length, Next header. Since the selected encryption algorithm may be block encryption , So it may need to be filled (Padding); Fill length attached (Pad length) It is convenient to remove the filled data when unpacking ;Next Head Used to indicate the original IP The message payload The type of agreement , Such as 6 Express TCP.
  1. The original IP In the message payload And ESP trailer Proceed as a whole encryption , The encryption algorithm and key are provided by SA(Security Association) give .
  2. For the first time 2 Add the encrypted data obtained in step ESP header, Encrypted data and ESP header Collectively known as “Enchilada”, Yes “Enchilada” Make one Abstract , Get an integrity measure (ESP Message Authentication Data), And add to the end , Integrity measurement algorithms include the following The authentication key to be used is provided by SA give .
  • ESP header It consists of two parts :SPI (Security Parameter Index),Sequence number. SPI Used with SA Association , from SAD Get information about the IPSec Packet protocol algorithm, key and other information ;Sequence number It is initially established as 0, Each packet sent will increase automatically 1, Used to resist retransmission attacks .
  1. Put the original IP The head of the protocol Change the field to 50( Indicates that the upper layer agreement is ESP), And add to ESP header front , Complete packaging .

Unpacking process

  1. The receiver receives IP After the message , The protocol type found is 50, That means this is one ESP package . First see ESP header, adopt SPI Determine the corresponding... Of the data message SA , Get the corresponding pattern (tunnel/transport mode) And safety regulations .
  2. Calculation “enchilada” A summary of the section , And attached at the end Authentication Data comparing , Verify data integrity ; Check the sequence number , Make sure the data is “ fresh ” Of , Prevent replay attacks .
  3. according to SA Encryption algorithm and key provided , Decrypt Encrypted data , Get the original IP The message payload And ESP trailer.
  4. according to ESP trailer Of Next Header Judge ESP The type of message protocol encapsulated ( Such as TCP), And according to Padding Length Fill in length information , Find the length of the filled field , Delete and get the original IP The message payload.
  5. take IP Tou and Yuan IP The message payload Combine , Then we get the complete original IP message .

Classic illustration

notes :payload( Load data ) Is relative , about IP Protocol message ,payload yes TCP header + TCP payload, So pay attention to distinguish between the above words and pictures payload describe .

原网站

版权声明
本文为[Mengfei]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206231201091503.html