61 N_(
"Name: "),
N_(
"aka: "),
N_(
"Valid From: "),
N_(
"Valid To: "),
62 N_(
"Key Type: "),
N_(
"Key Usage: "),
N_(
"Fingerprint: "),
N_(
"Serial-No: "),
63 N_(
"Issued By: "),
N_(
"Subkey: ")
83static void print_utf8(FILE *fp,
const char *buf,
size_t len)
86 memcpy(tstr, buf, len);
110 for (; dn->
key; dn++)
130 static const char *
const stdpart[] = {
131 "CN",
"OU",
"O",
"STREET",
"L",
"ST",
"C", NULL,
136 for (
int i = 0; stdpart[i]; i++)
143 for (; dn->
key; dn++)
146 for (i = 0; stdpart[i]; i++)
175 const char *s = NULL, *s1 = NULL;
180 for (s = str + 1; (s[0] !=
'\0') && (s[0] !=
'='); s++)
200 if ((n == 0) || (n & 1))
204 array->
value = (
char *) p;
205 for (s1 = str; n > 0; s1 += 2, n--)
206 sscanf(s1,
"%2hhx", (
unsigned char *) p++);
211 for (n = 0, s = str; *s; s++)
216 if ((*s ==
',') || (*s ==
'=') || (*s ==
'+') || (*s ==
'<') || (*s ==
'>') ||
217 (*s ==
'#') || (*s ==
';') || (*s ==
'\\') || (*s ==
'\"') || (*s ==
' '))
235 else if ((*s ==
',') || (*s ==
'=') || (*s ==
'+') || (*s ==
'<') ||
236 (*s ==
'>') || (*s ==
'#') || (*s ==
';'))
247 array->
value = (
char *) p;
248 for (s = str; n > 0; s++, n--)
255 sscanf(s,
"%2hhx", (
unsigned char *) p++);
284 size_t arrayidx, arraysize;
291 while (str[0] ==
' ')
295 if (arrayidx >= arraysize)
300 for (
int i = 0; i < arrayidx; i++)
308 array[arrayidx].
key = NULL;
309 array[arrayidx].
value = NULL;
314 while (str[0] ==
' ')
316 if ((str[0] !=
'\0') && (str[0] !=
',') && (str[0] !=
';') && (str[0] !=
'+'))
321 array[arrayidx].
key = NULL;
322 array[arrayidx].
value = NULL;
326 for (
int i = 0; i < arrayidx; i++)
345 const char *s = NULL;
349 s = strchr(userid + 1,
'>');
353 else if (*userid ==
'(')
355 fputs(
_(
"[Can't display this user ID (unknown encoding)]"), fp);
359 fputs(
_(
"[Can't display this user ID (invalid encoding)]"), fp);
367 for (
int i = 0; dn[i].
key; i++)
376 fputs(
_(
"[Can't display this user ID (invalid DN)]"), fp);
389 const char *s = NULL, *s2 = NULL;
391 char shortbuf[128] = { 0 };
392 unsigned long aval = 0;
393 const char *delim = NULL;
394 gpgme_user_id_t uid = NULL;
395 static int max_header_width = 0;
397 if (max_header_width == 0)
399 for (
int i = 0; i <
KIP_MAX; i++)
403 if (max_header_width < width)
404 max_header_width = width;
407 for (
int i = 0; i <
KIP_MAX; i++)
411 bool is_pgp = (
key->protocol == GPGME_PROTOCOL_OpenPGP);
413 for (idx = 0, uid =
key->uids; uid; idx++, uid = uid->next)
428 fputs(
_(
"[Invalid]"), fp);
438 if (
key->subkeys && (
key->subkeys->timestamp > 0))
440 tt =
key->subkeys->timestamp;
447 if (
key->subkeys && (
key->subkeys->expires > 0))
449 tt =
key->subkeys->expires;
457 s = gpgme_pubkey_algo_name(
key->subkeys->pubkey_algo);
461 s2 = is_pgp ?
"PGP" :
"X.509";
464 aval =
key->subkeys->length;
468 fprintf(fp, ngettext(
"%s, %lu bit %s\n",
"%s, %lu bit %s\n", aval), s2, aval, s);
476 fprintf(fp,
"%s%s", delim,
_(
"encryption"));
482 fprintf(fp,
"%s%s", delim,
_(
"signing"));
488 fprintf(fp,
"%s%s", delim,
_(
"certification"));
494 s =
key->subkeys->fpr;
496 if (is_pgp && (strlen(s) == 40))
498 for (
int i = 0; (s[0] !=
'\0') && (s[1] !=
'\0') && (s[2] !=
'\0') &&
499 (s[3] !=
'\0') && (s[4] !=
'\0');
513 for (
int i = 0; (s[0] !=
'\0') && (s[1] !=
'\0') && (s[2] !=
'\0'); s += 2, i++)
517 putc(is_pgp ?
' ' :
':', fp);
518 if (is_pgp && (i == 7))
522 fprintf(fp,
"%s\n", s);
525 if (
key->issuer_serial)
527 s =
key->issuer_serial;
532 if (
key->issuer_name)
534 s =
key->issuer_name;
543 gpgme_subkey_t subkey = NULL;
545 for (idx = 1, subkey =
key->subkeys; subkey; idx++, subkey = subkey->next)
557 fputs(
_(
"[Revoked]"), fp);
563 fputs(
_(
"[Invalid]"), fp);
569 fputs(
_(
"[Expired]"), fp);
571 if (subkey->disabled)
575 fputs(
_(
"[Disabled]"), fp);
579 if (subkey->timestamp > 0)
581 tt = subkey->timestamp;
588 if (subkey->expires > 0)
590 tt = subkey->expires;
597 s = gpgme_pubkey_algo_name(subkey->pubkey_algo);
599 aval = subkey->length;
603 fprintf(fp, ngettext(
"%s, %lu bit %s\n",
"%s, %lu bit %s\n", aval),
"PGP", aval, s);
608 if (subkey->can_encrypt)
610 fprintf(fp,
"%s%s", delim,
_(
"encryption"));
613 if (subkey->can_sign)
615 fprintf(fp,
"%s%s", delim,
_(
"signing"));
618 if (subkey->can_certify)
620 fprintf(fp,
"%s%s", delim,
_(
"certification"));
633 const char *s = NULL;
634 gpgme_ctx_t listctx = NULL;
635 gpgme_error_t err = GPG_ERR_NO_ERROR;
636 gpgme_key_t k = NULL;
655 while ((s = k->chain_id) && k->subkeys && !
mutt_str_equal(s, k->subkeys->fpr))
658 err = gpgme_op_keylist_start(listctx, s, 0);
661 if (err == GPG_ERR_NO_ERROR)
662 err = gpgme_op_keylist_next(listctx, &k);
663 if (err != GPG_ERR_NO_ERROR)
665 fprintf(fp,
_(
"Error finding issuer key: %s\n"), gpgme_strerror(err));
668 gpgme_op_keylist_end(listctx);
674 fputs(
_(
"Error: certification chain too long - stopping here\n"), fp);
681 gpgme_release(listctx);
684 char title[1024] = { 0 };
685 snprintf(title,
sizeof(title),
_(
"Key ID: 0x%s"),
crypt_keyid(key));
759 mutt_error(
_(
"This key can't be used: expired/disabled/revoked"));
766 const char *warn_s = NULL;
767 char buf2[1024] = { 0 };
771 warn_s =
_(
"ID is expired/disabled/revoked. Do you really want to use the key?");
778 case GPGME_VALIDITY_NEVER:
779 warn_s =
_(
"ID is not valid. Do you really want to use the key?");
781 case GPGME_VALIDITY_MARGINAL:
782 warn_s =
_(
"ID is only marginally valid. Do you really want to use the key?");
784 case GPGME_VALIDITY_FULL:
785 case GPGME_VALIDITY_ULTIMATE:
787 case GPGME_VALIDITY_UNKNOWN:
788 case GPGME_VALIDITY_UNDEFINED:
789 warn_s =
_(
"ID has undefined validity. Do you really want to use the key?");
794 snprintf(buf2,
sizeof(buf2),
"%s", warn_s);
859 if (!dlg || !dlg->
wdata)
#define ARRAY_GET(head, idx)
Return the element at index.
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Convenience wrapper for the config headers.
const char * cc_charset(void)
Get the cached value of $charset.
Convenience wrapper for the core headers.
struct CryptKeyInfo * crypt_copy_key(struct CryptKeyInfo *key)
Return a copy of KEY.
int crypt_id_is_valid(struct CryptKeyInfo *key)
Is key ID valid.
bool crypt_id_is_strong(struct CryptKeyInfo *key)
Is the key strong.
unsigned int key_check_cap(gpgme_key_t key, enum KeyCap cap)
Check the capabilities of a key.
const char * crypt_keyid(struct CryptKeyInfo *k)
Find the ID for the key.
Wrapper for PGP/SMIME calls to GPGME.
@ KIP_FINGERPRINT
PGP Key field: Fingerprint.
@ KIP_SERIAL_NO
PGP Key field: Serial number.
@ KIP_SUBKEY
PGP Key field: Subkey.
@ KIP_AKA
PGP Key field: aka (Also Known As)
@ KIP_VALID_FROM
PGP Key field: Valid From date.
@ KIP_KEY_TYPE
PGP Key field: Key Type.
@ KIP_NAME
PGP Key field: Name.
@ KIP_ISSUED_BY
PGP Key field: Issued By.
@ KIP_KEY_USAGE
PGP Key field: Key Usage.
@ KIP_VALID_TO
PGP Key field: Valid To date.
@ KEY_CAP_CAN_CERTIFY
Key can be used to certify.
@ KEY_CAP_CAN_ENCRYPT
Key can be used for encryption.
@ KEY_CAP_CAN_SIGN
Key can be used for signing.
bool mutt_isxdigit(int arg)
Wrapper for isxdigit(3)
bool mutt_isalnum(int arg)
Wrapper for isalnum(3)
size_t mutt_strwidth(const char *s)
Measure a string's width in screen cells.
struct MuttWindow * dialog_find(struct MuttWindow *win)
Find the parent Dialog of a Window.
const char * dispatcher_get_retval_name(int rv)
Get the name of a return value.
@ FR_SUCCESS
Valid function - successfully performed.
@ FR_UNKNOWN
Unknown function.
@ FR_ERROR
Valid function - error occurred.
@ FR_NO_ACTION
Valid function - no action performed.
#define mutt_file_fclose(FP)
#define mutt_file_fopen(PATH, MODE)
bool OptPgpCheckTrust
(pseudo) used by dlg_pgp()
static int create_gpgme_context(gpgme_ctx_t *ctx)
Create a GPGME context.
static const struct GpgmeFunction GpgmeFunctions[]
All the NeoMutt functions that the Gpgme supports.
static const char *const KeyInfoPrompts[]
Names of header fields used in the pgp key display, e.g. Name:, Fingerprint:
int KeyInfoPadding[KIP_MAX]
Number of padding spaces needed after each of the strings in KeyInfoPrompts after translation.
static void parse_and_print_user_id(FILE *fp, const char *userid)
Print a nice representation of the userid.
static struct DnArray * parse_dn(const char *str)
Parse a DN and return an array-ized one.
static void print_key_info(gpgme_key_t key, FILE *fp)
Verbose information about a key or certificate to a file.
static void print_utf8(FILE *fp, const char *buf, size_t len)
Write a UTF-8 string to a file.
static bool print_dn_part(FILE *fp, struct DnArray *dn, const char *key)
Print the X.500 Distinguished Name.
static bool crypt_key_is_valid(struct CryptKeyInfo *k)
Is the key valid.
bool crypt_keys_are_valid(struct CryptKeyInfo *keys)
Are all these keys valid?
static void verify_key(struct CryptKeyInfo *key)
Show detailed information about the selected key.
static void print_dn_parts(FILE *fp, struct DnArray *dn)
Print all parts of a DN in a standard sequence.
static const char * parse_dn_part(struct DnArray *array, const char *str)
Parse an RDN.
int gpgme_function_dispatcher(struct MuttWindow *win, int op)
Perform a Gpgme function - Implements function_dispatcher_t -.
static int op_exit(struct GpgmeData *gd, int op)
Exit this menu - Implements gpgme_function_t -.
static int op_generic_select_entry(struct GpgmeData *gd, int op)
Select the current entry - Implements gpgme_function_t -.
static int op_view_id(struct GpgmeData *gd, int op)
View the key's user id - Implements gpgme_function_t -.
static int op_verify_key(struct GpgmeData *gd, int op)
Verify a PGP public key - Implements gpgme_function_t -.
#define mutt_message(...)
#define mutt_debug(LEVEL,...)
Convenience wrapper for the gui headers.
@ LL_DEBUG1
Log at debug level 1.
#define MUTT_MEM_MALLOC(n, type)
int mutt_ch_convert_string(char **ps, const char *from, const char *to, uint8_t flags)
Convert a string between encodings.
#define MUTT_ICONV_NO_FLAGS
No flags are set.
size_t mutt_date_localtime_format(char *buf, size_t buflen, const char *format, time_t t)
Format localtime.
Convenience wrapper for the library headers.
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
#define KEYFLAG_ISX509
Key is an X.509 key.
const char * opcodes_get_name(int op)
Get the name of an opcode.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
@ MUTT_NO
User answered 'No', or assume 'No'.
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
enum QuadOption query_yesorno(const char *prompt, enum QuadOption def)
Ask the user a Yes/No question.
String manipulation buffer.
gpgme_validity_t validity
uid validity (cached for convenience)
KeyFlags flags
global and per uid flags (for convenience)
struct CryptKeyInfo * next
Linked list.
An X500 Distinguished Name.
Data to pass to the Gpgme Functions.
struct CryptKeyInfoArray * key_table
Array of Keys.
struct CryptKeyInfo * key
Selected Key.
bool done
Should we close the Dialog?
struct Menu * menu
Gpgme Menu.
gpgme_function_t function
Function to call.
int op
Op code, e.g. OP_GENERIC_SELECT_ENTRY.
void * wdata
Private data.