两个非常基本的问题:
示例:
- Mallory creates two different documents A and B, that have an
identical hash value (collision).
- Mallory then sends document A to Alice, who agrees to what the
document says, signs its hash and sends it back to Mallory.
- Mallory copies the signature sent by Alice from document A to
document B. Then she sends document B to Bob, claiming that Alice
signed the other document (document B).
- Because the digital signature matches the document hash, Bob's
software is unable to detect the modification.
参考资料:http://en.wikipedia.org/wiki/Collision_攻打
哈希函数对于数据签名也是很好的。例如,如果您使用的是HMAC,则可以使用与已知但不是传输的值(秘密值)连接的数据哈希来签名数据。所以你发送纯文本和hmac哈希。然后,接收器简单地用已知值对提交的数据进行散列,并检查它是否与发送的hmac匹配。如果是一样的话,你知道它没有被一个没有秘密价值的人篡改。这通常用于HTTP框架的安全cookie系统中,以及在您希望数据具有一定有效性的HTTP上进行数据的消息传输。
我不明白为什么这段代码产生的颜色比第二段要少,当您与两个输入发生冲突时,如何帮助为下一个递归循环追加相同的两个值?
不建议:
hash = sha512(password + salt);
for (i = 0; i < 1000; i++) {
hash = sha512(hash); // <-- Do NOT do this!
}
推荐:
hash = sha512(password + salt);
for (i = 0; i < 1000; i++) {
hash = sha512(hash + password + salt);
}
我读了五遍这部分,虽然有点道理,但我很难完全理解它。
现在,hash1的碰撞概率为0.001%。但是,当我们执行下一个hash2 = sha1( hash1 );时,hash1的所有冲突都会自动变成hash2的冲突。所以现在,我们有0.001%的哈希1‘S率,第二次sha1呼叫增加了这一点。
发布于 2015-02-13 17:52:42
对问题2的答复:
算法1:将算法改为此算法,将更容易解释。
hash1 = sha512(password + salt1);
hash2 = sha512(password + salt2);
for (i = 0; i < 1000; i++) {
hash1 = sha512(hash1); // <-- Do NOT do this!
hash2 = sha512(hash2); // <-- Do NOT do this!
}
对于两个不同的输入( hash1和hash2 ),如果迭代10上有冲突,那么接下来的990次迭代将处理相同的工作,并输出相同的hash1和hash2。
哈希越多,在迭代12、15、20、100、101、314中创建的中间冲突就越多.每增加一次迭代,就会增加碰撞的概率。
如果Bob运行此代码(前一个循环的一半)
hash1 = sha512(password + salt1);
for (i = 0; i < 1000; i++) {
hash1 = sha512(hash1); // <-- Do NOT do this!
}
如果Alice运行此代码(前一个循环的一半)
hash2 = sha512(password + salt2);
for (i = 0; i < 1000; i++) {
hash2 = sha512(hash2); // <-- Do NOT do this!
}
与之前的评论相比,安全性降低了,因为Bob和Alice可以相互模仿,因为碰撞的概率增加了。当算法完成后
P(hash1 == hash2) > 1000 * P(sha512(password + salt2) == sha512(password + salt1) )
如果有超过鲍勃和爱丽丝,约翰,乔,杰克和杰里米运行这个循环,那么碰撞的概率仍然增加了破坏性的影响“生日悖论”。
算法2:每一次迭代都有不同的地方,这是很大的区别。
hash1 = sha512(password + salt1);
hash2 = sha512(password + salt2);
for (i = 0; i < 1000; i++) {
hash1 = sha512(hash + password + salt1);
hash2 = sha512(hash + password + salt2);
}
如果迭代i有冲突,那么下一个迭代i+1更有可能产生非冲突。当提供不同的输入时,每一次迭代都具有非常低的sha512碰撞概率。当算法完成时,Bob和Alice将算法拆分
P(hash1 == hash2) == P( sha512(password + salt2) == sha512(password + salt1) )
注意:可能在每次迭代时都有不同的salt值,正如引用的页面所建议的那样。
https://crypto.stackexchange.com/questions/22932
复制相似问题