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

时间:2013-02-17 00:27:39

标签: encryption openssl aes sha1

我必须为我的计算机安全类做一个实验室,我将使用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.) 

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

对此有任何帮助将不胜感激。

谢谢。

1 个答案:

答案 0 :(得分: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

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

openssl enc -aes-256-cbc -md sha1 -P

他们实际上似乎忘记在manual page中解释-md

相关问题