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