aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/hash/gost_3411/gost_3411.cpp60
1 files changed, 58 insertions, 2 deletions
diff --git a/src/hash/gost_3411/gost_3411.cpp b/src/hash/gost_3411/gost_3411.cpp
index 25118752f..0ac875532 100644
--- a/src/hash/gost_3411/gost_3411.cpp
+++ b/src/hash/gost_3411/gost_3411.cpp
@@ -137,8 +137,64 @@ void GOST_34_11::compress_n(const byte input[], u32bit blocks)
V[3] = AA_V_2;
}
- for(u32bit j = 0; j != 12; ++j)
- psi(S);
+ byte X0 = S[ 0] ^ S[ 2] ^ S[ 4] ^ S[ 6] ^ S[24] ^ S[30];
+ byte X1 = S[ 1] ^ S[ 3] ^ S[ 5] ^ S[ 7] ^ S[25] ^ S[31];
+ byte X2 = S[ 0] ^ S[ 8] ^ S[24] ^ S[26] ^ S[30];
+ byte X3 = S[ 1] ^ S[ 9] ^ S[25] ^ S[27] ^ S[31];
+ byte X4 = S[ 4] ^ S[ 6] ^ S[10] ^ S[28] ^ S[ 0] ^ S[24] ^ S[26] ^ S[30];
+ byte X5 = S[ 5] ^ S[ 7] ^ S[11] ^ S[29] ^ S[27] ^ S[ 1] ^ S[25] ^ S[31];
+ byte X6 = S[ 6] ^ S[ 8] ^ S[10] ^ S[12] ^ S[30] ^ X4;
+ byte X7 = S[ 7] ^ S[ 9] ^ S[11] ^ S[13] ^ S[31] ^ X5;
+ byte X8 = S[ 8] ^ S[10] ^ S[12] ^ S[14] ^ X0 ^ X6;
+ byte X9 = S[ 9] ^ S[11] ^ S[13] ^ S[15] ^ X1 ^ X7;
+ byte X10 = S[10] ^ S[12] ^ S[14] ^ S[16] ^ X2 ^ X8;
+ byte X11 = S[11] ^ S[13] ^ S[15] ^ S[17] ^ X3 ^ X9;
+ byte X12 = S[12] ^ S[14] ^ S[16] ^ S[18] ^ X4 ^ X10;
+ byte X13 = S[13] ^ S[15] ^ S[17] ^ S[19] ^ X5 ^ X11;
+ byte X14 = S[14] ^ S[16] ^ S[18] ^ S[20] ^ X6 ^ X12;
+ byte X15 = S[15] ^ S[17] ^ S[19] ^ S[21] ^ X7 ^ X13;
+ byte X16 = S[16] ^ S[18] ^ S[20] ^ S[22] ^ X8 ^ X14;
+ byte X17 = S[17] ^ S[19] ^ S[21] ^ S[23] ^ X9 ^ X15;
+ byte X18 = S[18] ^ S[20] ^ S[22] ^ S[24] ^ X10 ^ X16;
+ byte X19 = S[19] ^ S[21] ^ S[23] ^ S[25] ^ X11 ^ X17;
+ byte X20 = S[20] ^ S[22] ^ S[24] ^ S[26] ^ X12 ^ X18;
+ byte X21 = S[21] ^ S[23] ^ S[25] ^ S[27] ^ X13 ^ X19;
+ byte X22 = S[22] ^ S[24] ^ S[26] ^ S[28] ^ X14 ^ X20;
+ byte X23 = S[23] ^ S[25] ^ S[27] ^ S[29] ^ X15 ^ X21;
+
+ S[0] = S[24];
+ S[1] = S[25];
+ S[2] = S[26];
+ S[3] = S[27];
+ S[4] = S[28];
+ S[5] = S[29];
+ S[6] = S[30];
+ S[7] = S[31];
+ S[8] = X0;
+ S[9] = X1;
+ S[10] = X2;
+ S[11] = X3;
+ S[12] = X4;
+ S[13] = X5;
+ S[14] = X6;
+ S[15] = X7;
+ S[16] = X8;
+ S[17] = X9;
+ S[18] = X10;
+ S[19] = X11;
+ S[20] = X12;
+ S[21] = X13;
+ S[22] = X14;
+ S[23] = X15;
+ S[24] = X16;
+ S[25] = X17;
+ S[26] = X18;
+ S[27] = X19;
+ S[28] = X20;
+ S[29] = X21;
+ S[30] = X22;
+ S[31] = X23;
+
xor_buf(S, input + 32*i, 32);
psi(S);
xor_buf(S, hash, 32);