1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-03-28 22:49:59 +01:00

gpg: Add shortcut for setting key capabilities.

* g10/keygen.c (ask_key_flags): Add shortcut '='.
* doc/help.txt (gpg.keygen.flags): New.
This commit is contained in:
Werner Koch 2014-09-26 14:43:48 +02:00
parent c76117f8b0
commit b9b6ac9d26
2 changed files with 42 additions and 11 deletions

View File

@ -134,6 +134,21 @@ Please consult your security expert first.
.
.gpg.keygen.flags
Toggle the capabilities of the key.
It is only possible to toggle those capabilities which are possible
for the selected algorithm.
To quickly set the capabilities all at once it is possible to enter a
'=' as first character followed by a list of letters indicating the
capability to set: 's' for signing, 'e' for encryption, and 'a' for
authentication. Invalid letters and impossible capabilities are
ignored. This submenu is immediately closed after using this
shortcut.
.
.gpg.keygen.size
Enter the size of the key.

View File

@ -1591,6 +1591,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);
@ -1637,7 +1638,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;