IV
IV是指初始化向量。
在我们当前讨论的场景中: 在IPSec ESP使用AES-GCM加密
IV有两个含义:
1. ESP报文封装时的IV,RFC中称为 AES-GCM IV
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Initialization Vector |
| ( octets) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
~ Ciphertext (variable) ~
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2. 在讨论加解密设备的时候,我们讨论的IV,与1中不同,称为 AES-GCM-ESP IV, 也称作nonce
nonce由 salt 和1中IV组成。
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Salt |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Initialization Vector |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
总结:
ESP的IV协议规定了固定长度是8字节,salt是固定的4字节。所以在当前场景内,GCM的IV长度,固定为12字节。
参考:
https://tools.ietf.org/html/rfc4106#section-3.1
其他:
1 block size
由算法决定AES的block size为固定的16字节。
AES is a variant of Rijndael which has a fixed block size of bits, and a key size of , , or bits.
https://en.wikipedia.org/wiki/Advanced_Encryption_Standard
2 key length
AES的算法名字里边有AES128,AES256,这个怎么理解呢?
在实际的ESP封装传输以及ipsec协商中,他们使用的key length是上面的128,256 再加上32bit的盐。
在编码是需要注意。
AES-GCM-ESP with a bit key
The KEYMAT requested for each AES-GCM key is octets. The first
octets are the -bit AES key, and the remaining four octets
are used as the salt value in the nonce. AES-GCM-ESP with a bit key
The KEYMAT requested for each AES-GCM key is octets. The first
octets are the -bit AES key, and the remaining four octets
are used as the salt value in the nonce. AES-GCM-ESP with a bit key
The KEYMAT requested for each AES GCM key is octets. The first
octets are the -bit AES key, and the remaining four octets
are used as the salt value in the nonce.