removed module tests, outdated. We need something more system-test like

This commit is contained in:
Martin Willi 2006-10-18 11:38:43 +00:00
parent bcdfc0a5da
commit 9aac18cba8
62 changed files with 0 additions and 8203 deletions

View File

@ -1,36 +0,0 @@
noinst_PROGRAMS = testing
INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon -I$(top_srcdir)/src/stroke
testing_SOURCES = \
thread_pool_test.c policy_test.c prf_plus_test.h testcases.c ike_sa_manager_test.c \
linked_list_test.c send_queue_test.h policy_test.h encryption_payload_test.c thread_pool_test.h \
child_sa_test.c linked_list_test.h packet_test.c child_sa_test.h encryption_payload_test.h packet_test.h \
diffie_hellman_test.c event_queue_test.c event_queue_test.h socket_test.c Makefile.am identification_test.c \
ike_sa_manager_test.h ike_sa_test.c diffie_hellman_test.h parser_test.c socket_test.h identification_test.h \
connection_test.c proposal_test.c ike_sa_test.h kernel_interface_test.c parser_test.h connection_test.h \
proposal_test.h kernel_interface_test.h ike_sa_id_test.c hmac_test.c leak_detective_test.c hasher_test.c \
ike_sa_id_test.h hmac_test.h leak_detective_test.h job_queue_test.c scheduler_test.c hmac_signer_test.c \
hasher_test.h sender_test.c certificate_test.c job_queue_test.h scheduler_test.h hmac_signer_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 -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/transaction.o \
$(top_srcdir)/src/charon/ike_sa_init.o $(top_srcdir)/src/charon/ike_auth.o $(top_srcdir)/src/charon/create_child_sa.o \
$(top_srcdir)/src/charon/delete_child_sa.o $(top_srcdir)/src/charon/delete_ike_sa.o $(top_srcdir)/src/charon/dead_peer_detection.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 \
$(top_srcdir)/src/charon/transform_substructure.o $(top_srcdir)/src/charon/auth_payload.o $(top_srcdir)/src/charon/ike_header.o $(top_srcdir)/src/charon/nonce_payload.o \
$(top_srcdir)/src/charon/eap_payload.o $(top_srcdir)/src/charon/ts_payload.o $(top_srcdir)/src/charon/notify_payload.o $(top_srcdir)/src/charon/id_payload.o \
$(top_srcdir)/src/charon/ke_payload.o $(top_srcdir)/src/charon/unknown_payload.o $(top_srcdir)/src/charon/encodings.o $(top_srcdir)/src/charon/cp_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/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 \
$(top_srcdir)/src/charon/sender.o $(top_srcdir)/src/charon/receiver.o $(top_srcdir)/src/charon/stroke_interface.o

View File

