NXP Mifare S70 EV1 7bytes UID卡 目前寻卡-2次放冲撞都可以了 密钥验证不行
lddjs 2019-04-04 03:20:51 以下是密钥验证代码:
status=Authentication(UID,0,TYPEA_MODE);////验证0扇区keyA
/****************************************************************/
/*名称: Authentication */
/*功能: 该函数实现密码认证的过程 */
/*输入: UID: 卡片序列号地址 */
/* SecNR: 扇区号 */
/* mode: 模式 */
/*输出: FM1715_NOTAGERR: 无卡 */
/* FM1715_PARITYERR: 奇偶校验错 */
/* FM1715_CRCERR: CRC校验错 */
/* FM1715_OK: 应答正确 */
/* FM1715_AUTHERR: 权威认证有错 */
/****************************************************************/
uchar Authentication(uchar idata *UID,uchar SecNR,uchar mode)
{
uchar idata i;
uchar idata temp,temp1;
CRCPresetLSB = 0x63;
CRCPresetLSB = 0x63;
CWConductance = 0x3f;
ModConductance = 0x3f;
temp1 = Control;
temp1 = temp1 & 0xf7;
Control = temp1;
if (mode == 1) //AUTHENT1
buffer[0] = RF_CMD_AUTH_LB; //61
else
buffer[0] = RF_CMD_AUTH_LA; //60
buffer[1] = SecNR * 4 + 3;
for (i = 0; i < 4; i++)
{
buffer[2 + i] = UID[i];
}
ChannelRedundancy = 0x0f; //开启CRC,奇偶校验校验
temp = Command_Send(6, buffer, Authent1);
if (temp == FALSE)
{
return FM1715_NOTAGERR;
}
temp = ErrorFlag;
if ((temp & 0x02) == 0x02)
return FM1715_PARITYERR;
if((temp & 0x04) == 0x04)
return FM1715_FRAMINGERR;
if ((temp & 0x08) == 0x08)
return FM1715_CRCERR;
temp = Command_Send(0, buffer, Authent2); //AUTHENT2
if(temp == FALSE)
{
return FM1715_NOTAGERR;
}
temp = ErrorFlag;
if ((temp & 0x02) == 0x02)
return FM1715_PARITYERR;
if((temp & 0x04) == 0x04)
return FM1715_FRAMINGERR;
if ((temp & 0x08) == 0x08)
return FM1715_CRCERR;
temp1 = Control;
temp1 = temp1 & 0x08; //Crypto1on=1验证通过
if (temp1 == 0x08)
{
return FM1715_OK;
}
return FM1715_AUTHERR;
}
目前就是密钥验证一直不行,试过CL1前4字节和CL2前4字节UID验证都不行,那位大神能不能给指点一下?