1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-01-23 15:07:03 +01:00

gpg: Use GCRYMPI_FLAG_USER2 for SOS, and hash_public_key with that.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2019-11-20 17:20:22 +09:00
parent 93bcc87bd0
commit c31fd44737
2 changed files with 13 additions and 3 deletions

View File

@ -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)) else if (gcry_mpi_get_flag (pk->pkey[i], GCRYMPI_FLAG_OPAQUE))
{ {
const void *p; 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); 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) if (p)
memcpy (pp[i], p, (nbits+7)/8); memcpy (pp[i] + is_sos, p, (nbits+7)/8);
else else
pp[i] = NULL; 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]; n += nn[i];
} }
else else

View File

@ -234,6 +234,7 @@ sos_read (iobuf_t inp, unsigned int *ret_nread, int secure)
} }
a = gcry_mpi_set_opaque (NULL, buf, nbits); a = gcry_mpi_set_opaque (NULL, buf, nbits);
gcry_mpi_set_flag (a, GCRYMPI_FLAG_USER2);
*ret_nread = nread; *ret_nread = nread;
return a; return a;