SHA256 安全问题

发布于 2024-11-01 09:31:25 字数 203 浏览 5 评论 0原文

某些字符串 STR 的结果是:

SHA256(STR)=3f7c54571faee024e3fd68603c5c95f6a4c8ef73a398840b974f3f57737a116f 

是否可以获得 SHA256(myOwnString+STR) 的结果? (“+”用作连接)

此场景是否有任何已知的攻击?

Having that the result for some string STR was:

SHA256(STR)=3f7c54571faee024e3fd68603c5c95f6a4c8ef73a398840b974f3f57737a116f 

Would it be possible to get the result of SHA256(myOwnString+STR)? ('+' is used as concatenation)

Are there any known attacks for this scenario?

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

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

发布评论

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

评论(2

弄潮 2024-11-08 09:31:25

myOwnString+STR 将是与 STR 完全不同的字符串 - 因此,这两个将具有完全不同的哈希值;看看那些散列的结果,您无法猜测它们是您的散列函数应用于 STR 和基于 STR 的内容的结果。

这正是我们通常建议在对密码进行哈希处理时使用盐的原因 - 请参阅 盐 (密码学),关于这一点。

myOwnString+STR would be a totally different string than STR -- so, those two would have totally different hashes ; and looking at those hashed, you'd have no way of guessing they result of your hashing function being applied to STR and something based on STR.

That's precisely why we generally recommend using a salt when hashing passwords -- see Salt (cryptography), about that.

你的背包 2024-11-08 09:31:25

您所描述的是评估哈希函数的“雪崩特性”;如果你稍微改变输入,输出会改变多少?任何像样的散列函数都应该能够彻底改变结果,即使输入只改变一位。这就是为什么像盐和随机数这样的东西工作得很好,因为向初始字符串添加几个字节(它本身可能很弱,很短或可预测,就像密码一样),将哈希结果更改为完全不同且与原始字符串无关的结果。

更直接地回答你的问题:

2008 年的一次攻击破坏了原像
80 轮中的 46 轮的阻力
SHA-512,以及 64 轮中的 41 轮
SHA-256。[1]碰撞攻击
SHA-256 最多 24 个步骤

以及

有两种针对 SHA-2 的中间相遇原像攻击,其轮数有所减少。第一个攻击 64 轮中的 41 轮 SHA-256,时间复杂度为 2253.5,空间复杂度为 216,攻击 80 轮中的 46 轮 SHA-512,时间复杂度为 2511.5,空间复杂度为 23。第二个攻击 42 轮SHA-256,时间复杂度为2251.7,空间复杂度为212,42轮SHA-512,时间复杂度为2502,空间复杂度为222。

所以,是的,它被削弱了,但还远没有无用。我还没有发现任何专门针对处理输入长度扩展的攻击。

What you're describing is evaluating hash function's 'avalanche property'; if you change the input just a little bit, how much does the output change? Any decent hashing function should be able to completely mangle the result drastically even if the input changes just one bit. This is why things like salts and nonces work well, because adding few bytes to the initial string (which by itself might be weak, short or predictable, like passwords), changes the result of the hash to something completely different and unrelated to the original.

to answer your question more directly tho:

A 2008 attack breaks preimage
resistance for 46 out of 80 rounds of
SHA-512, and 41 out of 64 rounds of
SHA-256.[1] Collision attacks against
up to 24 steps of SHA-256

and

There are two meet-in-the-middle preimage attacks against SHA-2 with a reduced number of rounds. The first one attacks 41-round SHA-256 out of 64 rounds with time complexity of 2253.5 and space complexity of 216, and 46-round SHA-512 out of 80 rounds with time 2511.5 and space 23. The second one attacks 42-round SHA-256 with time complexity of 2251.7 and space complexity of 212, and 42-round SHA-512 with time 2502 and space 222.

So yes, it's weakened, but it's nowhere near useless yet. And I haven't found any attacks specific to dealing with input length extension.

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