I was trying to implement a SHA1 algorithm last night, and I got stuck at preprocessing the chunks in SHA1.
As I have understood it, the message that has to be hashed, has to be broken into chunks of 512 bits, and if the last chunk is not equal to 512 bits, a
1 is appended to the bits, followed by '0', and at the end the number of bits of the last chunk of message is appended. So an example:
abc = 97 98 99 abc = 01100001 01100010 01100011 chunk = 0110000101100010011000111... ( 482 x 0) ...11000
But what would happen if the last chunk is 504 bits? Then 9 bits
(2^9 = 512), should be used to describe the length of the message, but that does not fit, because there are only
512 - 504 - 1 = 7 bits left to describe the length.