Page 1 of 1

ISO7816 - Odd INS codes?

Posted: Thu May 21, 2015 2:06 am
by mabel
I found the following descriptions in ISO 7816. http://www.cardwerk.com/smartcards/smartcard_standard_ISO7816-4_5_basic_organizations.aspx#chap5_4

5.4.2 Instruction byte

The instruction byte INS of a command shall be coded to allow transmission with any of the protocols defined in part 3 of ISO/IEC 7816. Table 10 shows the INS codes that are consequently invalid.

Table 10 - Invalid INS codes

b8 b7 b6 b5 b4 b3 b2 b1 Meaning
x x x x x x x 1 Odd values
0 1 1 0 x x x x '6X'
1 0 0 1 x x x x '9X'


Why cann't I use odd values? Could it really cause any problems if I do?

Re: ISO7816 - Odd INS codes?

Posted: Fri May 22, 2015 1:14 am
by horse dream
The specification that you saw is an old version.
Odd instruction codes are typically handled differently from the even ones by the card, they are no simple aliases for these, but equally valid.
Beaucse 7816-4 requires a different handling of secure messaging and the pressure towards odd instruction codes came from additional requirements.
the even instruction code of read binary can handle only offsets up to 15 bits. If this is insufficient, the odd instruction has to be used, where the offset has to be coded in an offset DO.

Re: ISO7816 - Odd INS codes?

Posted: Fri May 22, 2015 1:19 am
by mabel
Hi,horse dream.Could you please explain what you mean : "Odd instruction codes are typically handled differently from the even ones by the card, they are no simple aliases for these..." As we all know,according to ISO, odd INS codes are invalid . What I want to know is if there is a card, which handles odd INS codes in an incorrect way .

Re: ISO7816 - Odd INS codes?

Posted: Fri May 22, 2015 1:53 am
by horse dream
mabel wrote:Hi,horse dream.Could you please explain what you mean : "Odd instruction codes are typically handled differently from the even ones by the card, they are no simple aliases for these..." As we all know,according to ISO, odd INS codes are invalid . What I want to know is if there is a card, which handles odd INS codes in an incorrect way .

The ISO7816 version you refer to dates from 1995. My understanding of javacard is, that your app alone defines, which INS codes it reacts to; I can't imagine another card-side instance taking any care.

Re: ISO7816 - Odd INS codes?

Posted: Tue May 26, 2015 11:46 pm
by Larson
You can see the following description in the page 11 of ISO7816 spec.
In the interindustry class, bit 1 of INS indicates a data field format as follows.
* If bit 1 is set to 0 (even INS code), then no indication is provided.
* If bit 1 is set to 1 (odd INS code), then BER - TLV encoding (see 5.2.2) shall apply as follows.
• In unchained commands with SW1 not set to '61', data fields, if any, shall be encoded in BER - TLV .
• Command chaining and / or the use of SW1 set to '61' allow the transmission of data strings too long
for a single command. Such a process may split data objects in data fields consecutively sent as a
sequence in one direction, i.e., while sending no data field in the opposite direction. When chaining
commands and / or using SW1 set to '61', the concatenation of all the consecutive data fields in the
same direction in the same sequence shall be encoded in BER - TLV .
:)