private static void VerifyDecrypt(NistKnownAnswerTestVector vector) { var rijndael = new Rijndael(vector.Key); int feedbackSize = vector.BitLength < 128 ? 8 : vector.BitLength; var transform = RijndaelDecryptionTransformFactory.Create(rijndael, vector.CipherMode, vector.IV, feedbackSize, PaddingMode.None); byte[] output = new byte[vector.Ciphertext.Length]; transform.TransformBlock(vector.Ciphertext, 0, vector.Ciphertext.Length, output, 0); AssertBytesEqual(vector.Plaintext, output, vector.BitLength); }
/// <summary> /// Creates a decryption transform that can be used by the .NET cryptography APIs. /// </summary> /// <param name="cipherMode">The mode if the cipher to use.</param> /// <param name="initializationVector">An initialization vector (if used by the <paramref name="cipherMode"/>, or <see langword="null"/> if not used).</param> /// <param name="feedbackSizeInBits">Size of the feedback register in bits for feedback modes.</param> /// <param name="paddingMode">The style of padding to apply to the last block.</param> /// <returns>An decryption transform that can be used by the .NET cryptography APIs.</returns> public ICryptoTransform CreateDecryptor(CipherMode cipherMode, byte[] initializationVector, int feedbackSizeInBits, PaddingMode paddingMode) { return(RijndaelDecryptionTransformFactory.Create(this, cipherMode, initializationVector, feedbackSizeInBits, paddingMode)); }