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
+12 -12
View File
@@ -17,7 +17,7 @@
#include "ntru_private_key.h"
#include "ntru_public_key.h"
#include <crypto/diffie_hellman.h>
#include <crypto/key_exchange.h>
#include <crypto/drbgs/drbg.h>
#include <utils/debug.h>
@@ -55,7 +55,7 @@ struct private_ntru_ke_t {
/**
* Diffie Hellman group number.
*/
diffie_hellman_group_t group;
key_exchange_method_t group;
/**
* NTRU Parameter Set
@@ -108,7 +108,7 @@ struct private_ntru_ke_t {
drbg_t *drbg;
};
METHOD(diffie_hellman_t, get_my_public_value, bool,
METHOD(key_exchange_t, get_public_key, bool,
private_ntru_ke_t *this, chunk_t *value)
{
*value = chunk_empty;
@@ -139,7 +139,7 @@ METHOD(diffie_hellman_t, get_my_public_value, bool,
return TRUE;
}
METHOD(diffie_hellman_t, get_shared_secret, bool,
METHOD(key_exchange_t, get_shared_secret, bool,
private_ntru_ke_t *this, chunk_t *secret)
{
if (!this->computed || !this->shared_secret.len)
@@ -152,7 +152,7 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
return TRUE;
}
METHOD(diffie_hellman_t, set_other_public_value, bool,
METHOD(key_exchange_t, set_public_key, bool,
private_ntru_ke_t *this, chunk_t value)
{
if (this->privkey)
@@ -218,13 +218,13 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
return this->computed;
}
METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
METHOD(key_exchange_t, get_method, key_exchange_method_t,
private_ntru_ke_t *this)
{
return this->group;
}
METHOD(diffie_hellman_t, destroy, void,
METHOD(key_exchange_t, destroy, void,
private_ntru_ke_t *this)
{
DESTROY_IF(this->privkey);
@@ -238,7 +238,7 @@ METHOD(diffie_hellman_t, destroy, void,
/*
* Described in header.
*/
ntru_ke_t *ntru_ke_create(diffie_hellman_group_t group, chunk_t g, chunk_t p)
ntru_ke_t *ntru_ke_create(key_exchange_method_t group, chunk_t g, chunk_t p)
{
private_ntru_ke_t *this;
const ntru_param_set_id_t *param_sets;
@@ -311,11 +311,11 @@ ntru_ke_t *ntru_ke_create(diffie_hellman_group_t group, chunk_t g, chunk_t p)
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,
.get_dh_group = _get_dh_group,
.set_public_key = _set_public_key,
.get_public_key = _get_public_key,
.get_method = _get_method,
.destroy = _destroy,
},
},
+3 -3
View File
@@ -30,9 +30,9 @@ typedef struct ntru_ke_t ntru_ke_t;
struct ntru_ke_t {
/**
* Implements diffie_hellman_t interface.
* Implements key_exchange_t interface.
*/
diffie_hellman_t dh;
key_exchange_t ke;
};
/**
@@ -43,7 +43,7 @@ struct ntru_ke_t {
* @param p not used
* @return ntru_ke_t object, NULL if not supported
*/
ntru_ke_t *ntru_ke_create(diffie_hellman_group_t group, chunk_t g, chunk_t p);
ntru_ke_t *ntru_ke_create(key_exchange_method_t group, chunk_t g, chunk_t p);
#endif /** NTRU_KE_H_ @}*/
+5 -5
View File
@@ -40,20 +40,20 @@ METHOD(plugin_t, get_features, int,
private_ntru_plugin_t *this, plugin_feature_t *features[])
{
static plugin_feature_t f[] = {
PLUGIN_REGISTER(DH, ntru_ke_create),
PLUGIN_PROVIDE(DH, NTRU_112_BIT),
PLUGIN_REGISTER(KE, ntru_ke_create),
PLUGIN_PROVIDE(KE, NTRU_112_BIT),
PLUGIN_DEPENDS(RNG, RNG_TRUE),
PLUGIN_DEPENDS(SIGNER, AUTH_HMAC_SHA2_256_256),
PLUGIN_DEPENDS(XOF, XOF_MGF1_SHA1),
PLUGIN_PROVIDE(DH, NTRU_128_BIT),
PLUGIN_PROVIDE(KE, NTRU_128_BIT),
PLUGIN_DEPENDS(RNG, RNG_TRUE),
PLUGIN_DEPENDS(SIGNER, AUTH_HMAC_SHA2_256_256),
PLUGIN_DEPENDS(XOF, XOF_MGF1_SHA1),
PLUGIN_PROVIDE(DH, NTRU_192_BIT),
PLUGIN_PROVIDE(KE, NTRU_192_BIT),
PLUGIN_DEPENDS(RNG, RNG_TRUE),
PLUGIN_DEPENDS(SIGNER, AUTH_HMAC_SHA2_256_256),
PLUGIN_DEPENDS(XOF, XOF_MGF1_SHA256),
PLUGIN_PROVIDE(DH, NTRU_256_BIT),
PLUGIN_PROVIDE(KE, NTRU_256_BIT),
PLUGIN_DEPENDS(RNG, RNG_TRUE),
PLUGIN_DEPENDS(SIGNER, AUTH_HMAC_SHA2_256_256),
PLUGIN_DEPENDS(XOF, XOF_MGF1_SHA256),