Verbose information about a key or certificate to a file.
387{
389 int idx;
390 const char *s = NULL, *s2 = NULL;
391 time_t tt = 0;
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;
397
398 if (max_header_width == 0)
399 {
400 for (
int i = 0; i <
KIP_MAX; i++)
401 {
404 if (max_header_width < width)
405 max_header_width = width;
407 }
408 for (
int i = 0; i <
KIP_MAX; i++)
410 }
411
412 bool is_pgp = (key->protocol == GPGME_PROTOCOL_OpenPGP);
413
414 for (idx = 0, uid = key->uids; uid; idx++, uid = uid->next)
415 {
416 if (uid->revoked)
417 continue;
418
419 s = uid->uid;
420
421
422 if (idx == 0)
424 else
426 if (uid->invalid)
427 {
428
429 fputs(
_(
"[Invalid]"), fp);
430 putc(' ', fp);
431 }
432 if (is_pgp)
434 else
436 putc('\n', fp);
437 }
438
439 if (key->subkeys && (key->subkeys->timestamp > 0))
440 {
441 tt = key->subkeys->timestamp;
442
446 }
447
448 if (key->subkeys && (key->subkeys->expires > 0))
449 {
450 tt = key->subkeys->expires;
451
455 }
456
457 if (key->subkeys)
458 s = gpgme_pubkey_algo_name(key->subkeys->pubkey_algo);
459 else
460 s = "?";
461
462 s2 = is_pgp ? "PGP" : "X.509";
463
464 if (key->subkeys)
465 aval = key->subkeys->length;
466
469
470 fprintf(fp, ngettext("%s, %lu bit %s\n", "%s, %lu bit %s\n", aval), s2, aval, s);
471
474 delim = "";
475
477 {
478
479 fprintf(fp,
"%s%s", delim,
_(
"encryption"));
481 }
483 {
484
485 fprintf(fp,
"%s%s", delim,
_(
"signing"));
487 }
489 {
490
491 fprintf(fp,
"%s%s", delim,
_(
"certification"));
492 }
493 putc('\n', fp);
494
495 if (key->subkeys)
496 {
497 s = key->subkeys->fpr;
500 if (is_pgp && (strlen(s) == 40))
501 {
502 for (int i = 0; (s[0] != '\0') && (s[1] != '\0') && (s[2] != '\0') &&
503 (s[3] != '\0') && (s[4] != '\0');
504 s += 4, i++)
505 {
506 putc(*s, fp);
507 putc(s[1], fp);
508 putc(s[2], fp);
509 putc(s[3], fp);
510 putc(' ', fp);
511 if (i == 4)
512 putc(' ', fp);
513 }
514 }
515 else
516 {
517 for (int i = 0; (s[0] != '\0') && (s[1] != '\0') && (s[2] != '\0'); s += 2, i++)
518 {
519 putc(*s, fp);
520 putc(s[1], fp);
521 putc(is_pgp ? ' ' : ':', fp);
522 if (is_pgp && (i == 7))
523 putc(' ', fp);
524 }
525 }
526 fprintf(fp, "%s\n", s);
527 }
528
529 if (key->issuer_serial)
530 {
531 s = key->issuer_serial;
534 }
535
536 if (key->issuer_name)
537 {
538 s = key->issuer_name;
542 putc('\n', fp);
543 }
544
545
546 if (is_pgp)
547 {
548 gpgme_subkey_t subkey = NULL;
549
550 for (idx = 1, subkey = key->subkeys; subkey; idx++, subkey = subkey->next)
551 {
552 s = subkey->keyid;
553
554 putc('\n', fp);
555 if (strlen(s) == 16)
556 s += 8;
559 if (subkey->revoked)
560 {
561 putc(' ', fp);
562
563 fputs(
_(
"[Revoked]"), fp);
564 }
565 if (subkey->invalid)
566 {
567 putc(' ', fp);
568
569 fputs(
_(
"[Invalid]"), fp);
570 }
571 if (subkey->expired)
572 {
573 putc(' ', fp);
574
575 fputs(
_(
"[Expired]"), fp);
576 }
577 if (subkey->disabled)
578 {
579 putc(' ', fp);
580
581 fputs(
_(
"[Disabled]"), fp);
582 }
583 putc('\n', fp);
584
585 if (subkey->timestamp > 0)
586 {
587 tt = subkey->timestamp;
588
592 }
593
594 if (subkey->expires > 0)
595 {
596 tt = subkey->expires;
597
601 }
602
603 s = gpgme_pubkey_algo_name(subkey->pubkey_algo);
604
605 aval = subkey->length;
606
609
610 fprintf(fp, ngettext("%s, %lu bit %s\n", "%s, %lu bit %s\n", aval), "PGP", aval, s);
611
614 delim = "";
615
616 if (subkey->can_encrypt)
617 {
618 fprintf(fp,
"%s%s", delim,
_(
"encryption"));
620 }
621 if (subkey->can_sign)
622 {
623 fprintf(fp,
"%s%s", delim,
_(
"signing"));
625 }
626 if (subkey->can_certify)
627 {
628 fprintf(fp,
"%s%s", delim,
_(
"certification"));
629 }
630 putc('\n', fp);
631 }
632 }
633}
unsigned int key_check_cap(gpgme_key_t key, enum KeyCap cap)
Check the capabilities of a key.
@ 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.
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.
@ MODULE_ID_NCRYPT
ModuleNcrypt, Ncrypt
size_t mutt_date_localtime_format(char *buf, size_t buflen, const char *format, time_t t)
Format localtime.
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Ncrypt private Module data.
int key_info_padding[KIP_MAX]
Padding for key info prompts.
Container for Accounts, Notifications.