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:
@@ -49,7 +49,7 @@ struct private_botan_diffie_hellman_t {
|
||||
/**
|
||||
* Diffie Hellman group number
|
||||
*/
|
||||
diffie_hellman_group_t group;
|
||||
key_exchange_method_t group;
|
||||
|
||||
/**
|
||||
* Private key
|
||||
@@ -94,10 +94,10 @@ bool load_private_key(private_botan_diffie_hellman_t *this, chunk_t value)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, set_other_public_value, bool,
|
||||
METHOD(key_exchange_t, set_public_key, bool,
|
||||
private_botan_diffie_hellman_t *this, chunk_t value)
|
||||
{
|
||||
if (!diffie_hellman_verify_value(this->group, value))
|
||||
if (!key_exchange_verify_pubkey(this->group, value))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -107,7 +107,7 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
|
||||
return botan_dh_key_derivation(this->dh_key, value, &this->shared_secret);
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
METHOD(key_exchange_t, get_public_key, bool,
|
||||
private_botan_diffie_hellman_t *this, chunk_t *value)
|
||||
{
|
||||
*value = chunk_empty;
|
||||
@@ -129,14 +129,14 @@ METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, set_private_value, bool,
|
||||
METHOD(key_exchange_t, set_private_key, bool,
|
||||
private_botan_diffie_hellman_t *this, chunk_t value)
|
||||
{
|
||||
chunk_clear(&this->shared_secret);
|
||||
return load_private_key(this, value);
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
METHOD(key_exchange_t, get_shared_secret, bool,
|
||||
private_botan_diffie_hellman_t *this, chunk_t *secret)
|
||||
{
|
||||
if (!this->shared_secret.len)
|
||||
@@ -147,13 +147,13 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
|
||||
METHOD(key_exchange_t, get_method, key_exchange_method_t,
|
||||
private_botan_diffie_hellman_t *this)
|
||||
{
|
||||
return this->group;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, destroy, void,
|
||||
METHOD(key_exchange_t, destroy, void,
|
||||
private_botan_diffie_hellman_t *this)
|
||||
{
|
||||
botan_mp_destroy(this->p);
|
||||
@@ -166,7 +166,7 @@ METHOD(diffie_hellman_t, destroy, void,
|
||||
/*
|
||||
* Generic internal constructor
|
||||
*/
|
||||
static botan_diffie_hellman_t *create_generic(diffie_hellman_group_t group,
|
||||
static botan_diffie_hellman_t *create_generic(key_exchange_method_t group,
|
||||
chunk_t g, chunk_t p, size_t exp_len)
|
||||
{
|
||||
private_botan_diffie_hellman_t *this;
|
||||
@@ -175,12 +175,12 @@ static botan_diffie_hellman_t *create_generic(diffie_hellman_group_t group,
|
||||
|
||||
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,
|
||||
.set_private_value = _set_private_value,
|
||||
.get_dh_group = _get_dh_group,
|
||||
.set_public_key = _set_public_key,
|
||||
.get_public_key = _get_public_key,
|
||||
.set_private_key = _set_private_key,
|
||||
.get_method = _get_method,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
@@ -222,7 +222,7 @@ static botan_diffie_hellman_t *create_generic(diffie_hellman_group_t group,
|
||||
* Described in header.
|
||||
*/
|
||||
botan_diffie_hellman_t *botan_diffie_hellman_create(
|
||||
diffie_hellman_group_t group, ...)
|
||||
key_exchange_method_t group, ...)
|
||||
{
|
||||
diffie_hellman_params_t *params;
|
||||
chunk_t g, p;
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
typedef struct botan_diffie_hellman_t botan_diffie_hellman_t;
|
||||
|
||||
#include <crypto/diffie_hellman.h>
|
||||
#include <crypto/key_exchange.h>
|
||||
|
||||
/**
|
||||
* Implementation of the Diffie-Hellman algorithm using Botan.
|
||||
@@ -40,20 +40,20 @@ typedef struct botan_diffie_hellman_t botan_diffie_hellman_t;
|
||||
struct botan_diffie_hellman_t {
|
||||
|
||||
/**
|
||||
* Implements diffie_hellman_t interface.
|
||||
* Implements key_exchange_t interface.
|
||||
*/
|
||||
diffie_hellman_t dh;
|
||||
key_exchange_t ke;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new botan_diffie_hellman_t object.
|
||||
*
|
||||
* @param group Diffie Hellman group number to use
|
||||
* @param group Diffie-Hellman group number to use
|
||||
* @param ... expects generator and prime as chunk_t if MODP_CUSTOM
|
||||
* @return botan_diffie_hellman_t object,
|
||||
* NULL if not supported
|
||||
*/
|
||||
botan_diffie_hellman_t *botan_diffie_hellman_create(
|
||||
diffie_hellman_group_t group, ...);
|
||||
key_exchange_method_t group, ...);
|
||||
|
||||
#endif /** BOTAN_DIFFIE_HELLMAN_H_ @}*/
|
||||
|
||||
@@ -48,7 +48,7 @@ struct private_botan_ec_diffie_hellman_t {
|
||||
/**
|
||||
* Diffie Hellman group
|
||||
*/
|
||||
diffie_hellman_group_t group;
|
||||
key_exchange_method_t group;
|
||||
|
||||
/**
|
||||
* EC curve name
|
||||
@@ -66,10 +66,10 @@ struct private_botan_ec_diffie_hellman_t {
|
||||
chunk_t shared_secret;
|
||||
};
|
||||
|
||||
METHOD(diffie_hellman_t, set_other_public_value, bool,
|
||||
METHOD(key_exchange_t, set_public_key, bool,
|
||||
private_botan_ec_diffie_hellman_t *this, chunk_t value)
|
||||
{
|
||||
if (!diffie_hellman_verify_value(this->group, value))
|
||||
if (!key_exchange_verify_pubkey(this->group, value))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -82,7 +82,7 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
|
||||
return botan_dh_key_derivation(this->key, value, &this->shared_secret);
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
METHOD(key_exchange_t, get_public_key, bool,
|
||||
private_botan_ec_diffie_hellman_t *this, chunk_t *value)
|
||||
{
|
||||
chunk_t pkey = chunk_empty;
|
||||
@@ -104,7 +104,7 @@ METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, set_private_value, bool,
|
||||
METHOD(key_exchange_t, set_private_key, bool,
|
||||
private_botan_ec_diffie_hellman_t *this, chunk_t value)
|
||||
{
|
||||
botan_mp_t scalar;
|
||||
@@ -132,7 +132,7 @@ METHOD(diffie_hellman_t, set_private_value, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
METHOD(key_exchange_t, get_shared_secret, bool,
|
||||
private_botan_ec_diffie_hellman_t *this, chunk_t *secret)
|
||||
{
|
||||
if (!this->shared_secret.len)
|
||||
@@ -143,13 +143,13 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
|
||||
METHOD(key_exchange_t, get_method, key_exchange_method_t,
|
||||
private_botan_ec_diffie_hellman_t *this)
|
||||
{
|
||||
return this->group;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, destroy, void,
|
||||
METHOD(key_exchange_t, destroy, void,
|
||||
private_botan_ec_diffie_hellman_t *this)
|
||||
{
|
||||
botan_privkey_destroy(this->key);
|
||||
@@ -161,19 +161,19 @@ METHOD(diffie_hellman_t, destroy, void,
|
||||
* Described in header.
|
||||
*/
|
||||
botan_ec_diffie_hellman_t *botan_ec_diffie_hellman_create(
|
||||
diffie_hellman_group_t group)
|
||||
key_exchange_method_t group)
|
||||
{
|
||||
private_botan_ec_diffie_hellman_t *this;
|
||||
botan_rng_t rng;
|
||||
|
||||
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,
|
||||
.set_private_value = _set_private_value,
|
||||
.get_dh_group = _get_dh_group,
|
||||
.set_public_key = _set_public_key,
|
||||
.get_public_key = _get_public_key,
|
||||
.set_private_key = _set_private_key,
|
||||
.get_method = _get_method,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -39,18 +39,18 @@ typedef struct botan_ec_diffie_hellman_t botan_ec_diffie_hellman_t;
|
||||
struct botan_ec_diffie_hellman_t {
|
||||
|
||||
/**
|
||||
* Implements diffie_hellman_t interface.
|
||||
* Implements key_exchange_t interface.
|
||||
*/
|
||||
diffie_hellman_t dh;
|
||||
key_exchange_t ke;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new botan_ec_diffie_hellman_t object.
|
||||
*
|
||||
* @param group EC Diffie Hellman group number to use
|
||||
* @param group EC Diffie-Hellman group number to use
|
||||
* @return botan_ec_diffie_hellman_t object, NULL if not supported
|
||||
*/
|
||||
botan_ec_diffie_hellman_t *botan_ec_diffie_hellman_create(
|
||||
diffie_hellman_group_t group);
|
||||
key_exchange_method_t group);
|
||||
|
||||
#endif /** BOTAN_EC_DIFFIE_HELLMAN_H_ @}*/
|
||||
|
||||
@@ -74,33 +74,33 @@ METHOD(plugin_t, get_features, int,
|
||||
|
||||
#ifdef BOTAN_HAS_DIFFIE_HELLMAN
|
||||
/* MODP DH groups */
|
||||
PLUGIN_REGISTER(DH, botan_diffie_hellman_create),
|
||||
PLUGIN_PROVIDE(DH, MODP_3072_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_4096_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_6144_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_8192_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_2048_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_2048_224),
|
||||
PLUGIN_PROVIDE(DH, MODP_2048_256),
|
||||
PLUGIN_PROVIDE(DH, MODP_1536_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_1024_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_1024_160),
|
||||
PLUGIN_PROVIDE(DH, MODP_768_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_CUSTOM),
|
||||
PLUGIN_REGISTER(KE, botan_diffie_hellman_create),
|
||||
PLUGIN_PROVIDE(KE, MODP_3072_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_4096_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_6144_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_8192_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_2048_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_2048_224),
|
||||
PLUGIN_PROVIDE(KE, MODP_2048_256),
|
||||
PLUGIN_PROVIDE(KE, MODP_1536_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_1024_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_1024_160),
|
||||
PLUGIN_PROVIDE(KE, MODP_768_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_CUSTOM),
|
||||
#endif
|
||||
#ifdef BOTAN_HAS_ECDH
|
||||
/* EC DH groups */
|
||||
PLUGIN_REGISTER(DH, botan_ec_diffie_hellman_create),
|
||||
PLUGIN_PROVIDE(DH, ECP_256_BIT),
|
||||
PLUGIN_PROVIDE(DH, ECP_384_BIT),
|
||||
PLUGIN_PROVIDE(DH, ECP_521_BIT),
|
||||
PLUGIN_PROVIDE(DH, ECP_256_BP),
|
||||
PLUGIN_PROVIDE(DH, ECP_384_BP),
|
||||
PLUGIN_PROVIDE(DH, ECP_512_BP),
|
||||
PLUGIN_REGISTER(KE, botan_ec_diffie_hellman_create),
|
||||
PLUGIN_PROVIDE(KE, ECP_256_BIT),
|
||||
PLUGIN_PROVIDE(KE, ECP_384_BIT),
|
||||
PLUGIN_PROVIDE(KE, ECP_521_BIT),
|
||||
PLUGIN_PROVIDE(KE, ECP_256_BP),
|
||||
PLUGIN_PROVIDE(KE, ECP_384_BP),
|
||||
PLUGIN_PROVIDE(KE, ECP_512_BP),
|
||||
#endif
|
||||
#ifdef BOTAN_HAS_X25519
|
||||
PLUGIN_REGISTER(DH, botan_x25519_create),
|
||||
PLUGIN_PROVIDE(DH, CURVE_25519),
|
||||
PLUGIN_REGISTER(KE, botan_x25519_create),
|
||||
PLUGIN_PROVIDE(KE, CURVE_25519),
|
||||
#endif
|
||||
|
||||
/* crypters */
|
||||
|
||||
@@ -42,7 +42,7 @@ struct private_diffie_hellman_t {
|
||||
/**
|
||||
* Public interface
|
||||
*/
|
||||
diffie_hellman_t public;
|
||||
key_exchange_t public;
|
||||
|
||||
/**
|
||||
* Private key
|
||||
@@ -55,10 +55,10 @@ struct private_diffie_hellman_t {
|
||||
chunk_t shared_secret;
|
||||
};
|
||||
|
||||
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)
|
||||
{
|
||||
if (!diffie_hellman_verify_value(CURVE_25519, value))
|
||||
if (!key_exchange_verify_pubkey(CURVE_25519, value))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -68,7 +68,7 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
|
||||
return botan_dh_key_derivation(this->key, value, &this->shared_secret);
|
||||
}
|
||||
|
||||
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->len = 0;
|
||||
@@ -88,7 +88,7 @@ METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, set_private_value, bool,
|
||||
METHOD(key_exchange_t, set_private_key, bool,
|
||||
private_diffie_hellman_t *this, chunk_t value)
|
||||
{
|
||||
if (value.len != 32)
|
||||
@@ -110,7 +110,7 @@ METHOD(diffie_hellman_t, set_private_value, bool,
|
||||
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)
|
||||
{
|
||||
if (!this->shared_secret.len)
|
||||
@@ -121,13 +121,13 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
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 CURVE_25519;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, destroy, void,
|
||||
METHOD(key_exchange_t, destroy, void,
|
||||
private_diffie_hellman_t *this)
|
||||
{
|
||||
botan_privkey_destroy(this->key);
|
||||
@@ -138,7 +138,7 @@ METHOD(diffie_hellman_t, destroy, void,
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
diffie_hellman_t *botan_x25519_create(diffie_hellman_group_t group)
|
||||
key_exchange_t *botan_x25519_create(key_exchange_method_t ke)
|
||||
{
|
||||
private_diffie_hellman_t *this;
|
||||
botan_rng_t rng;
|
||||
@@ -146,10 +146,10 @@ diffie_hellman_t *botan_x25519_create(diffie_hellman_group_t group)
|
||||
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,
|
||||
.set_private_value = _set_private_value,
|
||||
.get_dh_group = _get_dh_group,
|
||||
.set_public_key = _set_public_key,
|
||||
.get_public_key = _get_public_key,
|
||||
.set_private_key = _set_private_key,
|
||||
.get_method = _get_method,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
);
|
||||
|
||||
@@ -33,9 +33,9 @@
|
||||
/**
|
||||
* Creates a new X25519 implementation using Botan.
|
||||
*
|
||||
* @param group DH group, must be CURVE_25519
|
||||
* @param ke key exchange method, must be CURVE_25519
|
||||
* @return object, NULL if not supported
|
||||
*/
|
||||
diffie_hellman_t *botan_x25519_create(diffie_hellman_group_t group);
|
||||
key_exchange_t *botan_x25519_create(key_exchange_method_t ke);
|
||||
|
||||
#endif /** BOTAN_X25519_H_ @}*/
|
||||
|
||||
@@ -73,7 +73,7 @@ static bool generate_key(private_curve25519_dh_t *this)
|
||||
return this->drv->set_key(this->drv, key);
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, set_other_public_value, bool,
|
||||
METHOD(key_exchange_t, set_public_key, bool,
|
||||
private_curve25519_dh_t *this, chunk_t value)
|
||||
{
|
||||
if (value.len == CURVE25519_KEY_SIZE)
|
||||
@@ -87,7 +87,7 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
METHOD(key_exchange_t, get_public_key, bool,
|
||||
private_curve25519_dh_t *this, chunk_t *value)
|
||||
{
|
||||
u_char basepoint[CURVE25519_KEY_SIZE] = { 9 };
|
||||
@@ -101,7 +101,7 @@ METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, set_private_value, bool,
|
||||
METHOD(key_exchange_t, set_private_key, bool,
|
||||
private_curve25519_dh_t *this, chunk_t value)
|
||||
{
|
||||
if (value.len != CURVE25519_KEY_SIZE)
|
||||
@@ -111,7 +111,7 @@ METHOD(diffie_hellman_t, set_private_value, bool,
|
||||
return this->drv->set_key(this->drv, value.ptr);
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
METHOD(key_exchange_t, get_shared_secret, bool,
|
||||
private_curve25519_dh_t *this, chunk_t *secret)
|
||||
{
|
||||
if (!this->computed)
|
||||
@@ -122,13 +122,13 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
|
||||
METHOD(key_exchange_t, get_method, key_exchange_method_t,
|
||||
private_curve25519_dh_t *this)
|
||||
{
|
||||
return CURVE_25519;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, destroy, void,
|
||||
METHOD(key_exchange_t, destroy, void,
|
||||
private_curve25519_dh_t *this)
|
||||
{
|
||||
this->drv->destroy(this->drv);
|
||||
@@ -138,7 +138,7 @@ METHOD(diffie_hellman_t, destroy, void,
|
||||
/*
|
||||
* Described in header.
|
||||
*/
|
||||
curve25519_dh_t *curve25519_dh_create(diffie_hellman_group_t group)
|
||||
curve25519_dh_t *curve25519_dh_create(key_exchange_method_t group)
|
||||
{
|
||||
private_curve25519_dh_t *this;
|
||||
|
||||
@@ -149,12 +149,12 @@ curve25519_dh_t *curve25519_dh_create(diffie_hellman_group_t group)
|
||||
|
||||
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,
|
||||
.set_private_value = _set_private_value,
|
||||
.get_dh_group = _get_dh_group,
|
||||
.set_public_key = _set_public_key,
|
||||
.get_public_key = _get_public_key,
|
||||
.set_private_key = _set_private_key,
|
||||
.get_method = _get_method,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -32,9 +32,9 @@ typedef struct curve25519_dh_t curve25519_dh_t;
|
||||
struct curve25519_dh_t {
|
||||
|
||||
/**
|
||||
* Implements diffie_hellman_t interface.
|
||||
* Implements key_exchange_t interface.
|
||||
*/
|
||||
diffie_hellman_t dh;
|
||||
key_exchange_t ke;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -43,6 +43,6 @@ struct curve25519_dh_t {
|
||||
* @param group DH group, CURVE_25519
|
||||
* @return curve25519_dh_t object, NULL on error
|
||||
*/
|
||||
curve25519_dh_t *curve25519_dh_create(diffie_hellman_group_t group);
|
||||
curve25519_dh_t *curve25519_dh_create(key_exchange_method_t group);
|
||||
|
||||
#endif /** CURVE25519_DH_H_ @}*/
|
||||
|
||||
@@ -47,8 +47,8 @@ METHOD(plugin_t, get_features, int,
|
||||
{
|
||||
static plugin_feature_t f[] = {
|
||||
/* X25519 DH group */
|
||||
PLUGIN_REGISTER(DH, curve25519_dh_create),
|
||||
PLUGIN_PROVIDE(DH, CURVE_25519),
|
||||
PLUGIN_REGISTER(KE, curve25519_dh_create),
|
||||
PLUGIN_PROVIDE(KE, CURVE_25519),
|
||||
PLUGIN_DEPENDS(RNG, RNG_STRONG),
|
||||
/* Ed25519 private/public keys */
|
||||
PLUGIN_REGISTER(PRIVKEY, curve25519_private_key_load, TRUE),
|
||||
|
||||
@@ -36,7 +36,7 @@ struct private_gcrypt_dh_t {
|
||||
/**
|
||||
* Diffie Hellman group number
|
||||
*/
|
||||
diffie_hellman_group_t group;
|
||||
key_exchange_method_t group;
|
||||
|
||||
/*
|
||||
* Generator value
|
||||
@@ -74,13 +74,13 @@ struct private_gcrypt_dh_t {
|
||||
size_t p_len;
|
||||
};
|
||||
|
||||
METHOD(diffie_hellman_t, set_other_public_value, bool,
|
||||
METHOD(key_exchange_t, set_public_key, bool,
|
||||
private_gcrypt_dh_t *this, chunk_t value)
|
||||
{
|
||||
gcry_mpi_t p_min_1;
|
||||
gcry_error_t err;
|
||||
|
||||
if (!diffie_hellman_verify_value(this->group, value))
|
||||
if (!key_exchange_verify_pubkey(this->group, value))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -139,14 +139,14 @@ static chunk_t export_mpi(gcry_mpi_t value, size_t len)
|
||||
return chunk;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
METHOD(key_exchange_t, get_public_key, bool,
|
||||
private_gcrypt_dh_t *this, chunk_t *value)
|
||||
{
|
||||
*value = export_mpi(this->ya, this->p_len);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, set_private_value, bool,
|
||||
METHOD(key_exchange_t, set_private_key, bool,
|
||||
private_gcrypt_dh_t *this, chunk_t value)
|
||||
{
|
||||
gcry_error_t err;
|
||||
@@ -164,7 +164,7 @@ METHOD(diffie_hellman_t, set_private_value, bool,
|
||||
return !err;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
METHOD(key_exchange_t, get_shared_secret, bool,
|
||||
private_gcrypt_dh_t *this, chunk_t *secret)
|
||||
{
|
||||
if (!this->zz)
|
||||
@@ -175,13 +175,13 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
|
||||
METHOD(key_exchange_t, get_method, key_exchange_method_t,
|
||||
private_gcrypt_dh_t *this)
|
||||
{
|
||||
return this->group;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, destroy, void,
|
||||
METHOD(key_exchange_t, destroy, void,
|
||||
private_gcrypt_dh_t *this)
|
||||
{
|
||||
gcry_mpi_release(this->p);
|
||||
@@ -196,7 +196,7 @@ METHOD(diffie_hellman_t, destroy, void,
|
||||
/*
|
||||
* Generic internal constructor
|
||||
*/
|
||||
static gcrypt_dh_t *create_generic(diffie_hellman_group_t group, size_t exp_len,
|
||||
static gcrypt_dh_t *create_generic(key_exchange_method_t group, size_t exp_len,
|
||||
chunk_t g, chunk_t p)
|
||||
{
|
||||
private_gcrypt_dh_t *this;
|
||||
@@ -206,12 +206,12 @@ static gcrypt_dh_t *create_generic(diffie_hellman_group_t group, size_t exp_len,
|
||||
|
||||
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,
|
||||
.set_private_value = _set_private_value,
|
||||
.get_dh_group = _get_dh_group,
|
||||
.set_public_key = _set_public_key,
|
||||
.get_public_key = _get_public_key,
|
||||
.set_private_key = _set_private_key,
|
||||
.get_method = _get_method,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
@@ -273,7 +273,7 @@ static gcrypt_dh_t *create_generic(diffie_hellman_group_t group, size_t exp_len,
|
||||
/*
|
||||
* Described in header.
|
||||
*/
|
||||
gcrypt_dh_t *gcrypt_dh_create(diffie_hellman_group_t group)
|
||||
gcrypt_dh_t *gcrypt_dh_create(key_exchange_method_t group)
|
||||
{
|
||||
|
||||
diffie_hellman_params_t *params;
|
||||
@@ -290,7 +290,7 @@ gcrypt_dh_t *gcrypt_dh_create(diffie_hellman_group_t group)
|
||||
/*
|
||||
* Described in header.
|
||||
*/
|
||||
gcrypt_dh_t *gcrypt_dh_create_custom(diffie_hellman_group_t group, ...)
|
||||
gcrypt_dh_t *gcrypt_dh_create_custom(key_exchange_method_t group, ...)
|
||||
{
|
||||
if (group == MODP_CUSTOM)
|
||||
{
|
||||
|
||||
@@ -32,9 +32,9 @@ typedef struct gcrypt_dh_t gcrypt_dh_t;
|
||||
struct gcrypt_dh_t {
|
||||
|
||||
/**
|
||||
* Implements diffie_hellman_t interface.
|
||||
* Implements key_exchange_t interface.
|
||||
*/
|
||||
diffie_hellman_t dh;
|
||||
key_exchange_t ke;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -43,7 +43,7 @@ struct gcrypt_dh_t {
|
||||
* @param group Diffie Hellman group number to use
|
||||
* @return gcrypt_dh_t object, NULL if not supported
|
||||
*/
|
||||
gcrypt_dh_t *gcrypt_dh_create(diffie_hellman_group_t group);
|
||||
gcrypt_dh_t *gcrypt_dh_create(key_exchange_method_t group);
|
||||
|
||||
/**
|
||||
* Creates a new gcrypt_dh_t object for MODP_CUSTOM.
|
||||
@@ -52,7 +52,7 @@ gcrypt_dh_t *gcrypt_dh_create(diffie_hellman_group_t group);
|
||||
* @param ... expects generator and prime as chunk_t
|
||||
* @return gcrypt_dh_t object, NULL if not supported
|
||||
*/
|
||||
gcrypt_dh_t *gcrypt_dh_create_custom(diffie_hellman_group_t group, ...);
|
||||
gcrypt_dh_t *gcrypt_dh_create_custom(key_exchange_method_t group, ...);
|
||||
|
||||
#endif /** GCRYPT_DH_H_ @}*/
|
||||
|
||||
|
||||
@@ -106,20 +106,20 @@ METHOD(plugin_t, get_features, int,
|
||||
PLUGIN_PROVIDE(HASHER, HASH_SHA384),
|
||||
PLUGIN_PROVIDE(HASHER, HASH_SHA512),
|
||||
/* MODP DH groups */
|
||||
PLUGIN_REGISTER(DH, gcrypt_dh_create),
|
||||
PLUGIN_PROVIDE(DH, MODP_3072_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_4096_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_6144_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_8192_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_2048_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_2048_224),
|
||||
PLUGIN_PROVIDE(DH, MODP_2048_256),
|
||||
PLUGIN_PROVIDE(DH, MODP_1536_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_1024_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_1024_160),
|
||||
PLUGIN_PROVIDE(DH, MODP_768_BIT),
|
||||
PLUGIN_REGISTER(DH, gcrypt_dh_create_custom),
|
||||
PLUGIN_PROVIDE(DH, MODP_CUSTOM),
|
||||
PLUGIN_REGISTER(KE, gcrypt_dh_create),
|
||||
PLUGIN_PROVIDE(KE, MODP_3072_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_4096_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_6144_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_8192_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_2048_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_2048_224),
|
||||
PLUGIN_PROVIDE(KE, MODP_2048_256),
|
||||
PLUGIN_PROVIDE(KE, MODP_1536_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_1024_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_1024_160),
|
||||
PLUGIN_PROVIDE(KE, MODP_768_BIT),
|
||||
PLUGIN_REGISTER(KE, gcrypt_dh_create_custom),
|
||||
PLUGIN_PROVIDE(KE, MODP_CUSTOM),
|
||||
/* RSA private/public key loading */
|
||||
PLUGIN_REGISTER(PUBKEY, gcrypt_rsa_public_key_load, TRUE),
|
||||
PLUGIN_PROVIDE(PUBKEY, KEY_RSA),
|
||||
|
||||
@@ -41,7 +41,7 @@ struct private_gmp_diffie_hellman_t {
|
||||
/**
|
||||
* Diffie Hellman group number.
|
||||
*/
|
||||
diffie_hellman_group_t group;
|
||||
key_exchange_method_t group;
|
||||
|
||||
/*
|
||||
* Generator value.
|
||||
@@ -84,12 +84,12 @@ struct private_gmp_diffie_hellman_t {
|
||||
bool computed;
|
||||
};
|
||||
|
||||
METHOD(diffie_hellman_t, set_other_public_value, bool,
|
||||
METHOD(key_exchange_t, set_public_key, bool,
|
||||
private_gmp_diffie_hellman_t *this, chunk_t value)
|
||||
{
|
||||
mpz_t p_min_1;
|
||||
|
||||
if (!diffie_hellman_verify_value(this->group, value))
|
||||
if (!key_exchange_verify_pubkey(this->group, value))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -149,7 +149,7 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
|
||||
return this->computed;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
METHOD(key_exchange_t, get_public_key, bool,
|
||||
private_gmp_diffie_hellman_t *this,chunk_t *value)
|
||||
{
|
||||
value->len = this->p_len;
|
||||
@@ -161,7 +161,7 @@ METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, set_private_value, bool,
|
||||
METHOD(key_exchange_t, set_private_key, bool,
|
||||
private_gmp_diffie_hellman_t *this, chunk_t value)
|
||||
{
|
||||
mpz_import(this->xa, value.len, 1, 1, 1, 0, value.ptr);
|
||||
@@ -170,7 +170,7 @@ METHOD(diffie_hellman_t, set_private_value, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
METHOD(key_exchange_t, get_shared_secret, bool,
|
||||
private_gmp_diffie_hellman_t *this, chunk_t *secret)
|
||||
{
|
||||
if (!this->computed)
|
||||
@@ -186,13 +186,13 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
|
||||
METHOD(key_exchange_t, get_method, key_exchange_method_t,
|
||||
private_gmp_diffie_hellman_t *this)
|
||||
{
|
||||
return this->group;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, destroy, void,
|
||||
METHOD(key_exchange_t, destroy, void,
|
||||
private_gmp_diffie_hellman_t *this)
|
||||
{
|
||||
mpz_clear(this->p);
|
||||
@@ -207,7 +207,7 @@ METHOD(diffie_hellman_t, destroy, void,
|
||||
/**
|
||||
* Generic internal constructor
|
||||
*/
|
||||
static gmp_diffie_hellman_t *create_generic(diffie_hellman_group_t group,
|
||||
static gmp_diffie_hellman_t *create_generic(key_exchange_method_t group,
|
||||
size_t exp_len, chunk_t g, chunk_t p)
|
||||
{
|
||||
private_gmp_diffie_hellman_t *this;
|
||||
@@ -216,12 +216,12 @@ static gmp_diffie_hellman_t *create_generic(diffie_hellman_group_t group,
|
||||
|
||||
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,
|
||||
.set_private_value = _set_private_value,
|
||||
.get_dh_group = _get_dh_group,
|
||||
.set_public_key = _set_public_key,
|
||||
.get_public_key = _get_public_key,
|
||||
.set_private_key = _set_private_key,
|
||||
.get_method = _get_method,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
@@ -273,7 +273,7 @@ static gmp_diffie_hellman_t *create_generic(diffie_hellman_group_t group,
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
gmp_diffie_hellman_t *gmp_diffie_hellman_create(diffie_hellman_group_t group)
|
||||
gmp_diffie_hellman_t *gmp_diffie_hellman_create(key_exchange_method_t group)
|
||||
{
|
||||
diffie_hellman_params_t *params;
|
||||
|
||||
@@ -290,7 +290,7 @@ gmp_diffie_hellman_t *gmp_diffie_hellman_create(diffie_hellman_group_t group)
|
||||
* Described in header
|
||||
*/
|
||||
gmp_diffie_hellman_t *gmp_diffie_hellman_create_custom(
|
||||
diffie_hellman_group_t group, ...)
|
||||
key_exchange_method_t group, ...)
|
||||
{
|
||||
if (group == MODP_CUSTOM)
|
||||
{
|
||||
|
||||
@@ -31,9 +31,9 @@ typedef struct gmp_diffie_hellman_t gmp_diffie_hellman_t;
|
||||
struct gmp_diffie_hellman_t {
|
||||
|
||||
/**
|
||||
* Implements diffie_hellman_t interface.
|
||||
* Implements key_exchange_t interface.
|
||||
*/
|
||||
diffie_hellman_t dh;
|
||||
key_exchange_t ke;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -42,7 +42,7 @@ struct gmp_diffie_hellman_t {
|
||||
* @param group Diffie Hellman group number to use
|
||||
* @return gmp_diffie_hellman_t object, NULL if not supported
|
||||
*/
|
||||
gmp_diffie_hellman_t *gmp_diffie_hellman_create(diffie_hellman_group_t group);
|
||||
gmp_diffie_hellman_t *gmp_diffie_hellman_create(key_exchange_method_t group);
|
||||
|
||||
/**
|
||||
* Creates a new gmp_diffie_hellman_t object for MODP_CUSTOM.
|
||||
@@ -52,7 +52,7 @@ gmp_diffie_hellman_t *gmp_diffie_hellman_create(diffie_hellman_group_t group);
|
||||
* @return gmp_diffie_hellman_t object, NULL if not supported
|
||||
*/
|
||||
gmp_diffie_hellman_t *gmp_diffie_hellman_create_custom(
|
||||
diffie_hellman_group_t group, ...);
|
||||
key_exchange_method_t group, ...);
|
||||
|
||||
#endif /** GMP_DIFFIE_HELLMAN_H_ @}*/
|
||||
|
||||
|
||||
@@ -43,31 +43,31 @@ METHOD(plugin_t, get_features, int,
|
||||
{
|
||||
static plugin_feature_t f[] = {
|
||||
/* DH groups */
|
||||
PLUGIN_REGISTER(DH, gmp_diffie_hellman_create),
|
||||
PLUGIN_PROVIDE(DH, MODP_3072_BIT),
|
||||
PLUGIN_REGISTER(KE, gmp_diffie_hellman_create),
|
||||
PLUGIN_PROVIDE(KE, MODP_3072_BIT),
|
||||
PLUGIN_DEPENDS(RNG, RNG_STRONG),
|
||||
PLUGIN_PROVIDE(DH, MODP_4096_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_4096_BIT),
|
||||
PLUGIN_DEPENDS(RNG, RNG_STRONG),
|
||||
PLUGIN_PROVIDE(DH, MODP_6144_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_6144_BIT),
|
||||
PLUGIN_DEPENDS(RNG, RNG_STRONG),
|
||||
PLUGIN_PROVIDE(DH, MODP_8192_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_8192_BIT),
|
||||
PLUGIN_DEPENDS(RNG, RNG_STRONG),
|
||||
PLUGIN_PROVIDE(DH, MODP_2048_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_2048_BIT),
|
||||
PLUGIN_DEPENDS(RNG, RNG_STRONG),
|
||||
PLUGIN_PROVIDE(DH, MODP_2048_224),
|
||||
PLUGIN_PROVIDE(KE, MODP_2048_224),
|
||||
PLUGIN_DEPENDS(RNG, RNG_STRONG),
|
||||
PLUGIN_PROVIDE(DH, MODP_2048_256),
|
||||
PLUGIN_PROVIDE(KE, MODP_2048_256),
|
||||
PLUGIN_DEPENDS(RNG, RNG_STRONG),
|
||||
PLUGIN_PROVIDE(DH, MODP_1536_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_1536_BIT),
|
||||
PLUGIN_DEPENDS(RNG, RNG_STRONG),
|
||||
PLUGIN_PROVIDE(DH, MODP_1024_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_1024_BIT),
|
||||
PLUGIN_DEPENDS(RNG, RNG_STRONG),
|
||||
PLUGIN_PROVIDE(DH, MODP_1024_160),
|
||||
PLUGIN_PROVIDE(KE, MODP_1024_160),
|
||||
PLUGIN_DEPENDS(RNG, RNG_STRONG),
|
||||
PLUGIN_PROVIDE(DH, MODP_768_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_768_BIT),
|
||||
PLUGIN_DEPENDS(RNG, RNG_STRONG),
|
||||
PLUGIN_REGISTER(DH, gmp_diffie_hellman_create_custom),
|
||||
PLUGIN_PROVIDE(DH, MODP_CUSTOM),
|
||||
PLUGIN_REGISTER(KE, gmp_diffie_hellman_create_custom),
|
||||
PLUGIN_PROVIDE(KE, MODP_CUSTOM),
|
||||
PLUGIN_DEPENDS(RNG, RNG_STRONG),
|
||||
/* private/public keys */
|
||||
PLUGIN_REGISTER(PRIVKEY, gmp_rsa_private_key_load, TRUE),
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include <ntt_fft.h>
|
||||
#include <ntt_fft_reduce.h>
|
||||
#include <crypto/diffie_hellman.h>
|
||||
#include <crypto/key_exchange.h>
|
||||
#include <utils/debug.h>
|
||||
|
||||
static const int seed_len = 32; /* 256 bits */
|
||||
@@ -278,7 +278,7 @@ static uint8_t* unpack_rec(private_newhope_ke_t *this, uint8_t *x)
|
||||
return r;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
METHOD(key_exchange_t, get_public_key, bool,
|
||||
private_newhope_ke_t *this, chunk_t *value)
|
||||
{
|
||||
uint16_t n, q;
|
||||
@@ -397,7 +397,7 @@ METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
}
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
METHOD(key_exchange_t, get_shared_secret, bool,
|
||||
private_newhope_ke_t *this, chunk_t *secret)
|
||||
{
|
||||
if (this->shared_secret.len == 0)
|
||||
@@ -410,7 +410,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_newhope_ke_t *this, chunk_t value)
|
||||
{
|
||||
newhope_reconciliation_t * rec;
|
||||
@@ -436,7 +436,7 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
|
||||
if (value.len != poly_len + seed_len)
|
||||
{
|
||||
DBG1(DBG_LIB, "received %N KE payload of incorrect size",
|
||||
diffie_hellman_group_names, NH_128_BIT);
|
||||
key_exchange_method_names, NH_128_BIT);
|
||||
return FALSE;
|
||||
}
|
||||
a_seed = chunk_create(value.ptr + poly_len, seed_len);
|
||||
@@ -545,7 +545,7 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
|
||||
if (value.len != poly_len + rec_len)
|
||||
{
|
||||
DBG1(DBG_LIB, "received %N KE payload of incorrect size",
|
||||
diffie_hellman_group_names, NH_128_BIT);
|
||||
key_exchange_method_names, NH_128_BIT);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -581,13 +581,13 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
|
||||
}
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
|
||||
METHOD(key_exchange_t, get_method, key_exchange_method_t,
|
||||
private_newhope_ke_t *this)
|
||||
{
|
||||
return NH_128_BIT;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, destroy, void,
|
||||
METHOD(key_exchange_t, destroy, void,
|
||||
private_newhope_ke_t *this)
|
||||
{
|
||||
chunk_clear(&this->shared_secret);
|
||||
@@ -601,17 +601,17 @@ METHOD(diffie_hellman_t, destroy, void,
|
||||
/*
|
||||
* Described in header.
|
||||
*/
|
||||
newhope_ke_t *newhope_ke_create(diffie_hellman_group_t group, chunk_t g, chunk_t p)
|
||||
newhope_ke_t *newhope_ke_create(key_exchange_method_t ke, chunk_t g, chunk_t p)
|
||||
{
|
||||
private_newhope_ke_t *this;
|
||||
|
||||
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,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -32,20 +32,20 @@ typedef struct newhope_ke_t newhope_ke_t;
|
||||
struct newhope_ke_t {
|
||||
|
||||
/**
|
||||
* Implements diffie_hellman_t interface.
|
||||
* Implements key_exchange_t interface.
|
||||
*/
|
||||
diffie_hellman_t dh;
|
||||
key_exchange_t ke;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new newhope_ke_t object.
|
||||
*
|
||||
* @param group New Hope DH group number
|
||||
* @param ke New Hope key exchange number
|
||||
* @param g not used
|
||||
* @param p not used
|
||||
* @return newhope_ke_t object, NULL if not supported
|
||||
*/
|
||||
newhope_ke_t *newhope_ke_create(diffie_hellman_group_t group, chunk_t g, chunk_t p);
|
||||
newhope_ke_t *newhope_ke_create(key_exchange_method_t ke, chunk_t g, chunk_t p);
|
||||
|
||||
#endif /** NEWHOPE_KE_H_ @}*/
|
||||
|
||||
|
||||
@@ -42,8 +42,8 @@ METHOD(plugin_t, get_features, int,
|
||||
private_newhope_plugin_t *this, plugin_feature_t *features[])
|
||||
{
|
||||
static plugin_feature_t f[] = {
|
||||
PLUGIN_REGISTER(DH, newhope_ke_create),
|
||||
PLUGIN_PROVIDE(DH, NH_128_BIT),
|
||||
PLUGIN_REGISTER(KE, newhope_ke_create),
|
||||
PLUGIN_PROVIDE(KE, NH_128_BIT),
|
||||
PLUGIN_DEPENDS(XOF, XOF_SHAKE_128),
|
||||
PLUGIN_DEPENDS(XOF, XOF_CHACHA20),
|
||||
};
|
||||
|
||||
@@ -27,7 +27,7 @@ const int count = 1000;
|
||||
START_TEST(test_newhope_ke_good)
|
||||
{
|
||||
chunk_t i_msg, r_msg, i_shared_secret, r_shared_secret;
|
||||
diffie_hellman_t *i_nh, *r_nh;
|
||||
key_exchange_t *i_nh, *r_nh;
|
||||
struct timespec start, stop;
|
||||
int i;
|
||||
|
||||
@@ -35,24 +35,24 @@ START_TEST(test_newhope_ke_good)
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
i_nh = lib->crypto->create_dh(lib->crypto, NH_128_BIT);
|
||||
i_nh = lib->crypto->create_ke(lib->crypto, NH_128_BIT);
|
||||
ck_assert(i_nh != NULL);
|
||||
ck_assert(i_nh->get_dh_group(i_nh) == NH_128_BIT);
|
||||
ck_assert(i_nh->get_method(i_nh) == NH_128_BIT);
|
||||
|
||||
ck_assert(i_nh->get_my_public_value(i_nh, &i_msg));
|
||||
ck_assert(i_nh->get_public_key(i_nh, &i_msg));
|
||||
ck_assert(i_msg.len = 1824);
|
||||
|
||||
r_nh = lib->crypto->create_dh(lib->crypto, NH_128_BIT);
|
||||
r_nh = lib->crypto->create_ke(lib->crypto, NH_128_BIT);
|
||||
ck_assert(r_nh != NULL);
|
||||
|
||||
ck_assert(r_nh->set_other_public_value(r_nh, i_msg));
|
||||
ck_assert(r_nh->get_my_public_value(r_nh, &r_msg));
|
||||
ck_assert(r_nh->set_public_key(r_nh, i_msg));
|
||||
ck_assert(r_nh->get_public_key(r_nh, &r_msg));
|
||||
ck_assert(r_msg.len == 2048);
|
||||
|
||||
ck_assert(r_nh->get_shared_secret(r_nh, &r_shared_secret));
|
||||
ck_assert(r_shared_secret.len == 32);
|
||||
|
||||
ck_assert(i_nh->set_other_public_value(i_nh, r_msg));
|
||||
ck_assert(i_nh->set_public_key(i_nh, r_msg));
|
||||
ck_assert(i_nh->get_shared_secret(i_nh, &i_shared_secret));
|
||||
ck_assert(i_shared_secret.len == 32);
|
||||
ck_assert(chunk_equals(i_shared_secret, r_shared_secret));
|
||||
@@ -77,26 +77,26 @@ END_TEST
|
||||
START_TEST(test_newhope_ke_wrong)
|
||||
{
|
||||
chunk_t i_msg, r_msg, i_shared_secret, r_shared_secret;
|
||||
diffie_hellman_t *i_nh, *r_nh;
|
||||
key_exchange_t *i_nh, *r_nh;
|
||||
|
||||
i_nh = lib->crypto->create_dh(lib->crypto, NH_128_BIT);
|
||||
i_nh = lib->crypto->create_ke(lib->crypto, NH_128_BIT);
|
||||
ck_assert(i_nh != NULL);
|
||||
ck_assert(i_nh->get_my_public_value(i_nh, &i_msg));
|
||||
ck_assert(i_nh->get_public_key(i_nh, &i_msg));
|
||||
|
||||
r_nh = lib->crypto->create_dh(lib->crypto, NH_128_BIT);
|
||||
r_nh = lib->crypto->create_ke(lib->crypto, NH_128_BIT);
|
||||
ck_assert(r_nh != NULL);
|
||||
ck_assert(r_nh->set_other_public_value(r_nh, i_msg));
|
||||
ck_assert(r_nh->get_my_public_value(r_nh, &r_msg));
|
||||
ck_assert(r_nh->set_public_key(r_nh, i_msg));
|
||||
ck_assert(r_nh->get_public_key(r_nh, &r_msg));
|
||||
|
||||
/* destroy 1st instance of i_nh */
|
||||
i_nh->destroy(i_nh);
|
||||
chunk_free(&i_msg);
|
||||
|
||||
/* create 2nd instance of i_nh */
|
||||
i_nh = lib->crypto->create_dh(lib->crypto, NH_128_BIT);
|
||||
i_nh = lib->crypto->create_ke(lib->crypto, NH_128_BIT);
|
||||
ck_assert(i_nh != NULL);
|
||||
ck_assert(i_nh->get_my_public_value(i_nh, &i_msg));
|
||||
ck_assert(i_nh->set_other_public_value(i_nh, r_msg));
|
||||
ck_assert(i_nh->get_public_key(i_nh, &i_msg));
|
||||
ck_assert(i_nh->set_public_key(i_nh, r_msg));
|
||||
|
||||
ck_assert(r_nh->get_shared_secret(r_nh, &r_shared_secret));
|
||||
ck_assert(i_nh->get_shared_secret(i_nh, &i_shared_secret));
|
||||
@@ -114,7 +114,7 @@ END_TEST
|
||||
|
||||
START_TEST(test_newhope_ke_fail_i)
|
||||
{
|
||||
diffie_hellman_t *i_nh;
|
||||
key_exchange_t *i_nh;
|
||||
char buf_ff[2048];
|
||||
int i;
|
||||
|
||||
@@ -131,10 +131,10 @@ START_TEST(test_newhope_ke_fail_i)
|
||||
|
||||
for (i = 0; i < countof(r_msg); i++)
|
||||
{
|
||||
i_nh = lib->crypto->create_dh(lib->crypto, NH_128_BIT);
|
||||
i_nh = lib->crypto->create_ke(lib->crypto, NH_128_BIT);
|
||||
ck_assert(i_nh != NULL);
|
||||
ck_assert(i_nh->get_my_public_value(i_nh, &i_msg));
|
||||
ck_assert(!i_nh->set_other_public_value(i_nh, r_msg[i]));
|
||||
ck_assert(i_nh->get_public_key(i_nh, &i_msg));
|
||||
ck_assert(!i_nh->set_public_key(i_nh, r_msg[i]));
|
||||
chunk_free(&i_msg);
|
||||
i_nh->destroy(i_nh);
|
||||
}
|
||||
@@ -143,7 +143,7 @@ END_TEST
|
||||
|
||||
START_TEST(test_newhope_ke_fail_r)
|
||||
{
|
||||
diffie_hellman_t *r_nh;
|
||||
key_exchange_t *r_nh;
|
||||
char buf_ff[1824];
|
||||
int i;
|
||||
|
||||
@@ -158,9 +158,9 @@ START_TEST(test_newhope_ke_fail_r)
|
||||
|
||||
for (i = 0; i < countof(i_msg); i++)
|
||||
{
|
||||
r_nh = lib->crypto->create_dh(lib->crypto, NH_128_BIT);
|
||||
r_nh = lib->crypto->create_ke(lib->crypto, NH_128_BIT);
|
||||
ck_assert(r_nh != NULL);
|
||||
ck_assert(!r_nh->set_other_public_value(r_nh, i_msg[i]));
|
||||
ck_assert(!r_nh->set_public_key(r_nh, i_msg[i]));
|
||||
r_nh->destroy(r_nh);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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_ @}*/
|
||||
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -54,7 +54,7 @@ struct private_openssl_diffie_hellman_t {
|
||||
/**
|
||||
* Diffie Hellman group number.
|
||||
*/
|
||||
diffie_hellman_group_t group;
|
||||
key_exchange_method_t group;
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
|
||||
/**
|
||||
@@ -84,13 +84,13 @@ struct private_openssl_diffie_hellman_t {
|
||||
chunk_t shared_secret;
|
||||
};
|
||||
|
||||
METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
|
||||
METHOD(key_exchange_t, get_method, key_exchange_method_t,
|
||||
private_openssl_diffie_hellman_t *this)
|
||||
{
|
||||
return this->group;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
METHOD(key_exchange_t, get_public_key, bool,
|
||||
private_openssl_diffie_hellman_t *this, chunk_t *value)
|
||||
{
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
|
||||
@@ -115,7 +115,7 @@ METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
#endif
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
METHOD(key_exchange_t, get_shared_secret, bool,
|
||||
private_openssl_diffie_hellman_t *this, chunk_t *secret)
|
||||
{
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
|
||||
@@ -151,10 +151,10 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
}
|
||||
|
||||
|
||||
METHOD(diffie_hellman_t, set_other_public_value, bool,
|
||||
METHOD(key_exchange_t, set_public_key, bool,
|
||||
private_openssl_diffie_hellman_t *this, chunk_t value)
|
||||
{
|
||||
if (!diffie_hellman_verify_value(this->group, value))
|
||||
if (!key_exchange_verify_pubkey(this->group, value))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -204,7 +204,7 @@ static BIGNUM *calculate_public_key(BIGNUM *priv, const BIGNUM *g,
|
||||
return pub;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, set_private_value, bool,
|
||||
METHOD(key_exchange_t, set_private_key, bool,
|
||||
private_openssl_diffie_hellman_t *this, chunk_t value)
|
||||
{
|
||||
BIGNUM *priv, *g = NULL, *p = NULL, *pub = NULL;
|
||||
@@ -254,7 +254,7 @@ error:
|
||||
|
||||
#else /* OPENSSL_VERSION_NUMBER */
|
||||
|
||||
METHOD(diffie_hellman_t, set_private_value, bool,
|
||||
METHOD(key_exchange_t, set_private_key, bool,
|
||||
private_openssl_diffie_hellman_t *this, chunk_t value)
|
||||
{
|
||||
BIGNUM *privkey;
|
||||
@@ -274,7 +274,7 @@ METHOD(diffie_hellman_t, set_private_value, bool,
|
||||
|
||||
#endif /* OPENSSL_VERSION_NUMBER */
|
||||
|
||||
METHOD(diffie_hellman_t, destroy, void,
|
||||
METHOD(key_exchange_t, destroy, void,
|
||||
private_openssl_diffie_hellman_t *this)
|
||||
{
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
|
||||
@@ -292,7 +292,7 @@ METHOD(diffie_hellman_t, destroy, void,
|
||||
* Described in header.
|
||||
*/
|
||||
openssl_diffie_hellman_t *openssl_diffie_hellman_create(
|
||||
diffie_hellman_group_t group, ...)
|
||||
key_exchange_method_t group, ...)
|
||||
{
|
||||
private_openssl_diffie_hellman_t *this;
|
||||
BIGNUM *g, *p;
|
||||
@@ -300,12 +300,12 @@ openssl_diffie_hellman_t *openssl_diffie_hellman_create(
|
||||
|
||||
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,
|
||||
.set_private_value = _set_private_value,
|
||||
.get_dh_group = _get_dh_group,
|
||||
.set_public_key = _set_public_key,
|
||||
.get_public_key = _get_public_key,
|
||||
.set_private_key = _set_private_key,
|
||||
.get_method = _get_method,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -32,20 +32,20 @@ typedef struct openssl_diffie_hellman_t openssl_diffie_hellman_t;
|
||||
struct openssl_diffie_hellman_t {
|
||||
|
||||
/**
|
||||
* Implements diffie_hellman_t interface.
|
||||
* Implements key_exchange_t interface.
|
||||
*/
|
||||
diffie_hellman_t dh;
|
||||
key_exchange_t ke;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new openssl_diffie_hellman_t object.
|
||||
*
|
||||
* @param group Diffie Hellman group number to use
|
||||
* @param group Diffie-Hellman group number to use
|
||||
* @param ... expects generator and prime as chunk_t if MODP_CUSTOM
|
||||
* @return openssl_diffie_hellman_t object, NULL if not supported
|
||||
*/
|
||||
openssl_diffie_hellman_t *openssl_diffie_hellman_create(
|
||||
diffie_hellman_group_t group, ...);
|
||||
key_exchange_method_t group, ...);
|
||||
|
||||
#endif /** OPENSSL_DIFFIE_HELLMAN_H_ @}*/
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ struct private_openssl_ec_diffie_hellman_t {
|
||||
/**
|
||||
* Diffie Hellman group number.
|
||||
*/
|
||||
diffie_hellman_group_t group;
|
||||
key_exchange_method_t group;
|
||||
|
||||
/**
|
||||
* EC private (public) key
|
||||
@@ -198,10 +198,10 @@ error:
|
||||
}
|
||||
#endif /* OPENSSL_VERSION_NUMBER < ... */
|
||||
|
||||
METHOD(diffie_hellman_t, set_other_public_value, bool,
|
||||
METHOD(key_exchange_t, set_public_key, bool,
|
||||
private_openssl_ec_diffie_hellman_t *this, chunk_t value)
|
||||
{
|
||||
if (!diffie_hellman_verify_value(this->group, value))
|
||||
if (!key_exchange_verify_pubkey(this->group, value))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -232,7 +232,7 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
METHOD(key_exchange_t, get_public_key, bool,
|
||||
private_openssl_ec_diffie_hellman_t *this, chunk_t *value)
|
||||
{
|
||||
#if OPENSSL_VERSION_NUMBER < 0x1010000fL
|
||||
@@ -253,7 +253,7 @@ METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
#endif
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
METHOD(key_exchange_t, get_shared_secret, bool,
|
||||
private_openssl_ec_diffie_hellman_t *this, chunk_t *secret)
|
||||
{
|
||||
if (!this->shared_secret.len &&
|
||||
@@ -266,7 +266,7 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
|
||||
METHOD(key_exchange_t, get_method, key_exchange_method_t,
|
||||
private_openssl_ec_diffie_hellman_t *this)
|
||||
{
|
||||
return this->group;
|
||||
@@ -275,7 +275,7 @@ METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
int openssl_ecdh_group_to_nid(diffie_hellman_group_t group)
|
||||
int openssl_ecdh_group_to_nid(key_exchange_method_t group)
|
||||
{
|
||||
switch (group)
|
||||
{
|
||||
@@ -337,7 +337,7 @@ static bool ecp2chunk(EC_GROUP *group, EC_POINT *point, chunk_t *chunk)
|
||||
return chunk->len;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, set_private_value, bool,
|
||||
METHOD(key_exchange_t, set_private_key, bool,
|
||||
private_openssl_ec_diffie_hellman_t *this, chunk_t value)
|
||||
{
|
||||
BIGNUM *priv = NULL;
|
||||
@@ -390,7 +390,7 @@ METHOD(diffie_hellman_t, set_private_value, bool,
|
||||
|
||||
#else /* OPENSSL_VERSION_NUMBER */
|
||||
|
||||
METHOD(diffie_hellman_t, set_private_value, bool,
|
||||
METHOD(key_exchange_t, set_private_key, bool,
|
||||
private_openssl_ec_diffie_hellman_t *this, chunk_t value)
|
||||
{
|
||||
EC_KEY *key = NULL;
|
||||
@@ -430,7 +430,7 @@ error:
|
||||
|
||||
#endif /* OPENSSL_VERSION_NUMBER */
|
||||
|
||||
METHOD(diffie_hellman_t, destroy, void,
|
||||
METHOD(key_exchange_t, destroy, void,
|
||||
private_openssl_ec_diffie_hellman_t *this)
|
||||
{
|
||||
EC_GROUP_free(this->ec_group);
|
||||
@@ -443,7 +443,7 @@ METHOD(diffie_hellman_t, destroy, void,
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
openssl_ec_diffie_hellman_t *openssl_ec_diffie_hellman_create(diffie_hellman_group_t group)
|
||||
openssl_ec_diffie_hellman_t *openssl_ec_diffie_hellman_create(key_exchange_method_t group)
|
||||
{
|
||||
private_openssl_ec_diffie_hellman_t *this;
|
||||
int curve;
|
||||
@@ -456,12 +456,12 @@ openssl_ec_diffie_hellman_t *openssl_ec_diffie_hellman_create(diffie_hellman_gro
|
||||
|
||||
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,
|
||||
.set_private_value = _set_private_value,
|
||||
.get_dh_group = _get_dh_group,
|
||||
.set_public_key = _set_public_key,
|
||||
.get_public_key = _get_public_key,
|
||||
.set_private_key = _set_private_key,
|
||||
.get_method = _get_method,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -32,18 +32,19 @@ typedef struct openssl_ec_diffie_hellman_t openssl_ec_diffie_hellman_t;
|
||||
struct openssl_ec_diffie_hellman_t {
|
||||
|
||||
/**
|
||||
* Implements diffie_hellman_t interface.
|
||||
* Implements key_exchange_t interface.
|
||||
*/
|
||||
diffie_hellman_t dh;
|
||||
key_exchange_t ke;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new openssl_ec_diffie_hellman_t object.
|
||||
*
|
||||
* @param group EC Diffie Hellman group number to use
|
||||
* @return openssl_ec_diffie_hellman_t object, NULL if not supported
|
||||
* @param group EC Diffie-Hellman group number to use
|
||||
* @return openssl_ec_diffie_hellman_t object, NULL if unsupported
|
||||
*/
|
||||
openssl_ec_diffie_hellman_t *openssl_ec_diffie_hellman_create(diffie_hellman_group_t group);
|
||||
openssl_ec_diffie_hellman_t *openssl_ec_diffie_hellman_create(
|
||||
key_exchange_method_t group);
|
||||
|
||||
/**
|
||||
* Map ECDH groups to OpenSSL NIDs for the ECC curve.
|
||||
@@ -51,6 +52,6 @@ openssl_ec_diffie_hellman_t *openssl_ec_diffie_hellman_create(diffie_hellman_gro
|
||||
* @param group ECDH group
|
||||
* @return NID for the curve
|
||||
*/
|
||||
int openssl_ecdh_group_to_nid(diffie_hellman_group_t group);
|
||||
int openssl_ecdh_group_to_nid(key_exchange_method_t group);
|
||||
|
||||
#endif /** OPENSSL_EC_DIFFIE_HELLMAN_H_ @}*/
|
||||
|
||||
@@ -326,7 +326,7 @@ METHOD(plugin_t, get_name, char*,
|
||||
* Check if the given DH group is in the list of supported curves.
|
||||
*/
|
||||
static bool ecdh_group_supported(EC_builtin_curve *curves, size_t num_curves,
|
||||
diffie_hellman_group_t group)
|
||||
key_exchange_method_t group)
|
||||
{
|
||||
int j;
|
||||
|
||||
@@ -360,7 +360,7 @@ static void add_ecdh_features(plugin_feature_t *features,
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
if (to_add[i].kind != FEATURE_PROVIDE ||
|
||||
ecdh_group_supported(curves, num_curves, to_add[i].arg.dh_group))
|
||||
ecdh_group_supported(curves, num_curves, to_add[i].arg.ke))
|
||||
{
|
||||
features[(*pos)++] = to_add[i];
|
||||
}
|
||||
@@ -528,19 +528,19 @@ METHOD(plugin_t, get_features, int,
|
||||
#endif /* OPENSSL_VERSION_NUMBER */
|
||||
#ifndef OPENSSL_NO_DH
|
||||
/* MODP DH groups */
|
||||
PLUGIN_REGISTER(DH, openssl_diffie_hellman_create),
|
||||
PLUGIN_PROVIDE(DH, MODP_3072_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_4096_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_6144_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_8192_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_2048_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_2048_224),
|
||||
PLUGIN_PROVIDE(DH, MODP_2048_256),
|
||||
PLUGIN_PROVIDE(DH, MODP_1536_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_1024_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_1024_160),
|
||||
PLUGIN_PROVIDE(DH, MODP_768_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_CUSTOM),
|
||||
PLUGIN_REGISTER(KE, openssl_diffie_hellman_create),
|
||||
PLUGIN_PROVIDE(KE, MODP_3072_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_4096_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_6144_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_8192_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_2048_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_2048_224),
|
||||
PLUGIN_PROVIDE(KE, MODP_2048_256),
|
||||
PLUGIN_PROVIDE(KE, MODP_1536_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_1024_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_1024_160),
|
||||
PLUGIN_PROVIDE(KE, MODP_768_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_CUSTOM),
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RSA
|
||||
/* RSA private/public key loading */
|
||||
@@ -649,11 +649,11 @@ METHOD(plugin_t, get_features, int,
|
||||
#endif
|
||||
#endif /* OPENSSL_NO_ECDSA */
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x1010100fL && !defined(OPENSSL_NO_ECDH)
|
||||
PLUGIN_REGISTER(DH, openssl_x_diffie_hellman_create),
|
||||
PLUGIN_REGISTER(KE, openssl_x_diffie_hellman_create),
|
||||
/* available since 1.1.0a, but we require 1.1.1 features */
|
||||
PLUGIN_PROVIDE(DH, CURVE_25519),
|
||||
PLUGIN_PROVIDE(KE, CURVE_25519),
|
||||
/* available since 1.1.1 */
|
||||
PLUGIN_PROVIDE(DH, CURVE_448),
|
||||
PLUGIN_PROVIDE(KE, CURVE_448),
|
||||
#endif /* OPENSSL_VERSION_NUMBER && !OPENSSL_NO_ECDH */
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x1010100fL && !defined(OPENSSL_NO_EC)
|
||||
/* EdDSA private/public key loading */
|
||||
@@ -686,17 +686,17 @@ METHOD(plugin_t, get_features, int,
|
||||
static plugin_feature_t f_ecdh[] = {
|
||||
#ifndef OPENSSL_NO_ECDH
|
||||
/* EC DH groups */
|
||||
PLUGIN_REGISTER(DH, openssl_ec_diffie_hellman_create),
|
||||
PLUGIN_PROVIDE(DH, ECP_256_BIT),
|
||||
PLUGIN_PROVIDE(DH, ECP_384_BIT),
|
||||
PLUGIN_PROVIDE(DH, ECP_521_BIT),
|
||||
PLUGIN_PROVIDE(DH, ECP_224_BIT),
|
||||
PLUGIN_PROVIDE(DH, ECP_192_BIT),
|
||||
PLUGIN_REGISTER(KE, openssl_ec_diffie_hellman_create),
|
||||
PLUGIN_PROVIDE(KE, ECP_256_BIT),
|
||||
PLUGIN_PROVIDE(KE, ECP_384_BIT),
|
||||
PLUGIN_PROVIDE(KE, ECP_521_BIT),
|
||||
PLUGIN_PROVIDE(KE, ECP_224_BIT),
|
||||
PLUGIN_PROVIDE(KE, ECP_192_BIT),
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x10002000L
|
||||
PLUGIN_PROVIDE(DH, ECP_256_BP),
|
||||
PLUGIN_PROVIDE(DH, ECP_384_BP),
|
||||
PLUGIN_PROVIDE(DH, ECP_512_BP),
|
||||
PLUGIN_PROVIDE(DH, ECP_224_BP),
|
||||
PLUGIN_PROVIDE(KE, ECP_256_BP),
|
||||
PLUGIN_PROVIDE(KE, ECP_384_BP),
|
||||
PLUGIN_PROVIDE(KE, ECP_512_BP),
|
||||
PLUGIN_PROVIDE(KE, ECP_224_BP),
|
||||
#endif /* OPENSSL_VERSION_NUMBER */
|
||||
#endif /* OPENSSL_NO_ECDH */
|
||||
};
|
||||
|
||||
@@ -25,21 +25,21 @@
|
||||
|
||||
#include <utils/debug.h>
|
||||
|
||||
typedef struct private_diffie_hellman_t private_diffie_hellman_t;
|
||||
typedef struct private_key_exchange_t private_key_exchange_t;
|
||||
|
||||
/**
|
||||
* Private data
|
||||
*/
|
||||
struct private_diffie_hellman_t {
|
||||
struct private_key_exchange_t {
|
||||
/**
|
||||
* Public interface.
|
||||
*/
|
||||
diffie_hellman_t public;
|
||||
key_exchange_t public;
|
||||
|
||||
/**
|
||||
* Diffie Hellman group number.
|
||||
* Key exchange method.
|
||||
*/
|
||||
diffie_hellman_group_t group;
|
||||
key_exchange_method_t ke;
|
||||
|
||||
/**
|
||||
* Private (public) key
|
||||
@@ -58,11 +58,11 @@ struct private_diffie_hellman_t {
|
||||
};
|
||||
|
||||
/**
|
||||
* Map a DH group to a key type
|
||||
* Map a key exchange method to a key type
|
||||
*/
|
||||
static int map_key_type(diffie_hellman_group_t group)
|
||||
static int map_key_type(key_exchange_method_t ke)
|
||||
{
|
||||
switch (group)
|
||||
switch (ke)
|
||||
{
|
||||
case CURVE_25519:
|
||||
return EVP_PKEY_X25519;
|
||||
@@ -73,29 +73,29 @@ static int map_key_type(diffie_hellman_group_t group)
|
||||
}
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, set_other_public_value, bool,
|
||||
private_diffie_hellman_t *this, chunk_t value)
|
||||
METHOD(key_exchange_t, set_public_key, bool,
|
||||
private_key_exchange_t *this, chunk_t value)
|
||||
{
|
||||
if (!diffie_hellman_verify_value(this->group, value))
|
||||
if (!key_exchange_verify_pubkey(this->ke, value))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
EVP_PKEY_free(this->pub);
|
||||
this->pub = EVP_PKEY_new_raw_public_key(map_key_type(this->group), NULL,
|
||||
this->pub = EVP_PKEY_new_raw_public_key(map_key_type(this->ke), NULL,
|
||||
value.ptr, value.len);
|
||||
if (!this->pub)
|
||||
{
|
||||
DBG1(DBG_LIB, "%N public value is malformed",
|
||||
diffie_hellman_group_names, this->group);
|
||||
key_exchange_method_names, this->ke);
|
||||
return FALSE;
|
||||
}
|
||||
chunk_clear(&this->shared_secret);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
private_diffie_hellman_t *this, chunk_t *value)
|
||||
METHOD(key_exchange_t, get_public_key, bool,
|
||||
private_key_exchange_t *this, chunk_t *value)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
@@ -114,11 +114,11 @@ METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, set_private_value, bool,
|
||||
private_diffie_hellman_t *this, chunk_t value)
|
||||
METHOD(key_exchange_t, set_private_key, bool,
|
||||
private_key_exchange_t *this, chunk_t value)
|
||||
{
|
||||
EVP_PKEY_free(this->key);
|
||||
this->key = EVP_PKEY_new_raw_private_key(map_key_type(this->group), NULL,
|
||||
this->key = EVP_PKEY_new_raw_private_key(map_key_type(this->ke), NULL,
|
||||
value.ptr, value.len);
|
||||
if (!this->key)
|
||||
{
|
||||
@@ -127,28 +127,28 @@ METHOD(diffie_hellman_t, set_private_value, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
private_diffie_hellman_t *this, chunk_t *secret)
|
||||
METHOD(key_exchange_t, get_shared_secret, bool,
|
||||
private_key_exchange_t *this, chunk_t *secret)
|
||||
{
|
||||
if (!this->shared_secret.len &&
|
||||
!openssl_compute_shared_key(this->key, this->pub, &this->shared_secret))
|
||||
{
|
||||
DBG1(DBG_LIB, "%N shared secret computation failed",
|
||||
diffie_hellman_group_names, this->group);
|
||||
key_exchange_method_names, this->ke);
|
||||
return FALSE;
|
||||
}
|
||||
*secret = chunk_clone(this->shared_secret);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
|
||||
private_diffie_hellman_t *this)
|
||||
METHOD(key_exchange_t, get_method, key_exchange_method_t,
|
||||
private_key_exchange_t *this)
|
||||
{
|
||||
return this->group;
|
||||
return this->ke;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, destroy, void,
|
||||
private_diffie_hellman_t *this)
|
||||
METHOD(key_exchange_t, destroy, void,
|
||||
private_key_exchange_t *this)
|
||||
{
|
||||
EVP_PKEY_free(this->key);
|
||||
EVP_PKEY_free(this->pub);
|
||||
@@ -159,13 +159,13 @@ METHOD(diffie_hellman_t, destroy, void,
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
diffie_hellman_t *openssl_x_diffie_hellman_create(diffie_hellman_group_t group)
|
||||
key_exchange_t *openssl_x_diffie_hellman_create(key_exchange_method_t ke)
|
||||
{
|
||||
private_diffie_hellman_t *this;
|
||||
private_key_exchange_t *this;
|
||||
EVP_PKEY_CTX *ctx = NULL;
|
||||
EVP_PKEY *key = NULL;
|
||||
|
||||
switch (group)
|
||||
switch (ke)
|
||||
{
|
||||
case CURVE_25519:
|
||||
ctx = EVP_PKEY_CTX_new_id(NID_X25519, NULL);
|
||||
@@ -182,7 +182,7 @@ diffie_hellman_t *openssl_x_diffie_hellman_create(diffie_hellman_group_t group)
|
||||
EVP_PKEY_keygen(ctx, &key) <= 0)
|
||||
{
|
||||
DBG1(DBG_LIB, "generating key for %N failed",
|
||||
diffie_hellman_group_names, group);
|
||||
key_exchange_method_names, ke);
|
||||
EVP_PKEY_CTX_free(ctx);
|
||||
return NULL;
|
||||
}
|
||||
@@ -191,13 +191,13 @@ diffie_hellman_t *openssl_x_diffie_hellman_create(diffie_hellman_group_t group)
|
||||
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,
|
||||
.set_private_value = _set_private_value,
|
||||
.get_dh_group = _get_dh_group,
|
||||
.set_public_key = _set_public_key,
|
||||
.get_public_key = _get_public_key,
|
||||
.set_private_key = _set_private_key,
|
||||
.get_method = _get_method,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
.group = group,
|
||||
.ke = ke,
|
||||
.key = key,
|
||||
);
|
||||
return &this->public;
|
||||
|
||||
@@ -27,12 +27,12 @@
|
||||
#include <library.h>
|
||||
|
||||
/**
|
||||
* Creates a new diffie_hellman_t object.
|
||||
* Creates a new key_exchange_t object.
|
||||
*
|
||||
* @param group Diffie Hellman group number to use
|
||||
* @param ke key exchange method to use
|
||||
* @return object, NULL if not supported
|
||||
*/
|
||||
diffie_hellman_t *openssl_x_diffie_hellman_create(diffie_hellman_group_t group);
|
||||
key_exchange_t *openssl_x_diffie_hellman_create(key_exchange_method_t ke);
|
||||
|
||||
#endif /** OPENSSL_X_DIFFIE_HELLMAN_H_ @}*/
|
||||
|
||||
|
||||
@@ -46,9 +46,9 @@ struct private_pkcs11_dh_t {
|
||||
CK_SESSION_HANDLE session;
|
||||
|
||||
/**
|
||||
* Diffie Hellman group number.
|
||||
* Diffie-Hellman group number.
|
||||
*/
|
||||
diffie_hellman_group_t group;
|
||||
key_exchange_method_t group;
|
||||
|
||||
/**
|
||||
* Handle for own private value
|
||||
@@ -114,10 +114,10 @@ static bool derive_secret(private_pkcs11_dh_t *this, chunk_t other)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, set_other_public_value, bool,
|
||||
METHOD(key_exchange_t, set_public_key, bool,
|
||||
private_pkcs11_dh_t *this, chunk_t value)
|
||||
{
|
||||
if (!diffie_hellman_verify_value(this->group, value))
|
||||
if (!key_exchange_verify_pubkey(this->group, value))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -149,14 +149,14 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
|
||||
return derive_secret(this, value);
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
METHOD(key_exchange_t, get_public_key, bool,
|
||||
private_pkcs11_dh_t *this, chunk_t *value)
|
||||
{
|
||||
*value = chunk_clone(this->pub_key);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
METHOD(key_exchange_t, get_shared_secret, bool,
|
||||
private_pkcs11_dh_t *this, chunk_t *secret)
|
||||
{
|
||||
if (!this->secret.ptr)
|
||||
@@ -167,13 +167,13 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
|
||||
METHOD(key_exchange_t, get_method, key_exchange_method_t,
|
||||
private_pkcs11_dh_t *this)
|
||||
{
|
||||
return this->group;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, destroy, void,
|
||||
METHOD(key_exchange_t, destroy, void,
|
||||
private_pkcs11_dh_t *this)
|
||||
{
|
||||
this->lib->f->C_CloseSession(this->session);
|
||||
@@ -316,7 +316,7 @@ static pkcs11_library_t *find_token(private_pkcs11_dh_t *this,
|
||||
/**
|
||||
* Generic internal constructor
|
||||
*/
|
||||
static private_pkcs11_dh_t *create_generic(diffie_hellman_group_t group,
|
||||
static private_pkcs11_dh_t *create_generic(key_exchange_method_t group,
|
||||
CK_MECHANISM_TYPE key,
|
||||
CK_MECHANISM_TYPE derive)
|
||||
{
|
||||
@@ -324,11 +324,11 @@ static private_pkcs11_dh_t *create_generic(diffie_hellman_group_t group,
|
||||
|
||||
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,
|
||||
},
|
||||
},
|
||||
@@ -346,7 +346,7 @@ static private_pkcs11_dh_t *create_generic(diffie_hellman_group_t group,
|
||||
return this;
|
||||
}
|
||||
|
||||
static pkcs11_dh_t *create_ecp(diffie_hellman_group_t group, chunk_t ecparam)
|
||||
static pkcs11_dh_t *create_ecp(key_exchange_method_t group, chunk_t ecparam)
|
||||
{
|
||||
private_pkcs11_dh_t *this = create_generic(group, CKM_EC_KEY_PAIR_GEN,
|
||||
CKM_ECDH1_DERIVE);
|
||||
@@ -367,7 +367,7 @@ static pkcs11_dh_t *create_ecp(diffie_hellman_group_t group, chunk_t ecparam)
|
||||
/**
|
||||
* Constructor for MODP DH
|
||||
*/
|
||||
static pkcs11_dh_t *create_modp(diffie_hellman_group_t group, size_t exp_len,
|
||||
static pkcs11_dh_t *create_modp(key_exchange_method_t group, size_t exp_len,
|
||||
chunk_t g, chunk_t p)
|
||||
{
|
||||
private_pkcs11_dh_t *this = create_generic(group, CKM_DH_PKCS_KEY_PAIR_GEN,
|
||||
@@ -387,7 +387,7 @@ static pkcs11_dh_t *create_modp(diffie_hellman_group_t group, size_t exp_len,
|
||||
/**
|
||||
* Lookup the EC params for the given group.
|
||||
*/
|
||||
static chunk_t ecparams_lookup(diffie_hellman_group_t group)
|
||||
static chunk_t ecparams_lookup(key_exchange_method_t group)
|
||||
{
|
||||
switch (group)
|
||||
{
|
||||
@@ -410,7 +410,7 @@ static chunk_t ecparams_lookup(diffie_hellman_group_t group)
|
||||
/**
|
||||
* Described in header.
|
||||
*/
|
||||
pkcs11_dh_t *pkcs11_dh_create(diffie_hellman_group_t group, ...)
|
||||
pkcs11_dh_t *pkcs11_dh_create(key_exchange_method_t group, ...)
|
||||
{
|
||||
switch (group)
|
||||
{
|
||||
|
||||
@@ -32,19 +32,19 @@ typedef struct pkcs11_dh_t pkcs11_dh_t;
|
||||
struct pkcs11_dh_t {
|
||||
|
||||
/**
|
||||
* Implements diffie_hellman_t interface.
|
||||
* Implements key_exchange_t interface.
|
||||
*/
|
||||
diffie_hellman_t dh;
|
||||
key_exchange_t ke;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new pkcs11_dh_t object.
|
||||
*
|
||||
* @param group Diffie Hellman group number to use
|
||||
* @param group Diffie-Hellman group number to use
|
||||
* @param ... expects generator and prime as chunk_t if MODP_CUSTOM
|
||||
* @return pkcs11_dh_t object, NULL if not supported
|
||||
*/
|
||||
pkcs11_dh_t *pkcs11_dh_create(diffie_hellman_group_t group, ...);
|
||||
pkcs11_dh_t *pkcs11_dh_create(key_exchange_method_t group, ...);
|
||||
|
||||
#endif /** PKCS11_DH_H_ @}*/
|
||||
|
||||
|
||||
@@ -197,27 +197,27 @@ METHOD(plugin_t, get_features, int,
|
||||
PLUGIN_PROVIDE(HASHER, HASH_SHA512),
|
||||
};
|
||||
static plugin_feature_t f_dh[] = {
|
||||
PLUGIN_REGISTER(DH, pkcs11_dh_create),
|
||||
PLUGIN_PROVIDE(DH, MODP_2048_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_2048_224),
|
||||
PLUGIN_PROVIDE(DH, MODP_2048_256),
|
||||
PLUGIN_PROVIDE(DH, MODP_1536_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_3072_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_4096_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_6144_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_8192_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_1024_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_1024_160),
|
||||
PLUGIN_PROVIDE(DH, MODP_768_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_CUSTOM),
|
||||
PLUGIN_REGISTER(KE, pkcs11_dh_create),
|
||||
PLUGIN_PROVIDE(KE, MODP_2048_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_2048_224),
|
||||
PLUGIN_PROVIDE(KE, MODP_2048_256),
|
||||
PLUGIN_PROVIDE(KE, MODP_1536_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_3072_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_4096_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_6144_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_8192_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_1024_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_1024_160),
|
||||
PLUGIN_PROVIDE(KE, MODP_768_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_CUSTOM),
|
||||
};
|
||||
static plugin_feature_t f_ecdh[] = {
|
||||
PLUGIN_REGISTER(DH, pkcs11_dh_create),
|
||||
PLUGIN_PROVIDE(DH, ECP_192_BIT),
|
||||
PLUGIN_PROVIDE(DH, ECP_224_BIT),
|
||||
PLUGIN_PROVIDE(DH, ECP_256_BIT),
|
||||
PLUGIN_PROVIDE(DH, ECP_384_BIT),
|
||||
PLUGIN_PROVIDE(DH, ECP_521_BIT),
|
||||
PLUGIN_REGISTER(KE, pkcs11_dh_create),
|
||||
PLUGIN_PROVIDE(KE, ECP_192_BIT),
|
||||
PLUGIN_PROVIDE(KE, ECP_224_BIT),
|
||||
PLUGIN_PROVIDE(KE, ECP_256_BIT),
|
||||
PLUGIN_PROVIDE(KE, ECP_384_BIT),
|
||||
PLUGIN_PROVIDE(KE, ECP_521_BIT),
|
||||
};
|
||||
static plugin_feature_t f_rng[] = {
|
||||
PLUGIN_REGISTER(RNG, pkcs11_rng_create),
|
||||
|
||||
@@ -33,7 +33,7 @@ ENUM(plugin_feature_names, FEATURE_NONE, FEATURE_CUSTOM,
|
||||
"XOF",
|
||||
"KDF",
|
||||
"DRBG",
|
||||
"DH",
|
||||
"KE",
|
||||
"RNG",
|
||||
"NONCE_GEN",
|
||||
"PRIVKEY",
|
||||
@@ -99,8 +99,8 @@ uint32_t plugin_feature_hash(plugin_feature_t *feature)
|
||||
case FEATURE_DRBG:
|
||||
data = chunk_from_thing(feature->arg.drbg);
|
||||
break;
|
||||
case FEATURE_DH:
|
||||
data = chunk_from_thing(feature->arg.dh_group);
|
||||
case FEATURE_KE:
|
||||
data = chunk_from_thing(feature->arg.ke);
|
||||
break;
|
||||
case FEATURE_PRIVKEY:
|
||||
data = chunk_from_thing(feature->arg.privkey);
|
||||
@@ -178,8 +178,8 @@ bool plugin_feature_matches(plugin_feature_t *a, plugin_feature_t *b)
|
||||
return a->arg.kdf == b->arg.kdf;
|
||||
case FEATURE_DRBG:
|
||||
return a->arg.drbg == b->arg.drbg;
|
||||
case FEATURE_DH:
|
||||
return a->arg.dh_group == b->arg.dh_group;
|
||||
case FEATURE_KE:
|
||||
return a->arg.ke == b->arg.ke;
|
||||
case FEATURE_RNG:
|
||||
return a->arg.rng_quality <= b->arg.rng_quality;
|
||||
case FEATURE_NONCE_GEN:
|
||||
@@ -239,7 +239,7 @@ bool plugin_feature_equals(plugin_feature_t *a, plugin_feature_t *b)
|
||||
case FEATURE_XOF:
|
||||
case FEATURE_KDF:
|
||||
case FEATURE_DRBG:
|
||||
case FEATURE_DH:
|
||||
case FEATURE_KE:
|
||||
case FEATURE_NONCE_GEN:
|
||||
case FEATURE_RESOLVER:
|
||||
case FEATURE_PRIVKEY:
|
||||
@@ -347,9 +347,9 @@ char* plugin_feature_get_string(plugin_feature_t *feature)
|
||||
return str;
|
||||
}
|
||||
break;
|
||||
case FEATURE_DH:
|
||||
case FEATURE_KE:
|
||||
if (asprintf(&str, "%N:%N", plugin_feature_names, feature->type,
|
||||
diffie_hellman_group_names, feature->arg.dh_group) > 0)
|
||||
key_exchange_method_names, feature->arg.ke) > 0)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
@@ -530,8 +530,8 @@ bool plugin_feature_load(plugin_t *plugin, plugin_feature_t *feature,
|
||||
lib->crypto->add_drbg(lib->crypto, feature->arg.drbg,
|
||||
name, reg->arg.reg.f);
|
||||
break;
|
||||
case FEATURE_DH:
|
||||
lib->crypto->add_dh(lib->crypto, feature->arg.dh_group,
|
||||
case FEATURE_KE:
|
||||
lib->crypto->add_ke(lib->crypto, feature->arg.ke,
|
||||
name, reg->arg.reg.f);
|
||||
break;
|
||||
case FEATURE_RNG:
|
||||
@@ -635,8 +635,8 @@ bool plugin_feature_unload(plugin_t *plugin, plugin_feature_t *feature,
|
||||
case FEATURE_DRBG:
|
||||
lib->crypto->remove_drbg(lib->crypto, reg->arg.reg.f);
|
||||
break;
|
||||
case FEATURE_DH:
|
||||
lib->crypto->remove_dh(lib->crypto, reg->arg.reg.f);
|
||||
case FEATURE_KE:
|
||||
lib->crypto->remove_ke(lib->crypto, reg->arg.reg.f);
|
||||
break;
|
||||
case FEATURE_RNG:
|
||||
lib->crypto->remove_rng(lib->crypto, reg->arg.reg.f);
|
||||
|
||||
@@ -116,8 +116,8 @@ struct plugin_feature_t {
|
||||
FEATURE_KDF,
|
||||
/** drbg_t */
|
||||
FEATURE_DRBG,
|
||||
/** diffie_hellman_t */
|
||||
FEATURE_DH,
|
||||
/** key_exchange_t */
|
||||
FEATURE_KE,
|
||||
/** rng_t */
|
||||
FEATURE_RNG,
|
||||
/** nonce_gen_t */
|
||||
@@ -185,8 +185,8 @@ struct plugin_feature_t {
|
||||
drbg_type_t drbg;
|
||||
/** FEATURE_HASHER */
|
||||
hash_algorithm_t hasher;
|
||||
/** FEATURE_DH */
|
||||
diffie_hellman_group_t dh_group;
|
||||
/** FEATURE_KE */
|
||||
key_exchange_method_t ke;
|
||||
/** FEATURE_RNG */
|
||||
rng_quality_t rng_quality;
|
||||
/** FEATURE_PRIVKEY */
|
||||
@@ -293,7 +293,7 @@ struct plugin_feature_t {
|
||||
#define _PLUGIN_FEATURE_XOF(kind, alg) __PLUGIN_FEATURE(kind, XOF, .xof = alg)
|
||||
#define _PLUGIN_FEATURE_KDF(kind, alg) __PLUGIN_FEATURE(kind, KDF, .kdf = alg)
|
||||
#define _PLUGIN_FEATURE_DRBG(kind, type) __PLUGIN_FEATURE(kind, DRBG, .drbg = type)
|
||||
#define _PLUGIN_FEATURE_DH(kind, group) __PLUGIN_FEATURE(kind, DH, .dh_group = group)
|
||||
#define _PLUGIN_FEATURE_KE(kind, method) __PLUGIN_FEATURE(kind, KE, .ke = method)
|
||||
#define _PLUGIN_FEATURE_RNG(kind, quality) __PLUGIN_FEATURE(kind, RNG, .rng_quality = quality)
|
||||
#define _PLUGIN_FEATURE_NONCE_GEN(kind, ...) __PLUGIN_FEATURE(kind, NONCE_GEN, .custom = NULL)
|
||||
#define _PLUGIN_FEATURE_PRIVKEY(kind, type) __PLUGIN_FEATURE(kind, PRIVKEY, .privkey = type)
|
||||
@@ -328,7 +328,7 @@ struct plugin_feature_t {
|
||||
#define _PLUGIN_FEATURE_REGISTER_XOF(type, f) __PLUGIN_FEATURE_REGISTER(type, f)
|
||||
#define _PLUGIN_FEATURE_REGISTER_KDF(type, f) __PLUGIN_FEATURE_REGISTER(type, f)
|
||||
#define _PLUGIN_FEATURE_REGISTER_DRBG(type, f) __PLUGIN_FEATURE_REGISTER(type, f)
|
||||
#define _PLUGIN_FEATURE_REGISTER_DH(type, f) __PLUGIN_FEATURE_REGISTER(type, f)
|
||||
#define _PLUGIN_FEATURE_REGISTER_KE(type, f) __PLUGIN_FEATURE_REGISTER(type, f)
|
||||
#define _PLUGIN_FEATURE_REGISTER_RNG(type, f) __PLUGIN_FEATURE_REGISTER(type, f)
|
||||
#define _PLUGIN_FEATURE_REGISTER_NONCE_GEN(type, f) __PLUGIN_FEATURE_REGISTER(type, f)
|
||||
#define _PLUGIN_FEATURE_REGISTER_PRIVKEY(type, f, final) __PLUGIN_FEATURE_REGISTER_BUILDER(type, f, final)
|
||||
|
||||
@@ -352,26 +352,26 @@ TEST_VECTOR_RNG(rng_runs_1)
|
||||
TEST_VECTOR_RNG(rng_runs_2)
|
||||
TEST_VECTOR_RNG(rng_runs_3)
|
||||
|
||||
TEST_VECTOR_DH(modp768)
|
||||
TEST_VECTOR_DH(modp1024)
|
||||
TEST_VECTOR_DH(modp1536)
|
||||
TEST_VECTOR_DH(modp2048)
|
||||
TEST_VECTOR_DH(modp3072)
|
||||
TEST_VECTOR_DH(modp4096)
|
||||
TEST_VECTOR_DH(modp6144)
|
||||
TEST_VECTOR_DH(modp8192)
|
||||
TEST_VECTOR_DH(modp1024_160)
|
||||
TEST_VECTOR_DH(modp2048_224)
|
||||
TEST_VECTOR_DH(modp2048_256)
|
||||
TEST_VECTOR_DH(ecp192)
|
||||
TEST_VECTOR_DH(ecp224)
|
||||
TEST_VECTOR_DH(ecp256)
|
||||
TEST_VECTOR_DH(ecp384)
|
||||
TEST_VECTOR_DH(ecp521)
|
||||
TEST_VECTOR_DH(ecp224bp)
|
||||
TEST_VECTOR_DH(ecp256bp)
|
||||
TEST_VECTOR_DH(ecp384bp)
|
||||
TEST_VECTOR_DH(ecp512bp)
|
||||
TEST_VECTOR_DH(curve25519_1)
|
||||
TEST_VECTOR_DH(curve25519_2)
|
||||
TEST_VECTOR_DH(curve448_1)
|
||||
TEST_VECTOR_KE(modp768)
|
||||
TEST_VECTOR_KE(modp1024)
|
||||
TEST_VECTOR_KE(modp1536)
|
||||
TEST_VECTOR_KE(modp2048)
|
||||
TEST_VECTOR_KE(modp3072)
|
||||
TEST_VECTOR_KE(modp4096)
|
||||
TEST_VECTOR_KE(modp6144)
|
||||
TEST_VECTOR_KE(modp8192)
|
||||
TEST_VECTOR_KE(modp1024_160)
|
||||
TEST_VECTOR_KE(modp2048_224)
|
||||
TEST_VECTOR_KE(modp2048_256)
|
||||
TEST_VECTOR_KE(ecp192)
|
||||
TEST_VECTOR_KE(ecp224)
|
||||
TEST_VECTOR_KE(ecp256)
|
||||
TEST_VECTOR_KE(ecp384)
|
||||
TEST_VECTOR_KE(ecp521)
|
||||
TEST_VECTOR_KE(ecp224bp)
|
||||
TEST_VECTOR_KE(ecp256bp)
|
||||
TEST_VECTOR_KE(ecp384bp)
|
||||
TEST_VECTOR_KE(ecp512bp)
|
||||
TEST_VECTOR_KE(curve25519_1)
|
||||
TEST_VECTOR_KE(curve25519_2)
|
||||
TEST_VECTOR_KE(curve448_1)
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
/**
|
||||
* From RFC 7748
|
||||
*/
|
||||
dh_test_vector_t curve25519_1 = {
|
||||
.group = CURVE_25519, .priv_len = 32, .pub_len = 32, .shared_len = 32,
|
||||
ke_test_vector_t curve25519_1 = {
|
||||
.method = CURVE_25519, .priv_len = 32, .pub_len = 32, .shared_len = 32,
|
||||
.priv_a = "\x77\x07\x6d\x0a\x73\x18\xa5\x7d\x3c\x16\xc1\x72\x51\xb2\x66\x45"
|
||||
"\xdf\x4c\x2f\x87\xeb\xc0\x99\x2a\xb1\x77\xfb\xa5\x1d\xb9\x2c\x2a",
|
||||
.priv_b = "\x5d\xab\x08\x7e\x62\x4a\x8a\x4b\x79\xe1\x7f\x8b\x83\x80\x0e\xe6"
|
||||
@@ -36,8 +36,8 @@ dh_test_vector_t curve25519_1 = {
|
||||
/**
|
||||
* From RFC 8031
|
||||
*/
|
||||
dh_test_vector_t curve25519_2 = {
|
||||
.group = CURVE_25519, .priv_len = 32, .pub_len = 32, .shared_len = 32,
|
||||
ke_test_vector_t curve25519_2 = {
|
||||
.method = CURVE_25519, .priv_len = 32, .pub_len = 32, .shared_len = 32,
|
||||
.priv_a = "\x75\x1f\xb4\x30\x86\x55\xb4\x76\xb6\x78\x9b\x73\x25\xf9\xea\x8c"
|
||||
"\xdd\xd1\x6a\x58\x53\x3f\xf6\xd9\xe6\x00\x09\x46\x4a\x5f\x9d\x94",
|
||||
.priv_b = "\x0a\x54\x64\x52\x53\x29\x0d\x60\xdd\xad\xd0\xe0\x30\xba\xcd\x9e"
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
/**
|
||||
* From RFC 7748
|
||||
*/
|
||||
dh_test_vector_t curve448_1 = {
|
||||
.group = CURVE_448, .priv_len = 56, .pub_len = 56, .shared_len = 56,
|
||||
ke_test_vector_t curve448_1 = {
|
||||
.method = CURVE_448, .priv_len = 56, .pub_len = 56, .shared_len = 56,
|
||||
.priv_a = "\x9a\x8f\x49\x25\xd1\x51\x9f\x57\x75\xcf\x46\xb0\x4b\x58\x00\xd4"
|
||||
"\xee\x9e\xe8\xba\xe8\xbc\x55\x65\xd4\x98\xc2\x8d\xd9\xc9\xba\xf5"
|
||||
"\x74\xa9\x41\x97\x44\x89\x73\x91\x00\x63\x82\xa6\xf1\x27\xab\x1d"
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
* Test vectors from RFC5114
|
||||
*/
|
||||
|
||||
dh_test_vector_t ecp192 = {
|
||||
.group = ECP_192_BIT, .priv_len = 24, .pub_len = 48, .shared_len = 24,
|
||||
ke_test_vector_t ecp192 = {
|
||||
.method = ECP_192_BIT, .priv_len = 24, .pub_len = 48, .shared_len = 24,
|
||||
.priv_a = "\x32\x3f\xa3\x16\x9d\x8e\x9c\x65\x93\xf5\x94\x76\xbc\x14\x20\x00"
|
||||
"\xab\x5b\xe0\xe2\x49\xc4\x34\x26",
|
||||
.priv_b = "\x63\x1f\x95\xbb\x4a\x67\x63\x2c\x9c\x47\x6e\xee\x9a\xb6\x95\xab"
|
||||
@@ -36,8 +36,8 @@ dh_test_vector_t ecp192 = {
|
||||
"\xe5\xff\x4f\x83\x7f\x54\xfe\xbe",
|
||||
};
|
||||
|
||||
dh_test_vector_t ecp224 = {
|
||||
.group = ECP_224_BIT, .priv_len = 28, .pub_len = 56, .shared_len = 28,
|
||||
ke_test_vector_t ecp224 = {
|
||||
.method = ECP_224_BIT, .priv_len = 28, .pub_len = 56, .shared_len = 28,
|
||||
.priv_a = "\xb5\x58\xeb\x6c\x28\x8d\xa7\x07\xbb\xb4\xf8\xfb\xae\x2a\xb9\xe9"
|
||||
"\xcb\x62\xe3\xbc\x5c\x75\x73\xe2\x2e\x26\xd3\x7f",
|
||||
.priv_b = "\xac\x3b\x1a\xdd\x3d\x97\x70\xe6\xf6\xa7\x08\xee\x9f\x3b\x8e\x0a"
|
||||
@@ -54,8 +54,8 @@ dh_test_vector_t ecp224 = {
|
||||
"\xd9\x6e\xcc\x3b\x6d\xc1\x71\x4a\x4e\xa9\x49\xfa",
|
||||
};
|
||||
|
||||
dh_test_vector_t ecp256 = {
|
||||
.group = ECP_256_BIT, .priv_len = 32, .pub_len = 64, .shared_len = 32,
|
||||
ke_test_vector_t ecp256 = {
|
||||
.method = ECP_256_BIT, .priv_len = 32, .pub_len = 64, .shared_len = 32,
|
||||
.priv_a = "\x81\x42\x64\x14\x5f\x2f\x56\xf2\xe9\x6a\x8e\x33\x7a\x12\x84\x99"
|
||||
"\x3f\xaf\x43\x2a\x5a\xbc\xe5\x9e\x86\x7b\x72\x91\xd5\x07\xa3\xaf",
|
||||
.priv_b = "\x2c\xe1\x78\x8e\xc1\x97\xe0\x96\xdb\x95\xa2\x00\xcc\x0a\xb2\x6a"
|
||||
@@ -72,8 +72,8 @@ dh_test_vector_t ecp256 = {
|
||||
"\xf5\x81\x1e\x9d\xc8\xec\x8e\xea\x7f\x80\xd2\x1c\x82\x0c\x27\x88",
|
||||
};
|
||||
|
||||
dh_test_vector_t ecp384 = {
|
||||
.group = ECP_384_BIT, .priv_len = 48, .pub_len = 96, .shared_len = 48,
|
||||
ke_test_vector_t ecp384 = {
|
||||
.method = ECP_384_BIT, .priv_len = 48, .pub_len = 96, .shared_len = 48,
|
||||
.priv_a = "\xd2\x73\x35\xea\x71\x66\x4a\xf2\x44\xdd\x14\xe9\xfd\x12\x60\x71"
|
||||
"\x5d\xfd\x8a\x79\x65\x57\x1c\x48\xd7\x09\xee\x7a\x79\x62\xa1\x56"
|
||||
"\xd7\x06\xa9\x0c\xbc\xb5\xdf\x29\x86\xf0\x5f\xea\xdb\x93\x76\xf1",
|
||||
@@ -97,8 +97,8 @@ dh_test_vector_t ecp384 = {
|
||||
"\x27\xaa\x8a\x45\x40\x88\x4c\x37\xde\x15\x9a\x58\x02\x8a\xbc\x0e",
|
||||
};
|
||||
|
||||
dh_test_vector_t ecp521 = {
|
||||
.group = ECP_521_BIT, .priv_len = 66, .pub_len = 132, .shared_len = 66,
|
||||
ke_test_vector_t ecp521 = {
|
||||
.method = ECP_521_BIT, .priv_len = 66, .pub_len = 132, .shared_len = 66,
|
||||
.priv_a = "\x01\x13\xf8\x2d\xa8\x25\x73\x5e\x3d\x97\x27\x66\x83\xb2\xb7\x42"
|
||||
"\x77\xba\xd2\x73\x35\xea\x71\x66\x4a\xf2\x43\x0c\xc4\xf3\x34\x59"
|
||||
"\xb9\x66\x9e\xe7\x8b\x3f\xfb\x9b\x86\x83\x01\x5d\x34\x4d\xcb\xfe"
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
* Test vectors from RFC6923/RFC7027
|
||||
*/
|
||||
|
||||
dh_test_vector_t ecp224bp = {
|
||||
.group = ECP_224_BP, .priv_len = 28, .pub_len = 56, .shared_len = 28,
|
||||
ke_test_vector_t ecp224bp = {
|
||||
.method = ECP_224_BP, .priv_len = 28, .pub_len = 56, .shared_len = 28,
|
||||
.priv_a = "\x7c\x4b\x7a\x2c\x8a\x4b\xad\x1f\xbb\x7d\x79\xcc\x09\x55\xdb\x7c"
|
||||
"\x6a\x46\x60\xca\x64\xcc\x47\x78\x15\x9b\x49\x5e",
|
||||
.priv_b = "\x63\x97\x6d\x4a\xae\x6c\xd0\xf6\xdd\x18\xde\xfe\xf5\x5d\x96\x56"
|
||||
@@ -38,8 +38,8 @@ dh_test_vector_t ecp224bp = {
|
||||
"\xdc\xcb\xe3\xb6\x5d\x0f\x96\x7d\xca\xb5\x74\xeb",
|
||||
};
|
||||
|
||||
dh_test_vector_t ecp256bp = {
|
||||
.group = ECP_256_BP, .priv_len = 32, .pub_len = 64, .shared_len = 32,
|
||||
ke_test_vector_t ecp256bp = {
|
||||
.method = ECP_256_BP, .priv_len = 32, .pub_len = 64, .shared_len = 32,
|
||||
.priv_a = "\x81\xdb\x1e\xe1\x00\x15\x0f\xf2\xea\x33\x8d\x70\x82\x71\xbe\x38"
|
||||
"\x30\x0c\xb5\x42\x41\xd7\x99\x50\xf7\x7b\x06\x30\x39\x80\x4f\x1d",
|
||||
.priv_b = "\x55\xe4\x0b\xc4\x1e\x37\xe3\xe2\xad\x25\xc3\xc6\x65\x45\x11\xff"
|
||||
@@ -56,8 +56,8 @@ dh_test_vector_t ecp256bp = {
|
||||
"\xf9\x65\x56\xec\x91\xe6\xae\x79\x39\xbc\xe3\x1f\x3a\x18\xbf\x2b",
|
||||
};
|
||||
|
||||
dh_test_vector_t ecp384bp = {
|
||||
.group = ECP_384_BP, .priv_len = 48, .pub_len = 96, .shared_len = 48,
|
||||
ke_test_vector_t ecp384bp = {
|
||||
.method = ECP_384_BP, .priv_len = 48, .pub_len = 96, .shared_len = 48,
|
||||
.priv_a = "\x1e\x20\xf5\xe0\x48\xa5\x88\x6f\x1f\x15\x7c\x74\xe9\x1b\xde\x2b"
|
||||
"\x98\xc8\xb5\x2d\x58\xe5\x00\x3d\x57\x05\x3f\xc4\xb0\xbd\x65\xd6"
|
||||
"\xf1\x5e\xb5\xd1\xee\x16\x10\xdf\x87\x07\x95\x14\x36\x27\xd0\x42",
|
||||
@@ -81,8 +81,8 @@ dh_test_vector_t ecp384bp = {
|
||||
"\xad\xf6\x40\x37\x15\xc3\x5d\x4f\xb2\xa5\x44\x4f\x57\x5d\x4f\x42",
|
||||
};
|
||||
|
||||
dh_test_vector_t ecp512bp = {
|
||||
.group = ECP_512_BP, .priv_len = 64, .pub_len = 128, .shared_len = 64,
|
||||
ke_test_vector_t ecp512bp = {
|
||||
.method = ECP_512_BP, .priv_len = 64, .pub_len = 128, .shared_len = 64,
|
||||
.priv_a = "\x16\x30\x2f\xf0\xdb\xbb\x5a\x8d\x73\x3d\xab\x71\x41\xc1\xb4\x5a"
|
||||
"\xcb\xc8\x71\x59\x39\x67\x7f\x6a\x56\x85\x0a\x38\xbd\x87\xbd\x59"
|
||||
"\xb0\x9e\x80\x27\x96\x09\xff\x33\x3e\xb9\xd4\xc0\x61\x23\x1f\xb2"
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
* these have been generated.
|
||||
*/
|
||||
|
||||
dh_test_vector_t modp768 = {
|
||||
.group = MODP_768_BIT, .priv_len = 32, .pub_len = 96, .shared_len = 96,
|
||||
ke_test_vector_t modp768 = {
|
||||
.method = MODP_768_BIT, .priv_len = 32, .pub_len = 96, .shared_len = 96,
|
||||
.priv_a = "\x60\x91\xff\xc6\xde\x28\xc1\xcc\xc7\xc6\x5d\xa6\x11\xab\xfa\xe8"
|
||||
"\x6a\x10\x74\xb2\x22\x43\xe3\x70\x6c\xb6\xde\x2f\xe2\x9d\x11\x42",
|
||||
.priv_b = "\x76\xe0\x2f\xc3\xea\xbe\x6a\x0f\xce\xd6\xc3\x1e\x59\x45\xd1\x67"
|
||||
@@ -47,8 +47,8 @@ dh_test_vector_t modp768 = {
|
||||
"\x3d\xaa\xad\x22\xe8\x68\xb7\xe2\x50\x02\x9d\x30\x7e\xe5\x41\x48",
|
||||
};
|
||||
|
||||
dh_test_vector_t modp1024 = {
|
||||
.group = MODP_1024_BIT, .priv_len = 32, .pub_len = 128, .shared_len = 128,
|
||||
ke_test_vector_t modp1024 = {
|
||||
.method = MODP_1024_BIT, .priv_len = 32, .pub_len = 128, .shared_len = 128,
|
||||
.priv_a = "\xe5\x3c\x20\x5d\xa0\xd8\xe4\xbf\xb4\x17\x49\x44\x32\x0f\xc6\xe4"
|
||||
"\xea\x66\xfe\x44\xe3\xc9\x31\xac\x5d\xa1\x45\x0a\xea\x47\xeb\xcf",
|
||||
.priv_b = "\x7f\x9a\xf7\x21\xeb\x7c\xd2\xa9\x00\xa3\x6e\x39\x9e\xbc\x5c\x65"
|
||||
@@ -79,8 +79,8 @@ dh_test_vector_t modp1024 = {
|
||||
"\x48\x02\xd7\x4a\x4f\x75\x3b\x29\x4a\x96\x50\x3f\x26\x05\xd3\xf1",
|
||||
};
|
||||
|
||||
dh_test_vector_t modp1536 = {
|
||||
.group = MODP_1536_BIT, .priv_len = 32, .pub_len = 192, .shared_len = 192,
|
||||
ke_test_vector_t modp1536 = {
|
||||
.method = MODP_1536_BIT, .priv_len = 32, .pub_len = 192, .shared_len = 192,
|
||||
.priv_a = "\x22\xd9\xdc\xc7\x30\x79\x93\x6a\x85\x8c\x07\xaa\x85\xed\x07\xb3"
|
||||
"\xd1\xe8\xb6\x70\xe7\xca\xaf\xa1\x92\x83\x76\x96\x07\x0f\xef\x29",
|
||||
.priv_b = "\x32\x34\x74\xde\x77\x88\xe0\x03\x6b\x30\x95\x49\x56\x0b\x00\x0d"
|
||||
@@ -123,8 +123,8 @@ dh_test_vector_t modp1536 = {
|
||||
"\x38\x1b\x1e\x5b\x7a\xa5\xd0\x9a\xb6\x6b\x74\x99\x7c\xba\xed\x20",
|
||||
};
|
||||
|
||||
dh_test_vector_t modp2048 = {
|
||||
.group = MODP_2048_BIT, .priv_len = 48, .pub_len = 256, .shared_len = 256,
|
||||
ke_test_vector_t modp2048 = {
|
||||
.method = MODP_2048_BIT, .priv_len = 48, .pub_len = 256, .shared_len = 256,
|
||||
.priv_a = "\xaf\x3b\xfd\x38\x62\xca\xa1\x17\x74\xce\x2b\x74\x84\x08\x07\xc1"
|
||||
"\xde\x5c\xd6\xa7\x61\x9b\xb3\xa0\xc7\xaf\x39\xee\xda\xa6\xeb\x89"
|
||||
"\xe2\xe9\xc1\x44\xb3\x62\x5b\x27\x31\x87\x9c\xb5\x8f\xa3\x76\x6d",
|
||||
@@ -181,8 +181,8 @@ dh_test_vector_t modp2048 = {
|
||||
"\xee\x9c\x12\x15\xdd\x23\x93\xde\x02\xf5\xc1\x76\x7f\x07\x0e\x28",
|
||||
};
|
||||
|
||||
dh_test_vector_t modp3072 = {
|
||||
.group = MODP_3072_BIT, .priv_len = 48, .pub_len = 384, .shared_len = 384,
|
||||
ke_test_vector_t modp3072 = {
|
||||
.method = MODP_3072_BIT, .priv_len = 48, .pub_len = 384, .shared_len = 384,
|
||||
.priv_a = "\x51\xf8\xaa\xb6\x63\x20\x1e\xb2\x86\xba\xd2\x99\x32\xb2\xe5\x8a"
|
||||
"\x92\x96\xbf\x2a\xa7\x78\x79\xcc\x8c\x64\x29\xd5\xa6\x68\xad\xf7"
|
||||
"\x60\x57\xad\xc3\x77\xcc\x75\xfd\x86\x47\x96\xb8\xfa\x7b\x42\x8c",
|
||||
@@ -263,8 +263,8 @@ dh_test_vector_t modp3072 = {
|
||||
"\xdc\x87\x87\x5b\xe5\x88\xc0\xcd\xee\xee\xfd\x19\xcc\x4f\x1d\x40",
|
||||
};
|
||||
|
||||
dh_test_vector_t modp4096 = {
|
||||
.group = MODP_4096_BIT, .priv_len = 64, .pub_len = 512, .shared_len = 512,
|
||||
ke_test_vector_t modp4096 = {
|
||||
.method = MODP_4096_BIT, .priv_len = 64, .pub_len = 512, .shared_len = 512,
|
||||
.priv_a = "\xab\x69\xbc\xe9\x61\xf9\x8a\xa9\xd5\x91\xe3\xfd\x9a\xbc\x46\xc8"
|
||||
"\x0d\xde\x39\x02\x84\xf1\x91\x42\xe8\x81\x5a\xb0\x80\x54\x72\x2b"
|
||||
"\xbd\x2e\x14\x1e\x27\x9e\xc7\xfd\x30\xaa\xfa\xca\x66\x40\x93\x73"
|
||||
@@ -371,8 +371,8 @@ dh_test_vector_t modp4096 = {
|
||||
"\x4f\xb9\x39\x02\x12\xb9\xb2\xa3\x5d\x4a\xfa\x17\xb3\xee\xc0\x8a",
|
||||
};
|
||||
|
||||
dh_test_vector_t modp6144 = {
|
||||
.group = MODP_6144_BIT, .priv_len = 64, .pub_len = 768, .shared_len = 768,
|
||||
ke_test_vector_t modp6144 = {
|
||||
.method = MODP_6144_BIT, .priv_len = 64, .pub_len = 768, .shared_len = 768,
|
||||
.priv_a = "\xab\x36\xf0\x65\x7c\x4f\xba\xdc\x2a\x3b\x07\xed\xd1\xc8\xaf\xcb"
|
||||
"\x42\xaf\xcd\x7f\xf9\x1c\x57\x01\x37\x25\x50\x0d\x89\x42\x9f\x34"
|
||||
"\x79\x8f\x99\xf5\xde\x53\xd1\x08\x8f\xd9\xf6\x60\xa1\xa5\x2b\xe4"
|
||||
@@ -527,8 +527,8 @@ dh_test_vector_t modp6144 = {
|
||||
"\xb8\xd0\xeb\x41\xb6\x7c\xfb\x9d\x9d\xfd\x62\x0e\xb7\x99\xca\x17",
|
||||
};
|
||||
|
||||
dh_test_vector_t modp8192 = {
|
||||
.group = MODP_8192_BIT, .priv_len = 64, .pub_len = 1024, .shared_len = 1024,
|
||||
ke_test_vector_t modp8192 = {
|
||||
.method = MODP_8192_BIT, .priv_len = 64, .pub_len = 1024, .shared_len = 1024,
|
||||
.priv_a = "\xa6\x48\x81\x47\x45\xfe\x1e\xd1\x98\x9b\x75\xba\x6d\xd5\x01\xe4"
|
||||
"\x4e\x77\x6d\xc9\x97\xa0\xae\x27\x37\x64\x61\xb0\xee\x79\x65\x94"
|
||||
"\xc2\xe6\xdb\x07\xe5\xf9\xd8\x7d\x94\x4d\x37\x01\x22\x38\xe5\x70"
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
* Test vectors from RFC5114
|
||||
*/
|
||||
|
||||
dh_test_vector_t modp1024_160 = {
|
||||
.group = MODP_1024_160, .priv_len = 20, .pub_len = 128, .shared_len = 128,
|
||||
ke_test_vector_t modp1024_160 = {
|
||||
.method = MODP_1024_160, .priv_len = 20, .pub_len = 128, .shared_len = 128,
|
||||
.priv_a = "\xB9\xA3\xB3\xAE\x8F\xEF\xC1\xA2\x93\x04\x96\x50\x70\x86\xF8\x45"
|
||||
"\x5D\x48\x94\x3E",
|
||||
.priv_b = "\x93\x92\xC9\xF9\xEB\x6A\x7A\x6A\x90\x22\xF7\xD8\x3E\x72\x23\xC6"
|
||||
@@ -52,8 +52,8 @@ dh_test_vector_t modp1024_160 = {
|
||||
"\x16\x7E\xCD\x91\x55\x41\x6F\x46\xF4\x08\xED\x31\xB6\x3C\x6E\x6D",
|
||||
};
|
||||
|
||||
dh_test_vector_t modp2048_224 = {
|
||||
.group = MODP_2048_224, .priv_len = 28, .pub_len = 256, .shared_len = 256,
|
||||
ke_test_vector_t modp2048_224 = {
|
||||
.method = MODP_2048_224, .priv_len = 28, .pub_len = 256, .shared_len = 256,
|
||||
.priv_a = "\x22\xe6\x26\x01\xdb\xff\xd0\x67\x08\xa6\x80\xf7\x47\xf3\x61\xf7"
|
||||
"\x6d\x8f\x4f\x72\x1a\x05\x48\xe4\x83\x29\x4b\x0c",
|
||||
.priv_b = "\x4f\xf3\xbc\x96\xc7\xfc\x6a\x6d\x71\xd3\xb3\x63\x80\x0a\x7c\xdf"
|
||||
@@ -108,8 +108,8 @@ dh_test_vector_t modp2048_224 = {
|
||||
"\x7f\xcb\x51\x0b\x69\x98\xff\xd3\xaa\x6d\xe7\x3c\xf9\xf6\x38\x69",
|
||||
};
|
||||
|
||||
dh_test_vector_t modp2048_256 = {
|
||||
.group = MODP_2048_256, .priv_len = 32, .pub_len = 256, .shared_len = 256,
|
||||
ke_test_vector_t modp2048_256 = {
|
||||
.method = MODP_2048_256, .priv_len = 32, .pub_len = 256, .shared_len = 256,
|
||||
.priv_a = "\x08\x81\x38\x2c\xdb\x87\x66\x0c\x6d\xc1\x3e\x61\x49\x38\xd5\xb9"
|
||||
"\xc8\xb2\xf2\x48\x58\x1c\xc5\xe3\x1b\x35\x45\x43\x97\xfc\xe5\x0e",
|
||||
.priv_b = "\x7d\x62\xa7\xe3\xef\x36\xde\x61\x7b\x13\xd1\xaf\xb8\x2c\x78\x0d"
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#define TEST_VECTOR_KDF(x) extern kdf_test_vector_t x;
|
||||
#define TEST_VECTOR_DRBG(x) extern drbg_test_vector_t x;
|
||||
#define TEST_VECTOR_RNG(x) extern rng_test_vector_t x;
|
||||
#define TEST_VECTOR_DH(x) extern dh_test_vector_t x;
|
||||
#define TEST_VECTOR_KE(x) extern ke_test_vector_t x;
|
||||
|
||||
#include "test_vectors.h"
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#undef TEST_VECTOR_KDF
|
||||
#undef TEST_VECTOR_DRBG
|
||||
#undef TEST_VECTOR_RNG
|
||||
#undef TEST_VECTOR_DH
|
||||
#undef TEST_VECTOR_KE
|
||||
|
||||
#define TEST_VECTOR_CRYPTER(x)
|
||||
#define TEST_VECTOR_AEAD(x)
|
||||
@@ -53,7 +53,7 @@
|
||||
#define TEST_VECTOR_KDF(x)
|
||||
#define TEST_VECTOR_DRBG(x)
|
||||
#define TEST_VECTOR_RNG(x)
|
||||
#define TEST_VECTOR_DH(x)
|
||||
#define TEST_VECTOR_KE(x)
|
||||
|
||||
/* create test vector arrays */
|
||||
#undef TEST_VECTOR_CRYPTER
|
||||
@@ -128,13 +128,13 @@ static rng_test_vector_t *rng[] = {
|
||||
#undef TEST_VECTOR_RNG
|
||||
#define TEST_VECTOR_RNG(x)
|
||||
|
||||
#undef TEST_VECTOR_DH
|
||||
#define TEST_VECTOR_DH(x) &x,
|
||||
static dh_test_vector_t *dh[] = {
|
||||
#undef TEST_VECTOR_KE
|
||||
#define TEST_VECTOR_KE(x) &x,
|
||||
static ke_test_vector_t *ke[] = {
|
||||
#include "test_vectors.h"
|
||||
};
|
||||
#undef TEST_VECTOR_DH
|
||||
#define TEST_VECTOR_DH(x)
|
||||
#undef TEST_VECTOR_KE
|
||||
#define TEST_VECTOR_KE(x)
|
||||
|
||||
typedef struct private_test_vectors_plugin_t private_test_vectors_plugin_t;
|
||||
|
||||
@@ -235,10 +235,10 @@ plugin_t *test_vectors_plugin_create()
|
||||
lib->crypto->add_test_vector(lib->crypto,
|
||||
RANDOM_NUMBER_GENERATOR, rng[i]);
|
||||
}
|
||||
for (i = 0; i < countof(dh); i++)
|
||||
for (i = 0; i < countof(ke); i++)
|
||||
{
|
||||
lib->crypto->add_test_vector(lib->crypto,
|
||||
DIFFIE_HELLMAN_GROUP, dh[i]);
|
||||
KEY_EXCHANGE_METHOD, ke[i]);
|
||||
}
|
||||
|
||||
return &this->public.plugin;
|
||||
|
||||
@@ -44,12 +44,12 @@ struct private_wolfssl_diffie_hellman_t {
|
||||
wolfssl_diffie_hellman_t public;
|
||||
|
||||
/**
|
||||
* Diffie Hellman group number.
|
||||
* Diffie-Hellman group number.
|
||||
*/
|
||||
diffie_hellman_group_t group;
|
||||
key_exchange_method_t group;
|
||||
|
||||
/**
|
||||
* Diffie Hellman object
|
||||
* Diffie-Hellman object
|
||||
*/
|
||||
DhKey dh;
|
||||
|
||||
@@ -74,14 +74,14 @@ struct private_wolfssl_diffie_hellman_t {
|
||||
chunk_t shared_secret;
|
||||
};
|
||||
|
||||
METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
METHOD(key_exchange_t, get_public_key, bool,
|
||||
private_wolfssl_diffie_hellman_t *this, chunk_t *value)
|
||||
{
|
||||
*value = chunk_copy_pad(chunk_alloc(this->len), this->pub, 0x00);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
METHOD(key_exchange_t, get_shared_secret, bool,
|
||||
private_wolfssl_diffie_hellman_t *this, chunk_t *secret)
|
||||
{
|
||||
if (!this->shared_secret.len)
|
||||
@@ -92,12 +92,12 @@ 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_wolfssl_diffie_hellman_t *this, chunk_t value)
|
||||
{
|
||||
word32 len;
|
||||
|
||||
if (!diffie_hellman_verify_value(this->group, value))
|
||||
if (!key_exchange_verify_pubkey(this->group, value))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, set_private_value, bool,
|
||||
METHOD(key_exchange_t, set_private_key, bool,
|
||||
private_wolfssl_diffie_hellman_t *this, chunk_t value)
|
||||
{
|
||||
bool success = FALSE;
|
||||
@@ -141,13 +141,13 @@ METHOD(diffie_hellman_t, set_private_value, bool,
|
||||
return success;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
|
||||
METHOD(key_exchange_t, get_method, key_exchange_method_t,
|
||||
private_wolfssl_diffie_hellman_t *this)
|
||||
{
|
||||
return this->group;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, destroy, void,
|
||||
METHOD(key_exchange_t, destroy, void,
|
||||
private_wolfssl_diffie_hellman_t *this)
|
||||
{
|
||||
wc_FreeDhKey(&this->dh);
|
||||
@@ -200,7 +200,7 @@ static int wolfssl_priv_key_size(int len)
|
||||
/**
|
||||
* Generic internal constructor
|
||||
*/
|
||||
static wolfssl_diffie_hellman_t *create_generic(diffie_hellman_group_t group,
|
||||
static wolfssl_diffie_hellman_t *create_generic(key_exchange_method_t group,
|
||||
chunk_t g, chunk_t p)
|
||||
{
|
||||
private_wolfssl_diffie_hellman_t *this;
|
||||
@@ -209,12 +209,12 @@ static wolfssl_diffie_hellman_t *create_generic(diffie_hellman_group_t group,
|
||||
|
||||
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,
|
||||
.set_private_value = _set_private_value,
|
||||
.get_dh_group = _get_dh_group,
|
||||
.set_public_key = _set_public_key,
|
||||
.get_public_key = _get_public_key,
|
||||
.set_private_key = _set_private_key,
|
||||
.get_method = _get_method,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
@@ -263,7 +263,7 @@ static wolfssl_diffie_hellman_t *create_generic(diffie_hellman_group_t group,
|
||||
* Described in header
|
||||
*/
|
||||
wolfssl_diffie_hellman_t *wolfssl_diffie_hellman_create(
|
||||
diffie_hellman_group_t group, ...)
|
||||
key_exchange_method_t group, ...)
|
||||
{
|
||||
diffie_hellman_params_t *params;
|
||||
chunk_t g, p;
|
||||
|
||||
@@ -38,20 +38,20 @@ typedef struct wolfssl_diffie_hellman_t wolfssl_diffie_hellman_t;
|
||||
struct wolfssl_diffie_hellman_t {
|
||||
|
||||
/**
|
||||
* Implements diffie_hellman_t interface.
|
||||
* Implements key_exchange_t interface.
|
||||
*/
|
||||
diffie_hellman_t dh;
|
||||
key_exchange_t ke;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new wolfssl_diffie_hellman_t object.
|
||||
*
|
||||
* @param group Diffie Hellman group number to use
|
||||
* @param group Diffie-Hellman group number to use
|
||||
* @param ... expects generator and prime as chunk_t if MODP_CUSTOM
|
||||
* @return wolfssl_diffie_hellman_t object, NULL if not supported
|
||||
*/
|
||||
wolfssl_diffie_hellman_t *wolfssl_diffie_hellman_create(
|
||||
diffie_hellman_group_t group, ...);
|
||||
key_exchange_method_t group, ...);
|
||||
|
||||
#endif /** WOLFSSL_PLUGIN_DIFFIE_HELLMAN_H_ @}*/
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ struct private_wolfssl_ec_diffie_hellman_t {
|
||||
/**
|
||||
* Diffie Hellman group number.
|
||||
*/
|
||||
diffie_hellman_group_t group;
|
||||
key_exchange_method_t group;
|
||||
|
||||
/**
|
||||
* EC curve id for creating keys
|
||||
@@ -169,12 +169,12 @@ static bool compute_shared_key(private_wolfssl_ec_diffie_hellman_t *this,
|
||||
return success;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, set_other_public_value, bool,
|
||||
METHOD(key_exchange_t, set_public_key, bool,
|
||||
private_wolfssl_ec_diffie_hellman_t *this, chunk_t value)
|
||||
{
|
||||
ecc_point *pub_key;
|
||||
|
||||
if (!diffie_hellman_verify_value(this->group, value))
|
||||
if (!key_exchange_verify_pubkey(this->group, value))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -204,13 +204,13 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
METHOD(key_exchange_t, get_public_key, bool,
|
||||
private_wolfssl_ec_diffie_hellman_t *this,chunk_t *value)
|
||||
{
|
||||
return ecp2chunk(this->keysize, &this->key.pubkey, value, FALSE);
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, set_private_value, bool,
|
||||
METHOD(key_exchange_t, set_private_key, bool,
|
||||
private_wolfssl_ec_diffie_hellman_t *this, chunk_t value)
|
||||
{
|
||||
bool success = FALSE;
|
||||
@@ -248,7 +248,7 @@ METHOD(diffie_hellman_t, set_private_value, bool,
|
||||
return success;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
METHOD(key_exchange_t, get_shared_secret, bool,
|
||||
private_wolfssl_ec_diffie_hellman_t *this, chunk_t *secret)
|
||||
{
|
||||
if (!this->shared_secret.len)
|
||||
@@ -259,13 +259,13 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
|
||||
METHOD(key_exchange_t, get_method, key_exchange_method_t,
|
||||
private_wolfssl_ec_diffie_hellman_t *this)
|
||||
{
|
||||
return this->group;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, destroy, void,
|
||||
METHOD(key_exchange_t, destroy, void,
|
||||
private_wolfssl_ec_diffie_hellman_t *this)
|
||||
{
|
||||
wc_ecc_free(&this->key);
|
||||
@@ -276,19 +276,19 @@ METHOD(diffie_hellman_t, destroy, void,
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
wolfssl_ec_diffie_hellman_t *wolfssl_ec_diffie_hellman_create(diffie_hellman_group_t group)
|
||||
wolfssl_ec_diffie_hellman_t *wolfssl_ec_diffie_hellman_create(key_exchange_method_t group)
|
||||
{
|
||||
private_wolfssl_ec_diffie_hellman_t *this;
|
||||
WC_RNG rng;
|
||||
|
||||
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,
|
||||
.set_private_value = _set_private_value,
|
||||
.get_dh_group = _get_dh_group,
|
||||
.set_public_key = _set_public_key,
|
||||
.get_public_key = _get_public_key,
|
||||
.set_private_key = _set_private_key,
|
||||
.get_method = _get_method,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -38,19 +38,19 @@ typedef struct wolfssl_ec_diffie_hellman_t wolfssl_ec_diffie_hellman_t;
|
||||
struct wolfssl_ec_diffie_hellman_t {
|
||||
|
||||
/**
|
||||
* Implements diffie_hellman_t interface.
|
||||
* Implements key_exchange_t interface.
|
||||
*/
|
||||
diffie_hellman_t dh;
|
||||
key_exchange_t ke;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new wolfssl_ec_diffie_hellman_t object.
|
||||
*
|
||||
* @param group EC Diffie Hellman group number to use
|
||||
* @param group EC Diffie-Hellman group number to use
|
||||
* @return wolfssl_ec_diffie_hellman_t object, NULL if not
|
||||
* supported
|
||||
*/
|
||||
wolfssl_ec_diffie_hellman_t *wolfssl_ec_diffie_hellman_create(
|
||||
diffie_hellman_group_t group);
|
||||
key_exchange_method_t group);
|
||||
|
||||
#endif /** WOLFSSL_PLUGIN_EC_DIFFIE_HELLMAN_H_ @}*/
|
||||
|
||||
@@ -227,77 +227,77 @@ METHOD(plugin_t, get_features, int,
|
||||
#endif
|
||||
#ifdef HAVE_ECC_DHE
|
||||
/* EC DH groups */
|
||||
PLUGIN_REGISTER(DH, wolfssl_ec_diffie_hellman_create),
|
||||
PLUGIN_REGISTER(KE, wolfssl_ec_diffie_hellman_create),
|
||||
#if (!defined(NO_ECC256) || defined(HAVE_ALL_CURVES)) && \
|
||||
(!defined(ECC_MIN_KEY_SZ) || ECC_MIN_KEY_SZ <= 256)
|
||||
PLUGIN_PROVIDE(DH, ECP_256_BIT),
|
||||
PLUGIN_PROVIDE(KE, ECP_256_BIT),
|
||||
#endif
|
||||
#if (defined(HAVE_ECC384) || defined(HAVE_ALL_CURVES)) && \
|
||||
(!defined(ECC_MIN_KEY_SZ) || ECC_MIN_KEY_SZ <= 384)
|
||||
PLUGIN_PROVIDE(DH, ECP_384_BIT),
|
||||
PLUGIN_PROVIDE(KE, ECP_384_BIT),
|
||||
#endif
|
||||
#if (defined(HAVE_ECC521) || defined(HAVE_ALL_CURVES)) && \
|
||||
(!defined(ECC_MIN_KEY_SZ) || ECC_MIN_KEY_SZ <= 521)
|
||||
PLUGIN_PROVIDE(DH, ECP_521_BIT),
|
||||
PLUGIN_PROVIDE(KE, ECP_521_BIT),
|
||||
#endif
|
||||
#if (defined(HAVE_ECC224) || defined(HAVE_ALL_CURVES)) && \
|
||||
(!defined(ECC_MIN_KEY_SZ) || ECC_MIN_KEY_SZ <= 224)
|
||||
PLUGIN_PROVIDE(DH, ECP_224_BIT),
|
||||
PLUGIN_PROVIDE(KE, ECP_224_BIT),
|
||||
#endif
|
||||
#if (defined(HAVE_ECC192) || defined(HAVE_ALL_CURVES)) && \
|
||||
(!defined(ECC_MIN_KEY_SZ) || ECC_MIN_KEY_SZ <= 192)
|
||||
PLUGIN_PROVIDE(DH, ECP_192_BIT),
|
||||
PLUGIN_PROVIDE(KE, ECP_192_BIT),
|
||||
#endif
|
||||
#ifdef HAVE_ECC_BRAINPOOL
|
||||
#if (!defined(NO_ECC256) || defined(HAVE_ALL_CURVES)) && \
|
||||
(!defined(ECC_MIN_KEY_SZ) || ECC_MIN_KEY_SZ <= 256)
|
||||
PLUGIN_PROVIDE(DH, ECP_256_BP),
|
||||
PLUGIN_PROVIDE(KE, ECP_256_BP),
|
||||
#endif
|
||||
#if (defined(HAVE_ECC384) || defined(HAVE_ALL_CURVES)) && \
|
||||
(!defined(ECC_MIN_KEY_SZ) || ECC_MIN_KEY_SZ <= 384)
|
||||
PLUGIN_PROVIDE(DH, ECP_384_BP),
|
||||
PLUGIN_PROVIDE(KE, ECP_384_BP),
|
||||
#endif
|
||||
#if (defined(HAVE_ECC512) || defined(HAVE_ALL_CURVES)) && \
|
||||
(!defined(ECC_MIN_KEY_SZ) || ECC_MIN_KEY_SZ <= 512)
|
||||
PLUGIN_PROVIDE(DH, ECP_512_BP),
|
||||
PLUGIN_PROVIDE(KE, ECP_512_BP),
|
||||
#endif
|
||||
#if (defined(HAVE_ECC224) || defined(HAVE_ALL_CURVES)) && \
|
||||
(!defined(ECC_MIN_KEY_SZ) || ECC_MIN_KEY_SZ <= 224)
|
||||
PLUGIN_PROVIDE(DH, ECP_224_BP),
|
||||
PLUGIN_PROVIDE(KE, ECP_224_BP),
|
||||
#endif
|
||||
#endif
|
||||
#endif /* HAVE_ECC_DHE */
|
||||
#ifndef NO_DH
|
||||
/* MODP DH groups */
|
||||
PLUGIN_REGISTER(DH, wolfssl_diffie_hellman_create),
|
||||
PLUGIN_REGISTER(KE, wolfssl_diffie_hellman_create),
|
||||
#if !defined(USE_FAST_MATH) || FP_MAX_BITS >= (3072 * 2)
|
||||
PLUGIN_PROVIDE(DH, MODP_3072_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_3072_BIT),
|
||||
#endif
|
||||
#if !defined(USE_FAST_MATH) || FP_MAX_BITS >= (4096 * 2)
|
||||
PLUGIN_PROVIDE(DH, MODP_4096_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_4096_BIT),
|
||||
#endif
|
||||
#if !defined(USE_FAST_MATH) || FP_MAX_BITS >= (6144 * 2)
|
||||
PLUGIN_PROVIDE(DH, MODP_6144_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_6144_BIT),
|
||||
#endif
|
||||
#if !defined(USE_FAST_MATH) || FP_MAX_BITS >= (8192 * 2)
|
||||
PLUGIN_PROVIDE(DH, MODP_8192_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_8192_BIT),
|
||||
#endif
|
||||
#if !defined(USE_FAST_MATH) || FP_MAX_BITS >= (2048 * 2)
|
||||
PLUGIN_PROVIDE(DH, MODP_2048_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_2048_224),
|
||||
PLUGIN_PROVIDE(DH, MODP_2048_256),
|
||||
PLUGIN_PROVIDE(KE, MODP_2048_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_2048_224),
|
||||
PLUGIN_PROVIDE(KE, MODP_2048_256),
|
||||
#endif
|
||||
#if !defined(USE_FAST_MATH) || FP_MAX_BITS >= (1536 * 2)
|
||||
PLUGIN_PROVIDE(DH, MODP_1536_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_1536_BIT),
|
||||
#endif
|
||||
#if !defined(USE_FAST_MATH) || FP_MAX_BITS >= (1024 * 2)
|
||||
PLUGIN_PROVIDE(DH, MODP_1024_BIT),
|
||||
PLUGIN_PROVIDE(DH, MODP_1024_160),
|
||||
PLUGIN_PROVIDE(KE, MODP_1024_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_1024_160),
|
||||
#endif
|
||||
#if !defined(USE_FAST_MATH) || FP_MAX_BITS >= (768 * 2)
|
||||
PLUGIN_PROVIDE(DH, MODP_768_BIT),
|
||||
PLUGIN_PROVIDE(KE, MODP_768_BIT),
|
||||
#endif
|
||||
PLUGIN_PROVIDE(DH, MODP_CUSTOM),
|
||||
PLUGIN_PROVIDE(KE, MODP_CUSTOM),
|
||||
#endif /* NO_DH */
|
||||
#ifndef NO_RSA
|
||||
/* RSA private/public key loading */
|
||||
@@ -439,12 +439,12 @@ METHOD(plugin_t, get_features, int,
|
||||
#endif /* HAVE_ECC_VERIFY */
|
||||
#endif /* HAVE_ECC */
|
||||
#if defined (HAVE_CURVE25519) || defined(HAVE_CURVE448)
|
||||
PLUGIN_REGISTER(DH, wolfssl_x_diffie_hellman_create),
|
||||
PLUGIN_REGISTER(KE, wolfssl_x_diffie_hellman_create),
|
||||
#ifdef HAVE_CURVE25519
|
||||
PLUGIN_PROVIDE(DH, CURVE_25519),
|
||||
PLUGIN_PROVIDE(KE, CURVE_25519),
|
||||
#endif
|
||||
#ifdef HAVE_CURVE448
|
||||
PLUGIN_PROVIDE(DH, CURVE_448),
|
||||
PLUGIN_PROVIDE(KE, CURVE_448),
|
||||
#endif
|
||||
#endif /* HAVE_CURVE25519 || HAVE_CURVE448 */
|
||||
#if defined(HAVE_ED25519) || defined(HAVE_ED448)
|
||||
|
||||
@@ -45,15 +45,16 @@ typedef struct private_diffie_hellman_t private_diffie_hellman_t;
|
||||
* Private data
|
||||
*/
|
||||
struct private_diffie_hellman_t {
|
||||
|
||||
/**
|
||||
* Public interface.
|
||||
*/
|
||||
diffie_hellman_t public;
|
||||
key_exchange_t public;
|
||||
|
||||
/**
|
||||
* Diffie Hellman group number.
|
||||
*/
|
||||
diffie_hellman_group_t group;
|
||||
key_exchange_method_t group;
|
||||
|
||||
/**
|
||||
* Private (public) key
|
||||
@@ -75,14 +76,14 @@ struct private_diffie_hellman_t {
|
||||
|
||||
#ifdef HAVE_CURVE25519
|
||||
|
||||
METHOD(diffie_hellman_t, set_other_public_value_25519, bool,
|
||||
METHOD(key_exchange_t, set_public_key_25519, bool,
|
||||
private_diffie_hellman_t *this, chunk_t value)
|
||||
{
|
||||
word32 len = CURVE25519_KEYSIZE;
|
||||
curve25519_key pub;
|
||||
int ret;
|
||||
|
||||
if (!diffie_hellman_verify_value(this->group, value))
|
||||
if (!key_exchange_verify_pubkey(this->group, value))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -91,7 +92,7 @@ METHOD(diffie_hellman_t, set_other_public_value_25519, bool,
|
||||
if (ret != 0)
|
||||
{
|
||||
DBG1(DBG_LIB, "%N public key initialization failed",
|
||||
diffie_hellman_group_names, this->group);
|
||||
key_exchange_method_names, this->group);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -100,7 +101,7 @@ METHOD(diffie_hellman_t, set_other_public_value_25519, bool,
|
||||
if (ret != 0)
|
||||
{
|
||||
DBG1(DBG_LIB, "%N public value is malformed",
|
||||
diffie_hellman_group_names, this->group);
|
||||
key_exchange_method_names, this->group);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -110,7 +111,7 @@ METHOD(diffie_hellman_t, set_other_public_value_25519, bool,
|
||||
this->shared_secret.ptr, &len, EC25519_LITTLE_ENDIAN) != 0)
|
||||
{
|
||||
DBG1(DBG_LIB, "%N shared secret computation failed",
|
||||
diffie_hellman_group_names, this->group);
|
||||
key_exchange_method_names, this->group);
|
||||
chunk_clear(&this->shared_secret);
|
||||
wc_curve25519_free(&pub);
|
||||
return FALSE;
|
||||
@@ -119,7 +120,7 @@ METHOD(diffie_hellman_t, set_other_public_value_25519, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_my_public_value_25519, bool,
|
||||
METHOD(key_exchange_t, get_public_key_25519, bool,
|
||||
private_diffie_hellman_t *this, chunk_t *value)
|
||||
{
|
||||
word32 len = CURVE25519_KEYSIZE;
|
||||
@@ -134,7 +135,7 @@ METHOD(diffie_hellman_t, get_my_public_value_25519, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, set_private_value_25519, bool,
|
||||
METHOD(key_exchange_t, set_private_key_25519, bool,
|
||||
private_diffie_hellman_t *this, chunk_t value)
|
||||
{
|
||||
curve25519_key pub;
|
||||
@@ -167,14 +168,14 @@ METHOD(diffie_hellman_t, set_private_value_25519, bool,
|
||||
|
||||
#ifdef HAVE_CURVE448
|
||||
|
||||
METHOD(diffie_hellman_t, set_other_public_value_448, bool,
|
||||
METHOD(key_exchange_t, set_public_key_448, bool,
|
||||
private_diffie_hellman_t *this, chunk_t value)
|
||||
{
|
||||
word32 len = CURVE448_KEY_SIZE;
|
||||
curve448_key pub;
|
||||
int ret;
|
||||
|
||||
if (!diffie_hellman_verify_value(this->group, value))
|
||||
if (!key_exchange_verify_pubkey(this->group, value))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -183,7 +184,7 @@ METHOD(diffie_hellman_t, set_other_public_value_448, bool,
|
||||
if (ret != 0)
|
||||
{
|
||||
DBG1(DBG_LIB, "%N public key initialization failed",
|
||||
diffie_hellman_group_names, this->group);
|
||||
key_exchange_method_names, this->group);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -192,7 +193,7 @@ METHOD(diffie_hellman_t, set_other_public_value_448, bool,
|
||||
if (ret != 0)
|
||||
{
|
||||
DBG1(DBG_LIB, "%N public value is malformed",
|
||||
diffie_hellman_group_names, this->group);
|
||||
key_exchange_method_names, this->group);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -202,7 +203,7 @@ METHOD(diffie_hellman_t, set_other_public_value_448, bool,
|
||||
this->shared_secret.ptr, &len, EC448_LITTLE_ENDIAN) != 0)
|
||||
{
|
||||
DBG1(DBG_LIB, "%N shared secret computation failed",
|
||||
diffie_hellman_group_names, this->group);
|
||||
key_exchange_method_names, this->group);
|
||||
chunk_clear(&this->shared_secret);
|
||||
wc_curve448_free(&pub);
|
||||
return FALSE;
|
||||
@@ -211,7 +212,7 @@ METHOD(diffie_hellman_t, set_other_public_value_448, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_my_public_value_448, bool,
|
||||
METHOD(key_exchange_t, get_public_key_448, bool,
|
||||
private_diffie_hellman_t *this, chunk_t *value)
|
||||
{
|
||||
word32 len = CURVE448_KEY_SIZE;
|
||||
@@ -226,7 +227,7 @@ METHOD(diffie_hellman_t, get_my_public_value_448, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, set_private_value_448, bool,
|
||||
METHOD(key_exchange_t, set_private_key_448, bool,
|
||||
private_diffie_hellman_t *this, chunk_t value)
|
||||
{
|
||||
curve448_key pub;
|
||||
@@ -257,7 +258,7 @@ METHOD(diffie_hellman_t, set_private_value_448, bool,
|
||||
|
||||
#endif /* HAVE_CURVE448 */
|
||||
|
||||
METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
METHOD(key_exchange_t, get_shared_secret, bool,
|
||||
private_diffie_hellman_t *this, chunk_t *secret)
|
||||
{
|
||||
if (!this->shared_secret.len)
|
||||
@@ -268,13 +269,13 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
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;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, destroy, void,
|
||||
METHOD(key_exchange_t, destroy, void,
|
||||
private_diffie_hellman_t *this)
|
||||
{
|
||||
if (this->group == CURVE_25519)
|
||||
@@ -296,7 +297,7 @@ METHOD(diffie_hellman_t, destroy, void,
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
diffie_hellman_t *wolfssl_x_diffie_hellman_create(diffie_hellman_group_t group)
|
||||
key_exchange_t *wolfssl_x_diffie_hellman_create(key_exchange_method_t group)
|
||||
{
|
||||
private_diffie_hellman_t *this;
|
||||
WC_RNG rng;
|
||||
@@ -305,7 +306,7 @@ diffie_hellman_t *wolfssl_x_diffie_hellman_create(diffie_hellman_group_t group)
|
||||
INIT(this,
|
||||
.public = {
|
||||
.get_shared_secret = _get_shared_secret,
|
||||
.get_dh_group = _get_dh_group,
|
||||
.get_method = _get_method,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
.group = group,
|
||||
@@ -321,9 +322,9 @@ diffie_hellman_t *wolfssl_x_diffie_hellman_create(diffie_hellman_group_t group)
|
||||
if (group == CURVE_25519)
|
||||
{
|
||||
#ifdef HAVE_CURVE25519
|
||||
this->public.set_other_public_value = _set_other_public_value_25519;
|
||||
this->public.get_my_public_value = _get_my_public_value_25519;
|
||||
this->public.set_private_value = _set_private_value_25519;
|
||||
this->public.set_public_key = _set_public_key_25519;
|
||||
this->public.get_public_key = _get_public_key_25519;
|
||||
this->public.set_private_key = _set_private_key_25519;
|
||||
|
||||
if (wc_curve25519_init(&this->key.key25519) != 0)
|
||||
{
|
||||
@@ -338,9 +339,9 @@ diffie_hellman_t *wolfssl_x_diffie_hellman_create(diffie_hellman_group_t group)
|
||||
else if (group == CURVE_448)
|
||||
{
|
||||
#ifdef HAVE_CURVE448
|
||||
this->public.set_other_public_value = _set_other_public_value_448;
|
||||
this->public.get_my_public_value = _get_my_public_value_448;
|
||||
this->public.set_private_value = _set_private_value_448;
|
||||
this->public.set_public_key = _set_public_key_448;
|
||||
this->public.get_public_key = _get_public_key_448;
|
||||
this->public.set_private_key = _set_private_key_448;
|
||||
|
||||
if (wc_curve448_init(&this->key.key448) != 0)
|
||||
{
|
||||
|
||||
@@ -33,11 +33,11 @@
|
||||
#include <library.h>
|
||||
|
||||
/**
|
||||
* Creates a new diffie_hellman_t object.
|
||||
* Creates a new key_exchange_t object.
|
||||
*
|
||||
* @param group Diffie Hellman group number to use
|
||||
* @param group Diffie-Hellman group number to use
|
||||
* @return object, NULL if not supported
|
||||
*/
|
||||
diffie_hellman_t *wolfssl_x_diffie_hellman_create(diffie_hellman_group_t group);
|
||||
key_exchange_t *wolfssl_x_diffie_hellman_create(key_exchange_method_t group);
|
||||
|
||||
#endif /** WOLFSSL_PLUGIN_X_DIFFIE_HELLMAN_H_ @}*/
|
||||
|
||||
Reference in New Issue
Block a user