Как исправить ответ APDU SW=6700 (неправильная длина)

Я пытаюсь написать код для получения данных с удостоверения личности гражданина Таиланда, ссылаясь на APDU по этой ссылке.

И мой код, как показано ниже.

        // Display the list of terminals
        TerminalFactory factory = TerminalFactory.getDefault();
        List<CardTerminal> terminals = factory.terminals().list();
        System.out.println("Terminals: " + terminals);

        // Use the first terminal
        CardTerminal terminal = terminals.get(0);

        // Connect wit hthe card
        Card card = terminal.connect("*");
        System.out.println("Card: " + card);
        CardChannel channel = card.getBasicChannel();

        // Send Select Applet command
        String hex;
        byte[] aid = new byte[]{(byte) 0xA0, 0X00, 0x00, 0x00, 0x54, 0x48, 0x00, 0x01};
        //CommandAPDU(int cla, int ins, int p1, int p2, byte[] data)

        ResponseAPDU answer = channel.transmit(new CommandAPDU(0x00, 0xA4, 0x04, 0x00, aid));   // SELECT            
        System.out.println("SELECT: " + answer.toString());
        hex = DatatypeConverter.printHexBinary(answer.getBytes());
        System.out.println("Response: " + hex);
        System.out.println(new String(answer.getBytes(), "TIS620"));

        // Send test command
        answer = channel.transmit(new CommandAPDU(0x00, 0xc0, 0x00, 0x00));                     // GET RESPONSE
        System.out.println("RESPONSE: " + answer.toString());
        hex = DatatypeConverter.printHexBinary(answer.getBytes());
        System.out.println("Response: " + hex);
        System.out.println(new String(answer.getBytes(), "TIS620"));

        // Send test command
        byte[] aid2 = {(byte) 0x00};
        answer = channel.transmit(new CommandAPDU(0x80, 0xb0, 0x00, 0x04, aid2));        // Citizen ID
        System.out.println("CID: " + answer.toString());
        hex = DatatypeConverter.printHexBinary(answer.getBytes());
        System.out.println("Response: " + hex);
        System.out.println(new String(answer.getBytes(), "TIS620"));
        // Disconnect the card
        card.disconnect(false);

и это ответ.

        Terminals: [PC/SC terminal Generic EMV Smartcard Reader 0]
        Card: PC/SC card in Generic EMV Smartcard Reader 0, protocol T=0, state OK
        SELECT: ResponseAPDU: 12 bytes, SW=9000
        Response: 6F08A0000000544800019000

ОТВЕТ: ResponseAPDU: 2 байта, SW=9000 Ответ: 9000 CID: ResponseAPDU: 2 байта, SW=6700 Ответ: 6700

Я попытался добавить 0x100 для 'ne' байта после данных, и это не работает.

0 ответов

Другие вопросы по тегам