aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2020-10-30 17:03:22 +0900
committerNIIBE Yutaka <gniibe@fsij.org>2020-10-30 17:03:22 +0900
commit813e24108a139c8059dad8bc679b2ab76b807ed9 (patch)
treef7bcd75e291436d4df10962d405c2ec2d0131f68
parentdd4fb1c8f668f78fbcf5052e80c5c40d4cdad20c (diff)
downloadgnupg-813e24108a139c8059dad8bc679b2ab76b807ed9.tar.gz
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>
-rw-r--r--g10/misc.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/g10/misc.c b/g10/misc.c
index 111a916e8..0d457365b 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -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