diff options
author | Werner Koch <[email protected]> | 2019-01-20 10:41:23 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2019-01-22 09:13:28 +0000 |
commit | 9309175de8c76de44021c25c7885355ff1a9b67b (patch) | |
tree | 14a82f519745a6eb62abf908f774ba624e006e63 /scd/apdu.c | |
parent | ssh: Simplify the curve name lookup. (diff) | |
download | gnupg-9309175de8c76de44021c25c7885355ff1a9b67b.tar.gz gnupg-9309175de8c76de44021c25c7885355ff1a9b67b.zip |
scd: One new and one improved 7816 function.
* scd/apdu.c (apdu_send_direct): New arg R_SW.
* scd/command.c (cmd_apdu): Ditto.
* scd/iso7816.c (iso7816_apdu_direct): New arg R_SW.
(iso7816_general_authenticate): New.
* scd/app-nks.c (get_chv_status, get_nks_version): Pass NULL for new
arg.
--
iso7816_general_authenticate will be used for the PIV card support.
The new arg to iso7816_apdu_direct and apdu_send_direct allows to get
the raw status word back without the need to handle an output buffer.
Signed-off-by: Werner Koch <[email protected]>
(cherry picked from commit 70bb5c7931598590b1acfae90bf4657f5911d2d3)
Diffstat (limited to '')
-rw-r--r-- | scd/apdu.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/scd/apdu.c b/scd/apdu.c index 7ed0b978b..af7757070 100644 --- a/scd/apdu.c +++ b/scd/apdu.c @@ -3062,19 +3062,25 @@ apdu_send_simple (int slot, int extended_mode, /* This is a more generic version of the apdu sending routine. It - takes an already formatted APDU in APDUDATA or length APDUDATALEN - and returns with an APDU including the status word. With - HANDLE_MORE set to true this function will handle the MORE DATA - status and return all APDUs concatenated with one status word at - the end. If EXTENDED_LENGTH is != 0 extended lengths are allowed - with a max. result data length of EXTENDED_LENGTH bytes. The - function does not return a regular status word but 0 on success. - If the slot is locked, the function returns immediately with an - error. */ + * takes an already formatted APDU in APDUDATA or length APDUDATALEN + * and returns with an APDU including the status word. With + * HANDLE_MORE set to true this function will handle the MORE DATA + * status and return all APDUs concatenated with one status word at + * the end. If EXTENDED_LENGTH is != 0 extended lengths are allowed + * with a max. result data length of EXTENDED_LENGTH bytes. The + * function does not return a regular status word but 0 on success. + * If the slot is locked, the function returns immediately with an + * error. + * + * Out of historical reasons the function returns 0 on success and + * outs the status word at the end of the result to be able to get the + * status word in the case of a not provided RETBUF, R_SW can be used + * to store the SW. But note that R_SW qill only be set if the + * function returns 0. */ int apdu_send_direct (int slot, size_t extended_length, const unsigned char *apdudata, size_t apdudatalen, - int handle_more, + int handle_more, unsigned int *r_sw, unsigned char **retbuf, size_t *retbuflen) { #define SHORT_RESULT_BUFFER_SIZE 258 @@ -3281,9 +3287,13 @@ apdu_send_direct (int slot, size_t extended_length, (*retbuf)[(*retbuflen)++] = sw; } + if (r_sw) + *r_sw = sw; + if (DBG_CARD_IO && retbuf) log_printhex (" dump: ", *retbuf, *retbuflen); + return 0; } |