Home GnuPG

gcry_mpi_sub_ui: fix subtracting from negative value

Description

gcry_mpi_sub_ui: fix subtracting from negative value

* mpi/mpi-add.c (_gcry_mpi_sub_ui): Set output sign bit when 'u'
is negative.
* tests/mpitests.c (test_add): Additional tests for mpi_add_ui; Check
test output and fail if output does not match expected.
(test_sub): Additional tests for mpi_sub_ui; Check test output and fail
if output does not match expected.
(test_mul): Additional tests for mpi_mul_ui; Check test output and fail
if output does not match expected.
  • Reported-by: Guido Vranken <guidovranken@gmail.com>
  • Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>

Details

Provenance
jukiviliAuthored on Nov 30 2021, 9:04 PM
Parents
rCbff9ed54285b: tests: Fix basic.c to show useful information on error.
Branches
Unknown
Tags
Unknown