Hi

> It seems to me that the card (or the relevant applet) is programmed to
> return 6A88 instead of 6A82. Just to be sure: what happens if you try
> opensc-explorer and try to cd to any non-existent DF with debug on,

Yes, the error code comes from the card. And just as you expected, 
opensc-exploring a non-existent DF will return the same SW.

OpenSC [3F00]> cd 1234
0xb77eb6c0 19:38:45.370 [opensc-explorer] card.c:571:sc_select_file: called; 
type=2, path=3f001234
0xb77eb6c0 19:38:45.370 [opensc-explorer] apdu.c:524:sc_transmit_apdu: called
0xb77eb6c0 19:38:45.370 [opensc-explorer] card.c:292:sc_lock: called
0xb77eb6c0 19:38:45.370 [opensc-explorer] reader-pcsc.c:241:pcsc_transmit: 
reader 'SCM SCR 331 [CCID Interface] (50400A7F) 00 00'
0xb77eb6c0 19:38:45.370 [opensc-explorer] apdu.c:184:sc_apdu_log:
Outgoing APDU data [    7 bytes] =====================================
00 A4 08 00 02 12 34 ......4
======================================================================
0xb77eb6c0 19:38:45.370 [opensc-explorer] 
reader-pcsc.c:174:pcsc_internal_transmit: called
0xb77eb6c0 19:38:45.407 [opensc-explorer] apdu.c:184:sc_apdu_log:
Incoming APDU data [    2 bytes] =====================================
6A 88 j.
======================================================================
0xb77eb6c0 19:38:45.408 [opensc-explorer] card.c:330:sc_unlock: called
0xb77eb6c0 19:38:45.408 [opensc-explorer] iso7816.c:103:iso7816_check_sw: 
Referenced data not found
0xb77eb6c0 19:38:45.408 [opensc-explorer] iso7816.c:484:iso7816_select_file: 
returning with: -1216 (Data object not found)
0xb77eb6c0 19:38:45.408 [opensc-explorer] card.c:597:sc_select_file: returning 
with: -1216 (Data object not found)
unable to select DF: Data object not found


> So I guess the best option is to constrain the number of possible
> error codes from sc_enum_apps and better document/define what it
> should do and what happens if it fails. Does the attached patch work
> for you?

The provided patch only works partially. The first error will pass 
(-1216 -> -1201) but it will still fail on the second one. Below is 
the resulting output from pkcs15-tool.
Do you need to patch card.c instead of dir.c?

