I'm really confused about the computation about SHA 256.

$$W_t = \begin{cases} M_t^{(i)} & 0 \leq t \leq 15 \\ &\\ \sigma_1^{256}(W_{t-2}) + W_{t-7} + \sigma_0^{256}(W_{t-15}) + W_{t-16} & 16 \leq t \leq 63 \end{cases}$$

The $W_t$ variable: What's the value of $W_t$? How do I get that value?

I'm still confused because of the explanation using the English language. I'm a beginner guys, any help from you will be a plus point for me about hashing.


1 Answer 1


It is in SHA-256 message schedule (NIST-FIPS 180-4);

The message $M$ with length $l$ is first padded as the usual way;

  • append 1 to the end of the message,
  • then, add $k$ zero bits such that $$l+1+k \equiv 448 \mod 512$$
  • finally, add the length of the message in 64-bit. Now, the total padded length is divisible by 512.

After padding, the padded message parsed into $M^{1},\ldots,M^{N}$ where each has size 512-bit.

The sub index $t$ represents 32-bits in 512 bits. Thus, The $M_t^{(i)}$ is the $t$-th 32-bit in the $M^{(i)}$ for $0 \leq t \leq 15$

The $W_t$ is defined as your equation;

$$W_t = \begin{cases} M_t^{(i)} & 0 \leq t \leq 15 \\ &\\ \sigma_1^{256}(W_{t-2}) + W_{t-7} + \sigma_0^{256}(W_{t-15}) + W_{t-16} & 16 \leq t \leq 63 \end{cases}$$

Where $$\sigma_1^{256}(x) = \operatorname{ROTR}^{17}(x) \oplus \operatorname{ROTR}^{19}(x) \oplus \operatorname{SHR^{10}(x)}$$ $$\sigma_0^{256}(x) = \operatorname{ROTR}^{7}(x) \oplus \operatorname{ROTR}^{18}(x) \oplus \operatorname{SHR^{3}(x)}$$

$\sigma_1^{256}(x)$ and $\sigma_0^{256}(x)$ operate on 32 bits and produce 32 bits.

Note: the 256 above the $\sigma$ represents the 256 in SHA-256. Similarly, there is $\sigma_0^{512}(x)$ and $\sigma_1^{512}(x)$ for SHA-512.

  • $\begingroup$ so you mean Wt = M16.....Mn ? $\endgroup$
    – Onta Ss
    Mar 8, 2019 at 10:44
  • 1
    $\begingroup$ No. $W_1 = M_1^{(i)}, W_2 = M_2^{(i)}, \ldots, W_{15} = M_{15}^{(i)}$ $\endgroup$
    – kelalaka
    Mar 8, 2019 at 11:00
  • $\begingroup$ @OntaSs there is no $M_{16}$, the 16 words of the input block are numbered 0 to 15 only $\endgroup$ Mar 9, 2019 at 0:50
  • $\begingroup$ @kelalaka Wt = M1 u mean (Wt-2) = (M1-2) ? sorry bro i learn self-taught about this. i got little confused if read mathematic formulas $\endgroup$
    – Onta Ss
    Mar 9, 2019 at 2:25
  • $\begingroup$ @RichieFrame yeah i got it. How about W16....W63 ? what is the value ? $\endgroup$
    – Onta Ss
    Mar 9, 2019 at 3:27

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.