I am trying to understand SHA2 - 512 algorithm, so I am following this document which has the intermediate values for the string "abc". At t=0
, the values for f
, h
and g
are straightforward. But I am not getting the same value for e
, which suggests that I am doing something wrong when I am computing $T_1 = h + \Sigma_1(e) + \text{Ch}(e,f,g) + K_i + W_i$. I am almost sure that I have implemented $\text{Ch( )}$ and $\Sigma_1 ( )$ correctly. I guess my issue might be with the addition over $\pmod {2^{64}}$. I understand each term in summation of $T_1$ is a 64-bit number. So I assume we can convert these numbers to integers and add them up over $\pmod {2^{64}}$. Now the resulting number may not be 64-bit long in binary. Do we add $0$'s in front of behind the binary representation to make it 64-bit long?
I am not sure if this is helpful, but here are a few values I am getting in binary for t=0
(for now I am adding zeros to the left of the most significant bit):
#Sigma_1(e)
0101000100001110010100100111111110101101111001101000001011010001
#Ch(e,f,g)
0001111110000101110010011000110001111011001001110011110100111011
#T_1
0110100101100101001100111001100011001110110101111110100010100000
#e <- T_1 + d
0000111010110101001010001101001100101101111101010001111110010001
whereas according to the document, e
in binary is 1100001111010100111010111111110101001000011001010000111111111010
.
If you can provide a resource that includes the intermediate values for these other functions, I hope I can figure it out. Otherwise, it would be much appreciated if you could give a detailed explanation for how to get the correct value. Please let me know if you would like me to include more information.