So I followed openssl: recover key and IV by passphrase and managed to retrieve my salt, key and IV using -P
in openssl.
openssl enc -aes-256-cbc -in encrypted -pass "pass:password" -out m.jpg
this gives me the proper m.jpg
file so I would assume
openssl enc -aes-256-cbc -d -in encrypted -pass "pass:password" -out m.jpg -P
gives me the right salt, key and IV:
salt=7A01E44D968CEBD0
key=6F4C7DD6F49D0605095CAD7EA2745913E83B71A52C34F2ED260544286FDEE78A
iv =0BBD122901B13F76D03ED2EBE4E8D1CC
Now when I tried to decrypt the encrypted file with the above salt, key and IV by doing
openssl enc -aes-256-cbc -d -in encrypted -K 6F4C7DD6F49D0605095CAD7EA2745913E83B71A52C34F2ED260544286FDEE78A -iv 0BBD122901B13F76D03ED2EBE4E8D1CC -S 7A01E44D968CEBD0 -out m.jpg
I wasn't able to decrypt the file. Maybe something's wrong with the format? So I tried putting them into quotes
openssl enc -aes-256-cbc -d -in encrypted -K "6F4C7DD6F49D0605095CAD7EA2745913E83B71A52C34F2ED260544286FDEE78A" -iv "0BBD122901B13F76D03ED2EBE4E8D1CC" -S "7A01E44D968CEBD0" -out m.jpg
and to no avail.
The --help
states that
-iv IV IV to use, specified as a hexidecimal string
-K key Key to use, specified as a hexidecimal string
-S salt Salt to use, specified as a hexidecimal string
which is exactly what I did. Unless there is a special way of passing the hex string?
Or had something gone wrong in my process of retrieving the IV, key and salt? (Or in the process of decrypting the file)?