I recently bought a smart card reader (Gemplus USB Smart Card Reader) which came with some cards. I've been reading several tutorials about how to work with them but I have a couple of questions. I'm trying to comunicate (Sending APDU) with the smart card but with not success. I installed an applet into a Virtual smart card (using Netbeans).
My process method is like this:
byte[] buffer = apdu.getBuffer();
byte CLA = (byte) (buffer[ISO7816.OFFSET_CLA] & 0xFF);
byte INS = (byte) (buffer[ISO7816.OFFSET_INS] & 0xFF);
if (CLA != HW_CLA){
ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
}
switch (INS) {
case HW_INS_ADD:
add(apdu);
break;
case HW_INS_SUBTRACT:
subtract(apdu);
break;
default:
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
}
The add
and subtract
method adds or substract 5 units to a declared variable (balance). I would like to save into the card the balance value after making an operation. Does anyone know how can i write that value into the card? And if possible, how can i read it before?
Appreciate any help. Thank you.