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
@@ -73,7 +73,7 @@ static bool generate_key(private_curve25519_dh_t *this)
return this->drv->set_key(this->drv, key);
}
METHOD(diffie_hellman_t, set_other_public_value, bool,
METHOD(key_exchange_t, set_public_key, bool,
private_curve25519_dh_t *this, chunk_t value)
{
if (value.len == CURVE25519_KEY_SIZE)
@@ -87,7 +87,7 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
return FALSE;
}
METHOD(diffie_hellman_t, get_my_public_value, bool,
METHOD(key_exchange_t, get_public_key, bool,
private_curve25519_dh_t *this, chunk_t *value)
{
u_char basepoint[CURVE25519_KEY_SIZE] = { 9 };
@@ -101,7 +101,7 @@ METHOD(diffie_hellman_t, get_my_public_value, bool,
return FALSE;
}
METHOD(diffie_hellman_t, set_private_value, bool,
METHOD(key_exchange_t, set_private_key, bool,
private_curve25519_dh_t *this, chunk_t value)
{
if (value.len != CURVE25519_KEY_SIZE)
@@ -111,7 +111,7 @@ METHOD(diffie_hellman_t, set_private_value, bool,
return this->drv->set_key(this->drv, value.ptr);
}
METHOD(diffie_hellman_t, get_shared_secret, bool,
METHOD(key_exchange_t, get_shared_secret, bool,
private_curve25519_dh_t *this, chunk_t *secret)
{
if (!this->computed)
@@ -122,13 +122,13 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
return TRUE;
}
METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
METHOD(key_exchange_t, get_method, key_exchange_method_t,
private_curve25519_dh_t *this)
{
return CURVE_25519;
}
METHOD(diffie_hellman_t, destroy, void,
METHOD(key_exchange_t, destroy, void,
private_curve25519_dh_t *this)
{
this->drv->destroy(this->drv);
@@ -138,7 +138,7 @@ METHOD(diffie_hellman_t, destroy, void,
/*
* Described in header.
*/
curve25519_dh_t *curve25519_dh_create(diffie_hellman_group_t group)
curve25519_dh_t *curve25519_dh_create(key_exchange_method_t group)
{
private_curve25519_dh_t *this;
@@ -149,12 +149,12 @@ curve25519_dh_t *curve25519_dh_create(diffie_hellman_group_t group)
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,
},
},
@@ -32,9 +32,9 @@ typedef struct curve25519_dh_t curve25519_dh_t;
struct curve25519_dh_t {
/**
* Implements diffie_hellman_t interface.
* Implements key_exchange_t interface.
*/
diffie_hellman_t dh;
key_exchange_t ke;
};
/**
@@ -43,6 +43,6 @@ struct curve25519_dh_t {
* @param group DH group, CURVE_25519
* @return curve25519_dh_t object, NULL on error
*/
curve25519_dh_t *curve25519_dh_create(diffie_hellman_group_t group);
curve25519_dh_t *curve25519_dh_create(key_exchange_method_t group);
#endif /** CURVE25519_DH_H_ @}*/
@@ -47,8 +47,8 @@ METHOD(plugin_t, get_features, int,
{
static plugin_feature_t f[] = {
/* X25519 DH group */
PLUGIN_REGISTER(DH, curve25519_dh_create),
PLUGIN_PROVIDE(DH, CURVE_25519),
PLUGIN_REGISTER(KE, curve25519_dh_create),
PLUGIN_PROVIDE(KE, CURVE_25519),
PLUGIN_DEPENDS(RNG, RNG_STRONG),
/* Ed25519 private/public keys */
PLUGIN_REGISTER(PRIVKEY, curve25519_private_key_load, TRUE),