aboutsummaryrefslogtreecommitdiffstats
path: root/g10
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2014-09-26 12:43:48 +0000
committerWerner Koch <[email protected]>2014-09-26 12:43:48 +0000
commit7ff4ea2160e87a16bf701552d3b9c7ab1c42f9ec (patch)
tree947773e5376ae887cec1bb75df7e91912e83295b /g10
parentgpg: Do not always print dashes in obsolete_option. (diff)
downloadgnupg-7ff4ea2160e87a16bf701552d3b9c7ab1c42f9ec.tar.gz
gnupg-7ff4ea2160e87a16bf701552d3b9c7ab1c42f9ec.zip
gpg: Add shortcut for setting key capabilities.
* g10/keygen.c (ask_key_flags): Add shortcut '='. * doc/help.txt (gpg.keygen.flags): New.
Diffstat (limited to 'g10')
-rw-r--r--g10/keygen.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/g10/keygen.c b/g10/keygen.c
index b6b50f621..4ec7f5048 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -1655,6 +1655,7 @@ ask_key_flags(int algo,int subkey)
*/
const char *togglers=_("SsEeAaQq");
char *answer=NULL;
+ const char *s;
unsigned int current=0;
unsigned int possible=openpgp_pk_algo_usage(algo);
@@ -1701,7 +1702,22 @@ ask_key_flags(int algo,int subkey)
answer = cpr_get("keygen.flags",_("Your selection? "));
cpr_kill_prompt();
- if(strlen(answer)>1)
+ if (*answer == '=')
+ {
+ /* Hack to allow direct entry of the capabilities. */
+ current = 0;
+ for (s=answer+1; *s; s++)
+ {
+ if ((*s == 's' || *s == 'S') && (possible&PUBKEY_USAGE_SIG))
+ current |= PUBKEY_USAGE_SIG;
+ else if ((*s == 'e' || *s == 'E') && (possible&PUBKEY_USAGE_ENC))
+ current |= PUBKEY_USAGE_ENC;
+ else if ((*s == 'a' || *s == 'A') && (possible&PUBKEY_USAGE_AUTH))
+ current |= PUBKEY_USAGE_AUTH;
+ }
+ break;
+ }
+ else if (strlen(answer)>1)
tty_printf(_("Invalid selection.\n"));
else if(*answer=='\0' || *answer==togglers[6] || *answer==togglers[7])
break;