PBKDF2-HMAC-SHA1

发布于 2024-08-25 17:15:15 字数 455 浏览 6 评论 0原文

为了为 WPA2 网络生成有效的成对主密钥,路由器使用 PBKDF2-HMAC-SHA1 算法。据我所知,sha1 函数执行了 4096 次来导出 PMK,但是我对该过程有两个问题。

请原谅伪代码。

1) SHA1 函数第一个实例的输入是如何格式化的? SHA1("network_name"+"network_name_length"+"network_password")

是否按该顺序格式化,是网络名称、长度和密码的十六进制值还是纯 ASCII?

然后,根据我收集的信息,收到的 160 位摘要将直接输入另一轮哈希,无需任何额外的加盐。像这样: SHA1(“上一轮哈希的 160 位摘要”) 上升并重复。

2) 一旦发生这种情况,输出的 4096 次 256 位将用作成对主密钥。我不明白的是,如果 SHA1 产生 160 位输出,那么该算法如何得出密钥所需的 256 位?

感谢您的帮助。

To generate a valid pairwise master key for a WPA2 network a router uses the PBKDF2-HMAC-SHA1 algorithm. I understand that the sha1 function is performed 4096 times to derive the PMK, however I have two questions about the process.

Excuse the pseudo code.

1) How is the input to the first instance of the SHA1 function formatted?
SHA1("network_name"+"network_name_length"+"network_password")

Is it formatted in that order, is it the hex value of the network name, length and password or straight ASCII?

Then from what I gather the 160 bit digest received is fed straight into another round of hashing without any additional salting. Like this: SHA1("160bit digest from last round of hashing") Rise and repeat.

2) Once this occurs 4096 times 256 bits of the output is used as the pairwise master key. What I don't understand is that if SHA1 produces 160bit output, how does the algorithm arrive at the 256bits required for a key?

Thanks for the help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怪我闹别瞎闹 2024-09-01 17:15:15

是的,没错,为 WPA 网络生成二进制密钥的算法是:

key = PBKDF2(passphrase, ssid, 4096, 256)

PBKDF2 在 http://www.ietf.org/rfc/rfc2898.txt

它使用 HMAC 算法创建输入的摘要。 HMAC 可以使用任何哈希函数,正如您提到的,这里规范要求使用 SHA1。哈希是在 HMAC 算法内的中间状态上完成的:

H(K XOR opad, H(K XOR ipad, text))

(H=所选的哈希函数,K 是密码,文本为 ssid)

PBKDF2 重复此 HMAC 过程 4096 次。

HMAC算法: http://www.ietf.org/rfc/rfc2104

这里有一个源示例派生密钥:

https://www. codeblog.org/viewsrc/openssl-engine-0.9.6a/crypto/evp/p5_crpt2.c

int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
   80:                            unsigned char *salt, int saltlen, int iter,
   81:                            int keylen, unsigned char *out)

salt 是 SSID,pass 是密码。

yeah thats right, the algorithm to generate a binary key for a WPA network is:

key = PBKDF2(passphrase, ssid, 4096, 256)

PBKDF2 is described in http://www.ietf.org/rfc/rfc2898.txt

It uses the HMAC algorithm to create a digest of the input. HMAC can use any hash function, here the spec calls for SHA1 as you mentioned. The hash is done on an intermediate state within the HMAC algorithm:

H(K XOR opad, H(K XOR ipad, text))

(H=the chosen hash function, K is the passphrase, text would be ssid)

This HMAC process is repeated 4096 times by PBKDF2.

HMAC algorithm: http://www.ietf.org/rfc/rfc2104

There's a source example here of deriving a key:

https://www.codeblog.org/viewsrc/openssl-engine-0.9.6a/crypto/evp/p5_crpt2.c

int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
   80:                            unsigned char *salt, int saltlen, int iter,
   81:                            int keylen, unsigned char *out)

salt is the SSID, pass is the password.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文