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:
committed by
Tobias Brunner
parent
47de9ef9a1
commit
40676786aa
@@ -204,8 +204,8 @@ static BIGNUM *calculate_public_key(BIGNUM *priv, const BIGNUM *g,
|
||||
return pub;
|
||||
}
|
||||
|
||||
METHOD(key_exchange_t, set_private_key, bool,
|
||||
private_openssl_diffie_hellman_t *this, chunk_t value)
|
||||
METHOD(key_exchange_t, set_seed, bool,
|
||||
private_openssl_diffie_hellman_t *this, chunk_t value, drbg_t *drbg)
|
||||
{
|
||||
BIGNUM *priv, *g = NULL, *p = NULL, *pub = NULL;
|
||||
OSSL_PARAM_BLD *bld = NULL;
|
||||
@@ -254,8 +254,8 @@ error:
|
||||
|
||||
#else /* OPENSSL_VERSION_NUMBER */
|
||||
|
||||
METHOD(key_exchange_t, set_private_key, bool,
|
||||
private_openssl_diffie_hellman_t *this, chunk_t value)
|
||||
METHOD(key_exchange_t, set_seed, bool,
|
||||
private_openssl_diffie_hellman_t *this, chunk_t value, drbg_t *drbg)
|
||||
{
|
||||
BIGNUM *privkey;
|
||||
|
||||
@@ -304,7 +304,7 @@ openssl_diffie_hellman_t *openssl_diffie_hellman_create(
|
||||
.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,
|
||||
},
|
||||
|
||||
@@ -337,8 +337,8 @@ static bool ecp2chunk(EC_GROUP *group, EC_POINT *point, chunk_t *chunk)
|
||||
return chunk->len;
|
||||
}
|
||||
|
||||
METHOD(key_exchange_t, set_private_key, bool,
|
||||
private_openssl_ec_diffie_hellman_t *this, chunk_t value)
|
||||
METHOD(key_exchange_t, set_seed, bool,
|
||||
private_openssl_ec_diffie_hellman_t *this, chunk_t value, drbg_t *drbg)
|
||||
{
|
||||
BIGNUM *priv = NULL;
|
||||
EC_POINT *pub = NULL;
|
||||
@@ -390,8 +390,8 @@ METHOD(key_exchange_t, set_private_key, bool,
|
||||
|
||||
#else /* OPENSSL_VERSION_NUMBER */
|
||||
|
||||
METHOD(key_exchange_t, set_private_key, bool,
|
||||
private_openssl_ec_diffie_hellman_t *this, chunk_t value)
|
||||
METHOD(key_exchange_t, set_seed, bool,
|
||||
private_openssl_ec_diffie_hellman_t *this, chunk_t value, drbg_t *drbg)
|
||||
{
|
||||
EC_KEY *key = NULL;
|
||||
EC_POINT *pub = NULL;
|
||||
@@ -460,7 +460,7 @@ openssl_ec_diffie_hellman_t *openssl_ec_diffie_hellman_create(key_exchange_metho
|
||||
.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,
|
||||
},
|
||||
|
||||
@@ -114,8 +114,8 @@ METHOD(key_exchange_t, get_public_key, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(key_exchange_t, set_private_key, bool,
|
||||
private_key_exchange_t *this, chunk_t value)
|
||||
METHOD(key_exchange_t, set_seed, bool,
|
||||
private_key_exchange_t *this, chunk_t value, drbg_t *drbg)
|
||||
{
|
||||
EVP_PKEY_free(this->key);
|
||||
this->key = EVP_PKEY_new_raw_private_key(map_key_type(this->ke), NULL,
|
||||
@@ -193,7 +193,7 @@ key_exchange_t *openssl_x_diffie_hellman_create(key_exchange_method_t ke)
|
||||
.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,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user