I'm trying to decrypt a base64 string which has been encrypted with aes256 in openssl. I was given the session key and IV, which were encrypted with my key. I converted them to hexadecimal so that I can use the following openssl command:
openssl enc -d -aes256 -iv iv.hex -K sessionkey.hex -in message.b64 -out message.txt
I get the error saying the IV is a non-hex value. I started out with IV and session key in base64, which was encrypted with my key. So I did the following:
//convert base64 to binary
openssl base64 -d -in iv.b64 -out iv.bin
openssl base64 -d -in sessionkey.b64 -out sessionkey.bin
//decrypt using my private key
openssl rsautl -decrypt -inkey mykey.pem -in sessionkey.bin -out sessionkey_out.bin
openssl rsautl -decrypt -inkey mykey.pem -in iv.bin -out iv_out.bin
//convert to hex using the following C code:
include
main()
{
int c;
while ((c=getchar())!=EOF)
printf("%02X",c);
}
//use the hex IV and key to decrypt the message
openssl enc -d -aes256 -iv iv.hex -K sessionkey.hex -in message.b64 -out message.txt
I get the error at the last step, saying the IV is non-hex. Any ideas?