[ipsec][crypto] 在IPSec ESP使用AES-GCM加密时的IV

IV

IV是指初始化向量。

在我们当前讨论的场景中: 在IPSec ESP使用AES-GCM加密

IV有两个含义:

1. ESP报文封装时的IV,RFC中称为 AES-GCM IV

    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                      Initialization Vector                    |
   |                            (8 octets)                         |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                                                               |
   ~                       Ciphertext (variable)                   ~
   |                                                               |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

2. 在讨论加解密设备的时候,我们讨论的IV,与1中不同,称为 AES-GCM-ESP IV, 也称作nonce

  nonce由 salt 和1中IV组成。

   0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                             Salt                              |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                     Initialization Vector                     |
   |                                                               |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

总结:

  ESP的IV协议规定了固定长度是8字节,salt是固定的4字节。所以在当前场景内,GCM的IV长度,固定为12字节。

参考:

https://tools.ietf.org/html/rfc4106#section-3.1

另外

有算法决定AES的block size为固定的16字节。

AES is a variant of Rijndael which has a fixed block size of 128 bits, and a key size of 128, 192, or 256 bits.

https://en.wikipedia.org/wiki/Advanced_Encryption_Standard

猜你喜欢

转载自www.cnblogs.com/hugetong/p/10601828.html
今日推荐