key-exchange: Joint ke_test_vector format for DH and KEM

Both Diffie-Hellman (DH) and Key Encapsulation Mechanism (KEM) based
key exchange methods use a common ke_test_vector format. The
set_seed() function is used to provide deterministic private key
material for the crypto tests.
This commit is contained in:
Andreas Steffen
2024-11-21 14:26:35 +01:00
committed by Tobias Brunner
parent 47de9ef9a1
commit 40676786aa
21 changed files with 1952 additions and 1187 deletions
@@ -135,8 +135,8 @@ METHOD(key_exchange_t, get_public_key, bool,
return TRUE;
}
METHOD(key_exchange_t, set_private_key, bool,
private_gmp_diffie_hellman_t *this, chunk_t value)
METHOD(key_exchange_t, set_seed, bool,
private_gmp_diffie_hellman_t *this, chunk_t value, drbg_t *drbg)
{
mpz_import(this->xa, value.len, 1, 1, 1, 0, value.ptr);
mpz_powm(this->ya, this->g, this->xa, this->p);
@@ -228,7 +228,7 @@ static gmp_diffie_hellman_t *create_generic(key_exchange_method_t group,
.get_shared_secret = _get_shared_secret,
.set_public_key = _set_public_key,
.get_public_key = _get_public_key,
.set_private_key = _set_private_key,
.set_seed = _set_seed,
.get_method = _get_method,
.destroy = _destroy,
},