0
$\begingroup$

In Wikipedia pseudo code of SHA-512 the padding section says pad 1 bit then 0 bits. It then goes on to say append length without 1 or 0 padding. What does that mean?

https://en.wikipedia.org/wiki/SHA-2#Pseudocode

append length of message (without the '1' bit or padding), in bits, as 64-bit big-endian integer

The appending of message length in sha-2 as a 64 bit integer without 1 and 0 padding is a bit confusing. How is it different from SHA-1?

$\endgroup$
3
  • $\begingroup$ it means don't also pad the length like you pad the message, with a "1" at the end $\endgroup$ Commented Feb 16, 2017 at 8:24
  • $\begingroup$ Related: SHA256: Padding a 512 bits length message $\endgroup$ Commented Feb 16, 2017 at 9:46
  • 2
    $\begingroup$ That remark tells you that you should not consider the padding when computing the length. $\endgroup$ Commented Feb 16, 2017 at 9:48

1 Answer 1

1
$\begingroup$

Richie is of course correct; the padding needs to be done to form a final block that can also contain the length. As the length encoding is itself static in size, there is no need to pad the length itself.

This is the same as SHA-1 except that the size of the various elements (block size, length encoding) differs.

$\endgroup$
1
  • 4
    $\begingroup$ Note: SHA-512 use a 128-bit field for the length, when SHA-256 and SHA-1 use a 64-bit field for the length. $\endgroup$
    – fgrieu
    Commented Feb 16, 2017 at 9:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.