【问题标题】:authentication error in mifare plus card using nxp sdk advanced使用 nxp sdk 高级的 mifare plus 卡中的身份验证错误
【发布时间】:2018-09-01 05:25:53
【问题描述】:

对于加号卡的身份验证,我使用nxp javadoc中提供的以下方法签名

public void authenticateSL3(boolean firstAuth,
               int blockNo,
               int keyNo,
               byte keyVersion,
               byte[] divInput,
               byte[] pcdCap2In) 

参数:

firstAuth - false: Following Authentication; true: First Authentication
blockNo - address of the AES authentication key. please check the MIFARE Plus datasheet for the sector AES key addresses.
keyNo - Key Storage number
keyVersion - Key Version number
divInput - Diversification Input used to diversify the key
pcdCap2In - Capabilities of PCD, which define what PCD is capable to do.(00H to 06H)

javadoc 链接

https://www.mifare.net/files/advanced_javadoc/

例如

byte[] divInput = null;

byte[] pcdCap2In = new byte[0];

objMfPlusNfcCard.authenticateSL3(true, block_no, 3, (byte) 0, divInput,
                pcdCap2In); 

上述方法中第三个参数值(3)和第四个参数值((byte) 0)是AES_key的索引和AES_key的版本,因此在keystore对象中添加如下

private IKeyStore ks= KeyStoreFactory.getInstance().getSoftwareKeyStore(); 

ks.formatKeyEntry(3, IKeyConstants.KeyType.KEYSTORE_KEY_TYPE_AES128); 

ks.setKey(3, (byte) 0,IKeyConstants.KeyType.KEYSTORE_KEY_TYPE_AES128, MIFARE_PLUS_KEY_AES128); 

我在弄清楚 objMfPlusNfcCard.authenticateSL3 方法中的 block_no 参数值可能是什么时遇到了问题

我还在该行业的 MIFARE Plus 数据表中搜索了 AES 密钥地址,但没有找到任何此类信息。

下面提供的 MIFARE Plus 数据表链接

http://www.nxp.com/documents/short_data_sheet/MF1SPLUSX0Y1_SDS.pdf

【问题讨论】:

    标签: android mifare


    【解决方案1】:

    我在尝试使用 First Authenticate 命令激活安全级别 3 时遇到了同样的问题。我知道需要发送到 MF Plus 卡的命令的最终结果是“70 03 90 00”(十六进制)。因此,反复试验使我找到了解决方案:

    byte[] divInput = null;
    byte[] pcdCap2In = new byte[0];
    
    objMfPlusNfcCard.authenticateSL3(true, 0x9003, 3, (byte) 0, divInput, pcdCap2In);
    

    所以对我来说,块号实际上是“安全级别 3 开关密钥”的扇区号。否则会按照上面的方法:

    AES Sector Keys for sector 0 to 39 (40 00h to 40 4Fh)
      Key A = sector number multiplied by 2
      Key B = sector number multiplied by 2 +1
      E.g. Key A for sector 2 has number: 40 04
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-11
      • 1970-01-01
      • 1970-01-01
      • 2014-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多