Skip to main content
added 8 characters in body
Source Link
Peter Green
  • 1.6k
  • 1
  • 11
  • 16

It depends on how exactly the hash function is defined.

Typically the first step of a hashing function is to convert the input from a series of bits or bytes to a series of blocks using a padding scheme. Many such padding schemes include the length of the input in the padding as it makes the security arguments easier. Typically the length is encoded as a fixed-size integer.

So the question becomes what happens when the range of that fixed size integer is exceeded. There are two main possibilities.

  • The integer is allowed to wrap around (this seems to be the case for MD5)
  • The hash function is only defined for messages shorter than a threshold (this seems to be the case for SHA1 and SHA2)

However you are likely to find this is a case where practical implementations of the algorithm don't enforce the specification. For example the first result for "sha1 reference implementation" I found on on google ( https://github.com/clibs/sha1/blob/master/sha1.c ) did not enforce any limit on input size.

It depends on how exactly the hash function is defined.

Typically the first step of a hashing function is to convert the input from a series of bytes to a series of blocks using a padding scheme. Many such padding schemes include the length of the input in the padding as it makes the security arguments easier. Typically the length is encoded as a fixed-size integer.

So the question becomes what happens when the range of that fixed size integer is exceeded. There are two main possibilities.

  • The integer is allowed to wrap around (this seems to be the case for MD5)
  • The hash function is only defined for messages shorter than a threshold (this seems to be the case for SHA1 and SHA2)

However you are likely to find this is a case where practical implementations of the algorithm don't enforce the specification. For example the first result for "sha1 reference implementation" I found on on google ( https://github.com/clibs/sha1/blob/master/sha1.c ) did not enforce any limit on input size.

It depends on how exactly the hash function is defined.

Typically the first step of a hashing function is to convert the input from a series of bits or bytes to a series of blocks using a padding scheme. Many such padding schemes include the length of the input in the padding as it makes the security arguments easier. Typically the length is encoded as a fixed-size integer.

So the question becomes what happens when the range of that fixed size integer is exceeded. There are two main possibilities.

  • The integer is allowed to wrap around (this seems to be the case for MD5)
  • The hash function is only defined for messages shorter than a threshold (this seems to be the case for SHA1 and SHA2)

However you are likely to find this is a case where practical implementations of the algorithm don't enforce the specification. For example the first result for "sha1 reference implementation" I found on on google ( https://github.com/clibs/sha1/blob/master/sha1.c ) did not enforce any limit on input size.

Source Link
Peter Green
  • 1.6k
  • 1
  • 11
  • 16

It depends on how exactly the hash function is defined.

Typically the first step of a hashing function is to convert the input from a series of bytes to a series of blocks using a padding scheme. Many such padding schemes include the length of the input in the padding as it makes the security arguments easier. Typically the length is encoded as a fixed-size integer.

So the question becomes what happens when the range of that fixed size integer is exceeded. There are two main possibilities.

  • The integer is allowed to wrap around (this seems to be the case for MD5)
  • The hash function is only defined for messages shorter than a threshold (this seems to be the case for SHA1 and SHA2)

However you are likely to find this is a case where practical implementations of the algorithm don't enforce the specification. For example the first result for "sha1 reference implementation" I found on on google ( https://github.com/clibs/sha1/blob/master/sha1.c ) did not enforce any limit on input size.