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:
@@ -59,9 +59,9 @@ struct private_ke_payload_t {
|
||||
uint16_t payload_length;
|
||||
|
||||
/**
|
||||
* DH Group Number.
|
||||
* Key exchange method number.
|
||||
*/
|
||||
uint16_t dh_group_number;
|
||||
uint16_t ke_method;
|
||||
|
||||
/**
|
||||
* Key Exchange Data of this KE payload.
|
||||
@@ -92,8 +92,8 @@ static encoding_rule_t encodings_v2[] = {
|
||||
{ RESERVED_BIT, offsetof(private_ke_payload_t, reserved_bit[6]) },
|
||||
/* Length of the whole payload*/
|
||||
{ PAYLOAD_LENGTH, offsetof(private_ke_payload_t, payload_length) },
|
||||
/* DH Group number as 16 bit field*/
|
||||
{ U_INT_16, offsetof(private_ke_payload_t, dh_group_number) },
|
||||
/* Key exchange method number as 16 bit field*/
|
||||
{ U_INT_16, offsetof(private_ke_payload_t, ke_method) },
|
||||
/* 2 reserved bytes */
|
||||
{ RESERVED_BYTE, offsetof(private_ke_payload_t, reserved_byte[0])},
|
||||
{ RESERVED_BYTE, offsetof(private_ke_payload_t, reserved_byte[1])},
|
||||
@@ -107,7 +107,7 @@ static encoding_rule_t encodings_v2[] = {
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
! Next Payload !C! RESERVED ! Payload Length !
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
! DH Group # ! RESERVED !
|
||||
! KE method # ! RESERVED !
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
! !
|
||||
~ Key Exchange Data ~
|
||||
@@ -197,10 +197,10 @@ METHOD(ke_payload_t, get_key_exchange_data, chunk_t,
|
||||
return this->key_exchange_data;
|
||||
}
|
||||
|
||||
METHOD(ke_payload_t, get_dh_group_number, diffie_hellman_group_t,
|
||||
METHOD(ke_payload_t, get_key_exchange_method, key_exchange_method_t,
|
||||
private_ke_payload_t *this)
|
||||
{
|
||||
return this->dh_group_number;
|
||||
return this->ke_method;
|
||||
}
|
||||
|
||||
METHOD2(payload_t, ke_payload_t, destroy, void,
|
||||
@@ -230,11 +230,11 @@ ke_payload_t *ke_payload_create(payload_type_t type)
|
||||
.destroy = _destroy,
|
||||
},
|
||||
.get_key_exchange_data = _get_key_exchange_data,
|
||||
.get_dh_group_number = _get_dh_group_number,
|
||||
.get_key_exchange_method = _get_key_exchange_method,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
.next_payload = PL_NONE,
|
||||
.dh_group_number = MODP_NONE,
|
||||
.ke_method = MODP_NONE,
|
||||
.type = type,
|
||||
);
|
||||
this->payload_length = get_header_length(this);
|
||||
@@ -244,19 +244,19 @@ ke_payload_t *ke_payload_create(payload_type_t type)
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
ke_payload_t *ke_payload_create_from_diffie_hellman(payload_type_t type,
|
||||
diffie_hellman_t *dh)
|
||||
ke_payload_t *ke_payload_create_from_key_exchange(payload_type_t type,
|
||||
key_exchange_t *ke)
|
||||
{
|
||||
private_ke_payload_t *this;
|
||||
chunk_t value;
|
||||
|
||||
if (!dh->get_my_public_value(dh, &value))
|
||||
if (!ke->get_public_key(ke, &value))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
this = (private_ke_payload_t*)ke_payload_create(type);
|
||||
this->key_exchange_data = value;
|
||||
this->dh_group_number = dh->get_dh_group(dh);
|
||||
this->ke_method = ke->get_method(ke);
|
||||
this->payload_length += this->key_exchange_data.len;
|
||||
|
||||
return &this->public;
|
||||
|
||||
@@ -29,7 +29,7 @@ typedef struct ke_payload_t ke_payload_t;
|
||||
#include <encoding/payloads/payload.h>
|
||||
#include <encoding/payloads/transform_substructure.h>
|
||||
#include <collections/linked_list.h>
|
||||
#include <crypto/diffie_hellman.h>
|
||||
#include <crypto/key_exchange.h>
|
||||
|
||||
/**
|
||||
* Class representing an IKEv1 or IKEv2 key exchange payload.
|
||||
@@ -49,11 +49,11 @@ struct ke_payload_t {
|
||||
chunk_t (*get_key_exchange_data) (ke_payload_t *this);
|
||||
|
||||
/**
|
||||
* Gets the Diffie-Hellman Group Number of this KE payload (IKEv2 only).
|
||||
* Gets the key exchange method of this KE payload (IKEv2 only).
|
||||
*
|
||||
* @return DH Group Number of this payload
|
||||
* @return key exchange method of this payload
|
||||
*/
|
||||
diffie_hellman_group_t (*get_dh_group_number) (ke_payload_t *this);
|
||||
key_exchange_method_t (*get_key_exchange_method)(ke_payload_t *this);
|
||||
|
||||
/**
|
||||
* Destroys a ke_payload_t object.
|
||||
@@ -70,13 +70,13 @@ struct ke_payload_t {
|
||||
ke_payload_t *ke_payload_create(payload_type_t type);
|
||||
|
||||
/**
|
||||
* Creates a ke_payload_t from a diffie_hellman_t.
|
||||
* Creates a ke_payload_t from a key_exchange_t.
|
||||
*
|
||||
* @param type PLV2_KEY_EXCHANGE or PLV1_KEY_EXCHANGE
|
||||
* @param dh diffie hellman object containing group and key
|
||||
* @param ke key exchange object containing method and public key
|
||||
* @return ke_payload_t object, NULL on error
|
||||
*/
|
||||
ke_payload_t *ke_payload_create_from_diffie_hellman(payload_type_t type,
|
||||
diffie_hellman_t *dh);
|
||||
ke_payload_t *ke_payload_create_from_key_exchange(payload_type_t type,
|
||||
key_exchange_t *ke);
|
||||
|
||||
#endif /** KE_PAYLOAD_H_ @}*/
|
||||
|
||||
@@ -904,7 +904,7 @@ static void add_to_proposal_v1_ike(proposal_t *proposal,
|
||||
get_alg_from_ikev1(PSEUDO_RANDOM_FUNCTION, value), 0);
|
||||
break;
|
||||
case TATTR_PH1_GROUP:
|
||||
proposal->add_algorithm(proposal, DIFFIE_HELLMAN_GROUP,
|
||||
proposal->add_algorithm(proposal, KEY_EXCHANGE_METHOD,
|
||||
value, 0);
|
||||
break;
|
||||
default:
|
||||
@@ -951,7 +951,7 @@ static void add_to_proposal_v1(proposal_t *proposal,
|
||||
get_alg_from_ikev1_auth(value), 0);
|
||||
break;
|
||||
case TATTR_PH2_GROUP:
|
||||
proposal->add_algorithm(proposal, DIFFIE_HELLMAN_GROUP,
|
||||
proposal->add_algorithm(proposal, KEY_EXCHANGE_METHOD,
|
||||
value, 0);
|
||||
break;
|
||||
case TATTR_PH2_EXT_SEQ_NUMBER:
|
||||
@@ -1318,7 +1318,7 @@ static void set_from_proposal_v1_ike(private_proposal_substructure_t *this,
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
enumerator = proposal->create_enumerator(proposal, DIFFIE_HELLMAN_GROUP);
|
||||
enumerator = proposal->create_enumerator(proposal, KEY_EXCHANGE_METHOD);
|
||||
if (enumerator->enumerate(enumerator, &alg, &key_size))
|
||||
{
|
||||
transform->add_transform_attribute(transform,
|
||||
@@ -1396,7 +1396,7 @@ static void set_from_proposal_v1(private_proposal_substructure_t *this,
|
||||
return;
|
||||
}
|
||||
|
||||
enumerator = proposal->create_enumerator(proposal, DIFFIE_HELLMAN_GROUP);
|
||||
enumerator = proposal->create_enumerator(proposal, KEY_EXCHANGE_METHOD);
|
||||
if (enumerator->enumerate(enumerator, &alg, &key_size))
|
||||
{
|
||||
transform->add_transform_attribute(transform,
|
||||
@@ -1489,11 +1489,11 @@ static void set_from_proposal_v2(private_proposal_substructure_t *this,
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
/* dh groups */
|
||||
enumerator = proposal->create_enumerator(proposal, DIFFIE_HELLMAN_GROUP);
|
||||
enumerator = proposal->create_enumerator(proposal, KEY_EXCHANGE_METHOD);
|
||||
while (enumerator->enumerate(enumerator, &alg, NULL))
|
||||
{
|
||||
transform = transform_substructure_create_type(PLV2_TRANSFORM_SUBSTRUCTURE,
|
||||
DIFFIE_HELLMAN_GROUP, alg);
|
||||
KEY_EXCHANGE_METHOD, alg);
|
||||
add_transform_substructure(this, transform);
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
@@ -29,7 +29,7 @@ typedef struct transform_substructure_t transform_substructure_t;
|
||||
#include <encoding/payloads/payload.h>
|
||||
#include <encoding/payloads/transform_attribute.h>
|
||||
#include <collections/linked_list.h>
|
||||
#include <crypto/diffie_hellman.h>
|
||||
#include <crypto/key_exchange.h>
|
||||
#include <crypto/signers/signer.h>
|
||||
#include <crypto/prfs/prf.h>
|
||||
#include <crypto/crypters/crypter.h>
|
||||
|
||||
Reference in New Issue
Block a user