vico
vico

Reputation: 18201

Does decryptor need to know initialization vector?

Trying to understand how encrytion works in specific application I use. I know that system transfer 16 bytes long AES-128 key to other side and its value in hex is 2b779fddc83888c18253f14022497328. I also know that AES CBC algorithm is used for encryption. Data for encryption is string aaaaaaaa.

Trying to reproduce encrypt with openssl enc command:

openssl enc -aes-128-cbc -K 2b779fddc83888c18253f14022497328 -iv 0123456789ABCDEF -in plain.txt -out encrypted.txt

According this procedure I found that initialization vector is also needed, but application documentation says nothing about it. Is it possible that IV omitted in application? Does usual way of passing key to other side includes initialization vector also?

Content of encrypted.txtin case aaaaaaaa input string:

48 EF 03 13 71 AE 2F DC │ 54 99 4D F6 F5 F1 ED 60

UPD

I found in documentation that my 8 bytes input string should be trailed with NUL till length becomes 16 bytes.

In this case content of plain.txt in HEX is:

61 61 61 61 61 61 61 61 00 00 00 00 00 00 00 00

and content of encrypted.txt:

3E 12 7D 26 60 EF E4 AD 34 D8 94 11 27 28 59 E8 F6 D8 5F 4B D1 03 69 A5 13 09 FC BD 49 A9 EF 8C

Does knowing that last 8 bytes in plain.txt is always NUL brings information to decryptor about IV?

Upvotes: 0

Views: 386

Answers (1)

Alexandre Fenyo
Alexandre Fenyo

Reputation: 4819

With CBC-based AES encryption, the IV must be chosen randomly and is a public information. It makes two encrypted contents of the same byte array not having the same encrypted value. You need to know the IV value to decrypt the data.

Upvotes: 1

Related Questions