diffie-hellman: Add a bool return value to get_my_public_value()
This commit is contained in:
@@ -1077,14 +1077,14 @@ START_TEST(test_ntru_ke)
|
||||
ck_assert(i_ntru != NULL);
|
||||
ck_assert(i_ntru->get_dh_group(i_ntru) == params[k].group);
|
||||
|
||||
i_ntru->get_my_public_value(i_ntru, &pub_key);
|
||||
ck_assert(i_ntru->get_my_public_value(i_ntru, &pub_key));
|
||||
ck_assert(pub_key.len > 0);
|
||||
|
||||
r_ntru = lib->crypto->create_dh(lib->crypto, params[k].group);
|
||||
ck_assert(r_ntru != NULL);
|
||||
|
||||
r_ntru->set_other_public_value(r_ntru, pub_key);
|
||||
r_ntru->get_my_public_value(r_ntru, &cipher_text);
|
||||
ck_assert(r_ntru->get_my_public_value(r_ntru, &cipher_text));
|
||||
ck_assert(cipher_text.len > 0);
|
||||
|
||||
ck_assert(r_ntru->get_shared_secret(r_ntru, &r_shared_secret));
|
||||
@@ -1109,8 +1109,8 @@ START_TEST(test_ntru_retransmission)
|
||||
chunk_t pub_key1, pub_key2;
|
||||
|
||||
i_ntru = lib->crypto->create_dh(lib->crypto, NTRU_256_BIT);
|
||||
i_ntru->get_my_public_value(i_ntru, &pub_key1);
|
||||
i_ntru->get_my_public_value(i_ntru, &pub_key2);
|
||||
ck_assert(i_ntru->get_my_public_value(i_ntru, &pub_key1));
|
||||
ck_assert(i_ntru->get_my_public_value(i_ntru, &pub_key2));
|
||||
ck_assert(chunk_equals(pub_key1, pub_key2));
|
||||
|
||||
chunk_free(&pub_key1);
|
||||
@@ -1137,7 +1137,7 @@ START_TEST(test_ntru_pubkey_oid)
|
||||
|
||||
r_ntru = lib->crypto->create_dh(lib->crypto, NTRU_128_BIT);
|
||||
r_ntru->set_other_public_value(r_ntru, oid_tests[_i]);
|
||||
r_ntru->get_my_public_value(r_ntru, &cipher_text);
|
||||
ck_assert(r_ntru->get_my_public_value(r_ntru, &cipher_text));
|
||||
ck_assert(cipher_text.len == 0);
|
||||
r_ntru->destroy(r_ntru);
|
||||
}
|
||||
@@ -1152,14 +1152,14 @@ START_TEST(test_ntru_wrong_set)
|
||||
"libstrongswan.plugins.ntru.parameter_set",
|
||||
"x9_98_bandwidth");
|
||||
i_ntru = lib->crypto->create_dh(lib->crypto, NTRU_112_BIT);
|
||||
i_ntru->get_my_public_value(i_ntru, &pub_key);
|
||||
ck_assert(i_ntru->get_my_public_value(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);
|
||||
r_ntru->set_other_public_value(r_ntru, pub_key);
|
||||
r_ntru->get_my_public_value(r_ntru, &cipher_text);
|
||||
ck_assert(r_ntru->get_my_public_value(r_ntru, &cipher_text));
|
||||
ck_assert(cipher_text.len == 0);
|
||||
|
||||
chunk_free(&pub_key);
|
||||
@@ -1190,7 +1190,7 @@ START_TEST(test_ntru_ciphertext)
|
||||
for (i = 0; i < countof(test); i++)
|
||||
{
|
||||
i_ntru = lib->crypto->create_dh(lib->crypto, NTRU_128_BIT);
|
||||
i_ntru->get_my_public_value(i_ntru, &pub_key);
|
||||
ck_assert(i_ntru->get_my_public_value(i_ntru, &pub_key));
|
||||
i_ntru->set_other_public_value(i_ntru, test[i]);
|
||||
ck_assert(!i_ntru->get_shared_secret(i_ntru, &shared_secret));
|
||||
ck_assert(shared_secret.len == 0);
|
||||
@@ -1210,10 +1210,10 @@ START_TEST(test_ntru_wrong_ciphertext)
|
||||
r_ntru = lib->crypto->create_dh(lib->crypto, NTRU_128_BIT);
|
||||
m_ntru = lib->crypto->create_dh(lib->crypto, NTRU_128_BIT);
|
||||
|
||||
i_ntru->get_my_public_value(i_ntru, &pub_key_i);
|
||||
m_ntru->get_my_public_value(m_ntru, &pub_key_m);
|
||||
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));
|
||||
r_ntru->set_other_public_value(r_ntru, pub_key_m);
|
||||
r_ntru->get_my_public_value(r_ntru, &cipher_text);
|
||||
ck_assert(r_ntru->get_my_public_value(r_ntru, &cipher_text));
|
||||
i_ntru->set_other_public_value(i_ntru, cipher_text);
|
||||
ck_assert(!i_ntru->get_shared_secret(i_ntru, &shared_secret));
|
||||
ck_assert(shared_secret.len == 0);
|
||||
|
||||
Reference in New Issue
Block a user