summaryrefslogtreecommitdiffstats
path: root/src/protocols/ec25519_fhmqvc/state.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/protocols/ec25519_fhmqvc/state.c')
-rw-r--r--src/protocols/ec25519_fhmqvc/state.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/protocols/ec25519_fhmqvc/state.c b/src/protocols/ec25519_fhmqvc/state.c
index 79bb6e2..cfb9028 100644
--- a/src/protocols/ec25519_fhmqvc/state.c
+++ b/src/protocols/ec25519_fhmqvc/state.c
@@ -46,12 +46,15 @@ static void init_protocol_state(void) {
/** Generates a new ephemeral keypair */
static void new_handshake_key(keypair_t *key) {
- fastd_random_bytes(key->secret.p, SECRETKEYBYTES, false);
- ecc_25519_gf_sanitize_secret(&key->secret, &key->secret);
+ fastd_random_bytes(key->secret.p, SECRETKEYBYTES, false);
+ ecc_25519_gf_sanitize_secret(&key->secret, &key->secret);
- ecc_25519_work_t work;
- ecc_25519_scalarmult_base(&work, &key->secret);
- ecc_25519_store_packed(&key->public.int256, &work);
+ ecc_25519_work_t work;
+ ecc_25519_scalarmult_base(&work, &key->secret);
+ ecc_25519_store_packed(&key->public.int256, &work);
+
+ if (!divide_key(&key->secret))
+ exit_bug("generated invalid ephemeral key");
}
/**