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++)
201 if ((n == 0) || (n & 1))
205 array->
value = (
char *) p;
206 for (s1 = str; n > 0; 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 ==
' '))
236 else if ((*s ==
',') || (*s ==
'=') || (*s ==
'+') || (*s ==
'<') ||
237 (*s ==
'>') || (*s ==
'#') || (*s ==
';'))
248 array->
value = (
char *) p;
249 for (s = str; n > 0; 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);
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);
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;
471 fprintf(fp, ngettext(
"%s, %lu bit %s\n",
"%s, %lu bit %s\n", aval), s2, aval, s);
480 fprintf(fp,
"%s%s", delim,
_(
"encryption"));
486 fprintf(fp,
"%s%s", delim,
_(
"signing"));
492 fprintf(fp,
"%s%s", delim,
_(
"certification"));
498 s = key->subkeys->fpr;
501 if (is_pgp && (strlen(s) == 40))
503 for (
int i = 0; (s[0] !=
'\0') && (s[1] !=
'\0') && (s[2] !=
'\0') &&
504 (s[3] !=
'\0') && (s[4] !=
'\0');
518 for (
int i = 0; (s[0] !=
'\0') && (s[1] !=
'\0') && (s[2] !=
'\0'); s += 2, i++)
522 putc(is_pgp ?
' ' :
':', fp);
523 if (is_pgp && (i == 7))
527 fprintf(fp,
"%s\n", s);
530 if (key->issuer_serial)
532 s = key->issuer_serial;
537 if (key->issuer_name)
539 s = key->issuer_name;
549 gpgme_subkey_t subkey = NULL;
551 for (idx = 1, subkey = key->subkeys; subkey; idx++, subkey = subkey->next)
564 fputs(
_(
"[Revoked]"), fp);
570 fputs(
_(
"[Invalid]"), fp);
576 fputs(
_(
"[Expired]"), fp);
578 if (subkey->disabled)
582 fputs(
_(
"[Disabled]"), fp);
586 if (subkey->timestamp > 0)
588 tt = subkey->timestamp;
595 if (subkey->expires > 0)
597 tt = subkey->expires;
604 s = gpgme_pubkey_algo_name(subkey->pubkey_algo);
606 aval = subkey->length;
611 fprintf(fp, ngettext(
"%s, %lu bit %s\n",
"%s, %lu bit %s\n", aval),
"PGP", aval, s);
617 if (subkey->can_encrypt)
619 fprintf(fp,
"%s%s", delim,
_(
"encryption"));
622 if (subkey->can_sign)
624 fprintf(fp,
"%s%s", delim,
_(
"signing"));
627 if (subkey->can_certify)
629 fprintf(fp,
"%s%s", delim,
_(
"certification"));
642 const char *s = NULL;
643 gpgme_ctx_t listctx = NULL;
644 gpgme_error_t err = GPG_ERR_NO_ERROR;
645 gpgme_key_t k = NULL;
664 while ((s = k->chain_id) && k->subkeys && !
mutt_str_equal(s, k->subkeys->fpr))
667 err = gpgme_op_keylist_start(listctx, s, 0);
670 if (err == GPG_ERR_NO_ERROR)
671 err = gpgme_op_keylist_next(listctx, &k);
672 if (err != GPG_ERR_NO_ERROR)
674 fprintf(fp,
_(
"Error finding issuer key: %s\n"), gpgme_strerror(err));
677 gpgme_op_keylist_end(listctx);
683 fputs(
_(
"Error: certification chain too long - stopping here\n"), fp);
690 gpgme_release(listctx);
693 char title[1024] = { 0 };
694 snprintf(title,
sizeof(title),
_(
"Key ID: 0x%s"),
crypt_keyid(key));
768 mutt_error(
_(
"This key can't be used: expired/disabled/revoked"));
775 const char *warn_s = NULL;
776 char buf2[1024] = { 0 };
780 warn_s =
_(
"ID is expired/disabled/revoked. Do you really want to use the key?");
787 case GPGME_VALIDITY_NEVER:
788 warn_s =
_(
"ID is not valid. Do you really want to use the key?");
790 case GPGME_VALIDITY_MARGINAL:
791 warn_s =
_(
"ID is only marginally valid. Do you really want to use the key?");
793 case GPGME_VALIDITY_FULL:
794 case GPGME_VALIDITY_ULTIMATE:
796 case GPGME_VALIDITY_UNKNOWN:
797 case GPGME_VALIDITY_UNDEFINED:
798 warn_s =
_(
"ID has undefined validity. Do you really want to use the key?");
803 snprintf(buf2,
sizeof(buf2),
"%s", warn_s);
869 if (!event || !dlg || !dlg->
wdata)
875 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)
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.
bool OptPgpCheckTrust
(pseudo) used by dlg_pgp()
static int create_gpgme_context(gpgme_ctx_t *ctx)
Create a GPGME context.
static int op_quit(struct AliasFunctionData *fdata, const struct KeyEvent *event)
Save changes and exit this dialog - 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_verify_key(struct GpgmeData *gd, const struct KeyEvent *event)
Verify a PGP public key - Implements gpgme_function_t -.
static int op_quit(struct GpgmeData *gd, const struct KeyEvent *event)
Save changes and exit this dialog - 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.