aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2019-08-21 13:26:34 +0000
committerWerner Koch <[email protected]>2019-08-21 13:26:34 +0000
commitce403c74dbc9c027b823910f22338269e625f76f (patch)
tree91da3e514381ddb2b8d0a24783a0c6da1cac194c
parentscd:nks: Extend keypairinfo with usage flags. (diff)
downloadgnupg-ce403c74dbc9c027b823910f22338269e625f76f.tar.gz
gnupg-ce403c74dbc9c027b823910f22338269e625f76f.zip
gpg: In a list of card keys show the standard keys.
* g10/keygen.c (ask_algo): Identify the standard keys. -- The asterisks mark the usages of a key as retruned by scd via the $AUTHKEYID et al. attributes. Signed-off-by: Werner Koch <[email protected]>
-rw-r--r--doc/help.txt8
-rw-r--r--g10/keygen.c22
2 files changed, 27 insertions, 3 deletions
diff --git a/doc/help.txt b/doc/help.txt
index 38f25cd3e..4d748c4e7 100644
--- a/doc/help.txt
+++ b/doc/help.txt
@@ -133,6 +133,14 @@ encryption. This algorithm should only be used in certain domains.
Please consult your security expert first.
.
+.gpg.keygen.cardkey
+Select which key from the card shall be used.
+
+The listing shows the selection index, the keygrip (a string of hex
+digits), the card specific key reference, the algorithm used for this
+key, and in parentheses the usage of the key (cert, sign, auth, encr).
+If known the standard usage for a key is marked with an asterisk.
+.
.gpg.keygen.flags
Toggle the capabilities of the key.
diff --git a/g10/keygen.c b/g10/keygen.c
index d9037d29d..bd02b631f 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -2268,6 +2268,12 @@ ask_algo (ctrl_t ctrl, int addmode, int *r_subkey_algo, unsigned int *r_usage,
do
{
+ char *authkeyref, *encrkeyref, *signkeyref;
+
+ agent_scd_getattr_one ("$AUTHKEYID", &authkeyref);
+ agent_scd_getattr_one ("$ENCRKEYID", &encrkeyref);
+ agent_scd_getattr_one ("$SIGNKEYID", &signkeyref);
+
tty_printf (_("Available keys:\n"));
for (count=1,sl=keypairlist; sl; sl = sl->next, count++)
{
@@ -2308,17 +2314,23 @@ ask_algo (ctrl_t ctrl, int addmode, int *r_subkey_algo, unsigned int *r_usage,
}
if ((sl->flags & GCRY_PK_USAGE_SIGN))
{
- tty_printf ("%ssign", any?",":" (");
+ tty_printf ("%ssign%s", any?",":" (",
+ (signkeyref && keyref
+ && !strcmp (signkeyref, keyref))? "*":"");
any = 1;
}
if ((sl->flags & GCRY_PK_USAGE_AUTH))
{
- tty_printf ("%sauth", any?",":" (");
+ tty_printf ("%sauth%s", any?",":" (",
+ (authkeyref && keyref
+ && !strcmp (authkeyref, keyref))? "*":"");
any = 1;
}
if ((sl->flags & GCRY_PK_USAGE_ENCR))
{
- tty_printf ("%sencr", any?",":" (");
+ tty_printf ("%sencr%s", any?",":" (",
+ (encrkeyref && keyref
+ && !strcmp (encrkeyref, keyref))? "*":"");
any = 1;
}
tty_printf ("%s\n", any?")":"");
@@ -2330,6 +2342,10 @@ ask_algo (ctrl_t ctrl, int addmode, int *r_subkey_algo, unsigned int *r_usage,
cpr_kill_prompt ();
trim_spaces (answer);
selection = atoi (answer);
+ xfree (authkeyref);
+ xfree (encrkeyref);
+ xfree (signkeyref);
+
}
while (!(selection > 0 && selection < count));