From: Niels Möller Date: Sun, 9 Apr 2017 10:23:59 +0000 (+0200) Subject: Delete valgrind magic in pss-test. X-Git-Tag: nettle_3.4rc1~53 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=870ede284c573fac70d8598a7bbaffcae78ad398;p=thirdparty%2Fnettle.git Delete valgrind magic in pss-test. * testsuite/pss-test.c: Delete magic to let valgrind to check if pss_encode_mgf1 is side-channel silent with respect to the salt and digest inputs. It turns out that the most significant bits of the padded bignum, and hence its size, depends on these inputs. Which results in a data-dependent branch in the normalization code of at the end of gmp's mpz_import. --- diff --git a/ChangeLog b/ChangeLog index 369712bd..ba6a1b93 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2017-04-09 Niels Möller + + * testsuite/pss-test.c: Delete magic to let valgrind to check if + pss_encode_mgf1 is side-channel silent with respect to the salt + and digest inputs. It turns out that the most significant bits of + the padded bignum, and hence its size, depends on these inputs. + Which results in a data-dependent branch in the normalization code + of at the end of gmp's mpz_import. + 2017-04-04 Niels Möller * pss.c (pss_verify_mgf1): Use const for input mpz_t argument. diff --git a/testsuite/pss-test.c b/testsuite/pss-test.c index 81226554..f6ba697c 100644 --- a/testsuite/pss-test.c +++ b/testsuite/pss-test.c @@ -2,38 +2,6 @@ #include "pss.h" -#if HAVE_VALGRIND_MEMCHECK_H -# include - -static void -test_unmark_mpz(mpz_t m) -{ - VALGRIND_MAKE_MEM_DEFINED (m, sizeof(*m)); - VALGRIND_MAKE_MEM_DEFINED (&m->_mp_d, sizeof(mp_limb_t) * mpz_size(m)); -} - -static int -pss_encode_mgf1_for_test(mpz_t m, size_t bits, - const struct nettle_hash *hash, - size_t salt_length, const uint8_t *salt, - const uint8_t *digest) -{ - int res; - - /* Makes valgrind trigger on any branches depending on the input - data. */ - VALGRIND_MAKE_MEM_UNDEFINED (salt, salt_length); - VALGRIND_MAKE_MEM_UNDEFINED (digest, hash->digest_size); - - res = pss_encode_mgf1 (m, bits, hash, salt_length, salt, digest); - VALGRIND_MAKE_MEM_DEFINED (&res, sizeof(res)); - test_unmark_mpz (m); - return res; -} -#else -#define pss_encode_mgf1_for_test pss_encode_mgf1 -#endif - void test_main(void) {