62 N_(
"Name: "),
N_(
"aka: "),
N_(
"Valid From: "),
N_(
"Valid To: "),
63 N_(
"Key Type: "),
N_(
"Key Usage: "),
N_(
"Fingerprint: "),
N_(
"Serial-No: "),
64 N_(
"Issued By: "),
N_(
"Subkey: ")
84static void print_utf8(FILE *fp,
const char *buf,
size_t len)
87 memcpy(tstr, buf, len);
111 for (; dn->
key; dn++)
131 static const char *
const stdpart[] = {
132 "CN",
"OU",
"O",
"STREET",
"L",
"ST",
"C", NULL,
137 for (
int i = 0; stdpart[i]; i++)
144 for (; dn->
key; dn++)
147 for (i = 0; stdpart[i]; i++)
176 const char *s = NULL, *s1 = NULL;
181 for (s = str + 1; (s[0] !=
'\0') && (s[0] !=
'='); s++)
198 for (s = str; isxdigit(*s); s++)
201 if ((n == 0) || (n & 1))
205 array->
value = (
char *) p;
206 for (s1 = str; n; s1 += 2, n--)
207 sscanf(s1,
"%2hhx", (
unsigned char *) p++);
212 for (n = 0, s = str; *s; s++)
217 if ((*s ==
',') || (*s ==
'=') || (*s ==
'+') || (*s ==
'<') || (*s ==
'>') ||
218 (*s ==
'#') || (*s ==
';') || (*s ==
'\\') || (*s ==
'\"') || (*s ==
' '))
222 else if (isxdigit(s[0]) && isxdigit(s[1]))
236 else if ((*s ==
',') || (*s ==
'=') || (*s ==
'+') || (*s ==
'<') ||
237 (*s ==
'>') || (*s ==
'#') || (*s ==
';'))
248 array->
value = (
char *) p;
249 for (s = str; n; s++, n--)
256 sscanf(s,
"%2hhx", (
unsigned char *) p++);
285 size_t arrayidx, arraysize;
292 while (str[0] ==
' ')
296 if (arrayidx >= arraysize)
301 for (
int i = 0; i < arrayidx; i++)
309 array[arrayidx].
key = NULL;
310 array[arrayidx].
value = NULL;
315 while (str[0] ==
' ')
317 if ((str[0] !=
'\0') && (str[0] !=
',') && (str[0] !=
';') && (str[0] !=
'+'))
322 array[arrayidx].
key = NULL;
323 array[arrayidx].
value = NULL;
327 for (
int i = 0; i < arrayidx; i++)
346 const char *s = NULL;
350 s = strchr(userid + 1,
'>');
354 else if (*userid ==
'(')
356 fputs(
_(
"[Can't display this user ID (unknown encoding)]"), fp);
358 else if (!isalnum(userid[0]))
360 fputs(
_(
"[Can't display this user ID (invalid encoding)]"), fp);
368 for (
int i = 0; dn[i].
key; i++)
377 fputs(
_(
"[Can't display this user ID (invalid DN)]"), fp);
390 const char *s = NULL, *s2 = NULL;
392 char shortbuf[128] = { 0 };
393 unsigned long aval = 0;
394 const char *delim = NULL;
395 gpgme_user_id_t uid = NULL;
396 static int max_header_width = 0;
398 if (max_header_width == 0)
400 for (
int i = 0; i <
KIP_MAX; i++)
404 if (max_header_width < width)
405 max_header_width = width;
408 for (
int i = 0; i <
KIP_MAX; i++)
412 bool is_pgp = (
key->protocol == GPGME_PROTOCOL_OpenPGP);
414 for (idx = 0, uid =
key->uids; uid; idx++, uid = uid->next)
429 fputs(
_(
"[Invalid]"), fp);
439 if (
key->subkeys && (
key->subkeys->timestamp > 0))
441 tt =
key->subkeys->timestamp;
448 if (
key->subkeys && (
key->subkeys->expires > 0))
450 tt =
key->subkeys->expires;
458 s = gpgme_pubkey_algo_name(
key->subkeys->pubkey_algo);
462 s2 = is_pgp ?
"PGP" :
"X.509";
465 aval =
key->subkeys->length;
469 fprintf(fp, ngettext(
"%s, %lu bit %s\n",
"%s, %lu bit %s\n", aval), s2, aval, s);
477 fprintf(fp,
"%s%s", delim,
_(
"encryption"));
483 fprintf(fp,
"%s%s", delim,
_(
"signing"));
489 fprintf(fp,
"%s%s", delim,
_(
"certification"));
495 s =
key->subkeys->fpr;
497 if (is_pgp && (strlen(s) == 40))
499 for (
int i = 0; (s[0] !=
'\0') && (s[1] !=
'\0') && (s[2] !=
'\0') &&
500 (s[3] !=
'\0') && (s[4] !=
'\0');
514 for (
int i = 0; (s[0] !=
'\0') && (s[1] !=
'\0') && (s[2] !=
'\0'); s += 2, i++)
518 putc(is_pgp ?
' ' :
':', fp);
519 if (is_pgp && (i == 7))
523 fprintf(fp,
"%s\n", s);
526 if (
key->issuer_serial)
528 s =
key->issuer_serial;
533 if (
key->issuer_name)
535 s =
key->issuer_name;
544 gpgme_subkey_t subkey = NULL;
546 for (idx = 1, subkey =
key->subkeys; subkey; idx++, subkey = subkey->next)
558 fputs(
_(
"[Revoked]"), fp);
564 fputs(
_(
"[Invalid]"), fp);
570 fputs(
_(
"[Expired]"), fp);
572 if (subkey->disabled)
576 fputs(
_(
"[Disabled]"), fp);
580 if (subkey->timestamp > 0)
582 tt = subkey->timestamp;
589 if (subkey->expires > 0)
591 tt = subkey->expires;
598 s = gpgme_pubkey_algo_name(subkey->pubkey_algo);
600 aval = subkey->length;
604 fprintf(fp, ngettext(
"%s, %lu bit %s\n",
"%s, %lu bit %s\n", aval),
"PGP", aval, s);
609 if (subkey->can_encrypt)
611 fprintf(fp,
"%s%s", delim,
_(
"encryption"));
614 if (subkey->can_sign)
616 fprintf(fp,
"%s%s", delim,
_(
"signing"));
619 if (subkey->can_certify)
621 fprintf(fp,
"%s%s", delim,
_(
"certification"));
634 const char *s = NULL;
635 gpgme_ctx_t listctx = NULL;
636 gpgme_error_t err = GPG_ERR_NO_ERROR;
637 gpgme_key_t k = NULL;
656 while ((s = k->chain_id) && k->subkeys && !
mutt_str_equal(s, k->subkeys->fpr))
659 err = gpgme_op_keylist_start(listctx, s, 0);
662 if (err == GPG_ERR_NO_ERROR)
663 err = gpgme_op_keylist_next(listctx, &k);
664 if (err != GPG_ERR_NO_ERROR)
666 fprintf(fp,
_(
"Error finding issuer key: %s\n"), gpgme_strerror(err));
669 gpgme_op_keylist_end(listctx);
675 fputs(
_(
"Error: certification chain too long - stopping here\n"), fp);
682 gpgme_release(listctx);
685 char title[1024] = { 0 };
686 snprintf(title,
sizeof(title),
_(
"Key ID: 0x%s"),
crypt_keyid(key));
755 mutt_error(
_(
"This key can't be used: expired/disabled/revoked"));
762 const char *warn_s = NULL;
763 char buf2[1024] = { 0 };
767 warn_s =
_(
"ID is expired/disabled/revoked. Do you really want to use the key?");
774 case GPGME_VALIDITY_NEVER:
775 warn_s =
_(
"ID is not valid. Do you really want to use the key?");
777 case GPGME_VALIDITY_MARGINAL:
778 warn_s =
_(
"ID is only marginally valid. Do you really want to use the key?");
780 case GPGME_VALIDITY_FULL:
781 case GPGME_VALIDITY_ULTIMATE:
783 case GPGME_VALIDITY_UNKNOWN:
784 case GPGME_VALIDITY_UNDEFINED:
785 warn_s =
_(
"ID has undefined validity. Do you really want to use the key?");
790 snprintf(buf2,
sizeof(buf2),
"%s", warn_s);
847 if (!win || !win->
wdata)
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.
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.
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
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.
const char * uid
and for convenience point to this user ID
An X500 Distinguished Name.
Data to pass to the Gpgme Functions.
struct CryptKeyInfo * key
Selected Key.
struct CryptKeyInfo ** key_table
Array of Keys.
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.