- installing of child sa works

- need correct IP adresses to actually use IPsec
This commit is contained in:
Martin Willi
2006-02-16 09:55:07 +00:00
parent ce461bbd13
commit 30b5b412da
23 changed files with 770 additions and 277 deletions
@@ -127,4 +127,8 @@ $(BUILD_DIR)rsa_test.o : $(TESTCASES_DIR)rsa_test.c $(TESTCASES_DIR)rsa_test.h
TEST_OBJS+= $(BUILD_DIR)kernel_interface_test.o
$(BUILD_DIR)kernel_interface_test.o : $(TESTCASES_DIR)kernel_interface_test.c $(TESTCASES_DIR)kernel_interface_test.h
$(CC) $(CFLAGS) -c -o $@ $<
TEST_OBJS+= $(BUILD_DIR)child_sa_test.o
$(BUILD_DIR)child_sa_test.o : $(TESTCASES_DIR)child_sa_test.c $(TESTCASES_DIR)child_sa_test.h
$(CC) $(CFLAGS) -c -o $@ $<
+102
View File
@@ -0,0 +1,102 @@
/**
* @file child_sa_test.c
*
* @brief Tests for the child_sa_t class.
*
*/
/*
* Copyright (C) 2005 Jan Hutter, Martin Willi
* Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#include "child_sa_test.h"
#include <daemon.h>
#include <sa/child_sa.h>
#include <utils/allocator.h>
#include <utils/logger.h>
/**
* Described in header.
*/
void test_child_sa(protected_tester_t *tester)
{
proposal_t *proposal1, *proposal2;
linked_list_t *list;
host_t *local_me, *remote_me;
host_t *local_other, *remote_other;
child_sa_t *local_sa, *remote_sa;
prf_plus_t *local_prf_plus, *remote_prf_plus;
prf_t *local_prf, *remote_prf;
u_int8_t key_buffer[] = {0x01,0x02,0x03,0x04};
chunk_t key = {key_buffer, sizeof(key_buffer)};
status_t status;
/* setup test data */
local_me = host_create(AF_INET, "192.168.0.1", 0);
local_other = host_create(AF_INET, "192.168.0.2", 0);
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);
proposal1 = proposal_create(1);
proposal1->add_algorithm(proposal1, ESP, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 16);
proposal2 = proposal_create(2);
proposal2->add_algorithm(proposal2, AH, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 0);
list = linked_list_create();
list->insert_last(list, proposal1);
list->insert_last(list, proposal2);
local_prf = prf_create(PRF_HMAC_SHA1);
remote_prf = prf_create(PRF_HMAC_SHA1);
local_prf->set_key(local_prf, key);
remote_prf->set_key(remote_prf, key);
local_prf_plus = prf_plus_create(local_prf, key);
remote_prf_plus = prf_plus_create(remote_prf, key);
/*
* local plays initiator
***********************
*/
status = local_sa->alloc(local_sa, list);
tester->assert_true(tester, status == SUCCESS, "spi allocation");
status = remote_sa->add(remote_sa, proposal1, remote_prf_plus);
tester->assert_true(tester, status == SUCCESS, "sa add");
status = local_sa->update(local_sa, proposal1, local_prf_plus);
tester->assert_true(tester, status == SUCCESS, "sa update");
/* cleanup */
proposal1->destroy(proposal1);
proposal2->destroy(proposal2);
list->destroy(list);
local_prf->destroy(local_prf);
local_prf_plus->destroy(local_prf_plus);
remote_prf->destroy(remote_prf);
remote_prf_plus->destroy(remote_prf_plus);
local_sa->destroy(local_sa);
remote_sa->destroy(remote_sa);
local_me->destroy(local_me);
local_other->destroy(local_other);
remote_me->destroy(remote_me);
remote_other->destroy(remote_other);
}
+42
View File
@@ -0,0 +1,42 @@
/**
* @file child_sa_test.h
*
* @brief Tests for the child_sa_t class.
*
*/
/*
* Copyright (C) 2005 Jan Hutter, Martin Willi
* Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#ifndef CHILD_SA_TEST_H_
#define CHILD_SA_TEST_H_
#include <utils/tester.h>
/**
* @brief Test function used to test the child_sa_t functionality.
*
* @param tester associated protected_tester_t object
*
* @ingroup testcases
*/
void test_child_sa(protected_tester_t *tester);
#endif //CHILD_SA_TEST_H_
+2 -2
View File
@@ -32,9 +32,9 @@
void test_init_config(protected_tester_t *tester)
{
init_config_t *init_config = init_config_create("192.168.0.1","192.168.0.2",500,500);
proposal_t *prop1, *prop2, *prop3, *prop4, *selected_one;
proposal_t *prop1, *prop2, *prop3, *prop4;//, *selected_one;
linked_list_t *list;
status_t status;
//status_t status;
prop1 = proposal_create(1);
prop1->add_algorithm(prop1, IKE, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 20);
@@ -65,10 +65,10 @@ void test_kernel_interface(protected_tester_t *tester)
//status = kernel_interface->get_spi(kernel_interface, me, other, 50, TRUE, &spi);
//tester->assert_true(tester, status == SUCCESS, "spi get");
status = kernel_interface->get_spi(kernel_interface, me, other, 50, FALSE, &spi);
tester->assert_true(tester, status == SUCCESS, "spi get");
status = kernel_interface->add_sa(kernel_interface, me, other, spi, 50, TRUE, ENCR_AES_CBC, enc_key,AUTH_HMAC_MD5_96,inc_key,TRUE);
status = kernel_interface->add_sa(kernel_interface, me, other, spi, 50, FALSE, ENCR_AES_CBC, enc_key,AUTH_UNDEFINED,inc_key,TRUE);
tester->assert_true(tester, status == SUCCESS, "build sa");
+9 -2
View File
@@ -61,6 +61,7 @@
#include <testcases/proposal_test.h>
#include <testcases/rsa_test.h>
#include <testcases/kernel_interface_test.h>
#include <testcases/child_sa_test.h>
/* output for test messages */
extern FILE * stderr;
@@ -126,6 +127,7 @@ test_t sa_config_test = {test_sa_config, "sa_config_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 child_sa_test = {test_child_sa, "Child SA"};
daemon_t* charon;
@@ -138,6 +140,7 @@ static void daemon_kill(daemon_t *this, char* none)
this->job_queue->destroy(this->job_queue);
this->event_queue->destroy(this->event_queue);
this->send_queue->destroy(this->send_queue);
this->kernel_interface->destroy(this->kernel_interface);
//this->configuration_manager->destroy(this->configuration_manager);
allocator_free(charon);
}
@@ -160,6 +163,7 @@ daemon_t *daemon_create()
charon->job_queue = job_queue_create();
charon->event_queue = event_queue_create();
charon->send_queue = send_queue_create();
charon->kernel_interface = kernel_interface_create();
//charon->configuration_manager = configuration_manager_create(RETRANSMIT_TIMEOUT,MAX_RETRANSMIT_COUNT,HALF_OPEN_IKE_SA_TIMEOUT);
charon->sender = NULL;
charon->receiver = NULL;
@@ -237,6 +241,8 @@ int main()
&rsa_test,
NULL
};
/* get rid of compiler warning ;-) */
*all_tests = *all_tests;
/* allocator needs initialization */
allocator_init();
@@ -244,13 +250,14 @@ int main()
daemon_create();
charon->logger_manager->disable_logger_level(charon->logger_manager,TESTER,FULL);
charon->logger_manager->enable_logger_level(charon->logger_manager,CHILD_SA,FULL);
/* charon->logger_manager->enable_logger_level(charon->logger_manager,TESTER,RAW); */
tester_t *tester = tester_create(test_output, FALSE);
tester->perform_tests(tester,all_tests);
//tester->perform_test(tester,&kernel_interface_test);
//tester->perform_tests(tester,all_tests);
tester->perform_test(tester,&child_sa_test);
tester->destroy(tester);