diff --git a/ChangeLog b/ChangeLog index 0a98d67397616c441a0d4fbd8aaa7052151ed85b..ca7d7bf7dae8610a3752e69454485bcedb292923 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,17 +1,19 @@ 2023-11-15 Niels Möller <nisse@lysator.liu.se> + * ecc-mod-arith.c (ecc_mod_addmul_1): Use assert_maybe. + * ecc-curve448.c (ecc_curve448_modp): Likewise. + * testsuite/curve25519-dh-test.c (test_g): Add calls to mark_bytes_undefined and mark_bytes_defined. (test_a): Likewise. (test_main): Skip side-channel tests in builds with mini-gmp or extra asserts enabled. - - * ecc-mod-arith.c (ecc_mod_addmul_1): Use assert_maybe. + * testsuite/curve448-dh-test.c: Analogous changes. * testsuite/Makefile.in (TS_SC_HOGWEED): New make variable. Added - sc-curve25519-dh-test to list. - + sc-curve25519-dh-test and sc-curve448-dh-test to list. * testsuite/sc-curve25519-dh-test: New testcase. + * testsuite/sc-curve448-dh-test: New testcase. 2023-11-14 Niels Möller <nisse@lysator.liu.se> diff --git a/ecc-curve448.c b/ecc-curve448.c index daef56cc83654ddf084012194c30cb9916681eba..1bffeeb7cb323795c83c0f9d31ebe14020917821 100644 --- a/ecc-curve448.c +++ b/ecc-curve448.c @@ -91,7 +91,7 @@ ecc_curve448_modp(const struct ecc_modulo *m, mp_limb_t *rp, mp_limb_t *xp) tp[5] = tp[6] = 0; c7 = mpn_add_n (rp, xp, tp, 7); c7 = mpn_cnd_add_n (c7, rp, rp, m->B, 7); - assert (c7 == 0); + assert_maybe (c7 == 0); } #else #define ecc_curve448_modp ecc_mod diff --git a/testsuite/Makefile.in b/testsuite/Makefile.in index b8bce5564799669b0898876edf542c849f9bdb17..cf3d962cb108399f4ecb9513ba274ee19537eaf8 100644 --- a/testsuite/Makefile.in +++ b/testsuite/Makefile.in @@ -67,7 +67,7 @@ TS_C = $(TS_NETTLE) @IF_HOGWEED@ $(TS_HOGWEED) TS_CXX = @IF_CXX@ $(CXX_SOURCES:.cxx=$(EXEEXT)) TARGETS = $(TS_C) $(TS_CXX) TS_SC_HOGWEED = sc-pkcs1-sec-decrypt-test sc-rsa-sec-decrypt-test \ - sc-ecdsa-sign-test sc-curve25519-dh-test + sc-ecdsa-sign-test sc-curve25519-dh-test sc-curve448-dh-test TS_SC = sc-cnd-memcpy-test sc-gcm-test sc-memeql-test \ @IF_HOGWEED@ $(TS_SC_HOGWEED) diff --git a/testsuite/curve448-dh-test.c b/testsuite/curve448-dh-test.c index 7d142d6f350b789bb1b96f8439210f5cb627fb54..c91a57532335e321e6d257564cc843361b598983 100644 --- a/testsuite/curve448-dh-test.c +++ b/testsuite/curve448-dh-test.c @@ -38,7 +38,10 @@ static void test_g (const uint8_t *s, const uint8_t *r) { uint8_t p[CURVE448_SIZE]; + mark_bytes_undefined (CURVE448_SIZE, s); curve448_mul_g (p, s); + mark_bytes_defined (CURVE448_SIZE, p); + if (!MEMEQ (CURVE448_SIZE, p, r)) { printf ("curve448_mul_g failure:\ns = "); @@ -56,7 +59,11 @@ static void test_a (const uint8_t *s, const uint8_t *b, const uint8_t *r) { uint8_t p[CURVE448_SIZE]; + mark_bytes_undefined (CURVE448_SIZE, s); + mark_bytes_undefined (CURVE448_SIZE, b); curve448_mul (p, s, b); + mark_bytes_defined (CURVE448_SIZE, p); + if (!MEMEQ (CURVE448_SIZE, p, r)) { printf ("curve448_mul failure:\ns = "); @@ -75,6 +82,10 @@ test_a (const uint8_t *s, const uint8_t *b, const uint8_t *r) void test_main (void) { +#if NETTLE_USE_MINI_GMP || WITH_EXTRA_ASSERTS + if (test_side_channel) + SKIP(); +#endif /* From RFC 7748. */ test_g (H("9a8f4925d1519f5775cf46b04b5800d4ee9ee8bae8bc5565d498c28d" "d9c9baf574a9419744897391006382a6f127ab1d9ac2d8c0a598726b"), diff --git a/testsuite/sc-curve448-dh-test b/testsuite/sc-curve448-dh-test new file mode 100755 index 0000000000000000000000000000000000000000..fdd59bdc514ea2eb95a08fe7d8c3df9129d6acc9 --- /dev/null +++ b/testsuite/sc-curve448-dh-test @@ -0,0 +1,6 @@ +#! /bin/sh + +srcdir=`dirname $0` +. "${srcdir}/sc-valgrind.sh" + +with_valgrind ./curve448-dh-test