RFC 3174 (SHA-1) 中指定的十六进制数字的含义

发布于 2024-07-17 12:17:13 字数 544 浏览 5 评论 0 原文

我正在尝试了解 SHA-1,我正在查看规范(RFC 31741)中包含的 C 实现,这部分让我感到困惑:

context->Intermediate_Hash[0] = 0x67452301; 
  上下文->Intermediate_Hash[1] = 0xEFCDAB89; 
  上下文->Intermediate_Hash[2] = 0x98BADCFE; 
  上下文->Intermediate_Hash[3] = 0x10325476; 
  上下文->Intermediate_Hash[4] = 0xC3D2E1F0; 
  

这些硬编码的十六进制值有什么意义,它们只是使算法起作用的特殊调味料,还是代表一些数学常数?

您可以在此处查看完整代码:http://www.faqs.org/rfcs/rfc3174。 html

I'm trying to learn about SHA-1, I was looking at the C implementation that was included in the specification (RFC 31741) and this part confuses me:

context->Intermediate_Hash[0]   = 0x67452301;
context->Intermediate_Hash[1]   = 0xEFCDAB89;
context->Intermediate_Hash[2]   = 0x98BADCFE;
context->Intermediate_Hash[3]   = 0x10325476;
context->Intermediate_Hash[4]   = 0xC3D2E1F0;

What are the significance of those hard coded hex values, are they just special sauce that makes the algorithm work, or do they represent some mathematical constants?

You can view the full code here: http://www.faqs.org/rfcs/rfc3174.html

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

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

发布评论

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

评论(3

风向决定发型 2024-07-24 12:17:13

它们是“没什么秘密”

所选值没有特殊属性。 这些数字与随机选择的值具有相同的属性,但不允许算法设计者选择它们。 选择常量的算法设计者可能允许他嵌入某种后门,因此它们的选择方式会尽可能降低自由度。

典型的选择包括 pi 的第一个数字,或者在 SHA-1 小素数的平方根的情况下:

所使用的常数值是根据我的袖子数字选择的:四个舍入常数 k 是 2、3、5 和 10 的平方根的 2^30 倍。 h0 到 h3 的前四个起始值是相同的如MD5算法,与第五种(对于h4)类似。

来自维基百科:SHA-1

They're "nothing up my sleeve numbers".

The chosen value has no special properties. These are numbers have the same properties as randomly chosen values, but don't allow the algorithm designer to choose them. The algorithm designer choosing the constants might allow him to embed some kind of backdoor, so they're chosen in a way that reduces the degrees of freedom as much as possible.

Typical choices include the first digits of pi, or in the case of SHA-1 square-roots of small primes:

The constant values used are chosen as nothing up my sleeve numbers: the four round constants k are 2^30 times the square roots of 2, 3, 5 and 10. The first four starting values for h0 through h3 are the same as the MD5 algorithm, and the fifth (for h4) is similar.

From Wikipedia: SHA-1

山有枢 2024-07-24 12:17:13

为了避免过于冗长的答案,它们只是特定于算法的常量。 作为类似用法的示例,请参阅 卡马克平方根。 它使用特殊值作为通过提供初始朴素猜测来加速传统平方根方法的一种方式。

正如代码所暗示的,它们只是帮助充当中间哈希元素的数字。 他们
不一定具有任何含义,正如您可能暗示的数学常数,但它们对算法很重要。

To save you on an overly verbose answer, they're just constants specific to the algorithm. As an example of a similar usage, refer to the Carmack Square Root. It uses a special value as a way of speeding up traditional methods of square rooting by providing an initial naive guess.

They're just numbers that help out serving as, as implied by the code, intermediate hash elements. They
don't necessarily have any meaning as you may imply as mathematical constants, but they're important to the algorithm.

西瑶 2024-07-24 12:17:13

它没有回答您的问题,但请注意对 SHA-1 的真正引用(如所解释的
在 RFC 中)是 FIPS 180。 没有更多解释,但至少它是原始来源:-(

另外,请记住 SHA-1 是今天的 严重濒危

It does not answer your question but do note that the real reference to SHA-1 (as explained
in the RFC) is FIPS 180. No more explanations there but at least it is the original source :-(

Also, remember that SHA-1 is today seriously endangered.

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