zoukankan      html  css  js  c++  java
  • [ipsec][crypto] 什么是AEAD加密算法中的AAD 及aad length

    AAD

    全称:Additianal Authenticated Data

    翻译成中文就是附加的验证数据。

    在理解AAD之前,需要理解什么是AEAD:

    AEAD,简单的来说就是一份数据在完成加密的时候同时完成了消息认证,或者反过来。

    见:[crypto] AEAD是啥

    也就是说,加密用的数据和消息认证用的数据是一样的。

    好,那么下面引出一个场景,就是加密还是同样的加密,但是消息认证需要给丰富的信息才能完成。比如序号。

    这个时候多出来的那个需要就叫做附加验证数据,即AAD。

    那么这段数据的长度就是AAD length。

    举个栗子

    ESP封装既如此。当使用AEAD算法时,并不能满足额外的消息认证能力。因为加密内容本身不包含序列信息,无法防止重放攻击

    所以消息认证需要增加SPI和seq信息。

    又因为SEN的存在。见[crypto][ipsec] 简述ESP协议的sequence number机制

    AAD的长度就有了两种情况,

        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
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |                               SPI                             |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |                     32-bit Sequence Number                    |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    
                 Figure 3: AAD Format with 32-bit Sequence Number
    
        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
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |                               SPI                             |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |                 64-bit Extended Sequence Number               |
       |                                                               |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    
             Figure 4: AAD Format with 64-bit Extended Sequence Number

    SPI + SEQ(low32)

    或 SPI + SEQ(low32)+  SEQ(high32)

    即:8字节或12字节。

    参考:

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

    https://tools.ietf.org/html/rfc4309#section-5

  • 相关阅读:
    依赖倒置原则
    接口声明
    java泛型
    RandomAccessFile
    InputStreamReader/OutputStreamWriter乱码问题解决
    InputStreamReader和OutputStreamWriter
    Android开发UI之Notification
    Android开发UI之Toast的使用
    Android开发之PagerAdapter
    Android开发UI之ViewPager及PagerAdapter
  • 原文地址:https://www.cnblogs.com/hugetong/p/10601312.html
Copyright © 2011-2022 走看看