Numbers in initialization vector (IV) are all zeros

JaneDoe picture JaneDoe · Oct 8, 2015 · Viewed 7.8k times · Source

I'm having trouble understanding the following sentence : "the numbers in initialization vector (IV) are all zeros (not the ASCII character '0').

My goal is to use openssl enc command to encrypt a file using aes-128-cbc with a key K (let's say 1234567890) and the iv that fulfil such requirements.

So far, I've tried not putting -iv option but it then says "iv undefined" because if option -K is used, option -iv must be provided. I've tried to used -iv 0 but I'me not sure it is the correct one.

For the instance, I used:

openssl enc -aes-128-cbc -e -in input.txt -out output.txt -K 1234567890 -iv 0

Can please you help me illustrate the correct iv that fulfill the above requirements?

Answer

Leśny Rumcajs picture Leśny Rumcajs · Oct 8, 2015

For modes CBC, CFB or OFB you need initialization vector, which in length is equal to block size of a specific cipher. For AES you have 128 bits.

You can check your command by using -p, for example:

openssl enc -aes-128-cbc -e -in test.txt -out output.txt -K 1234567812346578 -iv 0 -p

Would give you :

salt=A086E8DE00000000
key=12345678123456781234567812345678
iv =00000000000000000000000000000000

If your key or IV is too short, it will pad it with zeroes till reaching the correct size.