SonarQube

使用opensll加解密压缩文件 续

2020-11-05  本文已影响0人  戈壁堂

使用opensll加解密压缩文件

使用 openssl version可以查看对应的版本。加密文件操作在CentOS7上操作,版本为1.0.2k版本 # OpenSSL 1.0.2k-fips 26 Jan 2017

在ubuntu上下载成功后,与原始文件对比MD5值相同。文件有效。但尝试解密时却报错——

*** WARNING : deprecated key derivation used.
Using -iter or -pbkdf2 would be better.
bad decrypt
139932932575680:error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt:../crypto/evp/evp_enc.c:537:

Ubuntu的openssl版本为OpenSSL 1.1.1 11 Sep 2018版本。

参考——

The default hash used by openssl enc for password-based key derivation changed in 1.1.0 to SHA256 versus MD5 in lower versions. This produces a different key from the same password (and salt if used as it usually is), and trying to encrypt and decrypt with different keys produces garbage, an error, or both.

原因是高版本加密时对密码使用sha256进行加密;低版本使用md5方式。如果需要兼容,则需要指定参数 -md的值,确保两边使用相同的摘要算法。所以在高版本上对上述文件进行解密时,命令为——

openssl enc -d -aes256 -md md5 -in mainsonar.tar.gz -pass pass:password |tar xz

上一篇下一篇

猜你喜欢

热点阅读