aboutsummaryrefslogtreecommitdiffstats
path: root/scd/app-openpgp.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2021-03-12 07:20:28 +0000
committerNIIBE Yutaka <[email protected]>2021-03-12 07:20:28 +0000
commit95156ef9bfb6a3a525454d50ae2f5b538ccbd774 (patch)
treea447f71215f764d250ff86b89f02a6d438d07163 /scd/app-openpgp.c
parentgpg: Fix compute_fingerprint for ECC with SOS. (diff)
downloadgnupg-95156ef9bfb6a3a525454d50ae2f5b538ccbd774.tar.gz
gnupg-95156ef9bfb6a3a525454d50ae2f5b538ccbd774.zip
scd: 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 <[email protected]>
Diffstat (limited to 'scd/app-openpgp.c')
-rw-r--r--scd/app-openpgp.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/scd/app-openpgp.c b/scd/app-openpgp.c
index 918452cd0..987a31be3 100644
--- a/scd/app-openpgp.c
+++ b/scd/app-openpgp.c
@@ -717,6 +717,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 (*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.
@@ -890,12 +905,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];
}