From fcd2e665fedf38ee633ff67ea7a3e3d24c6d96f4 Mon Sep 17 00:00:00 2001 From: Vincent JARDIN Date: Mon, 29 Mar 2021 16:45:07 +0000 Subject: [PATCH] IASECC/CPX: fix APDU errors for SE get data On a CPX, this object needs to be read from 3F00. For instance: $ opensc-explorer -r 2 OpenSC [3F00]> cd 0002 OpenSC [3F00/0002]> apdu 00 CB 3F FF 0A 4D 08 70 06 BF FB 05 02 7B 80 Sending: 00 CB 3F FF 0A 4D 08 70 06 BF FB 05 02 7B 80 Received (SW1=0x6A, SW2=0x88) Failure: Data object not found OpenSC [3F00/0002]> apdu 00 A4 09 04 02 3F 00 Sending: 00 A4 09 04 02 3F 00 Received (SW1=0x90, SW2=0x00) Success! OpenSC [3F00/0002]> apdu 00 CB 3F FF 0A 4D 08 70 06 BF FB 05 02 7B 80 Sending: 00 CB 3F FF 0A 4D 08 70 06 BF FB 05 02 7B 80 Received (SW1=0x90, SW2=0x00) Success! Currently, this patch limits to the CPX cards since I cannot know the behaviour for the other cards. I could not find any reference from the standard. Fix: issue #2275 --- src/libopensc/card-iasecc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libopensc/card-iasecc.c b/src/libopensc/card-iasecc.c index 8c5d17e1..043661b1 100644 --- a/src/libopensc/card-iasecc.c +++ b/src/libopensc/card-iasecc.c @@ -1714,6 +1714,11 @@ iasecc_se_get_info(struct sc_card *card, struct iasecc_se_info *se) LOG_FUNC_CALLED(ctx); + if (iasecc_is_cpx(card)) { + rv = iasecc_select_mf(card, NULL); + LOG_TEST_RET(ctx, rv, "MF invalid"); + } + if (se->reference > IASECC_SE_REF_MAX) LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);