martinpaljak / vJCRE

Virtual Java Card Runtime Environment RETIRED
52 stars 22 forks source link

sendBytesLong doesn't throw an exception if setOutgoingLength not called #7

Open vletoux opened 8 years ago

vletoux commented 8 years ago

According to http://www.win.tue.nl/pinpasjc/docs/apis/jc222/javacard/framework/APDU.html#sendBytesLong%28byte[],%20short,%20short%29

"throws:(...) APDUException.ILLEGAL_USE if setOutgoingLength() not called or setOutgoingAndSend() previously invoked or response byte count exceeded or if APDUException.NO_T0_GETRESPONSE or APDUException.NO_T0_REISSUE or APDUException.NO_T0_REISSUE previously thrown. "

Indeed no check is done on sendBytesLong for that https://github.com/martinpaljak/vJCRE/blob/85c7828089fcde0fa8cde89a622b5ec582804947/src/pro/javacard/vre/vAPDU.java#L92

Took me a while to find the problem in my card when testing on the card while it was fine on the emulator ;-)

vletoux commented 8 years ago

Same for setIncomingAndReceive called twice => should trigger an error