【发布时间】: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-GCM 示例stackoverflow.com/a/10366194/637783
-
谢谢,我希望在我自己写之前看到这一点