观测下老外的水平如何

I’m not exactly sure what you are trying to achieve here. Whatever you transceive with IsoPcdA’s transceive method are complete APDUs (as defined in ISO/IEC 7816-4, or rather any PDU within the ISO-DEP transport protocol). So the return value of transceive is a full C-APDU (command APDU) and the byte array parameter of transceive is a full R-APDU (response APDU) including the two bytes of the status word (SW1 | SW2). Thus, the last two bytes of that parameter are the status word. In your example SW1 would be 02 and SW2 would be 03.

What you see as status byte in the InDataExchange command of the PN532 NFC controller is not the status word of the APDU but the status of the command execution within the PN532 NFC controller. This status byte gives you information about buffer overflows, communication timeouts, etc and is not something that is returned by the card side.

EDIT : Sample code + test commands:

Sample Code running on Galaxy Nexus (CM 10):

try {
  Class isoPcdA = Class.forName("android.nfc.tech.IsoPcdA");
  Method isoPcdA_get = isoPcdA.getDeclaredMethod("get", Tag.class);

  final IsoPcdA techIsoPcdA = (IsoPcdA)isoPcdA_get.invoke(null, tag);

  if (techIsoPcdA != null) {
    if (mWorker != null) {
      mInterrupt = true;
      mWorker.interrupt();
      try {
        mWorker.join();
      } catch (Exception e) {}
    }

    mInterrupt = false;
    mWorker = new Thread(new Runnable() {
      public void run () {
        try {
          techIsoPcdA.connect();

          byte[] command = techIsoPcdA.transceive(new byte[]{ (byte)0x90, (byte)0x00 });
          Log.d(CardEmulationTest.class.getName(), "Connected.");

          while (!mInterrupt) {
            Log.d(CardEmulationTest.class.getName(), "C-APDU=" + StringUtils.convertByteArrayToHexString(command));
            command = techIsoPcdA.transceive(command);
          }
        } catch (Exception e) {
          Log.e(CardEmulationTest.class.getName(), "Exception while communicating on IsoPcdA object", e);
        } finally {
          try {
            techIsoPcdA.close();
          } catch (Exception e) {}
        }
      }
    });

    mWorker.start();
  }
} catch (Exception e) {
  Log.e(CardEmulationTest.class.getName(), "Exception while processing IsoPcdA object", e);
}

Test (using ACR122U):

InListPassivTargets (1 target at 106kbps)

> FF00000004 D44A 0100 00
< D54B 010100046004088821310578338800 9000

InDataExchange with DATA = 0x01

> FF00000004 D440 01 01 00
< D541 00 01 9000

So we get an error code of 0x00 from the card reader (status of InDataExchange command; not part of the actual response APDU), we get 0x01 as the response (this is the IsoDepA response APDU) and we get 0x9000 as the status code for the card reader wrapper APDU (not part of the actual response APDU).

InDataExchange with DATA = 0x01 0x02

> FF00000005 D440 01 0102 00
< D541 00 0102 9000

So we get an error code of 0x00 from the card reader (status of InDataExchange command; not part of the actual response APDU), we get 0x01 0x02 as the response (this is the IsoDepA response APDU) and we get 0x9000 as the status code for the card reader wrapper APDU (not part of the actual response APDU).

InDataExchange with DATA = 0x01 0x02 0x03

> FF00000006 D440 01 010203 00
< D541 00 010203 9000

So we get an error code of 0x00 from the card reader (status of InDataExchange command; not part of the actual response APDU), we get 0x01 0x02 0x03 as the response (this is the IsoDepA response APDU) and we get 0x9000 as the status code for the card reader wrapper APDU (not part of the actual response APDU).

InDataExchange with DATA = 0x01 0x02 0x03 0x04

> FF00000007 D440 01 01020304 00
< D541 00 01020304 9000

So we get an error code of 0x00 from the card reader (status of InDataExchange command; not part of the actual response APDU), we get 0x01 0x02 0x03 0x04 as the response (this is the IsoDepA response APDU) and we get 0x9000 as the status code for the card reader wrapper APDU (not part of the actual response APDU).

Thus, we get exactly the data taht we send as command APDU as response APDU (note that none of these APDUs is formatted according to ISO 7816-4, but that doesnt matter as the IsoPcdA card emulation works with any ISO 14443-4 transport protocol format).

The status code of 0x9000 belongs to the card reader APDU encapsulation (CLA=FF INS=00 P1P2=0000 Lc [PN542 COMMAND] Le=00) that is required as the ACR122U’s PN532 is accessed over the CCID (PC/SC) interface. These are pure reader command encapsulation and have nothing to do with the communication over ISO-DEP.

The D440 01 [DATA] is the PN532 command to exchange data (e.g. APDUs) over ISO-DEP and the D541 00 [DATA] is the associated response.