@ -1,303 +0,0 @@
/**
* @file aes_cbc_crypter_test.c
*
* @brief Tests for the aes_cbc_crypter_t class.
*
*/
/*
* Copyright (C) 2005-2006 Martin Willi
* Copyright (C) 2005 Jan Hutter
* 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 <string.h>
#include "aes_cbc_crypter_test.h"
#include <daemon.h>
void test_aes_cbc_crypter(protected_tester_t *tester)
{
/*
* Test 1 of RFC3602
* Key : 0x06a9214036b8a15b512e03d534120006
* IV : 0x3dafba429d9eb430b422da802c9fac41
* Plaintext : "Single block msg"
* Ciphertext: 0xe353779c1079aeb82708942dbe77181a
*/
crypter_t *crypter;
u_int8_t key1[] = {0x06,0xa9,0x21,0x40,0x36,0xb8,0xa1,0x5b,
0x51,0x2e,0x03,0xd5,0x34,0x12,0x00,0x06};
chunk_t key1_chunk = {ptr: key1, len : 16};
u_int8_t iv1[] = {0x3d,0xaf,0xba,0x42,0x9d,0x9e,0xb4,0x30,
0xb4,0x22,0xda,0x80,0x2c,0x9f,0xac,0x41};
chunk_t iv1_chunk = {ptr: iv1, len : 16};
u_int8_t ciphertext1[] = { 0xe3,0x53,0x77,0x9c,0x10,0x79,0xae,0xb8,
0x27,0x08,0x94,0x2d,0xbe,0x77,0x18,0x1a};
chunk_t expected_encrypted1 = {ptr: ciphertext1, len : 16};
char * plaintext1 = "Single block msg";
chunk_t data1 = {ptr: plaintext1, len : 16};
chunk_t encrypted1;
chunk_t decrypted1;
logger_t *logger;
logger = logger_manager->get_logger(logger_manager,TESTER);
crypter = (crypter_t *) aes_cbc_crypter_create(16);
tester->assert_true(tester, (crypter != NULL), "create call test");
tester->assert_true(tester, (crypter->set_key(crypter,key1_chunk) == SUCCESS), "set_key call test");
tester->assert_true(tester, (crypter->encrypt(crypter,data1,iv1_chunk,&encrypted1) == SUCCESS), "encrypt call test");
tester->assert_true(tester, (memcmp(encrypted1.ptr, expected_encrypted1.ptr, 16) == 0), "Encrypted value");
logger->log_chunk(logger,RAW,"exptected encrypted :", expected_encrypted1);
logger->log_chunk(logger,RAW,"encrypted :", encrypted1);
tester->assert_true(tester, (crypter->decrypt(crypter,encrypted1,iv1_chunk,&decrypted1) == SUCCESS), "decrypt call test");
chunk_free(&encrypted1);
tester->assert_true(tester, (memcmp(decrypted1.ptr, plaintext1, 16) == 0), "decrypted value");
logger->log_chunk(logger,RAW,"expected decrypted :", data1);
logger->log_chunk(logger,RAW,"decrypted :", decrypted1);
chunk_free(&decrypted1);
crypter->destroy(crypter);
/*
* Test 2 of RFC3602
* Key : 0xc286696d887c9aa0611bbb3e2025a45a
* IV : 0x562e17996d093d28ddb3ba695a2e6f58
* Plaintext : 0x000102030405060708090a0b0c0d0e0f
* 101112131415161718191a1b1c1d1e1f
* Ciphertext: 0xd296cd94c2cccf8a3a863028b5e1dc0a
* 7586602d253cfff91b8266bea6d61ab1
*/
u_int8_t key2[] = {0xc2,0x86,0x69,0x6d,0x88,0x7c,0x9a,0xa0,
0x61,0x1b,0xbb,0x3e,0x20,0x25,0xa4,0x5a};
chunk_t key2_chunk = {ptr: key2, len : 16};
u_int8_t iv2[] = {0x56,0x2e,0x17,0x99,0x6d,0x09,0x3d,0x28,
0xdd,0xb3,0xba,0x69,0x5a,0x2e,0x6f,0x58};
chunk_t iv2_chunk = {ptr: iv2, len : 16};
u_int8_t ciphertext2[] = { 0xd2,0x96,0xcd,0x94,0xc2,0xcc,0xcf,0x8a,
0x3a,0x86,0x30,0x28,0xb5,0xe1,0xdc,0x0a,
0x75,0x86,0x60,0x2d,0x25,0x3c,0xff,0xf9,
0x1b,0x82,0x66,0xbe,0xa6,0xd6,0x1a,0xb1};
chunk_t expected_encrypted2 = {ptr: ciphertext2, len : 32};
u_int8_t plaintext2[] = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f};
chunk_t data2 = {ptr: plaintext2, len : 32};
chunk_t encrypted2;
chunk_t decrypted2;
crypter = (crypter_t *) aes_cbc_crypter_create(16);
tester->assert_true(tester, (crypter != NULL), "create call test");
tester->assert_true(tester, (crypter->set_key(crypter,key2_chunk) == SUCCESS), "set_key call test");
tester->assert_true(tester, (crypter->encrypt(crypter,data2,iv2_chunk,&encrypted2) == SUCCESS), "encrypt call test");
tester->assert_true(tester, (memcmp(encrypted2.ptr, expected_encrypted2.ptr, 32) == 0), "Encrypted value");
logger->log_chunk(logger,RAW,"exptected encrypted :", expected_encrypted2);
logger->log_chunk(logger,RAW,"encrypted :", encrypted2);
tester->assert_true(tester, (crypter->decrypt(crypter,encrypted2,iv2_chunk,&decrypted2) == SUCCESS), "decrypt call test");
chunk_free(&encrypted2);
tester->assert_true(tester, (memcmp(decrypted2.ptr, plaintext2, 32) == 0), "decrypted value");
logger->log_chunk(logger,RAW,"expected decrypted :", data2);
logger->log_chunk(logger,RAW,"decrypted :", decrypted2);
chunk_free(&decrypted2);
crypter->destroy(crypter);
/*
* Test 3 of RFC3603
* Key : 0x56e47a38c5598974bc46903dba290349
* IV : 0x8ce82eefbea0da3c44699ed7db51b7d9
* Plaintext : 0xa0a1a2a3a4a5a6a7a8a9aaabacadaeaf
* b0b1b2b3b4b5b6b7b8b9babbbcbdbebf
* c0c1c2c3c4c5c6c7c8c9cacbcccdcecf
* d0d1d2d3d4d5d6d7d8d9dadbdcdddedf
* Ciphertext: 0xc30e32ffedc0774e6aff6af0869f71aa
* 0f3af07a9a31a9c684db207eb0ef8e4e
* 35907aa632c3ffdf868bb7b29d3d46ad
* 83ce9f9a102ee99d49a53e87f4c3da55
*/
u_int8_t key3[] = {0x56,0xe4,0x7a,0x38,0xc5,0x59,0x89,0x74,
0xbc,0x46,0x90,0x3d,0xba,0x29,0x03,0x49};
chunk_t key3_chunk = {ptr: key3, len : 16};
u_int8_t iv3[] = {0x8c,0xe8,0x2e,0xef,0xbe,0xa0,0xda,0x3c,
0x44,0x69,0x9e,0xd7,0xdb,0x51,0xb7,0xd9};
chunk_t iv3_chunk = {ptr: iv3, len : 16};
u_int8_t ciphertext3[] = { 0xc3,0x0e,0x32,0xff,0xed,0xc0,0x77,0x4e,
0x6a,0xff,0x6a,0xf0,0x86,0x9f,0x71,0xaa,
0x0f,0x3a,0xf0,0x7a,0x9a,0x31,0xa9,0xc6,
0x84,0xdb,0x20,0x7e,0xb0,0xef,0x8e,0x4e,
0x35,0x90,0x7a,0xa6,0x32,0xc3,0xff,0xdf,
0x86,0x8b,0xb7,0xb2,0x9d,0x3d,0x46,0xad,
0x83,0xce,0x9f,0x9a,0x10,0x2e,0xe9,0x9d,
0x49,0xa5,0x3e,0x87,0xf4,0xc3,0xda,0x55};
chunk_t expected_encrypted3 = {ptr: ciphertext3, len : 64};
u_int8_t plaintext3[] = {0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,
0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,
0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,
0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0xbe,0xbf,
0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,
0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,
0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,
0xd8,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf};
chunk_t data3 = {ptr: plaintext3, len : 64};
chunk_t encrypted3;
chunk_t decrypted3;
crypter = (crypter_t *) aes_cbc_crypter_create(16);
tester->assert_true(tester, (crypter != NULL), "create call test");
tester->assert_true(tester, (crypter->set_key(crypter,key3_chunk) == SUCCESS), "set_key call test");
tester->assert_true(tester, (crypter->encrypt(crypter,data3,iv3_chunk,&encrypted3) == SUCCESS), "encrypt call test");
tester->assert_true(tester, (memcmp(encrypted3.ptr, expected_encrypted3.ptr, 64) == 0), "Encrypted value");
logger->log_chunk(logger,RAW,"exptected encrypted :", expected_encrypted3);
logger->log_chunk(logger,RAW,"encrypted :", encrypted3);
tester->assert_true(tester, (crypter->decrypt(crypter,encrypted3,iv3_chunk,&decrypted3) == SUCCESS), "decrypt call test");
chunk_free(&encrypted3);
tester->assert_true(tester, (memcmp(decrypted3.ptr, plaintext3, 64) == 0), "decrypted value");
logger->log_chunk(logger,RAW,"expected decrypted :", data3);
logger->log_chunk(logger,RAW,"decrypted :", decrypted3);
chunk_free(&decrypted3);
crypter->destroy(crypter);
/**
* Test4: Own en-/decrypt test using AES-256
*
* PLAINTEXT: 00112233445566778899aabbccddeeff
* KEY: 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f
* INPUT: 00112233445566778899aabbccddeeff
* OUTPUT: 8ea2b7ca516745bfeafc49904b496089
*/
u_int8_t key4[] = {
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f
};
chunk_t key4_chunk = {ptr: key4, len : 32};
u_int8_t iv4[] = {
0x8c,0xe8,0x2e,0xef,0xbe,0xa0,0xda,0x3c,
0x44,0x69,0x9e,0xd7,0xdb,0x51,0xb7,0xd9
};
chunk_t iv4_chunk = {ptr: iv4, len : 16};
u_int8_t plaintext4[] = {
0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,
0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,
0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,
0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0xbe,0xbf,
0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,
0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,
0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,
0xd8,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf
};
chunk_t data4 = {ptr: plaintext4, len : 64};
chunk_t encrypted4;
chunk_t decrypted4;
crypter = (crypter_t *) aes_cbc_crypter_create(32);
tester->assert_true(tester, (crypter != NULL), "create call test");
tester->assert_true(tester, (crypter->set_key(crypter,key4_chunk) == SUCCESS), "set_key call test");
tester->assert_true(tester, (crypter->encrypt(crypter,data4,iv4_chunk,&encrypted4) == SUCCESS), "encrypt call test");
tester->assert_true(tester, (crypter->decrypt(crypter,encrypted4,iv4_chunk,&decrypted4) == SUCCESS), "decrypt call test");
chunk_free(&encrypted4);
logger->log_chunk(logger,RAW,"expected decrypted :", data4);
logger->log_chunk(logger,RAW,"decrypted :", decrypted4);
tester->assert_true(tester, (memcmp(decrypted4.ptr, plaintext4, 64) == 0), "decrypted value");
chunk_free(&decrypted4);
crypter->destroy(crypter);
/**
* Test4: Own en-/decrypt test using AES-192
*
* PLAINTEXT: 00112233445566778899aabbccddeeff
* KEY: 000102030405060708090a0b0c0d0e0f1011121314151617
* INPUT: 00112233445566778899aabbccddeeff
* OUTPUT: 8ea2b7ca516745bfeafc49904b496089
*/
u_int8_t key5[] = {
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17
};
chunk_t key5_chunk = {ptr: key5, len : 24};
u_int8_t iv5[] = {
0x8c,0xe8,0x2e,0xef,0xbe,0xa0,0xda,0x3c,
0x44,0x69,0x9e,0xd7,0xdb,0x51,0xb7,0xd9
};
chunk_t iv5_chunk = {ptr: iv5, len : 16};
u_int8_t plaintext5[] = {
0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,
0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,
0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,
0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0xbe,0xbf,
0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,
0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,
0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,
0xd8,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf
};
chunk_t data5 = {ptr: plaintext5, len : 64};
chunk_t encrypted5;
chunk_t decrypted5;
crypter = (crypter_t *) aes_cbc_crypter_create(24);
tester->assert_true(tester, (crypter != NULL), "create call test");
tester->assert_true(tester, (crypter->set_key(crypter,key5_chunk) == SUCCESS), "set_key call test");
tester->assert_true(tester, (crypter->encrypt(crypter,data5,iv5_chunk,&encrypted5) == SUCCESS), "encrypt call test");
tester->assert_true(tester, (crypter->decrypt(crypter,encrypted5,iv5_chunk,&decrypted5) == SUCCESS), "decrypt call test");
chunk_free(&encrypted4);
logger->log_chunk(logger,RAW,"expected decrypted :", data5);
logger->log_chunk(logger,RAW,"decrypted :", decrypted5);
tester->assert_true(tester, (memcmp(decrypted5.ptr, plaintext5, 64) == 0), "decrypted value");
chunk_free(&decrypted5);
crypter->destroy(crypter);
}

View File

@ -1,39 +0,0 @@
/**
* @file aes_cbc_crypter_test.h
*
* @brief Tests for the aes_cbc_crypter_t class.
*
*/
/*
* Copyright (C) 2005-2006 Martin Willi
* Copyright (C) 2005 Jan Hutter
* 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 AES_CBC_CRYPTER_TEST_H_
#define AES_CBC_CRYPTER_TEST_H_
#include <crypto/crypters/aes_cbc_crypter.h>
#include <utils/tester.h>
/**
* @brief Test function used to test the aes_cbc_crypter_t class.
*
* @param tester associated tester object
*
* @ingroup testcases
*/
void test_aes_cbc_crypter(protected_tester_t *tester);
#endif /* AES_CBC_CRYPTER_TEST_H_ */

View File

@ -1,112 +0,0 @@
/**
* @file certificate_test.c
*
* @brief Tests for the certificate_t class.
*
*/
/*
* Copyright (C) 2006 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 <string.h>
#include "certificate_test.h"
#include <daemon.h>
#include <crypto/x509.h>
#include <utils/logger.h>
static char certificate_buffer[] = {
0x30,0x82,0x02,0xf9,0x30,0x82,0x01,0xe1,0xa0,0x03,0x02,0x01,0x02,0x02,0x11,0x00,
0xfe,0xae,0xe3,0xcf,0x00,0x27,0x8d,0xa0,0xe1,0xfa,0xb2,0x07,0xd4,0x15,0x40,0x93,
0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x05,0x05,0x00,0x30,
0x38,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x43,0x48,0x31,0x19,
0x30,0x17,0x06,0x03,0x55,0x04,0x0a,0x13,0x10,0x4c,0x69,0x6e,0x75,0x78,0x20,0x73,
0x74,0x72,0x6f,0x6e,0x67,0x53,0x77,0x61,0x6e,0x31,0x0e,0x30,0x0c,0x06,0x03,0x55,
0x04,0x03,0x13,0x05,0x6d,0x61,0x65,0x6e,0x6f,0x30,0x1e,0x17,0x0d,0x30,0x36,0x30,
0x33,0x32,0x37,0x30,0x36,0x35,0x32,0x33,0x38,0x5a,0x17,0x0d,0x31,0x31,0x30,0x33,
0x32,0x36,0x30,0x36,0x35,0x32,0x33,0x38,0x5a,0x30,0x38,0x31,0x0b,0x30,0x09,0x06,
0x03,0x55,0x04,0x06,0x13,0x02,0x43,0x48,0x31,0x19,0x30,0x17,0x06,0x03,0x55,0x04,
0x0a,0x13,0x10,0x4c,0x69,0x6e,0x75,0x78,0x20,0x73,0x74,0x72,0x6f,0x6e,0x67,0x53,
0x77,0x61,0x6e,0x31,0x0e,0x30,0x0c,0x06,0x03,0x55,0x04,0x03,0x13,0x05,0x6d,0x61,
0x65,0x6e,0x6f,0x30,0x82,0x01,0x22,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,
0x0d,0x01,0x01,0x01,0x05,0x00,0x03,0x82,0x01,0x0f,0x00,0x30,0x82,0x01,0x0a,0x02,
0x82,0x01,0x01,0x00,0xe3,0x75,0x56,0xb9,0x68,0x46,0xa6,0x3e,0x6c,0x19,0x36,0xfb,
0x9a,0xb4,0xbc,0xc1,0x22,0x47,0xc0,0x00,0x8a,0x44,0x1c,0xa7,0x44,0x2e,0x73,0x50,
0xfc,0xd2,0x91,0x9c,0xaa,0xc3,0xa3,0x88,0x8c,0x4b,0x33,0xef,0x9a,0x52,0x89,0x9c,
0x8e,0x01,0x62,0x21,0x7a,0x75,0x5e,0xa3,0x3b,0xc0,0xb0,0x58,0xc0,0xc0,0xce,0x77,
0xe0,0x84,0x9a,0x9e,0xc1,0x51,0x71,0xc7,0xc4,0xa0,0x1e,0xf0,0x8e,0xb3,0x90,0x3e,
0xcd,0xe3,0x7d,0x8e,0x11,0x7b,0x92,0x5d,0x4a,0x37,0x3b,0x4b,0xb3,0x3d,0x58,0x9a,
0x8b,0x51,0x39,0x15,0xcd,0x27,0xd4,0x5b,0xad,0x5e,0xa5,0x07,0x94,0x29,0x0f,0x02,
0x0c,0x61,0x85,0x97,0x3b,0xc4,0xcf,0x5d,0x17,0x86,0x4d,0x96,0x5e,0x42,0xe9,0xf2,
0x72,0x2f,0xd4,0x58,0x4d,0x02,0xf8,0x0f,0xbd,0xe7,0x37,0xc8,0xa9,0x87,0xfe,0xab,
0x26,0x37,0x13,0x90,0x65,0x2d,0x51,0x41,0x18,0x18,0xdf,0x48,0x21,0x87,0x70,0x61,
0xcb,0x1b,0x62,0xad,0xaf,0x65,0xd2,0x29,0x27,0x93,0x58,0x7b,0xea,0x89,0xdd,0x58,
0x01,0x6d,0xeb,0x60,0xd8,0xc3,0x82,0x07,0x2c,0x67,0x39,0xc3,0x68,0xfc,0xcd,0xeb,
0xe9,0x7c,0x67,0xe3,0x1b,0x7a,0x50,0xf9,0x36,0x68,0xea,0xe2,0x15,0x01,0xee,0x99,
0xf2,0x52,0xe0,0x0a,0x8e,0x5f,0x63,0xb1,0x61,0x7a,0x38,0x88,0x07,0xae,0xb0,0x8d,
0x44,0x26,0xe8,0xce,0x1b,0x6f,0xcd,0x05,0x4b,0x94,0x9d,0xee,0xb5,0xeb,0x28,0xc4,
0x93,0x47,0xfd,0x47,0x40,0x45,0x58,0xc0,0x3e,0x44,0x74,0x7b,0x78,0x8d,0xc8,0x25,
0xc1,0xe1,0x0a,0x43,0x02,0x03,0x01,0x00,0x01,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,
0x86,0xf7,0x0d,0x01,0x01,0x05,0x05,0x00,0x03,0x82,0x01,0x01,0x00,0x77,0xfd,0xd2,
0x68,0x7e,0xb9,0xc2,0x40,0xb4,0xa3,0xea,0xe8,0x15,0x55,0x18,0xfe,0xe3,0x80,0xe0,
0x73,0xf9,0xe1,0xe5,0xe2,0x91,0xf5,0xa7,0xcb,0xdf,0xfb,0xc1,0x36,0xa6,0x55,0x6a,
0xd9,0x27,0xcd,0xef,0x64,0x30,0x70,0xd8,0x4b,0x72,0x7c,0xd1,0x9c,0x32,0xf8,0xb4,
0x15,0x7f,0xd7,0x79,0x0c,0x9f,0x24,0xf8,0x50,0xea,0xc7,0xd9,0xef,0x1f,0xf1,0x76,
0x3c,0x19,0xdb,0x61,0xb7,0x35,0x97,0xf9,0x03,0x87,0x42,0x77,0x23,0xd8,0xfe,0xd1,
0x74,0xf2,0x1e,0x95,0x87,0x5f,0x42,0x80,0x8e,0xee,0x6c,0x19,0x7b,0x2c,0x25,0xe6,
0xf9,0xdb,0x24,0x35,0x94,0x65,0x44,0xa0,0x56,0x6f,0x7f,0x57,0x2e,0x1a,0xcd,0xa6,
0xed,0x7f,0x42,0xf2,0x64,0xd4,0xf9,0x3f,0xc1,0x46,0xf6,0xc8,0xb1,0xb2,0x80,0x75,
0x3e,0xd1,0xa8,0x5e,0x07,0xd0,0x3b,0x35,0x81,0x49,0x93,0x77,0xd2,0xcf,0xf7,0xb6,
0xd0,0xeb,0xe5,0xf3,0x2c,0x03,0x52,0xc7,0x6d,0x02,0x26,0xa6,0xdc,0x39,0xcd,0x4d,
0x9e,0xca,0x99,0x01,0x01,0x73,0xd6,0x55,0x89,0x93,0x12,0xa0,0xc5,0xe6,0xa7,0x9a,
0xdc,0x5f,0x9f,0x5c,0x2c,0x2b,0xdb,0x23,0xa5,0xee,0x69,0x15,0x1f,0x3a,0xf1,0x76,
0x36,0xb5,0x77,0x18,0x57,0xff,0xff,0xf7,0x45,0x59,0xce,0x1b,0x0b,0x56,0xcb,0x09,
0x00,0x12,0x17,0xb8,0xa2,0x81,0x86,0x70,0x29,0x63,0x99,0x76,0xff,0x18,0x80,0x2b,
0x9b,0x5e,0x04,0xb1,0xcc,0xe4,0x15,0x90,0x29,0xa6,0x40,0xdd,0x85,0x38,0xd7,0xfe,
0x10,0xb5,0x97,0x6e,0x62,0x60,0xb9,0x02,0x67,0xef,0xf1,0xab,0xb3,
};
/**
* Described in header.
*/
void test_certificate(protected_tester_t *tester)
{
/*chunk_t certificate = {certificate_buffer, sizeof(certificate_buffer)};
identification_t *id;
x509_t *cert;
cert = x509_create_from_chunk(certificate);
id = cert->get_subject(cert);
tester->assert_true(tester, strcmp(id->get_string(id), "C=CH, O=Linux strongSwan, CN=maeno") == 0, "subject");
id = cert->get_issuer(cert);
tester->assert_true(tester, strcmp(id->get_string(id), "C=CH, O=Linux strongSwan, CN=maeno") == 0, "issuer");
cert->destroy(cert);
cert = x509_create_from_file("scripts/complex1.der");
id = cert->get_subject(cert);
printf("Subject: %s\n", id->get_string(id));
id = cert->get_issuer(cert);
printf("Issuer: %s\n", id->get_string(id));
cert->destroy(cert);
cert = x509_create_from_file("scripts/complex2.der");
id = cert->get_subject(cert);
printf("Subject: %s\n", id->get_string(id));
id = cert->get_issuer(cert);
printf("Issuer: %s\n", id->get_string(id));
cert->destroy(cert);*/
}

