diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2021-03-12 08:15:04 +0100 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2021-03-12 08:15:04 +0100 |
commit | cfc1497efa8c98cf490f5efc9b280a6ec44514bd (patch) | |
tree | 4d7c816835efb6543f7f33853d379174d14e0f5f /g10 | |
parent | scd:piv: Improve APT parser compatibility. (diff) | |
download | gnupg2-cfc1497efa8c98cf490f5efc9b280a6ec44514bd.tar.xz gnupg2-cfc1497efa8c98cf490f5efc9b280a6ec44514bd.zip |
gpg: Fix compute_fingerprint for ECC with SOS.
* g10/keyid.c (hash_public_key): Tweak NBITS just as sos_write does.
--
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to 'g10')
-rw-r--r-- | g10/keyid.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/g10/keyid.c b/g10/keyid.c index caf2e4f6f..522cc9cda 100644 --- a/g10/keyid.c +++ b/g10/keyid.c @@ -180,7 +180,7 @@ hash_public_key (gcry_md_hd_t md, PKT_public_key *pk) } else if (gcry_mpi_get_flag (pk->pkey[i], GCRYMPI_FLAG_OPAQUE)) { - const void *p; + const char *p; int is_sos = 0; if (gcry_mpi_get_flag (pk->pkey[i], GCRYMPI_FLAG_USER2)) @@ -194,6 +194,21 @@ hash_public_key (gcry_md_hd_t md, PKT_public_key *pk) pp[i] = NULL; if (is_sos) { + if (*p) + { + nbits = ((nbits + 7) / 8) * 8; + + if (nbits >= 8 && !(*p & 0x80)) + if (--nbits >= 7 && !(*p & 0x40)) + if (--nbits >= 6 && !(*p & 0x20)) + if (--nbits >= 5 && !(*p & 0x10)) + if (--nbits >= 4 && !(*p & 0x08)) + if (--nbits >= 3 && !(*p & 0x04)) + if (--nbits >= 2 && !(*p & 0x02)) + if (--nbits >= 1 && !(*p & 0x01)) + --nbits; + } + pp[i][0] = (nbits >> 8); pp[i][1] = nbits; } |