diff options
author | Werner Koch <[email protected]> | 2010-04-27 14:11:41 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2010-04-27 14:11:41 +0000 |
commit | 03d34be425a6473d3c95b3fe1f8f47177fde0919 (patch) | |
tree | e60fd4e4c77c400f270dc0abcb390112089367c0 /g10/passphrase.c | |
parent | Ignore a stale agent socket. (diff) | |
download | gnupg-03d34be425a6473d3c95b3fe1f8f47177fde0919.tar.gz gnupg-03d34be425a6473d3c95b3fe1f8f47177fde0919.zip |
Provide a useful pinentry prompt.
Diffstat (limited to 'g10/passphrase.c')
-rw-r--r-- | g10/passphrase.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/g10/passphrase.c b/g10/passphrase.c index ddd43d8d6..1ba76e602 100644 --- a/g10/passphrase.c +++ b/g10/passphrase.c @@ -683,3 +683,57 @@ passphrase_to_dek (u32 *keyid, int pubkey_algo, s2k, mode, tryagain_text, NULL, NULL, canceled); } + + +/* Return an allocated utf-8 string describing the key PK. IF ESCAPED + is true spaces and control characters are percent or plus + escaped. */ +char * +gpg_format_keydesc (PKT_public_key *pk, int escaped) +{ + char *uid; + size_t uidlen; + const char *algo_name; + const char *timestr; + char *orig_codeset; + char *maink; + char *desc; + + algo_name = gcry_pk_algo_name (pk->pubkey_algo); + if (!algo_name) + algo_name = "?"; + timestr = strtimestamp (pk->timestamp); + uid = get_user_id (pk->keyid, &uidlen); + + orig_codeset = i18n_switchto_utf8 (); + + if (pk->main_keyid[2] && pk->main_keyid[3] + && pk->keyid[0] != pk->main_keyid[2] + && pk->keyid[1] != pk->main_keyid[3]) + maink = xtryasprintf (_(" (main key ID %s)"), keystr (pk->main_keyid)); + else + maink = NULL; + + desc = xtryasprintf (_("Please enter the passphrase to unlock the" + " secret key for the OpenPGP certificate:\n" + "\"%.*s\"\n" + "%u-bit %s key, ID %s,\n" + "created %s%s.\n"), + (int)uidlen, uid, + nbits_from_pk (pk), algo_name, + keystr (pk->keyid), timestr, + maink?maink:"" ); + xfree (maink); + xfree (uid); + + i18n_switchback (orig_codeset); + + if (escaped) + { + char *tmp = percent_plus_escape (desc); + xfree (desc); + desc = tmp; + } + + return desc; +} |