From 51ac192b79556110e3bb51a6a9e99f6364a01d73 Mon Sep 17 00:00:00 2001 From: Mike Hamburg Date: Sat, 23 Jan 2016 17:12:14 -0800 Subject: [PATCH] ct tests are in; succeed if -DNDEBUG is passed. Should carefully audit assertions. --- src/public_include/decaf/shake.hxx | 5 ---- test/test_ct.cxx | 37 +++++++++++++++++------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/public_include/decaf/shake.hxx b/src/public_include/decaf/shake.hxx index eeb356b..6fe2d6e 100644 --- a/src/public_include/decaf/shake.hxx +++ b/src/public_include/decaf/shake.hxx @@ -181,11 +181,6 @@ public: } } - /** Stir in new data */ - inline void stir( const std::string &data ) NOEXCEPT { - spongerng_stir(sp,(const unsigned char *__restrict__)data.data(),data.size()); - } - /** Stir in new data */ inline void stir( const Block &data ) NOEXCEPT { spongerng_stir(sp,data.data(),data.size()); diff --git a/test/test_ct.cxx b/test/test_ct.cxx index 9bb091d..54a14f1 100644 --- a/test/test_ct.cxx +++ b/test/test_ct.cxx @@ -14,15 +14,19 @@ #include #include #include -#include +#include using namespace decaf; -static const long NTESTS = 100; +static const long NTESTS = 1; -const char *undef_str = "Valgrind thinks this string is undefined." +const char *undef_str = "Valgrind thinks this string is undefined."; const Block undef_block(undef_str); +static inline void ignore(decaf_error_t x) { + (void)x; +} + template struct Tests { typedef typename Group::Scalar Scalar; @@ -31,27 +35,26 @@ typedef typename Group::Precomputed Precomputed; static void test_arithmetic() { SpongeRng rng(Block("test_arithmetic")); - rng.stir(undef_str); + rng.stir(undef_block); - Test test("Arithmetic"); Scalar x(rng),y(rng),z; - FixedBlock Ser; + uint8_t ser[Group::Scalar::SER_BYTES]; for (int i=0; i(ser))); (void)(p*y); (void)(p+q); (void)(p-q); @@ -75,10 +82,10 @@ static void test_ec() { (void)(p.times_two()); (void)(p==q); (void)(p.debugging_torque()); - (void)(p.non_secret_combo_with_base(y,z)); // Should fail + //(void)(p.non_secret_combo_with_base(y,z)); // Should fail (void)(Precomputed(p)*y); p.dual_scalarmul(q,r,y,z); - p.double_scalarmul(q,r,y,z); + Group::Point::double_scalarmul(p,y,q,z); } } @@ -107,7 +114,5 @@ int main(int argc, char **argv) { Tests::test_ec(); Tests::test_crypto(); - if (passing) printf("Passed all tests.\n"); - - return passing ? 0 : 1; + return 0; }