赞
踩
第一次做IPsec还是在2009年,那个时候主要研究的都是23xx系列的RFC,这么多年过去了,IPsec又推出了一系列的算法,最近要分析IPsec-AES-GCM的封装问题,主要是其Padding大小是多少,于是又研究了一下。
首先在RFC4303中有一段说明:
For the purposes of ensuring that the ICV is aligned on a
4-byte boundary (second bullet above), the padding
computation applies to the Payload Data inclusive of the IV,
the Pad Length, and Next Header fields. If a combined mode
algorithm is used, any replicated data and ICV-equivalent
data are included in the Payload Data covered by the padding
computation.
也就是说,原始的明文+Padding至少是要4字节对齐。
其次在RFC4106中说了这么一段:
The IV adds an additional eight octets to the packet, and the ICV
adds an additional 8, 12, or 16 octets. These are the only sources
of packet expansion, other than the 10-13 octets taken up by the ESP
SPI, Sequence Number, Padding, Pad Length, and Next Header fields (if
the minimal amount of padding is used).
这里结合上面的4字节对齐,来看10-13字节这一句。也就是除去SPI(4字节)、Sequence Number(4字节),Pad Length(1字节),Next Header(1字节),还剩下0-3字节。
因此,该算法最小添加字节数为:SPI(4)+Seq(4)+IV(8)+Pad(0)+Pad Len(1)+Next Header(1)+ICV(8)=26;
最大添加字节数为:SPI(4)+Seq(4)+IV(8)+Pad(3)+Pad Len(1)+Next Header(1)+ICV(16)=37;
注:以上不考虑TFC
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。