1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-02-02 16:43:03 +01:00

sos: Fix fingerprint computation.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2019-12-02 11:58:22 +09:00
parent f031b0fb6c
commit 638328a33d
4 changed files with 14 additions and 9 deletions

View File

@ -309,15 +309,7 @@ gpg_mpi_write (iobuf_t out, gcry_mpi_t a, unsigned int *r_nwritten)
/* Strip leading zero bits. */
for (; nbits >= 8 && !*p; p++, nbits -= 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;
CALC_NBITS (nbits, p);
}
/* gcry_log_debug (" [%u bit]\n", nbits); */
/* gcry_log_debughex (" ", p, (nbits+7)/8); */

View File

@ -1336,6 +1336,7 @@ ecckey_from_sexp (gcry_mpi_t *array, gcry_sexp_t sexp, int algo)
goto leave;
}
array[1] = gcry_sexp_nth_mpi (l2, 1, GCRYMPI_FMT_OPAQUE);
gcry_mpi_set_flag (array[1], GCRYMPI_FLAG_USER2);
gcry_sexp_release (l2);
if (!array[1])
{

View File

@ -194,6 +194,8 @@ hash_public_key (gcry_md_hd_t md, PKT_public_key *pk)
pp[i] = NULL;
if (is_sos)
{
const unsigned char *p0 = p;
CALC_NBITS (nbits, p0);
pp[i][0] = (nbits >> 8);
pp[i][1] = nbits;
}

View File

@ -63,6 +63,16 @@
#define is_ELGAMAL(a) ((a)==PUBKEY_ALGO_ELGAMAL_E)
#define is_DSA(a) ((a)==PUBKEY_ALGO_DSA)
#define CALC_NBITS(nbits,p) 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
/* A pointer to the packet object. */
typedef struct packet_struct PACKET;