Search code examples
androidsmartcardsmartcard-reader

APDU Case 2 Response too short


I'm using a ACR39T-A3 Smart Card Reader connected over USB to an Android device.

First I'm sending a APDU Case 2 command like this.

                int offset = 0;
                List<byte[]> dataList = new ArrayList<>(8);

             while (true) {



                    if (!responseString.contains("90 00")) {
                        break;
                    }


                    dataList.add(progress[0].response);




    int offsetStartInt = 0x7F & (offset >> 8);
    int offsetEndInt =  offset & 0xFF ;

    //SmartcardOS
    //T1
    byte[] apdu = new byte[]{
            (byte) 0x00, //CLA
            (byte) 0xB0, //INS
            (byte) offsetStartInt, //P1
            (byte) offsetEndInt, //P2
            (byte) 0xff, //LE

    };

     transmitApdu(apdu);
     offset += 256;

     }

Im trying to get a certificate from the Smartcard. The certificate can be bigger than 256 so i need send multiple. But as Response i just get 90 00 instead of the certificate in mulitple.

Can anybody help me? I don´t understand how does it work with the offset.


Solution

  • While I don't recognize your API (and responseString is somewhat too magically filled in my opinion), in principle it should work that way.

    Since you specify LE as 0xFF, I recommend either

    • to set LE to zero instead or
    • to increment offset only by 255.

    If your EF was not yet written to at all, some cards may return nothing but 90 00.