Verbose information about a key or certificate to a file.
389{
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
469
470 fprintf(fp, ngettext("%s, %lu bit %s\n", "%s, %lu bit %s\n", aval), s2, aval, s);
471
473 delim = "";
474
476 {
477
478 fprintf(fp,
"%s%s", delim,
_(
"encryption"));
480 }
482 {
483
484 fprintf(fp,
"%s%s", delim,
_(
"signing"));
486 }
488 {
489
490 fprintf(fp,
"%s%s", delim,
_(
"certification"));
491 }
492 putc('\n', fp);
493
494 if (key->subkeys)
495 {
496 s = key->subkeys->fpr;
498 if (is_pgp && (strlen(s) == 40))
499 {
500 for (int i = 0; (s[0] != '\0') && (s[1] != '\0') && (s[2] != '\0') &&
501 (s[3] != '\0') && (s[4] != '\0');
502 s += 4, i++)
503 {
504 putc(*s, fp);
505 putc(s[1], fp);
506 putc(s[2], fp);
507 putc(s[3], fp);
508 putc(' ', fp);
509 if (i == 4)
510 putc(' ', fp);
511 }
512 }
513 else
514 {
515 for (int i = 0; (s[0] != '\0') && (s[1] != '\0') && (s[2] != '\0'); s += 2, i++)
516 {
517 putc(*s, fp);
518 putc(s[1], fp);
519 putc(is_pgp ? ' ' : ':', fp);
520 if (is_pgp && (i == 7))
521 putc(' ', fp);
522 }
523 }
524 fprintf(fp, "%s\n", s);
525 }
526
527 if (key->issuer_serial)
528 {
529 s = key->issuer_serial;
532 }
533
534 if (key->issuer_name)
535 {
536 s = key->issuer_name;
539 putc('\n', fp);
540 }
541
542
543 if (is_pgp)
544 {
545 gpgme_subkey_t subkey = NULL;
546
547 for (idx = 1, subkey = key->subkeys; subkey; idx++, subkey = subkey->next)
548 {
549 s = subkey->keyid;
550
551 putc('\n', fp);
552 if (strlen(s) == 16)
553 s += 8;
555 if (subkey->revoked)
556 {
557 putc(' ', fp);
558
559 fputs(
_(
"[Revoked]"), fp);
560 }
561 if (subkey->invalid)
562 {
563 putc(' ', fp);
564
565 fputs(
_(
"[Invalid]"), fp);
566 }
567 if (subkey->expired)
568 {
569 putc(' ', fp);
570
571 fputs(
_(
"[Expired]"), fp);
572 }
573 if (subkey->disabled)
574 {
575 putc(' ', fp);
576
577 fputs(
_(
"[Disabled]"), fp);
578 }
579 putc('\n', fp);
580
581 if (subkey->timestamp > 0)
582 {
583 tt = subkey->timestamp;
584
588 }
589
590 if (subkey->expires > 0)
591 {
592 tt = subkey->expires;
593
597 }
598
599 s = gpgme_pubkey_algo_name(subkey->pubkey_algo);
600
601 aval = subkey->length;
602
604
605 fprintf(fp, ngettext("%s, %lu bit %s\n", "%s, %lu bit %s\n", aval), "PGP", aval, s);
606
608 delim = "";
609
610 if (subkey->can_encrypt)
611 {
612 fprintf(fp,
"%s%s", delim,
_(
"encryption"));
614 }
615 if (subkey->can_sign)
616 {
617 fprintf(fp,
"%s%s", delim,
_(
"signing"));
619 }
620 if (subkey->can_certify)
621 {
622 fprintf(fp,
"%s%s", delim,
_(
"certification"));
623 }
624 putc('\n', fp);
625 }
626 }
627}
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.