SHA-512 (source code)
= SHA-512
{c}
{title2=$H(m)\in\{0,1\}^{512}$}
\b[SHA-512] is a <SHA-2> <cryptographic hash function> with a 512-bit digest. It processes 1024-bit message blocks through eighty rounds using eight 64-bit state words and additions modulo $2^{64}$. Its message-length field is 128 bits.<Secure Hash Standard by National Institute of Standards and Technology>[§§5.1.2–5.3.5 and §6.4]{ref}
For bit length $\ell<2^{128}$, padding appends one bit and $k$ zero bits so that
$$
\ell+1+k\equiv896\pmod{1024},
$$
then appends the 128-bit original length. The <hash initialization vector> is fixed by the algorithm; it is not a fresh secret for each message. The padded blocks update the state in order, and the final eight words form the digest.
For a computed example, hash the three ASCII bytes `61 62 63`. Here $\ell=24$, so $k=871$ and $24+1+871+128=1024$. One padded 128-byte block is processed. Its digest, in <hexadecimal>, is
`ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f`.
The 128 hexadecimal digits represent 64 bytes. They do not represent the 128-byte padded input. For another padding-count example, 111 input bytes fit into one padded block, while 112 input bytes require two; the digest remains 64 bytes in either case.
<SHA-384>, <SHA-512 224> and <SHA-512 256> reuse the SHA-512 compression structure but have specified different initial states and output rules. Taking a prefix of an ordinary SHA-512 digest therefore does not implement those algorithms. A <cryptographic test vector> must identify the exact hash, input encoding and expected output rather than only a digest length.
Back to article page