Reputation: 247
Is there any one know how to get NVM (non-volatile memory) of java card applet file?
After researched on the Internet I can't find any tool or guide for this.
Upvotes: 1
Views: 817
Reputation: 550
You can write a function in your applet to return the data related to NVM or RAM using JCSystem APIs.
public static final byte INS_GET_MEMORY = (byte) 0xCB;
public static final short TAG_PERSISTANT_MEM = (short) 0xC602;
public static final short TAG_TRANSIENT_RESET = (short) 0xC702;
public static final short TAG_TRANSIENT_DESELECT = (short) 0xC802;
public static final short TAG_BUFFER_SIZE = (short) 0xC902;
private short GetMemory(byte[] apduBuffer) {
short outDataOffset = ISO7816.OFFSET_CDATA;
outDataOffset = Util.setShort(apduBuffer, outDataOffset, TAG_PERSISTANT_MEM);
// Size is bounded by short limit for Persistent MEMORY_TYPE_PERSISTENT
// Can use getAvailableMemory(short[] buffer,short offset,byte memoryType)
// If the size is more than short range
outDataOffset = Util.setShort(apduBuffer, outDataOffset,
JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_PERSISTENT));
outDataOffset = Util.setShort(apduBuffer, outDataOffset,TAG_TRANSIENT_RESET);
outDataOffset = Util.setShort(apduBuffer, outDataOffset,
JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_TRANSIENT_RESET));
outDataOffset = Util.setShort(apduBuffer, outDataOffset,TAG_TRANSIENT_DESELECT);
outDataOffset = Util.setShort(apduBuffer, outDataOffset,
JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_TRANSIENT_DESELECT));
outDataOffset = Util.setShort(apduBuffer, outDataOffset,TAG_BUFFER_SIZE);
outDataOffset = Util.setShort(apduBuffer, outDataOffset, (short) apduBuffer.length);
return (short) (outDataOffset - ISO7816.OFFSET_CDATA);
}
This function return output data length
Upvotes: 0
Reputation: 41
send GET DATA command with Tag DF55 to the card manager (not to applet)
Upvotes: 0
Reputation: 1
You can send GET DATA APDU command with P1=FF and P2=21, please refer to ETSI 102.226
APDU Command: try this 80 CA FF 21 10
thanks
Upvotes: 0