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:
@@ -51,7 +51,7 @@ struct private_ha_child_t {
|
||||
|
||||
METHOD(listener_t, child_keys, bool,
|
||||
private_ha_child_t *this, ike_sa_t *ike_sa, child_sa_t *child_sa,
|
||||
bool initiator, diffie_hellman_t *dh, chunk_t nonce_i, chunk_t nonce_r)
|
||||
bool initiator, key_exchange_t *dh, chunk_t nonce_i, chunk_t nonce_r)
|
||||
{
|
||||
ha_message_t *m;
|
||||
chunk_t secret;
|
||||
@@ -92,7 +92,7 @@ METHOD(listener_t, child_keys, bool,
|
||||
{
|
||||
m->add_attribute(m, HA_ALG_INTEG, alg);
|
||||
}
|
||||
if (proposal->get_algorithm(proposal, DIFFIE_HELLMAN_GROUP, &alg, NULL))
|
||||
if (proposal->get_algorithm(proposal, KEY_EXCHANGE_METHOD, &alg, NULL))
|
||||
{
|
||||
m->add_attribute(m, HA_ALG_DH, alg);
|
||||
}
|
||||
|
||||
@@ -67,9 +67,9 @@ struct private_ha_dispatcher_t {
|
||||
struct ha_diffie_hellman_t {
|
||||
|
||||
/**
|
||||
* Implements diffie_hellman_t
|
||||
* Implements key_exchange_t
|
||||
*/
|
||||
diffie_hellman_t dh;
|
||||
key_exchange_t dh;
|
||||
|
||||
/**
|
||||
* Shared secret
|
||||
@@ -82,21 +82,21 @@ struct ha_diffie_hellman_t {
|
||||
chunk_t pub;
|
||||
};
|
||||
|
||||
METHOD(diffie_hellman_t, dh_get_shared_secret, bool,
|
||||
METHOD(key_exchange_t, dh_get_shared_secret, bool,
|
||||
ha_diffie_hellman_t *this, chunk_t *secret)
|
||||
{
|
||||
*secret = chunk_clone(this->secret);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, dh_get_my_public_value, bool,
|
||||
METHOD(key_exchange_t, dh_get_public_key, bool,
|
||||
ha_diffie_hellman_t *this, chunk_t *value)
|
||||
{
|
||||
*value = chunk_clone(this->pub);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, dh_destroy, void,
|
||||
METHOD(key_exchange_t, dh_destroy, void,
|
||||
ha_diffie_hellman_t *this)
|
||||
{
|
||||
free(this);
|
||||
@@ -105,14 +105,14 @@ METHOD(diffie_hellman_t, dh_destroy, void,
|
||||
/**
|
||||
* Create a HA synced DH implementation
|
||||
*/
|
||||
static diffie_hellman_t *ha_diffie_hellman_create(chunk_t secret, chunk_t pub)
|
||||
static key_exchange_t *ha_diffie_hellman_create(chunk_t secret, chunk_t pub)
|
||||
{
|
||||
ha_diffie_hellman_t *this;
|
||||
|
||||
INIT(this,
|
||||
.dh = {
|
||||
.get_shared_secret = _dh_get_shared_secret,
|
||||
.get_my_public_value = _dh_get_my_public_value,
|
||||
.get_public_key = _dh_get_public_key,
|
||||
.destroy = _dh_destroy,
|
||||
},
|
||||
.secret = secret,
|
||||
@@ -210,7 +210,7 @@ static void process_ike_add(private_ha_dispatcher_t *this, ha_message_t *message
|
||||
if (ike_sa)
|
||||
{
|
||||
proposal_t *proposal;
|
||||
diffie_hellman_t *dh;
|
||||
key_exchange_t *dh;
|
||||
|
||||
proposal = proposal_create(PROTO_IKE, 0);
|
||||
if (integ)
|
||||
@@ -227,7 +227,7 @@ static void process_ike_add(private_ha_dispatcher_t *this, ha_message_t *message
|
||||
}
|
||||
if (dh_grp)
|
||||
{
|
||||
proposal->add_algorithm(proposal, DIFFIE_HELLMAN_GROUP, dh_grp, 0);
|
||||
proposal->add_algorithm(proposal, KEY_EXCHANGE_METHOD, dh_grp, 0);
|
||||
}
|
||||
charon->bus->set_sa(charon->bus, ike_sa);
|
||||
dh = ha_diffie_hellman_create(secret, dh_local);
|
||||
@@ -662,7 +662,7 @@ static void process_child_add(private_ha_dispatcher_t *this,
|
||||
chunk_t nonce_i = chunk_empty, nonce_r = chunk_empty, secret = chunk_empty;
|
||||
chunk_t encr_i, integ_i, encr_r, integ_r;
|
||||
linked_list_t *local_ts, *remote_ts;
|
||||
diffie_hellman_t *dh = NULL;
|
||||
key_exchange_t *dh = NULL;
|
||||
|
||||
enumerator = message->create_attribute_enumerator(message);
|
||||
while (enumerator->enumerate(enumerator, &attribute, &value))
|
||||
@@ -762,7 +762,7 @@ static void process_child_add(private_ha_dispatcher_t *this,
|
||||
}
|
||||
if (dh_grp)
|
||||
{
|
||||
proposal->add_algorithm(proposal, DIFFIE_HELLMAN_GROUP, dh_grp, 0);
|
||||
proposal->add_algorithm(proposal, KEY_EXCHANGE_METHOD, dh_grp, 0);
|
||||
}
|
||||
proposal->add_algorithm(proposal, EXTENDED_SEQUENCE_NUMBERS, esn, 0);
|
||||
if (secret.len)
|
||||
|
||||
@@ -82,7 +82,7 @@ static void copy_extensions(ha_message_t *m, ike_sa_t *ike_sa)
|
||||
}
|
||||
|
||||
METHOD(listener_t, ike_keys, bool,
|
||||
private_ha_ike_t *this, ike_sa_t *ike_sa, diffie_hellman_t *dh,
|
||||
private_ha_ike_t *this, ike_sa_t *ike_sa, key_exchange_t *dh,
|
||||
chunk_t dh_other, chunk_t nonce_i, chunk_t nonce_r, ike_sa_t *rekey,
|
||||
shared_key_t *shared, auth_method_t method)
|
||||
{
|
||||
@@ -132,7 +132,7 @@ METHOD(listener_t, ike_keys, bool,
|
||||
{
|
||||
m->add_attribute(m, HA_ALG_PRF, alg);
|
||||
}
|
||||
if (proposal->get_algorithm(proposal, DIFFIE_HELLMAN_GROUP, &alg, NULL))
|
||||
if (proposal->get_algorithm(proposal, KEY_EXCHANGE_METHOD, &alg, NULL))
|
||||
{
|
||||
m->add_attribute(m, HA_ALG_DH, alg);
|
||||
}
|
||||
@@ -142,7 +142,7 @@ METHOD(listener_t, ike_keys, bool,
|
||||
chunk_clear(&secret);
|
||||
if (ike_sa->get_version(ike_sa) == IKEV1)
|
||||
{
|
||||
if (dh->get_my_public_value(dh, &secret))
|
||||
if (dh->get_public_key(dh, &secret))
|
||||
{
|
||||
m->add_attribute(m, HA_LOCAL_DH, secret);
|
||||
chunk_free(&secret);
|
||||
|
||||
@@ -16,33 +16,33 @@
|
||||
|
||||
#include "load_tester_diffie_hellman.h"
|
||||
|
||||
METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
METHOD(key_exchange_t, get_public_key, bool,
|
||||
load_tester_diffie_hellman_t *this, chunk_t *value)
|
||||
{
|
||||
*value = chunk_empty;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, set_other_public_value, bool,
|
||||
METHOD(key_exchange_t, set_public_key, bool,
|
||||
load_tester_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,
|
||||
load_tester_diffie_hellman_t *this, chunk_t *secret)
|
||||
{
|
||||
*secret = chunk_empty;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
|
||||
METHOD(key_exchange_t, get_method, key_exchange_method_t,
|
||||
load_tester_diffie_hellman_t *this)
|
||||
{
|
||||
return MODP_NULL;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, destroy, void,
|
||||
METHOD(key_exchange_t, destroy, void,
|
||||
load_tester_diffie_hellman_t *this)
|
||||
{
|
||||
free(this);
|
||||
@@ -52,7 +52,7 @@ METHOD(diffie_hellman_t, destroy, void,
|
||||
* See header
|
||||
*/
|
||||
load_tester_diffie_hellman_t *load_tester_diffie_hellman_create(
|
||||
diffie_hellman_group_t group)
|
||||
key_exchange_method_t group)
|
||||
{
|
||||
load_tester_diffie_hellman_t *this;
|
||||
|
||||
@@ -62,11 +62,11 @@ load_tester_diffie_hellman_t *load_tester_diffie_hellman_create(
|
||||
}
|
||||
|
||||
INIT(this,
|
||||
.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,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#ifndef LOAD_TESTER_DIFFIE_HELLMAN_H_
|
||||
#define LOAD_TESTER_DIFFIE_HELLMAN_H_
|
||||
|
||||
#include <crypto/diffie_hellman.h>
|
||||
#include <crypto/key_exchange.h>
|
||||
|
||||
typedef struct load_tester_diffie_hellman_t load_tester_diffie_hellman_t;
|
||||
|
||||
@@ -32,18 +32,18 @@ typedef struct load_tester_diffie_hellman_t load_tester_diffie_hellman_t;
|
||||
struct load_tester_diffie_hellman_t {
|
||||
|
||||
/**
|
||||
* Implements diffie_hellman_t interface.
|
||||
* Implements key_exchange_t interface.
|
||||
*/
|
||||
diffie_hellman_t dh;
|
||||
key_exchange_t ke;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new gmp_diffie_hellman_t object.
|
||||
* Creates a new load_tester_diffie_hellman_t object.
|
||||
*
|
||||
* @param group Diffie Hellman group, supports MODP_NULL only
|
||||
* @return gmp_diffie_hellman_t object
|
||||
* @return load_tester_diffie_hellman_t object
|
||||
*/
|
||||
load_tester_diffie_hellman_t *load_tester_diffie_hellman_create(
|
||||
diffie_hellman_group_t group);
|
||||
key_exchange_method_t group);
|
||||
|
||||
#endif /** LOAD_TESTER_DIFFIE_HELLMAN_H_ @}*/
|
||||
|
||||
@@ -231,8 +231,8 @@ METHOD(plugin_t, get_features, int,
|
||||
private_load_tester_plugin_t *this, plugin_feature_t *features[])
|
||||
{
|
||||
static plugin_feature_t f[] = {
|
||||
PLUGIN_REGISTER(DH, load_tester_diffie_hellman_create),
|
||||
PLUGIN_PROVIDE(DH, MODP_NULL),
|
||||
PLUGIN_REGISTER(KE, load_tester_diffie_hellman_create),
|
||||
PLUGIN_PROVIDE(KE, MODP_NULL),
|
||||
PLUGIN_DEPENDS(CUSTOM, "load-tester"),
|
||||
PLUGIN_CALLBACK((plugin_feature_callback_t)register_load_tester, NULL),
|
||||
PLUGIN_PROVIDE(CUSTOM, "load-tester"),
|
||||
|
||||
@@ -266,10 +266,10 @@ static void log_child_sa(FILE *out, child_sa_t *child_sa, bool all)
|
||||
fprintf(out, "_%u", ks);
|
||||
}
|
||||
}
|
||||
if (proposal->get_algorithm(proposal, DIFFIE_HELLMAN_GROUP,
|
||||
if (proposal->get_algorithm(proposal, KEY_EXCHANGE_METHOD,
|
||||
&alg, NULL))
|
||||
{
|
||||
fprintf(out, "/%N", diffie_hellman_group_names, alg);
|
||||
fprintf(out, "/%N", key_exchange_method_names, alg);
|
||||
}
|
||||
if (proposal->get_algorithm(proposal, EXTENDED_SEQUENCE_NUMBERS,
|
||||
&alg, NULL) && alg == EXT_SEQ_NUMBERS)
|
||||
@@ -855,7 +855,7 @@ static void list_algs(FILE *out)
|
||||
ext_out_function_t xof;
|
||||
key_derivation_function_t kdf;
|
||||
drbg_type_t drbg;
|
||||
diffie_hellman_group_t group;
|
||||
key_exchange_method_t group;
|
||||
rng_quality_t quality;
|
||||
const char *plugin_name;
|
||||
int len;
|
||||
@@ -928,10 +928,10 @@ static void list_algs(FILE *out)
|
||||
enumerator->destroy(enumerator);
|
||||
fprintf(out, "\n dh-group: ");
|
||||
len = 13;
|
||||
enumerator = lib->crypto->create_dh_enumerator(lib->crypto);
|
||||
enumerator = lib->crypto->create_ke_enumerator(lib->crypto);
|
||||
while (enumerator->enumerate(enumerator, &group, &plugin_name))
|
||||
{
|
||||
print_alg(out, &len, diffie_hellman_group_names, group, plugin_name);
|
||||
print_alg(out, &len, key_exchange_method_names, group, plugin_name);
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
fprintf(out, "\n random-gen:");
|
||||
|
||||
@@ -230,10 +230,10 @@ static void list_child_ipsec(vici_builder_t *b, child_sa_t *child)
|
||||
b->add_kv(b, "integ-keysize", "%u", ks);
|
||||
}
|
||||
}
|
||||
if (proposal->get_algorithm(proposal, DIFFIE_HELLMAN_GROUP,
|
||||
if (proposal->get_algorithm(proposal, KEY_EXCHANGE_METHOD,
|
||||
&alg, NULL))
|
||||
{
|
||||
b->add_kv(b, "dh-group", "%N", diffie_hellman_group_names, alg);
|
||||
b->add_kv(b, "dh-group", "%N", key_exchange_method_names, alg);
|
||||
}
|
||||
if (proposal->get_algorithm(proposal, EXTENDED_SEQUENCE_NUMBERS,
|
||||
&alg, NULL) && alg == EXT_SEQ_NUMBERS)
|
||||
@@ -489,9 +489,9 @@ static void list_ike(private_vici_query_t *this, vici_builder_t *b,
|
||||
{
|
||||
b->add_kv(b, "prf-alg", "%N", pseudo_random_function_names, alg);
|
||||
}
|
||||
if (proposal->get_algorithm(proposal, DIFFIE_HELLMAN_GROUP, &alg, NULL))
|
||||
if (proposal->get_algorithm(proposal, KEY_EXCHANGE_METHOD, &alg, NULL))
|
||||
{
|
||||
b->add_kv(b, "dh-group", "%N", diffie_hellman_group_names, alg);
|
||||
b->add_kv(b, "dh-group", "%N", key_exchange_method_names, alg);
|
||||
}
|
||||
}
|
||||
add_condition(b, ike_sa, "ppk", COND_PPK);
|
||||
@@ -1304,7 +1304,7 @@ CALLBACK(get_algorithms, vici_message_t*,
|
||||
ext_out_function_t xof;
|
||||
key_derivation_function_t kdf;
|
||||
drbg_type_t drbg;
|
||||
diffie_hellman_group_t group;
|
||||
key_exchange_method_t group;
|
||||
rng_quality_t quality;
|
||||
const char *plugin_name;
|
||||
|
||||
@@ -1383,10 +1383,10 @@ CALLBACK(get_algorithms, vici_message_t*,
|
||||
b->end_section(b);
|
||||
|
||||
b->begin_section(b, "dh");
|
||||
enumerator = lib->crypto->create_dh_enumerator(lib->crypto);
|
||||
enumerator = lib->crypto->create_ke_enumerator(lib->crypto);
|
||||
while (enumerator->enumerate(enumerator, &group, &plugin_name))
|
||||
{
|
||||
add_algorithm(b, diffie_hellman_group_names, group, plugin_name);
|
||||
add_algorithm(b, key_exchange_method_names, group, plugin_name);
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
b->end_section(b);
|
||||
|
||||
Reference in New Issue
Block a user