diff options
author | David Shaw <dshaw@jabberwocky.com> | 2004-03-03 06:47:51 +0100 |
---|---|---|
committer | David Shaw <dshaw@jabberwocky.com> | 2004-03-03 06:47:51 +0100 |
commit | 2d7fe1d3a1eaaf77957a6726280136a6dd02691b (patch) | |
tree | 73be1a1760719399e4766a94a01c4dc05b47fe0d /g10/keyid.c | |
parent | * packet.h, free-packet.c (free_encrypted, free_plaintext), parse-packet.c (diff) | |
download | gnupg2-2d7fe1d3a1eaaf77957a6726280136a6dd02691b.tar.xz gnupg2-2d7fe1d3a1eaaf77957a6726280136a6dd02691b.zip |
* options.h, g10.c (main): Add a more flexible --keyid-format option to
replace the list-option (and eventually verify-option) show-long-keyids.
The format can be short, long, 0xshort, and 0xlong.
* keydb.h, keyid.c (keystr, keystrlen): New functions to generate a
printable keyid.
* keyedit.c (print_and_check_one_sig, show_key_with_all_names), keylist.c
(list_keyblock_print): Use new keystr() function here to print keyids.
Diffstat (limited to 'g10/keyid.c')
-rw-r--r-- | g10/keyid.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/g10/keyid.c b/g10/keyid.c index 5ae286e89..a2153ad76 100644 --- a/g10/keyid.c +++ b/g10/keyid.c @@ -144,6 +144,59 @@ do_fingerprint_md_sk( PKT_secret_key *sk ) return do_fingerprint_md( &pk ); } +size_t +keystrlen(void) +{ + switch(opt.keyid_format) + { + case KF_SHORT: + return 8; + + case KF_LONG: + return 16; + + case KF_0xSHORT: + return 10; + + case KF_0xLONG: + return 18; + + default: + BUG(); + } +} + +const char * +keystr(u32 *keyid) +{ + static char keyid_str[19]; + + switch(opt.keyid_format) + { + case KF_SHORT: + sprintf(keyid_str,"%08lX",(ulong)keyid[1]); + break; + + case KF_LONG: + sprintf(keyid_str,"%08lX%08lX",(ulong)keyid[0],(ulong)keyid[1]); + break; + + case KF_0xSHORT: + sprintf(keyid_str,"0x%08lX",(ulong)keyid[1]); + break; + + case KF_0xLONG: + sprintf(keyid_str,"0x%08lX%08lX",(ulong)keyid[0],(ulong)keyid[1]); + break; + + default: + BUG(); + } + + return keyid_str; +} + + /**************** * Get the keyid from the secret key and put it into keyid * if this is not NULL. Return the 32 low bits of the keyid. |