From: Niels Möller Date: Sun, 25 Nov 2018 16:11:39 +0000 (+0100) Subject: testutils.c: Fix high bits of the mpz_urandomb used with mini-gmp. X-Git-Tag: nettle_3.4.1rc1~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a287f1a93118b5cc4b4f4ac2a54216dde5ee01da;p=thirdparty%2Fnettle.git testutils.c: Fix high bits of the mpz_urandomb used with mini-gmp. --- diff --git a/ChangeLog b/ChangeLog index fc7fa0bc..2683e914 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2018-11-25 Niels Möller + * testsuite/testutils.c (mpz_urandomb) [NETTLE_USE_MINI_GMP]: Fix + masking of most significant bits. + * rsa-decrypt-tr.c (rsa_decrypt_tr): Use NETTLE_OCTET_SIZE_TO_LIMB_SIZE. diff --git a/testsuite/testutils.c b/testsuite/testutils.c index 6ce13c4e..c965618b 100644 --- a/testsuite/testutils.c +++ b/testsuite/testutils.c @@ -818,7 +818,7 @@ mpz_urandomb (mpz_t r, struct knuth_lfib_ctx *ctx, mp_bitcnt_t bits) uint8_t *buf = xalloc (bytes); knuth_lfib_random (ctx, bytes, buf); - buf[bytes-1] &= 0xff >> (8*bytes - bits); + buf[0] &= 0xff >> (8*bytes - bits); nettle_mpz_set_str_256_u (r, bytes, buf); free (buf); }