diff --git a/src/charon/testing/Makefile.am b/src/charon/testing/Makefile.am deleted file mode 100644 index 9f3b26085..000000000 --- a/src/charon/testing/Makefile.am +++ /dev/null @@ -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 diff --git a/src/charon/testing/aes_cbc_crypter_test.c b/src/charon/testing/aes_cbc_crypter_test.c deleted file mode 100644 index b5687cd85..000000000 --- a/src/charon/testing/aes_cbc_crypter_test.c +++ /dev/null @@ -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 . - * - * 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 - -#include "aes_cbc_crypter_test.h" - -#include - -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); -} - diff --git a/src/charon/testing/aes_cbc_crypter_test.h b/src/charon/testing/aes_cbc_crypter_test.h deleted file mode 100644 index 4f8c9e83b..000000000 --- a/src/charon/testing/aes_cbc_crypter_test.h +++ /dev/null @@ -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 . - * - * 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 -#include - -/** - * @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_ */ diff --git a/src/charon/testing/certificate_test.c b/src/charon/testing/certificate_test.c deleted file mode 100644 index ceb7bef14..000000000 --- a/src/charon/testing/certificate_test.c +++ /dev/null @@ -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 . - * - * 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 - -#include "certificate_test.h" - -#include -#include -#include - - -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);*/ -} diff --git a/src/charon/testing/certificate_test.h b/src/charon/testing/certificate_test.h deleted file mode 100644 index 8dcbd0f93..000000000 --- a/src/charon/testing/certificate_test.h +++ /dev/null @@ -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 . - * - * 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 - -/** - * @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_ */ - - - - diff --git a/src/charon/testing/child_sa_test.c b/src/charon/testing/child_sa_test.c deleted file mode 100644 index 2258c524f..000000000 --- a/src/charon/testing/child_sa_test.c +++ /dev/null @@ -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 . - * - * 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 -#include -#include - - -/** - * 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); - - -} diff --git a/src/charon/testing/child_sa_test.h b/src/charon/testing/child_sa_test.h deleted file mode 100644 index ac3c74a66..000000000 --- a/src/charon/testing/child_sa_test.h +++ /dev/null @@ -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 . - * - * 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 - -/** - * @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_ */ - - - - diff --git a/src/charon/testing/connection_test.c b/src/charon/testing/connection_test.c deleted file mode 100644 index 61c7d75de..000000000 --- a/src/charon/testing/connection_test.c +++ /dev/null @@ -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 . - * - * 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 -#include - - -/** - * 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); -} diff --git a/src/charon/testing/connection_test.h b/src/charon/testing/connection_test.h deleted file mode 100644 index 442161ac3..000000000 --- a/src/charon/testing/connection_test.h +++ /dev/null @@ -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 . - * - * 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 - -/** - * @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_ */ diff --git a/src/charon/testing/diffie_hellman_test.c b/src/charon/testing/diffie_hellman_test.c deleted file mode 100644 index 729f6b341..000000000 --- a/src/charon/testing/diffie_hellman_test.c +++ /dev/null @@ -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 . - * - * 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 - -#include "diffie_hellman_test.h" - -#include -#include -#include -#include - -/* - * 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); -} diff --git a/src/charon/testing/diffie_hellman_test.h b/src/charon/testing/diffie_hellman_test.h deleted file mode 100644 index 2bdfba3cb..000000000 --- a/src/charon/testing/diffie_hellman_test.h +++ /dev/null @@ -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 . - * - * 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 - -/** - * @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_*/ diff --git a/src/charon/testing/encryption_payload_test.c b/src/charon/testing/encryption_payload_test.c deleted file mode 100644 index 348c11f6b..000000000 --- a/src/charon/testing/encryption_payload_test.c +++ /dev/null @@ -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 . - * - * 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 - -#include "encryption_payload_test.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * 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); -} diff --git a/src/charon/testing/encryption_payload_test.h b/src/charon/testing/encryption_payload_test.h deleted file mode 100644 index 2ca653e8f..000000000 --- a/src/charon/testing/encryption_payload_test.h +++ /dev/null @@ -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 . - * - * 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 - -/** - * @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_*/ diff --git a/src/charon/testing/event_queue_test.c b/src/charon/testing/event_queue_test.c deleted file mode 100644 index 141430b4f..000000000 --- a/src/charon/testing/event_queue_test.c +++ /dev/null @@ -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 . - * - * 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 -#include - -#include "event_queue_test.h" - -#include -#include - -/** - * 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(¤t_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++) - { - int retval; - retval = pthread_join(threads[i], NULL); - tester->assert_true(tester,(retval== 0), "thread creation call check"); - - } - - tester->assert_true(tester,(event_queue->get_count(event_queue) == number_of_total_events), "event count check"); - - for (i = 0; i < EVENT_QUEUE_TIMES;i++) - { - for (j = 0; j < (EVENT_QUEUE_ENTRY_PER_TIME * EVENT_QUEUE_INSERT_THREADS);j++) - { - job_t *job; - - job = event_queue->get(event_queue); - gettimeofday(¤t_time,NULL); - tester->assert_true(tester,((current_time.tv_sec - start_time.tv_sec) == i), "value of entry check"); - job->destroy(job); - } - } - - - event_queue->destroy(event_queue); - return; -} diff --git a/src/charon/testing/event_queue_test.h b/src/charon/testing/event_queue_test.h deleted file mode 100644 index 54513da3b..000000000 --- a/src/charon/testing/event_queue_test.h +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @file event_queue_test.h - * - * @brief Tests to test the Event-Queue type event_queue_t - * - */ - -/* - * 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 . - * - * 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 EVENT_QUEUE_TEST_H_ -#define EVENT_QUEUE_TEST_H_ - -#include - -/** - * @brief Test function used to test the event_queue functionality. - * - * Tests are performed using one thread. - * - * @param tester associated tester object - * - * @ingroup testcases - */ -void test_event_queue(protected_tester_t *tester); - -#endif /*EVENT_QUEUE_TEST_H_*/ diff --git a/src/charon/testing/generator_test.c b/src/charon/testing/generator_test.c deleted file mode 100644 index 2ba772ce0..000000000 --- a/src/charon/testing/generator_test.c +++ /dev/null @@ -1,1291 +0,0 @@ -/** - * @file generator_test.c - * - * @brief Tests for the generator_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 . - * - * 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 - -#include "generator_test.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * Described in Header - */ -void test_generator_with_header_payload(protected_tester_t *tester) -{ - generator_t *generator; - ike_header_t *header_data; - chunk_t generated_data; - logger_t *logger; - - logger = logger_manager->get_logger(logger_manager, TESTER); - - header_data = ike_header_create(); - header_data->set_initiator_spi(header_data,1); - header_data->set_responder_spi(header_data,2); - ((payload_t *) header_data)->set_next_type((payload_t *) header_data, 3); - header_data->set_exchange_type(header_data, 6); - header_data->set_initiator_flag(header_data, TRUE); - header_data->set_response_flag(header_data, TRUE); - header_data->set_message_id(header_data,7); - - generator = generator_create(); - tester->assert_true(tester,(generator != NULL), "generator create check"); - - generator->generate_payload(generator,(payload_t *) header_data); - - generator->write_to_chunk(generator,&generated_data); - - u_int8_t expected_generation[] = { - 0x01,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, - 0x02,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, - 0x03,0x20,0x06,0x28, - 0x00,0x00,0x00,0x07, - 0x00,0x00,0x00,0x1C, - }; - - logger->log_bytes(logger,RAW,"expected header",expected_generation,sizeof(expected_generation)); - tester->assert_true(tester,(generated_data.len == sizeof(expected_generation)), "compare generated data length"); - logger->log_chunk(logger,RAW,"generated header",generated_data); - tester->assert_true(tester,(memcmp(expected_generation,generated_data.ptr,sizeof(expected_generation)) == 0), "compare generated data 1"); - chunk_free(&generated_data); - - generator->destroy(generator); - - header_data->set_initiator_spi(header_data,0x22000054231234LL); - header_data->set_responder_spi(header_data,0x122398); - ((payload_t *) header_data)->set_next_type((payload_t *) header_data,0xF3); - header_data->set_exchange_type(header_data, 0x12); - header_data->set_initiator_flag(header_data, TRUE); - header_data->set_response_flag(header_data, TRUE); - header_data->set_message_id(header_data,0x33AFF3); - - generator = generator_create(); - tester->assert_true(tester,(generator != NULL), "generator create check"); - - generator->generate_payload(generator,(payload_t *)header_data); - - generator->write_to_chunk(generator,&generated_data); - - u_int8_t expected_generation2[] = { - 0x34,0x12,0x23,0x54, - 0x00,0x00,0x22,0x00, - 0x98,0x23,0x12,0x00, - 0x00,0x00,0x00,0x00, - 0xF3,0x20,0x12,0x28, - 0x00,0x33,0xAF,0xF3, - 0x00,0x00,0x00,0x1C, - }; - - - logger->log_bytes(logger,RAW,"expected header",expected_generation2,sizeof(expected_generation2)); - - logger->log_chunk(logger,RAW,"generated header",generated_data); - - tester->assert_true(tester,(memcmp(expected_generation2,generated_data.ptr,sizeof(expected_generation2)) == 0), "compare generated data 2"); - chunk_free(&generated_data); - - header_data->destroy(header_data); - - generator->destroy(generator); -} - -/* - * Described in header - */ -void test_generator_with_transform_attribute(protected_tester_t *tester) -{ - generator_t *generator; - transform_attribute_t *attribute; - chunk_t generated_data; - logger_t *logger; - - logger = logger_manager->get_logger(logger_manager, TESTER); - - - /* test empty attribute */ - generator = generator_create(); - tester->assert_true(tester,(generator != NULL), "generator create check"); - attribute = transform_attribute_create(); - generator->generate_payload(generator,(payload_t *)attribute); - generator->write_to_chunk(generator,&generated_data); - logger->log_chunk(logger,RAW,"generated attribute",generated_data); - - u_int8_t expected_generation[] = { - 0x80,0x00,0x00,0x00, - }; - tester->assert_true(tester,(memcmp(expected_generation,generated_data.ptr,sizeof(expected_generation)) == 0), "compare generated data"); - chunk_free(&generated_data); - attribute->destroy(attribute); - generator->destroy(generator); - - /* test attribute with 2 byte data */ - generator = generator_create(); - tester->assert_true(tester,(generator != NULL), "generator create check"); - - attribute = transform_attribute_create(); - u_int16_t dataval = 5768; - chunk_t data; - data.ptr = (void *) &dataval; - data.len = 2; - - attribute->set_value_chunk(attribute,data); - - generator->generate_payload(generator,(payload_t *)attribute); - generator->write_to_chunk(generator,&generated_data); - logger->log_chunk(logger,RAW,"generated attribute",generated_data); - - u_int8_t expected_generation2[] = { - 0x80,0x00,0x16,0x88, - }; - tester->assert_true(tester,(memcmp(expected_generation2,generated_data.ptr,sizeof(expected_generation2)) == 0), "compare generated data"); - - chunk_free(&generated_data); - attribute->destroy(attribute); - generator->destroy(generator); - - - - /* test attribute with 25 byte data */ - generator = generator_create(); - tester->assert_true(tester,(generator != NULL), "generator create check"); - - attribute = transform_attribute_create(); - char *stringval = "ddddddddddeeeeeeeeeefffff"; - data.ptr = (void *) stringval; - data.len = 25; - - attribute->set_value_chunk(attribute,data); - - attribute->set_attribute_type(attribute,456); - - - generator->generate_payload(generator,(payload_t *)attribute); - generator->write_to_chunk(generator,&generated_data); - logger->log_chunk(logger,RAW,"generated attribute",generated_data); - - u_int8_t expected_generation3[] = { - 0x01,0xC8,0x00,0x19, - 0x64,0x64,0x64,0x64, - 0x64,0x64,0x64,0x64, - 0x64,0x64,0x65,0x65, - 0x65,0x65,0x65,0x65, - 0x65,0x65,0x65,0x65, - 0x66,0x66,0x66,0x66, - 0x66 - }; - tester->assert_true(tester,(memcmp(expected_generation3,generated_data.ptr,sizeof(expected_generation3)) == 0), "compare generated data"); - - chunk_free(&generated_data); - attribute->destroy(attribute); - generator->destroy(generator); -} - - - -/* - * Described in header - */ -void test_generator_with_transform_substructure(protected_tester_t *tester) -{ - generator_t *generator; - transform_attribute_t *attribute1, *attribute2; - transform_substructure_t *transform; - chunk_t data; - chunk_t generated_data; - logger_t *logger; - - logger = logger_manager->get_logger(logger_manager,TESTER); - - /* create generator */ - generator = generator_create(); - tester->assert_true(tester,(generator != NULL), "generator create check"); - - /* create attribute 1 */ - attribute1 = transform_attribute_create(); - char *stringval = "abcd"; - data.ptr = (void *) stringval; - data.len = 4; - attribute1->set_value_chunk(attribute1,data); - attribute1->set_attribute_type(attribute1,0); - logger->log(logger,CONTROL,"attribute1 created"); - - /* create attribute 2 */ - attribute2 = transform_attribute_create(); - stringval = "efgh"; - data.ptr = (void *) stringval; - data.len = 4; - attribute2->set_value_chunk(attribute2,data); - attribute2->set_attribute_type(attribute2,0); - logger->log(logger,CONTROL,"attribute2 created"); - - /* create transform */ - transform = transform_substructure_create(); - tester->assert_true(tester,(transform != NULL), "transform create check"); - transform->add_transform_attribute(transform,attribute1); - transform->add_transform_attribute(transform,attribute2); - transform->set_transform_type(transform,5); /* hex 5 */ - transform->set_transform_id(transform,65000); /* hex FDE8 */ - - - logger->log(logger,CONTROL,"transform created"); - - generator->generate_payload(generator,(payload_t *)transform); - generator->write_to_chunk(generator,&generated_data); - logger->log_chunk(logger,RAW,"generated transform",generated_data); - - u_int8_t expected_generation3[] = { - 0x00,0x00,0x00,0x18, - 0x05,0x00,0xFD,0xE8, - 0x00,0x00,0x00,0x04, - 0x61,0x62,0x63,0x64, - 0x00,0x00,0x00,0x04, - 0x65,0x66,0x67,0x68, - }; - tester->assert_true(tester,(memcmp(expected_generation3,generated_data.ptr,sizeof(expected_generation3)) == 0), "compare generated data"); - - chunk_free(&generated_data); - transform->destroy(transform); - generator->destroy(generator); -} - - -/* - * Described in header - */ -void test_generator_with_proposal_substructure(protected_tester_t *tester) -{ - generator_t *generator; - transform_attribute_t *attribute1, *attribute2, *attribute3; - transform_substructure_t *transform1, *transform2; - proposal_substructure_t *proposal; - chunk_t data; - chunk_t generated_data; - logger_t *logger; - - logger = logger_manager->get_logger(logger_manager,TESTER); - - /* create generator */ - generator = generator_create(); - tester->assert_true(tester,(generator != NULL), "generator create check"); - - /* create attribute 1 */ - attribute1 = transform_attribute_create(); - char *stringval = "abcd"; - data.ptr = (void *) stringval; - data.len = 4; - attribute1->set_value_chunk(attribute1,data); - attribute1->set_attribute_type(attribute1,0); - - logger->log(logger,CONTROL,"attribute1 created"); - - /* create attribute 2 */ - attribute2 = transform_attribute_create(); - stringval = "efgh"; - data.ptr = (void *) stringval; - data.len = 4; - attribute2->set_value_chunk(attribute2,data); - attribute2->set_attribute_type(attribute2,0); - logger->log(logger,CONTROL,"attribute2 created"); - - /* create attribute 3 */ - attribute3 = transform_attribute_create(); - stringval = "ijkl"; - data.ptr = (void *) stringval; - data.len = 4; - attribute3->set_value_chunk(attribute3,data); - attribute3->set_attribute_type(attribute3,0); - logger->log(logger,CONTROL,"attribute3 created"); - - /* create transform 1*/ - transform1 = transform_substructure_create(); - tester->assert_true(tester,(transform1 != NULL), "transform create check"); - transform1->add_transform_attribute(transform1,attribute1); - transform1->add_transform_attribute(transform1,attribute2); - transform1->set_transform_type(transform1,5); /* hex 5 */ - transform1->set_transform_id(transform1,65000); /* hex FDE8 */ - - /* create transform 2*/ - transform2 = transform_substructure_create(); - tester->assert_true(tester,(transform2 != NULL), "transform create check"); - transform2->add_transform_attribute(transform2,attribute3); - transform2->set_transform_type(transform2,3); /* hex 3 */ - transform2->set_transform_id(transform2,4); /* hex 4 */ - - logger->log(logger,CONTROL,"transforms created"); - - proposal = proposal_substructure_create(); - tester->assert_true(tester,(proposal != NULL), "proposal create check"); - - stringval = "ABCDEFGH"; - data.ptr = (void *) stringval; - data.len = 8; - - proposal->add_transform_substructure(proposal,transform1); - proposal->add_transform_substructure(proposal,transform2); - proposal->set_spi(proposal,data); - proposal->set_proposal_number(proposal,7); - proposal->set_protocol_id(proposal,4); - - generator->generate_payload(generator,(payload_t *)proposal); - generator->write_to_chunk(generator,&generated_data); - logger->log_chunk(logger,RAW,"generated transform",generated_data); - - u_int8_t expected_generation[] = { - /* proposal header */ - 0x00,0x00,0x00,0x38, - 0x07,0x04,0x08,0x02, - /* SPI */ - 0x41,0x42,0x43,0x44, - 0x45,0x46,0x47,0x48, - /* first transform */ - 0x03,0x00,0x00,0x18, - 0x05,0x00,0xFD,0xE8, - /* first transform attributes */ - 0x00,0x00,0x00,0x04, - 0x61,0x62,0x63,0x64, - 0x00,0x00,0x00,0x04, - 0x65,0x66,0x67,0x68, - /* second transform */ - 0x00,0x00,0x00,0x10, - 0x03,0x00,0x00,0x04, - /* second transform attributes */ - 0x00,0x00,0x00,0x04, - 0x69,0x6A,0x6B,0x6C - }; - logger->log_bytes(logger,RAW,"expected transform",expected_generation,sizeof(expected_generation)); - - tester->assert_true(tester,(memcmp(expected_generation,generated_data.ptr,sizeof(expected_generation)) == 0), "compare generated data"); - - chunk_free(&generated_data); - proposal->destroy(proposal); - generator->destroy(generator); -} - -/* - * Described in header - */ -void test_generator_with_sa_payload(protected_tester_t *tester) -{ - generator_t *generator; - transform_attribute_t *attribute1, *attribute2, *attribute3; - transform_substructure_t *transform1, *transform2; - proposal_substructure_t *proposal_str1, *proposal_str2; - linked_list_t *list; - proposal_t *proposal1, *proposal2; - sa_payload_t *sa_payload; - ike_header_t *ike_header; - - chunk_t data; - chunk_t generated_data; - logger_t *logger; - - logger = logger_manager->get_logger(logger_manager,TESTER); - - /* create generator */ - generator = generator_create(); - tester->assert_true(tester,(generator != NULL), "generator create check"); - - /* --------------------------- */ - /* test first with self created proposals */ - - /* create attribute 1 */ - attribute1 = transform_attribute_create(); - char *stringval = "abcd"; - data.ptr = (void *) stringval; - data.len = 4; - attribute1->set_value_chunk(attribute1,data); - attribute1->set_attribute_type(attribute1,0); - logger->log(logger,CONTROL,"attribute1 created"); - - /* create attribute 2 */ - attribute2 = transform_attribute_create(); - stringval = "efgh"; - data.ptr = (void *) stringval; - data.len = 4; - attribute2->set_value_chunk(attribute2,data); - attribute2->set_attribute_type(attribute2,0); - logger->log(logger,CONTROL,"attribute2 created"); - - /* create attribute 3 */ - attribute3 = transform_attribute_create(); - stringval = "ijkl"; - data.ptr = (void *) stringval; - data.len = 4; - attribute3->set_value_chunk(attribute3,data); - attribute3->set_attribute_type(attribute3,0); - logger->log(logger,CONTROL,"attribute3 created"); - - /* create transform 1*/ - transform1 = transform_substructure_create(); - tester->assert_true(tester,(transform1 != NULL), "transform create check"); - transform1->add_transform_attribute(transform1,attribute1); - transform1->add_transform_attribute(transform1,attribute2); - transform1->set_transform_type(transform1,5); /* hex 5 */ - transform1->set_transform_id(transform1,65000); /* hex FDE8 */ - - /* create transform 2*/ - transform2 = transform_substructure_create(); - tester->assert_true(tester,(transform2 != NULL), "transform create check"); - transform2->add_transform_attribute(transform2,attribute3); - transform2->set_transform_type(transform2,3); /* hex 3 */ - transform2->set_transform_id(transform2,4); /* hex 4 */ - - logger->log(logger,CONTROL,"transforms created"); - - /* create proposal 1 */ - proposal_str1 = proposal_substructure_create(); - tester->assert_true(tester,(proposal1 != NULL), "proposal create check"); - - stringval = "ABCDEFGH"; - data.ptr = (void *) stringval; - data.len = 8; - - proposal_str1->add_transform_substructure(proposal_str1,transform1); - proposal_str1->add_transform_substructure(proposal_str1,transform2); - proposal_str1->set_spi(proposal_str1,data); - proposal_str1->set_proposal_number(proposal_str1,7); - proposal_str1->set_protocol_id(proposal_str1,4); - - /* create proposal 2 */ - proposal_str2 = proposal_substructure_create(); - tester->assert_true(tester,(proposal_str2 != NULL), "proposal create check"); - proposal_str2->set_proposal_number(proposal_str2,7); - proposal_str2->set_protocol_id(proposal_str2,5); - - /* create sa_payload */ - sa_payload = sa_payload_create(); - - sa_payload->add_proposal_substructure(sa_payload,proposal_str1); - sa_payload->add_proposal_substructure(sa_payload,proposal_str2); - - ike_header = ike_header_create(); - ike_header->set_initiator_spi(ike_header,0x22000054231234LL); - ike_header->set_responder_spi(ike_header,0x122398); - ((payload_t *) ike_header)->set_next_type((payload_t *) ike_header,SECURITY_ASSOCIATION); - ike_header->set_exchange_type(ike_header, 0x12); - ike_header->set_initiator_flag(ike_header, TRUE); - ike_header->set_response_flag(ike_header, TRUE); - ike_header->set_message_id(ike_header,0x33AFF3); - - generator->generate_payload(generator,(payload_t *)ike_header); - generator->generate_payload(generator,(payload_t *)sa_payload); - generator->write_to_chunk(generator,&generated_data); - logger->log_chunk(logger,RAW,"generated transform",generated_data); - - u_int8_t expected_generation[] = { - /* sa payload header */ - 0x34,0x12,0x23,0x54, - 0x00,0x00,0x22,0x00, - 0x98,0x23,0x12,0x00, - 0x00,0x00,0x00,0x00, - 0x21,0x20,0x12,0x28, - 0x00,0x33,0xAF,0xF3, - 0x00,0x00,0x00,0x60, - - /* sa payload header */ - 0x00,0x00,0x00,0x44, - /* proposal header */ - 0x02,0x00,0x00,0x38, - 0x07,0x04,0x08,0x02, - /* SPI */ - 0x41,0x42,0x43,0x44, - 0x45,0x46,0x47,0x48, - /* first transform */ - 0x03,0x00,0x00,0x18, - 0x05,0x00,0xFD,0xE8, - /* first transform attributes */ - 0x00,0x00,0x00,0x04, - 0x61,0x62,0x63,0x64, - 0x00,0x00,0x00,0x04, - 0x65,0x66,0x67,0x68, - /* second transform */ - 0x00,0x00,0x00,0x10, - 0x03,0x00,0x00,0x04, - /* second transform attributes */ - 0x00,0x00,0x00,0x04, - 0x69,0x6A,0x6B,0x6C, - /* proposal header 2*/ - 0x00,0x00,0x00,0x08, - 0x07,0x05,0x00,0x00, - - }; - - logger->log_bytes(logger,RAW,"expected transform",expected_generation,sizeof(expected_generation)); - - tester->assert_true(tester,(memcmp(expected_generation,generated_data.ptr,sizeof(expected_generation)) == 0), "compare generated data"); - - chunk_free(&generated_data); - ike_header->destroy(ike_header); - sa_payload->destroy(sa_payload); - generator->destroy(generator); - - /* --------------------------- */ - /* test with automatic created proposals */ - - generator = generator_create(); - tester->assert_true(tester,(generator != NULL), "generator create check"); - - - 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(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); - 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_generation2[] = { - 0x00,0x00,0x00,0x6C, /* payload header*/ - 0x02,0x00,0x00,0x34, /* a proposal */ - 0x01,0x01,0x00,0x04, - 0x03,0x00,0x00,0x0C, /* transform 1 */ - 0x01,0x00,0x00,0x01, - 0x80,0x0E,0x00,0x14, /* keylength attribute with 20 bytes length */ - 0x03,0x00,0x00,0x0C, /* transform 2 */ - 0x02,0x00,0x00,0x02, - 0x80,0x0E,0x00,0x16, /* keylength attribute with 20 bytes length */ - 0x03,0x00,0x00,0x0C, /* transform 3 */ - 0x03,0x00,0x00,0x03, - 0x80,0x0E,0x00,0x18, /* keylength attribute with 20 bytes length */ - 0x00,0x00,0x00,0x08, /* transform 4 */ - 0x04,0x00,0x00,0x04, - 0x00,0x00,0x00,0x34, /* a proposal */ - 0x02,0x01,0x00,0x04, - 0x03,0x00,0x00,0x0C, /* transform 1 */ - 0x01,0x00,0x00,0x05, - 0x80,0x0E,0x00,0x1A, /* keylength attribute with 16 bytes length */ - 0x03,0x00,0x00,0x0C, /* transform 2 */ - 0x02,0x00,0x00,0x06, - 0x80,0x0E,0x00,0x1C, /* keylength attribute with 16 bytes length */ - 0x03,0x00,0x00,0x0C, /* transform 3 */ - 0x03,0x00,0x00,0x07, - 0x80,0x0E,0x00,0x1E, /* keylength attribute with 16 bytes length */ - 0x00,0x00,0x00,0x08, /* transform 4 */ - 0x04,0x00,0x00,0x08, - - }; - - logger->log_bytes(logger,RAW,"expected",expected_generation2,sizeof(expected_generation2)); - - tester->assert_true(tester,(memcmp(expected_generation2,generated_data.ptr,sizeof(expected_generation2)) == 0), "compare generated data"); - - sa_payload->destroy(sa_payload); - list->destroy(list); - proposal1->destroy(proposal1); - proposal2->destroy(proposal2); - chunk_free(&generated_data); - generator->destroy(generator); -} - -/* - * Described in header - */ -void test_generator_with_ke_payload(protected_tester_t *tester) -{ - generator_t *generator; - ke_payload_t *ke_payload; - logger_t *logger; - chunk_t generated_data; - chunk_t key_exchange_data; - - logger = logger_manager->get_logger(logger_manager,TESTER); - - /* create generator */ - generator = generator_create(); - tester->assert_true(tester,(generator != NULL), "generator create check"); - - ke_payload = ke_payload_create(); - - - key_exchange_data.ptr = "test-text"; - key_exchange_data.len = strlen(key_exchange_data.ptr); - - ke_payload->set_key_exchange_data(ke_payload,key_exchange_data); - - ke_payload->set_dh_group_number(ke_payload,7777); - - generator->generate_payload(generator,(payload_t *)ke_payload); - generator->write_to_chunk(generator,&generated_data); - logger->log_chunk(logger,RAW,"generated payload",generated_data); - - u_int8_t expected_generation[] = { - /* payload header */ - 0x00,0x00,0x00,0x11, - 0x1E,0x61,0x00,0x00, - /* key exchange data */ - 0x74,0x65,0x73,0x74, - 0x2D,0x74,0x65,0x78, - 0x74 - }; - - - logger->log_bytes(logger,RAW,"expected payload",expected_generation,sizeof(expected_generation)); - - tester->assert_true(tester,(memcmp(expected_generation,generated_data.ptr,sizeof(expected_generation)) == 0), "compare generated data"); - - chunk_free(&generated_data); - - ke_payload->destroy(ke_payload); - generator->destroy(generator); - -} - -/* - * Described in header - */ -void test_generator_with_notify_payload(protected_tester_t *tester) -{ - generator_t *generator; - notify_payload_t *notify_payload; - logger_t *logger; - chunk_t generated_data; - chunk_t notification_data; - - logger = logger_manager->get_logger(logger_manager,TESTER); - - /* create generator */ - generator = generator_create(); - tester->assert_true(tester,(generator != NULL), "generator create check"); - - notify_payload = notify_payload_create(); - - notification_data.ptr = "67890"; - notification_data.len = strlen(notification_data.ptr); - - notify_payload->set_protocol_id(notify_payload,255); - notify_payload->set_notify_type(notify_payload,63333); /* Hex F765 */ - notify_payload->set_spi(notify_payload, 0x31323334); - notify_payload->set_notification_data(notify_payload,notification_data); - - generator->generate_payload(generator,(payload_t *)notify_payload); - generator->write_to_chunk(generator,&generated_data); - logger->log_chunk(logger,RAW,"generated payload",generated_data); - - u_int8_t expected_generation[] = { - /* payload header */ - 0x00,0x00,0x00,0x11, - 0xFF,0x04,0xF7,0x65, - /* spi */ - 0x31,0x32,0x33,0x34, - /* notification data */ - 0x36,0x37,0x38,0x39, - 0x30, - }; - - logger->log_bytes(logger,RAW,"expected payload",expected_generation,sizeof(expected_generation)); - - tester->assert_true(tester,(memcmp(expected_generation,generated_data.ptr,sizeof(expected_generation)) == 0), "compare generated data"); - - chunk_free(&generated_data); - - notify_payload->destroy(notify_payload); - generator->destroy(generator); -} - -/* - * Described in header - */ -void test_generator_with_nonce_payload(protected_tester_t *tester) -{ - generator_t *generator; - nonce_payload_t *nonce_payload; - logger_t *logger; - chunk_t generated_data; - chunk_t nonce; - - logger = logger_manager->get_logger(logger_manager,TESTER); - - /* create generator */ - generator = generator_create(); - tester->assert_true(tester,(generator != NULL), "generator create check"); - - nonce_payload = nonce_payload_create(); - - - nonce.ptr = "1234567890123456"; - nonce.len = strlen("1234567890123456"); - - nonce_payload->set_nonce(nonce_payload,nonce); - - generator->generate_payload(generator,(payload_t *)nonce_payload); - generator->write_to_chunk(generator,&generated_data); - logger->log_chunk(logger,RAW,"generated payload",generated_data); - - - u_int8_t expected_generation[] = { - /* payload header */ - 0x00,0x00,0x00,0x14, - /* nonce data */ - 0x31,0x32,0x33,0x34, - 0x35,0x36,0x37,0x38, - 0x39,0x30,0x31,0x32, - 0x33,0x34,0x35,0x36 - }; - - logger->log_bytes(logger,RAW,"expected payload",expected_generation,sizeof(expected_generation)); - - tester->assert_true(tester,(memcmp(expected_generation,generated_data.ptr,sizeof(expected_generation)) == 0), "compare generated data"); - - chunk_free(&generated_data); - - - nonce_payload->destroy(nonce_payload); - generator->destroy(generator); -} - -/* - * Described in header. - */ -void test_generator_with_id_payload(protected_tester_t *tester) -{ - generator_t *generator; - id_payload_t *id_payload; - logger_t *logger; - chunk_t generated_data; - chunk_t id; - - logger = logger_manager->get_logger(logger_manager,TESTER); - - /* create generator */ - generator = generator_create(); - tester->assert_true(tester,(generator != NULL), "generator create check"); - - id_payload = id_payload_create(FALSE); - - - id.ptr = "123456789012"; - id.len = strlen(id.ptr); - - id_payload->set_id_type(id_payload,ID_IPV4_ADDR); - id_payload->set_data(id_payload,id); - - generator->generate_payload(generator,(payload_t *)id_payload); - generator->write_to_chunk(generator,&generated_data); - logger->log_chunk(logger,RAW,"generated payload",generated_data); - - - u_int8_t expected_generation[] = { - /* payload header */ - 0x00,0x00,0x00,0x14, - 0x01,0x00,0x00,0x00, - /* id data */ - 0x31,0x32,0x33,0x34, - 0x35,0x36,0x37,0x38, - 0x39,0x30,0x31,0x32, - }; - - logger->log_bytes(logger,RAW,"expected payload",expected_generation,sizeof(expected_generation)); - - tester->assert_true(tester,(memcmp(expected_generation,generated_data.ptr,sizeof(expected_generation)) == 0), "compare generated data"); - - chunk_free(&generated_data); - - id_payload->destroy(id_payload); - generator->destroy(generator); -} - -/* - * Described in header. - */ -void test_generator_with_auth_payload(protected_tester_t *tester) -{ - generator_t *generator; - auth_payload_t *auth_payload; - logger_t *logger; - chunk_t generated_data; - chunk_t auth; - - logger = logger_manager->get_logger(logger_manager,TESTER); - - /* create generator */ - generator = generator_create(); - tester->assert_true(tester,(generator != NULL), "generator create check"); - - auth_payload = auth_payload_create(); - - - auth.ptr = "123456789012"; - auth.len = strlen(auth.ptr); - - auth_payload->set_auth_method(auth_payload,SHARED_KEY_MESSAGE_INTEGRITY_CODE); - auth_payload->set_data(auth_payload,auth); - - generator->generate_payload(generator,(payload_t *)auth_payload); - generator->write_to_chunk(generator,&generated_data); - logger->log_chunk(logger,RAW,"generated payload",generated_data); - - - u_int8_t expected_generation[] = { - /* payload header */ - 0x00,0x00,0x00,0x14, - 0x02,0x00,0x00,0x00, - /* auth data */ - 0x31,0x32,0x33,0x34, - 0x35,0x36,0x37,0x38, - 0x39,0x30,0x31,0x32, - }; - - logger->log_bytes(logger,RAW,"expected payload",expected_generation,sizeof(expected_generation)); - - tester->assert_true(tester,(memcmp(expected_generation,generated_data.ptr,sizeof(expected_generation)) == 0), "compare generated data"); - - chunk_free(&generated_data); - - auth_payload->destroy(auth_payload); - generator->destroy(generator); -} - -/* - * Described in header. - */ -void test_generator_with_ts_payload(protected_tester_t *tester) -{ - generator_t *generator; - ts_payload_t *ts_payload; - traffic_selector_substructure_t *ts1, *ts2; - host_t *start_host1, *start_host2, *end_host1, *end_host2; - logger_t *logger; - chunk_t generated_data; - - logger = logger_manager->get_logger(logger_manager,TESTER); - - /* create generator */ - generator = generator_create(); - tester->assert_true(tester,(generator != NULL), "generator create check"); - - ts_payload = ts_payload_create(TRUE); - - /* first traffic selector */ - ts1 = traffic_selector_substructure_create(); - - start_host1 = host_create(AF_INET,"192.168.1.0",500); - ts1->set_start_host(ts1,start_host1); - start_host1->destroy(start_host1); - - end_host1 = host_create(AF_INET,"192.168.1.255",500); - ts1->set_end_host(ts1,end_host1); - end_host1->destroy(end_host1); - - ts_payload->add_traffic_selector_substructure(ts_payload,ts1); - - /* second traffic selector */ - - ts2 = traffic_selector_substructure_create(); - - start_host2 = host_create(AF_INET,"0.0.0.0",0); - ts2->set_start_host(ts2,start_host2); - ts2->set_protocol_id(ts2,3); - start_host2->destroy(start_host2); - - end_host2 = host_create(AF_INET,"255.255.255.255",65535); - ts2->set_end_host(ts2,end_host2); - end_host2->destroy(end_host2); - - ts_payload->add_traffic_selector_substructure(ts_payload,ts2); - - - generator->generate_payload(generator,(payload_t *)ts_payload); - generator->write_to_chunk(generator,&generated_data); - logger->log_chunk(logger,RAW,"generated payload",generated_data); - - - u_int8_t expected_generation[] = { - /* payload header */ - 0x00,0x00,0x00,0x28, - 0x02,0x00,0x00,0x00, - - /* traffic selector 1 */ - 0x07,0x00,0x00,0x10, - 0x01,0xF4,0x01,0xF4, - 0xC0,0xA8,0x01,0x00, - 0xC0,0xA8,0x01,0xFF, - - /* traffic selector 2 */ - 0x07,0x03,0x00,0x10, - 0x00,0x00,0xFF,0xFF, - 0x00,0x00,0x00,0x00, - 0xFF,0xFF,0xFF,0xFF, - }; - - logger->log_bytes(logger,RAW,"expected payload",expected_generation,sizeof(expected_generation)); - - tester->assert_true(tester,(memcmp(expected_generation,generated_data.ptr,sizeof(expected_generation)) == 0), "compare generated data"); - - chunk_free(&generated_data); - - ts_payload->destroy(ts_payload); - generator->destroy(generator); -} - -/* - * Described in header. - */ -void test_generator_with_cert_payload(protected_tester_t *tester) -{ - generator_t *generator; - cert_payload_t *cert_payload; - logger_t *logger; - chunk_t generated_data; - chunk_t cert; - - logger = logger_manager->get_logger(logger_manager,TESTER); - - /* create generator */ - generator = generator_create(); - tester->assert_true(tester,(generator != NULL), "generator create check"); - - cert_payload = cert_payload_create(); - - - cert.ptr = "123456789012"; - cert.len = strlen(cert.ptr); - - cert_payload->set_cert_encoding(cert_payload, CERT_PGP); - cert_payload->set_data(cert_payload,cert); - - generator->generate_payload(generator,(payload_t *)cert_payload); - generator->write_to_chunk(generator,&generated_data); - logger->log_chunk(logger,RAW,"generated payload",generated_data); - - u_int8_t expected_generation[] = { - /* payload header */ - 0x00,0x00,0x00,0x11, - 0x02, - /* cert data */ - 0x31,0x32,0x33,0x34, - 0x35,0x36,0x37,0x38, - 0x39,0x30,0x31,0x32, - }; - - logger->log_bytes(logger,RAW,"expected payload",expected_generation,sizeof(expected_generation)); - - tester->assert_true(tester,(memcmp(expected_generation,generated_data.ptr,sizeof(expected_generation)) == 0), "compare generated data"); - - chunk_free(&generated_data); - - cert_payload->destroy(cert_payload); - generator->destroy(generator); -} - -/* - * Described in header. - */ -void test_generator_with_certreq_payload(protected_tester_t *tester) -{ - generator_t *generator; - certreq_payload_t *certreq_payload; - logger_t *logger; - chunk_t generated_data; - chunk_t certreq; - - logger = logger_manager->get_logger(logger_manager,TESTER); - - /* create generator */ - generator = generator_create(); - tester->assert_true(tester,(generator != NULL), "generator create check"); - - certreq_payload = certreq_payload_create(); - - - certreq.ptr = "123456789012"; - certreq.len = strlen(certreq.ptr); - - certreq_payload->set_cert_encoding(certreq_payload, CERT_PGP); - certreq_payload->set_data(certreq_payload,certreq); - - generator->generate_payload(generator,(payload_t *)certreq_payload); - generator->write_to_chunk(generator,&generated_data); - logger->log_chunk(logger,RAW,"generated payload",generated_data); - - u_int8_t expected_generation[] = { - /* payload header */ - 0x00,0x00,0x00,0x11, - 0x02, - /* certreq data */ - 0x31,0x32,0x33,0x34, - 0x35,0x36,0x37,0x38, - 0x39,0x30,0x31,0x32, - }; - - logger->log_bytes(logger,RAW,"expected payload",expected_generation,sizeof(expected_generation)); - - tester->assert_true(tester,(memcmp(expected_generation,generated_data.ptr,sizeof(expected_generation)) == 0), "compare generated data"); - - chunk_free(&generated_data); - - certreq_payload->destroy(certreq_payload); - generator->destroy(generator); -} - -/* - * Described in header. - */ -void test_generator_with_delete_payload(protected_tester_t *tester) -{ - generator_t *generator; - delete_payload_t *delete_payload; - logger_t *logger; - chunk_t generated_data; - chunk_t spis; - - logger = logger_manager->get_logger(logger_manager,TESTER); - - /* create generator */ - generator = generator_create(); - tester->assert_true(tester,(generator != NULL), "generator create check"); - - delete_payload = delete_payload_create(PROTO_AH); - - - spis.ptr = "123456789012"; - spis.len = strlen(spis.ptr); - - delete_payload->set_spi_count(delete_payload,3); - delete_payload->set_spi_size(delete_payload,4); - delete_payload->set_spis(delete_payload,spis); - - generator->generate_payload(generator,(payload_t *)delete_payload); - generator->write_to_chunk(generator,&generated_data); - logger->log_chunk(logger,RAW,"generated payload",generated_data); - - u_int8_t expected_generation[] = { - /* payload header */ - 0x00,0x00,0x00,0x14, - 0x02,0x04,0x00,0x03, - /* delete data */ - 0x31,0x32,0x33,0x34, - 0x35,0x36,0x37,0x38, - 0x39,0x30,0x31,0x32, - }; - - logger->log_bytes(logger,RAW,"expected payload",expected_generation,sizeof(expected_generation)); - - tester->assert_true(tester,(memcmp(expected_generation,generated_data.ptr,sizeof(expected_generation)) == 0), "compare generated data"); - - chunk_free(&generated_data); - - delete_payload->destroy(delete_payload); - generator->destroy(generator); -} - -/* - * Described in header. - */ -void test_generator_with_vendor_id_payload(protected_tester_t *tester) -{ - generator_t *generator; - vendor_id_payload_t *vendor_id_payload; - logger_t *logger; - chunk_t generated_data; - chunk_t data; - - logger = logger_manager->get_logger(logger_manager,TESTER); - - /* create generator */ - generator = generator_create(); - tester->assert_true(tester,(generator != NULL), "generator create check"); - - vendor_id_payload = vendor_id_payload_create(); - - - data.ptr = "123456789012"; - data.len = strlen(data.ptr); -; - vendor_id_payload->set_data(vendor_id_payload,data); - generator->generate_payload(generator,(payload_t *)vendor_id_payload); - generator->write_to_chunk(generator,&generated_data); - logger->log_chunk(logger,RAW,"generated payload",generated_data); - - u_int8_t expected_generation[] = { - /* payload header */ - 0x00,0x00,0x00,0x10, - /* vendor_id data */ - 0x31,0x32,0x33,0x34, - 0x35,0x36,0x37,0x38, - 0x39,0x30,0x31,0x32, - }; - - logger->log_bytes(logger,RAW,"expected payload",expected_generation,sizeof(expected_generation)); - - tester->assert_true(tester,(memcmp(expected_generation,generated_data.ptr,sizeof(expected_generation)) == 0), "compare generated data"); - - chunk_free(&generated_data); - - vendor_id_payload->destroy(vendor_id_payload); - generator->destroy(generator); -} - -/* - * Described in header - */ -void test_generator_with_cp_payload(protected_tester_t *tester) -{ - generator_t *generator; - configuration_attribute_t *attribute1, *attribute2; - cp_payload_t *configuration; - chunk_t data; - chunk_t generated_data; - logger_t *logger; - - logger = logger_manager->get_logger(logger_manager,TESTER); - - /* create generator */ - generator = generator_create(); - tester->assert_true(tester,(generator != NULL), "generator create check"); - - /* create attribute 1 */ - attribute1 = configuration_attribute_create(); - char *stringval = "abcd"; - data.ptr = (void *) stringval; - data.len = 4; - attribute1->set_value(attribute1,data); - attribute1->set_attribute_type(attribute1,3); - logger->log(logger,CONTROL,"attribute1 created"); - - /* create attribute 2 */ - attribute2 = configuration_attribute_create(); - stringval = "efgh"; - data.ptr = (void *) stringval; - data.len = 4; - attribute2->set_value(attribute2,data); - attribute2->set_attribute_type(attribute2,4); - logger->log(logger,CONTROL,"attribute2 created"); - - /* create configuration */ - configuration = cp_payload_create(); - tester->assert_true(tester,(configuration != NULL), "configuration create check"); - configuration->add_configuration_attribute(configuration,attribute1); - configuration->add_configuration_attribute(configuration,attribute2); - configuration->set_config_type(configuration,5); /* hex 5 */ - - - logger->log(logger,CONTROL,"cp payload created"); - - generator->generate_payload(generator,(payload_t *)configuration); - generator->write_to_chunk(generator,&generated_data); - logger->log_chunk(logger,RAW,"generated configuration",generated_data); - - u_int8_t expected_generation3[] = { - /* cp payload header */ - 0x00,0x00,0x00,0x18, - 0x05,0x00,0x00,0x00, - /* configuration attribute 1*/ - 0x00,0x03,0x00,0x04, - 0x61,0x62,0x63,0x64, - /* configuration attribute 2*/ - 0x00,0x04,0x00,0x04, - 0x65,0x66,0x67,0x68, - }; - - logger->log_bytes(logger,RAW,"expected configuration",expected_generation3,sizeof(expected_generation3)); - - tester->assert_true(tester,(memcmp(expected_generation3,generated_data.ptr,sizeof(expected_generation3)) == 0), "compare generated data"); - - chunk_free(&generated_data); - configuration->destroy(configuration); - generator->destroy(generator); -} - -/* - * Described in header. - */ -void test_generator_with_eap_payload(protected_tester_t *tester) -{ - generator_t *generator; - eap_payload_t *eap_payload; - logger_t *logger; - chunk_t generated_data; - chunk_t message; - - logger = logger_manager->get_logger(logger_manager,TESTER); - - /* create generator */ - generator = generator_create(); - tester->assert_true(tester,(generator != NULL), "generator create check"); - - eap_payload = eap_payload_create(); - - - message.ptr = "123456789012"; - message.len = strlen(message.ptr); -; - eap_payload->set_message(eap_payload,message); - generator->generate_payload(generator,(payload_t *)eap_payload); - generator->write_to_chunk(generator,&generated_data); - logger->log_chunk(logger,RAW,"generated payload",generated_data); - - u_int8_t expected_generation[] = { - /* payload header */ - 0x00,0x00,0x00,0x10, - /* eap data */ - 0x31,0x32,0x33,0x34, - 0x35,0x36,0x37,0x38, - 0x39,0x30,0x31,0x32, - }; - - logger->log_bytes(logger,RAW,"expected payload",expected_generation,sizeof(expected_generation)); - - tester->assert_true(tester,(memcmp(expected_generation,generated_data.ptr,sizeof(expected_generation)) == 0), "compare generated data"); - - chunk_free(&generated_data); - - eap_payload->destroy(eap_payload); - generator->destroy(generator); -} diff --git a/src/charon/testing/generator_test.h b/src/charon/testing/generator_test.h deleted file mode 100644 index 9a162bbed..000000000 --- a/src/charon/testing/generator_test.h +++ /dev/null @@ -1,184 +0,0 @@ -/** - * @file generator_test.h - * - * @brief Tests for the generator_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 . - * - * 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 GENERATOR_TEST_H_ -#define GENERATOR_TEST_H_ - -#include - -/** - * @brief Test function used to test the generator with header payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_generator_with_header_payload(protected_tester_t *tester); - -/** - * @brief Test function used to test the generator with transform attribute payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_generator_with_transform_attribute(protected_tester_t *tester); - - -/** - * @brief Test function used to test the generator with transform substructure payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_generator_with_transform_substructure(protected_tester_t *tester); - -/** - * @brief Test function used to test the generator with proposal substructure payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_generator_with_proposal_substructure(protected_tester_t *tester); - -/** - * @brief Test function used to test the generator with SA payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_generator_with_sa_payload(protected_tester_t *tester); - -/** - * @brief Test function used to test the generator with KE payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_generator_with_ke_payload(protected_tester_t *tester); - -/** - * @brief Test function used to test the generator with Notify payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_generator_with_notify_payload(protected_tester_t *tester); - -/** - * @brief Test function used to test the generator with Nonce payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_generator_with_nonce_payload(protected_tester_t *tester); - -/** - * @brief Test function used to test the generator with ID payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_generator_with_id_payload(protected_tester_t *tester); - -/** - * @brief Test function used to test the generator with AUTH payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_generator_with_auth_payload(protected_tester_t *tester); - -/** - * @brief Test function used to test the generator with TS payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_generator_with_ts_payload(protected_tester_t *tester); - -/** - * @brief Test function used to test the generator with CERT payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_generator_with_cert_payload(protected_tester_t *tester); - -/** - * @brief Test function used to test the generator with CERTREQ payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_generator_with_certreq_payload(protected_tester_t *tester); - -/** - * @brief Test function used to test the generator with DELETE payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_generator_with_delete_payload(protected_tester_t *tester); - -/** - * @brief Test function used to test the generator with VENDOR ID payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_generator_with_vendor_id_payload(protected_tester_t *tester); - -/** - * @brief Test function used to test the generator with CP payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_generator_with_cp_payload(protected_tester_t *tester); - -/** - * @brief Test function used to test the generator with EAP payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_generator_with_eap_payload(protected_tester_t *tester); - - -#endif /*GENERATOR_TEST_H_*/ diff --git a/src/charon/testing/hasher_test.c b/src/charon/testing/hasher_test.c deleted file mode 100644 index c0471fed6..000000000 --- a/src/charon/testing/hasher_test.c +++ /dev/null @@ -1,171 +0,0 @@ -/** - * @file hasher_test.h - * - * @brief Tests for the hasher_t classes. - * - */ - -/* - * 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 . - * - * 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 - -#include "hasher_test.h" - - -/* - * described in Header-File - */ -void test_md5_hasher(protected_tester_t *tester) -{ - /* - * Test vectors from RFC1321: - * MD5 ("") = d41d8cd98f00b204e9800998ecf8427e - * MD5 ("a") = 0cc175b9c0f1b6a831c399e269772661 - * MD5 ("abc") = 900150983cd24fb0d6963f7d28e17f72 - * MD5 ("message digest") = f96b697d7cb7938d525a2f31aaf161d0 - * MD5 ("abcdefghijklmnopqrstuvwxyz") = c3fcd3d76192e4007dfb496cca67e13b - * - * currently testing "", "abc", "abcdefghijklmnopqrstuvwxyz" - */ - hasher_t *hasher = hasher_create(HASH_MD5); - u_int8_t hash_buffer[16]; - chunk_t empty, abc, abcd, hash_chunk; - - u_int8_t hash_empty[] = { - 0xd4,0x1d,0x8c,0xd9, - 0x8f,0x00,0xb2,0x04, - 0xe9,0x80,0x09,0x98, - 0xec,0xf8,0x42,0x7e - }; - - u_int8_t hash_abc[] = { - 0x90,0x01,0x50,0x98, - 0x3c,0xd2,0x4f,0xb0, - 0xd6,0x96,0x3f,0x7d, - 0x28,0xe1,0x7f,0x72 - }; - - u_int8_t hash_abcd[] = { - 0xc3,0xfc,0xd3,0xd7, - 0x61,0x92,0xe4,0x00, - 0x7d,0xfb,0x49,0x6c, - 0xca,0x67,0xe1,0x3b - }; - - empty.ptr = ""; - empty.len = 0; - abc.ptr = "abc"; - abc.len = 3; - abcd.ptr = "abcdefghijklmnopqrstuvwxyz"; - abcd.len = strlen(abcd.ptr); - - tester->assert_true(tester, hasher->get_hash_size(hasher) == 16, "block size"); - - /* simple hashing, using empty */ - hasher->get_hash(hasher, empty, hash_buffer); - tester->assert_false(tester, memcmp(hash_buffer, hash_empty, 16), "hash for empty"); - - /* simple hashing, using "abc" */ - hasher->get_hash(hasher, abc, hash_buffer); - tester->assert_false(tester, memcmp(hash_buffer, hash_abc, 16), "hash for abc"); - - /* with allocation, using "abcdb..." */ - hasher->reset(hasher); - hasher->allocate_hash(hasher, abcd, &hash_chunk); - tester->assert_true(tester, hash_chunk.len == 16, "hash len"); - tester->assert_false(tester, memcmp(hash_chunk.ptr, hash_abcd, hash_chunk.len), "hash for abcd..."); - free(hash_chunk.ptr); - hasher->destroy(hasher); -} - -/* - * described in Header-File - */ -void test_sha1_hasher(protected_tester_t *tester) -{ - /* - * Test Vectors (from FIPS PUB 180-1) - * "abc" - * A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D - * "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" - * 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1 - * A million repetitions of "a" - * 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F - */ - hasher_t *hasher = hasher_create(HASH_SHA1); - u_int8_t hash_buffer[20]; - chunk_t abc, abcdb, aaa, hash_chunk; - u_int32_t i; - u_int8_t hash_abc[] = { - 0xA9,0x99,0x3E,0x36, - 0x47,0x06,0x81,0x6A, - 0xBA,0x3E,0x25,0x71, - 0x78,0x50,0xC2,0x6C, - 0x9C,0xD0,0xD8,0x9D - }; - u_int8_t hash_abcdb[] = { - 0x84,0x98,0x3E,0x44, - 0x1C,0x3B,0xD2,0x6E, - 0xBA,0xAE,0x4A,0xA1, - 0xF9,0x51,0x29,0xE5, - 0xE5,0x46,0x70,0xF1 - }; - u_int8_t hash_aaa[] = { - 0x34,0xAA,0x97,0x3C, - 0xD4,0xC4,0xDA,0xA4, - 0xF6,0x1E,0xEB,0x2B, - 0xDB,0xAD,0x27,0x31, - 0x65,0x34,0x01,0x6F - }; - abc.ptr = "abc"; - abc.len = 3; - abcdb.ptr = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; - abcdb.len = strlen(abcdb.ptr); - aaa.ptr = "aaaaaaaaaa"; /* 10 a's */ - aaa.len = 10; - - tester->assert_true(tester, hasher->get_hash_size(hasher) == 20, "block size"); - - /* simple hashing, using "abc" */ - hasher->get_hash(hasher, abc, hash_buffer); - tester->assert_false(tester, memcmp(hash_buffer, hash_abc, 20), "hash for abc"); - - /* with allocation, using "abcdb..." */ - hasher->reset(hasher); - hasher->allocate_hash(hasher, abcdb, &hash_chunk); - tester->assert_true(tester, hash_chunk.len == 20, "chunk len"); - tester->assert_false(tester, memcmp(hash_chunk.ptr, hash_abcdb, hash_chunk.len), "hash for abcdb..."); - free(hash_chunk.ptr); - - /* updating, using "aaaaaaa..." */ - hasher->reset(hasher); - for(i=0; i<100000; i++) - { - if (i != 99999) - { - hasher->get_hash(hasher, aaa, NULL); - } - else - { - hasher->get_hash(hasher, aaa, hash_buffer); - } - } - tester->assert_false(tester, memcmp(hash_buffer, hash_aaa, 20), "hash for aaa..."); - - - hasher->destroy(hasher); -} diff --git a/src/charon/testing/hasher_test.h b/src/charon/testing/hasher_test.h deleted file mode 100644 index 7877cd0fb..000000000 --- a/src/charon/testing/hasher_test.h +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @file hasher_test.h - * - * @brief Tests for the hasher_t classes. - * - */ - -/* - * 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 . - * - * 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 HASHER_TEST_H_ -#define HASHER_TEST_H_ - -#include -#include -#include -#include - -/** - * @brief Test function used to test the SHA1-hasher functionality. - * - * @param tester associated tester object - * - * @ingroup testcases - */ -void test_sha1_hasher(protected_tester_t *tester); - -/** - * @brief Test function used to test the Md5-hasher functionality. - * - * @param tester associated tester object - * - * @ingroup testcases - */ -void test_md5_hasher(protected_tester_t *tester); - -#endif /*HASHER_TEST_H_*/ diff --git a/src/charon/testing/hmac_signer_test.c b/src/charon/testing/hmac_signer_test.c deleted file mode 100644 index 7d4f0cfe3..000000000 --- a/src/charon/testing/hmac_signer_test.c +++ /dev/null @@ -1,204 +0,0 @@ -/** - * @file hmac_signer_test.c - * - * @brief Tests for the hmac_signer_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 . - * - * 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 - -#include "hmac_signer_test.h" - -#include -#include - - -/* - * Described in header. - */ -void test_hmac_md5_signer(protected_tester_t *tester) -{ - /* Test cases from RFC2202 - * - * test_case = 5 - * key = 0x0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c - * key_len = 16 - * data = "Test With Truncation" - * data_len = 20 - * digest = 0x56461ef2342edc00f9bab995690efd4c - * digest-96 0x56461ef2342edc00f9bab995 - * - * currently only this test 5 gets performed! - */ - chunk_t keys[4]; - chunk_t data[4]; - chunk_t signature[4]; - chunk_t reference[4]; - chunk_t wrong_reference[4]; - int i; - logger_t *logger; - bool valid; - - logger = logger_manager->get_logger(logger_manager, TESTER); - - signer_t *signer = (signer_t *) signer_create(AUTH_HMAC_MD5_96); - tester->assert_true(tester, (signer != NULL), "signer create call check"); - - - /* - * values for test 5 - */ - u_int8_t key1[] = { - 0x0c,0x0c,0x0c,0x0c, - 0x0c,0x0c,0x0c,0x0c, - 0x0c,0x0c,0x0c,0x0c, - 0x0c,0x0c,0x0c,0x0c, - }; - keys[0].ptr = key1; - keys[0].len = sizeof(key1); - data[0].ptr = "Test With Truncation"; - data[0].len = 20; - u_int8_t reference1[] = { - 0x56,0x46,0x1e,0xf2,0x34,0x2e, - 0xdc,0x00,0xf9,0xba,0xb9,0x95 - }; - reference[0].ptr = reference1; - reference[0].len = sizeof(reference1); - - u_int8_t wrong_reference1[] = { - 0x56,0x46,0x1e,0xa2,0x34,0x2e, - 0xdc,0x00,0xf9,0xba,0xb9,0x95 - }; - - wrong_reference[0].ptr = wrong_reference1; - wrong_reference[0].len = sizeof(wrong_reference1); - - for (i=0; i<1; i++) - { - signer->set_key(signer, keys[i]); - signer->allocate_signature(signer, data[i], &signature[i]); - tester->assert_true(tester, signature[i].len == 12, "chunk len"); - tester->assert_true(tester, (memcmp(signature[i].ptr, reference[i].ptr, 12) == 0), "hmac value"); - logger->log_chunk(logger,RAW,"expected signature:",reference[i]); - logger->log_chunk(logger,RAW,"signature:",signature[i]); - free(signature[i].ptr); - valid = signer->verify_signature(signer, data[i],reference[i]); - tester->assert_true(tester, (valid == TRUE), "Signature valid check"); - - valid = signer->verify_signature(signer, data[i],wrong_reference[i]); - tester->assert_true(tester, (valid == FALSE), "Signature not valid check"); - } - signer->destroy(signer); -} - - -/* - * Described in header. - */ -void test_hmac_sha1_signer(protected_tester_t *tester) -{ - /* - * test_case = 7 - * key = 0xaa repeated 80 times - * key_len = 80 - * data = "Test Using Larger Than Block-Size Key and Larger - * Than One Block-Size Data" - * data_len = 73 - * digest = 0x4c1a03424b55e07fe7f27be1d58bb9324a9a5a04 - * digest-96 = 0x4c1a03424b55e07fe7f27be1 - */ - - chunk_t keys[4]; - chunk_t data[4]; - chunk_t signature[4]; - chunk_t reference[4]; - chunk_t wrong_reference[4]; - int i; - logger_t *logger; - bool valid; - - logger = logger_manager->get_logger(logger_manager, TESTER); - - signer_t *signer = (signer_t *) signer_create(AUTH_HMAC_SHA1_96); - tester->assert_true(tester, (signer != NULL), "signer create call check"); - - - /* - * values for test 5 - */ - u_int8_t key1[] = { - 0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa, - }; - keys[0].ptr = key1; - keys[0].len = sizeof(key1); - data[0].ptr = "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data"; - data[0].len = 73; - u_int8_t reference1[] = { - 0xe8,0xe9,0x9d,0x0f,0x45,0x23, - 0x7d,0x78,0x6d,0x6b,0xba,0xa7 - }; - reference[0].ptr = reference1; - reference[0].len = sizeof(reference1); - - u_int8_t wrong_reference1[] = { - 0xe8,0xe9,0x9d,0x0f,0x46,0x23, - 0x7d,0x71,0x6d,0x6b,0xba,0xa7 - }; - - wrong_reference[0].ptr = wrong_reference1; - wrong_reference[0].len = sizeof(wrong_reference1); - - for (i=0; i<1; i++) - { - signer->set_key(signer, keys[i]); - signer->allocate_signature(signer, data[i], &signature[i]); - tester->assert_true(tester, signature[i].len == 12, "chunk len"); - tester->assert_true(tester, (memcmp(signature[i].ptr, reference[i].ptr, 12) == 0), "hmac value"); - logger->log_chunk(logger,RAW,"expected signature:",reference[i]); - logger->log_chunk(logger,RAW,"signature:",signature[i]); - free(signature[i].ptr); - valid = signer->verify_signature(signer, data[i],reference[i]); - tester->assert_true(tester, (valid == TRUE), "Signature valid check"); - - valid = signer->verify_signature(signer, data[i],wrong_reference[i]); - tester->assert_true(tester, (valid == FALSE), "Signature not valid check"); - } - - signer->destroy(signer); -} diff --git a/src/charon/testing/hmac_signer_test.h b/src/charon/testing/hmac_signer_test.h deleted file mode 100644 index a8b02ba04..000000000 --- a/src/charon/testing/hmac_signer_test.h +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @file hmac_signer_test.h - * - * @brief Tests for the hmac_signer_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 . - * - * 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 HMAC_SIGNER_TEST_H_ -#define HMAC_SIGNER_TEST_H_ - -#include - -/** - * @brief Test function used to test the hmac sign functionality using MD5. - * - * @param tester associated tester object - * - * @ingroup testcases - */ -void test_hmac_md5_signer(protected_tester_t *tester); - -/** - * @brief Test function used to test the hmac sign functionality using SHA1. - * - * @param tester associated tester object - * - * @ingroup testcases - */ -void test_hmac_sha1_signer(protected_tester_t *tester); - -#endif /* HMAC_SIGNER_TEST_H_ */ diff --git a/src/charon/testing/hmac_test.c b/src/charon/testing/hmac_test.c deleted file mode 100644 index 800e0db12..000000000 --- a/src/charon/testing/hmac_test.c +++ /dev/null @@ -1,409 +0,0 @@ -/** - * @file hmac_test.h - * - * @brief Tests for the hmac_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 . - * - * 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 - -#include "hmac_test.h" - -#include - - -/* - * described in Header-File - */ -void test_hmac_sha1(protected_tester_t *tester) -{ - /* - * Test cases from RFC2202 - * - * test_case = 1 - * key = 0x0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b - * key_len = 20 - * data = "Hi There" - * data_len = 8 - * digest = 0xb617318655057264e28bc0b6fb378c8ef146be00 - * - * test_case = 2 - * key = "Jefe" - * key_len = 4 - * data = "what do ya want for nothing?" - * data_len = 28 - * digest = 0xeffcdf6ae5eb2fa2d27416d5f184df9c259a7c79 - * - * test_case = 3 - * key = 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - * key_len = 20 - * data = 0xdd repeated 50 times - * data_len = 50 - * digest = 0x125d7342b9ac11cd91a39af48aa17b4f63f175d3 - * - * test_case = 4 - * key = 0x0102030405060708090a0b0c0d0e0f10111213141516171819 - * key_len = 25 - * data = 0xcd repeated 50 times - * data_len = 50 - * digest = 0x4c9007f4026250c6bc8414f9bf50c86c2d7235da - * - * test_case = 5 - * key = 0x0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c - * key_len = 20 - * data = "Test With Truncation" - * data_len = 20 - * digest = 0x4c1a03424b55e07fe7f27be1d58bb9324a9a5a04 - * digest-96 = 0x4c1a03424b55e07fe7f27be1 - * - * test_case = 6 - * key = 0xaa repeated 80 times - * key_len = 80 - * data = "Test Using Larger Than Block-Size Key - Hash Key First" - * data_len = 54 - * digest = 0xaa4ae5e15272d00e95705637ce8a3b55ed402112 - * - * test_case = 7 - * key = 0xaa repeated 80 times - * key_len = 80 - * data = "Test Using Larger Than Block-Size Key and Larger - * Than One Block-Size Data" - * data_len = 73 - * digest = 0xe8e99d0f45237d786d6bbaa7965c7808bbff1a91 - * - * currently performing test 1, 2, 4 and 7 - */ - - chunk_t keys[4]; - chunk_t data[4]; - chunk_t digest[4]; - chunk_t reference[4]; - int i; - - /* - * values for test 1 - */ - u_int8_t key1[] = { - 0x0b,0x0b,0x0b,0x0b, - 0x0b,0x0b,0x0b,0x0b, - 0x0b,0x0b,0x0b,0x0b, - 0x0b,0x0b,0x0b,0x0b, - 0x0b,0x0b,0x0b,0x0b - }; - keys[0].ptr = key1; - keys[0].len = sizeof(key1); - data[0].ptr = "Hi There"; - data[0].len = 8; - u_int8_t reference1[] = { - 0xb6,0x17,0x31,0x86, - 0x55,0x05,0x72,0x64, - 0xe2,0x8b,0xc0,0xb6, - 0xfb,0x37,0x8c,0x8e, - 0xf1,0x46,0xbe,0x00 - }; - reference[0].ptr = reference1; - reference[0].len = sizeof(reference1); - - /* - * values for test 2 - */ - u_int8_t reference2[] = { - 0xef,0xfc,0xdf,0x6a, - 0xe5,0xeb,0x2f,0xa2, - 0xd2,0x74,0x16,0xd5, - 0xf1,0x84,0xdf,0x9c, - 0x25,0x9a,0x7c,0x79 - }; - keys[1].ptr = "Jefe"; - keys[1].len = 4; - data[1].ptr = "what do ya want for nothing?"; - data[1].len = 28; - reference[1].ptr = reference2; - reference[1].len = sizeof(reference2); - - /* - * values for test 7 - */ - u_int8_t key7[] = { - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - }; - u_int8_t reference7[] = { - 0xe8,0xe9,0x9d,0x0f, - 0x45,0x23,0x7d,0x78, - 0x6d,0x6b,0xba,0xa7, - 0x96,0x5c,0x78,0x08, - 0xbb,0xff,0x1a,0x91 - }; - keys[2].ptr = key7; - keys[2].len = sizeof(key7); - data[2].ptr = "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data"; - data[2].len = 73; - reference[2].ptr = reference7; - reference[2].len = sizeof(reference7); - - - for (i=0; i<3; i++) - { - hmac_t *hmac = hmac_create(HASH_SHA1); - hmac->set_key(hmac, keys[i]); - hmac->allocate_mac(hmac, data[i], &digest[i]); - hmac->destroy(hmac); - - tester->assert_true(tester, digest[i].len == 20, "chunk len"); - tester->assert_false(tester, memcmp(digest[i].ptr, reference[i].ptr, 20), "hmac value"); - free(digest[i].ptr); - } - - /* - * test 4 is donne in append mode - */ - u_int8_t val = 0xcd; - - u_int8_t key4[] = { - 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 - }; - keys[3].ptr = key4; - keys[3].len = sizeof(key4); - u_int8_t reference4[] = { - 0x4c,0x90,0x07,0xf4, - 0x02,0x62,0x50,0xc6, - 0xbc,0x84,0x14,0xf9, - 0xbf,0x50,0xc8,0x6c, - 0x2d,0x72,0x35,0xda - }; - reference[3].ptr = reference4; - reference[3].len = sizeof(reference4); - - hmac_t *hmac = hmac_create(HASH_SHA1); - hmac->set_key(hmac, keys[3]); - data[3].ptr = &val; - data[3].len = 1; - for (i=0; i<49; i++) - { - hmac->get_mac(hmac, data[3], NULL); - } - hmac->allocate_mac(hmac, data[3], &digest[3]); - hmac->destroy(hmac); - - tester->assert_true(tester, digest[3].len == 20, "chunk len append mode"); - tester->assert_false(tester, memcmp(digest[3].ptr, reference[3].ptr, 20), "hmac value append mode"); - free(digest[3].ptr); -} - -/* - * described in Header-File - */ -void test_hmac_md5(protected_tester_t *tester) -{ - /* - * Test cases from RFC2202 - * - * test_case = 1 - * key = 0x0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b - * key_len = 16 - * data = "Hi There" - * data_len = 8 - * digest = 0x9294727a3638bb1c13f48ef8158bfc9d - * - * test_case = 2 - * key = "Jefe" - * key_len = 4 - * data = "what do ya want for nothing?" - * data_len = 28 - * digest = 0x750c783e6ab0b503eaa86e310a5db738 - * - * test_case = 3 - * key = 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - * key_len 16 - * data = 0xdd repeated 50 times - * data_len = 50 - * digest = 0x56be34521d144c88dbb8c733f0e8b3f6 - * - * test_case = 4 - * key = 0x0102030405060708090a0b0c0d0e0f10111213141516171819 - * key_len 25 - * data = 0xcd repeated 50 times - * data_len = 50 - * digest = 0x697eaf0aca3a3aea3a75164746ffaa79 - * - * test_case = 5 - * key = 0x0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c - * key_len = 16 - * data = "Test With Truncation" - * data_len = 20 - * digest = 0x56461ef2342edc00f9bab995690efd4c - * digest-96 0x56461ef2342edc00f9bab995 - * - * test_case = 6 - * key = 0xaa repeated 80 times - * key_len = 80 - * data = "Test Using Larger Than Block-Size Key - Hash Key First" - * data_len = 54 - * digest = 0x6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd - * - * test_case = 7 - * key = 0xaa repeated 80 times - * key_len = 80 - * data = "Test Using Larger Than Block-Size Key and Larger - * Than One Block-Size Data" - * data_len = 73 - * digest = 0x6f630fad67cda0ee1fb1f562db3aa53e - * - * - * - * currently performing test 1, 2, 4 and 7 - * - */ - chunk_t keys[4]; - chunk_t data[4]; - chunk_t digest[4]; - chunk_t reference[4]; - int i; - - /* - * values for test 1 - */ - u_int8_t key1[] = { - 0x0b,0x0b,0x0b,0x0b, - 0x0b,0x0b,0x0b,0x0b, - 0x0b,0x0b,0x0b,0x0b, - 0x0b,0x0b,0x0b,0x0b, - }; - keys[0].ptr = key1; - keys[0].len = sizeof(key1); - data[0].ptr = "Hi There"; - data[0].len = 8; - u_int8_t reference1[] = { - 0x92,0x94,0x72,0x7a, - 0x36,0x38,0xbb,0x1c, - 0x13,0xf4,0x8e,0xf8, - 0x15,0x8b,0xfc,0x9d - }; - reference[0].ptr = reference1; - reference[0].len = sizeof(reference1); - - /* - * values for test 2 - */ - u_int8_t reference2[] = { - 0x75,0x0c,0x78,0x3e, - 0x6a,0xb0,0xb5,0x03, - 0xea,0xa8,0x6e,0x31, - 0x0a,0x5d,0xb7,0x38 - }; - keys[1].ptr = "Jefe"; - keys[1].len = 4; - data[1].ptr = "what do ya want for nothing?"; - data[1].len = 28; - reference[1].ptr = reference2; - reference[1].len = sizeof(reference2); - - /* - * values for test 7 - */ - u_int8_t key7[] = { - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - }; - u_int8_t reference7[] = { - 0x6f,0x63,0x0f,0xad, - 0x67,0xcd,0xa0,0xee, - 0x1f,0xb1,0xf5,0x62, - 0xdb,0x3a,0xa5,0x3e - }; - keys[2].ptr = key7; - keys[2].len = sizeof(key7); - data[2].ptr = "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data"; - data[2].len = 73; - reference[2].ptr = reference7; - reference[2].len = sizeof(reference7); - - - for (i=0; i<3; i++) - { - hmac_t *hmac = hmac_create(HASH_MD5); - hmac->set_key(hmac, keys[i]); - hmac->allocate_mac(hmac, data[i], &digest[i]); - hmac->destroy(hmac); - tester->assert_true(tester, digest[i].len == 16, "chunk len"); - tester->assert_false(tester, memcmp(digest[i].ptr, reference[i].ptr, 16), "hmac value"); - free(digest[i].ptr); - } - - /* - * test 4 is donne in append mode - */ - u_int8_t val = 0xcd; - - u_int8_t key4[] = { - 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 - }; - keys[3].ptr = key4; - keys[3].len = sizeof(key4); - u_int8_t reference4[] = { - 0x69,0x7e,0xaf,0x0a, - 0xca,0x3a,0x3a,0xea, - 0x3a,0x75,0x16,0x47, - 0x46,0xff,0xaa,0x79 - }; - reference[3].ptr = reference4; - reference[3].len = sizeof(reference4); - - hmac_t *hmac = hmac_create(HASH_MD5); - hmac->set_key(hmac, keys[3]); - data[3].ptr = &val; - data[3].len = 1; - for (i=0; i<49; i++) - { - hmac->get_mac(hmac, data[3], NULL); - } - hmac->allocate_mac(hmac, data[3], &digest[3]); - hmac->destroy(hmac); - - tester->assert_true(tester, digest[3].len == 16, "chunk len append mode"); - tester->assert_false(tester, memcmp(digest[3].ptr, reference[3].ptr, 16), "hmac value append mode"); - free(digest[3].ptr); -} diff --git a/src/charon/testing/hmac_test.h b/src/charon/testing/hmac_test.h deleted file mode 100644 index f7b9846a0..000000000 --- a/src/charon/testing/hmac_test.h +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @file hmac_test.h - * - * @brief Tests for the hmac_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 . - * - * 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 HMAC_TEST_H_ -#define HMAC_TEST_H_ - -#include -#include - -/** - * @brief Test function used to test the hmac functionality - * using SHA1. - * - * @param tester associated tester object - * - * @ingroup testcases - */ -void test_hmac_sha1(protected_tester_t *tester); - -/** - * @brief Test function used to test the hmac functionality - * using MD5. - * - * @param tester associated tester object - * - * @ingroup testcases - */ -void test_hmac_md5(protected_tester_t *tester); - -#endif /*HMAC_TEST_H_*/ diff --git a/src/charon/testing/identification_test.c b/src/charon/testing/identification_test.c deleted file mode 100644 index c821bcc48..000000000 --- a/src/charon/testing/identification_test.c +++ /dev/null @@ -1,167 +0,0 @@ -/** - * @file identification_test.c - * - * @brief Tests for the identification_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 . - * - * 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 - -#include "identification_test.h" - -#include -#include - -/* - * described in Header-File - */ -void test_identification(protected_tester_t *tester) -{ - identification_t *a, *b, *c, *d; - bool result; - int wildcards; - - { /* test RFC822_ADDR */ - char *bob_string = "bob@wonderland.net"; - chunk_t bob_chunk = {bob_string, strlen(bob_string)}; - - a = identification_create_from_string("alice@wonderland.net"); - b = identification_create_from_encoding(ID_RFC822_ADDR, bob_chunk); - c = identification_create_from_string("*@wonderland.net"); - d = identification_create_from_string("*@badlands.com"); - - result = a->matches(a, c, &wildcards); - tester->assert_true(tester, result, "alice belongs to wonderland"); - result = b->matches(b, c, &wildcards); - tester->assert_true(tester, result, "bob belongs to wonderland"); - result = a->matches(a, d, &wildcards); - tester->assert_false(tester, result, "alice does not belong to badlands"); - result = b->matches(b, d, &wildcards); - tester->assert_false(tester, result, "bob does not belong to badlands"); - result = c->matches(c, d, &wildcards); - tester->assert_false(tester, result, "wonderland is not in badlands"); - result = a->matches(a, a, &wildcards); - tester->assert_true(tester, result, "alice belongs to alice alice"); - result = a->equals(a, a); - tester->assert_true(tester, result, "alice is alice"); - result = a->equals(a, b); - tester->assert_false(tester, result, "alice is not bob"); - - a->destroy(a); - b->destroy(b); - c->destroy(c); - d->destroy(d); - } - - { /* test FQDN */ - char *bob_string = "@dave.nirvana.org"; - chunk_t bob_chunk = {bob_string, strlen(bob_string)}; - - a = identification_create_from_string("@carol.nirvana.org"); - b = identification_create_from_encoding(ID_FQDN, bob_chunk); - c = identification_create_from_string("@*.nirvana.org"); - d = identification_create_from_string("@*.samsara.com"); - - result = a->matches(a, c, &wildcards); - tester->assert_true(tester, result, "carol belongs to nirvana"); - result = b->matches(b, c, &wildcards); - tester->assert_true(tester, result, "dave belongs to nirvana"); - result = a->matches(a, d, &wildcards); - tester->assert_false(tester, result, "carol does not belong to samsara"); - result = b->matches(b, d, &wildcards); - tester->assert_false(tester, result, "dave does not belong to samsara"); - result = c->matches(c, d, &wildcards); - tester->assert_false(tester, result, "nirvana is not in samsara"); - result = a->matches(a, a, &wildcards); - tester->assert_true(tester, result, "carol belongs to carol carol"); - result = a->equals(a, a); - tester->assert_true(tester, result, "carol is carol"); - result = a->equals(a, b); - tester->assert_false(tester, result, "carol is not dave"); - - a->destroy(a); - b->destroy(b); - c->destroy(c); - d->destroy(d); - } - - - { /* test ID IPV4 ADDR, no wildcards yet */ - char bob_addr[] = {192,168,0,2}; - chunk_t bob_chunk = chunk_from_buf(bob_addr); - - a = identification_create_from_string("192.168.0.1"); - b = identification_create_from_encoding(ID_IPV4_ADDR, bob_chunk); - c = identification_create_from_string("192.168.0.2"); /* as bob */ - - result = a->equals(a, a); - tester->assert_true(tester, result, "IPV4_ADDR of alice equals IPV4_ADDR of alice"); - result = b->equals(b, c); - tester->assert_true(tester, result, "IPV4_ADDR of bob equals IPV4_ADDR of carol"); - result = a->equals(a, b); - tester->assert_false(tester, result, "IPV4_ADDR of alice doesn't equal IPV4_ADDR of bob"); - - a->destroy(a); - b->destroy(b); - c->destroy(c); - } - - { /* test ID IPV6 ADDR, no wildcards yet */ - char bob_addr[] = {0x20,0x01,0x0d,0xb8,0x85,0xa3,0x08,0xd3,0x13,0x19,0x8a,0x2e,0x03,0x70,0x73,0x44}; - chunk_t bob_chunk = chunk_from_buf(bob_addr); - - a = identification_create_from_string("2001:0db8:85a3:08d3:1319:8a2e:0370:7345"); - b = identification_create_from_encoding(ID_IPV6_ADDR, bob_chunk); - c = identification_create_from_string("2001:0db8:85a3:08d3:1319:8a2e:0370:7344"); /* as bob */ - - result = a->equals(a, a); - tester->assert_true(tester, result, "IPV6_ADDR of alice equals IPV6_ADDR of alice"); - result = b->equals(b, c); - tester->assert_true(tester, result, "IPV6_ADDR of bob equals IPV6_ADDR of carol"); - result = a->equals(a, b); - tester->assert_false(tester, result, "IPV6_ADDR of alice doesn't equal IPV6_ADDR of bob"); - - a->destroy(a); - b->destroy(b); - c->destroy(c); - } - - { /* test ID DER_ASN1_DN */ - a = identification_create_from_string("C=CH, O=Linux strongSwan, CN=alice"); - b = identification_create_from_string("O=Linux strongSwan, C=CH, CN=bob"); - c = identification_create_from_string("C=CH, O=Linux strongSwan, CN=*"); - d = identification_create_from_string("C=CH, O=Linux openswan, CN=*"); - - result = a->equals(a, a); - tester->assert_true(tester, result, "DN of alice equals DN of alice"); - result = a->equals(a, b); - tester->assert_false(tester, result, "DN of alice doesn't equal DN of bob"); - result = a->matches(a, c, &wildcards); - tester->assert_true(tester, result, "DN of alice belongs to DN of carol"); - /* TODO: This does NOT work, wildcard check should work with unordered RDNs */ - result = b->matches(b, c, &wildcards); - tester->assert_true(tester, result, "DN of bob belongs to DN of carol"); - result = b->matches(b, d, &wildcards); - tester->assert_false(tester, result, "DN of bob doesn't belong to DN of dave"); - - a->destroy(a); - b->destroy(b); - c->destroy(c); - d->destroy(d); - } -} diff --git a/src/charon/testing/identification_test.h b/src/charon/testing/identification_test.h deleted file mode 100644 index b1078c52f..000000000 --- a/src/charon/testing/identification_test.h +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @file identification_test.h - * - * @brief Tests for the identification_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 . - * - * 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 IDENTIFICATION_TEST_H_ -#define IDENTIFICATION_TEST_H_ - -#include - -/** - * @brief Test function used to test the identification functionality. - * - * @param tester associated tester object - * - * @ingroup testcases - */ -void test_identification(protected_tester_t *tester); - -#endif /* IDENTIFICATION_TEST_H_ */ diff --git a/src/charon/testing/ike_sa_id_test.c b/src/charon/testing/ike_sa_id_test.c deleted file mode 100644 index 9ac95198f..000000000 --- a/src/charon/testing/ike_sa_id_test.c +++ /dev/null @@ -1,85 +0,0 @@ -/** - * @file ike_sa_id_test.c - * - * @brief Tests for the ike_sa_id_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 . - * - * 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 "ike_sa_id_test.h" - -#include - -/* - * described in Header-File - */ -void test_ike_sa_id(protected_tester_t *tester) -{ - ike_sa_id_t *ike_sa_id, *clone, *equal, *other1, *other2, *other3, *other4; - u_int64_t initiator, initiator2, responder, responder2; - bool is_initiator; - - initiator = 0; - - initiator2 = 12345612; - - responder = 34334; - - responder2 = 987863; - - is_initiator = TRUE; - - ike_sa_id = ike_sa_id_create(initiator, responder, is_initiator); - equal = ike_sa_id_create(initiator, responder, is_initiator); - other1 = ike_sa_id_create(initiator, responder2, is_initiator); - other2 = ike_sa_id_create(initiator2, responder2, is_initiator); - other3 = ike_sa_id_create(initiator2, responder, is_initiator); - is_initiator = FALSE; - other4 = ike_sa_id_create(initiator, responder, is_initiator); - - /* check equality */ - tester->assert_true(tester,(ike_sa_id->equals(ike_sa_id,equal) == TRUE), "equal check"); - tester->assert_true(tester,(equal->equals(equal,ike_sa_id) == TRUE), "equal check"); - - /* check clone functionality and equality*/ - clone = ike_sa_id->clone(ike_sa_id); - tester->assert_false(tester,(clone == ike_sa_id), "clone pointer check"); - tester->assert_true(tester,(ike_sa_id->equals(ike_sa_id,clone) == TRUE), "equal check"); - - /* check for non equality */ - tester->assert_false(tester,(ike_sa_id->equals(ike_sa_id,other1) == TRUE), "equal check"); - - tester->assert_false(tester,(ike_sa_id->equals(ike_sa_id,other2) == TRUE), "equal check"); - - tester->assert_false(tester,(ike_sa_id->equals(ike_sa_id,other3) == TRUE), "equal check"); - - tester->assert_false(tester,(ike_sa_id->equals(ike_sa_id,other4) == TRUE), "equal check"); - - other4->replace_values(other4,ike_sa_id); - tester->assert_true(tester,(ike_sa_id->equals(ike_sa_id,other4) == TRUE), "equal check"); - - - /* check destroy functionality */ - ike_sa_id->destroy(ike_sa_id); - equal->destroy(equal); - clone->destroy(clone); - other1->destroy(other1); - other2->destroy(other2); - other3->destroy(other3); - other4->destroy(other4); -} diff --git a/src/charon/testing/ike_sa_id_test.h b/src/charon/testing/ike_sa_id_test.h deleted file mode 100644 index c2d0b71ff..000000000 --- a/src/charon/testing/ike_sa_id_test.h +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @file ike_sa_id_test.h - * - * @brief Tests for the ike_sa_id_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 . - * - * 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 IKE_SA_ID_TEST_H_ -#define IKE_SA_ID_TEST_H_ - -#include - -/** - * @brief Test function used to test the ike_sa_id functionality. - * - * Tests are performed using one thread to test the - * features of the ike_sa_id_t. - * - * @param tester associated tester object - * - * @ingroup testcases - */ -void test_ike_sa_id(protected_tester_t *tester); - -#endif /*IKE_SA_ID_TEST_H_*/ diff --git a/src/charon/testing/ike_sa_manager_test.c b/src/charon/testing/ike_sa_manager_test.c deleted file mode 100644 index 8b8892ab0..000000000 --- a/src/charon/testing/ike_sa_manager_test.c +++ /dev/null @@ -1,186 +0,0 @@ -/** - * @file ike_sa_manager_test.c - * - * @brief Tests for the ike_sa_manager_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 . - * - * 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 -#include -#include - -#include "ike_sa_manager_test.h" - -#include -#include - - -static struct ike_sa_manager_test_struct_s { - protected_tester_t *tester; - ike_sa_manager_t *isam; -} td; - -static void test1_thread(ike_sa_id_t *ike_sa_id) -{ - ike_sa_t *ike_sa; - status_t status; - - status = td.isam->checkout(td.isam, ike_sa_id, &ike_sa); - td.tester->assert_true(td.tester, (status == SUCCESS), "checkout of a blocked ike_sa"); - usleep(10000); - status = td.isam->checkin(td.isam, ike_sa); - td.tester->assert_true(td.tester, (status == SUCCESS), "checkin of a requested ike_sa"); -} - - -static void test3_thread(ike_sa_id_t *ike_sa_id) -{ - ike_sa_t *ike_sa; - status_t status; - - status = td.isam->checkout(td.isam, ike_sa_id, &ike_sa); - td.tester->assert_true(td.tester, (status == NOT_FOUND), "IKE_SA already deleted"); -} - - - - -void test_ike_sa_manager(protected_tester_t *tester) -{ - status_t status; - u_int64_t initiator, responder; - ike_sa_id_t *ike_sa_id, *sa_id; - ike_sa_t *ike_sa; - int thread_count = 200; - int sa_count = 100; - int i; - pthread_t threads[thread_count]; - - td.tester = tester; - td.isam = ike_sa_manager_create(); - tester->assert_true(tester, (td.isam != NULL), "ike_sa_manager creation"); - - - - - /* First Test: - * we play initiator for IKE_SA_INIT first - * create an IKE_SA, - * - */ - - td.isam->create_and_checkout(td.isam, &ike_sa); - /* for testing purposes, we manipulate the responder spi. - * this is usually done be the response from the communication partner, - * but we don't have one... - */ - responder = 123; - - sa_id = ike_sa->get_id(ike_sa); - sa_id->set_responder_spi(sa_id, responder); - - ike_sa_id = sa_id->clone(sa_id); - - /* check in, so we should have a "completed" sa, specified by ike_sa_id */ - status = td.isam->checkin(td.isam, ike_sa); - tester->assert_true(tester, (status == SUCCESS), "checkin modified IKE_SA"); - - /* now we check it out and start some other threads */ - status = td.isam->checkout(td.isam, ike_sa_id, &ike_sa); - tester->assert_true(tester, (status == SUCCESS), "checkout existing IKE_SA 1"); - - for (i = 0; i < thread_count; i++) - { - if (pthread_create(&threads[i], NULL, (void*(*)(void*))test1_thread, (void*)ike_sa_id)) - { - /* failed, decrease list */ - thread_count--; - i--; - } - } - sleep(1); - - - status = td.isam->checkin(td.isam, ike_sa); - tester->assert_true(tester, (status == SUCCESS), "checkin IKE_SA"); - - - sleep(1); - /* we now delete the IKE_SA, while it is requested by the threads. - * this should block until the have done their work.*/ - status = td.isam->delete(td.isam, ike_sa_id); - tester->assert_true(tester, (status == SUCCESS), "delete IKE_SA by id"); - - - for (i = 0; i < thread_count; i++) - { - pthread_join(threads[i], NULL); - } - - ike_sa_id->destroy(ike_sa_id); - - - /* Second Test: - * now we simulate our partner initiates an IKE_SA_INIT, - * so we are the responder. - * - */ - memset(&initiator, 0, sizeof(initiator)); - memset(&responder, 0, sizeof(responder)); - - initiator = 123; - ike_sa_id = ike_sa_id_create(initiator, responder, TRUE); - - status = td.isam->checkout(td.isam, ike_sa_id, &ike_sa); - tester->assert_false(tester, (status == SUCCESS), "checkout unexisting IKE_SA 2"); - - /* let them go acquiring */ - sleep(1); - - - ike_sa_id->destroy(ike_sa_id); - - /* Third Test: - * put in a lot of IKE_SAs, check it out, set a thread waiting - * and destroy the manager... - */ - thread_count = sa_count; - - for (i = 0; i < sa_count; i++) - { - td.isam->create_and_checkout(td.isam, &ike_sa); - - if (pthread_create(&threads[i], NULL, (void*(*)(void*))test3_thread, (void*)ike_sa->get_id(ike_sa))) - { - /* failed, decrease list */ - thread_count--; - } - } - - /* let them go acquiring */ - sleep(1); - - td.isam->destroy(td.isam); - - for (i = 0; i < thread_count; i++) - { - pthread_join(threads[i], NULL); - } -} - diff --git a/src/charon/testing/ike_sa_manager_test.h b/src/charon/testing/ike_sa_manager_test.h deleted file mode 100644 index f299ab74a..000000000 --- a/src/charon/testing/ike_sa_manager_test.h +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @file ike_sa_manager_test.h - * - * @brief Tests for the ike_sa_manager_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 . - * - * 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 IKE_SA_MANAGER_TEST_H_ -#define IKE_SA_MANAGER_TEST_H_ - -#include - -/** - * @brief Test function used to test the ike_sa_manager_t functionality. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_ike_sa_manager(protected_tester_t *tester); - - - -#endif /*IKE_SA_MANAGER_TEST_H_*/ diff --git a/src/charon/testing/ike_sa_test.c b/src/charon/testing/ike_sa_test.c deleted file mode 100644 index feecfc3e5..000000000 --- a/src/charon/testing/ike_sa_test.c +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @file ike_sa_test.c - * - * @brief Tests for the ike_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 . - * - * 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 "ike_sa_test.h" - -#include -#include -#include - -void test_ike_sa(protected_tester_t *tester) -{ - ike_sa_t *ike_sa; - ike_sa_id_t *ike_sa_id; - u_int64_t initiator, responder; - bool is_initiator; - - - initiator = 0; - responder = 34334LL; - is_initiator = TRUE; - /* create a ike_sa_id object for the new IKE_SA */ - ike_sa_id = ike_sa_id_create(initiator, responder, is_initiator); - - /* empty message and configuration objects are created */ - - - /* test every ike_sa function */ - ike_sa = ike_sa_create(ike_sa_id); - -/* ike_sa->initialize_connection(ike_sa, NULL); - - tester->assert_true(tester,(ike_sa != NULL), "ike_sa pointer check"); -*/ - ike_sa->destroy(ike_sa); - - ike_sa_id->destroy(ike_sa_id); -} diff --git a/src/charon/testing/ike_sa_test.h b/src/charon/testing/ike_sa_test.h deleted file mode 100644 index d4cb3315d..000000000 --- a/src/charon/testing/ike_sa_test.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @file ike_sa_test.h - * - * @brief Tests for the ike_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 . - * - * 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 IKE_SA_TEST_H_ -#define IKE_SA_TEST_H_ - -#include - -/** - * @brief Test function used to test the ike_sa_t functionality. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_ike_sa(protected_tester_t *tester); - -#endif /*IKE_SA_TEST_H_*/ diff --git a/src/charon/testing/job_queue_test.c b/src/charon/testing/job_queue_test.c deleted file mode 100644 index 72d46d0d8..000000000 --- a/src/charon/testing/job_queue_test.c +++ /dev/null @@ -1,133 +0,0 @@ -/** - * @file job_queue_test.c - * - * @brief Tests for the job_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 . - * - * 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 -#include -#include - -#include "job_queue_test.h" - -#include -#include - - -typedef struct job_queue_test_s job_queue_test_t; - -/** - * @brief Informations for the involved test-thread used in this test - * - */ -struct job_queue_test_s{ - protected_tester_t *tester; - job_queue_t *job_queue; - /** - * number of items to be inserted in the job-queue - */ - int insert_item_count; - /** - * number of items to be removed by each - * receiver thread from the job-queue - */ - int remove_item_count; -}; - -/** - * @brief sender thread used in the the job_queue test function - * - * @param testinfo informations for the specific thread. - */ -static void test_job_queue_sender(job_queue_test_t * testinfo) -{ - int i; - for (i = 0; i < testinfo->insert_item_count; i++) - { - job_t *job = (job_t *) initiate_ike_sa_job_create(NULL); - testinfo->job_queue->add(testinfo->job_queue,job); - } -} - -/** - * @brief receiver thread used in the the job_queue test function - * - * @param testinfo informations for the specific thread. - */ -static void test_job_queue_receiver(job_queue_test_t * testinfo) -{ - int i; - for (i = 0; i < testinfo->remove_item_count; i++) - { - job_t *job; - job = testinfo->job_queue->get(testinfo->job_queue); - testinfo->tester->assert_true(testinfo->tester,(job->get_type(job) == INITIATE_IKE_SA), "job type check"); - job->destroy(job); - } -} - -/* - * description is in header file - */ -void test_job_queue(protected_tester_t *tester) -{ - int desired_value, i; - int sender_count = 10; - int receiver_count = 2; - pthread_t sender_threads[sender_count]; - pthread_t receiver_threads[receiver_count]; - job_queue_t *job_queue = job_queue_create(); - job_queue_test_t test_infos; - - test_infos.tester = tester; - test_infos.job_queue = job_queue; - test_infos.insert_item_count = 10000; - test_infos.remove_item_count = 50000; - - - desired_value = test_infos.insert_item_count * sender_count - - test_infos.remove_item_count * receiver_count; - - for (i = 0; i < receiver_count;i++) - { - pthread_create( &receiver_threads[i], NULL,(void*(*)(void*)) &test_job_queue_receiver, (void*) &test_infos); - } - for (i = 0; i < sender_count;i++) - { - pthread_create( &sender_threads[i], NULL,(void*(*)(void*)) &test_job_queue_sender, (void*) &test_infos); - } - - - /* Wait for all threads */ - for (i = 0; i < sender_count;i++) - { - pthread_join(sender_threads[i], NULL); - } - for (i = 0; i < receiver_count;i++) - { - pthread_join(receiver_threads[i], NULL); - } - - /* the job-queue has to have disered_value count entries! */ - tester->assert_true(tester,(job_queue->get_count(job_queue) == desired_value), "get count value check"); - - job_queue->destroy(job_queue); -} diff --git a/src/charon/testing/job_queue_test.h b/src/charon/testing/job_queue_test.h deleted file mode 100644 index 4faac2a0a..000000000 --- a/src/charon/testing/job_queue_test.h +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @file job_queue_test.h - * - * @brief Tests for the job_queue_test_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 . - * - * 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 JOB_QUEUE_TEST_H_ -#define JOB_QUEUE_TEST_H_ - -#include - -/** - * @brief Test function used to test the job_queue functionality. - * - * Tests are performed using different threads to test the multi-threaded - * features of the job_queue_t. - * - * @param tester associated tester object - * - * @ingroup testcases - */ -void test_job_queue(protected_tester_t *tester); - -#endif /*JOB_QUEUE_TEST_H_*/ diff --git a/src/charon/testing/kernel_interface_test.c b/src/charon/testing/kernel_interface_test.c deleted file mode 100644 index c151ec50c..000000000 --- a/src/charon/testing/kernel_interface_test.c +++ /dev/null @@ -1,176 +0,0 @@ -/** - * @file kernel_interface_test.h - * - * @brief Tests for the kernel_interface_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 . - * - * 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 "kernel_interface_test.h" - -#include -#include -#include -#include - - -/** - * @brief private method to test kernel_interface with optional NAT-T configuration data - */ - 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; - 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); - - 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, FALSE); - tester->assert_true(tester, status == SUCCESS, "add policy"); - - status = kernel_interface->del_policy(kernel_interface, 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, FALSE); - 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, FALSE); - 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, FALSE); - 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, 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); -} diff --git a/src/charon/testing/kernel_interface_test.h b/src/charon/testing/kernel_interface_test.h deleted file mode 100644 index ce569b4f6..000000000 --- a/src/charon/testing/kernel_interface_test.h +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @file kernel_interface_test.h - * - * @brief Tests for the kernel_interface_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 . - * - * 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 KERNEL_INTERFACE_TEST_H_ -#define KERNEL_INTERFACE_TEST_H_ - -#include - -/** - * @brief Test function used to test the kernel_interface functionality. - * - * @param tester associated tester object - * - * @ingroup testcases - */ -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_*/ diff --git a/src/charon/testing/leak_detective_test.c b/src/charon/testing/leak_detective_test.c deleted file mode 100644 index 8d71d9f0f..000000000 --- a/src/charon/testing/leak_detective_test.c +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @file leak_detective_test.h - * - * @brief Tests for the leak_detective_test. - * - */ - -/* - * 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 . - * - * 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 "leak_detective_test.h" - - -void *mem_a, *mem_b, *mem_c; - -void a() -{ - mem_a = malloc(4); -} - -void b() -{ - a(); - mem_b = malloc(5); -} - -void c() -{ - b(); - mem_c = malloc(6); -} - -void recursive(int depth) -{ - void *tiny = malloc(1); - if (--depth > 0) - { - recursive(depth); - } - free(tiny); -} - - -/* - * described in Header-File - */ -void test_leak_detective(protected_tester_t *tester) -{ - void *m1, *m2, *m3; - - - m1 = malloc(1); - m2 = calloc(1, 2); - m3 = malloc(3); - - m3 = realloc(m3, 4); - - free(m2); - free(m3); - free(m1); - - c(); - free(mem_a); - free(mem_c); - free(mem_b); - recursive(10000); -} diff --git a/src/charon/testing/leak_detective_test.h b/src/charon/testing/leak_detective_test.h deleted file mode 100644 index e64266bd5..000000000 --- a/src/charon/testing/leak_detective_test.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @file leak_detective_test.h - * - * @brief Tests for the leak_detective_public_key_t and leak_detective_private_key classes. - * - */ - -/* - * 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 . - * - * 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 LEAK_DETEICTVE_TEST_H -#define LEAK_DETEICTVE_TEST_H - -#include - -/** - * @brief Test function used to test the leak_detective functionality. - * - * @param tester associated tester object - * - * @ingroup testcases - */ -void test_leak_detective(protected_tester_t *tester); - - -#endif /*LEAK_DETEICTVE_TEST_H*/ diff --git a/src/charon/testing/linked_list_test.c b/src/charon/testing/linked_list_test.c deleted file mode 100644 index 6f5b99783..000000000 --- a/src/charon/testing/linked_list_test.c +++ /dev/null @@ -1,242 +0,0 @@ -/** - * @file linked_list_test.c - * - * @brief Tests for the linked_list_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 . - * - * 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 - -#include "linked_list_test.h" - -#include - - /* - * Description in header-file - */ -void test_linked_list(protected_tester_t *tester) -{ - void *test_value = NULL; - - linked_list_t *linked_list = linked_list_create(); - - tester->assert_true(tester,(linked_list->get_count(linked_list) == 0), "count check"); - - linked_list->insert_first(linked_list,"one"); - tester->assert_true(tester,(linked_list->get_count(linked_list) == 1), "count check"); - - linked_list->insert_first(linked_list,"two"); - tester->assert_true(tester,(linked_list->get_count(linked_list) == 2), "count check"); - - linked_list->insert_first(linked_list,"three"); - tester->assert_true(tester,(linked_list->get_count(linked_list) == 3), "count check"); - - linked_list->insert_first(linked_list,"four"); - tester->assert_true(tester,(linked_list->get_count(linked_list) == 4), "count check"); - - linked_list->insert_first(linked_list,"five"); - tester->assert_true(tester,(linked_list->get_count(linked_list) == 5), "count check"); - - tester->assert_true(tester,(linked_list->get_first(linked_list,&test_value) == SUCCESS), "get_first call check"); - tester->assert_true(tester,(strcmp((char *) test_value,"five") == 0), "get_first value check"); - tester->assert_true(tester,(linked_list->get_count(linked_list) == 5), "count check"); - - tester->assert_true(tester,(linked_list->get_last(linked_list,&test_value) == SUCCESS), "get_last call check"); - tester->assert_true(tester,(strcmp((char *) test_value,"one") == 0), "get_last value check"); - tester->assert_true(tester,( linked_list->get_count(linked_list) == 5), "count check"); - - tester->assert_true(tester,(linked_list->remove_first(linked_list,&test_value) == SUCCESS), "remove_first call check"); - tester->assert_true(tester,(strcmp((char *) test_value,"five") == 0), "remove_first value check"); - tester->assert_true(tester,(linked_list->get_count(linked_list) == 4), "count check"); - - tester->assert_true(tester,(linked_list->get_first(linked_list,&test_value) == SUCCESS), "get_first call check"); - tester->assert_true(tester,(strcmp((char *) test_value,"four") == 0), "get_first value check"); - tester->assert_true(tester,(linked_list->get_count(linked_list) == 4), "count check"); - - tester->assert_true(tester,(linked_list->get_last(linked_list,&test_value) == SUCCESS), "get_last call check"); - tester->assert_true(tester,(strcmp((char *) test_value,"one") == 0), "get_last value check"); - tester->assert_true(tester,(linked_list->get_count(linked_list) == 4), "count check"); - - tester->assert_true(tester,(linked_list->get_at_position(linked_list,0,&test_value) == SUCCESS), "get_at_position call check"); - tester->assert_true(tester,(strcmp((char *) test_value,"four") == 0), "get_at_position value check"); - - tester->assert_true(tester,(linked_list->get_at_position(linked_list,1,&test_value) == SUCCESS), "get_at_position call check"); - tester->assert_true(tester,(strcmp((char *) test_value,"three") == 0), "get_at_position value check"); - - tester->assert_true(tester,(linked_list->get_at_position(linked_list,2,&test_value) == SUCCESS), "get_at_position call check"); - tester->assert_true(tester,(strcmp((char *) test_value,"two") == 0), "get_at_position value check"); - - tester->assert_true(tester,(linked_list->get_at_position(linked_list,3,&test_value) == SUCCESS), "get_at_position call check"); - tester->assert_true(tester,(strcmp((char *) test_value,"one") == 0), "get_at_position value check"); - - tester->assert_false(tester,(linked_list->get_at_position(linked_list,4,&test_value) == SUCCESS), "get_at_position call check"); - tester->assert_false(tester,(linked_list->remove_at_position(linked_list,4,&test_value) == SUCCESS), "remove_at_position call check"); - tester->assert_false(tester,(linked_list->insert_at_position(linked_list,5,test_value) == SUCCESS), "insert_at_position call 1 check"); - - tester->assert_true(tester,(linked_list->insert_at_position(linked_list,3,"six") == SUCCESS), "insert_at_position call 2 check"); - tester->assert_true(tester,(linked_list->insert_at_position(linked_list,3,"seven") == SUCCESS), "insert_at_position call 3 check"); - - tester->assert_true(tester,(linked_list->get_at_position(linked_list,3,&test_value) == SUCCESS), "get_at_position call check"); - tester->assert_true(tester,(strcmp((char *) test_value,"seven") == 0), "get_at_position value 1 check"); - - tester->assert_true(tester,(linked_list->get_at_position(linked_list,4,&test_value) == SUCCESS), "get_at_position call check"); - tester->assert_true(tester,(strcmp((char *) test_value,"six") == 0), "get_at_position value 2 check"); - - tester->assert_true(tester,(linked_list->get_at_position(linked_list,5,&test_value) == SUCCESS), "get_at_position call check"); - tester->assert_true(tester,(strcmp((char *) test_value,"one") == 0), "get_at_position value 3 check"); - - tester->assert_true(tester,(linked_list->remove_at_position(linked_list,3,&test_value) == SUCCESS), "remove_at_position call check"); - tester->assert_true(tester,(linked_list->remove_at_position(linked_list,3,&test_value) == SUCCESS), "remove_at_position call check"); - - - tester->assert_true(tester,(linked_list->remove_last(linked_list,&test_value) == SUCCESS), "remove_last call check"); - tester->assert_true(tester,(strcmp((char *) test_value,"one") == 0), "remove_last value check"); - tester->assert_true(tester,(linked_list->get_count(linked_list) == 3), "count check"); - - tester->assert_true(tester,(linked_list->get_last(linked_list,&test_value) == SUCCESS), "get_last call check"); - tester->assert_true(tester,(strcmp((char *) test_value,"two") == 0), "get_last value check"); - tester->assert_true(tester,(linked_list->get_count(linked_list) == 3), "count check"); - - tester->assert_true(tester,(linked_list->get_first(linked_list,&test_value) == SUCCESS), "get_first call check"); - tester->assert_true(tester,(strcmp((char *) test_value,"four") == 0), "get_first value check"); - tester->assert_true(tester,(linked_list->get_count(linked_list) == 3), "count check"); - - linked_list->destroy(linked_list); -} - - /* - * Description in header-file - */ -void test_linked_list_iterator(protected_tester_t *tester) -{ - void * value; - - linked_list_t *linked_list = linked_list_create(); - linked_list->insert_first(linked_list,"one"); - linked_list->insert_first(linked_list,"two"); - linked_list->insert_first(linked_list,"three"); - linked_list->insert_first(linked_list,"four"); - linked_list->insert_first(linked_list,"five"); - - iterator_t * iterator; - iterator_t * iterator2; - - - iterator = linked_list->create_iterator(linked_list,TRUE); - - tester->assert_true(tester,iterator->has_next(iterator), "it 1 has_next value check"); - iterator->current(iterator,&value); - tester->assert_true(tester,(strcmp((char *) value,"five") == 0), "it 1 current value check"); - - tester->assert_true(tester,iterator->has_next(iterator), "it 1 has_next value check"); - iterator->current(iterator,&value); - tester->assert_true(tester,(strcmp((char *) value,"four") == 0), "it 1 current value check"); - - iterator2 = linked_list->create_iterator(linked_list,FALSE); - - tester->assert_true(tester,iterator2->has_next(iterator2), "it 2 has_next value check"); - iterator2->current(iterator2,&value); - tester->assert_true(tester,(strcmp((char *) value,"one") == 0), "it 2 current value check"); - - tester->assert_true(tester,iterator->has_next(iterator), "it 1 has_next value check"); - iterator->current(iterator,&value); - tester->assert_true(tester,(strcmp((char *) value,"three") == 0), "it 1 current value check"); - - tester->assert_true(tester,iterator2->has_next(iterator2), "it 2 has_next value check"); - iterator2->current(iterator2,&value); - tester->assert_true(tester,(strcmp((char *) value,"two") == 0), "it 2 current value check"); - - tester->assert_true(tester,iterator->has_next(iterator), "it 1 has_next value check"); - iterator->current(iterator,&value); - tester->assert_true(tester,(strcmp((char *) value,"two") == 0), "it 1 current value check"); - - tester->assert_true(tester,iterator2->has_next(iterator2), "it 2 has_next value check"); - iterator2->current(iterator2,&value); - tester->assert_true(tester,(strcmp((char *) value,"three") == 0), "it 2 current value check"); - - tester->assert_true(tester,iterator->has_next(iterator), "it 1 has_next value check"); - iterator->current(iterator,&value); - tester->assert_true(tester,(strcmp((char *) value,"one") == 0), "it 1 current value check"); - - tester->assert_false(tester,iterator->has_next(iterator), "it 1 has_next value check"); - - tester->assert_true(tester,iterator2->has_next(iterator2), "it 2 has_next value check"); - tester->assert_true(tester,iterator2->has_next(iterator2), "it 2 has_next value check"); - tester->assert_false(tester,iterator2->has_next(iterator2), "it 2 has_next value check"); - - iterator->destroy(iterator); - iterator2->destroy(iterator2); - linked_list->destroy(linked_list); -} - - /* - * Description in header-file - */ -void test_linked_list_insert_and_remove(protected_tester_t *tester) -{ - void *value; - iterator_t * iterator; - - linked_list_t *linked_list = linked_list_create(); - linked_list->insert_first(linked_list,"one"); - linked_list->insert_first(linked_list,"two"); - - linked_list->insert_first(linked_list,"three"); - linked_list->insert_first(linked_list,"four"); - linked_list->insert_first(linked_list,"five"); - - - - iterator = linked_list->create_iterator(linked_list,TRUE); - - iterator->has_next(iterator); - iterator->has_next(iterator); - iterator->has_next(iterator); - iterator->current(iterator,&value); - tester->assert_true(tester,(strcmp((char *) value,"three") == 0), "current value check"); - - iterator->insert_before(iterator,"before_three"); - iterator->current(iterator,&value); - tester->assert_true(tester,(strcmp((char *) value,"three") == 0), "current value check"); - - - iterator->insert_after(iterator,"after_three"); - iterator->current(iterator,&value); - tester->assert_true(tester,(strcmp((char *) value,"three") == 0), "current value check"); - - - tester->assert_true(tester,(iterator->remove(iterator) == SUCCESS), "remove call check"); - iterator->current(iterator,&value); - tester->assert_true(tester,(strcmp((char *) value,"before_three") == 0), "current value check"); - - iterator->reset(iterator); - - iterator->has_next(iterator); - iterator->has_next(iterator); - iterator->has_next(iterator); - iterator->current(iterator,&value); - tester->assert_true(tester,(strcmp((char *) value,"before_three") == 0), "current value check"); - iterator->has_next(iterator); - iterator->current(iterator,&value); - tester->assert_true(tester,(strcmp((char *) value,"after_three") == 0), "current value check"); - - iterator->destroy(iterator); - - linked_list->destroy(linked_list); -} diff --git a/src/charon/testing/linked_list_test.h b/src/charon/testing/linked_list_test.h deleted file mode 100644 index 74dff9330..000000000 --- a/src/charon/testing/linked_list_test.h +++ /dev/null @@ -1,75 +0,0 @@ -/** - * @file linked_list_test.h - * - * @brief Tests for the linked_list_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 . - * - * 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 LINKED_LIST_TEST_H_ -#define LINKED_LIST_TEST_H_ - -#include - -/** - * @brief Test function for the type linked_list_t. - * - * Performs different kinds of assertions to check the functionality - * of the linked_list_t in a Single-Threaded environment. - * - * @warning To be usable in multi-threaded software - * this list has to get protected with locks. - * - * @param tester tester object - * - * @ingroup testcases - */ -void test_linked_list(protected_tester_t *tester); - -/** - * @brief Test function for the type linked_list_t and its iterator. - * - * Performs different kinds of assertions to check the functionality - * of the linked_list_t and its iterator in a Single-Threaded environment. - * - * @warning To be usable in multi-threaded software - * this list has to get protected with locks. - * - * @param tester tester object - * - * @ingroup testcases - */ -void test_linked_list_iterator(protected_tester_t *tester); - -/** - * @brief Test function for the type linked_list_t and its insert and remove - * functions. - * - * Performs different kinds of assertions to check the functionality - * of the linked_list_t and its insert and remove functions - * - * @warning To be usable in multi-threaded software - * this list has to get protected with locks. - * - * @param tester tester object - * - * @ingroup testcases - */ -void test_linked_list_insert_and_remove(protected_tester_t *tester); - -#endif /*LINKED_LIST_TEST_H_*/ diff --git a/src/charon/testing/packet_test.c b/src/charon/testing/packet_test.c deleted file mode 100644 index adfc3a8de..000000000 --- a/src/charon/testing/packet_test.c +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @file packet_test.c - * - * @brief Tests for the packet_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 . - * - * 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 - -#include "packet_test.h" - -#include -#include -#include - - -/* - * Described in Header - */ -void test_packet(protected_tester_t *tester) -{ - packet_t *packet = packet_create(); - packet_t *packet2; - chunk_t data; - char *string_to_copy = "aha, soso"; - - data.len = strlen(string_to_copy) + 1; - data.ptr = malloc(data.len); - memcpy(data.ptr, string_to_copy, data.len); - - packet->set_data(packet, data); - packet2 = packet->clone(packet); - data = packet2->get_data(packet2); - - tester->assert_true(tester,(data.len == (strlen(string_to_copy) + 1)),"value length check"); - tester->assert_true(tester,(memcmp(data.ptr,string_to_copy,data.len) == 0),"cloned value check"); - - packet2->destroy(packet2); - packet->destroy(packet); -} diff --git a/src/charon/testing/packet_test.h b/src/charon/testing/packet_test.h deleted file mode 100644 index 402362775..000000000 --- a/src/charon/testing/packet_test.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @file packet_test.h - * - * @brief Tests for the packet_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 . - * - * 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 PACKET_TEST_H_ -#define PACKET_TEST_H_ - -#include - -/** - * @brief Test function used to test the packet_t functionality. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_packet(protected_tester_t *tester); - -#endif /*PACKET_TEST_H_*/ diff --git a/src/charon/testing/parser_test.c b/src/charon/testing/parser_test.c deleted file mode 100644 index 7d2ba219b..000000000 --- a/src/charon/testing/parser_test.c +++ /dev/null @@ -1,965 +0,0 @@ -/** - * @file parser_test.c - * - * @brief Tests for the parser_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 . - * - * 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 - -#include "parser_test.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -/* - * Described in Header - */ -void test_parser_with_header_payload(protected_tester_t *tester) -{ - parser_t *parser; - ike_header_t *ike_header; - status_t status; - chunk_t header_chunk; - - u_int8_t header_bytes[] = { - 0x01,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, - 0x02,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, - 0x03,0x45,0x06,0x28, - 0x00,0x00,0x00,0x07, - 0x00,0x00,0x00,0x1C, - }; - header_chunk.ptr = header_bytes; - header_chunk.len = sizeof(header_bytes); - - - parser = parser_create(header_chunk); - tester->assert_true(tester,(parser != NULL), "parser create check"); - status = parser->parse_payload(parser, HEADER, (payload_t**)&ike_header); - tester->assert_true(tester,(status == SUCCESS),"parse_payload call check"); - parser->destroy(parser); - - if (status != SUCCESS) - { - return; - } - - tester->assert_true(tester,(ike_header->get_initiator_spi(ike_header) == 1),"parsed initiator_spi value"); - tester->assert_true(tester,(ike_header->get_responder_spi(ike_header) == 2),"parsed responder_spi value"); - tester->assert_true(tester,(ike_header->payload_interface.get_next_type((payload_t*)ike_header) == 3),"parsed next_payload value"); - tester->assert_true(tester,(ike_header->get_maj_version(ike_header) == 4),"parsed maj_version value"); - tester->assert_true(tester,(ike_header->get_min_version(ike_header) == 5),"parsed min_version value"); - tester->assert_true(tester,(ike_header->get_exchange_type(ike_header) == 6),"parsed exchange_type value"); - tester->assert_true(tester,(ike_header->get_initiator_flag(ike_header) == TRUE),"parsed flags.initiator value"); - tester->assert_true(tester,(ike_header->get_version_flag(ike_header) == FALSE),"parsed flags.version value"); - tester->assert_true(tester,(ike_header->get_response_flag(ike_header) == TRUE),"parsed flags.response value"); - tester->assert_true(tester,(ike_header->get_message_id(ike_header) == 7),"parsed message_id value"); - tester->assert_true(tester,(ike_header->payload_interface.get_length((payload_t*)ike_header) == 0x1C),"parsed length value"); - - ike_header->destroy(ike_header); -} - -/* - * Described in Header - */ -void test_parser_with_sa_payload(protected_tester_t *tester) -{ - parser_t *parser; - sa_payload_t *sa_payload; - status_t status; - chunk_t sa_chunk, sa_chunk2, sa_chunk3; - iterator_t *proposals, *transforms, *attributes; - - /* first test generic parsing functionality */ - - u_int8_t sa_bytes[] = { - 0x00,0x80,0x00,0x24, /* payload header*/ - 0x00,0x00,0x00,0x20, /* a proposal */ - 0x01,0x02,0x04,0x05, - 0x01,0x02,0x03,0x04, /* spi */ - 0x00,0x00,0x00,0x14, /* transform */ - 0x07,0x00,0x00,0x03, - 0x80,0x01,0x00,0x05, /* attribute without length */ - 0x00,0x03,0x00,0x04, /* attribute with length */ - 0x01,0x02,0x03,0x04 - - - }; - - sa_chunk.ptr = sa_bytes; - sa_chunk.len = sizeof(sa_bytes); - - - parser = parser_create(sa_chunk); - tester->assert_true(tester,(parser != NULL), "parser create check"); - status = parser->parse_payload(parser, SECURITY_ASSOCIATION, (payload_t**)&sa_payload); - tester->assert_true(tester,(status == SUCCESS),"parse_payload call check"); - parser->destroy(parser); - - if (status != SUCCESS) - { - return; - } - - - proposals = sa_payload->create_proposal_substructure_iterator(sa_payload, TRUE); - while (proposals->has_next(proposals)) - { - proposal_substructure_t *proposal; - proposals->current(proposals, (void**)&proposal); - chunk_t spi; - u_int8_t spi_should[] = {0x01, 0x02, 0x03, 0x04}; - - tester->assert_true(tester,(proposal->get_proposal_number(proposal) == 1),"proposal number"); - tester->assert_true(tester,(proposal->get_protocol_id(proposal) == 2),"proposal id"); - spi = proposal->get_spi(proposal); - tester->assert_false(tester,(memcmp(&spi_should, spi.ptr, spi.len)),"proposal spi"); - - transforms = proposal->create_transform_substructure_iterator(proposal, TRUE); - while(transforms->has_next(transforms)) - { - transform_substructure_t *transform; - int loopi; - transforms->current(transforms, (void**)&transform); - tester->assert_true(tester,(transform->get_transform_type(transform) == 7),"transform type"); - tester->assert_true(tester,(transform->get_transform_id(transform) == 3),"transform id"); - attributes = transform->create_transform_attribute_iterator(transform, TRUE); - loopi = 0; - while (attributes->has_next(attributes)) - { - transform_attribute_t *attribute; - attributes->current(attributes, (void**)&attribute); - if (loopi == 0) - { - u_int8_t value[] = {0x05, 0x00}; - chunk_t attribute_value; - tester->assert_true(tester,(attribute->get_attribute_type(attribute) == 1),"attribute 1 type"); - attribute_value = attribute->get_value_chunk(attribute); - tester->assert_false(tester,(memcmp(&value, attribute_value.ptr, attribute_value.len)),"attribute 1 value"); - } - if (loopi == 1) - { - u_int8_t value[] = {0x01, 0x02, 0x03, 0x04}; - chunk_t attribute_value; - tester->assert_true(tester,(attribute->get_attribute_type(attribute) == 3),"attribute 2 type"); - attribute_value = attribute->get_value_chunk(attribute); - tester->assert_false(tester,(memcmp(&value, attribute_value.ptr, attribute_value.len)),"attribute 2 value"); - } - loopi++; - } - attributes->destroy(attributes); - } - transforms->destroy(transforms); - } - proposals->destroy(proposals); - - sa_payload->destroy(sa_payload); - - - - /* now test SA functionality after parsing an SA payload*/ - - u_int8_t sa_bytes2[] = { - 0x00,0x00,0x00,0x6C, /* payload header*/ - 0x02,0x00,0x00,0x34, /* a proposal */ - 0x01,0x01,0x00,0x04, - 0x03,0x00,0x00,0x0C, /* transform 1 */ - 0x01,0x00,0x00,0x01, - 0x80,0x0E,0x00,0x14, /* keylength attribute with 20 bytes length */ - 0x03,0x00,0x00,0x0C, /* transform 2 */ - 0x02,0x00,0x00,0x01, - 0x80,0x0E,0x00,0x14, /* keylength attribute with 20 bytes length */ - 0x03,0x00,0x00,0x0C, /* transform 3 */ - 0x03,0x00,0x00,0x01, - 0x80,0x0E,0x00,0x14, /* keylength attribute with 20 bytes length */ - 0x00,0x00,0x00,0x08, /* transform 4 */ - 0x04,0x00,0x00,0x01, - 0x00,0x00,0x00,0x34, /* a proposal */ - 0x01,0x01,0x00,0x04, - 0x03,0x00,0x00,0x0C, /* transform 1 */ - 0x01,0x00,0x00,0x02, - 0x80,0x0E,0x00,0x10, /* keylength attribute with 16 bytes length */ - 0x03,0x00,0x00,0x0C, /* transform 2 */ - 0x02,0x00,0x00,0x02, - 0x80,0x0E,0x00,0x10, /* keylength attribute with 16 bytes length */ - 0x03,0x00,0x00,0x0C, /* transform 3 */ - 0x03,0x00,0x00,0x02, - 0x80,0x0E,0x00,0x10, /* keylength attribute with 16 bytes length */ - 0x00,0x00,0x00,0x08, /* transform 4 */ - 0x04,0x00,0x00,0x02, - }; - - sa_chunk2.ptr = sa_bytes2; - sa_chunk2.len = sizeof(sa_bytes2); - - parser = parser_create(sa_chunk2); - tester->assert_true(tester,(parser != NULL), "parser create check"); - status = parser->parse_payload(parser, SECURITY_ASSOCIATION, (payload_t**)&sa_payload); - tester->assert_true(tester,(status == SUCCESS),"parse_payload call check"); - parser->destroy(parser); - - if (status != SUCCESS) - { - return; - } - - status = sa_payload->payload_interface.verify(&(sa_payload->payload_interface)); - tester->assert_true(tester,(status == SUCCESS),"verify call check"); - /* - status = sa_payload->get_ike_proposals (sa_payload, &ike_proposals, &ike_proposal_count); - tester->assert_true(tester,(status == SUCCESS),"get ike proposals call check"); - - tester->assert_true(tester,(ike_proposal_count == 2),"ike proposal count check"); - tester->assert_true(tester,(ike_proposals[0].encryption_algorithm == 1),"ike proposal content check"); - tester->assert_true(tester,(ike_proposals[0].encryption_algorithm_key_length == 20),"ike proposal content check"); - tester->assert_true(tester,(ike_proposals[0].integrity_algorithm == 1),"ike proposal content check"); - tester->assert_true(tester,(ike_proposals[0].integrity_algorithm_key_length == 20),"ike proposal content check"); - tester->assert_true(tester,(ike_proposals[0].pseudo_random_function == 1),"ike proposal content check"); - tester->assert_true(tester,(ike_proposals[0].pseudo_random_function_key_length == 20),"ike proposal content check"); - tester->assert_true(tester,(ike_proposals[0].diffie_hellman_group == 1),"ike proposal content check"); - - tester->assert_true(tester,(ike_proposals[1].encryption_algorithm == 2),"ike proposal content check"); - tester->assert_true(tester,(ike_proposals[1].encryption_algorithm_key_length == 16),"ike proposal content check"); - tester->assert_true(tester,(ike_proposals[1].integrity_algorithm == 2),"ike proposal content check"); - tester->assert_true(tester,(ike_proposals[1].integrity_algorithm_key_length == 16),"ike proposal content check"); - tester->assert_true(tester,(ike_proposals[1].pseudo_random_function == 2),"ike proposal content check"); - tester->assert_true(tester,(ike_proposals[1].pseudo_random_function_key_length == 16),"ike proposal content check"); - tester->assert_true(tester,(ike_proposals[1].diffie_hellman_group == 2),"ike proposal content check"); - - - if (status == SUCCESS) - { - free(ike_proposals); - } - */ - sa_payload->destroy(sa_payload); - - /* now test SA functionality after parsing an SA payload with child sa proposals*/ - u_int8_t sa_bytes3[] = { - 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, - }; - - sa_chunk3.ptr = sa_bytes3; - sa_chunk3.len = sizeof(sa_bytes3); - - parser = parser_create(sa_chunk3); - tester->assert_true(tester,(parser != NULL), "parser create check"); - status = parser->parse_payload(parser, SECURITY_ASSOCIATION, (payload_t**)&sa_payload); - tester->assert_true(tester,(status == SUCCESS),"parse_payload call check"); - parser->destroy(parser); - - if (status != SUCCESS) - { - return; - } - - status = sa_payload->payload_interface.verify(&(sa_payload->payload_interface)); - tester->assert_true(tester,(status == SUCCESS),"verify call check"); -/* - status = sa_payload->get_ike_proposals (sa_payload, &ike_proposals, &ike_proposal_count); - tester->assert_false(tester,(status == SUCCESS),"get ike proposals call check"); - - status = sa_payload->get_proposals (sa_payload, &proposals, &proposal_count); - tester->assert_true(tester,(status == SUCCESS),"get child proposals call check"); - - - tester->assert_true(tester,(proposal_count == 2),"child proposal count check"); - tester->assert_true(tester,(proposals[0].ah.is_set == TRUE),"is ah set check"); - tester->assert_true(tester,(proposals[0].ah.integrity_algorithm == AUTH_HMAC_MD5_96),"integrity_algorithm check"); - tester->assert_true(tester,(proposals[0].ah.integrity_algorithm_key_size == 20),"integrity_algorithm_key_size check"); - tester->assert_true(tester,(proposals[0].ah.diffie_hellman_group == MODP_2048_BIT),"diffie_hellman_group check"); - tester->assert_true(tester,(proposals[0].ah.extended_sequence_numbers == EXT_SEQ_NUMBERS),"extended_sequence_numbers check"); - tester->assert_true(tester,(proposals[0].ah.spi[0] == 1),"spi check"); - tester->assert_true(tester,(proposals[0].ah.spi[1] == 1),"spi check"); - tester->assert_true(tester,(proposals[0].ah.spi[2] == 1),"spi check"); - tester->assert_true(tester,(proposals[0].ah.spi[3] == 1),"spi check"); - - tester->assert_true(tester,(proposals[0].esp.is_set == TRUE),"is ah set check"); - tester->assert_true(tester,(proposals[0].esp.encryption_algorithm == ENCR_AES_CBC),"integrity_algorithm check"); - tester->assert_true(tester,(proposals[0].esp.encryption_algorithm_key_size == 32),"integrity_algorithm_key_size check"); - tester->assert_true(tester,(proposals[0].esp.diffie_hellman_group == MODP_1024_BIT),"diffie_hellman_group check"); - tester->assert_true(tester,(proposals[0].esp.integrity_algorithm == AUTH_UNDEFINED),"integrity_algorithm check"); - tester->assert_true(tester,(proposals[0].esp.spi[0] == 2),"spi check"); - tester->assert_true(tester,(proposals[0].esp.spi[1] == 2),"spi check"); - tester->assert_true(tester,(proposals[0].esp.spi[2] == 2),"spi check"); - tester->assert_true(tester,(proposals[0].esp.spi[3] == 2),"spi check"); - - tester->assert_true(tester,(proposals[1].ah.is_set == TRUE),"is ah set check"); - tester->assert_true(tester,(proposals[1].ah.integrity_algorithm == AUTH_HMAC_MD5_96),"integrity_algorithm check"); - tester->assert_true(tester,(proposals[1].ah.integrity_algorithm_key_size == 20),"integrity_algorithm_key_size check"); - tester->assert_true(tester,(proposals[1].ah.diffie_hellman_group == MODP_2048_BIT),"diffie_hellman_group check"); - tester->assert_true(tester,(proposals[1].ah.extended_sequence_numbers == EXT_SEQ_NUMBERS),"extended_sequence_numbers check"); - tester->assert_true(tester,(proposals[1].ah.spi[0] == 1),"spi check"); - tester->assert_true(tester,(proposals[1].ah.spi[1] == 1),"spi check"); - tester->assert_true(tester,(proposals[1].ah.spi[2] == 1),"spi check"); - tester->assert_true(tester,(proposals[1].ah.spi[3] == 1),"spi check"); - - tester->assert_true(tester,(proposals[1].esp.is_set == TRUE),"is ah set check"); - tester->assert_true(tester,(proposals[1].esp.encryption_algorithm == ENCR_AES_CBC),"integrity_algorithm check"); - tester->assert_true(tester,(proposals[1].esp.encryption_algorithm_key_size == 32),"integrity_algorithm_key_size check"); - tester->assert_true(tester,(proposals[1].esp.diffie_hellman_group == MODP_1024_BIT),"diffie_hellman_group check"); - tester->assert_true(tester,(proposals[1].esp.integrity_algorithm == AUTH_HMAC_MD5_96),"integrity_algorithm check"); - tester->assert_true(tester,(proposals[1].esp.integrity_algorithm_key_size == 20),"integrity_algorithm check"); - tester->assert_true(tester,(proposals[1].esp.spi[0] == 2),"spi check"); - tester->assert_true(tester,(proposals[1].esp.spi[1] == 2),"spi check"); - tester->assert_true(tester,(proposals[1].esp.spi[2] == 2),"spi check"); - tester->assert_true(tester,(proposals[1].esp.spi[3] == 2),"spi check"); - - if (status == SUCCESS) - { - free(proposals); - } - */ - - sa_payload->destroy(sa_payload); -} - -/* - * Described in Header - */ -void test_parser_with_nonce_payload(protected_tester_t *tester) -{ - parser_t *parser; - nonce_payload_t *nonce_payload; - status_t status; - chunk_t nonce_chunk, result; - - u_int8_t nonce_bytes[] = { - 0x00,0x00,0x00,0x14, /* payload header */ - 0x00,0x01,0x02,0x03, /* 16 Byte nonce */ - 0x04,0x05,0x06,0x07, - 0x08,0x09,0x0A,0x2B, - 0x0C,0x0D,0x0E,0x0F - }; - - nonce_chunk.ptr = nonce_bytes; - nonce_chunk.len = sizeof(nonce_bytes); - - parser = parser_create(nonce_chunk); - tester->assert_true(tester,(parser != NULL), "parser create check"); - status = parser->parse_payload(parser, NONCE, (payload_t**)&nonce_payload); - tester->assert_true(tester,(status == SUCCESS),"parse_payload call check"); - parser->destroy(parser); - - if (status != SUCCESS) - { - return; - } - result = nonce_payload->get_nonce(nonce_payload); - tester->assert_true(tester,(result.len == 16), "parsed nonce lenght"); - tester->assert_false(tester,(memcmp(nonce_bytes + 4, result.ptr, result.len)), "parsed nonce data"); - nonce_payload->destroy(nonce_payload); - chunk_free(&result); -} - -/* - * Described in Header - */ -void test_parser_with_id_payload(protected_tester_t *tester) -{ - parser_t *parser; - id_payload_t *id_payload; - status_t status; - chunk_t id_chunk, result; - - u_int8_t id_bytes[] = { - 0x00,0x00,0x00,0x14, /* payload header */ - 0x05,0x01,0x02,0x03, - 0x04,0x05,0x06,0x07,/* 12 Byte nonce */ - 0x08,0x09,0x0A,0x2B, - 0x0C,0x0D,0x0E,0x0F - }; - - id_chunk.ptr = id_bytes; - id_chunk.len = sizeof(id_bytes); - - parser = parser_create(id_chunk); - tester->assert_true(tester,(parser != NULL), "parser create check"); - status = parser->parse_payload(parser, ID_INITIATOR, (payload_t**)&id_payload); - tester->assert_true(tester,(status == SUCCESS),"parse_payload call check"); - parser->destroy(parser); - - if (status != SUCCESS) - { - return; - } - result = id_payload->get_data_clone(id_payload); - tester->assert_true(tester,(id_payload->get_initiator(id_payload) == TRUE), "is IDi payload"); - tester->assert_true(tester,(id_payload->get_id_type(id_payload) == ID_IPV6_ADDR), "is ID_IPV6_ADDR ID type"); - tester->assert_true(tester,(result.len == 12), "parsed data lenght"); - tester->assert_false(tester,(memcmp(id_bytes + 8, result.ptr, result.len)), "parsed nonce data"); - id_payload->destroy(id_payload); - chunk_free(&result); -} - - -/* - * Described in Header - */ -void test_parser_with_ke_payload(protected_tester_t *tester) -{ - parser_t *parser; - ke_payload_t *ke_payload; - status_t status; - chunk_t ke_chunk, result; - - u_int8_t ke_bytes[] = { - 0x00,0x00,0x00,0x18, /* payload header */ - 0x00,0x03,0x00,0x00, /* dh group 3 */ - 0x01,0x02,0x03,0x03, /* 16 Byte dh data */ - 0x04,0x05,0x06,0x07, - 0x08,0x09,0x0A,0x2B, - 0x0C,0x0D,0x0E,0x0F - }; - - ke_chunk.ptr = ke_bytes; - ke_chunk.len = sizeof(ke_bytes); - - parser = parser_create(ke_chunk); - tester->assert_true(tester,(parser != NULL), "parser create check"); - status = parser->parse_payload(parser, KEY_EXCHANGE, (payload_t**)&ke_payload); - tester->assert_true(tester,(status == SUCCESS),"parse_payload call check"); - parser->destroy(parser); - - if (status != SUCCESS) - { - return; - } - tester->assert_true(tester,(ke_payload->get_dh_group_number(ke_payload) == 3), "DH group"); - result = ke_payload->get_key_exchange_data(ke_payload); - tester->assert_true(tester,(result.len == 16), "parsed key lenght"); - tester->assert_false(tester,(memcmp(ke_bytes + 8, result.ptr, result.len)), "parsed key data"); - ke_payload->destroy(ke_payload); -} - - -/* - * Described in Header - */ -void test_parser_with_notify_payload(protected_tester_t *tester) -{ - parser_t *parser; - 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 */ - 0x03,0x04,0x00,0x01, - 0x01,0x02,0x03,0x03, /* spi */ - 0x04,0x05,0x06,0x07, /* noti dati */ - 0x08,0x09,0x0A,0x2B, - 0x0C,0x0D,0x0E,0x0F, - 0x0C,0x0D,0x0E,0x0F - }; - - notify_chunk.ptr = notify_bytes; - notify_chunk.len = sizeof(notify_bytes); - - parser = parser_create(notify_chunk); - tester->assert_true(tester,(parser != NULL), "parser create check"); - status = parser->parse_payload(parser, NOTIFY, (payload_t**)¬ify_payload); - tester->assert_true(tester,(status == SUCCESS),"parse_payload call check"); - parser->destroy(parser); - - if (status != SUCCESS) - { - return; - } - tester->assert_true(tester,(notify_payload->get_protocol_id(notify_payload) == 3), "Protocol id"); - tester->assert_true(tester,(notify_payload->get_notify_type(notify_payload) == 1), "notify message type"); - - 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"); - - notify_payload->destroy(notify_payload); -} - -/* - * Described in Header - */ -void test_parser_with_auth_payload(protected_tester_t *tester) -{ - parser_t *parser; - auth_payload_t *auth_payload; - status_t status; - chunk_t auth_chunk, result; - - u_int8_t auth_bytes[] = { - 0x00,0x00,0x00,0x14, /* payload header */ - 0x03,0x01,0x02,0x03, - 0x04,0x05,0x06,0x07,/* 12 Byte nonce */ - 0x08,0x09,0x0A,0x2B, - 0x0C,0x0D,0x0E,0x0F - }; - - auth_chunk.ptr = auth_bytes; - auth_chunk.len = sizeof(auth_bytes); - - parser = parser_create(auth_chunk); - tester->assert_true(tester,(parser != NULL), "parser create check"); - status = parser->parse_payload(parser, AUTHENTICATION, (payload_t**)&auth_payload); - tester->assert_true(tester,(status == SUCCESS),"parse_payload call check"); - parser->destroy(parser); - - if (status != SUCCESS) - { - return; - } - result = auth_payload->get_data_clone(auth_payload); - tester->assert_true(tester,(auth_payload->get_auth_method(auth_payload) == DSS_DIGITAL_SIGNATURE), "is DSS_DIGITAL_SIGNATURE method"); - tester->assert_true(tester,(result.len == 12), "parsed data lenght"); - tester->assert_false(tester,(memcmp(auth_bytes + 8, result.ptr, result.len)), "parsed nonce data"); - auth_payload->destroy(auth_payload); - chunk_free(&result); -} - -/* - * Described in Header - */ -void test_parser_with_ts_payload(protected_tester_t *tester) -{ - parser_t *parser; - ts_payload_t *ts_payload; - status_t status; - chunk_t ts_chunk; - traffic_selector_substructure_t *ts1, *ts2; - host_t *start_host1, *start_host2, *end_host1, *end_host2; - iterator_t *iterator; - - u_int8_t ts_bytes[] = { - /* payload header */ - 0x00,0x00,0x00,0x28, - 0x02,0x00,0x00,0x00, - - /* traffic selector 1 */ - 0x07,0x00,0x00,0x10, - 0x01,0xF4,0x01,0xF4, - 0xC0,0xA8,0x01,0x00, - 0xC0,0xA8,0x01,0xFF, - - /* traffic selector 2 */ - 0x07,0x03,0x00,0x10, - 0x00,0x00,0xFF,0xFF, - 0x00,0x00,0x00,0x00, - 0xFF,0xFF,0xFF,0xFF, - }; - - ts_chunk.ptr = ts_bytes; - ts_chunk.len = sizeof(ts_bytes); - - parser = parser_create(ts_chunk); - tester->assert_true(tester,(parser != NULL), "parser create check"); - status = parser->parse_payload(parser, TRAFFIC_SELECTOR_RESPONDER, (payload_t**)&ts_payload); - tester->assert_true(tester,(status == SUCCESS),"parse_payload call check"); - parser->destroy(parser); - - if (status != SUCCESS) - { - return; - } - - iterator = ts_payload->create_traffic_selector_substructure_iterator(ts_payload,TRUE); - - tester->assert_true(tester,(iterator->has_next(iterator)), "has next check"); - - /* check first ts */ - iterator->current(iterator,(void **)&ts1); - tester->assert_true(tester,(ts1->get_protocol_id(ts1) == 0), "ip protocol id check"); - start_host1 = ts1->get_start_host(ts1); - end_host1 = ts1->get_end_host(ts1); - tester->assert_true(tester,(start_host1->get_port(start_host1) == 500), "start port check"); - tester->assert_true(tester,(end_host1->get_port(end_host1) == 500), "start port check"); - tester->assert_true(tester,(memcmp(start_host1->get_address(start_host1),"192.168.1.0",strlen("192.168.1.0")) == 0), "start address check"); - tester->assert_true(tester,(memcmp(end_host1->get_address(end_host1),"192.168.1.255",strlen("192.168.1.255")) == 0), "end address check"); - - start_host1->destroy(start_host1); - end_host1->destroy(end_host1); - - tester->assert_true(tester,(iterator->has_next(iterator)), "has next check"); - - /* check second ts */ - - iterator->current(iterator,(void **)&ts2); - - tester->assert_true(tester,(ts2->get_protocol_id(ts2) == 3), "ip protocol id check"); - start_host2 = ts2->get_start_host(ts2); - end_host2 = ts2->get_end_host(ts2); - tester->assert_true(tester,(start_host2->get_port(start_host2) == 0), "start port check"); - tester->assert_true(tester,(end_host2->get_port(end_host2) == 65535), "start port check"); - tester->assert_true(tester,(memcmp(start_host2->get_address(start_host2),"0.0.0.0",strlen("0.0.0.0")) == 0), "start address check"); - tester->assert_true(tester,(memcmp(end_host2->get_address(end_host2),"255.255.255.255",strlen("255.255.255.255")) == 0), "end address check"); - start_host2->destroy(start_host2); - end_host2->destroy(end_host2); - - - - tester->assert_false(tester,(iterator->has_next(iterator)), "has next check"); - - iterator->destroy(iterator); - - ts_payload->destroy(ts_payload); -} - -/* - * Described in Header - */ -void test_parser_with_cert_payload(protected_tester_t *tester) -{ - parser_t *parser; - cert_payload_t *cert_payload; - status_t status; - chunk_t cert_chunk, result; - - u_int8_t cert_bytes[] = { - 0x00,0x00,0x00,0x11, /* payload header */ - 0x03, - 0x04,0x05,0x06,0x07,/* 12 Byte nonce */ - 0x08,0x09,0x0A,0x2B, - 0x0C,0x0D,0x0E,0x0F - }; - - cert_chunk.ptr = cert_bytes; - cert_chunk.len = sizeof(cert_bytes); - - parser = parser_create(cert_chunk); - tester->assert_true(tester,(parser != NULL), "parser create check"); - status = parser->parse_payload(parser, CERTIFICATE, (payload_t**)&cert_payload); - tester->assert_true(tester,(status == SUCCESS),"parse_payload call check"); - parser->destroy(parser); - - if (status != SUCCESS) - { - return; - } - result = cert_payload->get_data_clone(cert_payload); - tester->assert_true(tester,(cert_payload->get_cert_encoding(cert_payload) == CERT_DNS_SIGNED_KEY), "is DNS_SIGNED_KEY encoding"); - tester->assert_true(tester,(result.len == 12), "parsed data lenght"); - tester->assert_false(tester,(memcmp(cert_bytes + 5, result.ptr, result.len)), "parsed data"); - cert_payload->destroy(cert_payload); - chunk_free(&result); -} - -/* - * Described in Header - */ -void test_parser_with_certreq_payload(protected_tester_t *tester) -{ - parser_t *parser; - certreq_payload_t *certreq_payload; - status_t status; - chunk_t certreq_chunk, result; - - u_int8_t certreq_bytes[] = { - 0x00,0x00,0x00,0x11, /* payload header */ - 0x03, - 0x04,0x05,0x06,0x07,/* 12 Byte data */ - 0x08,0x09,0x0A,0x2B, - 0x0C,0x0D,0x0E,0x0F - }; - - certreq_chunk.ptr = certreq_bytes; - certreq_chunk.len = sizeof(certreq_bytes); - - parser = parser_create(certreq_chunk); - tester->assert_true(tester,(parser != NULL), "parser create check"); - status = parser->parse_payload(parser, CERTIFICATE_REQUEST, (payload_t**)&certreq_payload); - tester->assert_true(tester,(status == SUCCESS),"parse_payload call check"); - parser->destroy(parser); - - if (status != SUCCESS) - { - return; - } - result = certreq_payload->get_data_clone(certreq_payload); - tester->assert_true(tester,(certreq_payload->get_cert_encoding(certreq_payload) == CERT_DNS_SIGNED_KEY), "is DNS_SIGNED_KEY encoding"); - tester->assert_true(tester,(result.len == 12), "parsed data length"); - tester->assert_false(tester,(memcmp(certreq_bytes + 5, result.ptr, result.len)), "parsed data"); - certreq_payload->destroy(certreq_payload); - chunk_free(&result); -} - -/* - * Described in Header - */ -void test_parser_with_delete_payload(protected_tester_t *tester) -{ - parser_t *parser; - delete_payload_t *delete_payload; - status_t status; - chunk_t delete_chunk, result; - - u_int8_t delete_bytes[] = { - 0x00,0x00,0x00,0x14, /* payload header */ - 0x03,0x03,0x00,0x04, - 0x04,0x05,0x06,0x07,/* 12 Byte data */ - 0x08,0x09,0x0A,0x2B, - 0x0C,0x0D,0x0E,0x0F - }; - - delete_chunk.ptr = delete_bytes; - delete_chunk.len = sizeof(delete_bytes); - - parser = parser_create(delete_chunk); - tester->assert_true(tester,(parser != NULL), "parser create check"); - status = parser->parse_payload(parser, DELETE, (payload_t**)&delete_payload); - tester->assert_true(tester,(status == SUCCESS),"parse_payload call check"); - parser->destroy(parser); - - if (status != SUCCESS) - { - return; - } - result = delete_payload->get_spis(delete_payload); - tester->assert_true(tester,(delete_payload->get_protocol_id(delete_payload) == PROTO_ESP), "is ESP protocol"); - tester->assert_true(tester,(delete_payload->get_spi_size(delete_payload) == 3), "SPI size check"); - tester->assert_true(tester,(delete_payload->get_spi_count(delete_payload) == 4), "SPI count check"); - tester->assert_true(tester,(result.len == 12), "parsed data lenght"); - tester->assert_false(tester,(memcmp(delete_bytes + 8, result.ptr, result.len)), "parsed data"); - tester->assert_true(tester,(((payload_t *)delete_payload)->verify((payload_t *)delete_payload) == SUCCESS), "verify check"); - - delete_payload->destroy(delete_payload); -} - - -/* - * Described in Header - */ -void test_parser_with_vendor_id_payload(protected_tester_t *tester) -{ - parser_t *parser; - vendor_id_payload_t *vendor_id_payload; - status_t status; - chunk_t vendor_id_chunk, result; - - u_int8_t vendor_id_bytes[] = { - 0x00,0x00,0x00,0x10, /* payload header */ - 0x04,0x05,0x06,0x07,/* 12 Byte data */ - 0x08,0x09,0x0A,0x2B, - 0x0C,0x0D,0x0E,0x0F - }; - - vendor_id_chunk.ptr = vendor_id_bytes; - vendor_id_chunk.len = sizeof(vendor_id_bytes); - - parser = parser_create(vendor_id_chunk); - tester->assert_true(tester,(parser != NULL), "parser create check"); - status = parser->parse_payload(parser, VENDOR_ID, (payload_t**)&vendor_id_payload); - tester->assert_true(tester,(status == SUCCESS),"parse_payload call check"); - parser->destroy(parser); - - if (status != SUCCESS) - { - return; - } - result = vendor_id_payload->get_data(vendor_id_payload); - tester->assert_true(tester,(result.len == 12), "parsed data lenght"); - tester->assert_false(tester,(memcmp(vendor_id_bytes + 4, result.ptr, result.len)), "parsed data"); - tester->assert_true(tester,(((payload_t *)vendor_id_payload)->verify((payload_t *)vendor_id_payload) == SUCCESS), "verify check"); - - vendor_id_payload->destroy(vendor_id_payload); -} - -/* - * Described in Header - */ -void test_parser_with_cp_payload(protected_tester_t *tester) -{ - parser_t *parser; - cp_payload_t *cp_payload; - configuration_attribute_t *attribute; - status_t status; - chunk_t cp_chunk; - iterator_t *iterator; - - /* first test generic parsing functionality */ - - u_int8_t cp_bytes[] = { - /* cp payload header */ - 0x00,0x00,0x00,0x18, - 0x05,0x00,0x00,0x00, - /* configuration attribute 1*/ - 0x00,0x03,0x00,0x04, - 0x61,0x62,0x63,0x64, - /* configuration attribute 2*/ - 0x00,0x04,0x00,0x04, - 0x65,0x66,0x67,0x68, - }; - - cp_chunk.ptr = cp_bytes; - cp_chunk.len = sizeof(cp_bytes); - - - parser = parser_create(cp_chunk); - tester->assert_true(tester,(parser != NULL), "parser create check"); - status = parser->parse_payload(parser, CONFIGURATION, (payload_t**)&cp_payload); - tester->assert_true(tester,(status == SUCCESS),"parse_payload call check"); - - iterator = cp_payload->create_configuration_attribute_iterator(cp_payload,TRUE); - - tester->assert_true(tester,(iterator->has_next(iterator)),"has_next call check"); - - iterator->current(iterator,(void **)&attribute); - - - tester->assert_true(tester,(attribute->get_attribute_type(attribute) == 3),"get type check"); - tester->assert_true(tester,(attribute->get_attribute_length(attribute) == 4),"get type check"); - - tester->assert_true(tester,(iterator->has_next(iterator)),"has_next call check"); - - iterator->current(iterator,(void **)&attribute); - - - tester->assert_true(tester,(attribute->get_attribute_type(attribute) == 4),"get type check"); - tester->assert_true(tester,(attribute->get_attribute_length(attribute) == 4),"get type check"); - - iterator->current(iterator,(void **)&attribute); - - tester->assert_false(tester,(iterator->has_next(iterator)),"has_next call check"); - - - iterator->destroy(iterator); - - if (status != SUCCESS) - { - return; - } - - cp_payload->destroy(cp_payload); - parser->destroy(parser); - -} - -/* - * Described in Header - */ -void test_parser_with_eap_payload(protected_tester_t *tester) -{ - parser_t *parser; - eap_payload_t *eap_payload; - status_t status; - chunk_t eap_chunk, result; - - u_int8_t eap_bytes[] = { - 0x00,0x00,0x00,0x10, /* payload header */ - 0x04,0x05,0x06,0x07,/* 12 Byte data */ - 0x08,0x09,0x0A,0x2B, - 0x0C,0x0D,0x0E,0x0F - }; - - eap_chunk.ptr = eap_bytes; - eap_chunk.len = sizeof(eap_bytes); - - parser = parser_create(eap_chunk); - tester->assert_true(tester,(parser != NULL), "parser create check"); - status = parser->parse_payload(parser, VENDOR_ID, (payload_t**)&eap_payload); - tester->assert_true(tester,(status == SUCCESS),"parse_payload call check"); - parser->destroy(parser); - - if (status != SUCCESS) - { - return; - } - result = eap_payload->get_message(eap_payload); - tester->assert_true(tester,(result.len == 12), "parsed data lenght"); - tester->assert_false(tester,(memcmp(eap_bytes + 4, result.ptr, result.len)), "parsed data"); - tester->assert_true(tester,(((payload_t *)eap_payload)->verify((payload_t *)eap_payload) == SUCCESS), "verify check"); - - eap_payload->destroy(eap_payload); -} - diff --git a/src/charon/testing/parser_test.h b/src/charon/testing/parser_test.h deleted file mode 100644 index 0ce0d1067..000000000 --- a/src/charon/testing/parser_test.h +++ /dev/null @@ -1,171 +0,0 @@ -/** - * @file parser_test.h - * - * @brief Tests for the parser_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 . - * - * 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 PARSER_TEST_H_ -#define PARSER_TEST_H_ - -#include - -/** - * @brief Test function used to test the parser_t functionality when - * parsing a header payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_parser_with_header_payload(protected_tester_t *tester); - -/** - * @brief Test function used to test the parser_t functionality when - * parsing a sa payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_parser_with_sa_payload(protected_tester_t *tester); - -/** - * @brief Test function used to test the parser_t functionality when - * parsing a nonce payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_parser_with_nonce_payload(protected_tester_t *tester); - -/** - * @brief Test function used to test the parser_t functionality when - * parsing a ID payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_parser_with_id_payload(protected_tester_t *tester); - -/** - * @brief Test function used to test the parser_t functionality when - * parsing a ke payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_parser_with_ke_payload(protected_tester_t *tester); - -/** - * @brief Test function used to test the parser_t functionality when - * parsing a notify payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_parser_with_notify_payload(protected_tester_t *tester); - -/** - * @brief Test function used to test the parser_t functionality when - * parsing a AUTH payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_parser_with_auth_payload(protected_tester_t *tester); - -/** - * @brief Test function used to test the parser_t functionality when - * parsing a TS payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_parser_with_ts_payload(protected_tester_t *tester); - -/** - * @brief Test function used to test the parser_t functionality when - * parsing a CERT payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_parser_with_cert_payload(protected_tester_t *tester); - -/** - * @brief Test function used to test the parser_t functionality when - * parsing a CERTREQ payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_parser_with_certreq_payload(protected_tester_t *tester); - -/** - * @brief Test function used to test the parser_t functionality when - * parsing a CERTREQ payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_parser_with_delete_payload(protected_tester_t *tester); - -/** - * @brief Test function used to test the parser_t functionality when - * parsing a VENDOR ID payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_parser_with_vendor_id_payload(protected_tester_t *tester); - -/** - * @brief Test function used to test the parser_t functionality when - * parsing a CP payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_parser_with_cp_payload(protected_tester_t *tester); - -/** - * @brief Test function used to test the parser_t functionality when - * parsing a EAP payload. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_parser_with_eap_payload(protected_tester_t *tester); - - - -#endif /*PARSER_TEST_H_*/ diff --git a/src/charon/testing/policy_test.c b/src/charon/testing/policy_test.c deleted file mode 100644 index 973ca6c00..000000000 --- a/src/charon/testing/policy_test.c +++ /dev/null @@ -1,239 +0,0 @@ -/** - * @file policy_test.c - * - * @brief Tests for the policy_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 . - * - * 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 "policy_test.h" - -#include -#include -#include -#include -#include - - -/** - * Described in header. - */ -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(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 -// * -// */ -// -// ts_stored = linked_list_create(); -// -// /* allow any tcp */ -// ts = traffic_selector_create_from_string(6, TS_IPV4_ADDR_RANGE, "0.0.0.0", 0, "255.255.255.255", 65535); -// ts_stored->insert_last(ts_stored, (void*)ts); -// /* allow udp on port 123 to ".122" */ -// ts = traffic_selector_create_from_string(7, TS_IPV4_ADDR_RANGE, "152.96.193.122", 123, "152.96.193.122", 123); -// ts_stored->insert_last(ts_stored, (void*)ts); -// /* allow udp on ports > 2000 in subnet ... */ -// ts = traffic_selector_create_from_string(7, TS_IPV4_ADDR_RANGE, "152.96.193.0", 2000, "152.96.193.255", 65535); -// ts_stored->insert_last(ts_stored, (void*)ts); -// -// -// -// /* define request and result */ -// -// /* udp on subnet:123, should be reduced to ".122" */ -// ts = traffic_selector_create_from_string(7, TS_IPV4_ADDR_RANGE, "152.96.193.0", 123, "152.96.193.255", 123); -// ts_supplied->insert_last(ts_supplied, (void*)ts); -// ts_reference[0] = traffic_selector_create_from_string(7, TS_IPV4_ADDR_RANGE, "152.96.193.122", 123, "152.96.193.122", 123); -// -// /* should be granted. */ -// ts_request[1] = traffic_selector_create_from_string(7, TS_IPV4_ADDR_RANGE, "152.96.193.0", 2000, "152.96.193.255", 2000); -// ts_reference[1] = traffic_selector_create_from_string(7, TS_IPV4_ADDR_RANGE, "152.96.193.0", 2000, "152.96.193.255", 2000); -// -// /* should be reduced to port 2000 - 3000. and range ".193.*" */ -// ts_request[2] = traffic_selector_create_from_string(7, TS_IPV4_ADDR_RANGE, "152.96.191.0", 1000, "152.96.194.255", 3000); -// ts_reference[2] = traffic_selector_create_from_string(7, TS_IPV4_ADDR_RANGE, "152.96.193.0", 2000, "152.96.193.255", 3000); -// -// /* icmp request, should be discarded */ -// ts_request[3] = traffic_selector_create_from_string(1, TS_IPV4_ADDR_RANGE, "0.0.0.0", 0, "255.255.255.255", 65535); -// -// policy->add_my_traffic_selector(policy, ts_policy[0]); -// policy->add_my_traffic_selector(policy, ts_policy[1]); -// policy->add_my_traffic_selector(policy, ts_policy[2]); -// -// count = policy->get_my_traffic_selectors(policy, &ts_result); -// tester->assert_true(tester, (count == 3), "ts get count"); -// ts_result[0]->destroy(ts_result[0]); -// ts_result[0]->destroy(ts_result[1]); -// ts_result[0]->destroy(ts_result[2]); -// free(ts_result); -// -// count = policy->select_my_traffic_selectors(policy, &ts_request[0], 4, &ts_result); -// tester->assert_true(tester, (count == 3), "ts select count"); -// -// -// /* store and restore into ts payload, tricky tricky */ -// ts_payload = ts_payload_create_from_traffic_selectors(TRUE, ts_result, count); -// -// /* destroy */ -// ts_result[0]->destroy(ts_result[0]); -// ts_result[0]->destroy(ts_result[1]); -// ts_result[0]->destroy(ts_result[2]); -// free(ts_result); -// -// /* get them again out of the payload */ -// count = ts_payload->get_traffic_selectors(ts_payload, &ts_result); -// ts_payload->destroy(ts_payload); -// -// -// -// int i; -// for (i = 0; iget_from_address(ts_result[i]); -// chunk_t fa_ref = ts_reference[i]->get_from_address(ts_reference[i]); -// chunk_t ta_res = ts_result[i]->get_to_address(ts_result[i]); -// chunk_t ta_ref = ts_reference[i]->get_to_address(ts_reference[i]); -// u_int16_t fp_res = ts_result[i]->get_from_port(ts_result[i]); -// u_int16_t fp_ref = ts_reference[i]->get_from_port(ts_reference[i]); -// u_int16_t tp_res = ts_result[i]->get_to_port(ts_result[i]); -// u_int16_t tp_ref = ts_reference[i]->get_to_port(ts_reference[i]); -// -// -// logger->log_chunk(logger, RAW, "from address result", fa_res); -// logger->log_chunk(logger, RAW, "from address reference", fa_ref); -// logger->log_chunk(logger, RAW, "to address result", ta_res); -// logger->log_chunk(logger, RAW, "to address reference", ta_ref); -// tester->assert_true(tester, fa_res.len == fa_ref.len, "from address len"); -// tester->assert_false(tester, memcmp(fa_res.ptr, fa_ref.ptr,fa_res.len), "from address value"); -// tester->assert_true(tester, ta_res.len == ta_ref.len, "to address len"); -// tester->assert_false(tester, memcmp(ta_res.ptr, ta_ref.ptr,ta_res.len), "to address value"); -// -// tester->assert_true(tester, fp_res == fp_ref, "from port"); -// tester->assert_true(tester, tp_res == tp_ref, "to port"); -// -// free(fa_res.ptr); -// free(fa_ref.ptr); -// free(ta_res.ptr); -// free(ta_ref.ptr); -// } -// -// -// /* destroy */ -// ts_result[0]->destroy(ts_result[0]); -// ts_result[0]->destroy(ts_result[1]); -// ts_result[0]->destroy(ts_result[2]); -// free(ts_result); -// -// ts_policy[0]->destroy(ts_policy[0]); -// ts_policy[1]->destroy(ts_policy[1]); -// ts_policy[2]->destroy(ts_policy[2]); -// ts_request[0]->destroy(ts_request[0]); -// ts_reference[0]->destroy(ts_reference[0]); -// ts_request[1]->destroy(ts_request[1]); -// ts_reference[1]->destroy(ts_reference[1]); -// ts_request[2]->destroy(ts_request[2]); -// ts_reference[2]->destroy(ts_reference[2]); -// ts_request[3]->destroy(ts_request[3]); -/* - policy->destroy(policy);*/ -} diff --git a/src/charon/testing/policy_test.h b/src/charon/testing/policy_test.h deleted file mode 100644 index ed6af7bd9..000000000 --- a/src/charon/testing/policy_test.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file policy_test.h - * - * @brief Tests for the policy_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 . - * - * 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 SA_CONFIG_TEST_H_ -#define SA_CONFIG_TEST_H_ - -#include - -/** - * @brief Test function used to test the policy_t functionality. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_policy(protected_tester_t *tester); - -#endif /* SA_CONFIG_TEST_H_ */ - - - - diff --git a/src/charon/testing/prf_plus_test.c b/src/charon/testing/prf_plus_test.c deleted file mode 100644 index bf9137229..000000000 --- a/src/charon/testing/prf_plus_test.c +++ /dev/null @@ -1,146 +0,0 @@ -/** - * @file prf_plus_test.h - * - * @brief Tests for the prf_plus_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 . - * - * 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 - -#include "prf_plus_test.h" - -#include - - -/* - * described in Header-File - */ -void test_prf_plus(protected_tester_t *tester) -{ - prf_plus_t *prf_plus; - prf_t *prf; - chunk_t key, seed; - u_int8_t buffer[10000]; - int i; - - u_int8_t key_bytes[] = { - 0x01,0x02,0x03,0x04 - }; - u_int8_t seed_bytes[] = { - 0x01,0x02,0x03,0x04 - }; - - - - key.ptr = key_bytes; - key.len = sizeof(key_bytes); - seed.ptr = seed_bytes; - seed.len = sizeof(seed_bytes); - - prf = prf_create(PRF_HMAC_SHA1); - prf->set_key(prf, key); - - prf_plus = prf_plus_create(prf, seed); - - - for (i=0; i<100; i++) - { - prf_plus->get_bytes(prf_plus, i*i, buffer); - - } - - //tester->assert_true(tester, digest[3].len == 20, "chunk len append mode"); - //tester->assert_false(tester, memcmp(digest[3].ptr, reference[3].ptr, 20), "prf_plus value append mode"); - - prf_plus->destroy(prf_plus); - prf->destroy(prf); -} - -void test_prf_plus_md5(protected_tester_t *tester) -{ - /* md5 test data - u_int8_t nonce[] = { - 0x58,0xCC,0x4C,0xA3,0x81,0x81,0xDA,0x7D, - 0x19,0xA6,0x9F,0xB1,0xE8,0xD3,0xE7,0x96, - 0xC2,0x2A,0x6E,0xCB,0x09,0x43,0xDC,0x6E, - 0x75,0x22,0x34,0xAE,0xF8,0x53,0x7F,0xEC, - 0x00,0xC9,0xF6,0x1C,0x4A,0x39,0xB4,0x29, - 0x23,0xD8,0x24,0x22,0x95,0x52,0x77,0x29 - }; - - u_int8_t shared_key[] = { - 0xC0,0xDB,0x75,0x0A,0x40,0xBE,0xE2,0x8C,0x68,0x3C,0xB4,0xAA,0xE7,0xA7,0x6E,0xCC, - 0x2A,0x4B,0x9C,0x8E,0xC6,0x71,0xAD,0xF4,0xB7,0xC4,0xD6,0x53,0x41,0xB3,0x4A,0xE4, - 0x0D,0xC2,0x0C,0x60,0x9F,0x93,0x9E,0x87,0x30,0xCC,0xDC,0x51,0x9F,0x94,0x91,0x5D, - 0x31,0xE0,0x6E,0x22,0x3A,0x66,0x53,0xA6,0xD4,0x54,0x5E,0x71,0x61,0xA6,0x64,0x3B, - 0x19,0x40,0x6E,0x6F,0x3B,0xE3,0x64,0x3F,0x3B,0x68,0xEB,0x8E,0x4B,0x2A,0x53,0xEC, - 0xB0,0xB6,0x8E,0x5C,0x42,0xA1,0xC2,0x7F,0x4F,0x0B,0x7D,0xFC,0xF6,0x7E,0xF5,0xC0, - 0xBA,0xA8,0xFB,0x13,0xEF,0xA8,0xBD,0x90,0x95,0x08,0x2C,0x81,0xA9,0xDA,0x7D,0x45, - 0xDC,0x35,0x33,0x75,0xA8,0x4D,0xE2,0x34,0xA9,0x66,0x7F,0xAD,0x04,0x3A,0xE5,0x21 - }; - - u_int8_t skeyseed[] = { - 0xCD,0xC6,0xC0,0x68, - 0x60,0xDF,0x0C,0xC2, - 0x10,0xDB,0x0E,0xF7, - 0x20,0x6E,0x6C,0xB1 - }; - u_int8_t sk_d[] = { - 0xE1,0x74,0xA8,0x50, - 0x14,0xDB,0x79,0x64, - 0x92,0x3E,0x82,0x28, - 0x48,0x75,0x64,0xE7 - }; - u_int8_t sk_ai[] = { - 0xCA,0x19,0x73,0x69, - 0x38,0x35,0x40,0xA6, - 0xB1,0x98,0x4F,0x63, - 0xE6,0xF9,0x66,0xFF - }; - u_int8_t sk_ar[] = { - 0x14,0x1D,0x0A,0xC2, - 0x7B,0x1C,0x87,0xD2, - 0x65,0xA5,0xEF,0x0C, - 0x47,0xF4,0xCE,0xE2 - }; - u_int8_t sk_ei[] = { - 0x52,0x50,0x7E,0xDA, - 0x02,0x1D,0x8E,0xCF, - 0x20,0xA3,0x67,0xA6, - 0x4D,0xA0,0xAB,0x61 - }; - u_int8_t sk_er[] = { - 0xB9,0x65,0x0A,0x3C, - 0x30,0xA8,0x26,0x78, - 0x60,0x5A,0x74,0xBB, - 0x5C,0xC4,0xF8,0x71 - }; - u_int8_t sk_pi[] = { - 0xDD,0x61,0xAB,0x53, - 0xC8,0xDD,0x3A,0x44, - 0xDA,0x47,0x09,0x9B, - 0x3B,0xD2,0xBB,0xB6 - }; - u_int8_t sk_pr[] = { - 0x18,0x75,0xE4,0xC6, - 0x57,0xC4,0xDE,0x65, - 0x10,0xEB,0xA7,0xB6, - 0x24,0x0D,0xEC,0xB4 - };*/ -} diff --git a/src/charon/testing/prf_plus_test.h b/src/charon/testing/prf_plus_test.h deleted file mode 100644 index 7713292b6..000000000 --- a/src/charon/testing/prf_plus_test.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @file prf_plus_test.h - * - * @brief Tests for the prf_plus_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 . - * - * 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 PRF_PLUS_TEST_H_ -#define PRF_PLUS_TEST_H_ - -#include -#include - -/** - * @brief Test function used to test the prf_plus class. - * - * @param tester associated tester object - * - * @ingroup testcases - */ -void test_prf_plus(protected_tester_t *tester); - -#endif /*PRF_PLUS_TEST_H_*/ diff --git a/src/charon/testing/proposal_test.c b/src/charon/testing/proposal_test.c deleted file mode 100644 index 50cca1252..000000000 --- a/src/charon/testing/proposal_test.c +++ /dev/null @@ -1,106 +0,0 @@ -/** - * @file proposal_test.c - * - * @brief Tests for the proposal_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 . - * - * 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 "proposal_test.h" - -#include -#include -#include - - -/** - * Described in header. - */ -void test_proposal(protected_tester_t *tester) -{ - proposal_t *proposal1, *proposal2, *proposal3, *proposal4; - iterator_t *iterator; - algorithm_t *algo; - bool result; - - proposal1 = proposal_create(PROTO_ESP); - proposal1->add_algorithm(proposal1, ENCRYPTION_ALGORITHM, ENCR_3DES, 0); - proposal1->add_algorithm(proposal1, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 256); - proposal1->add_algorithm(proposal1, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 128); - proposal1->add_algorithm(proposal1, ENCRYPTION_ALGORITHM, ENCR_BLOWFISH, 0); - proposal1->add_algorithm(proposal1, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 0); - proposal1->add_algorithm(proposal1, INTEGRITY_ALGORITHM, AUTH_HMAC_MD5_96, 0); - 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(PROTO_ESP); - proposal2->add_algorithm(proposal2, ENCRYPTION_ALGORITHM, ENCR_3IDEA, 0); - proposal2->add_algorithm(proposal2, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 128); - proposal2->add_algorithm(proposal2, INTEGRITY_ALGORITHM, AUTH_HMAC_MD5_96, 0); - proposal2->add_algorithm(proposal2, DIFFIE_HELLMAN_GROUP, MODP_1024_BIT, 0); - - /* ah and esp prop */ - proposal3 = proposal1->select(proposal1, proposal2); - tester->assert_false(tester, proposal3 == NULL, "proposal select"); - if (proposal3) - { - 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 == 128, "encryption keylen"); - - - result = proposal3->get_algorithm(proposal3, INTEGRITY_ALGORITHM, &algo); - tester->assert_true(tester, result, "integrity algo select"); - tester->assert_true(tester, algo->algorithm == AUTH_HMAC_MD5_96, "integrity algo"); - - 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"); - } - iterator->destroy(iterator); - proposal3->destroy(proposal3); - } - - proposal1->destroy(proposal1); - proposal2->destroy(proposal2); - - /* from string tests */ - - proposal1 = proposal_create_from_string(PROTO_ESP, "3des-md5!"); - proposal2 = proposal_create_from_string(PROTO_ESP, "3des-md5-modp1024!"); - proposal3 = proposal_create_from_string(PROTO_ESP, "aes256-sha1"); - - proposal4 = proposal1->select(proposal1, proposal2); - tester->assert_true(tester, proposal4 == NULL, "from string 1"); - - proposal4 = proposal1->select(proposal1, proposal3); - tester->assert_true(tester, proposal4 != NULL, "from string 2"); - - result = proposal4->get_algorithm(proposal4, ENCRYPTION_ALGORITHM, &algo); - tester->assert_true(tester, result, "from string 3"); - tester->assert_true(tester, algo->algorithm == ENCR_3DES, "from string 4"); - result = proposal4->get_algorithm(proposal4, INTEGRITY_ALGORITHM, &algo); - tester->assert_true(tester, result, "from string 5"); - tester->assert_true(tester, algo->algorithm == AUTH_HMAC_MD5_96, "from string 6"); - - return; -} diff --git a/src/charon/testing/proposal_test.h b/src/charon/testing/proposal_test.h deleted file mode 100644 index 39d461164..000000000 --- a/src/charon/testing/proposal_test.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file proposal_test.h - * - * @brief Tests for the proposal_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 . - * - * 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_PROPOSAL_TEST_H_ -#define CHILD_PROPOSAL_TEST_H_ - -#include - -/** - * @brief Test function used to test the proposal_t functionality. - * - * @param tester associated protected_tester_t object - * - * @ingroup testcases - */ -void test_proposal(protected_tester_t *tester); - -#endif /* CHILD_PROPOSAL_TEST_H_ */ - - - - diff --git a/src/charon/testing/rsa_test.c b/src/charon/testing/rsa_test.c deleted file mode 100644 index 08dd9abd1..000000000 --- a/src/charon/testing/rsa_test.c +++ /dev/null @@ -1,225 +0,0 @@ -/** - * @file rsa_test.h - * - * @brief Tests for the hasher_t classes. - * - */ - -/* - * 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 . - * - * 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 - -#include "rsa_test.h" - -#include -#include -#include - -char private_key_buffer[] = { - 0x30,0x82,0x04,0xa2,0x02,0x00,0x02,0x82,0x01,0x00,0x6f,0x25,0x74,0x63,0x2a,0x2f, - 0x5d,0xd4,0x54,0x03,0xbe,0xd5,0x34,0x71,0xe0,0x30,0x37,0xe5,0x2e,0x39,0xda,0xe7, - 0x04,0xd4,0xe2,0x5b,0x43,0xc3,0x6a,0x50,0x61,0xe8,0x4b,0x5d,0x58,0x30,0xa4,0xcc, - 0x6d,0xab,0xdf,0x8b,0x75,0x8c,0x22,0x43,0xd4,0xd0,0x18,0x5e,0x32,0x24,0xba,0x38, - 0x6f,0xab,0x64,0x86,0x8f,0x54,0x40,0x77,0xcb,0x3a,0xb5,0x30,0xde,0xb4,0xcd,0x98, - 0xbb,0xb1,0xdb,0x7a,0xd4,0xc7,0x0e,0xc7,0x99,0xc4,0x05,0xd5,0xa4,0x96,0x2a,0x3c, - 0x71,0x0f,0x31,0xa4,0xcd,0xc2,0x15,0x28,0xec,0x16,0x02,0x28,0x61,0x5e,0x8e,0xcf, - 0xb6,0x0b,0x8c,0x81,0x79,0x58,0xfc,0x9b,0x5b,0x32,0x26,0xcb,0xbc,0xf2,0xc9,0x8a, - 0x76,0x26,0x4e,0x87,0xaa,0x1b,0xd4,0xa7,0xb3,0xcf,0x96,0x99,0x86,0xcc,0xcb,0x5e, - 0xb2,0x66,0xc9,0xe0,0x10,0xbe,0xf7,0xd9,0x99,0xa3,0x49,0x5c,0x41,0x1f,0xa4,0xd0, - 0xd0,0x48,0x77,0xad,0x0f,0xbc,0x2c,0x2a,0x29,0x34,0x3f,0x20,0xb5,0x15,0xa1,0xa7, - 0x22,0xda,0x15,0xf3,0xf1,0x51,0x83,0x1f,0x3d,0x49,0x26,0x81,0x6d,0x65,0xa6,0x9c, - 0x09,0x01,0xfa,0x10,0x26,0x76,0xec,0x46,0x77,0xa6,0xc1,0xf5,0xc7,0xa3,0x2d,0xf9, - 0x60,0xa1,0x8f,0x94,0x17,0x58,0x0d,0xc9,0x55,0x50,0x2a,0xeb,0x44,0x5e,0xea,0x69, - 0xc9,0x76,0x67,0x9c,0x8e,0xd1,0x9c,0x4f,0x9d,0x9e,0x0a,0xec,0x44,0x6b,0x7e,0x01, - 0x2d,0x53,0xf2,0xd6,0x7c,0x27,0x30,0x3d,0x40,0x6c,0x3c,0xef,0x82,0xd1,0x7f,0xe2, - 0xd2,0x9b,0xb6,0x96,0x08,0xd2,0xe0,0x8a,0x28,0xeb,0x02,0x03,0x01,0x00,0x01,0x02, - 0x82,0x01,0x00,0x0b,0x89,0xcc,0x5c,0xd5,0x0e,0xc8,0xc3,0x57,0x9b,0x71,0xee,0xa9, - 0x3c,0x9f,0x24,0xf2,0x50,0x88,0xed,0x79,0xa3,0x9c,0xf5,0x4a,0xb0,0x65,0xc6,0xfe, - 0x1c,0xed,0x25,0x13,0xd9,0xd3,0x63,0x6d,0x60,0x49,0x8c,0x5b,0xaf,0x1b,0x1b,0x5a, - 0x9d,0x47,0x14,0xf9,0x4a,0xa2,0x12,0xfd,0x00,0x09,0xdb,0xb5,0x9a,0x60,0x7b,0xc3, - 0x1b,0x8c,0x8e,0x02,0x2c,0x5a,0x1a,0x53,0xf3,0xa4,0x9c,0x90,0xa7,0xde,0x39,0xf1, - 0xf7,0x57,0xa7,0xa9,0x61,0x65,0xee,0x2e,0xe1,0x4a,0x6d,0x64,0xde,0x72,0x7b,0xd0, - 0xfd,0x88,0x10,0xba,0xd5,0x9d,0x52,0x17,0x2a,0x4a,0x00,0x45,0xec,0x55,0x00,0x1f, - 0x6d,0x33,0x58,0xef,0xfd,0x1b,0x96,0xea,0xc4,0x44,0x82,0xb2,0x89,0x53,0xe8,0x02, - 0xba,0x0c,0x28,0xff,0xd1,0xda,0xdc,0xea,0xae,0x80,0xbe,0x33,0x86,0xbc,0x38,0xe9, - 0x1c,0xa9,0x39,0xc5,0x28,0x14,0x53,0x5a,0x52,0x3e,0xff,0xb8,0xc6,0x77,0x7c,0xe2, - 0xf9,0x50,0x9a,0x58,0x46,0x4e,0xdf,0x11,0x0f,0x4d,0x70,0xf3,0xe7,0xe7,0x9a,0x8a, - 0x9f,0x58,0x05,0x54,0xda,0x60,0x52,0xec,0xa8,0x10,0x60,0x9c,0x83,0xf0,0xd7,0x15, - 0xaf,0xf9,0x44,0xe8,0x3e,0x68,0xb2,0x06,0xa5,0x6d,0x6d,0xc1,0x8d,0x55,0xa3,0x6e, - 0x7e,0xe4,0x86,0x2a,0x6e,0x23,0xe0,0xf5,0xe6,0x08,0x05,0xb5,0x1a,0x6d,0x9c,0xf4, - 0xbd,0x18,0x20,0x58,0x43,0x67,0x72,0xde,0x47,0x56,0xee,0x94,0xc6,0x70,0xc1,0xda, - 0x15,0x2a,0xb9,0xb7,0x6a,0x10,0xc4,0x02,0x6e,0xae,0x93,0xe8,0x5e,0x8f,0x55,0x80, - 0x4e,0x9a,0x75,0x02,0x81,0x81,0x00,0xc4,0x25,0x05,0xab,0x8d,0x6b,0xa0,0xac,0x82, - 0x44,0xe2,0x13,0x06,0x2e,0x1c,0x7b,0x6b,0x37,0x69,0x93,0x9e,0x33,0x41,0xb1,0xf0, - 0x54,0x6e,0xe1,0x52,0x98,0x83,0x36,0x2b,0xe4,0x86,0x85,0x19,0x53,0x1f,0xd7,0x2f, - 0xbb,0x76,0xef,0x8d,0xb1,0x42,0xd3,0xfc,0xba,0xc7,0xb6,0xe4,0x73,0x42,0x83,0x1d, - 0x08,0xf9,0x17,0x83,0xd3,0xb7,0xe7,0xb4,0x26,0x74,0x59,0xb6,0x07,0xe1,0x1f,0x97, - 0x1e,0x66,0x77,0xe2,0x7a,0x3e,0xb2,0x43,0x2a,0x60,0x34,0xa6,0x2e,0x4a,0x13,0xb9, - 0x4f,0xc3,0x64,0xc5,0xee,0x04,0x40,0xf4,0xa5,0x01,0x45,0xba,0x9e,0x09,0x22,0xd9, - 0x99,0x0c,0x0e,0x23,0xd9,0x43,0x8b,0x01,0x1a,0x3f,0xd4,0xa8,0x8d,0x9a,0xfc,0x9c, - 0x05,0x1d,0x6d,0x7b,0x18,0xe0,0x95,0x02,0x81,0x81,0x00,0x91,0x10,0x4b,0x84,0xdc, - 0x10,0x67,0x22,0x84,0x60,0x96,0x2e,0x11,0x1a,0xe9,0x1c,0xb7,0x2f,0xa4,0x4c,0xf4, - 0xd0,0x57,0xa2,0x4b,0xbc,0xa2,0x02,0x0f,0x33,0x1b,0x1f,0x19,0x19,0x68,0x8d,0xb6, - 0x8a,0x36,0xe3,0xeb,0x2c,0x8c,0xba,0x69,0xb4,0x17,0x97,0xfe,0x0b,0x76,0x2a,0x97, - 0x87,0x0c,0xdf,0x1e,0x7a,0xbc,0xc0,0x86,0x27,0x31,0xb9,0x9d,0xc2,0xf2,0xb7,0xcc, - 0x83,0x6a,0x5a,0xa1,0xab,0x05,0x60,0xa0,0x04,0x90,0xe2,0xc4,0x03,0xb4,0xd8,0x30, - 0xaa,0x93,0xd8,0x90,0x4e,0x3c,0x33,0x1f,0x43,0xa2,0x3a,0x2c,0x34,0xb9,0x01,0x89, - 0xbb,0xdc,0x0b,0x2e,0x4f,0x89,0x1b,0xf8,0x77,0x4c,0x4c,0x25,0xc5,0xca,0x38,0x00, - 0xd4,0x3a,0xaa,0x7c,0xf6,0xb6,0xad,0x69,0x0d,0x03,0x7f,0x02,0x81,0x81,0x00,0xa3, - 0xcc,0xef,0x21,0x46,0xe6,0xdc,0xb5,0x73,0xcc,0xa6,0xa7,0x90,0x7f,0xad,0x95,0x7c, - 0x02,0x38,0x8e,0xe8,0x8c,0x91,0x8e,0x51,0xcf,0x91,0x11,0x66,0x72,0xab,0x10,0xf0, - 0x32,0xd6,0x0c,0x0d,0x0c,0x18,0x09,0x12,0x79,0x91,0x67,0x98,0x82,0xb1,0xf6,0x6a, - 0x96,0x68,0xf6,0x59,0x6d,0xcf,0xdb,0xc2,0xc1,0x9d,0x93,0x7f,0xa9,0xad,0x69,0x38, - 0x4e,0xec,0xd7,0x86,0x66,0xaa,0x20,0x41,0x89,0x47,0xb5,0x52,0x53,0x18,0x4c,0xb2, - 0x3e,0x8f,0x3d,0x28,0x92,0x7b,0x96,0x61,0x29,0x35,0x59,0xd0,0xd9,0x66,0x80,0x00, - 0x4e,0x53,0xf3,0xb1,0x57,0x0c,0xf6,0x27,0x95,0xe2,0x35,0x64,0xc6,0xa9,0xdb,0x49, - 0xbe,0x6c,0x13,0xe1,0xf6,0xef,0xb9,0x89,0x69,0xd4,0x1b,0x7b,0xb3,0x58,0xc9,0x02, - 0x81,0x80,0x40,0x28,0x3d,0xce,0x37,0xea,0x05,0x43,0x2d,0xda,0xed,0xf0,0xd7,0xdd, - 0xd8,0x05,0xbc,0x3b,0x14,0xe6,0x78,0x4c,0x00,0xc6,0x25,0xca,0xfa,0xb8,0x00,0x72, - 0xf0,0xe6,0xd3,0x19,0xfa,0xb4,0xda,0x6b,0xcc,0x95,0x06,0xf9,0x00,0x10,0x9e,0x19, - 0x69,0x69,0xee,0x90,0xb1,0x25,0x6b,0x38,0xee,0x87,0x6b,0x9a,0x8b,0x0a,0x77,0x0a, - 0xb4,0xa2,0x4c,0x54,0xe1,0x36,0x4a,0xfc,0x40,0x38,0x6f,0x52,0x0d,0x21,0xcc,0x03, - 0xd8,0xf4,0x82,0x0e,0xc5,0x97,0xec,0x06,0x35,0x37,0x4d,0xb3,0x5c,0x4a,0x9b,0xe4, - 0x34,0xc6,0x97,0xb0,0x85,0xb6,0x59,0x6d,0x3d,0x87,0xb0,0x66,0xba,0xd4,0x25,0x12, - 0xd6,0x2a,0xc3,0x75,0xf3,0xd6,0xca,0xff,0x12,0x27,0x3e,0xf7,0x7a,0x99,0xbd,0x61, - 0x65,0x0f,0x02,0x81,0x81,0x00,0xb2,0xcb,0x21,0xf9,0x77,0x44,0x20,0xee,0xe9,0x60, - 0xf2,0x32,0x7e,0xd0,0xb2,0x8b,0xa7,0x96,0x20,0x20,0xf2,0x88,0xbd,0xbe,0x1f,0x92, - 0x59,0x26,0x7c,0x26,0x64,0x13,0xfc,0x9a,0x1c,0xd6,0x48,0xbf,0xe3,0xad,0x2d,0x89, - 0xd4,0x11,0x9b,0xed,0x38,0x99,0x3e,0xf4,0xe3,0x54,0xa3,0x0c,0x2a,0x91,0xdc,0xf9, - 0x38,0x94,0xbe,0xd7,0x90,0xc2,0x8d,0xcc,0x5a,0x28,0xbd,0x46,0x4e,0xd7,0x86,0x52, - 0x95,0xb1,0x39,0xb9,0x30,0x33,0x1f,0xe8,0xe7,0x37,0xfe,0x37,0xa5,0x20,0x82,0x1a, - 0xfd,0xc3,0x30,0xd0,0xdc,0x8d,0x71,0x66,0x30,0xb4,0x9a,0xb2,0xd6,0x03,0xfe,0xc5, - 0x4b,0xfd,0xd2,0x1b,0x3e,0x4e,0xc6,0xb0,0xe8,0x6c,0x83,0x44,0x6b,0xaa,0x05,0x51, - 0xd3,0xb2,0x04,0xca,0xf6,0xf3, -}; - -char public_key_buffer[] = { -// 0x30,0x82,0x01,0x21,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01, -// 0x01,0x05,0x00,0x03,0x82,0x01,0x0e,0x00, - 0x30,0x82,0x01,0x09,0x02,0x82,0x01,0x00, - 0x6f,0x25,0x74,0x63,0x2a,0x2f,0x5d,0xd4,0x54,0x03,0xbe,0xd5,0x34,0x71,0xe0,0x30, - 0x37,0xe5,0x2e,0x39,0xda,0xe7,0x04,0xd4,0xe2,0x5b,0x43,0xc3,0x6a,0x50,0x61,0xe8, - 0x4b,0x5d,0x58,0x30,0xa4,0xcc,0x6d,0xab,0xdf,0x8b,0x75,0x8c,0x22,0x43,0xd4,0xd0, - 0x18,0x5e,0x32,0x24,0xba,0x38,0x6f,0xab,0x64,0x86,0x8f,0x54,0x40,0x77,0xcb,0x3a, - 0xb5,0x30,0xde,0xb4,0xcd,0x98,0xbb,0xb1,0xdb,0x7a,0xd4,0xc7,0x0e,0xc7,0x99,0xc4, - 0x05,0xd5,0xa4,0x96,0x2a,0x3c,0x71,0x0f,0x31,0xa4,0xcd,0xc2,0x15,0x28,0xec,0x16, - 0x02,0x28,0x61,0x5e,0x8e,0xcf,0xb6,0x0b,0x8c,0x81,0x79,0x58,0xfc,0x9b,0x5b,0x32, - 0x26,0xcb,0xbc,0xf2,0xc9,0x8a,0x76,0x26,0x4e,0x87,0xaa,0x1b,0xd4,0xa7,0xb3,0xcf, - 0x96,0x99,0x86,0xcc,0xcb,0x5e,0xb2,0x66,0xc9,0xe0,0x10,0xbe,0xf7,0xd9,0x99,0xa3, - 0x49,0x5c,0x41,0x1f,0xa4,0xd0,0xd0,0x48,0x77,0xad,0x0f,0xbc,0x2c,0x2a,0x29,0x34, - 0x3f,0x20,0xb5,0x15,0xa1,0xa7,0x22,0xda,0x15,0xf3,0xf1,0x51,0x83,0x1f,0x3d,0x49, - 0x26,0x81,0x6d,0x65,0xa6,0x9c,0x09,0x01,0xfa,0x10,0x26,0x76,0xec,0x46,0x77,0xa6, - 0xc1,0xf5,0xc7,0xa3,0x2d,0xf9,0x60,0xa1,0x8f,0x94,0x17,0x58,0x0d,0xc9,0x55,0x50, - 0x2a,0xeb,0x44,0x5e,0xea,0x69,0xc9,0x76,0x67,0x9c,0x8e,0xd1,0x9c,0x4f,0x9d,0x9e, - 0x0a,0xec,0x44,0x6b,0x7e,0x01,0x2d,0x53,0xf2,0xd6,0x7c,0x27,0x30,0x3d,0x40,0x6c, - 0x3c,0xef,0x82,0xd1,0x7f,0xe2,0xd2,0x9b,0xb6,0x96,0x08,0xd2,0xe0,0x8a,0x28,0xeb, - 0x02,0x03,0x01,0x00,0x01 - -}; - -/* - * described in Header-File - */ -void test_rsa(protected_tester_t *tester) -{ - rsa_private_key_t *private_key; - rsa_public_key_t *public_key; - x509_t *certificate; - chunk_t data, signature; - chunk_t der_private_key = {private_key_buffer, sizeof(private_key_buffer)}; - chunk_t der_public_key = {public_key_buffer, sizeof(public_key_buffer)}; - logger_t *logger; - status_t status; - - u_int8_t test_data[] = { - 0x01,0x02,0x03,0x04, - 0x11,0x12,0x13,0x14, - 0x21,0x22,0x23,0x24, - 0x31,0x32,0x33,0x34, - 0x41,0x42,0x43,0x44, - 0x51,0x52,0x53,0x54, - 0x61,0x62,0x63,0x64, - 0x71,0x72,0x73,0x74, - 0x81,0x82,0x83,0x84, - }; - data.ptr = test_data; - data.len = sizeof(test_data); - - logger = logger_manager->get_logger(logger_manager, TESTER); - logger->disable_level(logger, FULL); - - /* key generation and signing */ -// private_key = rsa_private_key_create(512); -// tester->assert_true(tester, private_key != NULL, "generating private key"); -// -// status = private_key->build_emsa_pkcs1_signature(private_key, HASH_MD5, data, &signature); -// tester->assert_true(tester, status == SUCCESS, "build emsa_pkcs1_signature (genkey)"); -// -// public_key = private_key->get_public_key(private_key); -// tester->assert_true(tester, public_key != NULL, "extracting public key"); -// -// status = public_key->verify_emsa_pkcs1_signature(public_key, data, signature); -// tester->assert_true(tester, status == SUCCESS, "verify emsa_pkcs1_signature (genkey)"); -// -// free(signature.ptr); -// -// private_key->destroy(private_key); - - /* key setting */ - private_key = rsa_private_key_create_from_chunk(der_private_key); - tester->assert_true(tester, private_key != NULL, "loading private key from chunk"); - public_key = rsa_public_key_create_from_chunk(der_public_key); - tester->assert_true(tester, public_key != NULL, "loading public key from chunk"); - - status = private_key->build_emsa_pkcs1_signature(private_key, HASH_MD5, data, &signature); - tester->assert_true(tester, status == SUCCESS, "build emsa_pkcs1_signature (setkey)"); - status = public_key->verify_emsa_pkcs1_signature(public_key, data, signature); - tester->assert_true(tester, status == SUCCESS, "verify emsa_pkcs1_signature (setkey)"); - - free(signature.ptr); - - /* key comparison */ - tester->assert_true(tester, private_key->belongs_to(private_key, public_key), "key belongs to"); - - private_key->destroy(private_key); - private_key = rsa_private_key_create(512); - tester->assert_false(tester, private_key->belongs_to(private_key, public_key), "key belongs not to"); - - public_key->destroy(public_key); - private_key->destroy(private_key); - - /* key loading */ - private_key = rsa_private_key_create_from_file("alice.der", NULL); - tester->assert_true(tester, private_key != NULL, "loading private key from file"); - certificate = x509_create_from_file("alice-cert.der", "testcert"); - tester->assert_true(tester, public_key != NULL, "loading certificate from file"); - public_key = certificate->get_public_key(certificate); - tester->assert_true(tester, public_key != NULL, "loading public key from certificate"); - - tester->assert_true(tester, private_key->belongs_to(private_key, public_key), "key belongs to"); - - status = private_key->build_emsa_pkcs1_signature(private_key, HASH_SHA1, data, &signature); - tester->assert_true(tester, status == SUCCESS, "build emsa_pkcs1_signature (loadkey)"); - status = public_key->verify_emsa_pkcs1_signature(public_key, data, signature); - tester->assert_true(tester, status == SUCCESS, "verify emsa_pkcs1_signature (loadkey)"); - - free(signature.ptr); - - certificate->destroy(certificate); - private_key->destroy(private_key); - -} diff --git a/src/charon/testing/rsa_test.h b/src/charon/testing/rsa_test.h deleted file mode 100644 index 147ea14ec..000000000 --- a/src/charon/testing/rsa_test.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @file rsa_test.h - * - * @brief Tests for the rsa_public_key_t and rsa_private_key classes. - * - */ - -/* - * 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 . - * - * 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 RSA_TEST_H -#define RSA_TEST_H - -#include -#include - -#include - -/** - * @brief Test function used to test the rsa functionality. - * - * @param tester associated tester object - * - * @ingroup testcases - */ -void test_rsa(protected_tester_t *tester); - - -#endif /*RSA_TEST_H*/ diff --git a/src/charon/testing/scheduler_test.c b/src/charon/testing/scheduler_test.c deleted file mode 100644 index e522a24cc..000000000 --- a/src/charon/testing/scheduler_test.c +++ /dev/null @@ -1,93 +0,0 @@ -/** - * @file scheduler_test.c - * - * @brief Tests for the scheduler_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 . - * - * 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 -#include - -#include "scheduler_test.h" - -#include -#include -#include -#include -#include - - -/** - * @brief implementation of a scheduler test - * - * This one uses relative time events, which are not that exact. - * Test may fail on too slow machines. - */ -void test_scheduler(protected_tester_t *tester) -{ - int job_count = 5; - job_t *jobs[job_count]; - int current; - scheduler_t *scheduler = scheduler_create(); - - /* schedule 5 jobs */ - for (current = 0; current < job_count; current++) - { - /* misusing for testing only */ - jobs[current] = (job_t *) incoming_packet_job_create((packet_t*)(current+1)); - charon->event_queue->add_relative(charon->event_queue, jobs[current], (current+1) * 500); - } - - - for (current = 0; current < job_count; current++) - { - jobs[current] = NULL; - } - - usleep(50 * 1000); - - /* check if times are correct */ - for (current = 0; current < job_count; current++) - { - usleep(400 * 1000); - - tester->assert_true(tester, (charon->job_queue->get_count(charon->job_queue) == current ), "job-queue size before event"); - tester->assert_true(tester, (charon->event_queue->get_count(charon->event_queue) == job_count - current), "event-queue size before event"); - usleep(100 * 1000); - - tester->assert_true(tester, (charon->job_queue->get_count(charon->job_queue) == current + 1), "job-queue size after event"); - tester->assert_true(tester, (charon->event_queue->get_count(charon->event_queue) == job_count - current - 1), "event-queue size after event"); - } - - /* check job order */ - for (current = 0; current < job_count; current++) - { - jobs[current] = charon->job_queue->get(charon->job_queue); - incoming_packet_job_t *current_job; - current_job = (incoming_packet_job_t*) jobs[current]; - packet_t *packet; - packet = current_job->get_packet(current_job); - - tester->assert_true(tester, (((int)packet) == current+1), "job order"); - jobs[current]->destroy(jobs[current]); - } - - /* destruction test */ - scheduler->destroy(scheduler); -} diff --git a/src/charon/testing/scheduler_test.h b/src/charon/testing/scheduler_test.h deleted file mode 100644 index 8b859cf69..000000000 --- a/src/charon/testing/scheduler_test.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @file scheduler_test.h - * - * @brief Tests for the scheduler_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 . - * - * 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 SCHEDULER_TEST_H_ -#define SCHEDULER_TEST_H_ - -#include - -/** - * @brief Test function for the type scheduler_t. - * - * @param tester tester object - * - * @ingroup testcases - */ -void test_scheduler(protected_tester_t *tester); - -#endif /*SCHEDULER_TEST_H_*/ diff --git a/src/charon/testing/send_queue_test.c b/src/charon/testing/send_queue_test.c deleted file mode 100644 index d9e9541cd..000000000 --- a/src/charon/testing/send_queue_test.c +++ /dev/null @@ -1,143 +0,0 @@ -/** - * @file send_queue_test.c - * - * @brief Tests for the send_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 . - * - * 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 - -#include "send_queue_test.h" - -#include - - -/** - * @brief Informations for the involved test-thread used in this test - * - */ -typedef struct send_queue_test_s send_queue_test_t; - - -struct send_queue_test_s{ - /** - * Associated protected_tester_t object - */ - protected_tester_t *tester; - - /** - * Queue to test - */ - send_queue_t *send_queue; - - /** - * number of items to be inserted in the send-queue by each thread - */ - int insert_item_count; - - /** - * number of items to be removed by each - * receiver thread from the send-queue - */ - int remove_item_count; -}; - -/** - * @brief sender thread used in the the send_queue test function - * - * @param testinfo informations for the specific thread. - */ -static void test_send_queue_sender(send_queue_test_t * testinfo) -{ - int i; - for (i = 0; i < testinfo->insert_item_count; i++) - { - packet_t *packet = packet_create(); - testinfo->tester->assert_true(testinfo->tester,(packet != NULL), "create packet call check"); - testinfo->send_queue->add(testinfo->send_queue,packet); - } -} - -/** - * @brief receiver thread used in the the send_queue test function - * - * @param testinfo informations for the specific thread. - */ -static void test_send_queue_receiver(send_queue_test_t * testinfo) -{ - int i; - for (i = 0; i < testinfo->remove_item_count; i++) - { - packet_t *packet; - packet = testinfo->send_queue->get(testinfo->send_queue); - - testinfo->tester->assert_true(testinfo->tester,( packet != NULL), "packet not NULL call check"); - - packet->destroy(packet); - } -} - -/* - * description is in header file - */ -void test_send_queue(protected_tester_t *tester) -{ - int desired_value, i; - int sender_count = 10; - int receiver_count = 2; - pthread_t sender_threads[sender_count]; - pthread_t receiver_threads[receiver_count]; - send_queue_t *send_queue = send_queue_create(); - send_queue_test_t test_infos; - - test_infos.tester = tester; - test_infos.send_queue = send_queue; - test_infos.insert_item_count = 10000; - test_infos.remove_item_count = 10000; - - - desired_value = test_infos.insert_item_count * sender_count - - test_infos.remove_item_count * receiver_count; - - for (i = 0; i < receiver_count;i++) - { - pthread_create( &receiver_threads[i], NULL,(void*(*)(void*)) &test_send_queue_receiver, (void*) &test_infos); - } - - for (i = 0; i < sender_count;i++) - { - pthread_create( &sender_threads[i], NULL,(void*(*)(void*)) &test_send_queue_sender, (void*) &test_infos); - } - - - /* Wait for all threads */ - for (i = 0; i < sender_count;i++) - { - pthread_join(sender_threads[i], NULL); - } - for (i = 0; i < receiver_count;i++) - { - pthread_join(receiver_threads[i], NULL); - } - - - /* the send-queue has to have diserd_value count entries*/ - tester->assert_true(tester,(send_queue->get_count(send_queue) == desired_value), "count value check"); - send_queue->destroy(send_queue); -} diff --git a/src/charon/testing/send_queue_test.h b/src/charon/testing/send_queue_test.h deleted file mode 100644 index 570b77e6e..000000000 --- a/src/charon/testing/send_queue_test.h +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @file send_queue_test.h - * - * @brief Tests for the send_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 . - * - * 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 SEND_QUEUE_TEST_H_ -#define SEND_QUEUE_TEST_H_ - -#include - -/** - * @brief Test function used to test the send_queue functionality. - * - * Tests are performed using different threads to test the multi-threaded - * features of the send_queue_t. - * - * @param tester associated tester object - * - * @ingroup testcases - */ -void test_send_queue(protected_tester_t *tester); - -#endif /*SEND_QUEUE_TEST_H_*/ diff --git a/src/charon/testing/sender_test.c b/src/charon/testing/sender_test.c deleted file mode 100644 index 71754b08e..000000000 --- a/src/charon/testing/sender_test.c +++ /dev/null @@ -1,89 +0,0 @@ -/** - * @file sender_test.h - * - * @brief Tests for the sender_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 . - * - * 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 - -#include "sender_test.h" - -#include -#include -#include -#include -#include -#include -#include - -/** - * Number of packets to send by sender-thread - */ -#define NUMBER_OF_PACKETS_TO_SEND 5 - -void test_sender(protected_tester_t *tester) -{ - int i; - sender_t *sender; - receiver_t *receiver; - job_t *job; - packet_t *packet; - packet_t *received_packet; - char test_data[] = { - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, /* spi */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05, /* spi */ - 0x05, /* next payload */ - 0x20, /* IKE version */ - 0x00, /* exchange type */ - 0x00, /* flags */ - 0x00,0x00,0x00,0x01, /* message id */ - 0x00,0x00,0x00,0x24, /* length */ - 0x12,0x34,0x56,0x67, /* some data */ - 0x12,0x34,0x56,0x67, - }; - chunk_t data = chunk_from_buf(test_data); - chunk_t received; - sender = sender_create(); - receiver = receiver_create(); - - for (i = 0; i < NUMBER_OF_PACKETS_TO_SEND; i++) - { - packet = packet_create(); - packet->set_destination(packet, host_create(AF_INET, "127.0.0.1", 500)); - packet->set_source(packet, host_create(AF_INET, "127.0.0.1", 500)); - packet->set_data(packet, chunk_clone(data)); - charon->send_queue->add(charon->send_queue,packet); - } - - for (i = 0; i < NUMBER_OF_PACKETS_TO_SEND; i++) - { - job = charon->job_queue->get(charon->job_queue); - tester->assert_true(tester, (job->get_type(job) == INCOMING_PACKET), "job type check"); - received_packet = ((incoming_packet_job_t *)(job))->get_packet((incoming_packet_job_t *)(job)); - received = received_packet->get_data(received_packet); - tester->assert_true(tester, received.len == data.len, "received data length check"); - tester->assert_true(tester, memcmp(received.ptr, data.ptr, data.len) == 0, "received data value check"); - received_packet->destroy(received_packet); - job->destroy(job); - } - - sender->destroy(sender); - receiver->destroy(receiver); -} diff --git a/src/charon/testing/sender_test.h b/src/charon/testing/sender_test.h deleted file mode 100644 index 28e437f11..000000000 --- a/src/charon/testing/sender_test.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @file sender_test.h - * - * @brief Tests for the sender_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 . - * - * 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 SENDER_TEST_H_ -#define SENDER_TEST_H_ - -#include - -/** - * @brief Test function for the class sender_t. - * - * @param tester tester object - * - * @ingroup testcases - */ -void test_sender(protected_tester_t *tester); - -#endif /*SENDER_TEST_H_*/ diff --git a/src/charon/testing/socket_test.c b/src/charon/testing/socket_test.c deleted file mode 100644 index 0d264c976..000000000 --- a/src/charon/testing/socket_test.c +++ /dev/null @@ -1,84 +0,0 @@ -/** - * @file socket_test.c - * - * @brief Tests for the socket_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 . - * - * 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 -#include - -#include "socket_test.h" - -#include -#include - -/* - * Description in header file - */ -void test_socket(protected_tester_t *tester) -{ - int packet_count = 10; - int current; - socket_t *skt = socket_create(500, 4500); - packet_t *pkt = packet_create(); - char test_data[] = { - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, /* spi */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05, /* spi */ - 0x05, /* next payload */ - 0x20, /* IKE version */ - 0x00, /* exchange type */ - 0x00, /* flags */ - 0x00,0x00,0x00,0x01, /* message id */ - 0x00,0x00,0x00,0x24, /* length */ - 0x12,0x34,0x56,0x67, /* some data */ - 0x12,0x34,0x56,0x67, - }; - chunk_t data = chunk_from_buf(test_data); - chunk_t received; - - /* send to previously bound socket */ - pkt->set_destination(pkt, host_create(AF_INET, "127.0.0.1", 500)); - pkt->set_source(pkt, host_create(AF_INET, "127.0.0.1", 500)); - pkt->set_data(pkt, chunk_clone(data)); - - /* send packet_count packets */ - for (current = 0; current < packet_count; current++) - { - if (skt->send(skt, pkt) == FAILED) - { - tester->assert_true(tester, 0, "packet send"); - } - } - pkt->destroy(pkt); - - - /* receive packet_count packets */ - for (current = 0; current < packet_count; current++) - { - skt->receive(skt, &pkt); - received = pkt->get_data(pkt); - tester->assert_false(tester, memcmp(received.ptr, data.ptr, max(received.len, data.len)), "packet exchange"); - pkt->destroy(pkt); - } - - skt->destroy(skt); - -} diff --git a/src/charon/testing/socket_test.h b/src/charon/testing/socket_test.h deleted file mode 100644 index 40b68769b..000000000 --- a/src/charon/testing/socket_test.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @file socket_test.h - * - * @brief Tests for the socket_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 . - * - * 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 SOCKET_TEST_H_ -#define SOCKET_TEST_H_ - -#include - -/** - * @brief Test function for the class socket_t. - * - * @param tester tester object - * - * @ingroup testcases - */ -void test_socket(protected_tester_t *tester); - - -#endif /*SOCKET_TEST_H_*/ diff --git a/src/charon/testing/testcases.c b/src/charon/testing/testcases.c deleted file mode 100644 index 6b7273a89..000000000 --- a/src/charon/testing/testcases.c +++ /dev/null @@ -1,267 +0,0 @@ -/** - * @file tests.c - * - * @brief Main for all testcases. - * - */ - -/* - * 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 . - * - * 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 - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include "linked_list_test.h" -#include "thread_pool_test.h" -#include "job_queue_test.h" -#include "event_queue_test.h" -#include "send_queue_test.h" -#include "socket_test.h" -#include "sender_test.h" -#include "scheduler_test.h" -#include "ike_sa_id_test.h" -#include "ike_sa_test.h" -#include "ike_sa_manager_test.h" -#include "generator_test.h" -#include "parser_test.h" -#include "packet_test.h" -#include "diffie_hellman_test.h" -#include "hasher_test.h" -#include "hmac_test.h" -#include "prf_plus_test.h" -#include "aes_cbc_crypter_test.h" -#include "hmac_signer_test.h" -#include "encryption_payload_test.h" -#include "connection_test.h" -#include "policy_test.h" -#include "proposal_test.h" -#include "rsa_test.h" -#include "kernel_interface_test.h" -#include "child_sa_test.h" -#include "certificate_test.h" -#include "leak_detective_test.h" -#include "identification_test.h" - -/* output for test messages */ -extern FILE * stderr; - -test_t linked_list_test = {test_linked_list,"Linked List"}; -test_t iterator_test = {test_linked_list_iterator,"Linked List Iterator"}; -test_t linked_list_insert_and_remove_test = {test_linked_list_insert_and_remove,"Linked List Insert and remove"}; -test_t event_queue_test = {test_event_queue,"Event-Queue"}; -test_t job_queue_test1 = {test_job_queue,"Job-Queue"}; -test_t send_queue_test = {test_send_queue,"Send-Queue"}; -test_t socket_test = {test_socket,"Socket"}; -test_t thread_pool_test = {test_thread_pool,"Thread Pool"}; -test_t sender_test = {test_sender,"Sender"}; -test_t scheduler_test = {test_scheduler,"Scheduler"}; -test_t ike_sa_id_test = {test_ike_sa_id,"IKE_SA-Identifier"}; -test_t ike_sa_test = {test_ike_sa,"IKE_SA"}; -test_t ike_sa_manager_test = {test_ike_sa_manager, "IKE_SA-Manager"}; -test_t generator_test1 = {test_generator_with_header_payload,"Generator: header payload"}; -test_t generator_test2 = {test_generator_with_transform_attribute,"Generator: transform attribute"}; -test_t generator_test3 = {test_generator_with_transform_substructure,"Generator: transform substructure"}; -test_t generator_test4 = {test_generator_with_proposal_substructure,"Generator: proposal substructure"}; -test_t generator_test5 = {test_generator_with_sa_payload,"Generator: Message with SA Payload"}; -test_t generator_test6 = {test_generator_with_ke_payload,"Generator: KE Payload"}; -test_t generator_test7 = {test_generator_with_notify_payload,"Generator: Notify Payload"}; -test_t generator_test8 = {test_generator_with_nonce_payload,"Generator: Nonce Payload"}; -test_t generator_test9 = {test_generator_with_id_payload,"Generator: ID Payload"}; -test_t generator_test10 = {test_generator_with_auth_payload,"Generator: AUTH Payload"}; -test_t generator_test11 = {test_generator_with_ts_payload,"Generator: TS Payload"}; -test_t generator_test12 = {test_generator_with_cert_payload,"Generator: CERT Payload"}; -test_t generator_test13 = {test_generator_with_certreq_payload,"Generator: CERTREQ Payload"}; -test_t generator_test14 = {test_generator_with_delete_payload,"Generator: DELETE Payload"}; -test_t generator_test15 = {test_generator_with_vendor_id_payload,"Generator: VENDOR ID Payload"}; -test_t generator_test16 = {test_generator_with_cp_payload,"Generator: CP Payload"}; -test_t generator_test17 = {test_generator_with_eap_payload,"Generator: EAP Payload"}; -test_t parser_test1 = {test_parser_with_header_payload, "Parser: header payload"}; -test_t parser_test2 = {test_parser_with_sa_payload, "Parser: sa payload"}; -test_t parser_test3 = {test_parser_with_nonce_payload, "Parser: nonce payload"}; -test_t parser_test4 = {test_parser_with_ke_payload, "Parser: key exchange payload"}; -test_t parser_test5 = {test_parser_with_notify_payload, "Parser: notify payload"}; -test_t parser_test6 = {test_parser_with_id_payload, "Parser: ID payload"}; -test_t parser_test7 = {test_parser_with_auth_payload, "Parser: AUTH payload"}; -test_t parser_test8 = {test_parser_with_ts_payload, "Parser: TS payload"}; -test_t parser_test9 = {test_parser_with_cert_payload, "Parser: CERT payload"}; -test_t parser_test10 = {test_parser_with_certreq_payload, "Parser: CERTREQ payload"}; -test_t parser_test11 = {test_parser_with_delete_payload, "Parser: DELETE payload"}; -test_t parser_test12 = {test_parser_with_vendor_id_payload, "Parser: VENDOR ID payload"}; -test_t parser_test13 = {test_parser_with_cp_payload, "Parser: CP payload"}; -test_t parser_test14 = {test_parser_with_eap_payload, "Parser: EAP payload"}; -test_t packet_test = {test_packet,"Packet"}; -test_t diffie_hellman_test = {test_diffie_hellman,"Diffie Hellman"}; -test_t sha1_hasher_test = {test_sha1_hasher,"SHA1 hasher"}; -test_t md5_hasher_test = {test_md5_hasher,"MD5 hasher"}; -test_t hmac_test1 = {test_hmac_sha1, "HMAC using SHA1"}; -test_t hmac_test2 = {test_hmac_md5, "HMAC using MD5"}; -test_t prf_plus_test = {test_prf_plus, "prf+"}; -test_t aes_cbc_crypter_test = {test_aes_cbc_crypter, "AES CBC"}; -test_t hmac_signer_test1 = {test_hmac_md5_signer, "HMAC MD5 signer test"}; -test_t hmac_signer_test2 = {test_hmac_sha1_signer, "HMAC SHA1 signer test"}; -test_t encryption_payload_test = {test_encryption_payload, "encryption payload test"}; -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_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"}; -test_t identification_test = {test_identification, "identification"}; - - -daemon_t* charon; - -static void daemon_kill(daemon_t *this, char* none) -{ - //this->socket->destroy(this->socket); - this->ike_sa_manager->destroy(this->ike_sa_manager); - 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->destroy(this->configuration); - free(charon); -} - -/** - * @brief Create the dummy daemon for testing. - * - * @return created daemon_t - */ -daemon_t *daemon_create() -{ - charon = malloc_thing(daemon_t); - - /* assign methods */ - charon->kill = daemon_kill; - - 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(); - charon->send_queue = send_queue_create(); - //charon->kernel_interface = kernel_interface_create(); - //charon->configuration = configuration_create(RETRANSMIT_TIMEOUT,MAX_RETRANSMIT_COUNT,HALF_OPEN_IKE_SA_TIMEOUT); - charon->sender = NULL; - charon->receiver = NULL; - charon->scheduler = NULL; - charon->thread_pool = NULL; - - return charon; -} - - -int main() -{ - FILE * test_output = stderr; - - test_t *all_tests[] ={ - &linked_list_test, - &iterator_test, - &linked_list_insert_and_remove_test, - &thread_pool_test, - &job_queue_test1, - &event_queue_test, - &send_queue_test, - &scheduler_test, - &socket_test, - &sender_test, - &ike_sa_id_test, - &ike_sa_test, - &generator_test1, - &generator_test2, - &parser_test1, - &parser_test2, - &parser_test3, - &parser_test4, - &parser_test5, - &parser_test6, - &parser_test7, - &parser_test8, - &parser_test9, - &parser_test10, - &parser_test11, - &parser_test12, - &parser_test13, - &parser_test14, - &generator_test3, - &generator_test4, - &generator_test5, - &generator_test6, - &generator_test7, - &generator_test8, - &generator_test9, - &generator_test10, - &generator_test11, - &generator_test12, - &generator_test13, - &generator_test14, - &generator_test15, - &generator_test16, - &generator_test17, - &ike_sa_manager_test, - &packet_test, - &diffie_hellman_test, - &sha1_hasher_test, - &md5_hasher_test, - &hmac_test1, - &hmac_test2, - &prf_plus_test, - &aes_cbc_crypter_test, - &hmac_signer_test1, - &hmac_signer_test2, - &encryption_payload_test, - &connection_test, - &policy_test, - &proposal_test, - &rsa_test, - NULL - }; - /* get rid of compiler warning ;-) */ - *all_tests = *all_tests; - - daemon_create(); - - //logger_manager->enable_log_level(logger_manager, ALL_LOGGERS, FULL); - logger_manager->set_output(logger_manager, ALL_LOGGERS, stdout); - - tester_t *tester = tester_create(test_output, FALSE); - - //tester->perform_tests(tester,all_tests); - tester->perform_test(tester,&aes_cbc_crypter_test); - - - tester->destroy(tester); - - charon->kill(charon, NULL); - - return 0; -} diff --git a/src/charon/testing/thread_pool_test.c b/src/charon/testing/thread_pool_test.c deleted file mode 100644 index cf8709ddf..000000000 --- a/src/charon/testing/thread_pool_test.c +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @file thread_pool_test.c - * - * @brief Tests for the thread_pool_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 . - * - * 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 - -#include "thread_pool_test.h" - -#include - -/* - * Description in header file - */ -void test_thread_pool(protected_tester_t *tester) -{ - size_t desired_pool_size = 10; - size_t pool_size; - - thread_pool_t *pool = thread_pool_create(desired_pool_size); - pool_size = pool->get_pool_size(pool); - tester->assert_true(tester, (desired_pool_size == pool_size), "thread creation"); - pool->destroy(pool); -} diff --git a/src/charon/testing/thread_pool_test.h b/src/charon/testing/thread_pool_test.h deleted file mode 100644 index b960d4a70..000000000 --- a/src/charon/testing/thread_pool_test.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @file thread_pool_test.h - * - * @brief Tests for the thread_pool_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 . - * - * 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 THREAD_POOL_TEST_H_ -#define THREAD_POOL_TEST_H_ - -#include - -/** - * @brief Test function for the class thread_pool_t. - * - * @param tester tester object - * - * @ingroup testcases - */ -void test_thread_pool(protected_tester_t *tester); - -#endif /*THREAD_POOL_TEST_H_*/