Rename diffie_hellman_t to key_exchange_t and change the interface etc.

This makes it more generic so we can use it for QSKE methods.
This commit is contained in:
Tobias Brunner
2022-06-29 10:28:50 +02:00
parent ec95fd9b93
commit 3af7c6db87
130 changed files with 1379 additions and 1384 deletions
+43 -47
View File
@@ -56,7 +56,7 @@ struct entry_t {
drbg_constructor_t create_drbg;
rng_constructor_t create_rng;
nonce_gen_constructor_t create_nonce_gen;
dh_constructor_t create_dh;
ke_constructor_t create_ke;
void *create;
};
};
@@ -124,9 +124,9 @@ struct private_crypto_factory_t {
linked_list_t *nonce_gens;
/**
* registered diffie hellman, as entry_t
* registered key exchange methods, as entry_t
*/
linked_list_t *dhs;
linked_list_t *kes;
/**
* test manager to test crypto algorithms
@@ -484,37 +484,33 @@ METHOD(crypto_factory_t, create_nonce_gen, nonce_gen_t*,
return nonce_gen;
}
METHOD(crypto_factory_t, create_dh, diffie_hellman_t*,
private_crypto_factory_t *this, diffie_hellman_group_t group, ...)
METHOD(crypto_factory_t, create_ke, key_exchange_t*,
private_crypto_factory_t *this, key_exchange_method_t method, ...)
{
enumerator_t *enumerator;
entry_t *entry;
va_list args;
chunk_t g = chunk_empty, p = chunk_empty;
diffie_hellman_t *diffie_hellman = NULL;
key_exchange_t *ke = NULL;
if (group == MODP_CUSTOM)
if (method == MODP_CUSTOM)
{
va_start(args, group);
g = va_arg(args, chunk_t);
p = va_arg(args, chunk_t);
va_end(args);
VA_ARGS_GET(method, g, p);
}
this->lock->read_lock(this->lock);
enumerator = this->dhs->create_enumerator(this->dhs);
enumerator = this->kes->create_enumerator(this->kes);
while (enumerator->enumerate(enumerator, &entry))
{
if (entry->algo == group)
if (entry->algo == method)
{
if (this->test_on_create && group != MODP_CUSTOM &&
!this->tester->test_dh(this->tester, group,
entry->create_dh, NULL, entry->plugin_name))
if (this->test_on_create && method != MODP_CUSTOM &&
!this->tester->test_ke(this->tester, method,
entry->create_ke, NULL, entry->plugin_name))
{
continue;
}
diffie_hellman = entry->create_dh(group, g, p);
if (diffie_hellman)
ke = entry->create_ke(method, g, p);
if (ke)
{
break;
}
@@ -522,7 +518,7 @@ METHOD(crypto_factory_t, create_dh, diffie_hellman_t*,
}
enumerator->destroy(enumerator);
this->lock->unlock(this->lock);
return diffie_hellman;
return ke;
}
/**
@@ -935,36 +931,36 @@ METHOD(crypto_factory_t, remove_nonce_gen, void,
this->lock->unlock(this->lock);
}
METHOD(crypto_factory_t, add_dh, bool,
private_crypto_factory_t *this, diffie_hellman_group_t group,
const char *plugin_name, dh_constructor_t create)
METHOD(crypto_factory_t, add_ke, bool,
private_crypto_factory_t *this, key_exchange_method_t group,
const char *plugin_name, ke_constructor_t create)
{
u_int speed = 0;
if (!this->test_on_add ||
this->tester->test_dh(this->tester, group, create,
this->tester->test_ke(this->tester, group, create,
this->bench ? &speed : NULL, plugin_name))
{
add_entry(this, this->dhs, group, plugin_name, 0, create);
add_entry(this, this->kes, group, plugin_name, 0, create);
return TRUE;
}
this->test_failures++;
return FALSE;
}
METHOD(crypto_factory_t, remove_dh, void,
private_crypto_factory_t *this, dh_constructor_t create)
METHOD(crypto_factory_t, remove_ke, void,
private_crypto_factory_t *this, ke_constructor_t create)
{
entry_t *entry;
enumerator_t *enumerator;
this->lock->write_lock(this->lock);
enumerator = this->dhs->create_enumerator(this->dhs);
enumerator = this->kes->create_enumerator(this->kes);
while (enumerator->enumerate(enumerator, &entry))
{
if (entry->create_dh == create)
if (entry->create_ke == create)
{
this->dhs->remove_at(this->dhs, enumerator);
this->kes->remove_at(this->kes, enumerator);
free(entry);
}
}
@@ -1190,11 +1186,11 @@ METHOD(crypto_factory_t, create_drbg_enumerator, enumerator_t*,
return create_enumerator(this, this->drbgs, drbg_filter);
}
CALLBACK(dh_filter, bool,
CALLBACK(ke_filter, bool,
void *n, enumerator_t *orig, va_list args)
{
entry_t *entry;
diffie_hellman_group_t *algo;
key_exchange_method_t *algo;
const char **plugin_name;
VA_ARGS_VGET(args, algo, plugin_name);
@@ -1208,10 +1204,10 @@ CALLBACK(dh_filter, bool,
return FALSE;
}
METHOD(crypto_factory_t, create_dh_enumerator, enumerator_t*,
METHOD(crypto_factory_t, create_ke_enumerator, enumerator_t*,
private_crypto_factory_t *this)
{
return create_enumerator(this, this->dhs, dh_filter);
return create_enumerator(this, this->kes, ke_filter);
}
CALLBACK(rng_filter, bool,
@@ -1283,8 +1279,8 @@ METHOD(crypto_factory_t, add_test_vector, void,
return this->tester->add_drbg_vector(this->tester, vector);
case RANDOM_NUMBER_GENERATOR:
return this->tester->add_rng_vector(this->tester, vector);
case DIFFIE_HELLMAN_GROUP:
return this->tester->add_dh_vector(this->tester, vector);
case KEY_EXCHANGE_METHOD:
return this->tester->add_ke_vector(this->tester, vector);
default:
DBG1(DBG_LIB, "%N test vectors not supported, ignored",
transform_type_names, type);
@@ -1354,9 +1350,9 @@ METHOD(enumerator_t, verify_enumerate, bool,
*valid = this->tester->test_rng(this->tester, entry->algo,
entry->create_rng, NULL, entry->plugin_name);
break;
case DIFFIE_HELLMAN_GROUP:
*valid = this->tester->test_dh(this->tester, entry->algo,
entry->create_dh, NULL, entry->plugin_name);
case KEY_EXCHANGE_METHOD:
*valid = this->tester->test_ke(this->tester, entry->algo,
entry->create_ke, NULL, entry->plugin_name);
break;
default:
return FALSE;
@@ -1410,8 +1406,8 @@ METHOD(crypto_factory_t, create_verify_enumerator, enumerator_t*,
case RANDOM_NUMBER_GENERATOR:
inner = this->rngs->create_enumerator(this->rngs);
break;
case DIFFIE_HELLMAN_GROUP:
inner = this->dhs->create_enumerator(this->dhs);
case KEY_EXCHANGE_METHOD:
inner = this->kes->create_enumerator(this->kes);
break;
default:
this->lock->unlock(this->lock);
@@ -1444,7 +1440,7 @@ METHOD(crypto_factory_t, destroy, void,
this->drbgs->destroy(this->drbgs);
this->rngs->destroy(this->rngs);
this->nonce_gens->destroy(this->nonce_gens);
this->dhs->destroy(this->dhs);
this->kes->destroy(this->kes);
this->tester->destroy(this->tester);
this->lock->destroy(this->lock);
free(this);
@@ -1469,7 +1465,7 @@ crypto_factory_t *crypto_factory_create()
.create_drbg = _create_drbg,
.create_rng = _create_rng,
.create_nonce_gen = _create_nonce_gen,
.create_dh = _create_dh,
.create_ke = _create_ke,
.add_crypter = _add_crypter,
.remove_crypter = _remove_crypter,
.add_aead = _add_aead,
@@ -1490,8 +1486,8 @@ crypto_factory_t *crypto_factory_create()
.remove_rng = _remove_rng,
.add_nonce_gen = _add_nonce_gen,
.remove_nonce_gen = _remove_nonce_gen,
.add_dh = _add_dh,
.remove_dh = _remove_dh,
.add_ke = _add_ke,
.remove_ke = _remove_ke,
.create_crypter_enumerator = _create_crypter_enumerator,
.create_aead_enumerator = _create_aead_enumerator,
.create_signer_enumerator = _create_signer_enumerator,
@@ -1500,7 +1496,7 @@ crypto_factory_t *crypto_factory_create()
.create_xof_enumerator = _create_xof_enumerator,
.create_kdf_enumerator = _create_kdf_enumerator,
.create_drbg_enumerator = _create_drbg_enumerator,
.create_dh_enumerator = _create_dh_enumerator,
.create_ke_enumerator = _create_ke_enumerator,
.create_rng_enumerator = _create_rng_enumerator,
.create_nonce_gen_enumerator = _create_nonce_gen_enumerator,
.add_test_vector = _add_test_vector,
@@ -1517,7 +1513,7 @@ crypto_factory_t *crypto_factory_create()
.drbgs = linked_list_create(),
.rngs = linked_list_create(),
.nonce_gens = linked_list_create(),
.dhs = linked_list_create(),
.kes = linked_list_create(),
.lock = rwlock_create(RWLOCK_TYPE_DEFAULT),
.tester = crypto_tester_create(),
.test_on_add = lib->settings->get_bool(lib->settings,
+19 -19
View File
@@ -37,7 +37,7 @@ typedef struct crypto_factory_t crypto_factory_t;
#include <crypto/kdfs/kdf.h>
#include <crypto/drbgs/drbg.h>
#include <crypto/nonce_gen.h>
#include <crypto/diffie_hellman.h>
#include <crypto/key_exchange.h>
#include <crypto/transform.h>
#define CRYPTO_MAX_ALG_LINE 120 /* characters */
@@ -97,12 +97,12 @@ typedef rng_t* (*rng_constructor_t)(rng_quality_t quality);
typedef nonce_gen_t* (*nonce_gen_constructor_t)();
/**
* Constructor function for diffie hellman
* Constructor function for key exchange methods
*
* The DH constructor accepts additional arguments for:
* The key exchange method constructor accepts additional arguments for:
* - MODP_CUSTOM: chunk_t generator, chunk_t prime
*/
typedef diffie_hellman_t* (*dh_constructor_t)(diffie_hellman_group_t group, ...);
typedef key_exchange_t* (*ke_constructor_t)(key_exchange_method_t method, ...);
/**
* Handles crypto modules and creates instances.
@@ -207,15 +207,15 @@ struct crypto_factory_t {
nonce_gen_t* (*create_nonce_gen)(crypto_factory_t *this);
/**
* Create a diffie hellman instance.
* Create a key exchange method instance.
*
* Additional arguments are passed to the DH constructor.
* Additional arguments are passed to the key exchange method constructor.
*
* @param group diffie hellman group
* @return diffie_hellman_t instance, NULL if not supported
* @param method key exchange method
* @return key_exchange_t instance, NULL if not supported
*/
diffie_hellman_t* (*create_dh)(crypto_factory_t *this,
diffie_hellman_group_t group, ...);
key_exchange_t* (*create_ke)(crypto_factory_t *this,
key_exchange_method_t method, ...);
/**
* Register a crypter constructor.
@@ -402,22 +402,22 @@ struct crypto_factory_t {
nonce_gen_constructor_t create);
/**
* Register a diffie hellman constructor.
* Register a key exchange method constructor.
*
* @param group dh group to constructor
* @param method key exchange method to constructor
* @param plugin_name plugin that registered this algorithm
* @param create constructor function for that algorithm
* @return TRUE if registered, FALSE if test vector failed
*/
bool (*add_dh)(crypto_factory_t *this, diffie_hellman_group_t group,
const char *plugin_name, dh_constructor_t create);
bool (*add_ke)(crypto_factory_t *this, key_exchange_method_t method,
const char *plugin_name, ke_constructor_t create);
/**
* Unregister a diffie hellman constructor.
* Unregister a key exchange method constructor.
*
* @param create constructor function to unregister
*/
void (*remove_dh)(crypto_factory_t *this, dh_constructor_t create);
void (*remove_ke)(crypto_factory_t *this, ke_constructor_t create);
/**
* Create an enumerator over all registered crypter algorithms.
@@ -476,11 +476,11 @@ struct crypto_factory_t {
enumerator_t* (*create_drbg_enumerator)(crypto_factory_t *this);
/**
* Create an enumerator over all registered diffie hellman groups.
* Create an enumerator over all registered key exchange method.
*
* @return enumerator over diffie_hellman_group_t, plugin
* @return enumerator over key_exchange_method_t, plugin
*/
enumerator_t* (*create_dh_enumerator)(crypto_factory_t *this);
enumerator_t* (*create_ke_enumerator)(crypto_factory_t *this);
/**
* Create an enumerator over all registered random generators.
+41 -41
View File
@@ -85,9 +85,9 @@ struct private_crypto_tester_t {
linked_list_t *rng;
/**
* List of Diffie-Hellman test vectors
* List of key exchange method test vectors
*/
linked_list_t *dh;
linked_list_t *ke;
/**
* Is a test vector required to pass a test?
@@ -1649,13 +1649,13 @@ failure:
}
/**
* Benchmark a DH backend
* Benchmark a key exchange backend
*/
static u_int bench_dh(private_crypto_tester_t *this,
diffie_hellman_group_t group, dh_constructor_t create)
static u_int bench_ke(private_crypto_tester_t *this,
key_exchange_method_t method, ke_constructor_t create)
{
chunk_t pub = chunk_empty, shared = chunk_empty;
diffie_hellman_t *dh;
key_exchange_t *ke;
struct timespec start;
u_int runs;
@@ -1663,46 +1663,46 @@ static u_int bench_dh(private_crypto_tester_t *this,
start_timing(&start);
while (end_timing(&start) < this->bench_time)
{
dh = create(group);
if (!dh)
ke = create(method);
if (!ke)
{
return 0;
}
if (dh->get_my_public_value(dh, &pub) &&
dh->set_other_public_value(dh, pub) &&
dh->get_shared_secret(dh, &shared))
if (ke->get_public_key(ke, &pub) &&
ke->set_public_key(ke, pub) &&
ke->get_shared_secret(ke, &shared))
{
runs++;
}
chunk_free(&pub);
chunk_free(&shared);
dh->destroy(dh);
ke->destroy(ke);
}
return runs;
}
METHOD(crypto_tester_t, test_dh, bool,
private_crypto_tester_t *this, diffie_hellman_group_t group,
dh_constructor_t create, u_int *speed, const char *plugin_name)
METHOD(crypto_tester_t, test_ke, bool,
private_crypto_tester_t *this, key_exchange_method_t method,
ke_constructor_t create, u_int *speed, const char *plugin_name)
{
enumerator_t *enumerator;
dh_test_vector_t *v;
ke_test_vector_t *v;
bool failed = FALSE;
u_int tested = 0;
enumerator = this->dh->create_enumerator(this->dh);
enumerator = this->ke->create_enumerator(this->ke);
while (enumerator->enumerate(enumerator, &v))
{
diffie_hellman_t *a, *b;
key_exchange_t *a, *b;
chunk_t apub, bpub, asec, bsec;
if (v->group != group)
if (v->method != method)
{
continue;
}
a = create(group);
b = create(group);
a = create(method);
b = create(method);
if (!a || !b)
{
DESTROY_IF(a);
@@ -1710,11 +1710,11 @@ METHOD(crypto_tester_t, test_dh, bool,
failed = TRUE;
tested++;
DBG1(DBG_LIB, "disabled %N[%s]: creating instance failed",
diffie_hellman_group_names, group, plugin_name);
key_exchange_method_names, method, plugin_name);
break;
}
if (!a->set_private_value || !b->set_private_value)
if (!a->set_private_key || !b->set_private_key)
{ /* does not support testing */
a->destroy(a);
b->destroy(b);
@@ -1725,23 +1725,23 @@ METHOD(crypto_tester_t, test_dh, bool,
apub = bpub = asec = bsec = chunk_empty;
if (!a->set_private_value(a, chunk_create(v->priv_a, v->priv_len)) ||
!b->set_private_value(b, chunk_create(v->priv_b, v->priv_len)))
if (!a->set_private_key(a, chunk_create(v->priv_a, v->priv_len)) ||
!b->set_private_key(b, chunk_create(v->priv_b, v->priv_len)))
{
goto failure;
}
if (!a->get_my_public_value(a, &apub) ||
if (!a->get_public_key(a, &apub) ||
!chunk_equals(apub, chunk_create(v->pub_a, v->pub_len)))
{
goto failure;
}
if (!b->get_my_public_value(b, &bpub) ||
if (!b->get_public_key(b, &bpub) ||
!chunk_equals(bpub, chunk_create(v->pub_b, v->pub_len)))
{
goto failure;
}
if (!a->set_other_public_value(a, bpub) ||
!b->set_other_public_value(b, apub))
if (!a->set_public_key(a, bpub) ||
!b->set_public_key(b, apub))
{
goto failure;
}
@@ -1767,7 +1767,7 @@ failure:
if (failed)
{
DBG1(DBG_LIB, "disabled %N[%s]: %s test vector failed",
diffie_hellman_group_names, group, plugin_name, get_name(v));
key_exchange_method_names, method, plugin_name, get_name(v));
break;
}
}
@@ -1776,21 +1776,21 @@ failure:
{
DBG1(DBG_LIB, "%s %N[%s]: no test vectors found / untestable",
this->required ? "disabled" : "enabled ",
diffie_hellman_group_names, group, plugin_name);
key_exchange_method_names, method, plugin_name);
return !this->required;
}
if (!failed)
{
if (speed)
{
*speed = bench_dh(this, group, create);
*speed = bench_ke(this, method, create);
DBG1(DBG_LIB, "enabled %N[%s]: passed %u test vectors, %d points",
diffie_hellman_group_names, group, plugin_name, tested, *speed);
key_exchange_method_names, method, plugin_name, tested, *speed);
}
else
{
DBG1(DBG_LIB, "enabled %N[%s]: passed %u test vectors",
diffie_hellman_group_names, group, plugin_name, tested);
key_exchange_method_names, method, plugin_name, tested);
}
}
return !failed;
@@ -1850,10 +1850,10 @@ METHOD(crypto_tester_t, add_rng_vector, void,
this->rng->insert_last(this->rng, vector);
}
METHOD(crypto_tester_t, add_dh_vector, void,
private_crypto_tester_t *this, dh_test_vector_t *vector)
METHOD(crypto_tester_t, add_ke_vector, void,
private_crypto_tester_t *this, ke_test_vector_t *vector)
{
this->dh->insert_last(this->dh, vector);
this->ke->insert_last(this->ke, vector);
}
METHOD(crypto_tester_t, destroy, void,
@@ -1868,7 +1868,7 @@ METHOD(crypto_tester_t, destroy, void,
this->kdf->destroy(this->kdf);
this->drbg->destroy(this->drbg);
this->rng->destroy(this->rng);
this->dh->destroy(this->dh);
this->ke->destroy(this->ke);
free(this);
}
@@ -1890,7 +1890,7 @@ crypto_tester_t *crypto_tester_create()
.test_kdf = _test_kdf,
.test_drbg = _test_drbg,
.test_rng = _test_rng,
.test_dh = _test_dh,
.test_ke = _test_ke,
.add_crypter_vector = _add_crypter_vector,
.add_aead_vector = _add_aead_vector,
.add_signer_vector = _add_signer_vector,
@@ -1900,7 +1900,7 @@ crypto_tester_t *crypto_tester_create()
.add_kdf_vector = _add_kdf_vector,
.add_drbg_vector = _add_drbg_vector,
.add_rng_vector = _add_rng_vector,
.add_dh_vector = _add_dh_vector,
.add_ke_vector = _add_ke_vector,
.destroy = _destroy,
},
.crypter = linked_list_create(),
@@ -1912,7 +1912,7 @@ crypto_tester_t *crypto_tester_create()
.kdf = linked_list_create(),
.drbg = linked_list_create(),
.rng = linked_list_create(),
.dh = linked_list_create(),
.ke = linked_list_create(),
.required = lib->settings->get_bool(lib->settings,
"%s.crypto_test.required", FALSE, lib->ns),
+17 -17
View File
@@ -37,7 +37,7 @@ typedef struct kdf_test_vector_t kdf_test_vector_t;
typedef struct kdf_test_args_t kdf_test_args_t;
typedef struct drbg_test_vector_t drbg_test_vector_t;
typedef struct rng_test_vector_t rng_test_vector_t;
typedef struct dh_test_vector_t dh_test_vector_t;
typedef struct ke_test_vector_t ke_test_vector_t;
struct crypter_test_vector_t {
/** encryption algorithm this vector tests */
@@ -182,20 +182,20 @@ struct rng_test_vector_t {
void *user;
};
struct dh_test_vector_t {
/** diffie hellman group to test */
diffie_hellman_group_t group;
/** private value of alice */
struct ke_test_vector_t {
/** key exchange method to test */
key_exchange_method_t method;
/** private key of alice */
u_char *priv_a;
/** private value of bob */
/** private key of bob */
u_char *priv_b;
/** length of private values */
/** length of private keys */
size_t priv_len;
/** expected public value of alice */
/** expected public key of alice */
u_char *pub_a;
/** expected public value of bob */
/** expected public key of bob */
u_char *pub_b;
/** size of public values */
/** size of public keys */
size_t pub_len;
/** expected shared secret */
u_char *shared;
@@ -318,15 +318,15 @@ struct crypto_tester_t {
rng_constructor_t create,
u_int *speed, const char *plugin_name);
/**
* Test a Diffie-Hellman implementation.
* Test a key exchange implementation.
*
* @param group group to test
* @param create constructor function for the DH backend
* @param speed speed test result, NULL to omit
* @param ke key exchange method to test
* @param create constructor function for the key exchange method
* @param speed speeed test result, NULL to omit
* @return TRUE if test passed
*/
bool (*test_dh)(crypto_tester_t *this, diffie_hellman_group_t group,
dh_constructor_t create,
bool (*test_ke)(crypto_tester_t *this, key_exchange_method_t ke,
ke_constructor_t create,
u_int *speed, const char *plugin_name);
/**
@@ -397,7 +397,7 @@ struct crypto_tester_t {
*
* @param vector pointer to test vector
*/
void (*add_dh_vector)(crypto_tester_t *this, dh_test_vector_t *vector);
void (*add_ke_vector)(crypto_tester_t *this, ke_test_vector_t *vector);
/**
* Destroy a crypto_tester_t.
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010 Tobias Brunner
* Copyright (C) 2010-2019 Tobias Brunner
* Copyright (C) 2005-2010 Martin Willi
* Copyright (C) 2005 Jan Hutter
*
@@ -16,15 +16,15 @@
* for more details.
*/
#include "diffie_hellman.h"
#include "key_exchange.h"
ENUM_BEGIN(diffie_hellman_group_names, MODP_NONE, MODP_1024_BIT,
ENUM_BEGIN(key_exchange_method_names, MODP_NONE, MODP_1024_BIT,
"MODP_NONE",
"MODP_768",
"MODP_1024");
ENUM_NEXT(diffie_hellman_group_names, MODP_1536_BIT, MODP_1536_BIT, MODP_1024_BIT,
ENUM_NEXT(key_exchange_method_names, MODP_1536_BIT, MODP_1536_BIT, MODP_1024_BIT,
"MODP_1536");
ENUM_NEXT(diffie_hellman_group_names, MODP_2048_BIT, ECP_521_BIT, MODP_1536_BIT,
ENUM_NEXT(key_exchange_method_names, MODP_2048_BIT, ECP_521_BIT, MODP_1536_BIT,
"MODP_2048",
"MODP_3072",
"MODP_4096",
@@ -33,7 +33,7 @@ ENUM_NEXT(diffie_hellman_group_names, MODP_2048_BIT, ECP_521_BIT, MODP_1536_BIT,
"ECP_256",
"ECP_384",
"ECP_521");
ENUM_NEXT(diffie_hellman_group_names, MODP_1024_160, CURVE_448, ECP_521_BIT,
ENUM_NEXT(key_exchange_method_names, MODP_1024_160, CURVE_448, ECP_521_BIT,
"MODP_1024_160",
"MODP_2048_224",
"MODP_2048_256",
@@ -45,26 +45,26 @@ ENUM_NEXT(diffie_hellman_group_names, MODP_1024_160, CURVE_448, ECP_521_BIT,
"ECP_512_BP",
"CURVE_25519",
"CURVE_448");
ENUM_NEXT(diffie_hellman_group_names, MODP_NULL, MODP_NULL, CURVE_448,
ENUM_NEXT(key_exchange_method_names, MODP_NULL, MODP_NULL, CURVE_448,
"MODP_NULL");
ENUM_NEXT(diffie_hellman_group_names, NTRU_112_BIT, NTRU_256_BIT, MODP_NULL,
ENUM_NEXT(key_exchange_method_names, NTRU_112_BIT, NTRU_256_BIT, MODP_NULL,
"NTRU_112",
"NTRU_128",
"NTRU_192",
"NTRU_256");
ENUM_NEXT(diffie_hellman_group_names, NH_128_BIT, NH_128_BIT, NTRU_256_BIT,
ENUM_NEXT(key_exchange_method_names, NH_128_BIT, NH_128_BIT, NTRU_256_BIT,
"NEWHOPE_128");
ENUM_NEXT(diffie_hellman_group_names, MODP_CUSTOM, MODP_CUSTOM, NH_128_BIT,
ENUM_NEXT(key_exchange_method_names, MODP_CUSTOM, MODP_CUSTOM, NH_128_BIT,
"MODP_CUSTOM");
ENUM_END(diffie_hellman_group_names, MODP_CUSTOM);
ENUM_END(key_exchange_method_names, MODP_CUSTOM);
ENUM_BEGIN(diffie_hellman_group_names_short, MODP_NONE, MODP_1024_BIT,
ENUM_BEGIN(key_exchange_method_names_short, MODP_NONE, MODP_1024_BIT,
"modpnone",
"modp768",
"modp1024");
ENUM_NEXT(diffie_hellman_group_names_short, MODP_1536_BIT, MODP_1536_BIT, MODP_1024_BIT,
ENUM_NEXT(key_exchange_method_names_short, MODP_1536_BIT, MODP_1536_BIT, MODP_1024_BIT,
"modp1536");
ENUM_NEXT(diffie_hellman_group_names_short, MODP_2048_BIT, ECP_521_BIT, MODP_1536_BIT,
ENUM_NEXT(key_exchange_method_names_short, MODP_2048_BIT, ECP_521_BIT, MODP_1536_BIT,
"modp2048",
"modp3072",
"modp4096",
@@ -73,7 +73,7 @@ ENUM_NEXT(diffie_hellman_group_names_short, MODP_2048_BIT, ECP_521_BIT, MODP_153
"ecp256",
"ecp384",
"ecp521");
ENUM_NEXT(diffie_hellman_group_names_short, MODP_1024_160, CURVE_448, ECP_521_BIT,
ENUM_NEXT(key_exchange_method_names_short, MODP_1024_160, CURVE_448, ECP_521_BIT,
"modp1024s160",
"modp2048s224",
"modp2048s256",
@@ -85,27 +85,27 @@ ENUM_NEXT(diffie_hellman_group_names_short, MODP_1024_160, CURVE_448, ECP_521_BI
"ecp512bp",
"curve25519",
"curve448");
ENUM_NEXT(diffie_hellman_group_names_short, MODP_NULL, MODP_NULL, CURVE_448,
ENUM_NEXT(key_exchange_method_names_short, MODP_NULL, MODP_NULL, CURVE_448,
"modpnull");
ENUM_NEXT(diffie_hellman_group_names_short, NTRU_112_BIT, NTRU_256_BIT, MODP_NULL,
ENUM_NEXT(key_exchange_method_names_short, NTRU_112_BIT, NTRU_256_BIT, MODP_NULL,
"ntru112",
"ntru128",
"ntru192",
"ntru256");
ENUM_NEXT(diffie_hellman_group_names_short, NH_128_BIT, NH_128_BIT, NTRU_256_BIT,
ENUM_NEXT(key_exchange_method_names_short, NH_128_BIT, NH_128_BIT, NTRU_256_BIT,
"newhope128");
ENUM_NEXT(diffie_hellman_group_names_short, MODP_CUSTOM, MODP_CUSTOM, NH_128_BIT,
ENUM_NEXT(key_exchange_method_names_short, MODP_CUSTOM, MODP_CUSTOM, NH_128_BIT,
"modpcustom");
ENUM_END(diffie_hellman_group_names_short, MODP_CUSTOM);
ENUM_END(key_exchange_method_names_short, MODP_CUSTOM);
/**
* List of known diffie hellman group parameters.
* List of known Diffie-Hellman group parameters.
*/
static struct {
/* Public part of the struct */
diffie_hellman_params_t public;
/* The group identifier as specified in IKEv2 */
diffie_hellman_group_t group;
key_exchange_method_t group;
} dh_params[] = {
{
.group = MODP_768_BIT, .public = {
@@ -475,8 +475,8 @@ static struct {
},
};
/**
* See header.
/*
* Described in header
*/
void diffie_hellman_init()
{
@@ -500,16 +500,16 @@ void diffie_hellman_init()
}
}
/**
* Described in header.
/*
* Described in header
*/
diffie_hellman_params_t *diffie_hellman_get_params(diffie_hellman_group_t group)
diffie_hellman_params_t *diffie_hellman_get_params(key_exchange_method_t ke)
{
int i;
for (i = 0; i < countof(dh_params); i++)
{
if (dh_params[i].group == group)
if (dh_params[i].group == ke)
{
return &dh_params[i].public;
}
@@ -517,12 +517,12 @@ diffie_hellman_params_t *diffie_hellman_get_params(diffie_hellman_group_t group)
return NULL;
}
/**
* See header.
/*
* Described in header
*/
bool diffie_hellman_group_is_ec(diffie_hellman_group_t group)
bool key_exchange_is_ecdh(key_exchange_method_t ke)
{
switch (group)
switch (ke)
{
case ECP_256_BIT:
case ECP_384_BIT:
@@ -541,15 +541,15 @@ bool diffie_hellman_group_is_ec(diffie_hellman_group_t group)
}
}
/**
* See header.
/*
* Described in header
*/
bool diffie_hellman_verify_value(diffie_hellman_group_t group, chunk_t value)
bool key_exchange_verify_pubkey(key_exchange_method_t ke, chunk_t value)
{
diffie_hellman_params_t *params;
bool valid = FALSE;
switch (group)
switch (ke)
{
case MODP_768_BIT:
case MODP_1024_BIT:
@@ -562,7 +562,7 @@ bool diffie_hellman_verify_value(diffie_hellman_group_t group, chunk_t value)
case MODP_1024_160:
case MODP_2048_224:
case MODP_2048_256:
params = diffie_hellman_get_params(group);
params = diffie_hellman_get_params(ke);
if (params)
{
valid = value.len == params->prime.len;
@@ -610,12 +610,12 @@ bool diffie_hellman_verify_value(diffie_hellman_group_t group, chunk_t value)
case MODP_NONE:
/* fail */
break;
/* compile-warn unhandled groups, fail verification */
/* compile-warn unhandled methods, fail verification */
}
if (!valid)
{
DBG1(DBG_ENC, "invalid DH public value size (%zu bytes) for %N",
value.len, diffie_hellman_group_names, group);
value.len, key_exchange_method_names, ke);
}
return valid;
}
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010 Tobias Brunner
* Copyright (C) 2010-2019 Tobias Brunner
* Copyright (C) 2005-2007 Martin Willi
* Copyright (C) 2005 Jan Hutter
*
@@ -17,21 +17,21 @@
*/
/**
* @defgroup diffie_hellman diffie_hellman
* @defgroup key_exchange key_exchange
* @{ @ingroup crypto
*/
#ifndef DIFFIE_HELLMAN_H_
#define DIFFIE_HELLMAN_H_
#ifndef KEY_EXCHANGE_H_
#define KEY_EXCHANGE_H_
typedef enum diffie_hellman_group_t diffie_hellman_group_t;
typedef struct diffie_hellman_t diffie_hellman_t;
typedef enum key_exchange_method_t key_exchange_method_t;
typedef struct key_exchange_t key_exchange_t;
typedef struct diffie_hellman_params_t diffie_hellman_params_t;
#include <library.h>
/**
* Diffie-Hellman group.
* Key exchange method.
*
* The modulus (or group) to use for a Diffie-Hellman calculation.
* See IKEv2 RFC 3.3.2 and RFC 3526.
@@ -40,7 +40,7 @@ typedef struct diffie_hellman_params_t diffie_hellman_params_t;
* ECC Brainpool groups are defined in RFC 6954.
* Curve25519 and Curve448 groups are defined in RFC 8031.
*/
enum diffie_hellman_group_t {
enum key_exchange_method_t {
MODP_NONE = 0,
MODP_768_BIT = 1,
MODP_1024_BIT = 2,
@@ -79,80 +79,75 @@ enum diffie_hellman_group_t {
};
/**
* enum name for diffie_hellman_group_t.
* enum name for key_exchange_method_t.
*/
extern enum_name_t *diffie_hellman_group_names;
extern enum_name_t *key_exchange_method_names;
/**
* enum names for diffie_hellman_group_t (matching proposal keywords).
* enum names for key_exchange_method_t (matching proposal keywords).
*/
extern enum_name_t *diffie_hellman_group_names_short;
extern enum_name_t *key_exchange_method_names_short;
/**
* Implementation of the Diffie-Hellman algorithm, as in RFC2631.
* Implementation of a key exchange algorithms (e.g. Diffie-Hellman).
*/
struct diffie_hellman_t {
struct key_exchange_t {
/**
* Returns the shared secret of this diffie hellman exchange.
* Returns the shared secret of this key exchange method.
*
* Space for returned secret is allocated and must be freed by the caller.
*
* @param secret shared secret will be written into this chunk
* @param secret shared secret (allocated)
* @return TRUE if shared secret computed successfully
*/
bool (*get_shared_secret)(diffie_hellman_t *this, chunk_t *secret)
bool (*get_shared_secret)(key_exchange_t *this, chunk_t *secret)
__attribute__((warn_unused_result));
/**
* Sets the public value of partner.
* Sets the public key from the peer.
*
* Chunk gets cloned and can be destroyed afterwards.
*
* @param value public value of partner
* @return TRUE if other public value verified and set
* @param value public key of peer
* @return TRUE if other public key verified and set
*/
bool (*set_other_public_value)(diffie_hellman_t *this, chunk_t value)
bool (*set_public_key)(key_exchange_t *this, chunk_t value)
__attribute__((warn_unused_result));
/**
* Gets the own public value to transmit.
* Gets the own public key to transmit.
*
* Space for returned chunk is allocated and must be freed by the caller.
*
* @param value public value of caller is stored at this location
* @return TRUE if public value retrieved
* @param value public key (allocated)
* @return TRUE if public key retrieved
*/
bool (*get_my_public_value) (diffie_hellman_t *this, chunk_t *value)
bool (*get_public_key)(key_exchange_t *this, chunk_t *value)
__attribute__((warn_unused_result));
/**
* Set an explicit own private value to use.
* Set an explicit own private key to use.
*
* Calling this method is usually not required, as the DH backend generates
* an appropriate private value itself. It is optional to implement, and
* used mostly for testing purposes.
* used mostly for testing purposes. The private key may be the actual key
* or a seed for a DRBG.
*
* @param value private value to set
* @param value private key value to set
*/
bool (*set_private_value)(diffie_hellman_t *this, chunk_t value)
bool (*set_private_key)(key_exchange_t *this, chunk_t value)
__attribute__((warn_unused_result));
/**
* Get the DH group used.
* Get the key exchange method used.
*
* @return DH group set in construction
* @return key exchange method set in construction
*/
diffie_hellman_group_t (*get_dh_group) (diffie_hellman_t *this);
key_exchange_method_t (*get_method)(key_exchange_t *this);
/**
* Destroys a diffie_hellman_t object.
* Destroys a key_exchange_t object.
*/
void (*destroy) (diffie_hellman_t *this);
void (*destroy)(key_exchange_t *this);
};
/**
* Parameters for a specific diffie hellman group.
* Parameters for a specific Diffie-Hellman group.
*/
struct diffie_hellman_params_t {
@@ -183,31 +178,31 @@ struct diffie_hellman_params_t {
void diffie_hellman_init();
/**
* Get the parameters associated with the specified diffie hellman group.
* Get the parameters associated with the specified Diffie-Hellman group.
*
* Before calling this method, use diffie_hellman_init() to initialize the
* DH group table. This is usually done by library_init().
*
* @param group DH group
* @param ke key exchange method (DH group)
* @return The parameters or NULL, if the group is not supported
*/
diffie_hellman_params_t *diffie_hellman_get_params(diffie_hellman_group_t group);
diffie_hellman_params_t *diffie_hellman_get_params(key_exchange_method_t ke);
/**
* Check if a given DH group is an ECDH group
* Check if a given key exchange method is an ECDH group.
*
* @param group group to check
* @return TRUE if group is an ECP group
* @param ke key exchange method to check
* @return TRUE if key exchange method is an ECP group
*/
bool diffie_hellman_group_is_ec(diffie_hellman_group_t group);
bool key_exchange_is_ecdh(key_exchange_method_t ke);
/**
* Check if a diffie hellman public value is valid for given group.
* Check if a public key is valid for given key exchange method.
*
* @param group group the value is used in
* @param value public DH value to check
* @return TRUE if value looks valid for group
* @param ke key exchange method
* @param value public key to check
* @return TRUE if value looks valid
*/
bool diffie_hellman_verify_value(diffie_hellman_group_t group, chunk_t value);
bool key_exchange_verify_pubkey(key_exchange_method_t ke, chunk_t value);
#endif /** DIFFIE_HELLMAN_H_ @}*/
#endif /** KEY_EXCHANGE_H_ @}*/
+25 -25
View File
@@ -252,18 +252,18 @@ METHOD(proposal_t, get_algorithm, bool,
return found;
}
METHOD(proposal_t, has_dh_group, bool,
private_proposal_t *this, diffie_hellman_group_t group)
METHOD(proposal_t, has_ke_method, bool,
private_proposal_t *this, key_exchange_method_t ke)
{
bool found = FALSE, any = FALSE;
enumerator_t *enumerator;
uint16_t current;
enumerator = create_enumerator(this, DIFFIE_HELLMAN_GROUP);
enumerator = create_enumerator(this, KEY_EXCHANGE_METHOD);
while (enumerator->enumerate(enumerator, &current, NULL))
{
any = TRUE;
if (current == group)
if (current == ke)
{
found = TRUE;
break;
@@ -271,15 +271,15 @@ METHOD(proposal_t, has_dh_group, bool,
}
enumerator->destroy(enumerator);
if (!any && group == MODP_NONE)
if (!any && ke == MODP_NONE)
{
found = TRUE;
}
return found;
}
METHOD(proposal_t, promote_dh_group, bool,
private_proposal_t *this, diffie_hellman_group_t group)
METHOD(proposal_t, promote_ke_method, bool,
private_proposal_t *this, key_exchange_method_t method)
{
enumerator_t *enumerator;
entry_t *entry;
@@ -288,8 +288,8 @@ METHOD(proposal_t, promote_dh_group, bool,
enumerator = array_create_enumerator(this->transforms);
while (enumerator->enumerate(enumerator, &entry))
{
if (entry->type == DIFFIE_HELLMAN_GROUP &&
entry->alg == group)
if (entry->type == KEY_EXCHANGE_METHOD &&
entry->alg == method)
{
array_remove_at(this->transforms, enumerator);
found = TRUE;
@@ -300,8 +300,8 @@ METHOD(proposal_t, promote_dh_group, bool,
if (found)
{
entry_t entry = {
.type = DIFFIE_HELLMAN_GROUP,
.alg = group,
.type = KEY_EXCHANGE_METHOD,
.alg = method,
};
array_insert(this->transforms, ARRAY_HEAD, &entry);
}
@@ -319,7 +319,7 @@ static bool select_algo(private_proposal_t *this, proposal_t *other,
uint16_t alg1, alg2, ks1, ks2;
bool found = FALSE, optional = FALSE;
if (type == DIFFIE_HELLMAN_GROUP)
if (type == KEY_EXCHANGE_METHOD)
{
optional = this->protocol == PROTO_ESP || this->protocol == PROTO_AH;
}
@@ -408,7 +408,7 @@ static bool select_algos(private_proposal_t *this, proposal_t *other,
{
continue;
}
if (type == DIFFIE_HELLMAN_GROUP && (flags & PROPOSAL_SKIP_DH))
if (type == KEY_EXCHANGE_METHOD && (flags & PROPOSAL_SKIP_KE))
{
continue;
}
@@ -601,7 +601,7 @@ METHOD(proposal_t, clone_, proposal_t*,
{
continue;
}
if (entry->type == DIFFIE_HELLMAN_GROUP && (flags & PROPOSAL_SKIP_DH))
if (entry->type == KEY_EXCHANGE_METHOD && (flags & PROPOSAL_SKIP_KE))
{
continue;
}
@@ -696,13 +696,13 @@ static bool check_proposal(private_proposal_t *this)
e = array_create_enumerator(this->transforms);
while (e->enumerate(e, &entry))
{
if (entry->type == DIFFIE_HELLMAN_GROUP && !entry->alg)
if (entry->type == KEY_EXCHANGE_METHOD && !entry->alg)
{
array_remove_at(this->transforms, e);
}
}
e->destroy(e);
if (!get_algorithm(this, DIFFIE_HELLMAN_GROUP, NULL, NULL))
if (!get_algorithm(this, KEY_EXCHANGE_METHOD, NULL, NULL))
{
DBG1(DBG_CFG, "a DH group is mandatory in IKE proposals");
return FALSE;
@@ -943,8 +943,8 @@ proposal_t *proposal_create_v1(protocol_id_t protocol, uint8_t number,
.add_algorithm = _add_algorithm,
.create_enumerator = _create_enumerator,
.get_algorithm = _get_algorithm,
.has_dh_group = _has_dh_group,
.promote_dh_group = _promote_dh_group,
.has_ke_method = _has_ke_method,
.promote_ke_method = _promote_ke_method,
.select = _select_proposal,
.matches = _matches,
.get_protocol = _get_protocol,
@@ -983,7 +983,7 @@ static bool proposal_add_supported_ike(private_proposal_t *this, bool aead)
encryption_algorithm_t encryption;
integrity_algorithm_t integrity;
pseudo_random_function_t prf;
diffie_hellman_group_t group;
key_exchange_method_t group;
const char *plugin_name;
if (aead)
@@ -1175,7 +1175,7 @@ static bool proposal_add_supported_ike(private_proposal_t *this, bool aead)
enumerator->destroy(enumerator);
/* Round 1 adds ECC and NTRU algorithms with at least 128 bit security strength */
enumerator = lib->crypto->create_dh_enumerator(lib->crypto);
enumerator = lib->crypto->create_ke_enumerator(lib->crypto);
while (enumerator->enumerate(enumerator, &group, &plugin_name))
{
switch (group)
@@ -1192,7 +1192,7 @@ static bool proposal_add_supported_ike(private_proposal_t *this, bool aead)
case NTRU_192_BIT:
case NTRU_256_BIT:
case NH_128_BIT:
add_algorithm(this, DIFFIE_HELLMAN_GROUP, group, 0);
add_algorithm(this, KEY_EXCHANGE_METHOD, group, 0);
break;
default:
break;
@@ -1201,7 +1201,7 @@ static bool proposal_add_supported_ike(private_proposal_t *this, bool aead)
enumerator->destroy(enumerator);
/* Round 2 adds other algorithms with at least 128 bit security strength */
enumerator = lib->crypto->create_dh_enumerator(lib->crypto);
enumerator = lib->crypto->create_ke_enumerator(lib->crypto);
while (enumerator->enumerate(enumerator, &group, &plugin_name))
{
switch (group)
@@ -1210,7 +1210,7 @@ static bool proposal_add_supported_ike(private_proposal_t *this, bool aead)
case MODP_4096_BIT:
case MODP_6144_BIT:
case MODP_8192_BIT:
add_algorithm(this, DIFFIE_HELLMAN_GROUP, group, 0);
add_algorithm(this, KEY_EXCHANGE_METHOD, group, 0);
break;
default:
break;
@@ -1219,7 +1219,7 @@ static bool proposal_add_supported_ike(private_proposal_t *this, bool aead)
enumerator->destroy(enumerator);
/* Round 3 adds algorithms with less than 128 bit security strength */
enumerator = lib->crypto->create_dh_enumerator(lib->crypto);
enumerator = lib->crypto->create_ke_enumerator(lib->crypto);
while (enumerator->enumerate(enumerator, &group, &plugin_name))
{
switch (group)
@@ -1244,7 +1244,7 @@ static bool proposal_add_supported_ike(private_proposal_t *this, bool aead)
/* rarely used */
break;
case MODP_2048_BIT:
add_algorithm(this, DIFFIE_HELLMAN_GROUP, group, 0);
add_algorithm(this, KEY_EXCHANGE_METHOD, group, 0);
break;
default:
break;
+10 -10
View File
@@ -35,7 +35,7 @@ typedef struct proposal_t proposal_t;
#include <crypto/transform.h>
#include <crypto/crypters/crypter.h>
#include <crypto/signers/signer.h>
#include <crypto/diffie_hellman.h>
#include <crypto/key_exchange.h>
/**
* Protocol ID of a proposal.
@@ -61,8 +61,8 @@ enum proposal_selection_flag_t {
PROPOSAL_PREFER_SUPPLIED = (1<<0),
/** Whether to skip and ignore algorithms from a private range. */
PROPOSAL_SKIP_PRIVATE = (1<<1),
/** Whether to skip and ignore diffie hellman groups. */
PROPOSAL_SKIP_DH = (1<<2),
/** Whether to skip and ignore key exchange methods. */
PROPOSAL_SKIP_KE = (1<<2),
};
/**
@@ -110,21 +110,21 @@ struct proposal_t {
uint16_t *alg, uint16_t *key_size);
/**
* Check if the proposal has a specific DH group.
* Check if the proposal has a specific key exchange method.
*
* @param group group to check for
* @param method key exchange method to check for
* @return TRUE if algorithm included
*/
bool (*has_dh_group)(proposal_t *this, diffie_hellman_group_t group);
bool (*has_ke_method)(proposal_t *this, key_exchange_method_t method);
/**
* Move the given DH group to the front of the list if it was contained in
* the proposal.
* Move the given key exchange method to the front of the list if it was
* contained in the proposal.
*
* @param group group to promote
* @param method key exchange method to promote
* @return TRUE if algorithm included
*/
bool (*promote_dh_group)(proposal_t *this, diffie_hellman_group_t group);
bool (*promote_ke_method)(proposal_t *this, key_exchange_method_t method);
/**
* Compare two proposals and select a matching subset.
@@ -20,7 +20,7 @@
#include <crypto/transform.h>
#include <crypto/crypters/crypter.h>
#include <crypto/signers/signer.h>
#include <crypto/diffie_hellman.h>
#include <crypto/key_exchange.h>
%}
struct proposal_token {
@@ -149,36 +149,36 @@ prfmd5, PSEUDO_RANDOM_FUNCTION, PRF_HMAC_MD5, 0
prfaesxcbc, PSEUDO_RANDOM_FUNCTION, PRF_AES128_XCBC, 0
prfcamelliaxcbc, PSEUDO_RANDOM_FUNCTION, PRF_CAMELLIA128_XCBC, 0
prfaescmac, PSEUDO_RANDOM_FUNCTION, PRF_AES128_CMAC, 0
modpnone, DIFFIE_HELLMAN_GROUP, MODP_NONE, 0
modpnull, DIFFIE_HELLMAN_GROUP, MODP_NULL, 0
modp768, DIFFIE_HELLMAN_GROUP, MODP_768_BIT, 0
modp1024, DIFFIE_HELLMAN_GROUP, MODP_1024_BIT, 0
modp1536, DIFFIE_HELLMAN_GROUP, MODP_1536_BIT, 0
modp2048, DIFFIE_HELLMAN_GROUP, MODP_2048_BIT, 0
modp3072, DIFFIE_HELLMAN_GROUP, MODP_3072_BIT, 0
modp4096, DIFFIE_HELLMAN_GROUP, MODP_4096_BIT, 0
modp6144, DIFFIE_HELLMAN_GROUP, MODP_6144_BIT, 0
modp8192, DIFFIE_HELLMAN_GROUP, MODP_8192_BIT, 0
ecp192, DIFFIE_HELLMAN_GROUP, ECP_192_BIT, 0
ecp224, DIFFIE_HELLMAN_GROUP, ECP_224_BIT, 0
ecp256, DIFFIE_HELLMAN_GROUP, ECP_256_BIT, 0
ecp384, DIFFIE_HELLMAN_GROUP, ECP_384_BIT, 0
ecp521, DIFFIE_HELLMAN_GROUP, ECP_521_BIT, 0
modp1024s160, DIFFIE_HELLMAN_GROUP, MODP_1024_160, 0
modp2048s224, DIFFIE_HELLMAN_GROUP, MODP_2048_224, 0
modp2048s256, DIFFIE_HELLMAN_GROUP, MODP_2048_256, 0
ecp224bp, DIFFIE_HELLMAN_GROUP, ECP_224_BP, 0
ecp256bp, DIFFIE_HELLMAN_GROUP, ECP_256_BP, 0
ecp384bp, DIFFIE_HELLMAN_GROUP, ECP_384_BP, 0
ecp512bp, DIFFIE_HELLMAN_GROUP, ECP_512_BP, 0
curve25519, DIFFIE_HELLMAN_GROUP, CURVE_25519, 0
x25519, DIFFIE_HELLMAN_GROUP, CURVE_25519, 0
curve448, DIFFIE_HELLMAN_GROUP, CURVE_448, 0
x448, DIFFIE_HELLMAN_GROUP, CURVE_448, 0
ntru112, DIFFIE_HELLMAN_GROUP, NTRU_112_BIT, 0
ntru128, DIFFIE_HELLMAN_GROUP, NTRU_128_BIT, 0
ntru192, DIFFIE_HELLMAN_GROUP, NTRU_192_BIT, 0
ntru256, DIFFIE_HELLMAN_GROUP, NTRU_256_BIT, 0
newhope128, DIFFIE_HELLMAN_GROUP, NH_128_BIT, 0
modpnone, KEY_EXCHANGE_METHOD, MODP_NONE, 0
modpnull, KEY_EXCHANGE_METHOD, MODP_NULL, 0
modp768, KEY_EXCHANGE_METHOD, MODP_768_BIT, 0
modp1024, KEY_EXCHANGE_METHOD, MODP_1024_BIT, 0
modp1536, KEY_EXCHANGE_METHOD, MODP_1536_BIT, 0
modp2048, KEY_EXCHANGE_METHOD, MODP_2048_BIT, 0
modp3072, KEY_EXCHANGE_METHOD, MODP_3072_BIT, 0
modp4096, KEY_EXCHANGE_METHOD, MODP_4096_BIT, 0
modp6144, KEY_EXCHANGE_METHOD, MODP_6144_BIT, 0
modp8192, KEY_EXCHANGE_METHOD, MODP_8192_BIT, 0
ecp192, KEY_EXCHANGE_METHOD, ECP_192_BIT, 0
ecp224, KEY_EXCHANGE_METHOD, ECP_224_BIT, 0
ecp256, KEY_EXCHANGE_METHOD, ECP_256_BIT, 0
ecp384, KEY_EXCHANGE_METHOD, ECP_384_BIT, 0
ecp521, KEY_EXCHANGE_METHOD, ECP_521_BIT, 0
modp1024s160, KEY_EXCHANGE_METHOD, MODP_1024_160, 0
modp2048s224, KEY_EXCHANGE_METHOD, MODP_2048_224, 0
modp2048s256, KEY_EXCHANGE_METHOD, MODP_2048_256, 0
ecp224bp, KEY_EXCHANGE_METHOD, ECP_224_BP, 0
ecp256bp, KEY_EXCHANGE_METHOD, ECP_256_BP, 0
ecp384bp, KEY_EXCHANGE_METHOD, ECP_384_BP, 0
ecp512bp, KEY_EXCHANGE_METHOD, ECP_512_BP, 0
curve25519, KEY_EXCHANGE_METHOD, CURVE_25519, 0
x25519, KEY_EXCHANGE_METHOD, CURVE_25519, 0
curve448, KEY_EXCHANGE_METHOD, CURVE_448, 0
x448, KEY_EXCHANGE_METHOD, CURVE_448, 0
ntru112, KEY_EXCHANGE_METHOD, NTRU_112_BIT, 0
ntru128, KEY_EXCHANGE_METHOD, NTRU_128_BIT, 0
ntru192, KEY_EXCHANGE_METHOD, NTRU_192_BIT, 0
ntru256, KEY_EXCHANGE_METHOD, NTRU_256_BIT, 0
newhope128, KEY_EXCHANGE_METHOD, NH_128_BIT, 0
noesn, EXTENDED_SEQUENCE_NUMBERS, NO_EXT_SEQ_NUMBERS, 0
esn, EXTENDED_SEQUENCE_NUMBERS, EXT_SEQ_NUMBERS, 0
+3 -3
View File
@@ -23,7 +23,7 @@ ENUM_BEGIN(transform_type_names, ENCRYPTION_ALGORITHM, EXTENDED_SEQUENCE_NUMBERS
"ENCRYPTION_ALGORITHM",
"PSEUDO_RANDOM_FUNCTION",
"INTEGRITY_ALGORITHM",
"DIFFIE_HELLMAN_GROUP",
"KEY_EXCHANGE_METHOD",
"EXTENDED_SEQUENCE_NUMBERS");
ENUM_NEXT(transform_type_names, HASH_ALGORITHM, KEY_DERIVATION_FUNCTION,
EXTENDED_SEQUENCE_NUMBERS,
@@ -59,8 +59,8 @@ enum_name_t* transform_get_enum_names(transform_type_t type)
return pseudo_random_function_names;
case INTEGRITY_ALGORITHM:
return integrity_algorithm_names;
case DIFFIE_HELLMAN_GROUP:
return diffie_hellman_group_names;
case KEY_EXCHANGE_METHOD:
return key_exchange_method_names;
case EXTENDED_SEQUENCE_NUMBERS:
return extended_sequence_numbers_names;
case EXTENDED_OUTPUT_FUNCTION:
+1 -1
View File
@@ -33,7 +33,7 @@ enum transform_type_t {
ENCRYPTION_ALGORITHM = 1,
PSEUDO_RANDOM_FUNCTION = 2,
INTEGRITY_ALGORITHM = 3,
DIFFIE_HELLMAN_GROUP = 4,
KEY_EXCHANGE_METHOD = 4,
EXTENDED_SEQUENCE_NUMBERS = 5,
HASH_ALGORITHM = 256,
RANDOM_NUMBER_GENERATOR = 257,