无法从 Javacard 发送 128 字节数据,但在使用 sendBytesLong() 时可以发送 127 字节作为对 APDU 命令的响应

Unable to send 128 Bytes data from Javacard but can send 127 Bytes as a response to APDU command when using sendBytesLong()

当使用 apdu.sendBytesLong() 函数以 APDU 命令的形式从 javacard 发送数据时,我能够发送 127 字节的数据作为响应,但 128 字节的数据给出错误代码 6f00(SW_UNKNOWN ). 为什么会发生这种情况,任何人都可以在不将数据拆分为两个 apdu 命令的情况下提出解决方法。

le = apdu.setOutgoing();
            if(le != 128)
                ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
apdu.setOutgoingLength((byte)le);
apdu.sendBytesLong(mod_PkAIKR,(short)0, le);

其中 mod_PkAIKR 是一个 128 字节的字节数组。

谢谢

改变 apdu.setOutgoingLength((byte)le);apdu.setOutgoingLength(le);

  1. apiapdu.setOutgoing()参数类型较短,不需要类型转换
  2. 如果将le转换为类型byte,则参数值为负数。 (byte) 128 的值为 -128.