mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
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 <wk@gnupg.org>
This commit is contained in:
parent
43b14b4cc2
commit
7e1cd2cd41
6 changed files with 580 additions and 50 deletions
|
@ -77,3 +77,37 @@ hex_to_buffer (const char *string, size_t *r_length)
|
|||
*r_length = n;
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
/* Direct sending of an hex encoded APDU with error printing. This is
|
||||
* a simple wrapper around scd_apdu. */
|
||||
gpg_error_t
|
||||
send_apdu (const char *hexapdu, const char *desc, unsigned int ignore,
|
||||
unsigned char **r_data, size_t *r_datalen)
|
||||
{
|
||||
gpg_error_t err;
|
||||
unsigned int sw;
|
||||
|
||||
err = scd_apdu (hexapdu, &sw, r_data, r_datalen);
|
||||
if (err)
|
||||
log_error ("sending card command %s failed: %s\n", desc,
|
||||
gpg_strerror (err));
|
||||
else if (!hexapdu || !strcmp (hexapdu, "undefined"))
|
||||
;
|
||||
else if (ignore == 0xffff)
|
||||
; /* Ignore all status words. */
|
||||
else if (sw != 0x9000)
|
||||
{
|
||||
switch (sw)
|
||||
{
|
||||
case 0x6285: err = gpg_error (GPG_ERR_OBJ_TERM_STATE); break;
|
||||
case 0x6982: err = gpg_error (GPG_ERR_BAD_PIN); break;
|
||||
case 0x6985: err = gpg_error (GPG_ERR_USE_CONDITIONS); break;
|
||||
default: err = gpg_error (GPG_ERR_CARD);
|
||||
}
|
||||
if (!(ignore && ignore == sw))
|
||||
log_error ("card command %s failed: %s (0x%04x)\n", desc,
|
||||
gpg_strerror (err), sw);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue