生成aes256 cbc密钥时使用SHA1作为消息摘要

zer*_*dev 5 encryption openssl sha1 aes

我必须为我的计算机安全类做一个实验室,我将使用gpg和OpenSSL进行安全通信.我对这一步感到困惑:

Use 'openssl enc' command line symmetric cipher routine to generate a 
256bit AES key in CBC mode. You should use SHA1 as a message digest 
function for generating the key. Save generated secret key, IV, and 
salt into file named aes.key. (Use –P opting to print out the key, 
salt and IV used then immediately exit, don’t do any encryption at 
this step.) 
Run Code Online (Sandbox Code Playgroud)

但我正在查看openssl enc的手册页,我看不到摘要的选项.我知道有一个openssl dgst命令,但它只是计算输入的哈希值.这个问题有缺陷吗?什么"你应该使用SHA1作为消息摘要函数来生成密钥"是什么意思?我生成一个密钥然后只生成SHA1(key.aes)?

任何帮助都将不胜感激.

谢谢.

Dan*_*ger 5

openssl enc给出它的未知参数时获得的使用信息,例如-h:

-md            the next argument is the md to use to create a key
                 from a passphrase.  One of md2, md5, sha or sha1
Run Code Online (Sandbox Code Playgroud)

因此,您应该使用-md sha1将SHA1指定为密钥派生中使用的哈希函数.该步骤的完整解决方案是:

openssl enc -aes-256-cbc -md sha1 -P
Run Code Online (Sandbox Code Playgroud)

他们实际上似乎忘记-md手册页中解释.