mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
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 <wk@gnupg.org>
This commit is contained in:
parent
d93797c8a7
commit
70bb5c7931
6 changed files with 90 additions and 27 deletions
30
scd/apdu.c
30
scd/apdu.c
|
@ -3063,19 +3063,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
|
||||
|
@ -3282,9 +3288,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 (*retbuf, *retbuflen, " dump: ");
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue