Verbose information about a key or certificate to a file.
388{
390 int idx;
391 const char *s = NULL, *s2 = NULL;
392 time_t tt = 0;
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;
398
399 if (max_header_width == 0)
400 {
401 for (
int i = 0; i <
KIP_MAX; i++)
402 {
405 if (max_header_width < width)
406 max_header_width = width;
408 }
409 for (
int i = 0; i <
KIP_MAX; i++)
411 }
412
413 bool is_pgp = (key->protocol == GPGME_PROTOCOL_OpenPGP);
414
415 for (idx = 0, uid = key->uids; uid; idx++, uid = uid->next)
416 {
417 if (uid->revoked)
418 continue;
419
420 s = uid->uid;
421
422
423 if (idx == 0)
425 else
427 if (uid->invalid)
428 {
429
430 fputs(
_(
"[Invalid]"), fp);
431 putc(' ', fp);
432 }
433 if (is_pgp)
435 else
437 putc('\n', fp);
438 }
439
440 if (key->subkeys && (key->subkeys->timestamp > 0))
441 {
442 tt = key->subkeys->timestamp;
443
447 }
448
449 if (key->subkeys && (key->subkeys->expires > 0))
450 {
451 tt = key->subkeys->expires;
452
456 }
457
458 if (key->subkeys)
459 s = gpgme_pubkey_algo_name(key->subkeys->pubkey_algo);
460 else
461 s = "?";
462
463 s2 = is_pgp ? "PGP" : "X.509";
464
465 if (key->subkeys)
466 aval = key->subkeys->length;
467
470
471 fprintf(fp, ngettext("%s, %lu bit %s\n", "%s, %lu bit %s\n", aval), s2, aval, s);
472
475 delim = "";
476
478 {
479
480 fprintf(fp,
"%s%s", delim,
_(
"encryption"));
482 }
484 {
485
486 fprintf(fp,
"%s%s", delim,
_(
"signing"));
488 }
490 {
491
492 fprintf(fp,
"%s%s", delim,
_(
"certification"));
493 }
494 putc('\n', fp);
495
496 if (key->subkeys)
497 {
498 s = key->subkeys->fpr;
501 if (is_pgp && (strlen(s) == 40))
502 {
503 for (int i = 0; (s[0] != '\0') && (s[1] != '\0') && (s[2] != '\0') &&
504 (s[3] != '\0') && (s[4] != '\0');
505 s += 4, i++)
506 {
507 putc(*s, fp);
508 putc(s[1], fp);
509 putc(s[2], fp);
510 putc(s[3], fp);
511 putc(' ', fp);
512 if (i == 4)
513 putc(' ', fp);
514 }
515 }
516 else
517 {
518 for (int i = 0; (s[0] != '\0') && (s[1] != '\0') && (s[2] != '\0'); s += 2, i++)
519 {
520 putc(*s, fp);
521 putc(s[1], fp);
522 putc(is_pgp ? ' ' : ':', fp);
523 if (is_pgp && (i == 7))
524 putc(' ', fp);
525 }
526 }
527 fprintf(fp, "%s\n", s);
528 }
529
530 if (key->issuer_serial)
531 {
532 s = key->issuer_serial;
535 }
536
537 if (key->issuer_name)
538 {
539 s = key->issuer_name;
543 putc('\n', fp);
544 }
545
546
547 if (is_pgp)
548 {
549 gpgme_subkey_t subkey = NULL;
550
551 for (idx = 1, subkey = key->subkeys; subkey; idx++, subkey = subkey->next)
552 {
553 s = subkey->keyid;
554
555 putc('\n', fp);
556 if (strlen(s) == 16)
557 s += 8;
560 if (subkey->revoked)
561 {
562 putc(' ', fp);
563
564 fputs(
_(
"[Revoked]"), fp);
565 }
566 if (subkey->invalid)
567 {
568 putc(' ', fp);
569
570 fputs(
_(
"[Invalid]"), fp);
571 }
572 if (subkey->expired)
573 {
574 putc(' ', fp);
575
576 fputs(
_(
"[Expired]"), fp);
577 }
578 if (subkey->disabled)
579 {
580 putc(' ', fp);
581
582 fputs(
_(
"[Disabled]"), fp);
583 }
584 putc('\n', fp);
585
586 if (subkey->timestamp > 0)
587 {
588 tt = subkey->timestamp;
589
593 }
594
595 if (subkey->expires > 0)
596 {
597 tt = subkey->expires;
598
602 }
603
604 s = gpgme_pubkey_algo_name(subkey->pubkey_algo);
605
606 aval = subkey->length;
607
610
611 fprintf(fp, ngettext("%s, %lu bit %s\n", "%s, %lu bit %s\n", aval), "PGP", aval, s);
612
615 delim = "";
616
617 if (subkey->can_encrypt)
618 {
619 fprintf(fp,
"%s%s", delim,
_(
"encryption"));
621 }
622 if (subkey->can_sign)
623 {
624 fprintf(fp,
"%s%s", delim,
_(
"signing"));
626 }
627 if (subkey->can_certify)
628 {
629 fprintf(fp,
"%s%s", delim,
_(
"certification"));
630 }
631 putc('\n', fp);
632 }
633 }
634}
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.