private static void PerformRandomizedTest(CipherMode mode, PaddingMode padding, int keySize)
        {
            var aesCapi = new AesCryptoServiceProvider();

            aesCapi.Mode    = mode;
            aesCapi.Padding = padding;

            aesCapi.Key = ByteUtilities.GetCryptographicallyRandomBytes(keySize / Constants.BitsPerByte);
            aesCapi.IV  = ByteUtilities.GetCryptographicallyRandomBytes(128 / Constants.BitsPerByte);
            var capiEncryptionTransform = aesCapi.CreateEncryptor();

            var ours = new Rijndael(aesCapi.Key);
            var ourEncryptionTransform = ours.CreateEncryptor(aesCapi.Mode, aesCapi.IV, aesCapi.FeedbackSize,
                                                              aesCapi.Padding);

            byte[] encryptedResult = PerformRandomizedTest(capiEncryptionTransform, ourEncryptionTransform, null);

            var capiDecryptionTransform = aesCapi.CreateDecryptor();
            var ourDecryptionTransform  = ours.CreateDecryptor(aesCapi.Mode, aesCapi.IV, aesCapi.FeedbackSize,
                                                               aesCapi.Padding);

            byte[] decryptedResult = PerformRandomizedTest(capiDecryptionTransform, ourDecryptionTransform,
                                                           encryptedResult);
        }
Пример #2
0
 public Rijndael()
     : this(ByteUtilities.GetCryptographicallyRandomBytes(256 / Constants.BitsPerByte))
 {
 }