Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RijndaelManaged vs AesCryptoServiceProvider (AES Encryption)

I needed to encrypt data using AES. While researching I discovered the AesCryptoServiceProvider class.

I know very little about encryption and I did not know what the initialization vector (IV) was, so I tried searching for an AES example in stack overflow and that lead me to this question.

Why does the stack overflow link uses the RijndaelManaged class? Are the RijndaelManaged and AesCryptoServiceProvider classes doing the same thing?

like image 655
Tono Nam Avatar asked Nov 21 '12 03:11

Tono Nam


People also ask

Is RijndaelManaged secure?

Advanced Encryption Standard, short AES or Rijndael At Rijndael, encryption is done with a 128, 192, or 256-bit key, which provides guaranteed increased security against brute-force attacks. In addition, this encryption method works three times faster than DES in software.

Is Rijndael same as AES?

Rijndael and AES differ only in the range of supported values for the block length and cipher key length. For Rijndael, the block length and the key length can be independently specified to any multiple of 32 bits, with a minimum of 128 bits, and a maximum of 256 bits.

What is RijndaelManaged?

Rijndael (pronounced rain-dahl) is an Advanced Encryption Standard (AES) algorithm. It replaced the older and weaker Data Encryption Standard (DES) when it was selected as the standard symmetric key encryption algorithm by the National Institute of Standards and Technology (NIST).

Is Rijndael obsolete?

The Rijndael and RijndaelManaged types are obsolete.


1 Answers

AES is based on Rijndael but with the block size restricted to 128-bits. Rijndael supports a wider range of block sizes and many cryptographic libraries supply a separate Rijndael implementation to complement AES.

Block sizes of 128, 160, 192, 224, and 256 bits are supported by the Rijndael algorithm, but only the 128-bit block size is specified in the AES standard. [Wikipedia]

You linked to the RijndaelManaged class. The equivalent class for AES is AesManaged.

Regarding the difference between the classes: AesManaged simply uses RijndaelManaged with the block size set to 128. AesManaged and RijndaelManaged are not FIPS compliant and when used will throw an exception if the FIPS Group Policy flag is set. .NET Framework 4.6.2 (August 2016) added the AesCng class, an implementation of the CNG version of the AES algorithm.

An IV is a piece of random data, equal in length to the block size, which is required by certain symmetric modes of operation (e.g. CBC-mode). Typically the IV is combined (XOR-ed) with the first block of plaintext or the first block of ciphertext. The idea is to ensure that encrypting the same message twice with the same key will not result in the same output.

like image 129
Duncan Jones Avatar answered Sep 21 '22 19:09

Duncan Jones