diff options
author | Martin Willi <martin@strongswan.org> | 2006-06-15 11:09:11 +0000 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2006-06-15 11:09:11 +0000 |
commit | c095388f7f04930171eca643f29db972ec7d9ed5 (patch) | |
tree | 07acc62917bfd4a95a3a7fca76afa6431587c974 /src/charon/testing/proposal_test.c | |
parent | 3efbf983124b6cd89087a3967bdfdfe0ccc607e3 (diff) | |
download | strongswan-c095388f7f04930171eca643f29db972ec7d9ed5.tar.bz2 strongswan-c095388f7f04930171eca643f29db972ec7d9ed5.tar.xz |
added support for "ike" and "esp" keywords
fixed bugs in proposal code
algorithm selection for charon works now with ipsec.conf
a lot of other fixes
Diffstat (limited to 'src/charon/testing/proposal_test.c')
-rw-r--r-- | src/charon/testing/proposal_test.c | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/src/charon/testing/proposal_test.c b/src/charon/testing/proposal_test.c index 7adad91f5..d25573e84 100644 --- a/src/charon/testing/proposal_test.c +++ b/src/charon/testing/proposal_test.c @@ -32,15 +32,15 @@ */ void test_proposal(protected_tester_t *tester) { - proposal_t *proposal1, *proposal2, *proposal3; + proposal_t *proposal1, *proposal2, *proposal3, *proposal4; iterator_t *iterator; algorithm_t *algo; bool result; proposal1 = proposal_create(PROTO_ESP); proposal1->add_algorithm(proposal1, ENCRYPTION_ALGORITHM, ENCR_3DES, 0); - proposal1->add_algorithm(proposal1, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 32); - proposal1->add_algorithm(proposal1, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 16); + proposal1->add_algorithm(proposal1, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 256); + proposal1->add_algorithm(proposal1, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 128); proposal1->add_algorithm(proposal1, ENCRYPTION_ALGORITHM, ENCR_BLOWFISH, 0); proposal1->add_algorithm(proposal1, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 0); proposal1->add_algorithm(proposal1, INTEGRITY_ALGORITHM, AUTH_HMAC_MD5_96, 0); @@ -49,8 +49,9 @@ void test_proposal(protected_tester_t *tester) proposal2 = proposal_create(PROTO_ESP); proposal2->add_algorithm(proposal2, ENCRYPTION_ALGORITHM, ENCR_3IDEA, 0); - proposal2->add_algorithm(proposal2, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 0); + proposal2->add_algorithm(proposal2, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 128); proposal2->add_algorithm(proposal2, INTEGRITY_ALGORITHM, AUTH_HMAC_MD5_96, 0); + proposal2->add_algorithm(proposal2, DIFFIE_HELLMAN_GROUP, MODP_1024_BIT, 0); /* ah and esp prop */ proposal3 = proposal1->select(proposal1, proposal2); @@ -60,13 +61,12 @@ void test_proposal(protected_tester_t *tester) result = proposal3->get_algorithm(proposal3, ENCRYPTION_ALGORITHM, &algo); tester->assert_true(tester, result, "encryption algo select"); tester->assert_true(tester, algo->algorithm == ENCR_AES_CBC, "encryption algo"); - tester->assert_true(tester, algo->key_size == 16, "encryption keylen"); + tester->assert_true(tester, algo->key_size == 128, "encryption keylen"); result = proposal3->get_algorithm(proposal3, INTEGRITY_ALGORITHM, &algo); tester->assert_true(tester, result, "integrity algo select"); tester->assert_true(tester, algo->algorithm == AUTH_HMAC_MD5_96, "integrity algo"); - tester->assert_true(tester, algo->key_size == 16, "integrity keylen"); iterator = proposal3->create_algorithm_iterator(proposal3, INTEGRITY_ALGORITHM); tester->assert_false(tester, iterator == NULL, "integrity algo select"); @@ -74,7 +74,6 @@ void test_proposal(protected_tester_t *tester) { iterator->current(iterator, (void**)&algo); tester->assert_true(tester, algo->algorithm == AUTH_HMAC_MD5_96, "integrity algo"); - tester->assert_true(tester, algo->key_size == 16, "integrity keylen"); } iterator->destroy(iterator); proposal3->destroy(proposal3); @@ -82,5 +81,25 @@ void test_proposal(protected_tester_t *tester) proposal1->destroy(proposal1); proposal2->destroy(proposal2); + + /* from string tests */ + + proposal1 = proposal_create_from_string(PROTO_ESP, "3des-md5!"); + proposal2 = proposal_create_from_string(PROTO_ESP, "3des-md5-modp1024!"); + proposal3 = proposal_create_from_string(PROTO_ESP, "aes256-sha1"); + + proposal4 = proposal1->select(proposal1, proposal2); + tester->assert_true(tester, proposal4 == NULL, "from string 1"); + + proposal4 = proposal1->select(proposal1, proposal3); + tester->assert_true(tester, proposal4 != NULL, "from string 2"); + + result = proposal4->get_algorithm(proposal4, ENCRYPTION_ALGORITHM, &algo); + tester->assert_true(tester, result, "from string 3"); + tester->assert_true(tester, algo->algorithm == ENCR_3DES, "from string 4"); + result = proposal4->get_algorithm(proposal4, INTEGRITY_ALGORITHM, &algo); + tester->assert_true(tester, result, "from string 5"); + tester->assert_true(tester, algo->algorithm == AUTH_HMAC_MD5_96, "from string 6"); + return; } |