linux - Encryption/decryption doesn't work well between two different openssl versions -


i've downloaded , compiled openssl-1.1.0.

i can encrypt , decrypt using same exe of openssl (as here)

me@ubuntu:~/openssl-1.1.0$ ld_library_path=. ./apps/openssl aes-256-cbc -a -salt -in file.txt -out file.txt.enc enter aes-256-cbc encryption password: 123 verifying - enter aes-256-cbc encryption password: me@ubuntu:~/openssl-1.1.0$ ld_library_path=. apps/openssl aes-256-cbc -a -d -in file.txt.enc -out file.txt.dec enter aes-256-cbc decryption password: 123 

this openssl uses: libcrypto.so.1.1, libssl.so.1.1

when try decrypt openssl installed on ubuntu, uses: /lib/x86_64-linux-gnu/libssl.so.1.0.0, /lib/x86_64-linux-gnu/libcrypto.so.1.0.0

i error:

me@ubuntu:~/openssl-1.1.0$ openssl aes-256-cbc -a -d -in file.txt.enc -out file.txt.dec2 enter aes-256-cbc decryption password: 123 bad decrypt 140456117421728:error:06065064:digital envelope routines:evp_decryptfinal_ex:bad decrypt:evp_enc.c:539: 

what may cause this? thanks

the default digest changed md5 sha256 in openssl 1.1

try using -md md5

cgs@ubuntu:~$ echo "it-works!" > file.txt cgs@ubuntu:~$ ld_library_path=~/openssl-1.1.0/ openssl-1.1.0/apps/openssl aes-256-cbc -a -salt -in ~/file.txt -out ~/file.txt.enc -md md5 enter aes-256-cbc encryption password: verifying - enter aes-256-cbc encryption password: cgs@ubuntu:~$ ld_library_path=~/openssl-1.0.1f/ openssl-1.0.1f/apps/openssl aes-256-cbc -a -in ~/file.txt.enc -d enter aes-256-cbc decryption password: it-works! 

the ugly details:

the entered password not used aes (or other encryption) command implicitly derives key it. key derivation uses message digest changed in openssl 1.1 use sha256 not md5 default digest.

in case want keep simple password, , not start messing keying martial (-k,-iv) force same digest -md


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -