在“AESCryptoServiceProvider”中,生成内部使用的()方法CryptGenRandom()
的advapi32.dll
。 GenerateIV的
方法认定中():
public override void GenerateIV() {
Contract.Ensures(IVValue != null && IVValue.Length == BlockSizeValue/8);
Contract.Assert(m_cspHandle != null);
Contract.Assert(BlockSizeValue % 8 == 0);
byte[] iv = new byte[BlockSizeValue/8];
if (!CapiNative.UnsafeNativeMethods.CryptGenRandom(m_cspHandle, iv.Length, iv)) {
throw new CryptographicException(Marshal.GetLastWin32Error());
}
IVValue = iv;
}
CryptGenRandom的签名():
/// <summary>
/// Fill a buffer with cryptographically random bytes
/// </summary>
[DllImport("advapi32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptGenRandom(SafeCspHandle hProv,
int dwLen,
[Out, MarshalAs(UnmanagedType.LPArray)] byte[] pbBuffer);
http://stackoverflow.com/questions/8041451/good-aes-initialization-vector-练习 – vikky 2015-02-12 08:58:14
已经通过该线程。不管怎样,谢谢。它说在密码文本和混淆之前预先安排。 也检查NIST的标准。 http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf 检查此以及 http://security.stackexchange.com/questions/42642/should-aes-always -give-the-same-output – 2015-02-12 09:26:52