Reputation: 69
I am trying to encrypt a text file with openssl
using aes-128-cbc
encryption and I was wondering if there was a way I could encrypt it only using the key and not the iv?
Everytime I try to run:
openssl enc -aes-128-cbc -e -in dummy_file.txt -out dummy.aes-128-cbc.bin -K 00112233445566778889aabbccddeeff
I get the error saying iv undefined
and the encrypted file it generates is empty and it is not even a binary file.
Upvotes: 3
Views: 9745
Reputation: 94078
No, that's not possible, CBC requires an IV. You can however set the IV to all zeros. As the IV is XOR'ed with the first block of plaintext before encryption, this comes down to having no IV at all: you would directly encrypt the first block of plaintext with the block cipher.
Note that creating multiple ciphertext with the same key and IV will not result in a secure cipher. For CBC it is required to have a random (or at least unpredictable) IV. Otherwise an attacker can at least see which plaintext start with identical blocks of data.
The IV always consists of 16 bytes for AES, which comes down to 32 hexadecimal zeros, of course for the -iv
command line parameter of openssl
.
Upvotes: 10