further work for rekeying:
get liftimes from policy added new state initiation of rekeying done proposal redone: removed support for AH+ESP proposals
This commit is contained in:
@@ -29,7 +29,7 @@ $(top_srcdir)/src/charon/ke_payload.o $(top_srcdir)/src/charon/unknown_payload.o
|
||||
$(top_srcdir)/src/charon/delete_payload.o $(top_srcdir)/src/charon/sa_payload.o $(top_srcdir)/src/charon/certreq_payload.o $(top_srcdir)/src/charon/vendor_id_payload.o \
|
||||
$(top_srcdir)/src/charon/proposal_substructure.o $(top_srcdir)/src/charon/payload.o $(top_srcdir)/src/charon/message.o $(top_srcdir)/src/charon/generator.o \
|
||||
$(top_srcdir)/src/charon/parser.o $(top_srcdir)/src/charon/packet.o $(top_srcdir)/src/charon/socket.o $(top_srcdir)/src/charon/job.o \
|
||||
$(top_srcdir)/src/charon/delete_child_sa_job.o $(top_srcdir)/src/charon/rekey_child_sa_job.o \
|
||||
$(top_srcdir)/src/charon/delete_child_sa_job.o $(top_srcdir)/src/charon/rekey_child_sa_job.o $(top_srcdir)/src/charon/create_child_sa_requested.o \
|
||||
$(top_srcdir)/src/charon/delete_established_ike_sa_job.o $(top_srcdir)/src/charon/incoming_packet_job.o $(top_srcdir)/src/charon/delete_half_open_ike_sa_job.o \
|
||||
$(top_srcdir)/src/charon/retransmit_request_job.o $(top_srcdir)/src/charon/initiate_ike_sa_job.o $(top_srcdir)/src/charon/job_queue.o $(top_srcdir)/src/charon/event_queue.o \
|
||||
$(top_srcdir)/src/charon/send_queue.o $(top_srcdir)/src/charon/kernel_interface.o $(top_srcdir)/src/charon/thread_pool.o $(top_srcdir)/src/charon/scheduler.o \
|
||||
|
||||
@@ -49,14 +49,14 @@ void test_child_sa(protected_tester_t *tester)
|
||||
remote_me = host_create(AF_INET, "192.168.0.3", 0);
|
||||
remote_other = host_create(AF_INET, "192.168.0.4", 0);
|
||||
|
||||
local_sa = child_sa_create(local_me, local_other);
|
||||
remote_sa = child_sa_create(remote_me, remote_other);
|
||||
local_sa = child_sa_create(local_me, local_other, 5, 10);
|
||||
remote_sa = child_sa_create(remote_me, remote_other, 5, 10);
|
||||
|
||||
proposal1 = proposal_create(1);
|
||||
proposal1->add_algorithm(proposal1, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 16);
|
||||
proposal1 = proposal_create(PROTO_ESP);
|
||||
proposal1->add_algorithm(proposal1, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 16);
|
||||
|
||||
proposal2 = proposal_create(2);
|
||||
proposal2->add_algorithm(proposal2, PROTO_AH, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 0);
|
||||
proposal2 = proposal_create(PROTO_AH);
|
||||
proposal2->add_algorithm(proposal2, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 0);
|
||||
|
||||
list = linked_list_create();
|
||||
list->insert_last(list, proposal1);
|
||||
|
||||
@@ -37,29 +37,29 @@ void test_connection(protected_tester_t *tester)
|
||||
proposal_t *prop1, *prop2, *prop3, *prop4;
|
||||
linked_list_t *list;
|
||||
|
||||
prop1 = proposal_create(1);
|
||||
prop1->add_algorithm(prop1, PROTO_IKE, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 20);
|
||||
prop1->add_algorithm(prop1, PROTO_IKE, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 20);
|
||||
prop1->add_algorithm(prop1, PROTO_IKE, PSEUDO_RANDOM_FUNCTION, PRF_HMAC_SHA1, 20);
|
||||
prop1->add_algorithm(prop1, PROTO_IKE, DIFFIE_HELLMAN_GROUP, MODP_2048_BIT, 0);
|
||||
prop1 = proposal_create(PROTO_IKE);
|
||||
prop1->add_algorithm(prop1, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 20);
|
||||
prop1->add_algorithm(prop1, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 20);
|
||||
prop1->add_algorithm(prop1, PSEUDO_RANDOM_FUNCTION, PRF_HMAC_SHA1, 20);
|
||||
prop1->add_algorithm(prop1, DIFFIE_HELLMAN_GROUP, MODP_2048_BIT, 0);
|
||||
|
||||
prop2 = proposal_create(2);
|
||||
prop2->add_algorithm(prop2, PROTO_IKE, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 20);
|
||||
prop2->add_algorithm(prop2, PROTO_IKE, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 20);
|
||||
prop2->add_algorithm(prop2, PROTO_IKE, PSEUDO_RANDOM_FUNCTION, PRF_HMAC_MD5, 20);
|
||||
prop2->add_algorithm(prop2, PROTO_IKE, DIFFIE_HELLMAN_GROUP, MODP_1024_BIT, 0);
|
||||
prop2 = proposal_create(PROTO_IKE);
|
||||
prop2->add_algorithm(prop2, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 20);
|
||||
prop2->add_algorithm(prop2, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 20);
|
||||
prop2->add_algorithm(prop2, PSEUDO_RANDOM_FUNCTION, PRF_HMAC_MD5, 20);
|
||||
prop2->add_algorithm(prop2, DIFFIE_HELLMAN_GROUP, MODP_1024_BIT, 0);
|
||||
|
||||
prop3 = proposal_create(3);
|
||||
prop3->add_algorithm(prop3, PROTO_IKE, ENCRYPTION_ALGORITHM, ENCR_DES, 20);
|
||||
prop3->add_algorithm(prop3, PROTO_IKE, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 20);
|
||||
prop3->add_algorithm(prop3, PROTO_IKE, PSEUDO_RANDOM_FUNCTION, PRF_HMAC_MD5, 20);
|
||||
prop3->add_algorithm(prop3, PROTO_IKE, DIFFIE_HELLMAN_GROUP, MODP_768_BIT, 0);
|
||||
prop3 = proposal_create(PROTO_IKE);
|
||||
prop3->add_algorithm(prop3, ENCRYPTION_ALGORITHM, ENCR_DES, 20);
|
||||
prop3->add_algorithm(prop3, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 20);
|
||||
prop3->add_algorithm(prop3, PSEUDO_RANDOM_FUNCTION, PRF_HMAC_MD5, 20);
|
||||
prop3->add_algorithm(prop3, DIFFIE_HELLMAN_GROUP, MODP_768_BIT, 0);
|
||||
|
||||
prop4 = proposal_create(4);
|
||||
prop4->add_algorithm(prop4, PROTO_IKE, ENCRYPTION_ALGORITHM, ENCR_3DES, 20);
|
||||
prop4->add_algorithm(prop4, PROTO_IKE, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 20);
|
||||
prop4->add_algorithm(prop4, PROTO_IKE, PSEUDO_RANDOM_FUNCTION, PRF_HMAC_TIGER, 20);
|
||||
prop4->add_algorithm(prop4, PROTO_IKE, DIFFIE_HELLMAN_GROUP, MODP_768_BIT, 0);
|
||||
prop4 = proposal_create(PROTO_IKE);
|
||||
prop4->add_algorithm(prop4, ENCRYPTION_ALGORITHM, ENCR_3DES, 20);
|
||||
prop4->add_algorithm(prop4, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 20);
|
||||
prop4->add_algorithm(prop4, PSEUDO_RANDOM_FUNCTION, PRF_HMAC_TIGER, 20);
|
||||
prop4->add_algorithm(prop4, DIFFIE_HELLMAN_GROUP, MODP_768_BIT, 0);
|
||||
|
||||
connection->add_proposal(connection, prop1);
|
||||
connection->add_proposal(connection, prop2);
|
||||
|
||||
@@ -568,17 +568,17 @@ void test_generator_with_sa_payload(protected_tester_t *tester)
|
||||
tester->assert_true(tester,(generator != NULL), "generator create check");
|
||||
|
||||
|
||||
proposal1 = proposal_create(1);
|
||||
proposal1->add_algorithm(proposal1, PROTO_IKE, ENCRYPTION_ALGORITHM, 1, 20);
|
||||
proposal1->add_algorithm(proposal1, PROTO_IKE, PSEUDO_RANDOM_FUNCTION, 2, 22);
|
||||
proposal1->add_algorithm(proposal1, PROTO_IKE, INTEGRITY_ALGORITHM, 3, 24);
|
||||
proposal1->add_algorithm(proposal1, PROTO_IKE, DIFFIE_HELLMAN_GROUP, 4, 0);
|
||||
proposal1 = proposal_create(PROTO_IKE);
|
||||
proposal1->add_algorithm(proposal1, ENCRYPTION_ALGORITHM, 1, 20);
|
||||
proposal1->add_algorithm(proposal1, PSEUDO_RANDOM_FUNCTION, 2, 22);
|
||||
proposal1->add_algorithm(proposal1, INTEGRITY_ALGORITHM, 3, 24);
|
||||
proposal1->add_algorithm(proposal1, DIFFIE_HELLMAN_GROUP, 4, 0);
|
||||
|
||||
proposal2 = proposal_create(2);
|
||||
proposal2->add_algorithm(proposal2, PROTO_IKE, ENCRYPTION_ALGORITHM, 5, 26);
|
||||
proposal2->add_algorithm(proposal2, PROTO_IKE, PSEUDO_RANDOM_FUNCTION, 6, 28);
|
||||
proposal2->add_algorithm(proposal2, PROTO_IKE, INTEGRITY_ALGORITHM, 7, 30);
|
||||
proposal2->add_algorithm(proposal2, PROTO_IKE, DIFFIE_HELLMAN_GROUP, 8, 0);
|
||||
proposal2 = proposal_create(PROTO_IKE);
|
||||
proposal2->add_algorithm(proposal2, ENCRYPTION_ALGORITHM, 5, 26);
|
||||
proposal2->add_algorithm(proposal2, PSEUDO_RANDOM_FUNCTION, 6, 28);
|
||||
proposal2->add_algorithm(proposal2, INTEGRITY_ALGORITHM, 7, 30);
|
||||
proposal2->add_algorithm(proposal2, DIFFIE_HELLMAN_GROUP, 8, 0);
|
||||
|
||||
list = linked_list_create();
|
||||
list->insert_last(list, (void*)proposal1);
|
||||
@@ -630,121 +630,7 @@ void test_generator_with_sa_payload(protected_tester_t *tester)
|
||||
proposal1->destroy(proposal1);
|
||||
proposal2->destroy(proposal2);
|
||||
chunk_free(&generated_data);
|
||||
generator->destroy(generator);
|
||||
|
||||
|
||||
/* --------------------------- */
|
||||
/* test with automatic created child proposals */
|
||||
|
||||
generator = generator_create();
|
||||
tester->assert_true(tester,(generator != NULL), "generator create check");
|
||||
|
||||
|
||||
proposal1 = proposal_create(1);
|
||||
|
||||
proposal1->add_algorithm(proposal1, PROTO_AH, INTEGRITY_ALGORITHM, AUTH_HMAC_MD5_96, 20);
|
||||
proposal1->add_algorithm(proposal1, PROTO_AH, DIFFIE_HELLMAN_GROUP, MODP_2048_BIT, 0);
|
||||
proposal1->add_algorithm(proposal1, PROTO_AH, EXTENDED_SEQUENCE_NUMBERS, EXT_SEQ_NUMBERS, 0);
|
||||
proposal1->set_spi(proposal1, PROTO_AH, 0x01010101l);
|
||||
|
||||
proposal1->add_algorithm(proposal1, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 20);
|
||||
proposal1->add_algorithm(proposal1, PROTO_ESP, DIFFIE_HELLMAN_GROUP, MODP_1024_BIT, 0);
|
||||
proposal1->set_spi(proposal1, PROTO_ESP, 0x02020202);
|
||||
|
||||
|
||||
proposal2->add_algorithm(proposal2, PROTO_AH, INTEGRITY_ALGORITHM, AUTH_HMAC_MD5_96, 20);
|
||||
proposal2->add_algorithm(proposal2, PROTO_AH, DIFFIE_HELLMAN_GROUP, MODP_2048_BIT, 0);
|
||||
proposal2->add_algorithm(proposal2, PROTO_AH, EXTENDED_SEQUENCE_NUMBERS, EXT_SEQ_NUMBERS, 0);
|
||||
proposal2->set_spi(proposal2, PROTO_AH, 0x01010101);
|
||||
|
||||
proposal2->add_algorithm(proposal2, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 32);
|
||||
proposal2->add_algorithm(proposal2, PROTO_ESP, INTEGRITY_ALGORITHM, AUTH_HMAC_MD5_96, 20);
|
||||
proposal2->add_algorithm(proposal2, PROTO_ESP, DIFFIE_HELLMAN_GROUP, MODP_1024_BIT, 0);
|
||||
proposal2->set_spi(proposal2, PROTO_ESP, 0x02020202);
|
||||
|
||||
list->insert_last(list, (void*)proposal1);
|
||||
list->insert_last(list, (void*)proposal2);
|
||||
|
||||
sa_payload = sa_payload_create_from_proposal_list(list);
|
||||
tester->assert_true(tester,(sa_payload != NULL), "sa_payload create check");
|
||||
|
||||
generator->generate_payload(generator,(payload_t *)sa_payload);
|
||||
generator->write_to_chunk(generator,&generated_data);
|
||||
logger->log_chunk(logger,RAW,"generated",generated_data);
|
||||
|
||||
u_int8_t expected_generation3[] = {
|
||||
0x00,0x00,0x00,0xA0, /* payload header*/
|
||||
|
||||
/* suite 1 */
|
||||
0x02,0x00,0x00,0x28, /* a proposal */
|
||||
0x01,0x02,0x04,0x03,
|
||||
0x01,0x01,0x01,0x01,
|
||||
0x03,0x00,0x00,0x0C, /* transform 1 */
|
||||
0x03,0x00,0x00,0x01,
|
||||
0x80,0x0E,0x00,0x14, /* keylength attribute with 20 bytes length */
|
||||
|
||||
0x03,0x00,0x00,0x08, /* transform 2 */
|
||||
0x04,0x00,0x00,0x0E,
|
||||
|
||||
0x00,0x00,0x00,0x08, /* transform 3 */
|
||||
0x05,0x00,0x00,0x01,
|
||||
|
||||
|
||||
0x02,0x00,0x00,0x20, /* a proposal */
|
||||
0x01,0x03,0x04,0x02,
|
||||
0x02,0x02,0x02,0x02,
|
||||
|
||||
0x03,0x00,0x00,0x0C, /* transform 1 */
|
||||
0x01,0x00,0x00,0x0C,
|
||||
0x80,0x0E,0x00,0x20, /* keylength attribute with 32 bytes length */
|
||||
|
||||
0x00,0x00,0x00,0x08, /* transform 2 */
|
||||
0x04,0x00,0x00,0x02,
|
||||
|
||||
/* suite 2 */
|
||||
0x02,0x00,0x00,0x28, /* a proposal */
|
||||
0x02,0x02,0x04,0x03,
|
||||
0x01,0x01,0x01,0x01,
|
||||
0x03,0x00,0x00,0x0C, /* transform 1 */
|
||||
0x03,0x00,0x00,0x01,
|
||||
0x80,0x0E,0x00,0x14, /* keylength attribute with 20 bytes length */
|
||||
|
||||
0x03,0x00,0x00,0x08, /* transform 2 */
|
||||
0x04,0x00,0x00,0x0E,
|
||||
|
||||
0x00,0x00,0x00,0x08, /* transform 3 */
|
||||
0x05,0x00,0x00,0x01,
|
||||
|
||||
|
||||
0x00,0x00,0x00,0x2C, /* a proposal */
|
||||
0x02,0x03,0x04,0x03,
|
||||
0x02,0x02,0x02,0x02,
|
||||
|
||||
0x03,0x00,0x00,0x0C, /* transform 1 */
|
||||
0x01,0x00,0x00,0x0C,
|
||||
0x80,0x0E,0x00,0x20, /* keylength attribute with 32 bytes length */
|
||||
|
||||
0x03,0x00,0x00,0x0C, /* transform 2 */
|
||||
0x03,0x00,0x00,0x01,
|
||||
0x80,0x0E,0x00,0x14, /* keylength attribute with 20 bytes length */
|
||||
|
||||
0x00,0x00,0x00,0x08, /* transform 3 */
|
||||
0x04,0x00,0x00,0x02,
|
||||
|
||||
};
|
||||
|
||||
|
||||
logger->log_bytes(logger,RAW,"expected",expected_generation3,sizeof(expected_generation3));
|
||||
|
||||
tester->assert_true(tester,(memcmp(expected_generation3,generated_data.ptr,sizeof(expected_generation3)) == 0), "compare generated data");
|
||||
|
||||
sa_payload->destroy(sa_payload);
|
||||
proposal1->destroy(proposal1);
|
||||
proposal2->destroy(proposal2);
|
||||
list->destroy(list);
|
||||
chunk_free(&generated_data);
|
||||
generator->destroy(generator);
|
||||
|
||||
generator->destroy(generator);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -819,16 +705,12 @@ void test_generator_with_notify_payload(protected_tester_t *tester)
|
||||
|
||||
notify_payload = notify_payload_create();
|
||||
|
||||
|
||||
spi.ptr = "12345";
|
||||
spi.len = strlen(spi.ptr);
|
||||
|
||||
notification_data.ptr = "67890";
|
||||
notification_data.len = strlen(notification_data.ptr);
|
||||
|
||||
notify_payload->set_protocol_id(notify_payload,255);
|
||||
notify_payload->set_notify_message_type(notify_payload,63333); /* Hex F765 */
|
||||
notify_payload->set_spi(notify_payload,spi);
|
||||
notify_payload->set_spi(notify_payload, 0x3132333435);
|
||||
notify_payload->set_notification_data(notify_payload,notification_data);
|
||||
|
||||
generator->generate_payload(generator,(payload_t *)notify_payload);
|
||||
|
||||
@@ -532,6 +532,7 @@ void test_parser_with_notify_payload(protected_tester_t *tester)
|
||||
notify_payload_t *notify_payload;
|
||||
status_t status;
|
||||
chunk_t notify_chunk, result;
|
||||
u_int32_t spi;
|
||||
|
||||
u_int8_t notify_bytes[] = {
|
||||
0x00,0x00,0x00,0x1C, /* payload header */
|
||||
@@ -559,8 +560,8 @@ void test_parser_with_notify_payload(protected_tester_t *tester)
|
||||
tester->assert_true(tester,(notify_payload->get_protocol_id(notify_payload) == 3), "Protocol id");
|
||||
tester->assert_true(tester,(notify_payload->get_notify_message_type(notify_payload) == 1), "notify message type");
|
||||
|
||||
result = notify_payload->get_spi(notify_payload);
|
||||
tester->assert_false(tester,(memcmp(notify_bytes + 8, result.ptr, result.len)), "parsed spi");
|
||||
spi = notify_payload->get_spi(notify_payload);
|
||||
tester->assert_false(tester, spi == 0x01020303, "parsed spi");
|
||||
|
||||
result = notify_payload->get_notification_data(notify_payload);
|
||||
tester->assert_false(tester,(memcmp(notify_bytes + 12, result.ptr, result.len)), "parsed notification data");
|
||||
|
||||
@@ -34,98 +34,90 @@
|
||||
*/
|
||||
void test_policy(protected_tester_t *tester)
|
||||
{
|
||||
policy_t *policy;
|
||||
// traffic_selector_t *ts;
|
||||
// linked_list_t *ts_stored, *ts_supplied, *ts_selected, *ts_expected;
|
||||
proposal_t *proposal1, *proposal2, *proposal3, *proposal_sel;
|
||||
linked_list_t *proposals_list;
|
||||
iterator_t *iterator;
|
||||
logger_t *logger;
|
||||
identification_t *alice, *bob;
|
||||
|
||||
logger = logger_manager->get_logger(logger_manager, TESTER);
|
||||
logger->disable_level(logger, FULL);
|
||||
|
||||
alice = identification_create_from_string("152.96.193.131");
|
||||
bob = identification_create_from_string("152.96.193.130");
|
||||
policy = policy_create("test", alice, bob);
|
||||
|
||||
tester->assert_true(tester, (policy != NULL), "policy construction");
|
||||
|
||||
|
||||
/*
|
||||
* test proposal getting and selection
|
||||
*
|
||||
*/
|
||||
|
||||
/* esp only prop */
|
||||
proposal1 = proposal_create(1);
|
||||
proposal1->add_algorithm(proposal1, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 16);
|
||||
|
||||
/* ah only prop */
|
||||
proposal2 = proposal_create(2);
|
||||
proposal2->add_algorithm(proposal2, PROTO_AH, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 20);
|
||||
|
||||
/* ah and esp prop */
|
||||
proposal3 = proposal_create(3);
|
||||
proposal3->add_algorithm(proposal3, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_3DES, 16);
|
||||
proposal3->add_algorithm(proposal3, PROTO_AH, INTEGRITY_ALGORITHM, AUTH_HMAC_MD5_96, 20);
|
||||
|
||||
|
||||
policy->add_proposal(policy, proposal1);
|
||||
policy->add_proposal(policy, proposal2);
|
||||
policy->add_proposal(policy, proposal3);
|
||||
|
||||
|
||||
proposals_list = policy->get_proposals(policy);
|
||||
tester->assert_true(tester, (proposals_list->get_count(proposals_list) == 3), "proposal count");
|
||||
|
||||
|
||||
proposals_list = linked_list_create();
|
||||
proposal1 = proposal_create(1);
|
||||
proposal1->add_algorithm(proposal1, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 32);
|
||||
proposal2 = proposal_create(2);
|
||||
proposal2->add_algorithm(proposal2, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 16);
|
||||
proposal2->add_algorithm(proposal2, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_3DES, 16);
|
||||
proposal2->add_algorithm(proposal2, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_BLOWFISH, 0);
|
||||
proposal2->add_algorithm(proposal2, PROTO_AH, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 20);
|
||||
proposal2->add_algorithm(proposal2, PROTO_AH, INTEGRITY_ALGORITHM, AUTH_HMAC_MD5_96, 20);
|
||||
|
||||
proposals_list->insert_last(proposals_list, proposal1);
|
||||
proposals_list->insert_last(proposals_list, proposal2);
|
||||
|
||||
proposal_sel = policy->select_proposal(policy, proposals_list);
|
||||
tester->assert_false(tester, proposal_sel == NULL, "proposal select");
|
||||
/* check ESP encryption algo */
|
||||
iterator = proposal_sel->create_algorithm_iterator(proposal_sel, PROTO_ESP, ENCRYPTION_ALGORITHM);
|
||||
tester->assert_false(tester, iterator == NULL, "algorithm select ESP");
|
||||
while (iterator->has_next(iterator))
|
||||
{
|
||||
algorithm_t *algo;
|
||||
iterator->current(iterator, (void**)&algo);
|
||||
tester->assert_true(tester, algo->algorithm == ENCR_3DES, "ESP encryption algo");
|
||||
tester->assert_true(tester, algo->key_size == 16, "ESP encryption keysize");
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
iterator = proposal_sel->create_algorithm_iterator(proposal_sel, PROTO_AH, INTEGRITY_ALGORITHM);
|
||||
/* check AH integrity algo */
|
||||
tester->assert_false(tester, iterator == NULL, "algorithm select AH");
|
||||
while (iterator->has_next(iterator))
|
||||
{
|
||||
algorithm_t *algo;
|
||||
iterator->current(iterator, (void**)&algo);
|
||||
tester->assert_true(tester, algo->algorithm == AUTH_HMAC_MD5_96, "ESP encryption algo");
|
||||
tester->assert_true(tester, algo->key_size == 20, "ESP encryption keysize");
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
|
||||
proposal_sel->destroy(proposal_sel);
|
||||
|
||||
/* cleanup */
|
||||
proposal1->destroy(proposal1);
|
||||
proposal1->destroy(proposal2);
|
||||
proposals_list->destroy(proposals_list);
|
||||
|
||||
// policy_t *policy;
|
||||
// // traffic_selector_t *ts;
|
||||
// // linked_list_t *ts_stored, *ts_supplied, *ts_selected, *ts_expected;
|
||||
// proposal_t *proposal1, *proposal2, *proposal3, *proposal_sel;
|
||||
// linked_list_t *proposals_list;
|
||||
// iterator_t *iterator;
|
||||
// logger_t *logger;
|
||||
// identification_t *alice, *bob;
|
||||
//
|
||||
// logger = logger_manager->get_logger(logger_manager, TESTER);
|
||||
// logger->disable_level(logger, FULL);
|
||||
//
|
||||
// alice = identification_create_from_string("152.96.193.131");
|
||||
// bob = identification_create_from_string("152.96.193.130");
|
||||
// policy = policy_create("test", alice, bob);
|
||||
//
|
||||
// tester->assert_true(tester, (policy != NULL), "policy construction");
|
||||
//
|
||||
//
|
||||
// /*
|
||||
// * test proposal getting and selection
|
||||
// *
|
||||
// */
|
||||
//
|
||||
// /* esp only prop */
|
||||
// proposal1 = proposal_create(PROTO_ESP);
|
||||
// proposal1->add_algorithm(proposal1, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 16);
|
||||
//
|
||||
// /* ah only prop */
|
||||
// proposal2 = proposal_create(PROTO_AH);
|
||||
// proposal2->add_algorithm(proposal2, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 20);
|
||||
//
|
||||
// policy->add_proposal(policy, proposal1);
|
||||
// policy->add_proposal(policy, proposal2);
|
||||
//
|
||||
// proposals_list = policy->get_proposals(policy);
|
||||
// tester->assert_true(tester, (proposals_list->get_count(proposals_list) == 2), "proposal count");
|
||||
//
|
||||
//
|
||||
// proposals_list = linked_list_create();
|
||||
// proposal1 = proposal_create(1);
|
||||
// proposal1->add_algorithm(proposal1, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 32);
|
||||
// proposal2 = proposal_create(2);
|
||||
// proposal2->add_algorithm(proposal2, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 16);
|
||||
// proposal2->add_algorithm(proposal2, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_3DES, 16);
|
||||
// proposal2->add_algorithm(proposal2, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_BLOWFISH, 0);
|
||||
// proposal2->add_algorithm(proposal2, PROTO_AH, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 20);
|
||||
// proposal2->add_algorithm(proposal2, PROTO_AH, INTEGRITY_ALGORITHM, AUTH_HMAC_MD5_96, 20);
|
||||
//
|
||||
// proposals_list->insert_last(proposals_list, proposal1);
|
||||
// proposals_list->insert_last(proposals_list, proposal2);
|
||||
//
|
||||
// proposal_sel = policy->select_proposal(policy, proposals_list);
|
||||
// tester->assert_false(tester, proposal_sel == NULL, "proposal select");
|
||||
// /* check ESP encryption algo */
|
||||
// iterator = proposal_sel->create_algorithm_iterator(proposal_sel, PROTO_ESP, ENCRYPTION_ALGORITHM);
|
||||
// tester->assert_false(tester, iterator == NULL, "algorithm select ESP");
|
||||
// while (iterator->has_next(iterator))
|
||||
// {
|
||||
// algorithm_t *algo;
|
||||
// iterator->current(iterator, (void**)&algo);
|
||||
// tester->assert_true(tester, algo->algorithm == ENCR_3DES, "ESP encryption algo");
|
||||
// tester->assert_true(tester, algo->key_size == 16, "ESP encryption keysize");
|
||||
// }
|
||||
// iterator->destroy(iterator);
|
||||
// iterator = proposal_sel->create_algorithm_iterator(proposal_sel, PROTO_AH, INTEGRITY_ALGORITHM);
|
||||
// /* check AH integrity algo */
|
||||
// tester->assert_false(tester, iterator == NULL, "algorithm select AH");
|
||||
// while (iterator->has_next(iterator))
|
||||
// {
|
||||
// algorithm_t *algo;
|
||||
// iterator->current(iterator, (void**)&algo);
|
||||
// tester->assert_true(tester, algo->algorithm == AUTH_HMAC_MD5_96, "ESP encryption algo");
|
||||
// tester->assert_true(tester, algo->key_size == 20, "ESP encryption keysize");
|
||||
// }
|
||||
// iterator->destroy(iterator);
|
||||
//
|
||||
// proposal_sel->destroy(proposal_sel);
|
||||
//
|
||||
// /* cleanup */
|
||||
// proposal1->destroy(proposal1);
|
||||
// proposal1->destroy(proposal2);
|
||||
// proposals_list->destroy(proposals_list);
|
||||
//
|
||||
// /*
|
||||
// * test traffic selection getting and matching
|
||||
// *
|
||||
@@ -241,6 +233,6 @@ void test_policy(protected_tester_t *tester)
|
||||
// ts_request[2]->destroy(ts_request[2]);
|
||||
// ts_reference[2]->destroy(ts_reference[2]);
|
||||
// ts_request[3]->destroy(ts_request[3]);
|
||||
|
||||
policy->destroy(policy);
|
||||
/*
|
||||
policy->destroy(policy);*/
|
||||
}
|
||||
|
||||
@@ -37,58 +37,46 @@ void test_proposal(protected_tester_t *tester)
|
||||
algorithm_t *algo;
|
||||
bool result;
|
||||
|
||||
proposal1 = proposal_create(1);
|
||||
proposal1->add_algorithm(proposal1, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_3DES, 0);
|
||||
proposal1->add_algorithm(proposal1, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 32);
|
||||
proposal1->add_algorithm(proposal1, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 16);
|
||||
proposal1->add_algorithm(proposal1, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_BLOWFISH, 0);
|
||||
proposal1->add_algorithm(proposal1, PROTO_ESP, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 20);
|
||||
proposal1->add_algorithm(proposal1, PROTO_ESP, INTEGRITY_ALGORITHM, AUTH_HMAC_MD5_96, 20);
|
||||
proposal1->add_algorithm(proposal1, PROTO_AH, DIFFIE_HELLMAN_GROUP, MODP_1024_BIT, 0);
|
||||
proposal1->add_algorithm(proposal1, PROTO_AH, DIFFIE_HELLMAN_GROUP, MODP_2048_BIT, 0);
|
||||
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_BLOWFISH, 0);
|
||||
proposal1->add_algorithm(proposal1, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 0);
|
||||
proposal1->add_algorithm(proposal1, INTEGRITY_ALGORITHM, AUTH_HMAC_MD5_96, 0);
|
||||
proposal1->add_algorithm(proposal1, DIFFIE_HELLMAN_GROUP, MODP_1024_BIT, 0);
|
||||
proposal1->add_algorithm(proposal1, DIFFIE_HELLMAN_GROUP, MODP_2048_BIT, 0);
|
||||
|
||||
proposal2 = proposal_create(2);
|
||||
proposal2->add_algorithm(proposal2, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_3IDEA, 0);
|
||||
proposal2->add_algorithm(proposal2, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 16);
|
||||
proposal2->add_algorithm(proposal2, PROTO_ESP, INTEGRITY_ALGORITHM, AUTH_HMAC_MD5_96, 20);
|
||||
proposal1->add_algorithm(proposal2, PROTO_AH, DIFFIE_HELLMAN_GROUP, MODP_1024_BIT, 0);
|
||||
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, INTEGRITY_ALGORITHM, AUTH_HMAC_MD5_96, 0);
|
||||
|
||||
/* ah and esp prop */
|
||||
proposal3 = proposal1->select(proposal1, proposal2);
|
||||
tester->assert_false(tester, proposal3 == NULL, "proposal select");
|
||||
if (proposal3)
|
||||
{
|
||||
result = proposal3->get_algorithm(proposal3, PROTO_ESP, ENCRYPTION_ALGORITHM, &algo);
|
||||
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");
|
||||
|
||||
|
||||
result = proposal3->get_algorithm(proposal3, PROTO_ESP, INTEGRITY_ALGORITHM, &algo);
|
||||
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 == 20, "integrity keylen");
|
||||
tester->assert_true(tester, algo->key_size == 16, "integrity keylen");
|
||||
|
||||
iterator = proposal3->create_algorithm_iterator(proposal3, PROTO_ESP, INTEGRITY_ALGORITHM);
|
||||
iterator = proposal3->create_algorithm_iterator(proposal3, INTEGRITY_ALGORITHM);
|
||||
tester->assert_false(tester, iterator == NULL, "integrity algo select");
|
||||
while(iterator->has_next(iterator))
|
||||
{
|
||||
iterator->current(iterator, (void**)&algo);
|
||||
tester->assert_true(tester, algo->algorithm == AUTH_HMAC_MD5_96, "integrity algo");
|
||||
tester->assert_true(tester, algo->key_size == 20, "integrity keylen");
|
||||
tester->assert_true(tester, algo->key_size == 16, "integrity keylen");
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
|
||||
iterator = proposal3->create_algorithm_iterator(proposal3, PROTO_AH, DIFFIE_HELLMAN_GROUP );
|
||||
tester->assert_false(tester, iterator == NULL, "dh group algo select");
|
||||
while(iterator->has_next(iterator))
|
||||
{
|
||||
iterator->current(iterator, (void**)&algo);
|
||||
tester->assert_true(tester, algo->algorithm == MODP_1024_BIT, "dh group algo");
|
||||
tester->assert_true(tester, algo->key_size == 0, "dh gorup keylen");
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
|
||||
proposal3->destroy(proposal3);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user