summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2024-01-29 10:30:40 +0100
committerWerner Koch <wk@gnupg.org>2024-01-29 10:30:51 +0100
commit03207f62e80ac03826f7dbe04a59f15df0f57530 (patch)
tree5b89ff1a33cdf75c6fe2e5628fe6a7af38ad61eb
parentgpg: Hide --textmode from the help output. (diff)
downloadgnupg2-03207f62e80ac03826f7dbe04a59f15df0f57530.tar.xz
gnupg2-03207f62e80ac03826f7dbe04a59f15df0f57530.zip
gpg: Minor code cleanup for fingerprint computation.
* g10/keyid.c (do_hash_public_key): Simplify code for clarity.
-rw-r--r--g10/keyid.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/g10/keyid.c b/g10/keyid.c
index 4a041ce0e..89bba0d7a 100644
--- a/g10/keyid.c
+++ b/g10/keyid.c
@@ -234,20 +234,16 @@ do_hash_public_key (gcry_md_hd_t md, PKT_public_key *pk, int use_v5)
if (use_v5)
{
gcry_md_putc ( md, 0x9a ); /* ctb */
- gcry_md_putc ( md, n >> 24 ); /* 4 byte length header */
+ gcry_md_putc ( md, n >> 24 ); /* 4 byte length header (upper bits) */
gcry_md_putc ( md, n >> 16 );
- gcry_md_putc ( md, n >> 8 );
- gcry_md_putc ( md, n );
- /* Note that the next byte may either be 4 or 5. */
- gcry_md_putc ( md, pk->version );
}
else
{
gcry_md_putc ( md, 0x99 ); /* ctb */
- gcry_md_putc ( md, n >> 8 ); /* 2 byte length header */
- gcry_md_putc ( md, n );
- gcry_md_putc ( md, pk->version );
}
+ gcry_md_putc ( md, n >> 8 ); /* lower bits of the length header. */
+ gcry_md_putc ( md, n );
+ gcry_md_putc ( md, pk->version );
gcry_md_putc ( md, pk->timestamp >> 24 );
gcry_md_putc ( md, pk->timestamp >> 16 );
gcry_md_putc ( md, pk->timestamp >> 8 );
@@ -255,7 +251,7 @@ do_hash_public_key (gcry_md_hd_t md, PKT_public_key *pk, int use_v5)
gcry_md_putc ( md, pk->pubkey_algo );
- if (use_v5)
+ if (use_v5) /* Hash the 32 bit length */
{
n -= 10;
gcry_md_putc ( md, n >> 24 );