I have to create a Shell script that can decrypt a RSA key file that is encrypted with a specific .pem
file. And then to decrypt .zip
file with the AES key which I get from the RSA file once it is decrypted in a file named keyaes
(or whatever you want).
Here are the two commands I have to use
openssl rsautl -decrypt -in AES_KEY -inkey CERTIFICATE.pem -out keyaes
openssl enc -d -aes-256-cbc -in zipfile.zip -out extraction.zip -nosalt -p -K RSA_KEY_from_key_aes_output -iv 0
The commands work perfectly, the problem is in my script I don't know how to make it automatically and to get the key from the keyaes
output and put it into the next command properly.
How can I do it?
You could just use Bash command substitution in the second command, using backticks
openssl enc -d -aes-256-cbc -in zipfile.zip -out extraction.zip -nosalt -p -K `cat output_filename_with_aes_key` -iv 0