mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +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_IMPORT 1
|
||||||
#define FORMAT_KEYDESC_EXPORT 2
|
#define FORMAT_KEYDESC_EXPORT 2
|
||||||
#define FORMAT_KEYDESC_DELKEY 3
|
#define FORMAT_KEYDESC_DELKEY 3
|
||||||
|
#define FORMAT_KEYDESC_KEYGRIP 4
|
||||||
char *gpg_format_keydesc (ctrl_t ctrl,
|
char *gpg_format_keydesc (ctrl_t ctrl,
|
||||||
PKT_public_key *pk, int mode, int escaped);
|
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 = "";
|
const char *trailer = "";
|
||||||
int is_subkey;
|
int is_subkey;
|
||||||
|
|
||||||
is_subkey = (pk->main_keyid[0] && pk->main_keyid[1]
|
if (mode == FORMAT_KEYDESC_KEYGRIP)
|
||||||
&& pk->keyid[0] != pk->main_keyid[0]
|
{
|
||||||
&& pk->keyid[1] != pk->main_keyid[1]);
|
is_subkey = 0;
|
||||||
algo_name = openpgp_pk_algo_name (pk->pubkey_algo);
|
algo_name = NULL;
|
||||||
timestr = strtimestamp (pk->timestamp);
|
timestr = NULL;
|
||||||
uid = get_user_id (ctrl, is_subkey? pk->main_keyid:pk->keyid, &uidlen, 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 ();
|
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:");
|
" OpenPGP secret key:");
|
||||||
trailer = "?";
|
trailer = "?";
|
||||||
break;
|
break;
|
||||||
|
case FORMAT_KEYDESC_KEYGRIP:
|
||||||
|
prompt = _("Please enter the passphrase to export the"
|
||||||
|
" secret key with keygrip:");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
prompt = "?";
|
prompt = "?";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
desc = xtryasprintf (_("%s\n"
|
if (mode == FORMAT_KEYDESC_KEYGRIP)
|
||||||
"\"%.*s\"\n"
|
desc = xtryasprintf ("%s\n\n"
|
||||||
"%u-bit %s key, ID %s,\n"
|
" %s\n",
|
||||||
"created %s%s.\n%s"),
|
prompt,
|
||||||
prompt,
|
"<keygrip>");
|
||||||
(int)uidlen, uid,
|
else
|
||||||
nbits_from_pk (pk), algo_name,
|
desc = xtryasprintf (_("%s\n"
|
||||||
keystr (pk->keyid), timestr,
|
"\"%.*s\"\n"
|
||||||
maink?maink:"", trailer);
|
"%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 (maink);
|
||||||
xfree (uid);
|
xfree (uid);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user