【问题标题】:AES GCM implementation in c#c# 中的 AES GCM 实现
【发布时间】:2012-07-12 08:10:54
【问题描述】:

我正在 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 的说明将不胜感激。 谢谢

【问题讨论】:

标签: c# aes aes-gcm


【解决方案1】:

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

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

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

【讨论】:

猜你喜欢
  • 2015-12-19
  • 1970-01-01
  • 2018-10-18
  • 2013-07-17
  • 1970-01-01
  • 2016-12-19
  • 2014-07-14
  • 1970-01-01
  • 2014-03-19
相关资源
最近更新 更多