Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send response APDU containing return data AND status word other than 0x9000?

I would like to send a response APDU containing a response data field as well as a status word that is not 0x9000. Considering my understanding of ISO 7816-4 this should be possible in general.

However, whenever I specify return data and try to send it, I do not see any possibility to explicitly set a status word other than 0x9000.

On the contrary I can explicitly set arbitrary status words and send them as ISOException but have no possibility of attaching return data.

This behavior is ok for errors, i.e. status words 0x64XX - 0x69XX but what is for 0x63XX? It should be ok to send a warning and still convey return data.

So is it possible to send response APDUs containing return data AND a status word other than 0x9000 and how do I do this?

like image 833
Thomas Lieven Avatar asked Nov 29 '13 13:11

Thomas Lieven


1 Answers

Simply make sure that you send the data before throwing the exception. You may of course want to remember the status word you want to throw until the end. Then you can simply use ISOException.throwIt(short sw) to create the status word.

Note that - as you indicated - you should only return data if your status word indicates either 9000 or a warning (i. e. in the range 62xx up to 63xx). Returning data and a status word that indicates an error is a misinterpretation of ISO 7816-4.

I agree that throwing an exception to generate a warning does not feel right, but that's how it currently is.

like image 159
Maarten Bodewes Avatar answered Sep 20 '22 12:09

Maarten Bodewes