我正在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进行任何澄清。
谢谢

最佳答案

AAD代表附加的认证数据或附加的关联数据。这是可以与密文一起清除发送的数据。当您执行AEAD密码的组合验证和解密时,密文和AAD都经过完整性验证。

AAD数据不是关键,它只是可以包含在协议中的纯数据,需要对其进行完整性保护,但不需要加密(或者更合乎逻辑的是,对加密无用)。一个很好的例子是加密IP数据包的标头。如果对它进行加密,则不能将其用于路由;如果不保护它的完整性,则攻击者可能会更改消息的长度或源地址,而收件人却不知道。

请注意,AEAD密码在身份验证标签的计算中已经包含IV /随机数。因此,没有必要将其包含在AAD中。 AAD通常用于包括发件人,收件人和可能的消息标识号(如果该标识号位于消息的加密部分之外)。

10-05 22:47