【文件属性】:
文件名称:B_M算法求线性复杂度
文件大小:3KB
文件格式:C
更新时间:2016-02-11 06:21:29
B_M攻击
可以处理无限数据,求其线性复杂度
//by史瑞
//LFSR线性移位寄存器以及求异或运算OK
unsigned char LFSRB_M(unsigned char *fun,unsigned char *seq,unsigned long Cont){
unsigned long x;
unsigned char ch=0x00,t=0x00,*array;
array=(unsigned char *)malloc(Cont*sizeof(unsigned char));
for(x=0;x>(y%8));
}
t=LFSRB_M(fun,array,word(ln));
d=((((*(seq+n/8))<<(n%8))&0x80;)^t)?1:0;
free(array);
}
else
d=(((*(seq+n/8))<<(n%8))&0x80;)?1:0;
if(d){
if(ln!=0){
lm=ln;
func=(unsigned char *)malloc(word(ln)*sizeof(unsigned char));
memcpy(func,fun,word(ln));
if(ln<(n+1-ln)){
ln=n+1-ln;
}
fmc=(unsigned char *)malloc(word(ln)*sizeof(unsigned char));
InitialDSR(fmc,word(ln));
memcpy(fmc,fm,word(lfm));
for(k=0;k>((n-m-1)%8));
fun=(unsigned char *)realloc(fun,word(ln)*sizeof(unsigned char));
for(k=word(lm);k>=(place(ln));
*(fun+(word(ln)-1))^=ch;
}
}
n++;
printf("\t<%d,%d>",n,ln);
fprintf(fmm,"\t=<%d,%d,%d>",n,d,ln);
if(n%3==0){
printf("\n");
fprintf(fmm,"\n");
}
}
printf("\nFn=");
// for(k=0;k