When is it safe to use a broken hash function?

后端 未结 6 2024
太阳男子
太阳男子 2020-12-28 16:38

It is trivial to use a secure hash function like SHA-256, and continuing to use MD5 for security is reckless behavior. However, there are some complexities to hash function

6条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-28 17:18

    When you don't care whether it's safe or not.

    Seriously, it doesn't take any extra effort to use a secure hash function in pretty much every language, and performance impact is negligible, so I don't see why you wouldn't.

    [Edit after actually reading your question]

    According to Schneier a hash function vulnerable to a collsion attack can still be used as an HMAC. I believe this is because the security of an HMAC is Dependant on its secret key and a collision cannot be found until this key is obtained.

    Actually, it's essentially because being able to generate a collision for a hash does not necessarily help you generate a collision for the hash-of-a-hash (combined with the XORing used by HMACs).

    Does it then become safe to use a very weak message digest like md4 for passwords if a salt is perpended to the password?

    No, not if the hash has a preimage attack which allows you to prepend data to the input. For instance, if the hash was H(pass + salt), we'd need a preimage attack which allows us to find pass2 such that H(pass2 + salt) = H(pass + salt).

    There have been append attacks in the past, so I'm sure prepend attacks are possible.

提交回复
热议问题