Original: https://www.cnblogs.com/jiftle/p/16508368.html
Author: jiftle
Title: 观测下老外的水平如何

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/552203/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

  • 微信二维码标准

    一、258像素标准 宽度:258边距:18 范例: http://qr.topscan.com/api.php?w=258&m=18&el=h&text=h…

    技术杂谈 2023年5月31日
    0131
  • ElasticSearch这些坑记得避开

    一、管理方式 二、结构维护 三、数据调度 1、同步方案 2、中断和恢复 四、刷新策略 五、深度分页 六、参考源码 Index用不好,麻烦事不会少; 一、管理方式 ElasticSe…

    技术杂谈 2023年7月24日
    0104
  • 剑指offer计划27(栈与队列困难)—java

    1.1、题目1 剑指 Offer 59 – I. 滑动窗口的最大值 1.2、解法 解题思路:(来自作者bigbeats) 相当于维护一个最大队列(队头元素最大,向队尾非…

    技术杂谈 2023年7月25日
    0118
  • Go写文件的权限WriteFile(filename,data,0644)?

    本文来自博客园,作者:阿伟的博客,转载请注明原文链接:https://www.cnblogs.com/cenjw/p/go-ioutil-writefile-perm.html 前…

    技术杂谈 2023年7月24日
    095
  • []APP留存率下降分析的框架

    [原创]APP留存率下降分析的框架 [原创]APP留存率下降分析的框架 posted @2021-10-14 14:46 卖烧烤的鱼 阅读(67 ) 评论() 编辑 Origina…

    技术杂谈 2023年5月30日
    0119
  • 服务器一般达到多少QPS比较好?

    服务器一般达到多少QPS比较好? 一个大型网站需要多少服务器? posted @2017-09-14 09:45 52php 阅读(6963 ) 评论() 编辑 Original:…

    技术杂谈 2023年5月31日
    0134
  • Go学习第二天:查看变量的类型

    方法一: %T 格式化输出%T。详情见这个例子: import "fmt" func main(){ var a = 1 fmt.Printf( "a…

    技术杂谈 2023年7月24日
    0101
  • Uri: getLastPathSegment()

    该函数可用于截取URI当中的文件名。比如一段 URI如下: content://media/external/file/61585 调用该函数得到的结果为: 61585 也就是简化…

    技术杂谈 2023年6月1日
    0105
  • 软件测试基础理论

    软件基础的理论 一, 什么是软件产品 它是一个逻辑产品,没有实体,包括程序,文档和数据,需要通过终端设备才能体现出来功能和作用 二, 软件产品的中间过程文档 客户需求 &#…

    技术杂谈 2023年7月25日
    090
  • 如何保证消息的可靠性的投递

    如何保证消息的可靠性的投递 在本项目中,添加员工会发送入职邮件,利用RabbitMQ的队列发送入职邮件。这部分只是实现发送邮件的功能,RabbitMQ它有它的优点就是异步、解耦、流…

    技术杂谈 2023年7月11日
    0132
  • 小孩补脑

    橄榄油、动物的肉、鱼类、坚果:神经髓鞘发育很重要的物质基础。核桃中是含有很多Omega-6和Omega-3脂肪酸,并且DHA也是Omega-3的一种,但并不代表这种成分只有核桃中有…

    技术杂谈 2023年6月1日
    090
  • 2022.21 Web页面和本地程序通信的方法

    因为安全限制,web页面不能直接操作本地电脑资源,因此一些访问本地文件或操作本地设备之类的操作需要客户端本地程序来做,这就涉及到web页面与客户端电脑本地程序通信交互。 以前主流浏…

    技术杂谈 2023年5月30日
    0103
  • jenkins 入门

    Jenkins Pipeline(或简称为 “Pipeline”)是一套插件,将持续交付的实现和实施集成到 Jenkins 中。 https://www.j…

    技术杂谈 2023年5月31日
    099
  • 一个基于角色的访问控制(RBAC)的简单示例

    关于”基于角色的访问控制”是什么,本文不再赘述,如果不明白,请自行查阅资料了解。 本文参考用户·角色·权限·表的设计的思想设计。 本文用到的技术有Sprin…

    技术杂谈 2023年7月23日
    0104
  • 一切在这里

    我们播下种子,对天空祈求,滋润植物,饮下雨水,再还给土壤,诅咒寒冷,朝着太阳跳舞,随着微风起舞,由于经历过的东西而流泪,在月亮的赔本下做梦。 我们张开我们的双手迎接另一个可能充满希…

    技术杂谈 2023年5月31日
    082
  • 故障排查:是什么 导致了客户端批量心跳超时掉线

    为什么需要心跳机制了?因为针对某些客户端掉线(可能是因为网络断开、或客户端程序退出),服务端不能立即感受到(有的可能需要过很长的时间才能感受到),所以,需要引入心跳机制,让服务端尽…

    技术杂谈 2023年6月1日
    0100
亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球