| @@ -17,12 +17,27 @@ from decaf_h import decaf_h | |||||
| from crypto_h import crypto_h | from crypto_h import crypto_h | ||||
| from crypto_hxx import crypto_hxx | from crypto_hxx import crypto_hxx | ||||
| from f_field_h import f_field_h | from f_field_h import f_field_h | ||||
| from curve_data import curve_data | |||||
| root_hxx_code = "\n".join(( | root_hxx_code = "\n".join(( | ||||
| "#include <%s>" % name | "#include <%s>" % name | ||||
| for name in sorted(gend_files) | for name in sorted(gend_files) | ||||
| if re.match("^decaf/decaf_\d+.hxx$",name) | 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( | decaf_root_hxx = gen_file( | ||||
| public = True, | public = True, | ||||
| per = "global", | per = "global", | ||||
| @@ -387,6 +387,9 @@ static void micro() { | |||||
| }; /* template <typename group> struct Benches */ | }; /* 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) { | int main(int argc, char **argv) { | ||||
| bool micro = false; | bool micro = false; | ||||
| @@ -422,13 +425,10 @@ int main(int argc, char **argv) { | |||||
| strobe.encrypt_no_auth(Buffer(b1024,1024),Buffer(b1024,1024)); | 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"); | printf("\n"); | ||||
| Benchmark::calib(); | Benchmark::calib(); | ||||
| @@ -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) { | int main(int argc, char **argv) { | ||||
| (void) argc; (void) argv; | (void) argc; (void) argv; | ||||
| VALGRIND_MAKE_MEM_UNDEFINED(undef_str, strlen(undef_str)); | 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; | return 0; | ||||
| } | } | ||||
| @@ -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<GroupId GROUP> struct Tests */ | ||||
| template<> const uint8_t Tests<IsoEd25519>::rfc7748_1[32] = { | 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<Ed448Goldilocks>::elli_patho(elli_patho_448,56); | ||||
| template<> const Block Tests<IsoEd25519>::elli_patho(NULL,0); | template<> const Block Tests<IsoEd25519>::elli_patho(NULL,0); | ||||
| int main(int argc, char **argv) { | int main(int argc, char **argv) { | ||||
| (void) argc; (void) 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"); | if (passing) printf("Passed all tests.\n"); | ||||
| return passing ? 0 : 1; | return passing ? 0 : 1; | ||||
| } | } | ||||