2

I was trying encryption/decryption with AES then I tried the CBC & ECB modes I got the same encrypted output from all three ! is this how it goes?
it's may not be wrong but I just don't know what to expect . and what's the point of having modes if they all produce the same cipher ? is it time or performance complexity ?

can you explain the difference between AES and its cipher modes ? what's the default cipher mode ? or if you can give me any references cuz MSDN is not clear enough

thank you

Katia
  • 679
  • 2
  • 15
  • 42
  • 1
    Wikipedia has an article http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation – Ben Robinson Dec 02 '11 at 14:29
  • 1
    Was your input longer then the blocklength of your cypher? Because the modes control how inputs longer then one block are encrypted (see http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation). For only one block different modes can give the same result (depending on the IV of course) – Grizzly Dec 02 '11 at 14:31
  • 1
    @Grizzly I was trying things like my name :) not long enough to see the difference I guess .thanks – Katia Dec 02 '11 at 14:35
  • @katia: Note that you should not use a zero (or otherwise fixed) initialization vector for CBC, but instead a random one. And don't ever use ECB, until you understand why you shouldn't use it. – Paŭlo Ebermann Dec 02 '11 at 18:19

1 Answers1

5

CBC and ECB modes are ways to use symmetric encryption algorithms when you are encrypting data that is larger than one block (128 bits in AES). So, if you are encrypting data that fits into one block then CBC and ECB modes will result in the same ciphertext (assuming you are using a null IV when using CBC mode). If you are encrypting data greater in size than one block, or you are using an IV that is not null, and you are seeing CBC and ECB encryptions of the same data come out the same, you're doing something wrong in your code.

This is explained very well in the Wikipedia entry.

http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation