mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +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>
(cherry picked from commit 70bb5c7931
)
This commit is contained in:
parent
11a65159f9
commit
9309175de8
6 changed files with 90 additions and 27 deletions
30
scd/apdu.c
30
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue