On Thu, Jul 02, 2026 at 10:26:32PM +0200, Robert Jäschke via Mutt-dev wrote:
Thank you. That's a good idea. In principle, it's working.PGP example:[-- Begin signature information --] Good signature from: Kevin J. McCarthy <[email protected]> Fingerprint: 8975 A9B3 3AA3 7910 385C 5308 ADEF 7684 8031 6BDA created: Thu Jul 2 09:15:12 2026 WARNING: It is NOT certain that the key belongs to the person named as shown above [-- End signature information --]S/MIME example:[-- Begin signature information --] Good signature from: 1.2.840.113549.1.9.1=#726F626572742E6A61657363686B654068752D6265726C696E2E6465,CN=Robert +Jaeschke,2.5.4.42=#526F62657274,2.5.4.4=#4A61657363686B65,2.5.4.97=#474F5644452B4245,O=Humboldt-Universitaet zu Berlin,ST=Berlin,C=DE aka: <[email protected]> Fingerprint: E4:76:AD:AA:61:4A:7E:1C:FD:C3:D5:D1:7F:37:8D:99:80:76:E6:16 created: Wed Jul 1 10:36:10 2026 [-- End signature information --]So only the alignment needs to be fixed, which I did by modifying show_fingerprint() (I had to add the "msg" argument which is not nice but since the function is used only once, that could be fine.)
I agree. It's not pretty, but since it's only called once it should be okay.
So here are my two patches (thanks also to Alejandro for the tipps to improve my code):
Please move the helper function back inside crypt-gpgme.c and make it a static function there. There is no reason to put it in curs_lib.c, as I mentioned before. Otherwise this looks good. Thank you for the work.
-- >8 --
Subject: [PATCH 1/2] refactored alignment of strings into function
---
crypt-gpgme.c | 19 +++----------------
curs_lib.c | 11 +++++++++++
protos.h | 1 +
3 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/crypt-gpgme.c b/crypt-gpgme.c
index ccae5503..4e0be87f 100644
--- a/crypt-gpgme.c
+++ b/crypt-gpgme.c
@@ -1619,9 +1619,8 @@ static void show_one_sig_validity(gpgme_ctx_t ctx, int
idx, STATE *s)
static void print_smime_keyinfo(const char *msg, gpgme_signature_t sig,
gpgme_key_t key, STATE *s)
{
- int msgwid;
gpgme_user_id_t uids = NULL;
- int i, aka = 0;
+ int aka = 0;
state_puts(msg, s);
state_puts(" ", s);
@@ -1633,14 +1632,7 @@ static void print_smime_keyinfo(const char *msg,
gpgme_signature_t sig,
if (uids->revoked)
continue;
if (aka)
- {
- msgwid = mutt_strwidth(msg) - mutt_strwidth(_("aka: ")) + 1;
- if (msgwid < 0)
- msgwid = 0;
- for (i = 0; i < msgwid; i++)
- state_puts(" ", s);
- state_puts(_("aka: "), s);
- }
+ mutt_align_to_msg(msg, _("aka: "), s);
state_puts(uids->uid, s);
state_puts("\n", s);
@@ -1666,12 +1658,7 @@ static void print_smime_keyinfo(const char *msg,
gpgme_signature_t sig,
"Jan 1 1970" is not the created date. */
if (sig->timestamp)
{
- msgwid = mutt_strwidth(msg) - mutt_strwidth(_("created: ")) + 1;
- if (msgwid < 0)
- msgwid = 0;
- for (i = 0; i < msgwid; i++)
- state_puts(" ", s);
- state_puts(_("created: "), s);
+ mutt_align_to_msg(msg, _("created: "), s);
print_time(sig->timestamp, s);
state_puts("\n", s);
}
diff --git a/curs_lib.c b/curs_lib.c
index 5c93cbb0..9cf1b76f 100644
--- a/curs_lib.c
+++ b/curs_lib.c
@@ -1654,3 +1654,14 @@ int mutt_strwidth(const char *s)
}
return w;
}
+
+void mutt_align_to_msg(const char *msg, const char *key, STATE *s)
+{
+ int msgwid = mutt_strwidth(msg) - mutt_strwidth(_(key)) + 1;
+
+ if (msgwid < 0)
+ msgwid = 0;
+ for (int i = 0; i < msgwid; i++)
+ state_puts(" ", s);
+ state_puts(key, s);
+}
diff --git a/protos.h b/protos.h
index 4958aa0e..3dad301d 100644
--- a/protos.h
+++ b/protos.h
@@ -407,6 +407,7 @@ int mutt_smtp_send(const ADDRESS *, const ADDRESS *, const
ADDRESS *,
size_t mutt_wstr_trunc(const char *, size_t, size_t, size_t *);
int mutt_charlen(const char *s, int *);
int mutt_strwidth(const char *);
+void mutt_align_to_msg(const char *msg, const char *key, STATE *s);
int mutt_compose_menu(SEND_CONTEXT *);
int mutt_thread_set_flag(HEADER *, int, int, int);
int mutt_user_is_recipient(HEADER *);
--
2.47.3
-- >8 --
Subject: [PATCH 2/2] show s/mime keyid for successfully checked signatures
---
crypt-gpgme.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/crypt-gpgme.c b/crypt-gpgme.c
index 4e0be87f..5fa7b7e5 100644
--- a/crypt-gpgme.c
+++ b/crypt-gpgme.c
@@ -1528,12 +1528,11 @@ static int show_sig_summary(unsigned long sum,
}
-static void show_fingerprint(gpgme_key_t key, STATE *state)
+static void show_fingerprint(const char *msg, gpgme_key_t key, STATE *state)
{
const char *s;
int i, is_pgp;
char *buf, *p;
- const char *prefix = _("Fingerprint: ");
if (!key)
return;
@@ -1542,9 +1541,9 @@ static void show_fingerprint(gpgme_key_t key, STATE
*state)
return;
is_pgp = (key->protocol == GPGME_PROTOCOL_OpenPGP);
- buf = safe_malloc( strlen(prefix) + strlen(s) * 4 + 2 );
- strcpy(buf, prefix); /* __STRCPY_CHECKED__ */
- p = buf + strlen(buf);
+ mutt_align_to_msg(msg, _("Fingerprint: "), state);
+ buf = safe_malloc( strlen(s) * 4 + 2 );
+ p = buf;
if (is_pgp && strlen(s) == 40)
{ /* PGP v4 style formatted. */
for (i=0; *s && s[1] && s[2] && s[3] && s[4]; s += 4, i++)
@@ -1638,6 +1637,8 @@ static void print_smime_keyinfo(const char *msg,
gpgme_signature_t sig,
aka = 1;
}
+
+ show_fingerprint(msg, key, s);
}
else
{
@@ -1755,7 +1756,6 @@ static int show_one_sig_status(gpgme_ctx_t ctx, int idx,
STATE *s)
ultimate). */
print_smime_keyinfo(_("Good signature from:"), sig, key, s);
show_one_sig_validity(ctx, idx, s);
- show_fingerprint(key,s);
if (show_sig_summary(sum, ctx, key, idx, s, sig))
anywarn = 1;
}
--
2.47.3
-- Kevin J. McCarthy GPG Fingerprint: 8975 A9B3 3AA3 7910 385C 5308 ADEF 7684 8031 6BDA
signature.asc
Description: PGP signature
