1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-10 23:49:50 +02:00

scd:openpgp: Fix computing fingerprint for ECC with SOS.

* scd/app-openpgp.c (count_sos_bits): New.  Count as sos_write does.
(store_fpr): For ECC, use count_sos_bits.
--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
(cherry picked from commit 95156ef9bf)
and
(cherry picked from commit f482e4bd12)
This commit is contained in:
NIIBE Yutaka 2021-03-15 17:00:56 +09:00 committed by Werner Koch
parent 24033dc8ae
commit a942986f17
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -672,6 +672,21 @@ count_bits (const unsigned char *a, size_t len)
return n;
}
static unsigned int
count_sos_bits (const unsigned char *a, size_t len)
{
unsigned int n = len * 8;
int i;
if (len == 0 || *a == 0)
return n;
for (i=7; i && !(*a & (1<<i)); i--)
n--;
return n;
}
/* GnuPG makes special use of the login-data DO, this function parses
the login data to store the flags for later use. It may be called
at any time and should be called after changing the login-data DO.
@ -845,12 +860,18 @@ store_fpr (app_t app, int keynumber, u32 timestamp, unsigned char *fpr,
for (i = 0; i < argc; i++)
{
if (algo == PUBKEY_ALGO_RSA || i == 1)
if (algo == PUBKEY_ALGO_RSA)
{
nbits = count_bits (m[i], mlen[i]);
*p++ = nbits >> 8;
*p++ = nbits;
}
else if (i == 1)
{
nbits = count_sos_bits (m[i], mlen[i]);
*p++ = nbits >> 8;
*p++ = nbits;
}
memcpy (p, m[i], mlen[i]);
p += mlen[i];
}