gpt4 book ai didi

windows - 如何将低级命令(非 APDU)发送到 Windows 10(移动)上的智能卡?

转载 作者:可可西里 更新时间:2023-11-01 10:43:59 43 4
gpt4 key购买 nike

我正在根据 NFC Example 编写代码Microsoft 提供。
Windows.Devices.SmartCards 中的所有内容关于 APDU 命令。例如,TransmitAsync 方法描述为:

Asynchronously transmits the supplied application protocol data unit (APDU) command and returns the response.

但是,由于这是一个带有字节数组参数的方法,我认为我可以通过使用这个方法来摆脱 APDU。我在文件 CardReader.xaml.cs 中插入了一些代码:

private async Task HandleCard(SmartCard card){
......
// Handle MIFARE Standard/Classic
LogMessage("MIFARE Standard/Classic card detected");
var mfStdAccess = new MifareStandard.AccessHandler(connection);
var uid = await mfStdAccess.GetUidAsync();
LogMessage("UID: " + BitConverter.ToString(uid));

// My code
LogMessage("==============");
await SendBytes(connection, new byte[] { 0xFF, 0xCA, 0, 0, 0 }); //APDU Test
await SendBytes(connection, new byte[] { 0x50, 0x00 }); // Halt card
await SendBytes(connection, new byte[] { 0x52 }); //Wake card
return;
......
}
private async Task<byte[]> SendBytes(SmartCardConnection connection, byte[] RawData)
{
LogMessage("> " + BitConverter.ToString(RawData).Replace("-", " ").ToUpper());
byte[] res = (await connection.TransmitAsync(RawData.AsBuffer())).ToArray();
LogMessage("< " + BitConverter.ToString(res).Replace("-", " ").ToUpper());
return res;
}

我在手机上运行该应用程序以向 Mifare Classic 1K 卡发送命令。然而,我得到的是:

> FF CA 00 00 00
< 02 27 9F 8F 90 00
> 50 00
< 63 00
> 52
< 63 00

显然,APDU 一个有效。我不知道 63 00 是什么,但我猜它是 APUD 命令中的软件响应?
我在论坛上看到您可以使用 NfcAdapter 在 Android 手机上执行此操作。我的代码有什么问题?或者甚至可以在 Windows 10 移动版上发送低级命令(以摆脱 APDU)?
谢谢。

最佳答案

PCSC 具有特定于存储卡的命令。这样您就可以获得对 Mifare 的支持。当然,您必须有读卡器制造商对 Mifare 卡的支持,但 Mifare 仍然很受欢迎。

但是不支持 native Mifare 命令。您需要将这些转换为 2.01 specification 中的 PCSC 命令, 第 3.2.2.1 节。

因此您无需摆脱 native 命令。只需将存储卡特定的 APDU 发送到读卡器,读卡器就会将 native 命令发送到卡。

关于windows - 如何将低级命令(非 APDU)发送到 Windows 10(移动)上的智能卡?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35559893/

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