this is the c code

unsigned int delta[16] = { 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174
};


#define ROL(x,n) (x << n) | (x >> (32-n)) // n-bit left rotation

#define f(x) ( x + (ROL(x,7) ˆ ROL(x,22)) )

#define g(x) ( x ˆ (ROL(x,13) + ROL(x,27)) )


#define step(A,B,C,D,E,F,G,H,M1,M2,D1,D2) \ 
temp = H + ROL(g(E+M2),21) ˆ ROL(f(E+M2+D2),17); \ 
H = G + ROL(g(E+M2),9) ˆ ROL(f(E+M2+D2),5); \ 
G = F + g(E+M2) ˆ f(E+M2+D2); \ 
F = E + M2 + D2; \ 
E = D + ROL(f(A+M1),17) ˆ ROL(g(A+M1+D1),21); \ 
D = C + ROL(f(A+M1),5) ˆ ROL(g(A+M1+D1),9); \ 
C = B + f(A+M1) ˆ g(A+M1+D1); \ 
B = A + M1 + D1; \ 
A = temp;


FORK256 compression function(CV,M)
{ unsigned int A1,B1,C1,D1,E1,F1,G1,H1;
unsigned int A2,B2,C2,D2,E2,F2,G2,H2;
unsigned int A3,B3,C3,D3,E3,F3,G3,H3;
unsigned int A4,B4,C4,D4,E4,F4,G4,H4;

unsigned int temp;

A1 = A2 = A3 = A4 = CV[0]; B1 = B2 = B3 = B4 = CV[1];
C1 = C2 = C3 = C4 = CV[2]; D1 = D2 = D3 = D4 = CV[3];
E1 = E2 = E3 = E4 = CV[4]; F1 = F2 = F3 = F4 = CV[5];
G1 = G2 = G3 = G4 = CV[6]; H1 = H2 = H3 = H4 = CV[7];

// BRANCH1(CV,M)
step(A1,B1,C1,D1,E1,F1,G1,H1,M[0],M[1],delta[0],delta[1]);
step(A1,B1,C1,D1,E1,F1,G1,H1,M[2],M[3],delta[2],delta[3]);
step(A1,B1,C1,D1,E1,F1,G1,H1,M[4],M[5],delta[4],delta[5]);
step(A1,B1,C1,D1,E1,F1,G1,H1,M[6],M[7],delta[6],delta[7]);
step(A1,B1,C1,D1,E1,F1,G1,H1,M[8],M[9],delta[8],delta[9]);
step(A1,B1,C1,D1,E1,F1,G1,H1,M[10],M[11],delta[10],delta[11]);
step(A1,B1,C1,D1,E1,F1,G1,H1,M[12],M[13],delta[12],delta[13]);
step(A1,B1,C1,D1,E1,F1,G1,H1,M[14],M[15],delta[14],delta[15]);

// BRANCH2(CV,M)
step(A2,B2,C2,D2,E2,F2,G2,H2,M[14],M[15],delta[15],delta[14]);
step(A2,B2,C2,D2,E2,F2,G2,H2,M[11],M[9],delta[13],delta[12]);
step(A2,B2,C2,D2,E2,F2,G2,H2,M[8],M[10],delta[11],delta[10]);
step(A2,B2,C2,D2,E2,F2,G2,H2,M[3],M[4],delta[9],delta[8]);
step(A2,B2,C2,D2,E2,F2,G2,H2,M[2],M[13],delta[7],delta[6]);
step(A2,B2,C2,D2,E2,F2,G2,H2,M[0],M[5],delta[5],delta[4]);
step(A2,B2,C2,D2,E2,F2,G2,H2,M[6],M[7],delta[3],delta[2]);
step(A2,B2,C2,D2,E2,F2,G2,H2,M[12],M[1],delta[1],delta[0]);

// BRANCH3(CV,M)
step(A3,B3,C3,D3,E3,F3,G3,H3,M[7],M[6],delta[1],delta[0]);
step(A3,B3,C3,D3,E3,F3,G3,H3,M[10],M[14],delta[3],delta[2]);
step(A3,B3,C3,D3,E3,F3,G3,H3,M[13],M[2],delta[5],delta[4]);
step(A3,B3,C3,D3,E3,F3,G3,H3,M[9],M[12],delta[7],delta[6]);
step(A3,B3,C3,D3,E3,F3,G3,H3,M[11],M[4],delta[9],delta[8]);
step(A3,B3,C3,D3,E3,F3,G3,H3,M[15],M[8],delta[11],delta[10]);
step(A3,B3,C3,D3,E3,F3,G3,H3,M[5],M[0],delta[13],delta[12]);
step(A3,B3,C3,D3,E3,F3,G3,H3,M[1],M[3],delta[15],delta[14]);

// BRANCH4(CV,M)
step(A4,B4,C4,D4,E4,F4,G4,H4,M[5],M[12],delta[14],delta[15]);
step(A4,B4,C4,D4,E4,F4,G4,H4,M[1],M[8],delta[12],delta[13]);
step(A4,B4,C4,D4,E4,F4,G4,H4,M[15],M[0],delta[10],delta[11]);
step(A4,B4,C4,D4,E4,F4,G4,H4,M[13],M[11],delta[8],delta[9]);
step(A4,B4,C4,D4,E4,F4,G4,H4,M[3],M[10],delta[6],delta[7]);
step(A4,B4,C4,D4,E4,F4,G4,H4,M[9],M[2],delta[4],delta[5]);
step(A4,B4,C4,D4,E4,F4,G4,H4,M[7],M[14],delta[2],delta[3]);
step(A4,B4,C4,D4,E4,F4,G4,H4,M[4],M[6],delta[0],delta[1]);

// output
CV[0] = CV[0] + ((A1 + A2) ˆ (A3 + A4));
CV[1] = CV[1] + ((B1 + B2) ˆ (B3 + B4));
CV[2] = CV[2] + ((C1 + C2) ˆ (C3 + C4));
CV[3] = CV[3] + ((D1 + D2) ˆ (D3 + D4));
CV[4] = CV[4] + ((E1 + E2) ˆ (E3 + E4));
CV[5] = CV[5] + ((F1 + F2) ˆ (F3 + F4));
CV[6] = CV[6] + ((G1 + G2) ˆ (G3 + G4));
CV[7] = CV[7] + ((H1 + H2) ˆ (H3 + H4));
}
This article has been dead for over six months. Start a new discussion instead.