3 回答

TA貢獻(xiàn)1836條經(jīng)驗(yàn) 獲得超4個(gè)贊
在Openssl 1.1中,默認(rèn)摘要從MD5更改為SHA256
嘗試使用-md md5
cgs@ubuntu:~$ echo "it-works!" > file.txtcgs@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 md5enter 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 -denter aes-256-cbc decryption password:it-works!
丑陋的細(xì)節(jié):
輸入的密碼不是由aes(或其他加密)使用,但命令隱式從中導(dǎo)出密鑰。密鑰派生使用在openssl 1.1中更改的消息摘要使用SHA256而不是MD5作為默認(rèn)摘要。
如果你想保持簡單的密碼,而不是開始搞亂鍵盤軍事(-K,-iv)只需用-md強(qiáng)制相同的摘要

TA貢獻(xiàn)2019條經(jīng)驗(yàn) 獲得超9個(gè)贊
OpenSSL 1.1和LibreSSL之間也可能發(fā)生此問題。在這種情況下,以及在可用的更安全的消息摘要的其他情況下,您應(yīng)該避免使用-md md5
加密新文件,因?yàn)镸D5算法具有廣泛的漏洞。
您應(yīng)該使用-md sha256
或所有版本支持的其他更安全的消息摘要。-md md5
應(yīng)僅用于解密舊文件,理想情況下應(yīng)使用sha256重新加密。這也在OpenSSL FAQ中提到:
消息摘要用于從人工輸入的密碼短語創(chuàng)建加密/解密密鑰。在OpenSSL 1.1.0中,我們從MD5更改為SHA-256。我們這樣做是作為整體改變的一部分,以擺脫現(xiàn)在不安全和破碎的MD5算法。如果您有舊文件,請(qǐng)使用“-md md5”標(biāo)志對(duì)其進(jìn)行解密。
要檢查您正在使用的不同版本支持哪些消息摘要,請(qǐng)運(yùn)行openssl help
:
LibreSSL 2.2.7(包含在macOS 10.13 High Sierra中):
$ openssl help
…
Message Digest commands (see the `dgst' command for more details)
gost-mac md4 md5 md_gost94
ripemd160 sha sha1 sha224
sha256 sha384 sha512 streebog256
streebog512 whirlpool
…
OpenSSL 1.1f:
$ openssl help
…
Message Digest commands (see the `dgst' command for more details)
blake2b512 blake2s256 gost md4
md5 rmd160 sha1 sha224
sha256 sha384 sha512
…
添加回答
舉報(bào)