first merge of NATT code
This commit is contained in:
@@ -14,13 +14,13 @@ hasher_test.h sender_test.c certificate_test.c job_queue_test.h scheduler_test.h
|
||||
rsa_test.c sender_test.h generator_test.c aes_cbc_crypter_test.c certificate_test.h prf_plus_test.c \
|
||||
rsa_test.h generator_test.h aes_cbc_crypter_test.h send_queue_test.c
|
||||
|
||||
testing_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la -lgmp -lpthread \
|
||||
testing_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la -lgmp -lpthread -lm \
|
||||
$(top_srcdir)/src/charon/connection.o $(top_srcdir)/src/charon/local_connection_store.o $(top_srcdir)/src/charon/policy.o \
|
||||
$(top_srcdir)/src/charon/local_policy_store.o $(top_srcdir)/src/charon/local_credential_store.o $(top_srcdir)/src/charon/traffic_selector.o \
|
||||
$(top_srcdir)/src/charon/proposal.o $(top_srcdir)/src/charon/configuration.o $(top_srcdir)/src/charon/state.o $(top_srcdir)/src/charon/ike_sa_init_requested.o \
|
||||
$(top_srcdir)/src/charon/ike_sa_init_responded.o $(top_srcdir)/src/charon/ike_sa_established.o $(top_srcdir)/src/charon/responder_init.o \
|
||||
$(top_srcdir)/src/charon/initiator_init.o $(top_srcdir)/src/charon/ike_auth_requested.o $(top_srcdir)/src/charon/delete_ike_sa_requested.o \
|
||||
$(top_srcdir)/src/charon/delete_child_sa_requested.o \
|
||||
$(top_srcdir)/src/charon/delete_child_sa_requested.o $(top_srcdir)/src/charon/create_child_sa_requested.o \
|
||||
$(top_srcdir)/src/charon/child_sa.o $(top_srcdir)/src/charon/ike_sa.o $(top_srcdir)/src/charon/ike_sa_manager.o $(top_srcdir)/src/charon/ike_sa_id.o \
|
||||
$(top_srcdir)/src/charon/authenticator.o $(top_srcdir)/src/charon/encryption_payload.o $(top_srcdir)/src/charon/cert_payload.o \
|
||||
$(top_srcdir)/src/charon/traffic_selector_substructure.o $(top_srcdir)/src/charon/transform_attribute.o $(top_srcdir)/src/charon/configuration_attribute.o \
|
||||
@@ -30,7 +30,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/create_child_sa_requested.o \
|
||||
$(top_srcdir)/src/charon/delete_child_sa_job.o $(top_srcdir)/src/charon/rekey_child_sa_job.o $(top_srcdir)/src/charon/send_keepalive_job.o $(top_srcdir)/src/charon/send_dpd_job.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 \
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2006 Tobias Brunner, Daniel Roethlisberger
|
||||
* Copyright (C) 2005 Jan Hutter, Martin Willi
|
||||
* Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
@@ -34,6 +35,7 @@ void test_child_sa(protected_tester_t *tester)
|
||||
{
|
||||
proposal_t *proposal1, *proposal2;
|
||||
linked_list_t *list;
|
||||
connection_t *connection;
|
||||
host_t *local_me, *remote_me;
|
||||
host_t *local_other, *remote_other;
|
||||
child_sa_t *local_sa, *remote_sa;
|
||||
@@ -49,8 +51,8 @@ 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(0, local_me, local_other, 5, 10);
|
||||
remote_sa = child_sa_create(0, remote_me, remote_other, 5, 10);
|
||||
local_sa = child_sa_create(0, local_me, local_other, 5, 10, FALSE);
|
||||
remote_sa = child_sa_create(0, remote_me, remote_other, 5, 10, FALSE);
|
||||
|
||||
proposal1 = proposal_create(PROTO_ESP);
|
||||
proposal1->add_algorithm(proposal1, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 16);
|
||||
|
||||
@@ -710,7 +710,7 @@ void test_generator_with_notify_payload(protected_tester_t *tester)
|
||||
|
||||
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, 0x3132333435ll);
|
||||
notify_payload->set_spi(notify_payload, 0x31323334);
|
||||
notify_payload->set_notification_data(notify_payload,notification_data);
|
||||
|
||||
generator->generate_payload(generator,(payload_t *)notify_payload);
|
||||
@@ -719,11 +719,10 @@ void test_generator_with_notify_payload(protected_tester_t *tester)
|
||||
|
||||
u_int8_t expected_generation[] = {
|
||||
/* payload header */
|
||||
0x00,0x00,0x00,0x12,
|
||||
0xFF,0x05,0xF7,0x65,
|
||||
0x00,0x00,0x00,0x11,
|
||||
0xFF,0x04,0xF7,0x65,
|
||||
/* spi */
|
||||
0x31,0x32,0x33,0x34,
|
||||
0x35,
|
||||
/* notification data */
|
||||
0x36,0x37,0x38,0x39,
|
||||
0x30,
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2006 Tobias Brunner, Daniel Roethlisberger
|
||||
* Copyright (C) 2005 Jan Hutter, Martin Willi
|
||||
* Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
@@ -20,8 +21,7 @@
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
#include "kernel_interface_test.h"
|
||||
|
||||
#include <daemon.h>
|
||||
@@ -30,18 +30,19 @@
|
||||
#include <utils/host.h>
|
||||
|
||||
|
||||
/*
|
||||
* described in Header-File
|
||||
/**
|
||||
* @brief private method to test kernel_interface with optional NAT-T configuration data
|
||||
*/
|
||||
void test_kernel_interface(protected_tester_t *tester)
|
||||
void private_test_kernel_interface(protected_tester_t *tester, natt_conf_t *natt)
|
||||
{
|
||||
kernel_interface_t *kernel_interface;
|
||||
u_int32_t spi;
|
||||
host_t *me, *other, *left, *right;
|
||||
status_t status;
|
||||
prf_plus_t *prf_plus;
|
||||
prf_t *prf;
|
||||
prf_t *prf;
|
||||
u_int8_t key_bytes[] = {
|
||||
0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
|
||||
0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08
|
||||
};
|
||||
chunk_t key = chunk_from_buf(key_bytes);
|
||||
@@ -50,41 +51,125 @@ void test_kernel_interface(protected_tester_t *tester)
|
||||
|
||||
prf = prf_create(PRF_HMAC_MD5);
|
||||
prf->set_key(prf, key);
|
||||
prf_plus = prf_plus_create(prf, key);
|
||||
|
||||
prf_plus = prf_plus_create(prf, key);
|
||||
|
||||
|
||||
kernel_interface = kernel_interface_create();
|
||||
|
||||
me = host_create(AF_INET, "192.168.0.2", 0);
|
||||
other = host_create(AF_INET, "192.168.0.3", 0);
|
||||
|
||||
|
||||
status = kernel_interface->get_spi(kernel_interface, me, other, PROTO_ESP, 1234, &spi);
|
||||
tester->assert_true(tester, status == SUCCESS, "spi get");
|
||||
|
||||
status = kernel_interface->add_sa(kernel_interface, me, other, spi, PROTO_ESP, 1234, 0, 0, &enc_alg, &int_alg, prf_plus, TRUE);
|
||||
|
||||
status = kernel_interface->add_sa(kernel_interface, me, other, spi, PROTO_ESP, 1234, 5, 10, &enc_alg, &int_alg, prf_plus, natt, TRUE);
|
||||
tester->assert_true(tester, status == SUCCESS, "add sa");
|
||||
|
||||
|
||||
left = host_create(AF_INET, "10.1.0.0", 0);
|
||||
right = host_create(AF_INET, "10.2.0.0", 0);
|
||||
|
||||
status = kernel_interface->add_policy(kernel_interface, me, other, left, right, 16, 16, XFRM_POLICY_OUT, 0, PROTO_ESP, 1234);
|
||||
tester->assert_true(tester, status == SUCCESS, "add policy");
|
||||
|
||||
status = kernel_interface->add_policy(kernel_interface, me, other, left, right, 24, 24, XFRM_POLICY_OUT, 0, PROTO_ESP, 1234);
|
||||
tester->assert_true(tester, status == SUCCESS, "add policy OUT");
|
||||
status = kernel_interface->add_policy(kernel_interface, me, other, left, right, 24, 24, XFRM_POLICY_IN, 0, PROTO_ESP, 1234);
|
||||
tester->assert_true(tester, status == SUCCESS, "add policy IN");
|
||||
status = kernel_interface->add_policy(kernel_interface, me, other, left, right, 24, 24, XFRM_POLICY_FWD, 0, PROTO_ESP, 1234);
|
||||
tester->assert_true(tester, status == SUCCESS, "add policy FWD");
|
||||
|
||||
|
||||
kernel_interface->del_sa(kernel_interface, other, spi, PROTO_ESP);
|
||||
|
||||
sleep(10);
|
||||
|
||||
status = kernel_interface->del_policy(kernel_interface, me, other, left, right, 16, 16, XFRM_POLICY_OUT, 0);
|
||||
tester->assert_true(tester, status == SUCCESS, "del policy");
|
||||
|
||||
status = kernel_interface->del_sa(kernel_interface, other, spi, PROTO_ESP);
|
||||
tester->assert_true(tester, status == SUCCESS, "del sa");
|
||||
|
||||
me->destroy(me);
|
||||
other->destroy(other);
|
||||
left->destroy(left);
|
||||
right->destroy(right);
|
||||
|
||||
kernel_interface->destroy(kernel_interface);
|
||||
}
|
||||
|
||||
/*
|
||||
* described in Header-File
|
||||
*/
|
||||
void test_kernel_interface(protected_tester_t *tester)
|
||||
{
|
||||
private_test_kernel_interface(tester, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* described in Header-File
|
||||
*/
|
||||
void test_kernel_interface_with_nat(protected_tester_t *tester)
|
||||
{
|
||||
natt_conf_t natt;
|
||||
natt.sport = 4500;
|
||||
natt.dport = 9876;
|
||||
|
||||
private_test_kernel_interface(tester, &natt);
|
||||
}
|
||||
|
||||
void test_kernel_interface_update_hosts(protected_tester_t *tester)
|
||||
{
|
||||
kernel_interface_t *kernel_interface;
|
||||
u_int32_t spi;
|
||||
host_t *me, *other, *new_me, *new_other, *left, *right;
|
||||
status_t status;
|
||||
prf_plus_t *prf_plus;
|
||||
prf_t *prf;
|
||||
u_int8_t key_bytes[] = {
|
||||
0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
|
||||
0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08
|
||||
};
|
||||
chunk_t key = chunk_from_buf(key_bytes);
|
||||
algorithm_t int_alg = {AUTH_HMAC_MD5_96, 0};
|
||||
algorithm_t enc_alg = {ENCR_AES_CBC, 128};
|
||||
|
||||
prf = prf_create(PRF_HMAC_MD5);
|
||||
prf->set_key(prf, key);
|
||||
prf_plus = prf_plus_create(prf, key);
|
||||
|
||||
kernel_interface = kernel_interface_create();
|
||||
|
||||
me = host_create(AF_INET, "192.168.0.2", 0);
|
||||
other = host_create(AF_INET, "192.168.0.3", 0);
|
||||
|
||||
natt_conf_t natt;
|
||||
natt.sport = 4500;
|
||||
natt.dport = 9876;
|
||||
|
||||
status = kernel_interface->get_spi(kernel_interface, me, other, PROTO_ESP, 1234, &spi);
|
||||
tester->assert_true(tester, status == SUCCESS, "spi get");
|
||||
|
||||
status = kernel_interface->add_sa(kernel_interface, me, other, spi, PROTO_ESP, 1234, 5, 10, &enc_alg, &int_alg, prf_plus, &natt, TRUE);
|
||||
tester->assert_true(tester, status == SUCCESS, "add sa");
|
||||
|
||||
left = host_create(AF_INET, "10.1.0.0", 0);
|
||||
right = host_create(AF_INET, "10.2.0.0", 0);
|
||||
|
||||
status = kernel_interface->add_policy(kernel_interface, me, other, left, right, 16, 16, XFRM_POLICY_OUT, 0, PROTO_ESP, 1234);
|
||||
tester->assert_true(tester, status == SUCCESS, "add policy OUT");
|
||||
status = kernel_interface->add_policy(kernel_interface, me, other, left, right, 16, 16, XFRM_POLICY_IN, 0, PROTO_ESP, 1234);
|
||||
tester->assert_true(tester, status == SUCCESS, "add policy IN");
|
||||
status = kernel_interface->add_policy(kernel_interface, me, other, left, right, 16, 16, XFRM_POLICY_FWD, 0, PROTO_ESP, 1234);
|
||||
tester->assert_true(tester, status == SUCCESS, "add policy FWD");
|
||||
|
||||
new_me = host_create(AF_INET, "192.168.1.12", 4500);
|
||||
new_other = host_create(AF_INET, "192.168.1.13", 6543);
|
||||
|
||||
status = kernel_interface->update_sa_hosts(kernel_interface, me, other, new_me, new_other, me->get_differences(me, new_me), other->get_differences(other, new_other), spi, PROTO_ESP);
|
||||
tester->assert_true(tester, status == SUCCESS, "update hosts on sa");
|
||||
|
||||
status = kernel_interface->del_policy(kernel_interface, me, other, left, right, 16, 16, XFRM_POLICY_OUT, 0);
|
||||
tester->assert_true(tester, status == SUCCESS, "del policy");
|
||||
|
||||
status = kernel_interface->del_sa(kernel_interface, other, spi, PROTO_ESP);
|
||||
tester->assert_true(tester, status == SUCCESS, "del sa");
|
||||
|
||||
me->destroy(me);
|
||||
other->destroy(other);
|
||||
new_me->destroy(new_me);
|
||||
new_other->destroy(new_other);
|
||||
left->destroy(left);
|
||||
right->destroy(right);
|
||||
|
||||
sleep(15);
|
||||
|
||||
kernel_interface->destroy(kernel_interface);
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2006 Tobias Brunner, Daniel Roethlisberger
|
||||
* Copyright (C) 2005 Jan Hutter, Martin Willi
|
||||
* Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
@@ -34,5 +35,23 @@
|
||||
*/
|
||||
void test_kernel_interface(protected_tester_t *tester);
|
||||
|
||||
/**
|
||||
* @brief Test function used to test the kernel_interface functionality. Incldes NAT-T configuration.
|
||||
*
|
||||
* @param tester associated tester object
|
||||
*
|
||||
* @ingroup testcases
|
||||
*/
|
||||
void test_kernel_interface_with_nat(protected_tester_t *tester);
|
||||
|
||||
/**
|
||||
* @brief Test function used to test the hosts update functionality in kernel_interface_t.
|
||||
*
|
||||
* @param tester associated tester object
|
||||
*
|
||||
* @ingroup testcases
|
||||
*/
|
||||
void test_kernel_interface_update_hosts(protected_tester_t *tester);
|
||||
|
||||
|
||||
#endif /*KERNEL_INTERFACE_TEST_H_*/
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2006 Tobias Brunner, Daniel Roethlisberger
|
||||
* Copyright (C) 2005 Jan Hutter, Martin Willi
|
||||
* Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
@@ -35,7 +36,7 @@ void test_socket(protected_tester_t *tester)
|
||||
{
|
||||
int packet_count = 10;
|
||||
int current;
|
||||
socket_t *skt = socket_create(500);
|
||||
socket_t *skt = socket_create(500, 4500);
|
||||
packet_t *pkt = packet_create();
|
||||
char test_data[] = {
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, /* spi */
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2006 Tobias Brunner, Daniel Roethlisberger
|
||||
* Copyright (C) 2005 Jan Hutter, Martin Willi
|
||||
* Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
@@ -126,7 +127,9 @@ test_t connection_test = {test_connection, "connection_t test"};
|
||||
test_t policy_test = {test_policy, "policy_t test"};
|
||||
test_t proposal_test = {test_proposal, "proposal_t test"};
|
||||
test_t rsa_test = {test_rsa, "RSA private/public key test"};
|
||||
test_t kernel_interface_test = {test_kernel_interface, "Kernel Interface"};
|
||||
test_t kernel_interface_test1 = {test_kernel_interface, "Kernel Interface"};
|
||||
test_t kernel_interface_test2 = {test_kernel_interface_with_nat, "Kernel Interface: NAT"};
|
||||
test_t kernel_interface_test3 = {test_kernel_interface_update_hosts, "Kernel Interface: Hosts update"};
|
||||
test_t child_sa_test = {test_child_sa, "Child SA"};
|
||||
test_t certificate_test = {test_certificate, "X509 Certificate"};
|
||||
test_t leak_detective_test = {test_leak_detective, "LEAK detective"};
|
||||
@@ -159,7 +162,7 @@ daemon_t *daemon_create()
|
||||
/* assign methods */
|
||||
charon->kill = daemon_kill;
|
||||
|
||||
//charon->socket = socket_create(500);
|
||||
charon->socket = socket_create(500, 4500);
|
||||
charon->ike_sa_manager = ike_sa_manager_create();
|
||||
charon->job_queue = job_queue_create();
|
||||
charon->event_queue = event_queue_create();
|
||||
|
||||
Reference in New Issue
Block a user