1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| void cip(unsigned IN[5],unsigned OUT[5],unsigned Z[7][10])
{
unsigned r,x1,x2,x3,x4,kk,t1,t2,a;
x1=IN[1]; x2=IN[2]; x3=IN[3]; x4=IN[4];
for(r=1;r<=8;r++) /* les etapes */
{
/* le groupe d'operation effectuer sur le bloc de 64bits */
x1 = mul(x1,Z[1][r]); x4 = mul(x4,Z[4][r]);
x2 = (x2 + Z[2][r]) & one; x3 = (x3 + Z[3][r]) & one;
kk = mul(Z[5][r],(x1^x3));
t1 = mul(Z[6][r],(kk+(x2^x4)) & one);
t2 = (kk+t1) & one;
/* la permutation */
x1 = x1^t1; x4=x4^t2;
a = x2^t2; x2=x3^t1; x3=a;
printf("\n\t%1u-th rnd %6u\t%6u\t%6u\t%6u",r,x1,x2,x3,x4);
}
/* operation de sortie du bloc de 64bits crypter */
OUT[1] = mul(x1,Z[1][etape+1]);
OUT[4] = mul(x4,Z[4][etape+1]);
OUT[2] = (x3+Z[2][etape+1]) & one;
OUT[3] = (x2+Z[3][etape+1]) & one;
} |
Partager