From 7e1cd2cd416f852fc039af310e3df1ce395d89a9 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 13 Feb 2019 09:46:36 +0100 Subject: card: New command "yubikey". * tools/card-tool-yubikey.c: New. * tools/Makefile.am (gpg_card_tool_SOURCES): Add it. * tools/card-call-scd.c (scd_apdu): Allow returning data. * tools/card-tool-misc.c (send_apdu): New. Move from gpg-card-tool.c and let it return data. Change all callers. * tools/gpg-card-tool.c (cmd_writecert): Prepend the certref with the current application type. (cmd_yubikey): New. -- This command allows listing of active applications and to enable or disable selected applications. This is in particular useful to disable the OpenPGP application so that the PIV support can easily be tested. Signed-off-by: Werner Koch --- tools/card-call-scd.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'tools/card-call-scd.c') diff --git a/tools/card-call-scd.c b/tools/card-call-scd.c index 97fb6d9f1..8610da8b6 100644 --- a/tools/card-call-scd.c +++ b/tools/card-call-scd.c @@ -445,12 +445,20 @@ store_serialno (const char *line) /* Send an APDU to the current card. On success the status word is * stored at R_SW inless R_SW is NULL. With HEXAPDU being NULL only a * RESET command is send to scd. With HEXAPDU being the string - * "undefined" the command "SERIALNO undefined" is send to scd. */ + * "undefined" the command "SERIALNO undefined" is send to scd. If + * R_DATA is not NULL the data is without the status code is stored + * there. Caller must release it. */ gpg_error_t -scd_apdu (const char *hexapdu, unsigned int *r_sw) +scd_apdu (const char *hexapdu, unsigned int *r_sw, + unsigned char **r_data, size_t *r_datalen) { gpg_error_t err; + if (r_data) + *r_data = NULL; + if (r_datalen) + *r_datalen = 0; + err = start_agent (START_AGENT_NO_STARTUP_CMDS); if (err) return err; @@ -489,6 +497,12 @@ scd_apdu (const char *hexapdu, unsigned int *r_sw) { if (r_sw) *r_sw = buf16_to_uint (data+datalen-2); + if (r_data && r_datalen) + { + *r_data = data; + *r_datalen = datalen - 2; + data = NULL; + } } xfree (data); } -- cgit v1.2.3