Verbose information about a key or certificate to a file.
387{
388 int idx;
389 const char *s = NULL, *s2 = NULL;
390 time_t tt = 0;
391 char shortbuf[128] = { 0 };
392 unsigned long aval = 0;
393 const char *delim = NULL;
394 gpgme_user_id_t uid = NULL;
395 static int max_header_width = 0;
396
397 if (max_header_width == 0)
398 {
399 for (
int i = 0; i <
KIP_MAX; i++)
400 {
403 if (max_header_width < width)
404 max_header_width = width;
406 }
407 for (
int i = 0; i <
KIP_MAX; i++)
409 }
410
411 bool is_pgp = (key->protocol == GPGME_PROTOCOL_OpenPGP);
412
413 for (idx = 0, uid = key->uids; uid; idx++, uid = uid->next)
414 {
415 if (uid->revoked)
416 continue;
417
418 s = uid->uid;
419
420
421 if (idx == 0)
423 else
425 if (uid->invalid)
426 {
427
428 fputs(
_(
"[Invalid]"), fp);
429 putc(' ', fp);
430 }
431 if (is_pgp)
433 else
435 putc('\n', fp);
436 }
437
438 if (key->subkeys && (key->subkeys->timestamp > 0))
439 {
440 tt = key->subkeys->timestamp;
441
445 }
446
447 if (key->subkeys && (key->subkeys->expires > 0))
448 {
449 tt = key->subkeys->expires;
450
454 }
455
456 if (key->subkeys)
457 s = gpgme_pubkey_algo_name(key->subkeys->pubkey_algo);
458 else
459 s = "?";
460
461 s2 = is_pgp ? "PGP" : "X.509";
462
463 if (key->subkeys)
464 aval = key->subkeys->length;
465
467
468 fprintf(fp, ngettext("%s, %lu bit %s\n", "%s, %lu bit %s\n", aval), s2, aval, s);
469
471 delim = "";
472
474 {
475
476 fprintf(fp,
"%s%s", delim,
_(
"encryption"));
478 }
480 {
481
482 fprintf(fp,
"%s%s", delim,
_(
"signing"));
484 }
486 {
487
488 fprintf(fp,
"%s%s", delim,
_(
"certification"));
489 }
490 putc('\n', fp);
491
492 if (key->subkeys)
493 {
494 s = key->subkeys->fpr;
496 if (is_pgp && (strlen(s) == 40))
497 {
498 for (int i = 0; (s[0] != '\0') && (s[1] != '\0') && (s[2] != '\0') &&
499 (s[3] != '\0') && (s[4] != '\0');
500 s += 4, i++)
501 {
502 putc(*s, fp);
503 putc(s[1], fp);
504 putc(s[2], fp);
505 putc(s[3], fp);
506 putc(' ', fp);
507 if (i == 4)
508 putc(' ', fp);
509 }
510 }
511 else
512 {
513 for (int i = 0; (s[0] != '\0') && (s[1] != '\0') && (s[2] != '\0'); s += 2, i++)
514 {
515 putc(*s, fp);
516 putc(s[1], fp);
517 putc(is_pgp ? ' ' : ':', fp);
518 if (is_pgp && (i == 7))
519 putc(' ', fp);
520 }
521 }
522 fprintf(fp, "%s\n", s);
523 }
524
525 if (key->issuer_serial)
526 {
527 s = key->issuer_serial;
530 }
531
532 if (key->issuer_name)
533 {
534 s = key->issuer_name;
537 putc('\n', fp);
538 }
539
540
541 if (is_pgp)
542 {
543 gpgme_subkey_t subkey = NULL;
544
545 for (idx = 1, subkey = key->subkeys; subkey; idx++, subkey = subkey->next)
546 {
547 s = subkey->keyid;
548
549 putc('\n', fp);
550 if (strlen(s) == 16)
551 s += 8;
553 if (subkey->revoked)
554 {
555 putc(' ', fp);
556
557 fputs(
_(
"[Revoked]"), fp);
558 }
559 if (subkey->invalid)
560 {
561 putc(' ', fp);
562
563 fputs(
_(
"[Invalid]"), fp);
564 }
565 if (subkey->expired)
566 {
567 putc(' ', fp);
568
569 fputs(
_(
"[Expired]"), fp);
570 }
571 if (subkey->disabled)
572 {
573 putc(' ', fp);
574
575 fputs(
_(
"[Disabled]"), fp);
576 }
577 putc('\n', fp);
578
579 if (subkey->timestamp > 0)
580 {
581 tt = subkey->timestamp;
582
586 }
587
588 if (subkey->expires > 0)
589 {
590 tt = subkey->expires;
591
595 }
596
597 s = gpgme_pubkey_algo_name(subkey->pubkey_algo);
598
599 aval = subkey->length;
600
602
603 fprintf(fp, ngettext("%s, %lu bit %s\n", "%s, %lu bit %s\n", aval), "PGP", aval, s);
604
606 delim = "";
607
608 if (subkey->can_encrypt)
609 {
610 fprintf(fp,
"%s%s", delim,
_(
"encryption"));
612 }
613 if (subkey->can_sign)
614 {
615 fprintf(fp,
"%s%s", delim,
_(
"signing"));
617 }
618 if (subkey->can_certify)
619 {
620 fprintf(fp,
"%s%s", delim,
_(
"certification"));
621 }
622 putc('\n', fp);
623 }
624 }
625}
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:
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.
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.