3

我在 C# 中以 GCM 模式实现 AES 密码。我的问题与“其他经过身份验证的数据”(AAD)有关。在以下代码中

http://blogs.msdn.com/b/shawnfa/archive/2009/03/17/authenticated-symmetric-encryption-in-net.aspx

目前还不清楚我应该从哪里获得 AAD,以及在解密期间我应该如何检索特定于该加密的 AAD:

// Authenticated data becomes part of the authentication tag that is generated during
// encryption, however it is not part of the ciphertext.  That is, when decrypting the
// ciphertext the authenticated data will not be produced.  However, if the
// authenticated data does not match at encryption and decryption time, the
// authentication tag will not validate.
aes.AuthenticatedData = Encoding.UTF8.GetBytes("Additional authenticated data");

任何有关如何使用此 AAD 的说明将不胜感激。谢谢

4

1 回答 1

12

AAD 代表 Additional Authenticated Data 或 Additional Associated Data。这是可以与密文一起以明文形式发送的数据。当您执行 AEAD 密码的组合验证和解密时,密文和 AAD 的完整性都会得到验证。

AAD 数据不是密钥,它只是您可以包含在协议中的纯数据,需要保护完整性,但不需要(或者更合乎逻辑地,对加密没有用处)。一个很好的例子是加密 IP 数据包的标头;如果你加密它,你就不能将它用于路由,如果你不保护它的完整性,攻击者可能会在接收者不知道的情况下更改消息长度或源地址。

请注意,AEAD 密码已经在身份验证标签的计算中包含了 IV / nonce。因此,没有必要将其包含在 AAD 中。AAD 通常用于包括发送者、接收者和可能的消息标识号 - 如果它存在于消息的加密部分之外。

于 2012-07-17T20:56:50.893 回答