【问题标题】:getATR() does not reset the smart card in javax.smartcardiogetATR() 不会在 javax.smartcardio 中重置智能卡
【发布时间】:2013-07-03 16:19:59
【问题描述】:

我正在使用javax.smartcardio 包为带有Java 的智能卡编写一个小型应用程序,但我的ATR(重置答案)有一些问题。 card.getATR() 方法不会重置卡。它返回 ATR 字节,但不会将卡返回到 MF 状态。

这是我的例子:

TerminalFactory factory = TerminalFactory.getDefault();
List<CardTerminal> terminals = factory.terminals().list();

// get the first terminal
CardTerminal terminal = terminals.get(0);
// establish a connection with the card
Card card = terminal.connect("T=0");

ATR atr = card.getATR(); //atr.getBytes() <- correct

CardChannel channel = card.getBasicChannel();

ResponseAPDU r;
// STEP 1. select file in MF
r = channel.transmit(new CommandAPDU(new byte[]{0,(byte)0xA4,(byte)0x02,(byte)0x0C,(byte)0x02,0,(byte)0x02,0}));
// r.getBytes() == 90 00 <- correct

// STEP 2. select DF
r = channel.transmit(new CommandAPDU(new byte[]{0,(byte)0xA4,(byte)0x04,(byte)0x0C,(byte)0x02,(byte)0x05,0}));
// r.getBytes() == 90 00 <- correct

atr = card.getATR(); // answer to reset

// STEP 3. select file in MF, as in STEP 1
r = channel.transmit(new CommandAPDU(new byte[]{0,(byte)0xA4,(byte)0x02,(byte)0x0C,(byte)0x02,0,(byte)0x02,0}));
// r.getBytes() == 6A 82 <- fail, not found

card.disconnect(false);

我的错误在哪里?或者我怎样才能重置卡?

【问题讨论】:

  • 欢迎来到 Stackoverflow,Ro1 :)
  • 感谢指正。下次我就知道了;)

标签: java smartcard apdu


【解决方案1】:

Card.getATR() 没有指定它重置卡。它只是返回从卡请求的 ATR。您可能应该改用disconnect(true),然后重新连接到卡。​​

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-05-11
    • 1970-01-01
    • 1970-01-01
    • 2010-12-20
    • 1970-01-01
    • 1970-01-01
    • 2013-03-16
    • 1970-01-01
    相关资源
    最近更新 更多