Will Hashing Multiple Times Be More, Less, Or Similarly Secure As Hashing Once?
Flushing out this question:
- I saw this claim:
- List item:
Don't do this: hash = sha512(password + salt); for (i = 0; i < 1000; i++) { hash = sha512(hash); // <-- Do NOT do this! }
however if you are going to double hash then do thishash = sha512(password + salt); for (i = 0; i < 1000; i++) { hash = sha512(hash + password + salt); }
- See: https://stackoverflow.com/questions/4948322/fundamental-difference-between-hashing-and-encryption-algorithms/4948393#4948393
- List item:
- To me, it would appear that what you are attempting to do in rehashing is to slow down a brute force attack.
- Although the birthday problem could apply to multiple hashing, it seems it would equally apply to the first example (which the person labeled as "don't do this"), as to the second example (which the person felt more comfortable with).
- In either example, once the collision is found, then rehashing at that point is moot (since it will reproduce the same results between the hash and its collision).
- The specific scenario for this question is: is the person's example's that I have given in my question above correct in their assertion - that example 2 will make collisions, probability speaking, happen less often?
What I am looking for in an answer:
- This is not my field of expertise (which is why I am asking it here, where it is your expertise). Please feel free to correct my misunderstandings and problematic assumptions.
- I am interested in both a detailed technical explanation as long as it is accompanied by a layman's explanation of the steps and particularly the conclusion (with the emphasis being on the layman's explanation).
- I am asking theoretically of all one way hashing functions (if there are distinctions between broad classes of hashing algorithms, please feel free to generally point those out while understanding that the implications of your answer would practically be applied on my part toward a hashing algorithm similar to SHA-2, SHA-3, or bcrypt).
- I have looked through 10 different crypto.stackexchange.com questions and answers that would seem very similar to this question, but either they dealt with specific use cases that shaped the answer to the use case, or they gave a theoretical proof without explaining in layman's terms what their proof was actually doing and a layman's conclusion to their answer.
- For the purposes of this question, assume my calculus is not up to par, nor am I generally read on the mathematical variables being used in cryptography, but assume that I can follow algebra and can dust off my calculus if you tell me what the variables stand for (or links to their explanations).
Thank you in advance for your help with this question.