mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-30 16:17:02 +01:00
gpg: Allow passing a keygrip as description to pinentry.
* g10/keydb.h (FORMAT_KEYDESC_KEYGRIP): New. * g10/passphrase.c (gpg_format_keydesc): Add new mode. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
da39102216
commit
ace15e1b09
@ -316,6 +316,7 @@ void emit_status_need_passphrase (ctrl_t ctrl, u32 *keyid,
|
||||
#define FORMAT_KEYDESC_IMPORT 1
|
||||
#define FORMAT_KEYDESC_EXPORT 2
|
||||
#define FORMAT_KEYDESC_DELKEY 3
|
||||
#define FORMAT_KEYDESC_KEYGRIP 4
|
||||
char *gpg_format_keydesc (ctrl_t ctrl,
|
||||
PKT_public_key *pk, int mode, int escaped);
|
||||
|
||||
|
@ -459,12 +459,23 @@ gpg_format_keydesc (ctrl_t ctrl, PKT_public_key *pk, int mode, int escaped)
|
||||
const char *trailer = "";
|
||||
int is_subkey;
|
||||
|
||||
is_subkey = (pk->main_keyid[0] && pk->main_keyid[1]
|
||||
&& pk->keyid[0] != pk->main_keyid[0]
|
||||
&& pk->keyid[1] != pk->main_keyid[1]);
|
||||
algo_name = openpgp_pk_algo_name (pk->pubkey_algo);
|
||||
timestr = strtimestamp (pk->timestamp);
|
||||
uid = get_user_id (ctrl, is_subkey? pk->main_keyid:pk->keyid, &uidlen, NULL);
|
||||
if (mode == FORMAT_KEYDESC_KEYGRIP)
|
||||
{
|
||||
is_subkey = 0;
|
||||
algo_name = NULL;
|
||||
timestr = NULL;
|
||||
uid = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
is_subkey = (pk->main_keyid[0] && pk->main_keyid[1]
|
||||
&& pk->keyid[0] != pk->main_keyid[0]
|
||||
&& pk->keyid[1] != pk->main_keyid[1]);
|
||||
algo_name = openpgp_pk_algo_name (pk->pubkey_algo);
|
||||
timestr = strtimestamp (pk->timestamp);
|
||||
uid = get_user_id (ctrl, is_subkey? pk->main_keyid:pk->keyid,
|
||||
&uidlen, NULL);
|
||||
}
|
||||
|
||||
orig_codeset = i18n_switchto_utf8 ();
|
||||
|
||||
@ -500,20 +511,30 @@ gpg_format_keydesc (ctrl_t ctrl, PKT_public_key *pk, int mode, int escaped)
|
||||
" OpenPGP secret key:");
|
||||
trailer = "?";
|
||||
break;
|
||||
case FORMAT_KEYDESC_KEYGRIP:
|
||||
prompt = _("Please enter the passphrase to export the"
|
||||
" secret key with keygrip:");
|
||||
break;
|
||||
default:
|
||||
prompt = "?";
|
||||
break;
|
||||
}
|
||||
|
||||
desc = xtryasprintf (_("%s\n"
|
||||
"\"%.*s\"\n"
|
||||
"%u-bit %s key, ID %s,\n"
|
||||
"created %s%s.\n%s"),
|
||||
prompt,
|
||||
(int)uidlen, uid,
|
||||
nbits_from_pk (pk), algo_name,
|
||||
keystr (pk->keyid), timestr,
|
||||
maink?maink:"", trailer);
|
||||
if (mode == FORMAT_KEYDESC_KEYGRIP)
|
||||
desc = xtryasprintf ("%s\n\n"
|
||||
" %s\n",
|
||||
prompt,
|
||||
"<keygrip>");
|
||||
else
|
||||
desc = xtryasprintf (_("%s\n"
|
||||
"\"%.*s\"\n"
|
||||
"%u-bit %s key, ID %s,\n"
|
||||
"created %s%s.\n%s"),
|
||||
prompt,
|
||||
(int)uidlen, uid,
|
||||
nbits_from_pk (pk), algo_name,
|
||||
keystr (pk->keyid), timestr,
|
||||
maink?maink:"", trailer);
|
||||
xfree (maink);
|
||||
xfree (uid);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user