mirror of
git://git.gnupg.org/gnupg.git
synced 2025-02-01 16:33:02 +01:00
gpg: Add option to print fingerprints in ICAO spelling.
* g10/gpg.c: Add option --with-icao-spelling. * g10/options.h (struct opt): Add with_icao_spelling. * g10/keylist.c (print_icao_hexdigit): New. (print_fingerprint): Print ICAO spelling. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
a8116aacd9
commit
ae09515b9d
@ -2136,6 +2136,11 @@ Same as the command @option{--fingerprint} but changes only the format
|
|||||||
of the output and may be used together with another command.
|
of the output and may be used together with another command.
|
||||||
|
|
||||||
@ifset gpgtwoone
|
@ifset gpgtwoone
|
||||||
|
|
||||||
|
@item --with-icao-spelling
|
||||||
|
@opindex with-icao-spelling
|
||||||
|
Print the ICAO spelling of the fingerprint in addition to the hex digits.
|
||||||
|
|
||||||
@item --with-keygrip
|
@item --with-keygrip
|
||||||
@opindex with-keygrip
|
@opindex with-keygrip
|
||||||
Include the keygrip in the key listings.
|
Include the keygrip in the key listings.
|
||||||
|
@ -176,6 +176,7 @@ enum cmd_and_opt_values
|
|||||||
oNoAskCertLevel,
|
oNoAskCertLevel,
|
||||||
oFingerprint,
|
oFingerprint,
|
||||||
oWithFingerprint,
|
oWithFingerprint,
|
||||||
|
oWithICAOSpelling,
|
||||||
oWithKeygrip,
|
oWithKeygrip,
|
||||||
oWithSecret,
|
oWithSecret,
|
||||||
oAnswerYes,
|
oAnswerYes,
|
||||||
@ -692,6 +693,7 @@ static ARGPARSE_OPTS opts[] = {
|
|||||||
ARGPARSE_s_n (oUtf8Strings, "utf8-strings", "@"),
|
ARGPARSE_s_n (oUtf8Strings, "utf8-strings", "@"),
|
||||||
ARGPARSE_s_n (oNoUtf8Strings, "no-utf8-strings", "@"),
|
ARGPARSE_s_n (oNoUtf8Strings, "no-utf8-strings", "@"),
|
||||||
ARGPARSE_s_n (oWithFingerprint, "with-fingerprint", "@"),
|
ARGPARSE_s_n (oWithFingerprint, "with-fingerprint", "@"),
|
||||||
|
ARGPARSE_s_n (oWithICAOSpelling, "with-icao-spelling", "@"),
|
||||||
ARGPARSE_s_n (oWithKeygrip, "with-keygrip", "@"),
|
ARGPARSE_s_n (oWithKeygrip, "with-keygrip", "@"),
|
||||||
ARGPARSE_s_n (oWithSecret, "with-secret", "@"),
|
ARGPARSE_s_n (oWithSecret, "with-secret", "@"),
|
||||||
ARGPARSE_s_s (oDisableCipherAlgo, "disable-cipher-algo", "@"),
|
ARGPARSE_s_s (oDisableCipherAlgo, "disable-cipher-algo", "@"),
|
||||||
@ -2421,6 +2423,9 @@ main (int argc, char **argv)
|
|||||||
opt.with_fingerprint = 1;
|
opt.with_fingerprint = 1;
|
||||||
opt.fingerprint++;
|
opt.fingerprint++;
|
||||||
break;
|
break;
|
||||||
|
case oWithICAOSpelling:
|
||||||
|
opt.with_icao_spelling = 1;
|
||||||
|
break;
|
||||||
case oFingerprint:
|
case oFingerprint:
|
||||||
opt.fingerprint++;
|
opt.fingerprint++;
|
||||||
fpr_maybe_cmd = 1;
|
fpr_maybe_cmd = 1;
|
||||||
|
@ -1580,6 +1580,20 @@ list_keyblock (KBNODE keyblock, int secret, int has_secret, int fpr,
|
|||||||
es_fflush (es_stdout);
|
es_fflush (es_stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Print an hex digit in ICAO spelling. */
|
||||||
|
static void
|
||||||
|
print_icao_hexdigit (estream_t fp, int c)
|
||||||
|
{
|
||||||
|
static const char *list[16] = {
|
||||||
|
"Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven",
|
||||||
|
"Eight", "Niner", "Alfa", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot"
|
||||||
|
};
|
||||||
|
|
||||||
|
tty_fprintf (fp, "%s", list[c&15]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Function to print the finperprint.
|
* Function to print the finperprint.
|
||||||
* mode 0: as used in key listings, opt.with_colons is honored
|
* mode 0: as used in key listings, opt.with_colons is honored
|
||||||
@ -1675,6 +1689,26 @@ print_fingerprint (estream_t override_fp, PKT_public_key *pk, int mode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
tty_fprintf (fp, "\n");
|
tty_fprintf (fp, "\n");
|
||||||
|
if (!opt.with_colons && opt.with_icao_spelling)
|
||||||
|
{
|
||||||
|
p = array;
|
||||||
|
tty_fprintf (fp, "%*s\"", (int)strlen(text)+1, "");
|
||||||
|
for (i = 0; i < n; i++, p++)
|
||||||
|
{
|
||||||
|
if (!i)
|
||||||
|
;
|
||||||
|
else if (!(i%4))
|
||||||
|
tty_fprintf (fp, "\n%*s ", (int)strlen(text)+1, "");
|
||||||
|
else if (!(i%2))
|
||||||
|
tty_fprintf (fp, " ");
|
||||||
|
else
|
||||||
|
tty_fprintf (fp, " ");
|
||||||
|
print_icao_hexdigit (fp, *p >> 4);
|
||||||
|
tty_fprintf (fp, " ");
|
||||||
|
print_icao_hexdigit (fp, *p & 15);
|
||||||
|
}
|
||||||
|
tty_fprintf (fp, "\"\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print the serial number of an OpenPGP card if available. */
|
/* Print the serial number of an OpenPGP card if available. */
|
||||||
|
@ -67,6 +67,7 @@ struct
|
|||||||
int check_sigs; /* check key signatures */
|
int check_sigs; /* check key signatures */
|
||||||
int with_colons;
|
int with_colons;
|
||||||
int with_key_data;
|
int with_key_data;
|
||||||
|
int with_icao_spelling; /* Print ICAO spelling with fingerprints. */
|
||||||
int with_fingerprint; /* Option --with-fingerprint active. */
|
int with_fingerprint; /* Option --with-fingerprint active. */
|
||||||
int with_keygrip; /* Option --with-keygrip active. */
|
int with_keygrip; /* Option --with-keygrip active. */
|
||||||
int with_secret; /* Option --with-secret active. */
|
int with_secret; /* Option --with-secret active. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user