From 1f3a92e103d4a8e019d8d022647a2b9fb2681327 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 6 Jul 2020 12:01:42 +0200 Subject: mpi: Consider +0 and -0 the same in mpi_cmp. * mpi/mpi-cmp.c (do_mpi_cmp): Check size of U an V. Signed-off-by: Werner Koch --- mpi/mpi-cmp.c | 5 ++++- mpi/mpiutil.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mpi/mpi-cmp.c b/mpi/mpi-cmp.c index 66e09612..8927fa0e 100644 --- a/mpi/mpi-cmp.c +++ b/mpi/mpi-cmp.c @@ -89,8 +89,11 @@ do_mpi_cmp (gcry_mpi_t u, gcry_mpi_t v, int absmode) usign = absmode? 0 : u->sign; vsign = absmode? 0 : v->sign; - /* Compare sign bits. */ + /* Special treatment for +0 == -0 */ + if (!usize && !vsize) + return 0; + /* Compare sign bits. */ if (!usign && vsign) return 1; if (usign && !vsign) diff --git a/mpi/mpiutil.c b/mpi/mpiutil.c index a9e812e2..86b8361e 100644 --- a/mpi/mpiutil.c +++ b/mpi/mpiutil.c @@ -561,7 +561,7 @@ _gcry_mpi_set_ui (gcry_mpi_t w, unsigned long u) * int so that the value can be used with the bit test functions; in * contrast the other _ui functions take an unsigned long so that on * some platforms they may accept a larger value. On error the value - * at U is not changed. */ + * at W is not changed. */ gcry_err_code_t _gcry_mpi_get_ui (unsigned int *w, gcry_mpi_t u) { -- cgit v1.2.1