Heading
\begin{array}{l|rrrl|rrrl}
\text{hash} & d&r&\mu&\text{(bits)}&\tilde d&\tilde r&\tilde
\mu&\text{(bytes)}\\
\hline
\operatorname{MD5} & 128 & 512 & 65 && 16 & 64 & 9 \\
\operatorname{SHA-1} & 160 & 512 & 65 && 20 & 64 & 9 \\
\operatorname{RIPEMD-160} & 160 & 512 & 65 && 20 & 64 & 9 \\
\operatorname{SHA-224} & 224 & 512 & 65 && 28 & 64 & 9 \\
\operatorname{SHA-256} & 256 & 512 & 65 && 32 & 64 & 9 \\
\hline
\operatorname{SHA-512/224}& 224 & 1024 & 129 && 28 & 128 & 17 \\
\operatorname{SHA-512/256}& 256 & 1024 & 129 && 32 & 128 & 17 \\
\operatorname{SHA-384} & 384 & 1024 & 129 && 48 & 128 & 17 \\
\operatorname{SHA-512} & 512 & 1024 & 129 && 64 & 128 & 17 \\
\hline
\operatorname{SHA3-224} & 224 & 1152 & 4 && 28 & 144 & 1 \\
\operatorname{SHA3-256} & 256 & 1088 & 4 && 32 & 136 & 1 \\
\operatorname{SHA3-384} & 384 & 832 & 4 && 48 & 104 & 1 \\
\operatorname{SHA3-512} & 512 & 576 & 4 && 54 & 72 & 1 \\
\hline
\operatorname{SHAKE-128} & d & 1344 & 6 && \lceil d/8 \rceil & 168 & 1 \\
\operatorname{SHAKE-256} & d & 1088 & 6 && \lceil d/8 \rceil & 136 & 1 \\
\hline
\operatorname{BLAKE2s-256} & 256 & 512 & 0 && 32 & 64 & 0 \\
\operatorname{BLAKE2b-512} & 512 & 1024 & 0 && 64 & 128 & 0 \\
\end{array}
SHA3-x
SHA3-x is defined with KECCAK as;
- $\operatorname{SHA3-224}(M) = \operatorname{KECCAK}[448] (M \mathbin\| 01, 224)$
- $\operatorname{SHA3-256}(M) = \operatorname{KECCAK}[512] (M \mathbin\| 01, 256)$
- $\operatorname{SHA3-384}(M) = \operatorname{KECCAK}[768] (M \mathbin\| 01, 384)$
- $\operatorname{SHA3-512}(M) = \operatorname{KECCAK}[1024](M \mathbin\| 01, 512)$
KECCAK
and KECCAK defined as
- $\operatorname{KECCAK}[c] (N, d) = \operatorname{SPONGE}[\operatorname{KECCAK-p}[1600, 24], \operatorname{pad10*1}, 1600–c] (N, d)$
and note that $N = M\mathbin\|01$ and $d$ is the required output size, Now we have
- $\operatorname{SHA3-224}(M) = \operatorname{SPONGE}[\operatorname{KECCAK-p}[1600, 24], \operatorname{pad10*1}, 1600–448] (N, 224)$
- $\operatorname{SHA3-256}(M) = \operatorname{SPONGE}[\operatorname{KECCAK-p}[1600, 24], \operatorname{pad10*1}, 1600–512] (N, 256)$
- $\operatorname{SHA3-384}(M) = \operatorname{SPONGE}[\operatorname{KECCAK-p}[1600, 24], \operatorname{pad10*1}, 1600–768] (N, 384)$
- $\operatorname{SHA3-512}(M) = \operatorname{SPONGE}[\operatorname{KECCAK-p}[1600, 24], \operatorname{pad10*1}, 1600–1024] (N, 512)$
Padding
- $\operatorname{pad10*1}(x, m)$ is not important since the message is not formed yet.
SPONGE
As we can see, we can precompute a message $M$ up to the maximum multiple of $r$ that is smaller than $\operatorname{len}(M)$. More mathematically $$\operatorname{precomputableLen} = \lfloor(\operatorname{len}(M)/r)\rfloor \cdot r.$$ And the $r$ for
- $\operatorname{SHA3-224}(M)$ is $r = 1152$
- $\operatorname{SHA3-256}(M)$ is $r = 1088$
- $\operatorname{SHA3-384}(M)$ is $r = 832$
- $\operatorname{SHA3-512}(M)$ is $r = 576$
and the formula
$$\text{rounds}=\left\lfloor\frac{m_0}r\right\rfloor+\nu\left\lceil\frac{\left(m_0\bmod r\right)+m_1+\mu }r\right\rceil$$
SHAKE128 and SHAKE256
- $\operatorname{SHAKE128}(M, d) = \operatorname{KECCAK}[256] (M \mathbin\| 1111, d)$
- $\operatorname{SHAKE256}(M, d) = \operatorname{KECCAK}[512] (M \mathbin\| 1111, d)$
As we can see the main difference is the capacity and extra two bits appended to have the domain separation.
- $\operatorname{SHAKE128}(M, d)$ is $r =1344$
- $\operatorname{SHAKE256}(M, d)$ is $r =1088$
and the formula
$$\text{rounds}= \underbrace{\left\lfloor\frac{m_0}{r}\right\rfloor + \nu\left\lceil\frac{\left(m_0\bmod r\right)+m_1+\mu}r\right\rceil}_{\text{Absorbing part}} + \underbrace{\nu \left\lceil \frac{d}{r} -1 \right\rceil }_{\text{Squeezing part}}$$
BLAKE2b and BLAKE2s
BLAKE2 uses modified ChaCha as compression function with 16 words. BLAKE2s is the 32-bit version so $r=512$ here, and for BLAKE2b $r = 1024$ ( $s$ for small, $b$ for big).
and the formula
$$\text{rounds}=\left\lfloor\frac{m_0}r\right\rfloor+\nu\left\lceil\frac{\left(m_0\bmod r\right)+m_1+\mu } r\right\rceil$$
since BLAKE2 uses all-zero padding, they called it minimal padding.