63 N_(
"Name: "),
N_(
"aka: "),
N_(
"Valid From: "),
N_(
"Valid To: "),
64 N_(
"Key Type: "),
N_(
"Key Usage: "),
N_(
"Fingerprint: "),
N_(
"Serial-No: "),
65 N_(
"Issued By: "),
N_(
"Subkey: ")
85static void print_utf8(FILE *fp,
const char *buf,
size_t len)
88 memcpy(tstr, buf, len);
112 for (; dn->
key; dn++)
132 static const char *
const stdpart[] = {
133 "CN",
"OU",
"O",
"STREET",
"L",
"ST",
"C", NULL,
138 for (
int i = 0; stdpart[i]; i++)
145 for (; dn->
key; dn++)
148 for (i = 0; stdpart[i]; i++)
177 const char *s = NULL, *s1 = NULL;
182 for (s = str + 1; (s[0] !=
'\0') && (s[0] !=
'='); s++)
202 if ((n == 0) || (n & 1))
206 array->
value = (
char *) p;
207 for (s1 = str; n > 0; s1 += 2, n--)
208 sscanf(s1,
"%2hhx", (
unsigned char *) p++);
213 for (n = 0, s = str; *s; s++)
218 if ((*s ==
',') || (*s ==
'=') || (*s ==
'+') || (*s ==
'<') || (*s ==
'>') ||
219 (*s ==
'#') || (*s ==
';') || (*s ==
'\\') || (*s ==
'\"') || (*s ==
' '))
237 else if ((*s ==
',') || (*s ==
'=') || (*s ==
'+') || (*s ==
'<') ||
238 (*s ==
'>') || (*s ==
'#') || (*s ==
';'))
249 array->
value = (
char *) p;
250 for (s = str; n > 0; s++, n--)
257 sscanf(s,
"%2hhx", (
unsigned char *) p++);
286 size_t arrayidx, arraysize;
293 while (str[0] ==
' ')
297 if (arrayidx >= arraysize)
302 for (
int i = 0; i < arrayidx; i++)
310 array[arrayidx].
key = NULL;
311 array[arrayidx].
value = NULL;
316 while (str[0] ==
' ')
318 if ((str[0] !=
'\0') && (str[0] !=
',') && (str[0] !=
';') && (str[0] !=
'+'))
323 array[arrayidx].
key = NULL;
324 array[arrayidx].
value = NULL;
328 for (
int i = 0; i < arrayidx; i++)
347 const char *s = NULL;
351 s = strchr(userid + 1,
'>');
355 else if (*userid ==
'(')
357 fputs(
_(
"[Can't display this user ID (unknown encoding)]"), fp);
361 fputs(
_(
"[Can't display this user ID (invalid encoding)]"), fp);
369 for (
int i = 0; dn[i].
key; i++)
378 fputs(
_(
"[Can't display this user ID (invalid DN)]"), fp);
391 const char *s = NULL, *s2 = NULL;
393 char shortbuf[128] = { 0 };
394 unsigned long aval = 0;
395 const char *delim = NULL;
396 gpgme_user_id_t uid = NULL;
397 static int max_header_width = 0;
399 if (max_header_width == 0)
401 for (
int i = 0; i <
KIP_MAX; i++)
405 if (max_header_width < width)
406 max_header_width = width;
409 for (
int i = 0; i <
KIP_MAX; i++)
413 bool is_pgp = (
key->protocol == GPGME_PROTOCOL_OpenPGP);
415 for (idx = 0, uid =
key->uids; uid; idx++, uid = uid->next)
430 fputs(
_(
"[Invalid]"), fp);
440 if (
key->subkeys && (
key->subkeys->timestamp > 0))
442 tt =
key->subkeys->timestamp;
449 if (
key->subkeys && (
key->subkeys->expires > 0))
451 tt =
key->subkeys->expires;
459 s = gpgme_pubkey_algo_name(
key->subkeys->pubkey_algo);
463 s2 = is_pgp ?
"PGP" :
"X.509";
466 aval =
key->subkeys->length;
470 fprintf(fp, ngettext(
"%s, %lu bit %s\n",
"%s, %lu bit %s\n", aval), s2, aval, s);
478 fprintf(fp,
"%s%s", delim,
_(
"encryption"));
484 fprintf(fp,
"%s%s", delim,
_(
"signing"));
490 fprintf(fp,
"%s%s", delim,
_(
"certification"));
496 s =
key->subkeys->fpr;
498 if (is_pgp && (strlen(s) == 40))
500 for (
int i = 0; (s[0] !=
'\0') && (s[1] !=
'\0') && (s[2] !=
'\0') &&
501 (s[3] !=
'\0') && (s[4] !=
'\0');
515 for (
int i = 0; (s[0] !=
'\0') && (s[1] !=
'\0') && (s[2] !=
'\0'); s += 2, i++)
519 putc(is_pgp ?
' ' :
':', fp);
520 if (is_pgp && (i == 7))
524 fprintf(fp,
"%s\n", s);
527 if (
key->issuer_serial)
529 s =
key->issuer_serial;
534 if (
key->issuer_name)
536 s =
key->issuer_name;
545 gpgme_subkey_t subkey = NULL;
547 for (idx = 1, subkey =
key->subkeys; subkey; idx++, subkey = subkey->next)
559 fputs(
_(
"[Revoked]"), fp);
565 fputs(
_(
"[Invalid]"), fp);
571 fputs(
_(
"[Expired]"), fp);
573 if (subkey->disabled)
577 fputs(
_(
"[Disabled]"), fp);
581 if (subkey->timestamp > 0)
583 tt = subkey->timestamp;
590 if (subkey->expires > 0)
592 tt = subkey->expires;
599 s = gpgme_pubkey_algo_name(subkey->pubkey_algo);
601 aval = subkey->length;
605 fprintf(fp, ngettext(
"%s, %lu bit %s\n",
"%s, %lu bit %s\n", aval),
"PGP", aval, s);
610 if (subkey->can_encrypt)
612 fprintf(fp,
"%s%s", delim,
_(
"encryption"));
615 if (subkey->can_sign)
617 fprintf(fp,
"%s%s", delim,
_(
"signing"));
620 if (subkey->can_certify)
622 fprintf(fp,
"%s%s", delim,
_(
"certification"));
635 const char *s = NULL;
636 gpgme_ctx_t listctx = NULL;
637 gpgme_error_t err = GPG_ERR_NO_ERROR;
638 gpgme_key_t k = NULL;
657 while ((s = k->chain_id) && k->subkeys && !
mutt_str_equal(s, k->subkeys->fpr))
660 err = gpgme_op_keylist_start(listctx, s, 0);
663 if (err == GPG_ERR_NO_ERROR)
664 err = gpgme_op_keylist_next(listctx, &k);
665 if (err != GPG_ERR_NO_ERROR)
667 fprintf(fp,
_(
"Error finding issuer key: %s\n"), gpgme_strerror(err));
670 gpgme_op_keylist_end(listctx);
676 fputs(
_(
"Error: certification chain too long - stopping here\n"), fp);
683 gpgme_release(listctx);
686 char title[1024] = { 0 };
687 snprintf(title,
sizeof(title),
_(
"Key ID: 0x%s"),
crypt_keyid(key));
761 mutt_error(
_(
"This key can't be used: expired/disabled/revoked"));
768 const char *warn_s = NULL;
769 char buf2[1024] = { 0 };
773 warn_s =
_(
"ID is expired/disabled/revoked. Do you really want to use the key?");
780 case GPGME_VALIDITY_NEVER:
781 warn_s =
_(
"ID is not valid. Do you really want to use the key?");
783 case GPGME_VALIDITY_MARGINAL:
784 warn_s =
_(
"ID is only marginally valid. Do you really want to use the key?");
786 case GPGME_VALIDITY_FULL:
787 case GPGME_VALIDITY_ULTIMATE:
789 case GPGME_VALIDITY_UNKNOWN:
790 case GPGME_VALIDITY_UNDEFINED:
791 warn_s =
_(
"ID has undefined validity. Do you really want to use the key?");
796 snprintf(buf2,
sizeof(buf2),
"%s", warn_s);
861 if (!event || !dlg || !dlg->
wdata)
864 const int op =
event->op;
#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.
static int op_generic_select_entry(struct AliasMenuData *mdata, const struct KeyEvent *event)
select the current entry - Implements alias_function_t -
static int op_exit(struct AliasMenuData *mdata, const struct KeyEvent *event)
exit this menu - Implements alias_function_t -
int gpgme_function_dispatcher(struct MuttWindow *win, const struct KeyEvent *event)
Perform a Gpgme function - Implements function_dispatcher_t -.
static int op_generic_select_entry(struct GpgmeData *gd, const struct KeyEvent *event)
Select the current entry - Implements gpgme_function_t -.
static int op_exit(struct GpgmeData *gd, const struct KeyEvent *event)
Exit this menu - Implements gpgme_function_t -.
static int op_verify_key(struct GpgmeData *gd, const struct KeyEvent *event)
Verify a PGP public key - Implements gpgme_function_t -.
static int op_view_id(struct GpgmeData *gd, const struct KeyEvent *event)
View the key's user id - 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 FREE(x)
Free memory and set the pointer to NULL.
#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)
API for encryption/signing of emails.
#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.
gpgme_key_t kobj
GPGME key object.
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.
An event such as a keypress.
void * wdata
Private data.