Hello, the seInfo field is defined in libopensc/pkcs15.c as: { "seInfo", SC_ASN1_SEQUENCE, SC_ASN1_CONS | SC_ASN1_TAG_SEQUENCE, SC_ASN1_OPTIONAL, NULL, NULL }, but SC_ASN1_SEQUENCE type is not managed by asn1_decode_entry() in libopensc/asn1.c
I guess nothing bad happens if the field is not present. Unfortunately it is present in my card and I have an error: iso7816.c:302:iso7816_process_fci: processing FCI bytes iso7816.c:308:iso7816_process_fci: file identifier: 0x5032 iso7816.c:322:iso7816_process_fci: bytes in file: 284 iso7816.c:335:iso7816_process_fci: shareable: no iso7816.c:355:iso7816_process_fci: type: working EF iso7816.c:357:iso7816_process_fci: EF structure: 1 card.c:576:sc_select_file: returning with: 0 card.c:398:sc_read_binary: called; 284 bytes at index 0 card.c:398:sc_read_binary: called; 252 bytes at index 0 apdu.c:504:sc_transmit_apdu: called apdu.c:184:sc_apdu_log: Outgoing APDU data [ 5 bytes] ===================================== 00 B0 00 00 FC ..... ====================================================================== apdu.c:184:sc_apdu_log: Incoming APDU data [ 254 bytes] ===================================== 30 82 01 18 02 01 01 80 05 41 64 E8 6C 65 03 02 0........Ad.le.. 05 60 30 5F 30 11 02 01 02 04 0C D2 50 00 00 04 .`0_0.......P... 41 64 E8 6C 65 01 01 30 11 02 01 04 04 0C D2 50 Ad.le..0.......P 00 00 04 41 64 E8 6C 65 01 01 30 11 02 01 07 04 ...Ad.le..0..... 0C D2 50 00 00 04 41 64 E8 6C 65 01 01 30 11 02 ..P...Ad.le..0.. 01 08 04 0C D2 50 00 00 04 41 64 E8 6C 65 01 01 .....P...Ad.le.. 30 11 02 01 09 04 0C D2 50 00 00 04 41 64 E8 6C 0.......P...Ad.l 65 01 01 A2 81 A6 30 17 02 01 01 02 02 02 20 05 e.....0....... . 00 03 02 01 02 06 05 2B 0E 03 02 1A 02 01 10 30 .......+.......0 1B 02 01 02 02 02 02 50 05 00 03 02 01 02 06 09 .......P........ 60 86 48 01 65 03 04 02 01 02 01 20 30 1A 02 01 `.H.e...... 0... 03 02 01 06 05 00 03 02 06 40 06 09 2A 86 48 86 [EMAIL PROTECTED] F7 0D 01 01 05 02 01 12 30 1A 02 01 04 02 01 40 ........0......@ 05 00 03 02 06 40 06 09 2A 86 48 86 F7 0D 01 01 [EMAIL PROTECTED] 0B 02 01 22 30 1A 02 01 05 02 01 01 05 00 03 02 ..."0........... 06 40 06 09 2A 86 48 86 F7 0D 01 01 90 00 [EMAIL PROTECTED] ====================================================================== card.c:311:sc_unlock: called iso7816.c:132:iso7816_read_binary: returning with: 252 card.c:429:sc_read_binary: returning with: 252 card.c:398:sc_read_binary: called; 32 bytes at index 252 apdu.c:504:sc_transmit_apdu: called apdu.c:184:sc_apdu_log: Outgoing APDU data [ 5 bytes] ===================================== 00 B0 00 FC 20 .... ====================================================================== apdu.c:184:sc_apdu_log: Incoming APDU data [ 34 bytes] ===================================== 01 02 01 02 30 1A 02 01 06 02 01 01 05 00 03 02 ....0........... 02 04 06 09 2A 86 48 86 F7 0D 01 01 01 02 01 1A ....*.H......... 90 00 .. ====================================================================== card.c:311:sc_unlock: called iso7816.c:132:iso7816_read_binary: returning with: 32 card.c:429:sc_read_binary: returning with: 32 card.c:311:sc_unlock: called card.c:426:sc_read_binary: returning with: 284 asn1.c:1064:asn1_decode: called, left=284, depth 0 asn1.c:1089:asn1_decode: Looking for 'TokenInfo', tag 0x1000010 asn1.c:888:asn1_decode_entry: decoding 'TokenInfo' asn1.c:1064:asn1_decode: called, left=280, depth 1 asn1.c:1089:asn1_decode: Looking for 'version', tag 0x2 asn1.c:888:asn1_decode_entry: decoding 'version' asn1.c:1089:asn1_decode: Looking for 'serialNumber', tag 0x4, OPTIONAL asn1.c:1105:asn1_decode: not present asn1.c:1089:asn1_decode: Looking for 'manufacturerID', tag 0xc, OPTIONAL asn1.c:1105:asn1_decode: not present asn1.c:1089:asn1_decode: Looking for 'label', tag 0x20000000, OPTIONAL asn1.c:888:asn1_decode_entry: decoding 'label' asn1.c:1089:asn1_decode: Looking for 'label-tw', tag 0x21000000, OPTIONAL asn1.c:1105:asn1_decode: not present asn1.c:1089:asn1_decode: Looking for 'tokenflags', tag 0x3 asn1.c:888:asn1_decode_entry: decoding 'tokenflags' asn1.c:1089:asn1_decode: Looking for 'seInfo', tag 0x1000010, OPTIONAL asn1.c:888:asn1_decode_entry: decoding 'seInfo' asn1.c:1039:asn1_decode_entry: invalid ASN.1 type: 16 asn1.c:1044:asn1_decode_entry: decoding of ASN.1 object 'TokenInfo' failed: Invalid ASN.1 object pkcs15.c:99:sc_pkcs15_parse_tokeninfo: ASN.1 parsing of EF(TokenInfo) failed: Invalid ASN.1 object I am not yet an ASN.1 expert :-) so help is very welcome here. I would first like to skip the optional field to see how far I can go. Implementing a proper decoding of the field will be done later. What I did is: --- libopensc/asn1.c (révision 3040) +++ libopensc/asn1.c (copie de travail) @@ -1018,6 +1035,11 @@ static int asn1_decode_entry(sc_context_ if (entry->parm != NULL) r = callback_func(ctx, entry->arg, obj, objlen, depth); break; + case SC_ASN1_SEQUENCE: + if (parm != NULL) + r = asn1_decode(ctx, (struct sc_asn1_entry *) parm, obj, + objlen, NULL, NULL, 0, depth + 1); + break; default: sc_error(ctx, "invalid ASN.1 type: %d\n", entry->type); return SC_ERROR_INVALID_ASN1_OBJECT; and the code does not crash. But I have no idea if it is a correct to skip the field or not. Is my patch harmful? Thanks -- Dr. Ludovic Rousseau _______________________________________________ opensc-devel mailing list opensc-devel@lists.opensc-project.org http://www.opensc-project.org/mailman/listinfo/opensc-devel