aboutsummaryrefslogtreecommitdiffstats
path: root/src/hash/sha2/sha2_32.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/hash/sha2/sha2_32.cpp')
-rw-r--r--src/hash/sha2/sha2_32.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/hash/sha2/sha2_32.cpp b/src/hash/sha2/sha2_32.cpp
index be2638747..52528e6fd 100644
--- a/src/hash/sha2/sha2_32.cpp
+++ b/src/hash/sha2/sha2_32.cpp
@@ -48,6 +48,10 @@ inline void F1(u32bit A, u32bit B, u32bit C, u32bit& D,
*************************************************/
void SHA_224_256_BASE::compress_n(const byte input[], u32bit blocks)
{
+ u32bit A = digest[0], B = digest[1], C = digest[2],
+ D = digest[3], E = digest[4], F = digest[5],
+ G = digest[6], H = digest[7];
+
for(u32bit i = 0; i != blocks; ++i)
{
for(u32bit j = 0; j != 16; ++j)
@@ -58,10 +62,6 @@ void SHA_224_256_BASE::compress_n(const byte input[], u32bit blocks)
W[j] = sigma(W[j- 2], 17, 19, 10) + W[j- 7] +
sigma(W[j-15], 7, 18, 3) + W[j-16];
- u32bit A = digest[0], B = digest[1], C = digest[2],
- D = digest[3], E = digest[4], F = digest[5],
- G = digest[6], H = digest[7];
-
F1(A, B, C, D, E, F, G, H, W[ 0], 0x428A2F98);
F1(H, A, B, C, D, E, F, G, W[ 1], 0x71374491);
F1(G, H, A, B, C, D, E, F, W[ 2], 0xB5C0FBCF);
@@ -127,9 +127,14 @@ void SHA_224_256_BASE::compress_n(const byte input[], u32bit blocks)
F1(C, D, E, F, G, H, A, B, W[62], 0xBEF9A3F7);
F1(B, C, D, E, F, G, H, A, W[63], 0xC67178F2);
- digest[0] += A; digest[1] += B; digest[2] += C;
- digest[3] += D; digest[4] += E; digest[5] += F;
- digest[6] += G; digest[7] += H;
+ A = (digest[0] += A);
+ B = (digest[1] += B);
+ C = (digest[2] += C);
+ D = (digest[3] += D);
+ E = (digest[4] += E);
+ F = (digest[5] += F);
+ G = (digest[6] += G);
+ H = (digest[7] += H);
}
}