我目前嘗試寫關於JavaCard小應用程序的測試。我使用JUnit和javax.smartcardio將所有命令發送到智能卡。 但我需要打開一個安全通道才能讓我的一個測試正常運行。 經過兩天對文檔和實驗的嚴格審查,我無法找到打開此安全通道的方法。有人有智能卡API的線索嗎?或者其他API願意這樣做?java智能卡I/O安全通道
//TODO: need secure channel
byte[] header = {(byte)0x02, (byte)0x01, (byte)0x01}; //tag + length
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
outputStream.write(header);
outputStream.write(Value.SN.getBytes());
byte[] excpectedRes = outputStream.toByteArray();
// not a secure channel at all
ResponseAPDU answer = channel.transmit(new CommandAPDU(0x84, 0xCA, 0x02, 0x01, Value.Emptydata));
nameTest = "Test Select Serial number " + answer.toString();
CheckSW(0x90, 00, answer);
CheckResult(excpectedRes, result);
這是我的代碼,我總是得到一個0×69爲0x82答案(安全狀態不被滿足)
感謝
請詳細說明您的問題或發佈您的非工作代碼...解釋問題出在哪裏 –
@AuuragSharma代碼例程完成。 probeleme是我的頻道是一個簡單的javax.smartcardio.CardChannel –