From d2ff62dbdf891319e6db5850c6077c85e5eb784e Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 28 Nov 2019 12:02:41 +0100 Subject: [PATCH] gpg: Change the way v5 fingerprints are printed. * g10/gpg.h (MAX_FORMATTED_FINGERPRINT_LEN): Increase by one. * g10/keyid.c (format_hexfingerprint): Change v5 key formatting. -- The new format are groups of 5 letters to resemble the CW speed measurement rules. Many hams are used to such blocks from their CW lessons. Note that there is no double blank in the middle as with the v4 keys. Signed-off-by: Werner Koch --- g10/gpg.h | 2 +- g10/keyid.c | 17 ++++------------- g10/keylist.c | 4 ++-- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/g10/gpg.h b/g10/gpg.h index adb919d7d..d4e66e72d 100644 --- a/g10/gpg.h +++ b/g10/gpg.h @@ -50,7 +50,7 @@ /* The maximum length of a formatted fingerprint as returned by * format_hexfingerprint(). */ -#define MAX_FORMATTED_FINGERPRINT_LEN 59 +#define MAX_FORMATTED_FINGERPRINT_LEN 60 /* diff --git a/g10/keyid.c b/g10/keyid.c index 7605cb386..a7a54e07b 100644 --- a/g10/keyid.c +++ b/g10/keyid.c @@ -873,10 +873,10 @@ format_hexfingerprint (const char *fingerprint, char *buffer, size_t buflen) /* The v5 fingerprint is commonly printed truncated to 25 * octets. We accept the truncated as well as the full hex * version here and format it like this: - * B2CCB6 838332 5D61BA C50F9F 5E CD21A8 0AC8C5 2565C8 C52565 + * 19347 BC987 24640 25F99 DF3EC 2E000 0ED98 84892 E1F7B 3EA4C */ hexlen = 50; - space = 8 * 6 + 2 + 8 + 1; + space = 10 * 5 + 9 + 1; } else /* Other fingerprint versions - print as is. */ { @@ -908,18 +908,9 @@ format_hexfingerprint (const char *fingerprint, char *buffer, size_t buflen) } else if (hexlen == 50) /* v5 fingerprint */ { - for (i=j=0; i < 24; i++) + for (i=j=0; i < 50; i++) { - if (i && !(i % 6)) - buffer[j++] = ' '; - buffer[j++] = fingerprint[i]; - } - buffer[j++] = ' '; - buffer[j++] = fingerprint[i++]; - buffer[j++] = fingerprint[i++]; - for (; i < 50; i++) - { - if (!((i-26) % 6)) + if (i && !(i % 5)) buffer[j++] = ' '; buffer[j++] = fingerprint[i]; } diff --git a/g10/keylist.c b/g10/keylist.c index dacc13788..44cbe73bd 100644 --- a/g10/keylist.c +++ b/g10/keylist.c @@ -2059,9 +2059,9 @@ print_fingerprint (ctrl_t ctrl, estream_t override_fp, { if (!i) ; - else if (!(i%8)) + else if (!(i%10)) tty_fprintf (fp, "\n%*s ", (int)strlen(text)+1, ""); - else if (!(i%4)) + else if (!(i%5)) tty_fprintf (fp, " "); else tty_fprintf (fp, " ");