Initialization Vector

Encryption work by taking a number of text blocks and then applies a key to these to produce cipher .blocks. Cipher blocks could end up being the same for the same input text. Thus an intruder could try and guess the cipher text. This is knows as electronic code book.You will find that every time you encrypt, you will find that every time you encrypt you will get the same value.

Apart from using a password to generate an encryption key, which complete decimates the key space, we have the problem of the algorithm used to process the plain text. If this is ECB then we have repeating cipher blocks for the same plain text.

If I take "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" and encrypt with 3-DES and a key of "beginner12345" we get:

encrypted: DDE22EE186FA0425 DDE22EE186FA0425
DDE22EE186FA0425 DDE22EE186FA0425 DDE22EE186FA0425 DDE22EE186FA0425 DDE22EE186FA0425 B2460B702A2508AE

Where we can see that the "a...a" values are always coded with same cipher text. Thus we can say the "aaaaaaaa" maps to the cipher text of DDE22EE186FA0425 .

Adding IV

So, How do we overcome this problem, of always ending up with the same cipher text for a given plain text ? We add a bit of salt, to make sure that your result is always changing. For this we cipher text will change each time. This is typically applied into shared-key encryption and in hashing where we try and make sure that the cipher text differs for the same plain text.

The method most often used is CBC, where we start off with a random seed, knows as Initialization Vector. This is then used to create the first block. Next the output from the first block is then used to chain into the next block by Exclusive-Oring the output of the first with the output of the second block.

When does IV go wrong ?


We then end up with differing cipher block for a  changing IV. To change the IV , we might increment it by one for every message that we send. We could send it with the first message that we send, and we agree with the other side on how the IV vector will change. In the wireless encryption method, it had an IV which actually came around again after a certain amount of time, which meant that an intruder could actually determine the key used in encryption, which meant that an intruder could actually determine the key used in encryption, which obviously compromised the whole system.  WEP has been replaced by a session key which is unique to each host and which times-out before it can roll-over.

Comments

Popular posts from this blog

Maven Setting Mirror

Spring Session

Hibernate Version 5.0