I’m trying to understand the internal mechanism used in the SHA-1 hash function. I’m also referring to the FIPS-180 standard.
Managed to write an implementation is able to return accurate results hashing a string “abc”. However I’m still blunt how to interpret strings >= 56 bytes. The FIPS-180 standard specifies to use 1024bit for a string size of 56 bytes.
Sha1 operates on messages with block size of 512bits (64 bytes).
What happens if you have a message of length 104 bytes? First you need to pad the message in order to be able to operate on blocks of size 512bits.
You take the incomplete last block of 104 – 64 = 40 bytes, and go through the message padding phase that is described in fips-180 in order to get a block size of 512bits (64bytes), and perform the message digest calculation.
The padding phase (taken from wiki) is: