aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2019-11-20 08:20:22 +0000
committerNIIBE Yutaka <[email protected]>2020-05-04 01:57:08 +0000
commitc31fd447373d210fd0aaa577908714f5012e01fb (patch)
tree59fe4dc2720c193a8dd6c201afe040c8129fa06c
parentAdd sos_read. (diff)
downloadgnupg-c31fd447373d210fd0aaa577908714f5012e01fb.tar.gz
gnupg-c31fd447373d210fd0aaa577908714f5012e01fb.zip
gpg: Use GCRYMPI_FLAG_USER2 for SOS, and hash_public_key with that.
Signed-off-by: NIIBE Yutaka <[email protected]>
-rw-r--r--g10/keyid.c15
-rw-r--r--g10/parse-packet.c1
2 files changed, 13 insertions, 3 deletions
diff --git a/g10/keyid.c b/g10/keyid.c
index 0fdb18d88..d3fc29a98 100644
--- a/g10/keyid.c
+++ b/g10/keyid.c
@@ -181,14 +181,23 @@ 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;
+ int is_sos = 0;
+
+ if (gcry_mpi_get_flag (pk->pkey[i], GCRYMPI_FLAG_USER2))
+ is_sos = 2;
p = gcry_mpi_get_opaque (pk->pkey[i], &nbits);
- pp[i] = xmalloc ((nbits+7)/8);
+ pp[i] = xmalloc ((nbits+7)/8 + is_sos);
if (p)
- memcpy (pp[i], p, (nbits+7)/8);
+ memcpy (pp[i] + is_sos, p, (nbits+7)/8);
else
pp[i] = NULL;
- nn[i] = (nbits+7)/8;
+ if (is_sos)
+ {
+ pp[i][0] = (nbits >> 8);
+ pp[i][1] = nbits;
+ }
+ nn[i] = (nbits+7)/8 + is_sos;
n += nn[i];
}
else
diff --git a/g10/parse-packet.c b/g10/parse-packet.c
index c6037d755..54ce04abb 100644
--- a/g10/parse-packet.c
+++ b/g10/parse-packet.c
@@ -234,6 +234,7 @@ sos_read (iobuf_t inp, unsigned int *ret_nread, int secure)
}
a = gcry_mpi_set_opaque (NULL, buf, nbits);
+ gcry_mpi_set_flag (a, GCRYMPI_FLAG_USER2);
*ret_nread = nread;
return a;