aboutsummaryrefslogtreecommitdiffstats
path: root/scd/app-nks.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2019-04-03 15:31:09 +0000
committerWerner Koch <[email protected]>2019-04-03 15:31:39 +0000
commit679b8f1c045476bd6e0a1f1565379263143994ee (patch)
tree8d8ead53669ed3a151a391a6767d654d40eef87d /scd/app-nks.c
parentgpg: Allow decryption using PIV cards. (diff)
downloadgnupg-679b8f1c045476bd6e0a1f1565379263143994ee.tar.gz
gnupg-679b8f1c045476bd6e0a1f1565379263143994ee.zip
scd: New options --info and --info-only for READKEY.
* scd/command.c (cmd_readkey): New options --info and --info-only. * scd/app.c (app_readkey): New arg 'flags'. * scd/app-common.h (APP_READKEY_FLAG_INFO): New. (struct app_ctx_s): New args 'ctrl' and 'flags' for member readkey. Change all implementers. * scd/app-nks.c (do_readkey): Stub implementation of APP_READKEY_FLAG_INFO. * scd/app-openpgp.c (do_readkey): Implement APP_READKEY_FLAG_INFO. * scd/app-piv.c (do_readkey): Ditto. -- This feature allows to quickly get the keygrip and in most cases also the usage flags for one specific keyref. Example: <- readkey --info-only PIV.9D -> S KEYPAIRINFO FC6061FB457224370B85C6F34DD56CD29E669620 PIV.9D e -> OK Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'scd/app-nks.c')
-rw-r--r--scd/app-nks.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/scd/app-nks.c b/scd/app-nks.c
index 40c941616..2785ad014 100644
--- a/scd/app-nks.c
+++ b/scd/app-nks.c
@@ -618,7 +618,8 @@ do_readcert (app_t app, const char *certid,
certificate parsing code in commands.c:cmd_readkey. For internal
use PK and PKLEN may be NULL to just check for an existing key. */
static gpg_error_t
-do_readkey (app_t app, const char *keyid, unsigned char **pk, size_t *pklen)
+do_readkey (app_t app, ctrl_t ctrl, const char *keyid, unsigned int flags,
+ unsigned char **pk, size_t *pklen)
{
gpg_error_t err;
unsigned char *buffer[2];
@@ -653,6 +654,14 @@ do_readkey (app_t app, const char *keyid, unsigned char **pk, size_t *pklen)
return err;
}
+ if ((flags & APP_READKEY_FLAG_INFO))
+ {
+ /* Not yet implemented but we won't get here for any regular
+ * keyrefs anyway, thus the top layer will provide the
+ * keypairinfo from the certificate. */
+ (void)ctrl;
+ }
+
if (pk && pklen)
{
*pk = make_canon_sexp_from_rsa_pk (buffer[0], buflen[0],
@@ -698,7 +707,7 @@ do_writekey (app_t app, ctrl_t ctrl,
else
return gpg_error (GPG_ERR_INV_ID);
- if (!force && !do_readkey (app, keyid, NULL, NULL))
+ if (!force && !do_readkey (app, ctrl, keyid, 0, NULL, NULL))
return gpg_error (GPG_ERR_EEXIST);
/* Parse the S-expression. */