8

I have a message, I know the password and the cipher that was used to encrypt it, but I can't figure out how to ask openssl to decrypt it.

I see the cipher in the output from the ciphers command, and the man page lists a enc command for Encoding with Ciphers, but I can't find how I would do the opposite, decode a message.

2
  • 1
    What program is used to encrypt the file? It is very likely that the encryption program adds metadata to the encrypted content, like the initialization vector, salt, version of the program etc. If you treat the whole as encrypted bits, you will get garbage out.
    – Siyuan Ren
    Oct 15 '14 at 2:05
  • Late but: openssl ciphers lists ciphersuites for SSL/TLS, which is in practice never password based, and doesn't leave messages anywhere you could later decrypt (i.e. if you have a file, it's not SSL/TLS). openssl enc is one commonly used password-based encryption scheme, but there are CMS and (rarely) S/MIME PBEs and a common PGP PBE, and also PBE schemes for keys which are not accurately described as messages, as well as other PBEs. Jul 31 '16 at 7:42
1

I think you're looking for something like this:

openssl yourcipher -d < yourfile

For example if the file was encrypted using des3 cipher, and the file is /path/to/file.des3 then:

openssl des3 -d < /path/to/file.des3

It will ask you for the passphrase.

If the file is base64 encoded, then you should be able decode and decrypt like this:

openssl enc -base64 -d < /path/to/file | openssl yourcipher -d
7
  • Trying that, after entering the passphrase, I get "bad magic number". Not sure how to interpret that.
    – user50849
    Jan 15 '14 at 22:27
  • That error is common when the file is not really an encrypted file... Perhaps you need to unzip it first?
    – janos
    Jan 15 '14 at 22:32
  • 1
    If I've understood my instructions correctly, my file is base64 encoded (It looks like base64 as well, though that's no guarantee of course). But I've tried passing it through base64 -d [input] > [output] and then openssl [cipher] -d < [output] as well as deciphering the file as is, and I get the same "bad magic number" in both cases.
    – user50849
    Jan 15 '14 at 22:53
  • @user50849 I updated my answer thought it looks like you're already doing that... After you decode from base64, what does the file command tell you? Is the file binary?
    – janos
    Jan 15 '14 at 23:04
  • I tried your added base64 command, and unfortunately I get the same error. file says data about the decoded file. I assume that your answer is correct and that something is wrong on my end. Possibly I've corrupted the input or similar. I'll try to work that out and get back.
    – user50849
    Jan 15 '14 at 23:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.