【发布时间】:2016-07-23 03:36:54
【问题描述】:
我刚开始阅读 MIFARE Classic 卡,想知道如何使用密钥 A (A0A1A2A3A4A5) 和给定的密钥 B(保密)访问每个扇区。
我有一个将每个键加载到阅读器中的方法设置 (OMNIKEY 5421):
- 对于密钥 A:keyNo = 20 (
0x14) - 对于密钥 B:keyNo = 27 (
0x1B)
然后循环授权密钥:
while (loops > 0)
{
if (mifareCard.Authenticate(blockAddress, keyTypeA, keyNumberA) == false)
{
//throw new Exception("Can't authenticate under key 0 (key type A)");
//DisplayText("WARNING: authentication under transport key failed. Ending test sequence.");
Debug.WriteLine("WARNING: authentication under transport key A failed. Ending test sequence.");
return;
}
if (mifareCard.Authenticate(blockAddress, keyTypeB, keyNumberB) == false)
{
//throw new Exception("Can't authenticate under key 0 (key type A)");
//DisplayText("WARNING: authentication under transport key failed. Ending test sequence.");
Debug.WriteLine("WARNING: authentication under transport key B failed. Ending test sequence.");
return;
}
loops--;
loopsDone++;
DisplayText("OK-authenticate(loop #" + loopsDone + ") for access to sector " + sector + ", block " + blockWithinSector);
}
-
blockAddress是区块号 -
keyTypeA是密钥的类型。例如。 A 为 96 (0x60),B 为 97 (0x61) -
keyNumberA是来自读者的插槽
但是,当密钥 B 获得授权时,它会返回一个 SW 69 82,这意味着
'访问条件不满足'
有没有办法验证两个密钥?
【问题讨论】: