diff --git a/src/gen_headers/curve_data.py b/src/gen_headers/curve_data.py index 0250c11..d20c234 100644 --- a/src/gen_headers/curve_data.py +++ b/src/gen_headers/curve_data.py @@ -35,8 +35,9 @@ curve_data = { "wnaf":wnaf_config(5,3), "window_bits":4, - "eddsa_hash": "sha512", - "eddsa_supports_contexts": 0 + "eddsa_hash": "sha3_512", # TODO: no, actually it's SHA2-512 + "eddsa_supports_contexts": 0, + "eddsa_dom": "" }, "ed448goldilocks" : { "name" : "Ed448-Goldilocks", @@ -49,7 +50,9 @@ curve_data = { "combs":comb_config(5,5,18), "wnaf":wnaf_config(5,3), - "window_bits":5 + "window_bits":5, + + "eddsa_dom":"SigEd448" } } @@ -106,7 +109,7 @@ for curve,data in curve_data.iteritems(): data["iso_to"] = data["name"] if "eddsa_hash" not in data: - data["edddsa"] = "sha512" + data["eddsa_hash"] = "shake256" if "eddsa_supports_contexts" not in data: data["eddsa_supports_contexts"] = 1 diff --git a/src/per_curve/eddsa.tmpl.c b/src/per_curve/eddsa.tmpl.c index 18ff20f..d647801 100644 --- a/src/per_curve/eddsa.tmpl.c +++ b/src/per_curve/eddsa.tmpl.c @@ -11,12 +11,12 @@ #define API_NAME "$(c_ns)" #define API_NS(_id) $(c_ns)_##_id -#define hash_ctx_t shake256_ctx_t -#define hash_init shake256_init -#define hash_update shake256_update -#define hash_final shake256_final -#define hash_destroy shake256_destroy -#define hash_hash shake256_hash +#define hash_ctx_t $(eddsa_hash)_ctx_t +#define hash_init $(eddsa_hash)_init +#define hash_update $(eddsa_hash)_update +#define hash_final $(eddsa_hash)_final +#define hash_destroy $(eddsa_hash)_destroy +#define hash_hash $(eddsa_hash)_hash #define SUPPORTS_CONTEXTS $(C_NS)_EDDSA_SUPPORTS_CONTEXTS @@ -37,13 +37,21 @@ static void hash_init_with_dom( const uint8_t *context, uint8_t context_len ) { - const char *domS = "SigEd448"; - const uint8_t dom[2] = {1+word_is_zero(prehashed), context_len}; - hash_init(hash); + +#if SUPPORTS_CONTEXTS + const char *domS = "$(eddsa_dom)"; + const uint8_t dom[2] = {1+word_is_zero(prehashed), context_len}; hash_update(hash,(const unsigned char *)domS, strlen(domS)); hash_update(hash,dom,2); hash_update(hash,context,context_len); +#else + (void)prehashed; + (void)context; + assert(context==NULL); + (void)context_len; + assert(context_len == 0); +#endif } void API_NS(eddsa_derive_public_key) ( diff --git a/test/test_decaf.cxx b/test/test_decaf.cxx index 4dd6362..0ac2fcd 100644 --- a/test/test_decaf.cxx +++ b/test/test_decaf.cxx @@ -564,8 +564,6 @@ static void run() { printf("\n"); } - - }; /* template struct Tests */ /* X25519, X448 test vectors */