用于验证加号卡,我使用的是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
方法
我还在该扇区的MIFARE Plus数据表中搜索了AES密钥地址,但没有找到任何此类信息。
下面提供的MIFARE Plus数据表链接
http://www.nxp.com/documents/short_data_sheet/MF1SPLUSX0Y1_SDS.pdf
答案 0 :(得分:0)
我尝试使用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