R W
R W
import javacard.framework.*;
short adr,len;
byte[] buffer = apdu.getBuffer() ;
if (this.selectingApplet()) return;
// lecture CLA INS P1 P2 P3
if (buffer[ISO7816.OFFSET_CLA] != 0xf0) {
ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
}
switch (ins) {
case affichage:
Util.arrayCopy(assurance, (short) 0, buffer, (short) 0, (short)
assurance.length);
apdu.setOutgoingAndSend((short) 0, (short) assurance.length);
return;
case BINARY_READ:
// Question 1: test si adr <0 et Retourne le status word CLA WRONG_LENGTH
if (adr < (short)0)
ISOException.throwIt(ISO7816.SW_WRONG_LENGTH) ;
// Question 2: test si adr + len) >NVRSIZE et Retourne le status word
WRONG_LENGTH
if ((short)(adr + len) > (short)NVRSIZE)
ISOException.throwIt(ISO7816.SW_WRONG_LENGTH) ;
// Question 3 R�alise des transferts de m�moire � m�moire et
// transmet un message de r�ponse contenu dans le tampon de
r�ception
Util.arrayCopy(NVR,adr,buffer,(short)0,len);
apdu.setOutgoingAndSend((short)0,len);
break;
case BINARY_WRITE:
short readCount = apdu.setIncomingAndReceive(); //
offset=5 ...
// Question 4: test si readCount <0 et Retourne le status word
WRONG_LENGTH
if (readCount <= 0)
ISOException.throwIt(ISO7816.SW_WRONG_LENGTH) ;
if (adr < (short)0)
ISOException.throwIt(ISO7816.SW_WRONG_LENGTH) ;
if ((short)(adr + len) > (short)NVRSIZE )
ISOException.throwIt(ISO7816.SW_WRONG_LENGTH) ;
// Question 5: �criture par copie de l�apdu de commande
Util.arrayCopy(buffer,(short)5,NVR,adr,len);
break;
default:
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
}
}}