RFC 3174 (SHA-1) 中指定的十六进制数字的含义
我正在尝试了解 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它们是“没什么秘密”。
所选值没有特殊属性。 这些数字与随机选择的值具有相同的属性,但不允许算法设计者选择它们。 选择常量的算法设计者可能允许他嵌入某种后门,因此它们的选择方式会尽可能降低自由度。
典型的选择包括 pi 的第一个数字,或者在 SHA-1 小素数的平方根的情况下:
来自维基百科: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:
From Wikipedia: SHA-1
为了避免过于冗长的答案,它们只是特定于算法的常量。 作为类似用法的示例,请参阅 卡马克平方根。 它使用特殊值作为通过提供初始朴素猜测来加速传统平方根方法的一种方式。
正如代码所暗示的,它们只是帮助充当中间哈希元素的数字。 他们
不一定具有任何含义,正如您可能暗示的数学常数,但它们对算法很重要。
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.
它没有回答您的问题,但请注意对 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.