Rename diffie_hellman_t to key_exchange_t and change the interface etc.

This makes it more generic so we can use it for QSKE methods.
This commit is contained in:
Tobias Brunner
2022-06-29 10:28:50 +02:00
parent ec95fd9b93
commit 3af7c6db87
130 changed files with 1379 additions and 1384 deletions
@@ -54,7 +54,7 @@ struct private_openssl_diffie_hellman_t {
/**
* Diffie Hellman group number.
*/
diffie_hellman_group_t group;
key_exchange_method_t group;
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
/**
@@ -84,13 +84,13 @@ struct private_openssl_diffie_hellman_t {
chunk_t shared_secret;
};
METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
METHOD(key_exchange_t, get_method, key_exchange_method_t,
private_openssl_diffie_hellman_t *this)
{
return this->group;
}
METHOD(diffie_hellman_t, get_my_public_value, bool,
METHOD(key_exchange_t, get_public_key, bool,
private_openssl_diffie_hellman_t *this, chunk_t *value)
{
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
@@ -115,7 +115,7 @@ METHOD(diffie_hellman_t, get_my_public_value, bool,
#endif
}
METHOD(diffie_hellman_t, get_shared_secret, bool,
METHOD(key_exchange_t, get_shared_secret, bool,
private_openssl_diffie_hellman_t *this, chunk_t *secret)
{
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
@@ -151,10 +151,10 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
}
METHOD(diffie_hellman_t, set_other_public_value, bool,
METHOD(key_exchange_t, set_public_key, bool,
private_openssl_diffie_hellman_t *this, chunk_t value)
{
if (!diffie_hellman_verify_value(this->group, value))
if (!key_exchange_verify_pubkey(this->group, value))
{
return FALSE;
}
@@ -204,7 +204,7 @@ static BIGNUM *calculate_public_key(BIGNUM *priv, const BIGNUM *g,
return pub;
}
METHOD(diffie_hellman_t, set_private_value, bool,
METHOD(key_exchange_t, set_private_key, bool,
private_openssl_diffie_hellman_t *this, chunk_t value)
{
BIGNUM *priv, *g = NULL, *p = NULL, *pub = NULL;
@@ -254,7 +254,7 @@ error:
#else /* OPENSSL_VERSION_NUMBER */
METHOD(diffie_hellman_t, set_private_value, bool,
METHOD(key_exchange_t, set_private_key, bool,
private_openssl_diffie_hellman_t *this, chunk_t value)
{
BIGNUM *privkey;
@@ -274,7 +274,7 @@ METHOD(diffie_hellman_t, set_private_value, bool,
#endif /* OPENSSL_VERSION_NUMBER */
METHOD(diffie_hellman_t, destroy, void,
METHOD(key_exchange_t, destroy, void,
private_openssl_diffie_hellman_t *this)
{
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
@@ -292,7 +292,7 @@ METHOD(diffie_hellman_t, destroy, void,
* Described in header.
*/
openssl_diffie_hellman_t *openssl_diffie_hellman_create(
diffie_hellman_group_t group, ...)
key_exchange_method_t group, ...)
{
private_openssl_diffie_hellman_t *this;
BIGNUM *g, *p;
@@ -300,12 +300,12 @@ openssl_diffie_hellman_t *openssl_diffie_hellman_create(
INIT(this,
.public = {
.dh = {
.ke = {
.get_shared_secret = _get_shared_secret,
.set_other_public_value = _set_other_public_value,
.get_my_public_value = _get_my_public_value,
.set_private_value = _set_private_value,
.get_dh_group = _get_dh_group,
.set_public_key = _set_public_key,
.get_public_key = _get_public_key,
.set_private_key = _set_private_key,
.get_method = _get_method,
.destroy = _destroy,
},
},