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:
@@ -141,93 +141,93 @@ START_TEST(test_create_rng)
|
||||
}
|
||||
END_TEST
|
||||
|
||||
static diffie_hellman_t *dh_create(char *plugin)
|
||||
static key_exchange_t *ke_create(char *plugin)
|
||||
{
|
||||
return (diffie_hellman_t*)plugin;
|
||||
return (key_exchange_t*)plugin;
|
||||
}
|
||||
|
||||
static diffie_hellman_t *dh_create_modp1024(diffie_hellman_group_t group, ...)
|
||||
static key_exchange_t *ke_create_modp1024(key_exchange_method_t group, ...)
|
||||
{
|
||||
ck_assert(group == MODP_1024_BIT);
|
||||
return dh_create("plugin1");
|
||||
return ke_create("plugin1");
|
||||
}
|
||||
|
||||
static diffie_hellman_t *dh_create_modp1024_second(diffie_hellman_group_t group,
|
||||
...)
|
||||
static key_exchange_t *ke_create_modp1024_second(key_exchange_method_t group,
|
||||
...)
|
||||
{
|
||||
ck_assert(group == MODP_1024_BIT);
|
||||
return dh_create("plugin2");
|
||||
return ke_create("plugin2");
|
||||
}
|
||||
|
||||
static diffie_hellman_t *dh_create_modp2048(diffie_hellman_group_t group, ...)
|
||||
static key_exchange_t *ke_create_modp2048(key_exchange_method_t group, ...)
|
||||
{
|
||||
ck_assert(group == MODP_2048_BIT);
|
||||
return dh_create("plugin1");
|
||||
return ke_create("plugin1");
|
||||
}
|
||||
|
||||
static diffie_hellman_t *dh_create_modp2048_second(diffie_hellman_group_t group,
|
||||
...)
|
||||
static key_exchange_t *ke_create_modp2048_second(key_exchange_method_t group,
|
||||
...)
|
||||
{
|
||||
ck_assert(group == MODP_2048_BIT);
|
||||
return dh_create("plugin2");
|
||||
return ke_create("plugin2");
|
||||
}
|
||||
|
||||
static struct {
|
||||
char *exp1024;
|
||||
char *exp2048;
|
||||
struct {
|
||||
diffie_hellman_group_t g;
|
||||
dh_constructor_t create;
|
||||
key_exchange_method_t ke;
|
||||
ke_constructor_t create;
|
||||
char *plugin;
|
||||
} data[4];
|
||||
} dh_data[] = {
|
||||
} ke_data[] = {
|
||||
{ NULL, NULL, {
|
||||
{ MODP_NONE, NULL, NULL }
|
||||
}},
|
||||
{ "plugin1", NULL, {
|
||||
{ MODP_1024_BIT, dh_create_modp1024, "plugin1" },
|
||||
{ MODP_1024_BIT, ke_create_modp1024, "plugin1" },
|
||||
{ MODP_NONE, NULL, NULL }
|
||||
}},
|
||||
{ "plugin1", NULL, {
|
||||
{ MODP_1024_BIT, dh_create_modp1024, "plugin1" },
|
||||
{ MODP_1024_BIT, dh_create_modp1024_second, "plugin2" },
|
||||
{ MODP_1024_BIT, ke_create_modp1024, "plugin1" },
|
||||
{ MODP_1024_BIT, ke_create_modp1024_second, "plugin2" },
|
||||
{ MODP_NONE, NULL, NULL }
|
||||
}},
|
||||
{ "plugin2", NULL, {
|
||||
{ MODP_1024_BIT, dh_create_modp1024_second, "plugin2" },
|
||||
{ MODP_1024_BIT, dh_create_modp1024, "plugin1" },
|
||||
{ MODP_1024_BIT, ke_create_modp1024_second, "plugin2" },
|
||||
{ MODP_1024_BIT, ke_create_modp1024, "plugin1" },
|
||||
{ MODP_NONE, NULL, NULL }
|
||||
}},
|
||||
{ "plugin1", "plugin1", {
|
||||
{ MODP_1024_BIT, dh_create_modp1024, "plugin1" },
|
||||
{ MODP_2048_BIT, dh_create_modp2048, "plugin1" },
|
||||
{ MODP_1024_BIT, ke_create_modp1024, "plugin1" },
|
||||
{ MODP_2048_BIT, ke_create_modp2048, "plugin1" },
|
||||
{ MODP_NONE, NULL }
|
||||
}},
|
||||
{ "plugin1", "plugin1", {
|
||||
{ MODP_2048_BIT, dh_create_modp2048, "plugin1" },
|
||||
{ MODP_1024_BIT, dh_create_modp1024, "plugin1" },
|
||||
{ MODP_2048_BIT, ke_create_modp2048, "plugin1" },
|
||||
{ MODP_1024_BIT, ke_create_modp1024, "plugin1" },
|
||||
{ MODP_NONE, NULL }
|
||||
}},
|
||||
{ "plugin1", "plugin1", {
|
||||
{ MODP_2048_BIT, dh_create_modp2048, "plugin1" },
|
||||
{ MODP_2048_BIT, dh_create_modp2048_second, "plugin2" },
|
||||
{ MODP_1024_BIT, dh_create_modp1024, "plugin1" },
|
||||
{ MODP_2048_BIT, ke_create_modp2048, "plugin1" },
|
||||
{ MODP_2048_BIT, ke_create_modp2048_second, "plugin2" },
|
||||
{ MODP_1024_BIT, ke_create_modp1024, "plugin1" },
|
||||
{ MODP_NONE, NULL }
|
||||
}},
|
||||
{ "plugin1", "plugin2", {
|
||||
{ MODP_2048_BIT, dh_create_modp2048_second, "plugin2" },
|
||||
{ MODP_2048_BIT, dh_create_modp2048, "plugin1" },
|
||||
{ MODP_1024_BIT, dh_create_modp1024, "plugin1" },
|
||||
{ MODP_2048_BIT, ke_create_modp2048_second, "plugin2" },
|
||||
{ MODP_2048_BIT, ke_create_modp2048, "plugin1" },
|
||||
{ MODP_1024_BIT, ke_create_modp1024, "plugin1" },
|
||||
{ MODP_NONE, NULL }
|
||||
}},
|
||||
};
|
||||
|
||||
static void verify_dh(crypto_factory_t *factory, diffie_hellman_group_t request,
|
||||
static void verify_ke(crypto_factory_t *factory, key_exchange_method_t request,
|
||||
char *expected)
|
||||
{
|
||||
char *plugin;
|
||||
|
||||
plugin = (char*)factory->create_dh(factory, request);
|
||||
plugin = (char*)factory->create_ke(factory, request);
|
||||
if (!expected)
|
||||
{
|
||||
ck_assert(!plugin);
|
||||
@@ -239,56 +239,56 @@ static void verify_dh(crypto_factory_t *factory, diffie_hellman_group_t request,
|
||||
}
|
||||
}
|
||||
|
||||
START_TEST(test_create_dh)
|
||||
START_TEST(test_create_ke)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
crypto_factory_t *factory;
|
||||
diffie_hellman_group_t group;
|
||||
key_exchange_method_t ke;
|
||||
char *plugin;
|
||||
int i, len = 0;
|
||||
|
||||
|
||||
factory = crypto_factory_create();
|
||||
for (i = 0; dh_data[_i].data[i].g != MODP_NONE; i++)
|
||||
for (i = 0; ke_data[_i].data[i].ke != MODP_NONE; i++)
|
||||
{
|
||||
ck_assert(factory->add_dh(factory, dh_data[_i].data[i].g,
|
||||
dh_data[_i].data[i].plugin,
|
||||
dh_data[_i].data[i].create));
|
||||
ck_assert(factory->add_ke(factory, ke_data[_i].data[i].ke,
|
||||
ke_data[_i].data[i].plugin,
|
||||
ke_data[_i].data[i].create));
|
||||
}
|
||||
verify_dh(factory, MODP_1024_BIT, dh_data[_i].exp1024);
|
||||
verify_dh(factory, MODP_2048_BIT, dh_data[_i].exp2048);
|
||||
verify_ke(factory, MODP_1024_BIT, ke_data[_i].exp1024);
|
||||
verify_ke(factory, MODP_2048_BIT, ke_data[_i].exp2048);
|
||||
|
||||
len = countof(dh_data[_i].data);
|
||||
enumerator = factory->create_dh_enumerator(factory);
|
||||
for (i = 0; enumerator->enumerate(enumerator, &group, &plugin) && i < len;)
|
||||
len = countof(ke_data[_i].data);
|
||||
enumerator = factory->create_ke_enumerator(factory);
|
||||
for (i = 0; enumerator->enumerate(enumerator, &ke, &plugin) && i < len;)
|
||||
{
|
||||
ck_assert_int_eq(dh_data[_i].data[i].g, group);
|
||||
while (dh_data[_i].data[i].g == group)
|
||||
{ /* skip other entries by the same group */
|
||||
ck_assert_int_eq(ke_data[_i].data[i].ke, ke);
|
||||
while (ke_data[_i].data[i].ke == ke)
|
||||
{ /* skip other entries of the same method */
|
||||
i++;
|
||||
}
|
||||
switch (group)
|
||||
switch (ke)
|
||||
{
|
||||
case MODP_1024_BIT:
|
||||
ck_assert(dh_data[_i].exp1024);
|
||||
ck_assert_str_eq(dh_data[_i].exp1024, plugin);
|
||||
ck_assert(ke_data[_i].exp1024);
|
||||
ck_assert_str_eq(ke_data[_i].exp1024, plugin);
|
||||
break;
|
||||
case MODP_2048_BIT:
|
||||
ck_assert(dh_data[_i].exp2048);
|
||||
ck_assert_str_eq(dh_data[_i].exp2048, plugin);
|
||||
ck_assert(ke_data[_i].exp2048);
|
||||
ck_assert_str_eq(ke_data[_i].exp2048, plugin);
|
||||
break;
|
||||
default:
|
||||
fail("unexpected DH group");
|
||||
fail("unexpected key exchange method");
|
||||
break;
|
||||
}
|
||||
}
|
||||
ck_assert(!enumerator->enumerate(enumerator));
|
||||
ck_assert_int_eq(dh_data[_i].data[i].g, MODP_NONE);
|
||||
ck_assert_int_eq(ke_data[_i].data[i].ke, MODP_NONE);
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
for (i = 0; dh_data[_i].data[i].g != MODP_NONE; i++)
|
||||
for (i = 0; ke_data[_i].data[i].ke != MODP_NONE; i++)
|
||||
{
|
||||
factory->remove_dh(factory, dh_data[_i].data[i].create);
|
||||
factory->remove_ke(factory, ke_data[_i].data[i].create);
|
||||
}
|
||||
factory->destroy(factory);
|
||||
}
|
||||
@@ -305,8 +305,8 @@ Suite *crypto_factory_suite_create()
|
||||
tcase_add_loop_test(tc, test_create_rng, 0, countof(rng_data));
|
||||
suite_add_tcase(s, tc);
|
||||
|
||||
tc = tcase_create("create_dh");
|
||||
tcase_add_loop_test(tc, test_create_dh, 0, countof(dh_data));
|
||||
tc = tcase_create("create_ke");
|
||||
tcase_add_loop_test(tc, test_create_ke, 0, countof(ke_data));
|
||||
suite_add_tcase(s, tc);
|
||||
|
||||
return s;
|
||||
|
||||
@@ -54,8 +54,8 @@ IMPORT_FUNCTION_FOR_TESTS(ntru, ntru_public_key_create_from_data, ntru_public_ke
|
||||
* NTRU parameter sets to test
|
||||
*/
|
||||
static struct {
|
||||
diffie_hellman_group_t group;
|
||||
char *group_name;
|
||||
key_exchange_method_t ke;
|
||||
char *name;
|
||||
} params[] = {
|
||||
{ NTRU_112_BIT, "NTRU_112" },
|
||||
{ NTRU_128_BIT, "NTRU_128" },
|
||||
@@ -811,39 +811,39 @@ END_TEST
|
||||
START_TEST(test_ntru_ke)
|
||||
{
|
||||
chunk_t pub_key, cipher_text, i_shared_secret, r_shared_secret;
|
||||
diffie_hellman_t *i_ntru, *r_ntru;
|
||||
key_exchange_t *i_ntru, *r_ntru;
|
||||
char buf[10];
|
||||
int k, n, len;
|
||||
|
||||
k = (_i) / countof(parameter_sets);
|
||||
n = (_i) % countof(parameter_sets);
|
||||
|
||||
len = snprintf(buf, sizeof(buf), "%N", diffie_hellman_group_names,
|
||||
params[k].group);
|
||||
len = snprintf(buf, sizeof(buf), "%N", key_exchange_method_names,
|
||||
params[k].ke);
|
||||
ck_assert(len == 8);
|
||||
ck_assert(streq(buf, params[k].group_name));
|
||||
ck_assert(streq(buf, params[k].name));
|
||||
|
||||
lib->settings->set_str(lib->settings,
|
||||
"libstrongswan.plugins.ntru.parameter_set", parameter_sets[n]);
|
||||
|
||||
i_ntru = lib->crypto->create_dh(lib->crypto, params[k].group);
|
||||
i_ntru = lib->crypto->create_ke(lib->crypto, params[k].ke);
|
||||
ck_assert(i_ntru != NULL);
|
||||
ck_assert(i_ntru->get_dh_group(i_ntru) == params[k].group);
|
||||
ck_assert(i_ntru->get_method(i_ntru) == params[k].ke);
|
||||
|
||||
ck_assert(i_ntru->get_my_public_value(i_ntru, &pub_key));
|
||||
ck_assert(i_ntru->get_public_key(i_ntru, &pub_key));
|
||||
ck_assert(pub_key.len > 0);
|
||||
|
||||
r_ntru = lib->crypto->create_dh(lib->crypto, params[k].group);
|
||||
r_ntru = lib->crypto->create_ke(lib->crypto, params[k].ke);
|
||||
ck_assert(r_ntru != NULL);
|
||||
|
||||
ck_assert(r_ntru->set_other_public_value(r_ntru, pub_key));
|
||||
ck_assert(r_ntru->get_my_public_value(r_ntru, &cipher_text));
|
||||
ck_assert(r_ntru->set_public_key(r_ntru, pub_key));
|
||||
ck_assert(r_ntru->get_public_key(r_ntru, &cipher_text));
|
||||
ck_assert(cipher_text.len > 0);
|
||||
|
||||
ck_assert(r_ntru->get_shared_secret(r_ntru, &r_shared_secret));
|
||||
ck_assert(r_shared_secret.len > 0);
|
||||
|
||||
ck_assert(i_ntru->set_other_public_value(i_ntru, cipher_text));
|
||||
ck_assert(i_ntru->set_public_key(i_ntru, cipher_text));
|
||||
ck_assert(i_ntru->get_shared_secret(i_ntru, &i_shared_secret));
|
||||
ck_assert(chunk_equals(i_shared_secret, r_shared_secret));
|
||||
|
||||
@@ -858,12 +858,12 @@ END_TEST
|
||||
|
||||
START_TEST(test_ntru_retransmission)
|
||||
{
|
||||
diffie_hellman_t *i_ntru;
|
||||
key_exchange_t *i_ntru;
|
||||
chunk_t pub_key1, pub_key2;
|
||||
|
||||
i_ntru = lib->crypto->create_dh(lib->crypto, NTRU_256_BIT);
|
||||
ck_assert(i_ntru->get_my_public_value(i_ntru, &pub_key1));
|
||||
ck_assert(i_ntru->get_my_public_value(i_ntru, &pub_key2));
|
||||
i_ntru = lib->crypto->create_ke(lib->crypto, NTRU_256_BIT);
|
||||
ck_assert(i_ntru->get_public_key(i_ntru, &pub_key1));
|
||||
ck_assert(i_ntru->get_public_key(i_ntru, &pub_key2));
|
||||
ck_assert(chunk_equals(pub_key1, pub_key2));
|
||||
|
||||
chunk_free(&pub_key1);
|
||||
@@ -885,12 +885,12 @@ chunk_t oid_tests[] = {
|
||||
|
||||
START_TEST(test_ntru_pubkey_oid)
|
||||
{
|
||||
diffie_hellman_t *r_ntru;
|
||||
key_exchange_t *r_ntru;
|
||||
chunk_t cipher_text;
|
||||
|
||||
r_ntru = lib->crypto->create_dh(lib->crypto, NTRU_128_BIT);
|
||||
ck_assert(!r_ntru->set_other_public_value(r_ntru, oid_tests[_i]));
|
||||
ck_assert(r_ntru->get_my_public_value(r_ntru, &cipher_text));
|
||||
r_ntru = lib->crypto->create_ke(lib->crypto, NTRU_128_BIT);
|
||||
ck_assert(!r_ntru->set_public_key(r_ntru, oid_tests[_i]));
|
||||
ck_assert(r_ntru->get_public_key(r_ntru, &cipher_text));
|
||||
ck_assert(cipher_text.len == 0);
|
||||
r_ntru->destroy(r_ntru);
|
||||
}
|
||||
@@ -898,21 +898,21 @@ END_TEST
|
||||
|
||||
START_TEST(test_ntru_wrong_set)
|
||||
{
|
||||
diffie_hellman_t *i_ntru, *r_ntru;
|
||||
key_exchange_t *i_ntru, *r_ntru;
|
||||
chunk_t pub_key, cipher_text;
|
||||
|
||||
lib->settings->set_str(lib->settings,
|
||||
"libstrongswan.plugins.ntru.parameter_set",
|
||||
"x9_98_bandwidth");
|
||||
i_ntru = lib->crypto->create_dh(lib->crypto, NTRU_112_BIT);
|
||||
ck_assert(i_ntru->get_my_public_value(i_ntru, &pub_key));
|
||||
i_ntru = lib->crypto->create_ke(lib->crypto, NTRU_112_BIT);
|
||||
ck_assert(i_ntru->get_public_key(i_ntru, &pub_key));
|
||||
|
||||
lib->settings->set_str(lib->settings,
|
||||
"libstrongswan.plugins.ntru.parameter_set",
|
||||
"optimum");
|
||||
r_ntru = lib->crypto->create_dh(lib->crypto, NTRU_112_BIT);
|
||||
ck_assert(!r_ntru->set_other_public_value(r_ntru, pub_key));
|
||||
ck_assert(r_ntru->get_my_public_value(r_ntru, &cipher_text));
|
||||
r_ntru = lib->crypto->create_ke(lib->crypto, NTRU_112_BIT);
|
||||
ck_assert(!r_ntru->set_public_key(r_ntru, pub_key));
|
||||
ck_assert(r_ntru->get_public_key(r_ntru, &cipher_text));
|
||||
ck_assert(cipher_text.len == 0);
|
||||
|
||||
chunk_free(&pub_key);
|
||||
@@ -933,7 +933,7 @@ START_TEST(test_ntru_ciphertext)
|
||||
chunk_create(buf_ff, sizeof(buf_ff)),
|
||||
};
|
||||
|
||||
diffie_hellman_t *i_ntru;
|
||||
key_exchange_t *i_ntru;
|
||||
chunk_t pub_key, shared_secret;
|
||||
int i;
|
||||
|
||||
@@ -942,9 +942,9 @@ START_TEST(test_ntru_ciphertext)
|
||||
|
||||
for (i = 0; i < countof(test); i++)
|
||||
{
|
||||
i_ntru = lib->crypto->create_dh(lib->crypto, NTRU_128_BIT);
|
||||
ck_assert(i_ntru->get_my_public_value(i_ntru, &pub_key));
|
||||
ck_assert(!i_ntru->set_other_public_value(i_ntru, test[i]));
|
||||
i_ntru = lib->crypto->create_ke(lib->crypto, NTRU_128_BIT);
|
||||
ck_assert(i_ntru->get_public_key(i_ntru, &pub_key));
|
||||
ck_assert(!i_ntru->set_public_key(i_ntru, test[i]));
|
||||
ck_assert(!i_ntru->get_shared_secret(i_ntru, &shared_secret));
|
||||
ck_assert(shared_secret.len == 0);
|
||||
|
||||
@@ -956,18 +956,18 @@ END_TEST
|
||||
|
||||
START_TEST(test_ntru_wrong_ciphertext)
|
||||
{
|
||||
diffie_hellman_t *i_ntru, *r_ntru, *m_ntru;
|
||||
key_exchange_t *i_ntru, *r_ntru, *m_ntru;
|
||||
chunk_t pub_key_i, pub_key_m, cipher_text, shared_secret;
|
||||
|
||||
i_ntru = lib->crypto->create_dh(lib->crypto, NTRU_128_BIT);
|
||||
r_ntru = lib->crypto->create_dh(lib->crypto, NTRU_128_BIT);
|
||||
m_ntru = lib->crypto->create_dh(lib->crypto, NTRU_128_BIT);
|
||||
i_ntru = lib->crypto->create_ke(lib->crypto, NTRU_128_BIT);
|
||||
r_ntru = lib->crypto->create_ke(lib->crypto, NTRU_128_BIT);
|
||||
m_ntru = lib->crypto->create_ke(lib->crypto, NTRU_128_BIT);
|
||||
|
||||
ck_assert(i_ntru->get_my_public_value(i_ntru, &pub_key_i));
|
||||
ck_assert(m_ntru->get_my_public_value(m_ntru, &pub_key_m));
|
||||
ck_assert(r_ntru->set_other_public_value(r_ntru, pub_key_m));
|
||||
ck_assert(r_ntru->get_my_public_value(r_ntru, &cipher_text));
|
||||
ck_assert(!i_ntru->set_other_public_value(i_ntru, cipher_text));
|
||||
ck_assert(i_ntru->get_public_key(i_ntru, &pub_key_i));
|
||||
ck_assert(m_ntru->get_public_key(m_ntru, &pub_key_m));
|
||||
ck_assert(r_ntru->set_public_key(r_ntru, pub_key_m));
|
||||
ck_assert(r_ntru->get_public_key(r_ntru, &cipher_text));
|
||||
ck_assert(!i_ntru->set_public_key(i_ntru, cipher_text));
|
||||
ck_assert(!i_ntru->get_shared_secret(i_ntru, &shared_secret));
|
||||
ck_assert(shared_secret.len == 0);
|
||||
|
||||
|
||||
@@ -20,24 +20,24 @@
|
||||
|
||||
START_TEST(test_dh_group_mapping)
|
||||
{
|
||||
enum_name_t *e = diffie_hellman_group_names_short;
|
||||
diffie_hellman_group_t group;
|
||||
enum_name_t *e = key_exchange_method_names_short;
|
||||
key_exchange_method_t ke;
|
||||
const proposal_token_t *token;
|
||||
char *name;
|
||||
|
||||
do
|
||||
{
|
||||
for (group = e->first; group <= e->last; group++)
|
||||
for (ke = e->first; ke <= e->last; ke++)
|
||||
{
|
||||
if (group == MODP_CUSTOM)
|
||||
if (ke == MODP_CUSTOM)
|
||||
{ /* can't be configured */
|
||||
continue;
|
||||
}
|
||||
name = e->names[group - e->first];
|
||||
name = e->names[ke - e->first];
|
||||
token = lib->proposal->get_token(lib->proposal, name);
|
||||
ck_assert_msg(token, "%s can't be mapped", name);
|
||||
ck_assert_int_eq(token->type, DIFFIE_HELLMAN_GROUP);
|
||||
ck_assert_int_eq(token->algorithm, group);
|
||||
ck_assert_int_eq(token->type, KEY_EXCHANGE_METHOD);
|
||||
ck_assert_int_eq(token->algorithm, ke);
|
||||
}
|
||||
}
|
||||
while ((e = e->next));
|
||||
@@ -124,11 +124,11 @@ static struct {
|
||||
{ PROTO_ESP, "aes128-aes256-sha1-sha256", "aes256-aes128-sha256-sha1", "aes128-sha1" },
|
||||
{ PROTO_ESP, "aes256-aes128-sha256-sha1", "aes128-aes256-sha1-sha256", "aes256-sha256" },
|
||||
{ PROTO_ESP, "aes128-sha256-modp3072", "aes128-sha256", NULL },
|
||||
{ PROTO_ESP, "aes128-sha256-modp3072", "aes128-sha256", "aes128-sha256", PROPOSAL_SKIP_DH },
|
||||
{ PROTO_ESP, "aes128-sha256-modp3072", "aes128-sha256", "aes128-sha256", PROPOSAL_SKIP_KE },
|
||||
{ PROTO_ESP, "aes128-sha256", "aes128-sha256-modp3072", NULL },
|
||||
{ PROTO_ESP, "aes128-sha256", "aes128-sha256-modp3072", "aes128-sha256", PROPOSAL_SKIP_DH },
|
||||
{ PROTO_ESP, "aes128-sha256-modp3072", "aes128-sha256-modp3072", "aes128-sha256", PROPOSAL_SKIP_DH },
|
||||
{ PROTO_ESP, "aes128-sha256-modp3072", "aes128-sha256-ecp256", "aes128-sha256", PROPOSAL_SKIP_DH },
|
||||
{ PROTO_ESP, "aes128-sha256", "aes128-sha256-modp3072", "aes128-sha256", PROPOSAL_SKIP_KE },
|
||||
{ PROTO_ESP, "aes128-sha256-modp3072", "aes128-sha256-modp3072", "aes128-sha256", PROPOSAL_SKIP_KE },
|
||||
{ PROTO_ESP, "aes128-sha256-modp3072", "aes128-sha256-ecp256", "aes128-sha256", PROPOSAL_SKIP_KE },
|
||||
{ PROTO_ESP, "aes128-sha256-modp3072", "aes128-sha256-modpnone", NULL },
|
||||
{ PROTO_ESP, "aes128-sha256-modpnone", "aes128-sha256-modp3072", NULL },
|
||||
{ PROTO_ESP, "aes128-sha256-modp3072-modpnone", "aes128-sha256", "aes128-sha256" },
|
||||
@@ -246,10 +246,10 @@ static struct {
|
||||
{ "aes256-modp2048", "aes128-modp2048" }, NULL },
|
||||
{ PROTO_ESP, { "aes128-modp1024", "aes256-modp1024" },
|
||||
{ "aes256-modp2048", "aes128-modp2048" }, "aes128",
|
||||
PROPOSAL_SKIP_DH },
|
||||
PROPOSAL_SKIP_KE },
|
||||
{ PROTO_ESP, { "aes128-modp1024", "aes256-modp1024" },
|
||||
{ "aes256-modp2048", "aes128-modp2048" }, "aes256",
|
||||
PROPOSAL_PREFER_SUPPLIED | PROPOSAL_SKIP_DH },
|
||||
PROPOSAL_PREFER_SUPPLIED | PROPOSAL_SKIP_KE },
|
||||
};
|
||||
|
||||
START_TEST(test_select_proposal)
|
||||
@@ -301,38 +301,38 @@ START_TEST(test_select_proposal)
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_promote_dh_group)
|
||||
START_TEST(test_promote_ke_method)
|
||||
{
|
||||
proposal_t *proposal;
|
||||
|
||||
proposal = proposal_create_from_string(PROTO_IKE,
|
||||
"aes128-sha256-modp3072-ecp256");
|
||||
ck_assert(proposal->promote_dh_group(proposal, ECP_256_BIT));
|
||||
ck_assert(proposal->promote_ke_method(proposal, ECP_256_BIT));
|
||||
assert_proposal_eq(proposal, "IKE:AES_CBC_128/HMAC_SHA2_256_128/PRF_HMAC_SHA2_256/ECP_256/MODP_3072");
|
||||
proposal->destroy(proposal);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_promote_dh_group_already_front)
|
||||
START_TEST(test_promote_ke_method_already_front)
|
||||
{
|
||||
proposal_t *proposal;
|
||||
|
||||
proposal = proposal_create_from_string(PROTO_IKE,
|
||||
"aes128-sha256-modp3072-ecp256");
|
||||
ck_assert(proposal->promote_dh_group(proposal, MODP_3072_BIT));
|
||||
ck_assert(proposal->promote_ke_method(proposal, MODP_3072_BIT));
|
||||
assert_proposal_eq(proposal, "IKE:AES_CBC_128/HMAC_SHA2_256_128/PRF_HMAC_SHA2_256/MODP_3072/ECP_256");
|
||||
proposal->destroy(proposal);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_promote_dh_group_not_contained)
|
||||
START_TEST(test_promote_ke_method_not_contained)
|
||||
{
|
||||
proposal_t *proposal;
|
||||
|
||||
proposal = proposal_create_from_string(PROTO_IKE,
|
||||
"aes128-sha256-modp3072-ecp256");
|
||||
|
||||
ck_assert(!proposal->promote_dh_group(proposal, MODP_2048_BIT));
|
||||
ck_assert(!proposal->promote_ke_method(proposal, MODP_2048_BIT));
|
||||
assert_proposal_eq(proposal, "IKE:AES_CBC_128/HMAC_SHA2_256_128/PRF_HMAC_SHA2_256/MODP_3072/ECP_256");
|
||||
proposal->destroy(proposal);
|
||||
}
|
||||
@@ -447,11 +447,11 @@ static struct {
|
||||
{ PROTO_ESP, "aes128-serpent", "aes128-serpent" },
|
||||
{ PROTO_ESP, "aes128-serpent", "aes128", PROPOSAL_SKIP_PRIVATE },
|
||||
{ PROTO_ESP, "aes128-sha256-modp3072", "aes128-sha256-modp3072" },
|
||||
{ PROTO_ESP, "aes128-sha256-modp3072", "aes128-sha256", PROPOSAL_SKIP_DH },
|
||||
{ PROTO_ESP, "aes128-sha256-modp3072", "aes128-sha256", PROPOSAL_SKIP_KE },
|
||||
{ PROTO_ESP, "aes128-serpent-modp3072", "aes128-serpent",
|
||||
PROPOSAL_SKIP_DH },
|
||||
PROPOSAL_SKIP_KE },
|
||||
{ PROTO_ESP, "aes128-serpent-modp3072", "aes128",
|
||||
PROPOSAL_SKIP_PRIVATE | PROPOSAL_SKIP_DH },
|
||||
PROPOSAL_SKIP_PRIVATE | PROPOSAL_SKIP_KE },
|
||||
};
|
||||
|
||||
START_TEST(test_clone)
|
||||
@@ -505,10 +505,10 @@ Suite *proposal_suite_create()
|
||||
countof(select_proposal_data));
|
||||
suite_add_tcase(s, tc);
|
||||
|
||||
tc = tcase_create("promote_dh_group");
|
||||
tcase_add_test(tc, test_promote_dh_group);
|
||||
tcase_add_test(tc, test_promote_dh_group_already_front);
|
||||
tcase_add_test(tc, test_promote_dh_group_not_contained);
|
||||
tc = tcase_create("promote_ke_method");
|
||||
tcase_add_test(tc, test_promote_ke_method);
|
||||
tcase_add_test(tc, test_promote_ke_method_already_front);
|
||||
tcase_add_test(tc, test_promote_ke_method_not_contained);
|
||||
suite_add_tcase(s, tc);
|
||||
|
||||
tc = tcase_create("unknown transform types");
|
||||
|
||||
@@ -31,7 +31,7 @@ static transform_type_t tfs[] = {
|
||||
KEY_DERIVATION_FUNCTION,
|
||||
DETERMINISTIC_RANDOM_BIT_GENERATOR,
|
||||
RANDOM_NUMBER_GENERATOR,
|
||||
DIFFIE_HELLMAN_GROUP,
|
||||
KEY_EXCHANGE_METHOD,
|
||||
};
|
||||
|
||||
START_TEST(test_vectors)
|
||||
|
||||
@@ -57,7 +57,7 @@ TEST_SUITE(rng_tester_suite_create)
|
||||
TEST_SUITE_DEPEND(mgf1_sha1_suite_create, XOF, XOF_MGF1_SHA1)
|
||||
TEST_SUITE_DEPEND(mgf1_sha256_suite_create, XOF, XOF_MGF1_SHA256)
|
||||
TEST_SUITE_DEPEND(prf_plus_suite_create, KDF, KDF_PRF_PLUS)
|
||||
TEST_SUITE_DEPEND(ntru_suite_create, DH, NTRU_112_BIT)
|
||||
TEST_SUITE_DEPEND(ntru_suite_create, KE, NTRU_112_BIT)
|
||||
TEST_SUITE_DEPEND(fetch_http_suite_create, FETCHER, "http://")
|
||||
TEST_SUITE_DEPEND(ed25519_suite_create, PRIVKEY_GEN, KEY_ED25519)
|
||||
TEST_SUITE_DEPEND(ed448_suite_create, PRIVKEY_GEN, KEY_ED448)
|
||||
|
||||
Reference in New Issue
Block a user