【问题标题】:GET PROCESSING OPTIONS To get Data Bank Card (pscs-sharp)获取处理选项 获取数据银行卡 (pscs-sharp)
【发布时间】:2021-10-01 19:06:43
【问题描述】:

就我而言,我使用的是pcsc-sharp 项目。

我要暴露我的所作所为

  1. 选择 AID(在本例中为 Visa 卡)

请求:00 A4 04 00 A0000000031010 00

var array_byte = StringToByteArray("A0000000031010"); //VISA
       
        var contextFactory = ContextFactory.Instance;
        using (var ctx = contextFactory.Establish(SCardScope.System)) {
            using (var isoReader = new IsoReader(ctx, "HID Global OMNIKEY 3x21 Smart Card Reader 0", SCardShareMode.Shared, SCardProtocol.Any, false)) {

                var apdu = new CommandApdu(IsoCase.Case4Short, isoReader.ActiveProtocol) {
                    CLA = 0x00, // Class
                    Instruction = InstructionCode.SelectFile, //0xA4
                    P1 = 0x04, // Parameter 1
                    P2 = 0x00, // Parameter 2,
                    Data = array_byte,
                    Le = 0x00 // Expected length of the returned data
                };

                var response = isoReader.Transmit(apdu);
                Console.WriteLine("SW1 SW2 = {0:X2} {1:X2}", response.SW1, response.SW2);
                Console.WriteLine(response.HasData ? BitConverter.ToString(response.GetData()) : "No data");
                Console.ReadKey();
            }
        }

结果:

SW1 SW2 = 90 00
6F-43-84-07-A0-00-00-00-03-10-10-A5-38-50-0C-56-49-53-41-20-43-52-45-44-49-54-4F-87-01-01-9F-38-03-9F-1A-02-5F-2D-08-65-73-70-74-65-6E-66-72-9F-12-0F-43-52-45-44-4F-4D-41-54-49-43-20-56-49-53-41-9F-11-01-01

我检查了响应中的标签“9F38”(PDOL):

03-9F-1A-02

如果我是对的,这个 PDOL 会翻译成这样:

  • 03 -> 字节长
  • 9F-1A -> 标记终端国家代码
  • 02 -> 要返回的字段值的长度

我正在尝试这样做:

  1. 获取处理选项

请求:80 A8 00 00 8302 00

var array_byte = StringToByteArray("8302"); 

            var contextFactory = ContextFactory.Instance;
            using (var ctx = contextFactory.Establish(SCardScope.System)) {
                using (var isoReader = new IsoReader(ctx, "HID Global OMNIKEY 3x21 Smart Card Reader 0", SCardShareMode.Shared, SCardProtocol.Any, false)) {

                    var apdu = new CommandApdu(IsoCase.Case4Short, isoReader.ActiveProtocol) {
                        CLA = 0x80, // Class
                        Instruction = InstructionCode.GetProcessingOption, //0xA8
                        P1 = 0x00, // Parameter 1
                        P2 = 0x00, // Parameter 2,
                        Data = array_byte,
                        Le = 0x00 // Expected length of the returned data
                    };

                    var response = isoReader.Transmit(apdu);
                    Console.WriteLine("SW1 SW2 = {0:X2} {1:X2}", response.SW1, response.SW2);
                    Console.WriteLine(response.HasData ? BitConverter.ToString(response.GetData()) : "No data");
                    Console.ReadKey();
                }
            }

结果:

SW1 SW2 = 6D 00

No data

我测试了不同的数据(8302、8300、83020000),但我总是得到 6D 00 响应。我还测试了一个 apdu 工具 pyResMan 来执行此操作,但结果相同。

我提到了这个链接get processing options,但我仍然有疑问。

我不确定我在 APDU 命令中做错了什么,或者我缺少一些东西,但我需要执行 GPO 以获取 AFL 并读取我需要的所有卡数据(PAN,到期日期等...)。

提前致谢。问候。

【问题讨论】:

    标签: c# apdu pcsc evm


    【解决方案1】:

    最后,我找到了解决方案,我需要在执行 GPO 之前选择 AID。 (强制执行,直接执行GPO不行)

    1. 请求 AID --> 00 A4 04 00 A0000000031010 00
    2. 请求 GPO --> 80 A8 00 00 8302 00

    在那之后,我能够得到 GPO 的响应。

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 2016-06-23
      • 1970-01-01
      • 2018-05-26
      • 2014-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-22
      • 1970-01-01
      相关资源
      最近更新 更多