2

In preparing an input for SHA256 or RIPEMD-160 a single bit (1) is appended to the message before adding any necessary zero padding and before adding the bitlength (64 bits) to form 1 or more 512 bit blocks. What is the purpose of adding the single bit (1)?

JohnGalt
  • 546
  • 4
  • 10

1 Answers1

1

If you look at the Wikipedia on padding article page, you will see many different ideas.

The main problem when designing a padding, firstly, one has to consider how to eliminate the padding correctly, all the time. It is the designer's choice, as noted in and the original RFC 4634 -- SHA and HMAC-SHA.

Once you put 1 followed by many 000 to the end of a string, you can remove the padding by looking the first position of a single 1 from the end. That was the simplest idea for padding, AFAIK.

When considering that hashes only supply integrity, If finding a collusion is easy with this (or any) padding than the hash is already failed there.

kelalaka
  • 49,797
  • 12
  • 123
  • 211