美文网首页SonarQube
使用opensll加解密压缩文件 续

使用opensll加解密压缩文件 续

作者: 戈壁堂 | 来源:发表于2020-11-05 20:05 被阅读0次

使用opensll加解密压缩文件

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

  • 文件有点大,7GB左右,分片上传后,
  • 使用okhttp下载会报错EOF
  • 通过签名下载还遇到了坑:下载到4G多一点之后就自动断开了,一开始指定的失效时间有点短,wget默认自动重试时链接已经失效。
  • 签名算法……另外的坑,算了~

在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

相关文章

网友评论

    本文标题:使用opensll加解密压缩文件 续

    本文链接:https://www.haomeiwen.com/subject/dimavktx.html