get the ram and eeprom using applet
Posted: Wed Jun 08, 2016 5:11 am
i write applet to get amount of eeprom but i am not sure whether or not it is right
i multiplicate counter and 1024 to get amount of eeprom , when exception throw
1.sample of EEPROM:
package memoryPack;
import javacard.framework.*;
import java.lang.Exception;
public class memoryApp extends Applet
{
public static void install(byte[] bArray, short bOffset, byte bLength)
{
new memoryApp().register(bArray, (short) (bOffset + 1), bArray[bOffset]);
}
public void process(APDU apdu)
{
short counter = (short) 0x0000;
if (selectingApplet())
{
return;
}
byte[] buf = apdu.getBuffer();
switch (buf[ISO7816.OFFSET_INS])
{
case (byte)0x00:
try{
while(true){
byte[] temp = new byte[1024];
counter++;
}
}catch(Exception e){
ISOException.throwIt(counter);
}
break;
default:
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
}
}
}
i multiplicate counter and 1024 to get amount of eeprom , when exception throw
1.sample of EEPROM:
package memoryPack;
import javacard.framework.*;
import java.lang.Exception;
public class memoryApp extends Applet
{
public static void install(byte[] bArray, short bOffset, byte bLength)
{
new memoryApp().register(bArray, (short) (bOffset + 1), bArray[bOffset]);
}
public void process(APDU apdu)
{
short counter = (short) 0x0000;
if (selectingApplet())
{
return;
}
byte[] buf = apdu.getBuffer();
switch (buf[ISO7816.OFFSET_INS])
{
case (byte)0x00:
try{
while(true){
byte[] temp = new byte[1024];
counter++;
}
}catch(Exception e){
ISOException.throwIt(counter);
}
break;
default:
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
}
}
}