真正的HCS301(滚动码)解码C代码(已经通过测试)
时间:2019-12-23
大小:2.15MB
阅读数:1275
查看他发布的资源
资料介绍
#definebitcheck8(var,bit)(var((u1t)1(bit))) u1thcs301Key[8]={0xef,0xcd,0xab,0x89,0x67,0x45,0x23,0x01};/*hcs301Key[0]是低字节*/ u1thcs301Hop[4]={0x5a,0xa5,0x5a,0xa5,};/*32位加密部分,hcs301Hop[0]是低字节*/ staticvoidHcs301Decrypt() { u1tcnt1; u1tcnt0; u1tmask; u1ttem; u1tcarry; u1tcarry2; u1ti; for(cnt1=11+1;cnt1>0;cnt1--) { for(cnt0=48;cnt0>0;cnt0--) { if((cnt1^0x01)>0) { if(bitcheck8(hcs301Hop[2],3)==0) { mask=0x01; } else { mask=0x10; } if(bitcheck8(hcs301Hop[1],0)>0) { mask=2; } if(bitcheck8(hcs301Hop[0],0)>0) { mask=1; } tem=0x2e; if(bitcheck8(hcs301Hop[3],1)>0) { tem=0x74; if(bitcheck8(hcs301Hop[3],6)>0) { tem=0x3a; } } else { if(bitcheck8(hcs301Hop[3],6)>0) { tem=0x5c; } } mask=tem; tem=0; if(mask>0) { tem=0x80; } tem^=hcs301Hop[1]; tem^=hcs301Hop[3]; tem^=hcs301Key[1]; mask=tem; carry=0x00; if(bitcheck8(mask,7)>0) { carry=0x01; } mask=1; for(i=0;i4;i++) { carry2=0x00; if(bitcheck8(hcs301Hop[i],7)>0) { carry2=0x01; } hcs301Hop[i]=1; hcs301Hop[i]|=carry; carry=carry2; } } //ROTATE_KEY carry=0; if(bitcheck8(hcs301Key[7],7)>0) { carry=0x01; } for(i=0;i8;i++) { carry2=0x00; if(bitcheck8(hcs301Key[i],7)>0) { carry2=0x01; } hcs301Key[i]=1; hcs301Key[i]|=carry; carry=carry2; } } } }……
版权说明:本资料由用户提供并上传,仅用于学习交流;若内容存在侵权,请进行举报,或
联系我们 删除。