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);
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;
470 fprintf(fp, ngettext(
"%s, %lu bit %s\n",
"%s, %lu bit %s\n", aval), s2, aval, s);
479 fprintf(fp,
"%s%s", delim,
_(
"encryption"));
485 fprintf(fp,
"%s%s", delim,
_(
"signing"));
491 fprintf(fp,
"%s%s", delim,
_(
"certification"));
497 s = key->subkeys->fpr;
500 if (is_pgp && (strlen(s) == 40))
502 for (
int i = 0; (s[0] !=
'\0') && (s[1] !=
'\0') && (s[2] !=
'\0') &&
503 (s[3] !=
'\0') && (s[4] !=
'\0');
517 for (
int i = 0; (s[0] !=
'\0') && (s[1] !=
'\0') && (s[2] !=
'\0'); s += 2, i++)
521 putc(is_pgp ?
' ' :
':', fp);
522 if (is_pgp && (i == 7))
526 fprintf(fp,
"%s\n", s);
529 if (key->issuer_serial)
531 s = key->issuer_serial;
536 if (key->issuer_name)
538 s = key->issuer_name;
548 gpgme_subkey_t subkey = NULL;
550 for (idx = 1, subkey = key->subkeys; subkey; idx++, subkey = subkey->next)
563 fputs(
_(
"[Revoked]"), fp);
569 fputs(
_(
"[Invalid]"), fp);
575 fputs(
_(
"[Expired]"), fp);
577 if (subkey->disabled)
581 fputs(
_(
"[Disabled]"), fp);
585 if (subkey->timestamp > 0)
587 tt = subkey->timestamp;
594 if (subkey->expires > 0)
596 tt = subkey->expires;
603 s = gpgme_pubkey_algo_name(subkey->pubkey_algo);
605 aval = subkey->length;
610 fprintf(fp, ngettext(
"%s, %lu bit %s\n",
"%s, %lu bit %s\n", aval),
"PGP", aval, s);
616 if (subkey->can_encrypt)
618 fprintf(fp,
"%s%s", delim,
_(
"encryption"));
621 if (subkey->can_sign)
623 fprintf(fp,
"%s%s", delim,
_(
"signing"));
626 if (subkey->can_certify)
628 fprintf(fp,
"%s%s", delim,
_(
"certification"));
641 const char *s = NULL;
642 gpgme_ctx_t listctx = NULL;
643 gpgme_error_t err = GPG_ERR_NO_ERROR;
644 gpgme_key_t k = NULL;
663 while ((s = k->chain_id) && k->subkeys && !
mutt_str_equal(s, k->subkeys->fpr))
666 err = gpgme_op_keylist_start(listctx, s, 0);
669 if (err == GPG_ERR_NO_ERROR)
670 err = gpgme_op_keylist_next(listctx, &k);
671 if (err != GPG_ERR_NO_ERROR)
673 fprintf(fp,
_(
"Error finding issuer key: %s\n"), gpgme_strerror(err));
676 gpgme_op_keylist_end(listctx);
682 fputs(
_(
"Error: certification chain too long - stopping here\n"), fp);
689 gpgme_release(listctx);
692 char title[1024] = { 0 };
693 snprintf(title,
sizeof(title),
_(
"Key ID: 0x%s"),
crypt_keyid(key));
767 mutt_error(
_(
"This key can't be used: expired/disabled/revoked"));
774 const char *warn_s = NULL;
775 char buf2[1024] = { 0 };
779 warn_s =
_(
"ID is expired/disabled/revoked. Do you really want to use the key?");
786 case GPGME_VALIDITY_NEVER:
787 warn_s =
_(
"ID is not valid. Do you really want to use the key?");
789 case GPGME_VALIDITY_MARGINAL:
790 warn_s =
_(
"ID is only marginally valid. Do you really want to use the key?");
792 case GPGME_VALIDITY_FULL:
793 case GPGME_VALIDITY_ULTIMATE:
795 case GPGME_VALIDITY_UNKNOWN:
796 case GPGME_VALIDITY_UNDEFINED:
797 warn_s =
_(
"ID has undefined validity. Do you really want to use the key?");
802 snprintf(buf2,
sizeof(buf2),
"%s", warn_s);
867 if (!event || !dlg || !dlg->
wdata)
873 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.
bool 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.
void dispatcher_flush_on_error(int rv)
Flush pending keys after a dispatch error.
@ 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:
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_exit(struct AliasFunctionData *fdata, const struct KeyEvent *event)
exit this menu - Implements alias_function_t -
static int op_generic_select_entry(struct AliasFunctionData *fdata, const struct KeyEvent *event)
select the current entry - 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)
@ MODULE_ID_NCRYPT
ModuleNcrypt, Ncrypt
int mutt_ch_convert_string(char **ps, const char *from, const char *to, uint8_t flags)
Convert a string between encodings.
#define MUTT_ICONV_NONE
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.
@ KEYFLAG_ISX509
Key is an X.509 key.
Ncrypt private Module data.
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
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.
Ncrypt private Module data.
int key_info_padding[KIP_MAX]
Padding for key info prompts.
Container for Accounts, Notifications.