这段代码是什么语言编写的,我用dev c++编译是显示两处错误,这段代码怎么用?
void A3A8(/* in */ Byte rand[16], /* in */ Byte key[16], /* out */ Byte simoutput[12])
{
Byte x[32], bit[128];
int i, j, k, l, m, n, y, z, next_bit;
/* ( Load RAND into last 16 bytes of input ) */
for (i=16; i <32; i++)
x[i] = rand[i-16];
/* ( Loop eight times ) */
for (i=1; i <9; i++) {
/* ( Load key into first 16 bytes of input ) */
for (j=0; j <16; j++)
x[j] = key[j];
/* ( Perform substitutions ) */
for (j=0; j <5; j++)
for (k=0; k <(1 < <j); k++)
for (l=0; l <(1 < <(4-j)); l++) {
m = l + k*(1 < <(5-j));
n = m + (1 < <(4-j));
y = (x[m]+2*x[n]) % (1 < <(9-j));
z = (2*x[m]+x[n]) % (1 < <(9-j));
x[m] = table[j][y];
x[n] = table[j][z];
}
/* ( Form bits from bytes ) */
for (j=0; j <32; j++)
for (k=0; k <4; k++)
bit[4*j+k] = (x[j]>>(3-k)) & 1;
/* ( Permutation but not on the last loop ) */
if (i < 8)
for (j=0; j <16; j++) {
x[j+16] = 0;
for (k=0; k <8; k++) {
next_bit = ((8*j + k)*17) % 128;
x[j+16] ?= bit[next_bit] < < (7-k);
}
}
}
/*
* ( At this stage the vector x[] consists of 32 nibbles.
* The first 8 of these are taken as the output SRES. )
*/
/* The remainder of the code is not given explicitly in the
* standard, but was derived by reverse-engineering.
*/
for (i=0; i <4; i++)
simoutput[i] = (x[2*i] < <4) ? x[2*i+1];
for (i=0; i <6; i++)
simoutput[4+i] = (x[2*i+18] < <6) ? (x[2*i+18+1] < <2)
? (x[2*i+18+2]>>2);
simoutput[4+6] = (x[2*6+18] < <6) ? (x[2*6+18+1] < <2);
simoutput[4+7] = 0;
}
#ifdef TEST
int hextoint(char x)
{
x = toupper(x);
if (x >= 'A' && x <= 'F')
return x-'A'+10;
else if (x >= '0' && x <= '9')
return x-'0';
fprintf(stderr, "bad input.\n");
exit(1);
}
int main(int argc, char **argv)
{
Byte key[16], rand[16], simoutput[12];
int i;
if (argc != 3 ? ? strlen(argv[1]) != 34 ? ? strlen(argv[2]) != 34
? ? strncmp(argv[1], "0x", 2) != 0
? ? strncmp(argv[2], "0x", 2) != 0) {
fprintf(stderr, "Usage: %s 0x <key> 0x <rand>\n", argv[0]);
exit(1);
}
for (i=0; i <16; i++)
key[i] = (hextoint(argv[1][2*i+2]) < <4)
? hextoint(argv[1][2*i+3]);
for (i=0; i <16; i++)
rand[i] = (hextoint(argv[2][2*i+2]) < <4)
? hextoint(argv[2][2*i+3]);
A3A8(key, rand, simoutput);
printf("simoutput: ");
for (i=0; i <12; i++)
printf("%02X", simoutput[i]);
printf("\n");
return 0;
}
#endif