aboutsummaryrefslogtreecommitdiffstats
path: root/tools/card-call-scd.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2019-02-13 08:46:36 +0000
committerWerner Koch <[email protected]>2019-02-13 08:49:07 +0000
commit7e1cd2cd416f852fc039af310e3df1ce395d89a9 (patch)
tree10e09c9a4f15399f674ea055bb1c99983f0f3333 /tools/card-call-scd.c
parentscd: Implement decryption for PIV cards. (diff)
downloadgnupg-7e1cd2cd416f852fc039af310e3df1ce395d89a9.tar.gz
gnupg-7e1cd2cd416f852fc039af310e3df1ce395d89a9.zip
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 <[email protected]>
Diffstat (limited to 'tools/card-call-scd.c')
-rw-r--r--tools/card-call-scd.c18
1 files changed, 16 insertions, 2 deletions
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);
}