我想給的PIN,我智能卡與GPShell的-instParam選項。我發現了一些例子,但我沒有線索如何用給定的密碼初始化OwnerPIN對象。據我所知有是給我的小應用程序的安裝方法的LV編碼結構,但我怎麼解析。我嘗試了BERTLV對象,但是當安裝小程序時出現「條件不滿意」錯誤。 我有什麼:安裝參數JavaCard的
public static void install(byte[] bArray, short bOffset, byte bLength)
{
new MYPinCard(bArray, bOffset, bLength);
}
private MYPinCard(byte[] bArray, short bOffset, byte bLength)
{
m_pin = new OwnerPIN(PIN_TRY_LIMIT, MAX_PIN_SIZE);
byte iLen = bArray[bOffset]; // aid length
short iOffset = (short) (bOffset+iLen+1);
iLen = bArray[iOffset]; // application privileges length
iOffset = (short) (iOffset+iLen+1);
iLen = bArray[iOffset]; // application specific parameters length
iOffset++;
try
{
m_pin.update(bArray, iOffset, iLen);
}
catch (PINException e)
{
ISOException.throwIt((short)0x6AAA);
}
testdata = new byte[iLen];
Util.arrayCopy(bArray, bOffset, testdata, (short)0, iLen);
register();
}
private void getInstallParams(APDU apdu)
{
try
{
byte[] buffer = apdu.getBuffer();
// inform the JCRE that the applet has data to return
short le = apdu.setOutgoing();
// set the actual number of the outgoing data bytes
apdu.setOutgoingLength(((short)testdata.length));
apdu.sendBytesLong(testdata, (short)0, (short)testdata.length);
}
catch (APDUException e)
{
ISOException.throwIt(SW_APDU_EXCEPTION);
}
catch (TransactionException e)
{
ISOException.throwIt(SW_TRANSACTION_EXCEPTION);
}
catch (ArrayIndexOutOfBoundsException e)
{
ISOException.throwIt(SW_AIOOB_EXCEPTION);
}
catch (NullPointerException e)
{
ISOException.throwIt(SW_NULLPOINTER_EXCEPTION);
}
}
隨着getInstallParams()方法,我可以檢索的字節數。對於我的PIN是2字節的值,但我不知道如何處理該字節。
任何提示?
的'Util.arrayCopy(bArray,bOffset,TESTDATA,(短)0,艾朗);'部分可能使用了錯誤的偏移 - 恕我直言'iOffset'應該在那裏(如果你想存儲的參數值)。 – vlp