gpt4 book ai didi

authentication - Mifare 认证

转载 作者:行者123 更新时间:2023-12-03 12:37:39 30 4
gpt4 key购买 nike

假设我想对 Mifare Classic 进行身份验证。

我如何知道要发送到卡的确切类型的 APDU?

例子。

这段代码:

bcla = 0xFF;
bins = 0x86;
bp1 = 0x0;
bp2 = 0x0; // currentBlock
len = 0x5;

sendBuffer[0] = bcla;
sendBuffer[1] = bins;
sendBuffer[2] = bp1;
sendBuffer[3] = bp2;
sendBuffer[4] = len;
sendBuffer[5] = 0x1; // Version
sendBuffer[6] = 0x0; // Address MSB
sendBuffer[7] = currentBlock;
if(keyradioButton->Checked==true) // Address LSB
sendBuffer[8] = 0x60; // Key Type A
else if(keynumberradioButton->Checked ==true)
sendBuffer[8] = 0x61; // Key Type B
sendBuffer[9] = keynumber; // Key Number

sendbufferlen = 0xA;
receivebufferlen = 255;

//Invoke the Transmit command
retval = SCardTransmit(hCard, // A reference value returned from the SCardConnect function.
&sioreq,
sendBuffer, // Send buffer
sendbufferlen, // Send buffer length
&rioreq,
receiveBuffer, // Receive butter
&receivebufferlen); // Length of received buffer

是一个尝试向 Mifare Classic 进行身份验证的示例程序。
我的问题基本上是,我怎么知道要向卡发送什么样的 APDU?例如,我怎么知道 sendBuffer 中应该有什么? ?

最佳答案

在 Mifare Classic 1K 标签中有 16 个扇区,每个扇区包含 4 个块,每个块包含 16 个字节。

  • 扇区 0 包含块 (0,1,2,3)
  • 扇区 1 包含块 (4,5,6,7)
  • 扇区 2 包含块 (8,9,10,11)
  • 扇区 3 包含块 (12,13,14,15)....

  • 在读取或写入块之前您必须使用该扇区的 key A 或 key B 对其相应的扇区进行身份验证。身份验证完成后,您可以读取或写入。使用此命令,您可以使用 KEY A(60) 验证扇区 0
    byte[] authenticationByte = new byte[10];  

    authenticationByte = new byte[] { (byte) 0xFF, (byte) 0x86, (byte) 0x00,
    (byte) 0x00, (byte) 0x05, (byte) 0x00,(byte) 0x00, (byte) 0x04,
    (byte) 0x60,(byte) 0x00 };

    当身份验证成功时,您将收到 90 00。这是成功消息。否则响应为 63 00 ,这意味着身份验证失败。身份验证完成后,您可以读取块 (0,1,2,3),因为扇区 0 包含 4 个块,而这些块是块 (0,1,2,3)。

    更多详情可以阅读 this Answer .抱歉英语不好

    关于authentication - Mifare 认证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18824879/

    30 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com