}
}
+inline uchar circ(uchar x,int n) {return (x << n) | (x >> (8 - n));}
void diff(uchar *Y, uchar *X, int h) {
Y[3] = X[0]^X[1]^X[2];
}
else if(h==8) {
- Y[0] = X[0]^X[2]^X[3]^X[5]^X[6]^X[7];
+ /*Y[0] = X[0]^X[2]^X[3]^X[5]^X[6]^X[7];
Y[1] = X[0]^X[1]^X[3]^X[4]^X[6]^X[7];
Y[2] = X[0]^X[1]^X[2]^X[4]^X[5]^X[7];
Y[3] = X[1]^X[2]^X[3]^X[4]^X[5]^X[6];
Y[5] = X[1]^X[2]^X[4]^X[6]^X[7];
Y[6] = X[2]^X[3]^X[4]^X[5]^X[7];
Y[7] = X[0]^X[3]^X[4]^X[5]^X[6];
+ */
+
+
+ uchar X0=X[0];
+ uchar X1=X[1];
+ uchar X2=X[2];
+ uchar X3=X[3];
+ uchar X4=X[4];
+ uchar X5=X[5];
+ uchar X6=X[6];
+ uchar X7=X[7];
+
+ Y[0] = X0^X2^X3^X5^X6^X7;
+ Y[1] = X0^X1^X3^X4^X6^X7;
+ Y[2] = X0^X1^X2^X4^X5^X7;
+ Y[3] = X1^X2^X3^X4^X5^X6;
+ Y[4] = X0^X1^X5^X6^X7;
+ Y[5] = X1^X2^X4^X6^X7;
+ Y[6] = X2^X3^X4^X5^X7;
+ Y[7] = X0^X3^X4^X5^X6;
+
+
}
else if(h==16) {
- Y[0] = X[3] ^ X[4] ^ X[6] ^ X[8] ^ X[9] ^ X[13] ^ X[14];
+ Y[0] = X[3] ^ X[4] ^ X[6] ^ X[8] ^ X[9] ^ X[13] ^ X[14];
Y[1] = X[2] ^ X[5] ^ X[7] ^ X[8] ^ X[9] ^ X[12] ^ X[15];
Y[2] = X[1] ^ X[4] ^ X[6] ^ X[10] ^ X[11] ^ X[12] ^ X[15];
Y[3] = X[0] ^ X[5] ^ X[7] ^ X[10] ^ X[11] ^ X[13] ^ X[14];
Y[12] = X[1] ^ X[2] ^ X[6] ^ X[7] ^ X[9] ^ X[11] ^ X[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