...
0xb78528d0 19:49:28.378 [pkcs15-tool] card.c:571:sc_select_file: called; 
type=2, path=3f002f00
0xb78528d0 19:49:28.378 [pkcs15-tool] apdu.c:524:sc_transmit_apdu: called
0xb78528d0 19:49:28.378 [pkcs15-tool] card.c:292:sc_lock: called
0xb78528d0 19:49:28.378 [pkcs15-tool] reader-pcsc.c:241:pcsc_transmit: reader 
'SCM SCR 331 [CCID Interface] (50400A7F) 00 00'
0xb78528d0 19:49:28.378 [pkcs15-tool] apdu.c:184:sc_apdu_log:
Outgoing APDU data [    7 bytes] =====================================
00 A4 08 00 02 2F 00 ...../.
======================================================================
0xb78528d0 19:49:28.378 [pkcs15-tool] reader-pcsc.c:174:pcsc_internal_transmit: 
called
0xb78528d0 19:49:28.413 [pkcs15-tool] apdu.c:184:sc_apdu_log:
Incoming APDU data [    2 bytes] =====================================
6A 88 j.
======================================================================
0xb78528d0 19:49:28.413 [pkcs15-tool] card.c:330:sc_unlock: called
0xb78528d0 19:49:28.413 [pkcs15-tool] iso7816.c:103:iso7816_check_sw: 
Referenced data not found
0xb78528d0 19:49:28.413 [pkcs15-tool] iso7816.c:484:iso7816_select_file: 
returning with: -1216 (Data object not found)
0xb78528d0 19:49:28.413 [pkcs15-tool] card.c:597:sc_select_file: returning 
with: -1216 (Data object not found)
0xb78528d0 19:49:28.413 [pkcs15-tool] dir.c:154:sc_enum_apps: Cannot select 
EF.DIR file: -1201 (File not found)
0xb78528d0 19:49:28.413 [pkcs15-tool] pkcs15.c:759:sc_pkcs15_bind_internal: 
application path '3f005015'
0xb78528d0 19:49:28.413 [pkcs15-tool] card.c:571:sc_select_file: called; 
type=2, path=3f005015
0xb78528d0 19:49:28.413 [pkcs15-tool] apdu.c:524:sc_transmit_apdu: called
0xb78528d0 19:49:28.413 [pkcs15-tool] card.c:292:sc_lock: called
0xb78528d0 19:49:28.413 [pkcs15-tool] reader-pcsc.c:241:pcsc_transmit: reader 
'SCM SCR 331 [CCID Interface] (50400A7F) 00 00'
0xb78528d0 19:49:28.413 [pkcs15-tool] apdu.c:184:sc_apdu_log:
Outgoing APDU data [    7 bytes] =====================================
00 A4 08 00 02 50 15 .....P.
======================================================================
0xb78528d0 19:49:28.413 [pkcs15-tool] 
reader-pcsc.c:174:pcsc_internal_transmit: called
0xb78528d0 19:49:28.467 [pkcs15-tool] apdu.c:184:sc_apdu_log:
Incoming APDU data [    2 bytes] =====================================
6A 88 j.
======================================================================
0xb78528d0 19:49:28.467 [pkcs15-tool] card.c:330:sc_unlock: called
0xb78528d0 19:49:28.467 [pkcs15-tool] iso7816.c:103:iso7816_check_sw: 
Referenced data not found
0xb78528d0 19:49:28.467 [pkcs15-tool] iso7816.c:479:iso7816_select_file: 
returning with: -1216 (Data object not found)
0xb78528d0 19:49:28.467 [pkcs15-tool] card.c:597:sc_select_file: returning 
with: -1216 (Data object not found)
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-syn.c:125:sc_pkcs15_bind_synthetic: called
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-syn.c:166:sc_pkcs15_bind_synthetic: no emulator list in config file, 
trying all builtin emulators
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-syn.c:168:sc_pkcs15_bind_synthetic: trying westcos
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-westcos.c:257:sc_pkcs15emu_westcos_init_ex: sc_pkcs15_init_func_ex 
westcos
0xb78528d0 19:49:28.467 [pkcs15-tool] pkcs15-westcos.c:244:westcos_detect_card: 
westcos_detect_card (Unsupported card)
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-syn.c:168:sc_pkcs15_bind_synthetic: trying openpgp
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-syn.c:168:sc_pkcs15_bind_synthetic: trying infocamere
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-syn.c:168:sc_pkcs15_bind_synthetic: trying starcert
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-syn.c:168:sc_pkcs15_bind_synthetic: trying tcos
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-syn.c:168:sc_pkcs15_bind_synthetic: trying esteid
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-syn.c:168:sc_pkcs15_bind_synthetic: trying itacns
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-itacns.c:856:sc_pkcs15emu_itacns_init_ex: called
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-syn.c:168:sc_pkcs15_bind_synthetic: trying postecert
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-syn.c:168:sc_pkcs15_bind_synthetic: trying PIV-II
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-piv.c:1010:sc_pkcs15emu_piv_init_ex: called
0xb78528d0 19:49:28.467 [pkcs15-tool] pkcs15-piv.c:230:piv_detect_card: called
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-syn.c:168:sc_pkcs15_bind_synthetic: trying gemsafeGPK
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-gemsafeGPK.c:512:sc_pkcs15emu_gemsafeGPK_init_ex: Entering 
sc_pkcs15emu_gemsafeGPK_init_ex
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-gemsafeGPK.c:166:gemsafe_detect_card: called
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-syn.c:168:sc_pkcs15_bind_synthetic: trying gemsafeV1
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-syn.c:168:sc_pkcs15_bind_synthetic: trying actalis
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-syn.c:168:sc_pkcs15_bind_synthetic: trying atrust-acos
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-syn.c:168:sc_pkcs15_bind_synthetic: trying tccardos
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-syn.c:168:sc_pkcs15_bind_synthetic: trying entersafe
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-esinit.c:80:sc_pkcs15emu_entersafe_init_ex: called
0xb78528d0 19:49:28.467 [pkcs15-tool] pkcs15-esinit.c:36:entersafe_detect_card: 
called
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-syn.c:168:sc_pkcs15_bind_synthetic: trying pteid
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-syn.c:168:sc_pkcs15_bind_synthetic: trying oberthur
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-oberthur.c:1048:sc_pkcs15emu_oberthur_init_ex: called
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-oberthur.c:1035:oberthur_detect_card: called
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-oberthur.c:1037:oberthur_detect_card: returning with: -1413 (Unsupported 
card)
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-oberthur.c:1058:sc_pkcs15emu_oberthur_init_ex: returning with: -1413 
(Unsupported card)
0xb78528d0 19:49:28.467 [pkcs15-tool] 
pkcs15-syn.c:177:sc_pkcs15_bind_synthetic: searching for 'emulate foo { ... }' 
blocks
0xb78528d0 19:49:28.467 [pkcs15-tool] card.c:330:sc_unlock: called
0xb78528d0 19:49:28.467 [pkcs15-tool] pkcs15.c:960:sc_pkcs15_bind: returning 
with: -1413 (Unsupported card)
PKCS#15 binding failed: Unsupported card
...

- Thomas
_______________________________________________
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel

Reply via email to