SHA256 安全问题
某些字符串 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
myOwnString+STR
将是与STR
完全不同的字符串 - 因此,这两个将具有完全不同的哈希值;看看那些散列的结果,您无法猜测它们是您的散列函数应用于STR
和基于STR
的内容的结果。这正是我们通常建议在对密码进行哈希处理时使用盐的原因 - 请参阅 盐 (密码学),关于这一点。
myOwnString+STR
would be a totally different string thanSTR
-- 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 toSTR
and something based onSTR
.That's precisely why we generally recommend using a salt when hashing passwords -- see Salt (cryptography), about that.
您所描述的是评估哈希函数的“雪崩特性”;如果你稍微改变输入,输出会改变多少?任何像样的散列函数都应该能够彻底改变结果,即使输入只改变一位。这就是为什么像盐和随机数这样的东西工作得很好,因为向初始字符串添加几个字节(它本身可能很弱,很短或可预测,就像密码一样),将哈希结果更改为完全不同且与原始字符串无关的结果。
更直接地回答你的问题:
以及
所以,是的,它被削弱了,但还远没有无用。我还没有发现任何专门针对处理输入长度扩展的攻击。
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:
and
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.