gpg: Fix SOS handling with libgcrypt version <= 1.8.

* g10/misc.c (checksum_mpi): Don't depend new feature
of gcry_mpi_print which supports opaque MPI.

--

GnuPG-bug-id: 5116
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2020-10-30 17:03:22 +09:00
parent dd4fb1c8f6
commit 813e24108a
1 changed files with 19 additions and 0 deletions

View File

@ -257,6 +257,25 @@ checksum_mpi (gcry_mpi_t a)
byte *buffer;
size_t nbytes;
/*
* This code can be skipped when gcry_mpi_print
* supports opaque MPI.
*/
if (gcry_mpi_get_flag (a, GCRYMPI_FLAG_OPAQUE))
{
const byte *p;
unsigned int nbits;
p = gcry_mpi_get_opaque (a, &nbits);
if (!p)
return 0;
csum = nbits >> 8;
csum += (nbits & 0xff);
csum += checksum (p, (nbits+7)/8);
return csum;
}
if ( gcry_mpi_print (GCRYMPI_FMT_PGP, NULL, 0, &nbytes, a) )
BUG ();
/* Fixme: For numbers not in secure memory we should use a stack