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
+6 -6
View File
@@ -70,7 +70,7 @@ struct private_pts_t {
/**
* PTS Diffie-Hellman Secret
*/
diffie_hellman_t *dh;
key_exchange_t *dh;
/**
* PTS Diffie-Hellman Initiator Nonce
@@ -200,15 +200,15 @@ METHOD(pts_t, set_dh_hash_algorithm, void,
METHOD(pts_t, create_dh_nonce, bool,
private_pts_t *this, pts_dh_group_t group, int nonce_len)
{
diffie_hellman_group_t dh_group;
key_exchange_method_t dh_group;
chunk_t *nonce;
rng_t *rng;
dh_group = pts_dh_group_to_ike(group);
DBG2(DBG_PTS, "selected PTS DH group is %N",
diffie_hellman_group_names, dh_group);
key_exchange_method_names, dh_group);
DESTROY_IF(this->dh);
this->dh = lib->crypto->create_dh(lib->crypto, dh_group);
this->dh = lib->crypto->create_ke(lib->crypto, dh_group);
rng = lib->crypto->create_rng(lib->crypto, RNG_STRONG);
if (!rng)
@@ -232,7 +232,7 @@ METHOD(pts_t, create_dh_nonce, bool,
METHOD(pts_t, get_my_public_value, bool,
private_pts_t *this, chunk_t *value, chunk_t *nonce)
{
if (!this->dh->get_my_public_value(this->dh, value))
if (!this->dh->get_public_key(this->dh, value))
{
return FALSE;
}
@@ -243,7 +243,7 @@ METHOD(pts_t, get_my_public_value, bool,
METHOD(pts_t, set_peer_public_value, bool,
private_pts_t *this, chunk_t value, chunk_t nonce)
{
if (!this->dh->set_other_public_value(this->dh, value))
if (!this->dh->set_public_key(this->dh, value))
{
return FALSE;
}
+9 -9
View File
@@ -24,44 +24,44 @@
bool pts_dh_group_probe(pts_dh_group_t *dh_groups, bool mandatory_dh_groups)
{
enumerator_t *enumerator;
diffie_hellman_group_t dh_group;
key_exchange_method_t dh_group;
const char *plugin_name;
char format1[] = " %s PTS DH group %N[%s] available";
char format2[] = " %s PTS DH group %N not available";
*dh_groups = PTS_DH_GROUP_NONE;
enumerator = lib->crypto->create_dh_enumerator(lib->crypto);
enumerator = lib->crypto->create_ke_enumerator(lib->crypto);
while (enumerator->enumerate(enumerator, &dh_group, &plugin_name))
{
if (dh_group == MODP_1024_BIT)
{
*dh_groups |= PTS_DH_GROUP_IKE2;
DBG2(DBG_PTS, format1, "optional ", diffie_hellman_group_names,
DBG2(DBG_PTS, format1, "optional ", key_exchange_method_names,
dh_group, plugin_name);
}
else if (dh_group == MODP_1536_BIT)
{
*dh_groups |= PTS_DH_GROUP_IKE5;
DBG2(DBG_PTS, format1, "optional ", diffie_hellman_group_names,
DBG2(DBG_PTS, format1, "optional ", key_exchange_method_names,
dh_group, plugin_name);
}
else if (dh_group == MODP_2048_BIT)
{
*dh_groups |= PTS_DH_GROUP_IKE14;
DBG2(DBG_PTS, format1, "optional ", diffie_hellman_group_names,
DBG2(DBG_PTS, format1, "optional ", key_exchange_method_names,
dh_group, plugin_name);
}
else if (dh_group == ECP_256_BIT)
{
*dh_groups |= PTS_DH_GROUP_IKE19;
DBG2(DBG_PTS, format1, "mandatory", diffie_hellman_group_names,
DBG2(DBG_PTS, format1, "mandatory", key_exchange_method_names,
dh_group, plugin_name);
}
else if (dh_group == ECP_384_BIT)
{
*dh_groups |= PTS_DH_GROUP_IKE20;
DBG2(DBG_PTS, format1, "optional ", diffie_hellman_group_names,
DBG2(DBG_PTS, format1, "optional ", key_exchange_method_names,
dh_group, plugin_name);
}
}
@@ -79,7 +79,7 @@ bool pts_dh_group_probe(pts_dh_group_t *dh_groups, bool mandatory_dh_groups)
}
if (mandatory_dh_groups)
{
DBG1(DBG_PTS, format2, "mandatory", diffie_hellman_group_names,
DBG1(DBG_PTS, format2, "mandatory", key_exchange_method_names,
ECP_256_BIT);
return FALSE;
}
@@ -165,7 +165,7 @@ pts_dh_group_t pts_dh_group_select(pts_dh_group_t supported_dh_groups,
/**
* Described in header.
*/
diffie_hellman_group_t pts_dh_group_to_ike(pts_dh_group_t dh_group)
key_exchange_method_t pts_dh_group_to_ike(pts_dh_group_t dh_group)
{
switch (dh_group)
{
+3 -3
View File
@@ -23,7 +23,7 @@
#define PTS_DH_GROUP_H_
#include <library.h>
#include <crypto/diffie_hellman.h>
#include <crypto/key_exchange.h>
typedef enum pts_dh_group_t pts_dh_group_t;
@@ -98,11 +98,11 @@ pts_dh_group_t pts_dh_group_select(pts_dh_group_t supported_groups,
pts_dh_group_t offered_groups);
/**
* Convert pts_dh_group_t to diffie_hellman_group_t
* Convert pts_dh_group_t to key_exchange_method_t
*
* @param dh_group PTS DH group type
* @return IKE DH group type
*/
diffie_hellman_group_t pts_dh_group_to_ike(pts_dh_group_t dh_group);
key_exchange_method_t pts_dh_group_to_ike(pts_dh_group_t dh_group);
#endif /** PTS_DH_GROUP_H_ @}*/