CPU卡程序设计实例(二十五)ESAM过程密钥内部认证
2017-05-01 09:32
525 查看
/*******************************************
函数名称:EsamInsideVali
函数功能:ESAM过程密钥内部认证
输入参数: pcReceCardRand-卡产生的随机数,KEYNum1,内部认证密钥标识
输出参数:无
描述:发命令头--发数据-发取响应数据命令--获得数据
*******************************************/
unsigned char* EsamInsideVerify(unsigned char* pcReceCardRand,unsigned char KEYNum1)
{
unsigned char cReceCardDatdBuff2[8]={0};
unsigned char *pcReceDataBuff;
unsigned int itemp;
cCommandLen=0x05;
TxAndRxBuff[0]=0x80;
TxAndRxBuff[1]=0xfa;
TxAndRxBuff[2]=0x00;
TxAndRxBuff[3]=KEYNum1;
TxAndRxBuff[4]=0x08;
SendCommandHead_Pro(); //发命令头
if(ErrorRWBIT&CardError) goto EsamInsideValiEnd;
memcpy(&TxAndRxBuff[0],pcReceCardRand,8);
Delay1XETU(4);
cCommandLen=8;
SendCommand(cCommandLen);//发数据
TxAndRxBuff[0]=EsamReceChar();
TxAndRxBuff[1]=EsamReceChar();
SendC0Comm(); //发“取响应数据”命令
for(itemp=0;itemp<8;itemp++)
{
cReceCardDatdBuff2[itemp]=EsamReceChar(); //接受ESAM返回信息
if(ErrorRWBIT&CardError) break;
}
TxAndRxBuff[0]=EsamReceChar();
TxAndRxBuff[1]=EsamReceChar();
if((TxAndRxBuff[0]!=0x90)&&(TxAndRxBuff[1]!=0x00))
{
CardError=ErrorRWBIT|CardError;
goto EsamInsideValiEnd;
}
EsamInsideValiEnd:
pcReceDataBuff=&cReceCardDatdBuff2[0];
delay_ms2M(5);
return pcReceDataBuff;
}
函数名称:EsamInsideVali
函数功能:ESAM过程密钥内部认证
输入参数: pcReceCardRand-卡产生的随机数,KEYNum1,内部认证密钥标识
输出参数:无
描述:发命令头--发数据-发取响应数据命令--获得数据
*******************************************/
unsigned char* EsamInsideVerify(unsigned char* pcReceCardRand,unsigned char KEYNum1)
{
unsigned char cReceCardDatdBuff2[8]={0};
unsigned char *pcReceDataBuff;
unsigned int itemp;
cCommandLen=0x05;
TxAndRxBuff[0]=0x80;
TxAndRxBuff[1]=0xfa;
TxAndRxBuff[2]=0x00;
TxAndRxBuff[3]=KEYNum1;
TxAndRxBuff[4]=0x08;
SendCommandHead_Pro(); //发命令头
if(ErrorRWBIT&CardError) goto EsamInsideValiEnd;
memcpy(&TxAndRxBuff[0],pcReceCardRand,8);
Delay1XETU(4);
cCommandLen=8;
SendCommand(cCommandLen);//发数据
TxAndRxBuff[0]=EsamReceChar();
TxAndRxBuff[1]=EsamReceChar();
SendC0Comm(); //发“取响应数据”命令
for(itemp=0;itemp<8;itemp++)
{
cReceCardDatdBuff2[itemp]=EsamReceChar(); //接受ESAM返回信息
if(ErrorRWBIT&CardError) break;
}
TxAndRxBuff[0]=EsamReceChar();
TxAndRxBuff[1]=EsamReceChar();
if((TxAndRxBuff[0]!=0x90)&&(TxAndRxBuff[1]!=0x00))
{
CardError=ErrorRWBIT|CardError;
goto EsamInsideValiEnd;
}
EsamInsideValiEnd:
pcReceDataBuff=&cReceCardDatdBuff2[0];
delay_ms2M(5);
return pcReceDataBuff;
}
相关文章推荐
- CPU卡设计实例及程序设计(三十)ESAM过程密钥内部认证
- CPU卡程序设计实例(二十三)卡和ESAM之间内部认证
- CPU卡设计实例及程序设计(二十八)ESAM外部认证
- CPU卡程序设计实例(二十四)生成过程密钥
- CPU卡程序设计实例(二十六)卡和ESAM之间外部认证
- CPU卡程序设计实例(二十二)CPU卡内部认证
- CPU卡程序设计实例(十三)终端向ESAM发送数据
- CPU卡程序设计实例(十二)ESAM模块字节接收函数
- CPU卡程序设计实例(八)ESAM模块卡上、下电
- CPU卡程序设计实例(二十一)4字节随机数读取
- CPU卡程序设计实例(二十)8字节随机数读取
- CPU卡发卡程序设计过程中应当注意的几个问题
- CPU卡程序设计实例(十八)命令体函数
- CPU卡程序设计实例(二)软件设计
- CPU卡程序设计实例(十一)CPU卡字节数据接收
- openstack启动实例内部过程
- DTLS协议中client/server的认证过程和密钥协商过程
- CPU卡程序设计实例(三)命令格式
- CPU卡程序设计实例(十五)数据校验
- CPU卡程序设计实例(九)CPU卡复位程序