diff options
author | Werner Koch <[email protected]> | 2021-06-16 18:29:47 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2023-02-17 11:02:35 +0000 |
commit | adf387b3f1ebd24e7031760be70c3251a50686f7 (patch) | |
tree | 733bdf5b6a6bcf06a119d89c7f58b4f88e3e3933 | |
parent | scd:p15: Handle cards with bad encoded path objects. (diff) | |
download | gnupg-adf387b3f1ebd24e7031760be70c3251a50686f7.tar.gz gnupg-adf387b3f1ebd24e7031760be70c3251a50686f7.zip |
scd: Improve reading of binary records.
* scd/iso7816.c (iso7816_read_binary_ext): Handle the 0x6a86 SW the
same as 6b00.
* scd/apdu.c (apdu_get_atr): Modify debug messages.
* scd/app-p15.c (app_select_p15): Print FCI on error.
(read_p15_info): Clean up diag in presence of debug options.
--
Some cards return 6a86 instead of 6b00.
Signed-off-by: Werner Koch <[email protected]>
Backported-from-master: 44f977d0e332e77fb8a775c4837c00118bbe08cb
-rw-r--r-- | scd/apdu.c | 11 | ||||
-rw-r--r-- | scd/app-p15.c | 2 | ||||
-rw-r--r-- | scd/iso7816.c | 2 |
3 files changed, 5 insertions, 10 deletions
diff --git a/scd/apdu.c b/scd/apdu.c index 9fb5cbee4..c18f6c9cf 100644 --- a/scd/apdu.c +++ b/scd/apdu.c @@ -2615,19 +2615,16 @@ apdu_get_atr (int slot, size_t *atrlen) { unsigned char *buf; - if (DBG_READER) - log_debug ("enter: apdu_get_atr: slot=%d\n", slot); - if (slot < 0 || slot >= MAX_READER || !reader_table[slot].used ) { if (DBG_READER) - log_debug ("leave: apdu_get_atr => NULL (bad slot)\n"); + log_debug ("apdu_get_atr => NULL (bad slot)\n"); return NULL; } if (!reader_table[slot].atrlen) { if (DBG_READER) - log_debug ("leave: apdu_get_atr => NULL (no ATR)\n"); + log_debug ("apdu_get_atr => NULL (no ATR)\n"); return NULL; } @@ -2635,13 +2632,11 @@ apdu_get_atr (int slot, size_t *atrlen) if (!buf) { if (DBG_READER) - log_debug ("leave: apdu_get_atr => NULL (out of core)\n"); + log_debug ("apdu_get_atr => NULL (out of core)\n"); return NULL; } memcpy (buf, reader_table[slot].atr, reader_table[slot].atrlen); *atrlen = reader_table[slot].atrlen; - if (DBG_READER) - log_debug ("leave: apdu_get_atr => atrlen=%zu\n", *atrlen); return buf; } diff --git a/scd/app-p15.c b/scd/app-p15.c index 131cc2cb7..fb27b1005 100644 --- a/scd/app-p15.c +++ b/scd/app-p15.c @@ -3906,8 +3906,8 @@ read_p15_info (app_t app) log_printf ("\n"); } - log_info ("p15: atr ..........: "); atr = apdu_get_atr (app_get_slot (app), &atrlen); + log_info ("p15: atr ..........: "); if (!atr) log_printf ("[error]\n"); else diff --git a/scd/iso7816.c b/scd/iso7816.c index 941b68d38..a0b53f45b 100644 --- a/scd/iso7816.c +++ b/scd/iso7816.c @@ -906,7 +906,7 @@ iso7816_read_binary_ext (int slot, int extended_mode, if (r_sw) *r_sw = sw; - if (*result && sw == SW_BAD_P0_P1) + if (*result && (sw == SW_BAD_P0_P1 || sw == SW_INCORRECT_P0_P1)) { /* Bad Parameter means that the offset is outside of the EF. When reading all data we take this as an indication |