aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcharon/tests
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2016-12-15 18:22:11 +0100
committerTobias Brunner <tobias@strongswan.org>2017-02-06 11:14:31 +0100
commit22f13dcecdd7c788cf5cbf9533d2fb7a1f8317f5 (patch)
tree6a2923cc8dc9a3748c853f3656276e19ea267e87 /src/libcharon/tests
parentb062d3cc4463ae632f6e4f10d7981b60a290d458 (diff)
downloadstrongswan-22f13dcecdd7c788cf5cbf9533d2fb7a1f8317f5.tar.bz2
strongswan-22f13dcecdd7c788cf5cbf9533d2fb7a1f8317f5.tar.xz
proposal: Copy SPI and proposal number from correct proposal in select()
If charon.prefer_configured_proposals is disabled select() is called on the received proposal. This incorrectly set the SPI to 0 as the configured proposal has no SPI set. Fixes #2190.
Diffstat (limited to 'src/libcharon/tests')
-rw-r--r--src/libcharon/tests/suites/test_proposal.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/libcharon/tests/suites/test_proposal.c b/src/libcharon/tests/suites/test_proposal.c
index 19f4cd1e1..f1591794a 100644
--- a/src/libcharon/tests/suites/test_proposal.c
+++ b/src/libcharon/tests/suites/test_proposal.c
@@ -108,7 +108,7 @@ START_TEST(test_select)
select_data[_i].self);
other = proposal_create_from_string(select_data[_i].proto,
select_data[_i].other);
- selected = self->select(self, other, FALSE);
+ selected = self->select(self, other, TRUE, FALSE);
if (select_data[_i].expected)
{
expected = proposal_create_from_string(select_data[_i].proto,
@@ -128,6 +128,29 @@ START_TEST(test_select)
}
END_TEST
+START_TEST(test_select_spi)
+{
+ proposal_t *self, *other, *selected;
+
+ self = proposal_create_from_string(PROTO_ESP, "aes128-sha256-modp3072");
+ other = proposal_create_from_string(PROTO_ESP, "aes128-sha256-modp3072");
+ other->set_spi(other, 0x12345678);
+
+ selected = self->select(self, other, TRUE, FALSE);
+ ck_assert(selected);
+ ck_assert_int_eq(selected->get_spi(selected), other->get_spi(other));
+ selected->destroy(selected);
+
+ selected = self->select(self, other, FALSE, FALSE);
+ ck_assert(selected);
+ ck_assert_int_eq(selected->get_spi(selected), self->get_spi(self));
+ selected->destroy(selected);
+
+ other->destroy(other);
+ self->destroy(self);
+}
+END_TEST
+
Suite *proposal_suite_create()
{
Suite *s;
@@ -141,6 +164,7 @@ Suite *proposal_suite_create()
tc = tcase_create("select");
tcase_add_loop_test(tc, test_select, 0, countof(select_data));
+ tcase_add_test(tc, test_select_spi);
suite_add_tcase(s, tc);
return s;