Exemple #1
0
        private static void VerifyEncrypt(NistKnownAnswerTestVector vector)
        {
            var rijndael = new Rijndael(vector.Key);

            int feedbackSize = vector.BitLength < 128 ? 8 : vector.BitLength;

            var transform = RijndaelEncryptionTransformFactory.Create(rijndael, vector.CipherMode, vector.IV,
                                                                      feedbackSize, PaddingMode.None);

            byte[] output = transform.TransformFinalBlock(vector.Plaintext, 0, vector.Plaintext.Length);
            AssertBytesEqual(vector.Ciphertext, output, vector.BitLength);
        }
Exemple #2
0
 /// <summary>
 /// Creates an encryption 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 encryption transform that can be used by the .NET cryptography APIs.</returns>
 public ICryptoTransform CreateEncryptor(CipherMode cipherMode, byte[] initializationVector,
                                         int feedbackSizeInBits, PaddingMode paddingMode)
 {
     return(RijndaelEncryptionTransformFactory.Create(this, cipherMode, initializationVector, feedbackSizeInBits,
                                                      paddingMode));
 }