Java Card OwnerPin - APDU Command



我开始学习java卡,我正在阅读钱包的示例代码,其中有一个OwnerPin

以下是代码的一部分,与引脚及其验证相关:

OwnerPIN pin;
private myApplet(byte[] bArray, short bOffset, byte bLength) {
// It is good programming practice to allocate
// all the memory that an applet needs during
// its lifetime inside the constructor
pin = new OwnerPIN(PIN_TRY_LIMIT, MAX_PIN_SIZE);
byte iLen = bArray[bOffset]; // aid length
bOffset = (short) (bOffset + iLen + 1);
byte cLen = bArray[bOffset]; // info length
bOffset = (short) (bOffset + cLen + 1);
byte aLen = bArray[bOffset]; // applet data length
// The installation parameters contain the PIN
// initialization value
pin.update(bArray, (short) (bOffset + 1), aLen);
register();
}

我在理解这段代码时遇到了一点麻烦。我知道这是根据安装脚本设置引脚时的部分:

0x80 0xB8 0x00 0x00 0xd 0xb 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x00 0x00 0x00 0x7F;

我不明白安装小程序后引脚的值是多少。

显示的代码不足以实际说明给定的 APDU。

不过,此代码示例:

byte iLen = bArray[bOffset]; // aid length
bOffset = (short) (bOffset + iLen + 1);
byte cLen = bArray[bOffset]; // info length
bOffset = (short) (bOffset + cLen + 1);
byte aLen = bArray[bOffset]; // applet data length

是小程序installation方法的默认代码,因此可能由全局平台安装命令触发。但是,给定的 APDU 根本不是有效的全球平台。

从您的代码中,我们无法在process方法中看到 APDU 的入口点,但可能是这样工作的:给定的数据是一个 LV 编码的列表(长度/值(,因此您首先解析长度字节以获得帮助,保存长度iLen并将bOffset递增到下一个 LV 对。 最后,小程序数据的值和长度被获取并馈送到pin.update中。

在给定的 APDU 中,PIN 确实丢失了,尝试解析内容和长度以获取帮助和信息,您将看到小程序数据字节丢失。

最新更新