Browse Source

test/bench now uses run_for_all_curves<>

master
Michael Hamburg 8 years ago
parent
commit
050dcc186f
4 changed files with 48 additions and 45 deletions
  1. +15
    -0
      src/gen_headers/main.py
  2. +6
    -6
      test/bench_decaf.cxx
  3. +12
    -18
      test/test_ct.cxx
  4. +15
    -21
      test/test_decaf.cxx

+ 15
- 0
src/gen_headers/main.py View File

@@ -17,12 +17,27 @@ from decaf_h import decaf_h
from crypto_h import crypto_h
from crypto_hxx import crypto_hxx
from f_field_h import f_field_h
from curve_data import curve_data

root_hxx_code = "\n".join((
"#include <%s>" % name
for name in sorted(gend_files)
if re.match("^decaf/decaf_\d+.hxx$",name)
))
root_hxx_code += """

namespace decaf {
template <template<typename Group> class Run>
void run_for_all_curves() {
"""
root_hxx_code += "\n".join((
" Run<%s>::run();" % cd["cxx_ns"]
for cd in sorted(curve_data.values(), key=lambda x:x["c_ns"])
))
root_hxx_code += """
}
}
"""
decaf_root_hxx = gen_file(
public = True,
per = "global",


+ 6
- 6
test/bench_decaf.cxx View File

@@ -387,6 +387,9 @@ static void micro() {

}; /* template <typename group> struct Benches */

template <typename Group> struct Macro { static void run() { Benches<Group>::macro(); } };
template <typename Group> struct Micro { static void run() { Benches<Group>::micro(); } };

int main(int argc, char **argv) {
bool micro = false;
@@ -422,13 +425,10 @@ int main(int argc, char **argv) {
strobe.encrypt_no_auth(Buffer(b1024,1024),Buffer(b1024,1024));
}
Benches<IsoEd25519>::micro();
Benches<Ed448Goldilocks>::micro();
run_for_all_curves<Micro>();
}

Benches<IsoEd25519>::macro();
Benches<Ed448Goldilocks>::macro();

run_for_all_curves<Macro>();
printf("\n");
Benchmark::calib();


+ 12
- 18
test/test_ct.cxx View File

@@ -134,27 +134,21 @@ static void test_crypto() {
}
}

}; /* template<GroupId GROUP> */
static void run() {
printf("Testing %s:\n",Group::name());
test_arithmetic();
test_elligator();
test_ec();
test_cfrg();
test_crypto();
printf("\n");
}

}; /* template<GroupId GROUP> struct Tests */

int main(int argc, char **argv) {
(void) argc; (void) argv;
VALGRIND_MAKE_MEM_UNDEFINED(undef_str, strlen(undef_str));
printf("Testing %s:\n",IsoEd25519::name());
Tests<IsoEd25519>::test_arithmetic();
Tests<IsoEd25519>::test_elligator();
Tests<IsoEd25519>::test_ec();
Tests<IsoEd25519>::test_cfrg();
Tests<IsoEd25519>::test_crypto();
printf("\n");
printf("Testing %s:\n", Ed448Goldilocks::name());
Tests<Ed448Goldilocks>::test_arithmetic();
Tests<Ed448Goldilocks>::test_elligator();
Tests<Ed448Goldilocks>::test_ec();
Tests<Ed448Goldilocks>::test_cfrg();
Tests<Ed448Goldilocks>::test_crypto();
run_for_all_curves<Tests>();
return 0;
}

+ 15
- 21
test/test_decaf.cxx View File

@@ -489,6 +489,20 @@ static void test_cfrg_vectors() {
}
}


static void run() {
printf("Testing %s:\n",Group::name());
test_arithmetic();
test_elligator();
test_ec();
test_cfrg_crypto();
test_cfrg_vectors();
test_crypto();
printf("\n");
}



}; /* template<GroupId GROUP> struct Tests */

template<> const uint8_t Tests<IsoEd25519>::rfc7748_1[32] = {
@@ -566,30 +580,10 @@ const uint8_t elli_patho_448[56] = {
};
template<> const Block Tests<Ed448Goldilocks>::elli_patho(elli_patho_448,56);
template<> const Block Tests<IsoEd25519>::elli_patho(NULL,0);

int main(int argc, char **argv) {
(void) argc; (void) argv;
printf("Testing %s:\n",IsoEd25519::name());
Tests<IsoEd25519>::test_arithmetic();
Tests<IsoEd25519>::test_elligator();
Tests<IsoEd25519>::test_ec();
Tests<IsoEd25519>::test_cfrg_crypto();
Tests<IsoEd25519>::test_cfrg_vectors();
Tests<IsoEd25519>::test_crypto();

printf("\n");
printf("Testing %s:\n", Ed448Goldilocks::name());
Tests<Ed448Goldilocks>::test_arithmetic();
Tests<Ed448Goldilocks>::test_elligator();
Tests<Ed448Goldilocks>::test_ec();
Tests<Ed448Goldilocks>::test_cfrg_crypto();
Tests<Ed448Goldilocks>::test_cfrg_vectors();
Tests<Ed448Goldilocks>::test_crypto();
run_for_all_curves<Tests>();
if (passing) printf("Passed all tests.\n");
return passing ? 0 : 1;
}

Loading…
Cancel
Save