diff options
author | Werner Koch <[email protected]> | 2020-08-27 09:55:37 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2020-08-27 09:55:37 +0000 |
commit | a0a4744bd0640e587b33ec3dae819ec4054f0472 (patch) | |
tree | ece157a3a81e47c197406159b8e1ce3a146787c8 /tools/card-call-scd.c | |
parent | scd: Fix reading of the ATR for card type detection. (diff) | |
download | gnupg-a0a4744bd0640e587b33ec3dae819ec4054f0472.tar.gz gnupg-a0a4744bd0640e587b33ec3dae819ec4054f0472.zip |
scd: New option to APDU command to return the ATR as data.
* scd/command.c (cmd_apdu): Add new option --data-atr.
* tools/gpg-card.c (cmd_apdu): Use that here. Also fix the --exlen
option and do not print the statusword in atr mode.
* tools/card-call-scd.c (scd_apdu): Detect atr mode anddon't assume a
status word.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'tools/card-call-scd.c')
-rw-r--r-- | tools/card-call-scd.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/tools/card-call-scd.c b/tools/card-call-scd.c index 8e029a2bf..160d9480e 100644 --- a/tools/card-call-scd.c +++ b/tools/card-call-scd.c @@ -485,9 +485,13 @@ scd_apdu (const char *hexapdu, const char *options, unsigned int *r_sw, membuf_t mb; unsigned char *data; size_t datalen; + int no_sw; init_membuf (&mb, 256); + no_sw = (options && (strstr (options, "--dump-atr") + || strstr (options, "--data-atr"))); + snprintf (line, DIM(line), "SCD APDU %s%s%s", options?options:"", options?" -- ":"", hexapdu); err = assuan_transact (agent_ctx, line, @@ -497,16 +501,16 @@ scd_apdu (const char *hexapdu, const char *options, unsigned int *r_sw, data = get_membuf (&mb, &datalen); if (!data) err = gpg_error_from_syserror (); - else if (datalen < 2) /* Ooops */ + else if (datalen < (no_sw?1:2)) /* Ooops */ err = gpg_error (GPG_ERR_CARD); else { if (r_sw) - *r_sw = buf16_to_uint (data+datalen-2); + *r_sw = no_sw? 0 : buf16_to_uint (data+datalen-2); if (r_data && r_datalen) { *r_data = data; - *r_datalen = datalen - 2; + *r_datalen = datalen - (no_sw?0:2); data = NULL; } } |