4
$\begingroup$

I have an hash function hash()

I can easily compute the hash of the string "hello" like this:

out = hash("hello"); 

What are the implications from a security point of view of hashing the same string as:

out = IV;
out = hash('h' + out);
out = hash('e' + out);
out = hash('l' + out);
out = hash('l' + out);
out = hash('o' + out);

I mean hashing single bytes one after another, concatenating the current byte with the previous hash (first hash could be all zeros or some IV).

I know I'll get a completely different hash. Apart from that, what are the security implications of such habit?

$\endgroup$
3
  • $\begingroup$ shall I ask Bruce Schneier about that? :-) $\endgroup$ Commented Aug 10, 2016 at 13:03
  • $\begingroup$ Give the question more than 1/2 hour for reactions ;) Chances are this will be really slow compared to standard hashing and won't win you anything in terms of security. I don't know though if it actually breaks anything (it shouldn't). $\endgroup$
    – SEJPM
    Commented Aug 10, 2016 at 13:13
  • 4
    $\begingroup$ It introduces a length-extension attack into hashes that don't suffer from it. But that doesn't matter for password hashes. $\endgroup$ Commented Aug 10, 2016 at 13:30

1 Answer 1

1
$\begingroup$

In terms of a hash scheme, the security of your construction can be proven secure in the same way that the Merkel-Damgard construction is. One subtlety is that you need to add a final invocation to "hash()" to make sure you don't suffer from a length extension attack as @codeinchaos mentioned.

With regard to the technique to store password, it is not recommended to have a constant IV but rather choose some random IV for every entry in your password table. This is for the reason that whenever someone breaks into your system then she could see immediately the entries that store the same password. This technique is called "salting".

$\endgroup$
1
  • $\begingroup$ +1 for the final hash(). Of course it's better with salting. I was arguing if the security level is lower from the equivalent non-salted hash("hello"); $\endgroup$ Commented Aug 11, 2016 at 10:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.