Glam Prestige Journal

Bright entertainment trends with youth appeal.

I am using OpenSSL 1.0.1e-fips under RHEL 6.9.

I have encrypted a file with this command:

openssl enc -aes-256-gcm -a -e -in plaintext -out ciphertext

I then decrypt the encrypted file with this command:

openssl enc -aes-256-gcm -a -d -in ciphertext

This command produces this output:

test text
bad decrypt

The file has decrypted properly (i.e. the content of the file was indeed "test text"), but OpenSSL is reporting "bad decrypt". This happens even if I explicitly specify a hash function to use (e.g. -md sha512).

Why am I getting the "bad decrypt" message?

1 Answer

No version of OpenSSL supports any AEAD mode (which includes GCM) in conjunction with the "enc" command line app. All currently supported versions of OpenSSL will display an error message if you try to encrypt/decrypt using such a mode:

$ openssl enc -aes-256-gcm -a -e -in plaintext -out ciphertext
enc: AEAD ciphers not supported

OpenSSL 1.0.1 is a very old version of OpenSSL and is not currently supported by the project (although it may be supported by Red Hat). Very old versions of OpenSSL did not have the AEAD check that produces the above warning and attempted to encrypt/decrypt anyway - but incorrectly. Most significantly the "enc" command does not know how to handle the "tag" of an AEAD mode (hence the "bad decrypt" message you see). The tag is critical for security since it verifies the integrity of the ciphertext.

The command may look like its worked - but it hasn't. Basically don't use GCM mode with the enc command.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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