You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

智能卡开发中PIN验证出现Class not supported错误(6E 00)的问题求助

智能卡开发中PIN验证出现Class not supported错误(6E 00)的问题求助

大家好,我正在基于ISO/IEC 7816-4标准开发智能卡相关应用,目前已经顺利完成了使用Class 00的小程序选择操作,但在尝试执行PIN验证命令(使用Class 88)时,收到了6E 00响应——这个错误码对应的是“Class不支持”的问题。

我的PIN验证命令参数要求如下:

  • IsoCase: Case3Short
  • Class: 0x88
  • Instruction: 0x11
  • P1-P2: 0x0400
  • Command Length (Lc): 0x04
  • Command Data: 4字节数据,每个字节对应一位PIN数字
  • Expected Length (Le): 0

我参考了OpenPGP Card 2.1规范文档,下面是我编写的C#代码,有没有大佬能帮我分析下可能的问题出在哪,以及该怎么修改?

using System;
using PCSC;
using PCSC.Iso7816;

class Program
{
    static void Main()
    {
        var contextFactory = ContextFactory.Instance;
        using (var context = contextFactory.Establish(SCardScope.System))
        {
            Console.WriteLine("Currently connected readers: ");
            var readerNames = context.GetReaders();
            foreach (var readerName in readerNames)
            {
                Console.WriteLine("\t" + readerName);
            }

            using (var isoReader = new IsoReader(context, "Gemplus USB SmartCard Reader 0",                                        SCardShareMode.Shared, SCardProtocol.Any, false))
            {
                // Replace '2346' with the actual PIN you want to verify
                var pinToVerify = new byte[] { 0x01, 0x02, 0x03, 0x04 };

                // APDU command for PIN verification
                var apduCommand = new CommandApdu(IsoCase.Case3Short, isoReader.ActiveProtocol)
                {
                    CLA = 0x88,
                    INS = 0x11,
                    P1 = 0x04,
                    P2 = 0x00,
                    Data = pinToVerify
                };

                // Send the APDU command
                var response = isoReader.Transmit(apduCommand);

                // Check the response status word
                if (response.SW1 == 0x90 && response.SW2 == 0x00)
                {
                    Console.WriteLine("PIN verification successful!");
                }
                else if (response.SW1 == 0x63 && response.SW2 == 0x02)
                {
                    Console.WriteLine("Wrong PIN. Error response: 0x6302");
                }
                else
                {
                    Console.WriteLine($"PIN verification failed. Unexpected response: {response}");
                    Console.WriteLine("SW1 SW2 = {0:X2} {1:X2}", response.SW1, response.SW2);
                }
            }
        }
    }
}

备注:内容来源于stack exchange,提问作者Katarina Vujic

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.21 08:10:27