Question

i am building android application which connect to nfc secure element and get data to the android device.for building secure element i used java card API.In the jcop tools send ATR command to reset the java card.This is the sending commands.

/card -a a000000003000000 -c com.ibm.jc.CardManager
resetCard with timeout: 0 (ms)
--Waiting for card...
ATR=3B F8 18 00 FF 81 31 FE 45 4A 43 4F 50 76 32 34    ;.....1.EJCOPv24
    31 43                                              1C
ATR: T=1, FI=1/DI=8 (31clk/etu), N=-1, IFSC=254, BWI=4/CWI=5, Hist="JCOPv241"
 => 00 A4 04 00 08 A0 00 00 00 03 00 00 00 00 

i am using jcop tools for that.Secure element part is complete.but my android application need to send more request to secure element at one second.I used create a tag and send data this way.

byte[] GET_STRING = { 
        (byte) 0x80, // CLA Class        
        0x04, // INS Instruction
        0x00, // P1  Parameter 1
        0x00, // P2  Parameter 2
        0x10  // LE  maximal number of bytes expected in result
    };

result = tag.transceive(GET_STRING);
int len = result.length;
if (!(result[len-2]==(byte)0x90&&result[len-1]==(byte) 0x00))
   throw new RuntimeException("could not retrieve msisdn");

byte[] data = new byte[len-2];
System.arraycopy(result, 0, data, 0, len-2);
String str = new String(data).trim();

tag.close()

But I need to know how to send ATR command using android isoDep connection. if it is not possible how to reset the java card after getting data.

Thanks Sajith

Was it helpful?

Solution

Regarding your terminology:

On the contactless interface, you card does not have a reset sequence that produces an ATR. However, there is two comparable events on the contactless interface. One is turning the HF field off ann on. This causes a power-loss and consequently a hard reset of the card. The second one is to put the contactless card in HALT state and re-activate the card through the activation & selection procedure as specified in ISO/IEC 14443-3. This would typically also cause a card to reset its internal state.

Regarding your question of how to reset a contactless card that is connected through Android's IsoDep:

  • Hard reset: That's only possible through bringing the card out of the NFC device's read range and then scanning it again.

  • "Soft reset": On most devices this should be possible through closing and re-opening the connection using the IsoDep instance:

    IsoDep isoDepTag = IsoDep.get(tag);
    
    [...]
    
    isoDepTag.close();
    isoDepTag.connect();
    
    [...]
    

    However, you should be avare that some device (e.g. the Galaxy S4 in combination with certain Android versions) will not properly perform a soft reset (HALT + reactivation/selection) and, instead, just continue the previous connection.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top