输出项目:RetData=0x00操作成功;RetData=0xFF此操作失败。
unsigned char CpuCardAuthentication(unsigned char CpuFiled,unsigned char EsamFiled) { unsigned char i,Ret; //ESAM模块分散密钥 Ret = CosReset(0); if(Ret != 0) { return 0x01; } for(i = 0; i < 8; i++) { CmdBuf[i + 5] = CardSerial;//----------------------------------------分散因子 } Ret = CreateTempkey(0,EsamFiled);//----------------------------------------------分散密钥系统外部认证主密 if(Ret != 0) { return 0x02; } //从CPU卡取随机数 Ret = Getchanllege(1,8); if(Ret != 0) { return 0x03; } //把随机数送ESAM加密 for(i = 0; i < 8; i++) { CmdBuf[i + 5] = CosBuf; } Ret = DesTempkey(0);//------------------------------------------------------ESAM对随机数加密 if(Ret != 0) { return 0x04; } for(i = 0; i < 8; i++) { CmdBuf[i + 5] = CosBuf; } Ret = Externalauthen(1,CpuFiled); if(Ret == 0) { return 0x00; } else { return 0x05;//---------------------------------------------------------cpu卡外部认证错 } }