View File

@ -1,42 +0,0 @@
/**
* @file certificate_test.h
*
* @brief Tests for the certificate_t class.
*
*/
/*
* Copyright (C) 2006 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 CERTIFICATE_TEST_H_
#define CERTIFICATE_TEST_H_
#include <utils/tester.h>
/**
* @brief Test function used to test the certificate_t functionality.
*
* @param tester associated protected_tester_t object
*
* @ingroup testcases
*/
void test_certificate(protected_tester_t *tester);
#endif /* CERTIFICATE_TEST_H_ */

View File

@ -1,104 +0,0 @@
/**
* @file child_sa_test.c
*
* @brief Tests for the child_sa_t class.
*
*/
/*
* Copyright (C) 2006 Tobias Brunner, Daniel Roethlisberger
* Copyright (C) 2005-2006 Martin Willi
* Copyright (C) 2005 Jan Hutter
* 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/logger.h>
/**
* Described in header.
*/
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;
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(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);
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);
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);
}

View File

@ -1,43 +0,0 @@
/**
* @file child_sa_test.h
*
* @brief Tests for the child_sa_t class.
*
*/
/*
* Copyright (C) 2005-2006 Martin Willi
* Copyright (C) 2005 Jan Hutter
* 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_ */

View File

@ -1,84 +0,0 @@
/**
* @file connection_test.c
*
* @brief Tests for the connection_t class.
*
*/
/*
* Copyright (C) 2005-2006 Martin Willi
* Copyright (C) 2005 Jan Hutter
* 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 "connection_test.h"
#include <config/connections/connection.h>
#include <crypto/prfs/prf.h>
/**
* Described in header.
*/
void test_connection(protected_tester_t *tester)
{
host_t *alice = host_create(AF_INET, "192.168.0.1", 500);
host_t *bob = host_create(AF_INET, "192.168.0.2", 500);
connection_t *connection = connection_create(
"alice-bob", TRUE,
CERT_ALWAYS_SEND, CERT_ALWAYS_SEND,
alice, bob, RSA_DIGITAL_SIGNATURE);
proposal_t *prop1, *prop2, *prop3, *prop4;
linked_list_t *list;
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(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(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(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);
connection->add_proposal(connection, prop3);
connection->add_proposal(connection, prop4);
list = connection->get_proposals(connection);
tester->assert_true(tester,(list->get_count(list) == 4), "proposal count check ");
/* going to check proposals */
/* TODO test?*/
list->destroy(list);
connection->destroy(connection);
}

View File

@ -1,39 +0,0 @@
/**
* @file connection_test.h
*
* @brief Tests for the connection_t class.
*
*/
/*
* Copyright (C) 2005-2006 Martin Willi
* Copyright (C) 2005 Jan Hutter
* 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 INIT_CONFIG_TEST_H_
#define INIT_CONFIG_TEST_H_
#include <utils/tester.h>
/**
* @brief Test function used to test the connection_t functionality.
*
* @param tester associated protected_tester_t object
*
* @ingroup testcases
*/
void test_connection(protected_tester_t *tester);
#endif /* INIT_CONFIG_TEST_H_ */

View File

@ -1,77 +0,0 @@
/**
* @file diffie_hellman_test.c
*
* @brief Tests for the diffie_hellman_t class.
*
*/
/*
* Copyright (C) 2005-2006 Martin Willi
* Copyright (C) 2005 Jan Hutter
* 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 <string.h>
#include "diffie_hellman_test.h"
#include <daemon.h>
#include <utils/logger_manager.h>
#include <encoding/payloads/transform_substructure.h>
#include <crypto/diffie_hellman.h>
/*
* described in Header-File
*/
void test_diffie_hellman(protected_tester_t *tester)
{
diffie_hellman_t *my_diffie_hellman, *other_diffie_hellman;
logger_t *logger;
chunk_t my_public_value, other_public_value;
chunk_t my_secret, other_secret;
logger = logger_manager->get_logger(logger_manager,TESTER);
my_diffie_hellman = diffie_hellman_create(MODP_1024_BIT);
tester->assert_true(tester,(my_diffie_hellman != NULL), "create call check");
other_diffie_hellman = diffie_hellman_create(MODP_1024_BIT);
tester->assert_true(tester,(other_diffie_hellman != NULL), "create call check");
my_diffie_hellman->get_my_public_value(my_diffie_hellman,&my_public_value);
logger->log_chunk(logger,RAW,"My public value",my_public_value);
other_diffie_hellman->get_my_public_value(other_diffie_hellman,&other_public_value);
logger->log_chunk(logger,RAW,"Other public value",other_public_value);
my_diffie_hellman->set_other_public_value(my_diffie_hellman,other_public_value);
other_diffie_hellman->set_other_public_value(other_diffie_hellman,my_public_value);
free(my_public_value.ptr);
free(other_public_value.ptr);
tester->assert_true(tester,(my_diffie_hellman->get_shared_secret(my_diffie_hellman,&my_secret) == SUCCESS), "get_shared_secret call check");
logger->log_chunk(logger,RAW,"My shared secret",my_secret);
tester->assert_true(tester,(other_diffie_hellman->get_shared_secret(other_diffie_hellman,&other_secret) == SUCCESS), "get_shared_secret call check");
logger->log_chunk(logger,RAW,"Other shared secret",other_secret);
tester->assert_true(tester,(memcmp(my_secret.ptr,other_secret.ptr,other_secret.len) == 0), "shared secret same value check");
free(my_secret.ptr);
free(other_secret.ptr);
my_diffie_hellman->destroy(my_diffie_hellman);
other_diffie_hellman->destroy(other_diffie_hellman);
}

View File

@ -1,38 +0,0 @@
/**
* @file diffie_hellman_test.h
*
* @brief Tests for the diffie_hellman_t class.
*
*/
/*
* Copyright (C) 2005-2006 Martin Willi
* Copyright (C) 2005 Jan Hutter
* 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 DIFFIE_HELLMAN_TEST_H_
#define DIFFIE_HELLMAN_TEST_H_
#include <utils/tester.h>
/**
* @brief Test function used to test the diffie_hellman_t functionality.
*
* @param tester associated tester object
*
* @ingroup testcases
*/
void test_diffie_hellman(protected_tester_t *tester);
#endif /*DIFFIE_HELLMAN_TEST_H_*/

View File

@ -1,140 +0,0 @@
/**
* @file encryption_payload_test.c
*
* @brief Tests for the encryption_payload_t class.
*
*/
/*
* Copyright (C) 2005-2006 Martin Willi
* Copyright (C) 2005 Jan Hutter
* 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 <string.h>
#include "encryption_payload_test.h"
#include <daemon.h>
#include <utils/logger_manager.h>
#include <encoding/generator.h>
#include <encoding/parser.h>
#include <encoding/payloads/encryption_payload.h>
#include <encoding/payloads/nonce_payload.h>
#include <crypto/crypters/crypter.h>
#include <crypto/signers/signer.h>
/*
* described in Header-File
*/
void test_encryption_payload(protected_tester_t *tester)
{
encryption_payload_t *encryption_payload;
nonce_payload_t *nonce_payload;
crypter_t *crypter;
signer_t *signer;
chunk_t nonce, got_nonce;
chunk_t data;
chunk_t key;
generator_t *generator;
parser_t *parser;
status_t status;
logger_t *logger;
iterator_t *iterator;
u_int8_t key_bytes[] = {
0x01,0x01,0x01,0x01,
0x01,0x01,0x01,0x01,
0x01,0x01,0x01,0x01,
0x01,0x01,0x01,0x01
};
key.ptr = key_bytes;
key.len = sizeof(key_bytes);
logger = logger_manager->get_logger(logger_manager, TESTER);
nonce.ptr = "test text und so...";
nonce.len = strlen(nonce.ptr) + 1;
logger->log_chunk(logger, RAW, "nonce", nonce);
encryption_payload = encryption_payload_create();
nonce_payload = nonce_payload_create();
nonce_payload->set_nonce(nonce_payload, nonce);
encryption_payload->add_payload(encryption_payload, (payload_t*)nonce_payload);
signer = signer_create(AUTH_HMAC_SHA1_96);
crypter = crypter_create(ENCR_AES_CBC, 16);
signer->set_key(signer, key);
crypter->set_key(crypter, key);
/* generating */
encryption_payload->set_transforms(encryption_payload, crypter, signer);
logger->log(logger, RAW, "encrypt");
status = encryption_payload->encrypt(encryption_payload);
tester->assert_true(tester, (status == SUCCESS), "encryption");
generator = generator_create();
generator->generate_payload(generator, (payload_t*)encryption_payload);
generator->write_to_chunk(generator, &data);
logger->log_chunk(logger, RAW, "generated data", data);
encryption_payload->build_signature(encryption_payload, data);
logger->log_chunk(logger, RAW, "generated data", data);
encryption_payload->destroy(encryption_payload);
/* parsing */
parser = parser_create(data);
status = parser->parse_payload(parser, ENCRYPTED, (payload_t**)&encryption_payload);
tester->assert_true(tester, (status == SUCCESS), "parsing");
encryption_payload->set_transforms(encryption_payload, crypter, signer);
status = encryption_payload->verify_signature(encryption_payload, data);
tester->assert_true(tester, (status == SUCCESS), "signature verification");
status = encryption_payload->decrypt(encryption_payload);
tester->assert_true(tester, (status == SUCCESS), "decryption");
iterator = encryption_payload->create_payload_iterator(encryption_payload, TRUE);
while (iterator->has_next(iterator))
{
iterator->current(iterator, (void**)&nonce_payload);
got_nonce = nonce_payload->get_nonce(nonce_payload);
}
iterator->destroy(iterator);
tester->assert_true(tester, (got_nonce.len == nonce.len), "decrypted nonce");
tester->assert_false(tester, memcmp(nonce.ptr, got_nonce.ptr, nonce.len), "decrypted nonce");
logger->log_chunk(logger, RAW, "nonce", got_nonce);
free(data.ptr);
free(got_nonce.ptr);
encryption_payload->destroy(encryption_payload);
crypter->destroy(crypter);
signer->destroy(signer);
generator->destroy(generator);
parser->destroy(parser);
}

View File

@ -1,38 +0,0 @@
/**
* @file encryption_payload_test.h
*
* @brief Tests for the encryption_payload_t class.
*
*/
/*
* Copyright (C) 2005-2006 Martin Willi
* Copyright (C) 2005 Jan Hutter
* 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 ENCRYPTION_PAYLOAD_TEST_H_
#define ENCRYPTION_PAYLOAD_TEST_H_
#include <utils/tester.h>
/**
* @brief Test function used to test the encryption_payload_t functionality.
*
* @param tester associated tester object
*
* @ingroup testcases
*/
void test_encryption_payload(protected_tester_t *tester);
#endif /*ENCRYPTION_PAYLOAD_TEST_H_*/

View File

@ -1,144 +0,0 @@
/**
* @file event_queue_test.h
*
* @brief Tests for the event_queue_t class.
*
*/
/*
* Copyright (C) 2005-2006 Martin Willi
* Copyright (C) 2005 Jan Hutter
* 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 <stdlib.h>
#include <pthread.h>
#include "event_queue_test.h"
#include <queues/event_queue.h>
#include <queues/jobs/initiate_ike_sa_job.h>
/**
* Number of different times to insert per thread
*/
#define EVENT_QUEUE_TIMES 5
/**
* Number of entries per time per thread
*/
#define EVENT_QUEUE_ENTRY_PER_TIME 20
/**
* Number of test-thread
*/
#define EVENT_QUEUE_INSERT_THREADS 1
/**
* @brief Informations for the involved test-thread used in this test
*
*/
typedef struct event_queue_test_s event_queue_test_t;
struct event_queue_test_s{
protected_tester_t *tester;
event_queue_t *event_queue;
/**
* number of different event times to be inserted in the event-queue by each thread
*/
int insert_times_count;
/**
* number of event to insert at one time
*/
int entries_per_time;
};
static void event_queue_insert_thread(event_queue_test_t * testinfos)
{
timeval_t current_time;
timeval_t time;
job_t * job;
int i,j;
connection_t *connection;
gettimeofday(&current_time,NULL);
for (i = 0; i < testinfos->insert_times_count;i++)
{
for (j = 0; j < testinfos->entries_per_time;j++)
{
job = (job_t *) initiate_ike_sa_job_create(connection);
time.tv_usec = 0;
time.tv_sec = current_time.tv_sec + i;
testinfos->event_queue->add_absolute(testinfos->event_queue,job,time);
}
}
}
void test_event_queue(protected_tester_t *tester)
{
event_queue_t * event_queue = event_queue_create();
event_queue_test_t testinfos;
pthread_t threads[EVENT_QUEUE_INSERT_THREADS];
int i,j, number_of_total_events;
timeval_t current_time, start_time;
testinfos.tester = tester;
testinfos.event_queue = event_queue;
testinfos.insert_times_count = EVENT_QUEUE_TIMES;
testinfos.entries_per_time = EVENT_QUEUE_ENTRY_PER_TIME;
number_of_total_events = EVENT_QUEUE_ENTRY_PER_TIME * EVENT_QUEUE_TIMES * EVENT_QUEUE_INSERT_THREADS;
gettimeofday(&start_time,NULL);
for (i = 0; i < EVENT_QUEUE_INSERT_THREADS; i++)
{
int retval;
retval = pthread_create( &(threads[i]), NULL,(void*(*)(void*)) &event_queue_insert_thread, (void*) &testinfos);
tester->assert_true(tester,(retval== 0), "thread creation call check");
}
/* wait for all threads */
for (i = 0; i < EVENT_QUEUE_INSERT_THREADS; i++)