-1

I'm creating an app which needs to encrypt some data using the Windows Universal SDK.

I've the code, and it all looks pretty good, I'm using the AesCbcPkcs7 algorithm. I don't have any issue with the code, but what I don't understand is what does exactly mean "CbcPkcs7" after "Aes". I'm referring to the algorithm names under Windows.Security.Cryptography.Core.SymmetricAlgorithmNames
like those ones...

AesCbc
AesCcm
AesEcb
AesEcbPkcs7
AesGcm

Artjom B.
  • 58,311
  • 24
  • 111
  • 196
  • 1
    You really need to study cryptography before you try and use it. Those are different ways of using Aes and will substantially change the security of your application – Cobusve Aug 08 '15 at 17:54

1 Answers1

1

AES is a block cipher and as such can only encrypt blocks of fixed size (16 byte).

A mode of operation is needed to encrypt more than a block. ECB for example applies the block cipher as-is on every block of the plaintext separately to get the ciphertext blocks. ECB has problems, because it is not semantically secure, so CBC mode with a random initialization vector is better to use most of the time. Even better is an authenticated mode like GCM which provides not only confidentiality, but also integrity/authenticity.

This is still not enough, because a mode like CBC only enables you to encrypt plaintexts that are a multiple of the block size. A padding scheme is needed to pad the plaintext up to the next multiple of the block size in order to encrypt plaintexts of any length. PKCS#7 padding works by appending bytes with the value of each of those bytes denoting the number of appended bytes.

Modes like CTR and GCM are streaming modes and as such don't need a padding mode additionally to encrypt plaintexts of arbitrary length.

Artjom B.
  • 58,311
  • 24
  • 111
  • 196
  • Now, the more interesting question is whether "AesEcb" and "AesEcbPkcs7" are the same or not. – Artjom B. Aug 08 '15 at 18:03
  • Just a guess, but I suspect AesEcb is PaddingMode.None. Just as ECB is the basic encryption mode from which all other encyption modes are built, .None would be the PaddingMode from which all other PaddingModes are built (because there is no padding, the mode only has to add whatever its protocol calls for). – WDS Aug 09 '15 at 08:50