1
$\begingroup$

What does it mean by a HASH of a message with zero length or rather why is it required? What could be a possible scenario where this is used?

Also note that, for a given HASHing algorithm, the hash value of a zero length message is essentially pre-defined.

$\endgroup$
  • $\begingroup$ No, my question intends to ask something different. I have edited it to make it clearer now. $\endgroup$ – Tarun Mittal Nov 13 at 6:14
  • 1
    $\begingroup$ read the answer in the linked question carefully, it is defined as a nonempty string, so that some properties in Maarten bodewes' answer are satisfied. $\endgroup$ – kodlu Nov 13 at 6:16
  • 1
    $\begingroup$ It still doesn't answer "What could be a possible scenario where this is used?" $\endgroup$ – Tarun Mittal Nov 13 at 6:20
  • $\begingroup$ If you are using a hash module for example, then you can hash an empty string and make sure that the output matches what is says online, to make sure that the hash module is working as it should be $\endgroup$ – SamG101 Nov 13 at 8:09
  • $\begingroup$ @kodlu I myself see it as a related but not identical question, and asking for use cases is something different and allows for a more detailed answer. $\endgroup$ – Maarten - reinstate Monica Nov 13 at 12:37
4
$\begingroup$

The hash of a zero-length message is defined for several reasons:

  • There's no reason not to define it. If (as you assume) it'll never be used, then it doesn't matter whether it's defined and there's no reason to avoid defining it.
  • Having it undefined would create a weird exceptional case that'd need to be handled by anything that uses the hash, just in case it ever happens. Weird exceptions tend to lead to bugs, bugs tend to cause vulnerabilities, and cryptographers hate vulnerabilities and the design choices that cause them.
  • In practice, it will be used. One common use of hashes is to create a fingerprint of the contents of files, and empty (zero-length) files are entirely normal.

As for your point that for a given HASHing algorithm, the hash value of a zero length message is essentially pre-defined: that's true, but it's also true of any other specific message. The hash of "a" is essentially pre-defined, as is the hash of "foo", "This is a message", etc.

$\endgroup$

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