我希望明确设置加密参数(从.NET 4.7默认值中读取),以便在以后的框架版本实现不同的默认值时避免以后的解密困难。
为什么在手动设置反馈FeedbackSize之后,FeedbackSizeValue不会改变?
AesManaged aes = new AesManaged();
aes.Mode = CipherMode.CBC;
aes.KeySize = 256;
aes.Padding = PaddingMode.PKCS7;
aes.BlockSize = 128;
aes.FeedbackSize = aes.BlockSize;
这是aes对象,请参阅FeedbackSizeValue 8
- aes {System.Security.Cryptography.AesManaged} System.Security.Cryptography.AesManaged
- aes {System.Security.Cryptography.AesManaged} System.Security.Cryptography.AesManaged
BlockSize 128 int
BlockSizeValue 128 int
FeedbackSize 128 int
FeedbackSizeValue 8 int
+ IV {byte[16]} byte[]
IVValue null byte[]
+ Key {byte[32]} byte[]
KeySize 256 int
KeySizeValue 256 int
KeyValue null byte[]
+ LegalBlockSizes {System.Security.Cryptography.KeySizes[1]} System.Security.Cryptography.KeySizes[]
+ LegalBlockSizesValue {System.Security.Cryptography.KeySizes[1]} System.Security.Cryptography.KeySizes[]
+ LegalKeySizes {System.Security.Cryptography.KeySizes[1]} System.Security.Cryptography.KeySizes[]
+ LegalKeySizesValue {System.Security.Cryptography.KeySizes[1]} System.Security.Cryptography.KeySizes[]
Mode CBC System.Security.Cryptography.CipherMode
ModeValue CBC System.Security.Cryptography.CipherMode
Padding PKCS7 System.Security.Cryptography.PaddingMode
PaddingValue PKCS7 System.Security.Cryptography.PaddingMode
+ m_rijndael {System.Security.Cryptography.RijndaelManaged} System.Security.Cryptography.RijndaelManaged
+ Static members
答案 0 :(得分:1)
CBC模式没有反馈大小。见CBC mode:
此外,无需指定块大小(aes.BlockSize = 128;
),AES只有一个块大小。 Rijndael支持几种块大小,有必要指定128位的块大小,基本上是AES。虽然许多Rijndael实现默认为128位的块大小,但完全指定参数总是更好。