Reputation: 1
I am encrypting a data file using below openssl function
KEY="123456KEY";
IVEC="123456IVEC"
AES_set_encrypt_key(KEY, 128, &key);
AES_cfb128_encrypt(indata, outdata, bytes_read, &key, IVEC, &num, AES_ENCRYPT);
As a result I have encrypted file file.tgz.enc, I can decrypt this file using same AES_cfb128_encrypt(AES_DECRYPT) function, but I want to decrypt this file using command line openssl command. I am trying like
======
COMMAND
======
/usr/bin/openssl enc -aes-128-cbc -d -in file.tgz.enc -out
new-file.tgz -K 123456KEY -iv 123456IVEC
======
OUTPUT
======
non-hex digit
invalid hex iv value
I am getting error on command line, like non-hex digit, invalid hex iv value and I am unable to decrypt the file. any idea ? Can some one guide me ?
Upvotes: 0
Views: 1574
Reputation: 4044
-K and -iv expects hex character and the input you specified has non hex characters K
and Y
in 123456KEY
and I
and V
in 123456IVEC
You need pass proper 16 byte key to AES_cfb128_encrypt
and initialization vector to AES_cfb128_encrypt
But KEY has only 9 bytes, if size of KEY(variable) is 9 too, it is likely to result into undefined behavior as AES_set_encrypt_key
will go on reading 128 bites(16 bytes) from KEY
Whichever key and IV you use in your code, you need to take its hex representation and use it in openssl command tool
Upvotes: 1