0

In the NIST documentation for the Secure Hash Standard, it says to pad every message by appending the bit "1" to the end of the message, followed by k zero bits, where k is equal to the equation l (length of message in bits) + 1 + k = 448 mod 512. Then, it says to append a 64-bit block that is equal to the length expressed using a binary representation. The padded message should be a multiple of 512 bits. However, it does not seem to indicate how this would work for a message that is 512 bits or larger. My guess is that the equation above would be equal to the nearest multiple of 512 greater than the length minus 64. For example, for a message of 550 bits, k would be equal to 410. Am I right?

Patriot
  • 3,162
  • 3
  • 20
  • 66

1 Answers1

2

You're close; for a message of 550 bits, k=409; remember, k doesn't include the fixed 1 bit that you initially append.

In general, $k=512i + 447 - m$, where $m$ is the length of the message (in bits), and $i$ is the integer value that yields $0 \le k < 512$. In your example, $m=550$, and $i=1$; this gives us $k=512\times 1 + 447 - 550$

poncho
  • 154,064
  • 12
  • 239
  • 382