标题:这段代码是什么语言编写的,我用dev c++编译是显示两处错误,这段代码怎么用 ...
只看楼主
xdada123
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2008-4-23
 问题点数:0 回复次数:1 
这段代码是什么语言编写的,我用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
搜索更多相关主题的帖子: dev 语言 Byte 代码 编译 
2008-04-23 13:44
xdada123
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2008-4-23
得分:0 
dev c++编译显示

编译器: Default compiler
执行  g++.exe...
g++.exe "C:\Documents and Settings\Administrator\桌面\未命名1.cpp" -o "C:\Documents and Settings\Administrator\桌面\未命名1.exe"   -pg -g3  -I"C:\Program Files\DEV-CPP\lib\gcc\mingw32\3.4.2\include"  -I"C:\Program Files\DEV-CPP\include\c++\3.4.2\backward"  -I"C:\Program Files\DEV-CPP\include\c++\3.4.2\mingw32"  -I"C:\Program Files\DEV-CPP\include\c++\3.4.2"  -I"C:\Program Files\DEV-CPP\include"   -L"C:\Program Files\DEV-CPP\Lib" -lgmon -pg  -g3  
C:\Program Files\DEV-CPP\Lib/libmingw32.a(main.o)(.text+0x106):main.c: undefined reference to `WinMain@16'
collect2: ld returned 1 exit status

执行结束
2008-04-23 13:47



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-210635-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.340255 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved