proposal: Compare algorithms of all transform types for equality
This commit is contained in:
@@ -527,16 +527,27 @@ METHOD(proposal_t, get_number, u_int,
|
|||||||
METHOD(proposal_t, equals, bool,
|
METHOD(proposal_t, equals, bool,
|
||||||
private_proposal_t *this, proposal_t *other)
|
private_proposal_t *this, proposal_t *other)
|
||||||
{
|
{
|
||||||
|
transform_type_t type;
|
||||||
|
array_t *types;
|
||||||
|
int i;
|
||||||
|
|
||||||
if (&this->public == other)
|
if (&this->public == other)
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
return (
|
|
||||||
algo_list_equals(this, other, ENCRYPTION_ALGORITHM) &&
|
types = merge_types(this, (private_proposal_t*)other);
|
||||||
algo_list_equals(this, other, INTEGRITY_ALGORITHM) &&
|
for (i = 0; i < array_count(types); i++)
|
||||||
algo_list_equals(this, other, PSEUDO_RANDOM_FUNCTION) &&
|
{
|
||||||
algo_list_equals(this, other, DIFFIE_HELLMAN_GROUP) &&
|
array_get(types, i, &type);
|
||||||
algo_list_equals(this, other, EXTENDED_SEQUENCE_NUMBERS));
|
if (!algo_list_equals(this, other, type))
|
||||||
|
{
|
||||||
|
array_destroy(types);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
array_destroy(types);
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
METHOD(proposal_t, clone_, proposal_t*,
|
METHOD(proposal_t, clone_, proposal_t*,
|
||||||
|
|||||||
@@ -212,6 +212,23 @@ START_TEST(test_unknown_transform_types_print)
|
|||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(test_unknown_transform_types_equals)
|
||||||
|
{
|
||||||
|
proposal_t *self, *other;
|
||||||
|
|
||||||
|
self = proposal_create_from_string(PROTO_IKE, "aes128-sha256-ecp256");
|
||||||
|
other = proposal_create_from_string(PROTO_IKE, "aes128-sha256-ecp256");
|
||||||
|
other->add_algorithm(other, 242, 42, 0);
|
||||||
|
ck_assert(!self->equals(self, other));
|
||||||
|
ck_assert(!other->equals(other, self));
|
||||||
|
self->add_algorithm(self, 242, 42, 0);
|
||||||
|
ck_assert(self->equals(self, other));
|
||||||
|
ck_assert(other->equals(other, self));
|
||||||
|
other->destroy(other);
|
||||||
|
self->destroy(self);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
START_TEST(test_unknown_transform_types_select_fail)
|
START_TEST(test_unknown_transform_types_select_fail)
|
||||||
{
|
{
|
||||||
proposal_t *self, *other, *selected;
|
proposal_t *self, *other, *selected;
|
||||||
@@ -288,6 +305,7 @@ Suite *proposal_suite_create()
|
|||||||
|
|
||||||
tc = tcase_create("unknown transform types");
|
tc = tcase_create("unknown transform types");
|
||||||
tcase_add_test(tc, test_unknown_transform_types_print);
|
tcase_add_test(tc, test_unknown_transform_types_print);
|
||||||
|
tcase_add_test(tc, test_unknown_transform_types_equals);
|
||||||
tcase_add_test(tc, test_unknown_transform_types_select_fail);
|
tcase_add_test(tc, test_unknown_transform_types_select_fail);
|
||||||
tcase_add_test(tc, test_unknown_transform_types_select_fail_subtype);
|
tcase_add_test(tc, test_unknown_transform_types_select_fail_subtype);
|
||||||
tcase_add_test(tc, test_unknown_transform_types_select_success);
|
tcase_add_test(tc, test_unknown_transform_types_select_success);
|
||||||
|
|||||||
Reference in New Issue
Block a user