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
This commit is contained in:
Martin Willi
2006-06-15 11:09:11 +00:00
parent 3efbf98312
commit c095388f7f
17 changed files with 374 additions and 97 deletions
+26 -7
View File
@@ -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;
}
+1 -1
View File
@@ -252,7 +252,7 @@ int main()
tester_t *tester = tester_create(test_output, FALSE);
//tester->perform_tests(tester,all_tests);
tester->perform_test(tester,&kernel_interface_test);
tester->perform_test(tester,&proposal_test);
tester->destroy(tester);