识别AES算法。是AES 128还是AES 256?

时间:2013-08-21 07:22:04

标签: c# aes

我正在使用AES算法加密& c#中的解密。我正在使用 AesCryptoServiceProvider 类进行加密&解密。

以下是我在代码中的设置

AesCryptoServiceProvider result = new AesCryptoServiceProvider();
result.BlockSize = 128;
result.KeySize = 256;
result.Mode = CipherMode.CBC;
result.Padding = PaddingMode.PKCS7;

我很困惑我在这里使用的代码是AES 128还是AES 256的实现。

简单的问题是如何识别您使用的是AES 256 / AES 128?

我试过这个链接:http://social.msdn.microsoft.com/Forums/vstudio/en-US/ac5f4d30-343e-484e-b795-b214820a9327/aes-net-encryption-is-it-always-256-bit-aes

但我没有得到答案。

2 个答案:

答案 0 :(得分:5)

它是AES 256.数字是密钥大小。

来自Wikipedia

  

严格地说,AES标准是Rijndael的变体,其中块大小限制为128位。

因此块大小总是 128。


我不能指出任何官方文档,因为(据我所知)AES-<Number>一直是非官方的简写。我可以指出一个引用研究论文的Bruce Schneier Blog Post

  

AES是最着名和最广泛使用的分组密码。它的三个版本(AES-128,AES-192和AES-256)的密钥大小(128位,192位和256位)和轮数(分别为10,12和14)不同。在......的情况下。

虽然您的客户可能不喜欢该博客文章的其余部分,因为Schneier推荐AES-128而不是AES-256。

答案 1 :(得分:2)

AES的官方规范是FIPS-197。它包含有关密钥大小和块大小的以下文本。

1. Introduction

This standard specifies the Rijndael algorithm ([3] and [4]), a symmetric block cipher that can
process data blocks of 128 bits, using cipher keys with lengths of 128, 192, and 256 bits.
Rijndael was designed to handle additional block sizes and key lengths, however they are not
adopted in this standard.

Throughout the remainder of this standard, the algorithm specified herein will be referred to as
“the AES algorithm.” The algorithm may be used with the three different key lengths indicated
above, and therefore these different “flavors” may be referred to as “AES-128”, “AES-192”, and
“AES-256”.

由于NIST在比赛后选择Rijndael为AES,因此无法获得更权威的参考。

请注意,虽然您的代码还包含CBC和PKCS#7填充,但这些不是AES规范的一部分。 CBC是NIST批准的分组密码操作模式(参见NIST SP 800-38A)。该规范还提到NIST没有考虑填充方案,可能是因为它们不应该被用作提供任何安全性的算法(对于分组密码模式)。