5
$\begingroup$

Does length-prepending stop length-extension attacks on Merkle-Damgård hash functions, assuming that the length is checked?

$\endgroup$
5
$\begingroup$

Yes, if the length is formatted in a constant-size value (e.g. 64-bit field) or in an otherwise uniquely decodable manner.

With such a length field, no hash input can be the the prefix of another valid input. Thus there is no length-extension attack.

(Assumptions include that you reveal no intermediate values, of course.)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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