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
@@ -74,7 +74,7 @@ START_TEST(test_chacha20poly1305)
chunk_t chunk, exp;
keymat_t keymat = {
.get_version = _get_version,
.create_dh = (void*)return_null,
.create_ke = (void*)return_null,
.create_nonce_gen = (void*)return_null,
.get_aead = _get_aead,
};
@@ -332,11 +332,11 @@ void exchange_test_helper_init(char *plugins)
private_exchange_test_helper_t *this;
private_backend_t *backend;
plugin_feature_t features[] = {
PLUGIN_REGISTER(DH, mock_dh_create),
PLUGIN_REGISTER(KE, mock_dh_create),
/* we only need to support a limited number of DH groups */
PLUGIN_PROVIDE(DH, MODP_2048_BIT),
PLUGIN_PROVIDE(DH, MODP_3072_BIT),
PLUGIN_PROVIDE(DH, ECP_256_BIT),
PLUGIN_PROVIDE(KE, MODP_2048_BIT),
PLUGIN_PROVIDE(KE, MODP_3072_BIT),
PLUGIN_PROVIDE(KE, ECP_256_BIT),
PLUGIN_REGISTER(NONCE_GEN, create_nonce_gen),
PLUGIN_PROVIDE(NONCE_GEN),
PLUGIN_DEPENDS(RNG, RNG_WEAK),
+14 -14
View File
@@ -34,41 +34,41 @@ struct private_diffie_hellman_t {
/**
* Public interface
*/
diffie_hellman_t public;
key_exchange_t public;
/**
* Instantiated DH group
* Instantiated key exchagne method
*/
diffie_hellman_group_t group;
key_exchange_method_t method;
};
METHOD(diffie_hellman_t, get_my_public_value, bool,
METHOD(key_exchange_t, get_public_key, bool,
private_diffie_hellman_t *this, chunk_t *value)
{
*value = chunk_clone(mock_key);
return TRUE;
}
METHOD(diffie_hellman_t, set_other_public_value, bool,
METHOD(key_exchange_t, set_public_key, bool,
private_diffie_hellman_t *this, chunk_t value)
{
return TRUE;
}
METHOD(diffie_hellman_t, get_shared_secret, bool,
METHOD(key_exchange_t, get_shared_secret, bool,
private_diffie_hellman_t *this, chunk_t *secret)
{
*secret = chunk_clone(mock_key);
return TRUE;
}
METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
METHOD(key_exchange_t, get_method, key_exchange_method_t,
private_diffie_hellman_t *this)
{
return this->group;
return this->method;
}
METHOD(diffie_hellman_t, destroy, void,
METHOD(key_exchange_t, destroy, void,
private_diffie_hellman_t *this)
{
free(this);
@@ -77,19 +77,19 @@ METHOD(diffie_hellman_t, destroy, void,
/**
* See header
*/
diffie_hellman_t *mock_dh_create(diffie_hellman_group_t group)
key_exchange_t *mock_dh_create(key_exchange_method_t method)
{
private_diffie_hellman_t *this;
INIT(this,
.public = {
.get_shared_secret = _get_shared_secret,
.set_other_public_value = _set_other_public_value,
.get_my_public_value = _get_my_public_value,
.get_dh_group = _get_dh_group,
.set_public_key = _set_public_key,
.get_public_key = _get_public_key,
.get_method = _get_method,
.destroy = _destroy,
},
.group = group,
.method = method,
);
return &this->public;
}
+4 -4
View File
@@ -25,14 +25,14 @@
#ifndef MOCK_DH_H_
#define MOCK_DH_H_
#include <crypto/diffie_hellman.h>
#include <crypto/key_exchange.h>
/**
* Creates a diffie_hellman_t object.
* Creates a key_exchange_t object.
*
* @param group Diffie Hellman group, supports MODP_NULL only
* @param method key_exchange method, supports MODP_NULL only
* @return created object
*/
diffie_hellman_t *mock_dh_create(diffie_hellman_group_t group);
key_exchange_t *mock_dh_create(key_exchange_method_t method);
#endif /** MOCK_DH_H_ @}*/