Commit b06db0c7 authored by Michael Hamburg's avatar Michael Hamburg

EdDSA now supports multiple hashes as defined in curve_data.py. We still dont have sha512 though.

parent 9d0bac67
......@@ -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
......
......@@ -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) (
......
......@@ -564,8 +564,6 @@ static void run() {
printf("\n");
}
}; /* template<GroupId GROUP> struct Tests */
/* X25519, X448 test vectors */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment