just looking to see if i could get some help on this, i'm only about two weeks into working with javacard and lets say its fun! haha, but seriously. heres the bit of code that im calling in my function, its real simple, i have a bit of randomly generated data and im ciphering one of the arrays into the apdu to be sent back as a response, other commands work just fine like the mem method but that one just consistently fails.
private void initi(APDU apdu){
byte[] buf = apdu.getBuffer();
cdataoffset = (short)buf[ISO7816.OFFSET_CDATA];
len = Util.getShort(buf, cdataoffset);
try{
rd.generateData(tempbuf, (short) 0, (short) 32);
rd.generateData(serial, (short) 0, (short) 16);
rd.generateData(salt, (short) 0, (short) 6);
}
catch(CryptoException e){
ISOException.throwIt((short)(0x6900 | e.getReason()));
}
try{
privKey.setKey(tempbuf, (short) 0);
}
catch(ArrayIndexOutOfBoundsException e){}
catch(NullPointerException e){}
try{
cipherPriv.init(privKey, Cipher.MODE_ENCRYPT);
}
catch(CryptoException e){
ISOException.throwIt((short)(0x6900 | e.getReason()));
}
try{
cipherPriv.doFinal(serial, (short) 0, (short) 30, buf, cdataoffset);
}
catch(CryptoException e){
ISOException.throwIt((short)(0x6900 | e.getReason()));
}
apdu.setOutgoingAndSend((short) 0, len);
private void mem(APDU apdu){
byte[] buf = apdu.getBuffer();
short availableNVM = JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_PERSISTENT);
short availableVM = JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_TRANSIENT_DESELECT);
Util.setShort(buf, (short) 0, availableNVM);
Util.setShort(buf, (short) 2, availableVM);
apdu.setOutgoingAndSend((short) 0, (short) 4);
}
BTW im using a JCOP J3A081 card and gppro/antbuilder by martin for build/install
the response from the card:
A>> T=1 (4+0000) B0120000 A<< (0000+2) (89ms) 6901 SCardDisconnect("Identiv SCR3500 A Contact Reader", true)
my other theory is that im actually receiving my exception throw plus a value but i dont find that to be likely but im really not sure haha