aboutsummaryrefslogtreecommitdiffstats
path: root/Source/charon
diff options
context:
space:
mode:
Diffstat (limited to 'Source/charon')
-rw-r--r--Source/charon/Doxyfile220
-rw-r--r--Source/charon/Makefile100
-rw-r--r--Source/charon/Makefile.charon (renamed from Source/charon/transforms/prfs/Makefile.prfs)20
-rw-r--r--Source/charon/asn1/Makefile.asn124
-rw-r--r--Source/charon/asn1/asn1.c74
-rw-r--r--Source/charon/asn1/asn1.h172
-rw-r--r--Source/charon/asn1/der_decoder.c501
-rw-r--r--Source/charon/asn1/der_decoder.h79
-rw-r--r--Source/charon/asn1/der_encoder.c218
-rw-r--r--Source/charon/asn1/der_encoder.h60
-rw-r--r--Source/charon/charon-support.patch867
-rw-r--r--Source/charon/config/Makefile.config12
-rw-r--r--Source/charon/config/connection.h4
-rwxr-xr-xSource/charon/config/credential_store.h4
-rw-r--r--Source/charon/config/proposal.h8
-rw-r--r--Source/charon/config/traffic_selector.h2
-rw-r--r--Source/charon/daemon.h55
-rw-r--r--Source/charon/definitions.c40
-rw-r--r--Source/charon/definitions.h292
-rw-r--r--Source/charon/doc/Architecture.txt128
-rw-r--r--Source/charon/doc/Todo-list.txt41
-rw-r--r--Source/charon/encoding/Makefile.encoding8
-rw-r--r--Source/charon/encoding/message.h4
-rw-r--r--Source/charon/encoding/payloads/Makefile.payloads46
-rw-r--r--Source/charon/encoding/payloads/encryption_payload.c17
-rw-r--r--Source/charon/encoding/payloads/encryption_payload.h4
-rw-r--r--Source/charon/encoding/payloads/traffic_selector_substructure.h2
-rw-r--r--Source/charon/encoding/payloads/transform_substructure.h8
-rw-r--r--Source/charon/network/Makefile.network10
-rw-r--r--Source/charon/network/host.c365
-rw-r--r--Source/charon/network/host.h225
-rw-r--r--Source/charon/network/packet.h2
-rw-r--r--Source/charon/queues/Makefile.queues8
-rw-r--r--Source/charon/queues/jobs/Makefile.jobs12
-rw-r--r--Source/charon/sa/Makefile.sa12
-rw-r--r--Source/charon/sa/child_sa.h2
-rw-r--r--Source/charon/sa/ike_sa.c6
-rw-r--r--Source/charon/sa/ike_sa.h6
-rw-r--r--Source/charon/sa/states/Makefile.states14
-rw-r--r--Source/charon/sa/states/ike_auth_requested.c4
-rw-r--r--Source/charon/sa/states/ike_sa_init_requested.c2
-rw-r--r--Source/charon/sa/states/ike_sa_init_requested.h2
-rw-r--r--Source/charon/sa/states/ike_sa_init_responded.c4
-rw-r--r--Source/charon/sa/states/initiator_init.c25
-rw-r--r--Source/charon/sa/states/responder_init.c9
-rw-r--r--Source/charon/stroke.c304
-rw-r--r--Source/charon/stroke.h86
-rw-r--r--Source/charon/testcases/Makefile.testcases142
-rw-r--r--Source/charon/testcases/aes_cbc_crypter_test.c202
-rw-r--r--Source/charon/testcases/aes_cbc_crypter_test.h38
-rw-r--r--Source/charon/testcases/certificate_test.c95
-rw-r--r--Source/charon/testcases/certificate_test.h42
-rw-r--r--Source/charon/testcases/child_sa_test.c102
-rw-r--r--Source/charon/testcases/child_sa_test.h42
-rw-r--r--Source/charon/testcases/connection_test.c83
-rw-r--r--Source/charon/testcases/connection_test.h38
-rw-r--r--Source/charon/testcases/der_decoder_test.c140
-rw-r--r--Source/charon/testcases/der_decoder_test.h42
-rw-r--r--Source/charon/testcases/diffie_hellman_test.c76
-rw-r--r--Source/charon/testcases/diffie_hellman_test.h37
-rw-r--r--Source/charon/testcases/encryption_payload_test.c138
-rw-r--r--Source/charon/testcases/encryption_payload_test.h37
-rw-r--r--Source/charon/testcases/event_queue_test.c144
-rw-r--r--Source/charon/testcases/event_queue_test.h39
-rw-r--r--Source/charon/testcases/generator_test.c1411
-rw-r--r--Source/charon/testcases/generator_test.h183
-rw-r--r--Source/charon/testcases/hasher_test.c172
-rw-r--r--Source/charon/testcases/hasher_test.h49
-rw-r--r--Source/charon/testcases/hmac_signer_test.c204
-rw-r--r--Source/charon/testcases/hmac_signer_test.h46
-rw-r--r--Source/charon/testcases/hmac_test.c409
-rw-r--r--Source/charon/testcases/hmac_test.h49
-rw-r--r--Source/charon/testcases/ike_sa_id_test.c84
-rw-r--r--Source/charon/testcases/ike_sa_id_test.h40
-rw-r--r--Source/charon/testcases/ike_sa_manager_test.c185
-rw-r--r--Source/charon/testcases/ike_sa_manager_test.h39
-rw-r--r--Source/charon/testcases/ike_sa_test.c56
-rw-r--r--Source/charon/testcases/ike_sa_test.h37
-rw-r--r--Source/charon/testcases/job_queue_test.c133
-rw-r--r--Source/charon/testcases/job_queue_test.h40
-rw-r--r--Source/charon/testcases/kernel_interface_test.c85
-rw-r--r--Source/charon/testcases/kernel_interface_test.h38
-rw-r--r--Source/charon/testcases/linked_list_test.c241
-rw-r--r--Source/charon/testcases/linked_list_test.h74
-rw-r--r--Source/charon/testcases/packet_test.c56
-rw-r--r--Source/charon/testcases/packet_test.h37
-rw-r--r--Source/charon/testcases/parser_test.c964
-rw-r--r--Source/charon/testcases/parser_test.h170
-rw-r--r--Source/charon/testcases/policy_test.c247
-rw-r--r--Source/charon/testcases/policy_test.h42
-rw-r--r--Source/charon/testcases/prf_plus_test.c146
-rw-r--r--Source/charon/testcases/prf_plus_test.h38
-rw-r--r--Source/charon/testcases/proposal_test.c99
-rw-r--r--Source/charon/testcases/proposal_test.h42
-rw-r--r--Source/charon/testcases/receiver_test.c90
-rw-r--r--Source/charon/testcases/receiver_test.h37
-rw-r--r--Source/charon/testcases/rsa_test.c227
-rw-r--r--Source/charon/testcases/rsa_test.h41
-rw-r--r--Source/charon/testcases/scheduler_test.c92
-rw-r--r--Source/charon/testcases/scheduler_test.h37
-rw-r--r--Source/charon/testcases/send_queue_test.c142
-rw-r--r--Source/charon/testcases/send_queue_test.h40
-rw-r--r--Source/charon/testcases/sender_test.c80
-rw-r--r--Source/charon/testcases/sender_test.h37
-rw-r--r--Source/charon/testcases/socket_test.c73
-rw-r--r--Source/charon/testcases/socket_test.h38
-rw-r--r--Source/charon/testcases/testcases.c275
-rw-r--r--Source/charon/testcases/thread_pool_test.c41
-rw-r--r--Source/charon/testcases/thread_pool_test.h37
-rw-r--r--Source/charon/threads/Makefile.threads14
-rw-r--r--Source/charon/threads/kernel_interface.h2
-rwxr-xr-xSource/charon/threads/stroke_interface.c2
-rw-r--r--Source/charon/transforms/Makefile.transforms37
-rwxr-xr-xSource/charon/transforms/certificate.c230
-rwxr-xr-xSource/charon/transforms/certificate.h70
-rw-r--r--Source/charon/transforms/crypters/Makefile.crypters23
-rw-r--r--Source/charon/transforms/crypters/aes_cbc_crypter.c1628
-rw-r--r--Source/charon/transforms/crypters/aes_cbc_crypter.h61
-rw-r--r--Source/charon/transforms/crypters/crypter.c63
-rw-r--r--Source/charon/transforms/crypters/crypter.h153
-rw-r--r--Source/charon/transforms/diffie_hellman.c611
-rw-r--r--Source/charon/transforms/diffie_hellman.h149
-rw-r--r--Source/charon/transforms/hashers/Makefile.hashers27
-rw-r--r--Source/charon/transforms/hashers/hasher.c60
-rw-r--r--Source/charon/transforms/hashers/hasher.h147
-rw-r--r--Source/charon/transforms/hashers/md5_hasher.c393
-rw-r--r--Source/charon/transforms/hashers/md5_hasher.h60
-rw-r--r--Source/charon/transforms/hashers/sha1_hasher.c268
-rw-r--r--Source/charon/transforms/hashers/sha1_hasher.h60
-rw-r--r--Source/charon/transforms/hmac.c210
-rw-r--r--Source/charon/transforms/hmac.h118
-rw-r--r--Source/charon/transforms/prf_plus.c157
-rw-r--r--Source/charon/transforms/prf_plus.h93
-rw-r--r--Source/charon/transforms/prfs/hmac_prf.c118
-rw-r--r--Source/charon/transforms/prfs/hmac_prf.h64
-rw-r--r--Source/charon/transforms/prfs/prf.c67
-rw-r--r--Source/charon/transforms/prfs/prf.h136
-rw-r--r--Source/charon/transforms/rsa/Makefile.rsa23
-rw-r--r--Source/charon/transforms/rsa/rsa_private_key.c597
-rw-r--r--Source/charon/transforms/rsa/rsa_private_key.h185
-rw-r--r--Source/charon/transforms/rsa/rsa_public_key.c468
-rw-r--r--Source/charon/transforms/rsa/rsa_public_key.h153
-rw-r--r--Source/charon/transforms/signers/Makefile.signers23
-rw-r--r--Source/charon/transforms/signers/hmac_signer.c168
-rw-r--r--Source/charon/transforms/signers/hmac_signer.h58
-rw-r--r--Source/charon/transforms/signers/signer.c59
-rw-r--r--Source/charon/transforms/signers/signer.h147
-rw-r--r--Source/charon/types.c48
-rw-r--r--Source/charon/types.h155
-rw-r--r--Source/charon/utils/Makefile.utils44
-rw-r--r--Source/charon/utils/allocator.c445
-rw-r--r--Source/charon/utils/allocator.h324
-rw-r--r--Source/charon/utils/identification.c291
-rw-r--r--Source/charon/utils/identification.h211
-rw-r--r--Source/charon/utils/iterator.h153
-rw-r--r--Source/charon/utils/linked_list.c729
-rw-r--r--Source/charon/utils/linked_list.h203
-rw-r--r--Source/charon/utils/logger.c360
-rw-r--r--Source/charon/utils/logger.h199
-rw-r--r--Source/charon/utils/logger_manager.c212
-rw-r--r--Source/charon/utils/logger_manager.h155
-rw-r--r--Source/charon/utils/randomizer.c185
-rw-r--r--Source/charon/utils/randomizer.h122
-rw-r--r--Source/charon/utils/tester.c257
-rw-r--r--Source/charon/utils/tester.h148
165 files changed, 205 insertions, 23186 deletions
diff --git a/Source/charon/Doxyfile b/Source/charon/Doxyfile
deleted file mode 100644
index f9481b391..000000000
--- a/Source/charon/Doxyfile
+++ /dev/null
@@ -1,220 +0,0 @@
-# Doxyfile 1.4.1-KDevelop
-
-#---------------------------------------------------------------------------
-# Project related configuration options
-#---------------------------------------------------------------------------
-PROJECT_NAME = "charon - IKEv2 for strongSwan"
-PROJECT_NUMBER = 1.0
-OUTPUT_DIRECTORY = doc/api
-CREATE_SUBDIRS = NO
-OUTPUT_LANGUAGE = English
-USE_WINDOWS_ENCODING = NO
-BRIEF_MEMBER_DESC = YES
-REPEAT_BRIEF = YES
-ABBREVIATE_BRIEF =
-ALWAYS_DETAILED_SEC = NO
-INLINE_INHERITED_MEMB = NO
-FULL_PATH_NAMES = YES
-STRIP_FROM_PATH =
-STRIP_FROM_INC_PATH =
-SHORT_NAMES = NO
-JAVADOC_AUTOBRIEF = YES
-MULTILINE_CPP_IS_BRIEF = NO
-DETAILS_AT_TOP = YES
-INHERIT_DOCS = YES
-DISTRIBUTE_GROUP_DOC = NO
-TAB_SIZE = 1
-ALIASES =
-OPTIMIZE_OUTPUT_FOR_C = NO
-OPTIMIZE_OUTPUT_JAVA = NO
-SUBGROUPING = YES
-#---------------------------------------------------------------------------
-# Build related configuration options
-#---------------------------------------------------------------------------
-EXTRACT_ALL = NO
-EXTRACT_PRIVATE = NO
-EXTRACT_STATIC = NO
-EXTRACT_LOCAL_CLASSES = NO
-EXTRACT_LOCAL_METHODS = NO
-HIDE_UNDOC_MEMBERS = NO
-HIDE_UNDOC_CLASSES = NO
-HIDE_FRIEND_COMPOUNDS = NO
-HIDE_IN_BODY_DOCS = NO
-INTERNAL_DOCS = NO
-CASE_SENSE_NAMES = YES
-HIDE_SCOPE_NAMES = NO
-SHOW_INCLUDE_FILES = YES
-INLINE_INFO = YES
-SORT_MEMBER_DOCS = YES
-SORT_BRIEF_DOCS = NO
-SORT_BY_SCOPE_NAME = NO
-GENERATE_TODOLIST = YES
-GENERATE_TESTLIST = NO
-GENERATE_BUGLIST = YES
-GENERATE_DEPRECATEDLIST = YES
-ENABLED_SECTIONS =
-MAX_INITIALIZER_LINES = 30
-SHOW_USED_FILES = YES
-SHOW_DIRECTORIES = NO
-FILE_VERSION_FILTER =
-#---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
-#---------------------------------------------------------------------------
-QUIET = NO
-WARNINGS = YES
-WARN_IF_UNDOCUMENTED = YES
-WARN_IF_DOC_ERROR = YES
-WARN_NO_PARAMDOC = NO
-WARN_FORMAT = "$file:$line: $text"
-WARN_LOGFILE =
-#---------------------------------------------------------------------------
-# configuration options related to the input files
-#---------------------------------------------------------------------------
-INPUT = ./
-FILE_PATTERNS = *.h
-RECURSIVE = YES
-EXCLUDE =
-EXCLUDE_SYMLINKS = NO
-EXCLUDE_PATTERNS =
-EXAMPLE_PATH =
-EXAMPLE_PATTERNS =
-EXAMPLE_RECURSIVE = NO
-IMAGE_PATH =
-INPUT_FILTER =
-FILTER_PATTERNS =
-FILTER_SOURCE_FILES = NO
-#---------------------------------------------------------------------------
-# configuration options related to source browsing
-#---------------------------------------------------------------------------
-SOURCE_BROWSER = NO
-INLINE_SOURCES = NO
-STRIP_CODE_COMMENTS = YES
-REFERENCED_BY_RELATION = NO
-REFERENCES_RELATION = NO
-VERBATIM_HEADERS = YES
-#---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
-#---------------------------------------------------------------------------
-ALPHABETICAL_INDEX = NO
-COLS_IN_ALPHA_INDEX = 5
-IGNORE_PREFIX =
-#---------------------------------------------------------------------------
-# configuration options related to the HTML output
-#---------------------------------------------------------------------------
-GENERATE_HTML = YES
-HTML_OUTPUT = .
-HTML_FILE_EXTENSION = .html
-HTML_HEADER =
-HTML_FOOTER =
-HTML_STYLESHEET =
-HTML_ALIGN_MEMBERS = YES
-GENERATE_HTMLHELP = NO
-CHM_FILE =
-HHC_LOCATION =
-GENERATE_CHI = NO
-BINARY_TOC = NO
-TOC_EXPAND = NO
-DISABLE_INDEX = YES
-ENUM_VALUES_PER_LINE = 1
-GENERATE_TREEVIEW = YES
-TREEVIEW_WIDTH = 250
-#---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
-#---------------------------------------------------------------------------
-GENERATE_LATEX = NO
-LATEX_OUTPUT = latex
-LATEX_CMD_NAME = latex
-MAKEINDEX_CMD_NAME = makeindex
-COMPACT_LATEX = NO
-PAPER_TYPE = a4wide
-EXTRA_PACKAGES =
-LATEX_HEADER =
-PDF_HYPERLINKS = NO
-USE_PDFLATEX = NO
-LATEX_BATCHMODE = NO
-LATEX_HIDE_INDICES = NO
-#---------------------------------------------------------------------------
-# configuration options related to the RTF output
-#---------------------------------------------------------------------------
-GENERATE_RTF = NO
-RTF_OUTPUT = rtf
-COMPACT_RTF = NO
-RTF_HYPERLINKS = NO
-RTF_STYLESHEET_FILE =
-RTF_EXTENSIONS_FILE =
-#---------------------------------------------------------------------------
-# configuration options related to the man page output
-#---------------------------------------------------------------------------
-GENERATE_MAN = NO
-MAN_OUTPUT = man
-MAN_EXTENSION = .3
-MAN_LINKS = YES
-#---------------------------------------------------------------------------
-# configuration options related to the XML output
-#---------------------------------------------------------------------------
-GENERATE_XML = NO
-XML_OUTPUT = xml
-XML_SCHEMA =
-XML_DTD =
-XML_PROGRAMLISTING = YES
-#---------------------------------------------------------------------------
-# configuration options for the AutoGen Definitions output
-#---------------------------------------------------------------------------
-GENERATE_AUTOGEN_DEF = NO
-#---------------------------------------------------------------------------
-# configuration options related to the Perl module output
-#---------------------------------------------------------------------------
-GENERATE_PERLMOD = NO
-PERLMOD_LATEX = NO
-PERLMOD_PRETTY = YES
-PERLMOD_MAKEVAR_PREFIX =
-#---------------------------------------------------------------------------
-# Configuration options related to the preprocessor
-#---------------------------------------------------------------------------
-ENABLE_PREPROCESSING = YES
-MACRO_EXPANSION = YES
-EXPAND_ONLY_PREDEF = NO
-SEARCH_INCLUDES = YES
-INCLUDE_PATH =
-INCLUDE_FILE_PATTERNS =
-PREDEFINED = LEAK_DETECTIVE
-EXPAND_AS_DEFINED =
-SKIP_FUNCTION_MACROS = YES
-#---------------------------------------------------------------------------
-# Configuration::additions related to external references
-#---------------------------------------------------------------------------
-TAGFILES =
-GENERATE_TAGFILE =
-ALLEXTERNALS = NO
-EXTERNAL_GROUPS = YES
-PERL_PATH = /usr/bin/perl
-#---------------------------------------------------------------------------
-# Configuration options related to the dot tool
-#---------------------------------------------------------------------------
-CLASS_DIAGRAMS = YES
-HIDE_UNDOC_RELATIONS = YES
-HAVE_DOT = NO
-CLASS_GRAPH = YES
-COLLABORATION_GRAPH = YES
-GROUP_GRAPHS = YES
-UML_LOOK = NO
-TEMPLATE_RELATIONS = NO
-INCLUDE_GRAPH = YES
-INCLUDED_BY_GRAPH = YES
-CALL_GRAPH = NO
-GRAPHICAL_HIERARCHY = YES
-DIRECTORY_GRAPH = YES
-DOT_IMAGE_FORMAT = png
-DOT_PATH =
-DOTFILE_DIRS =
-MAX_DOT_GRAPH_WIDTH = 1024
-MAX_DOT_GRAPH_HEIGHT = 1024
-MAX_DOT_GRAPH_DEPTH = 0
-DOT_TRANSPARENT = NO
-DOT_MULTI_TARGETS = NO
-GENERATE_LEGEND = YES
-DOT_CLEANUP = YES
-#---------------------------------------------------------------------------
-# Configuration::additions related to the search engine
-#---------------------------------------------------------------------------
-SEARCHENGINE = NO
diff --git a/Source/charon/Makefile b/Source/charon/Makefile
deleted file mode 100644
index c4d65ca26..000000000
--- a/Source/charon/Makefile
+++ /dev/null
@@ -1,100 +0,0 @@
-# Copyright (C) 2005 Jan Hutter, Martin Willi
-# Hochschule fuer Technik Rapperswil
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the
-# Free Software Foundation; either version 2 of the License, or (at your
-# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# for more details.
-#
-
-FREESWANSRCDIR=../..
-# include strongswan Makefile, if charon sits in its tree
-ifeq ($(shell ls $(FREESWANSRCDIR)/Makefile.inc 2>&1), ../../Makefile.inc)
- include ${FREESWANSRCDIR}/Makefile.inc
-endif
-
-BUILD_DIR= ./bin/
-
-BINNAMECHARON= $(BUILD_DIR)charon
-BINNAMESTROKE= $(BUILD_DIR)stroke
-BINNAMETEST= $(BUILD_DIR)run_tests
-
-MAIN_DIR= ./
-
-LDFLAGS= -lgmp -lpthread
-
-CFLAGS+= -I. -O3#-Wall -g -DLEAK_DETECTIVE
-
-# objects is extended by each included Makefile
-OBJS=
-
-all : build_dir $(BINNAMECHARON) $(BINNAMESTROKE)
-
-programs : all
-
-test : build_dir $(BINNAMETEST)
- $(BINNAMETEST)
-
-apidoc :
- doxygen Doxyfile
-
-
-include $(MAIN_DIR)network/Makefile.network
-include $(MAIN_DIR)config/Makefile.config
-include $(MAIN_DIR)encoding/Makefile.encoding
-include $(MAIN_DIR)queues/Makefile.queues
-include $(MAIN_DIR)sa/Makefile.sa
-include $(MAIN_DIR)threads/Makefile.threads
-include $(MAIN_DIR)transforms/Makefile.transforms
-include $(MAIN_DIR)utils/Makefile.utils
-include $(MAIN_DIR)asn1/Makefile.asn1
-
-
-build_dir:
- mkdir -p $(BUILD_DIR)
-
-$(BUILD_DIR)daemon.o : daemon.c daemon.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-OBJS+=$(BUILD_DIR)types.o
-$(BUILD_DIR)types.o : types.c types.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-OBJS+=$(BUILD_DIR)definitions.o
-$(BUILD_DIR)definitions.o : definitions.c definitions.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-$(BINNAMECHARON) : $(OBJS) $(BUILD_DIR)daemon.o
- $(CC) $(LDFLAGS) $(OBJS) $(BUILD_DIR)daemon.o -o $@
-
-$(BINNAMESTROKE) : stroke.c
- $(CC) $(LDFLAGS) $(CFLAGS) stroke.c -o $@
-
-TEST_OBJS = $(OBJS)
-include $(MAIN_DIR)testcases/Makefile.testcases
-
-$(BUILD_DIR)run_tests : build_dir $(TEST_OBJS)
- $(CC) $(LDFLAGS) $(TEST_OBJS) -o $@
-
-install : $(BINNAMECHARON)
- $(INSTALL) $(INSTBINFLAGS) $(BINNAMECHARON) $(BINNAMESTROKE) $(LIBEXECDIR)
-
-install_file_list:
- @echo $(LIBEXECDIR)/charon
- @echo $(LIBEXECDIR)/stroke
-
-clean :
- rm -fR $(BUILD_DIR); rm -Rf doc/api
-
-cleanall: clean
-
-distclean: clean
-
-mostlyclean: clean
-
-realclean: clean
diff --git a/Source/charon/transforms/prfs/Makefile.prfs b/Source/charon/Makefile.charon
index 378d8bd0b..336495db9 100644
--- a/Source/charon/transforms/prfs/Makefile.prfs
+++ b/Source/charon/Makefile.charon
@@ -1,4 +1,4 @@
-# Copyright (C) 2005 Jan Hutter, Martin Willi
+# Copyright (C) 2006 Martin Willi
# Hochschule fuer Technik Rapperswil
#
# This program is free software; you can redistribute it and/or modify it
@@ -11,13 +11,15 @@
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
+CHARON_DIR= $(MAIN_DIR)charon/
-PRFS_DIR= $(TRANSFORMS_DIR)prfs/
-
-OBJS+= $(BUILD_DIR)prf.o
-$(BUILD_DIR)prf.o : $(PRFS_DIR)prf.c $(PRFS_DIR)prf.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-OBJS+= $(BUILD_DIR)hmac_prf.o
-$(BUILD_DIR)hmac_prf.o : $(PRFS_DIR)hmac_prf.c $(PRFS_DIR)hmac_prf.h
+$(BUILD_DIR)daemon.o : $(CHARON_DIR)daemon.c $(CHARON_DIR)daemon.h
$(CC) $(CFLAGS) -c -o $@ $<
+
+
+include $(CHARON_DIR)network/Makefile.network
+include $(CHARON_DIR)config/Makefile.config
+include $(CHARON_DIR)encoding/Makefile.encoding
+include $(CHARON_DIR)queues/Makefile.queues
+include $(CHARON_DIR)sa/Makefile.sa
+include $(CHARON_DIR)threads/Makefile.threads \ No newline at end of file
diff --git a/Source/charon/asn1/Makefile.asn1 b/Source/charon/asn1/Makefile.asn1
deleted file mode 100644
index 4aaedf4fe..000000000
--- a/Source/charon/asn1/Makefile.asn1
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright (C) 2005 Jan Hutter, Martin Willi
-# Hochschule fuer Technik Rapperswil
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the
-# Free Software Foundation; either version 2 of the License, or (at your
-# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# for more details.
-#
-
-ASN1_DIR= $(MAIN_DIR)asn1/
-
-
-OBJS+= $(BUILD_DIR)asn1.o
-$(BUILD_DIR)asn1.o : $(ASN1_DIR)asn1.c $(ASN1_DIR)asn1.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-OBJS+= $(BUILD_DIR)der_decoder.o
-$(BUILD_DIR)der_decoder.o : $(ASN1_DIR)der_decoder.c $(ASN1_DIR)der_decoder.h
- $(CC) $(CFLAGS) -c -o $@ $< \ No newline at end of file
diff --git a/Source/charon/asn1/asn1.c b/Source/charon/asn1/asn1.c
deleted file mode 100644
index 01952386c..000000000
--- a/Source/charon/asn1/asn1.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * @file asn1.c
- *
- * @brief String mappings for asn1.h
- *
- */
-
-/*
- * Copyright (C) 2006 Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "asn1.h"
-
-mapping_t asn1_type_m[] = {
- {ASN1_END, "ASN1_END"},
- {ASN1_BOOLEAN, "ASN1_BOOLEAN"},
- {ASN1_INTEGER, "ASN1_INTEGER"},
- {ASN1_BITSTRING, "ASN1_BITSTRING"},
- {ASN1_OCTETSTRING, "ASN1_OCTETSTRING"},
- {ASN1_NULL, "ASN1_NULL"},
- {ASN1_OID, "ASN1_OID"},
- {ASN1_ENUMERATED, "ASN1_ENUMERATED"},
- {ASN1_UTF8STRING, "ASN1_UTF8STRING"},
- {ASN1_NUMERICSTRING, "ASN1_NUMERICSTRING"},
- {ASN1_PRINTABLESTRING, "ASN1_PRINTABLESTRING"},
- {ASN1_T61STRING, "ASN1_T61STRING"},
- {ASN1_VIDEOTEXSTRING, "ASN1_VIDEOTEXSTRING"},
- {ASN1_IA5STRING, "ASN1_IA5STRING"},
- {ASN1_UTCTIME, "ASN1_UTCTIME"},
- {ASN1_GENERALIZEDTIME, "ASN1_GENERALIZEDTIME"},
- {ASN1_GRAPHICSTRING, "ASN1_GRAPHICSTRING"},
- {ASN1_VISIBLESTRING, "ASN1_VISIBLESTRING"},
- {ASN1_GENERALSTRING, "ASN1_GENERALSTRING"},
- {ASN1_UNIVERSALSTRING, "ASN1_UNIVERSALSTRING"},
- {ASN1_BMPSTRING, "ASN1_BMPSTRING"},
- {ASN1_CONSTRUCTED, "ASN1_CONSTRUCTED"},
- {ASN1_SEQUENCE, "ASN1_SEQUENCE"},
- {ASN1_SET, "ASN1_SET"},
- {ASN1_TAG_E_0, "ASN1_TAG_E_0"},
- {ASN1_TAG_E_1, "ASN1_TAG_E_1"},
- {ASN1_TAG_E_2, "ASN1_TAG_E_2"},
- {ASN1_TAG_E_3, "ASN1_TAG_E_3"},
- {ASN1_TAG_E_4, "ASN1_TAG_E_4"},
- {ASN1_TAG_E_5, "ASN1_TAG_E_5"},
- {ASN1_TAG_E_6, "ASN1_TAG_E_6"},
- {ASN1_TAG_E_7, "ASN1_TAG_E_7"},
- {ASN1_TAG_I_0, "ASN1_TAG_I_0"},
- {ASN1_TAG_I_1, "ASN1_TAG_I_1"},
- {ASN1_TAG_I_2, "ASN1_TAG_I_2"},
- {ASN1_TAG_I_3, "ASN1_TAG_I_3"},
- {ASN1_TAG_I_4, "ASN1_TAG_I_4"},
- {ASN1_TAG_I_5, "ASN1_TAG_I_5"},
- {ASN1_TAG_I_6, "ASN1_TAG_I_6"},
- {ASN1_TAG_I_7, "ASN1_TAG_I_7"},
- {ASN1_CHOICE, "ASN1_CHOICE"},
-};
-
-mapping_t asn1_flag_m[] = {
- {ASN1_OPTIONAL, "ASN1_OPTIONAL"},
- {ASN1_DEFAULT, "ASN1_DEFAULT"},
- {ASN1_MPZ, "ASN1_MPZ"},
- {ASN1_OF, "ASN1_OF"},
-};
diff --git a/Source/charon/asn1/asn1.h b/Source/charon/asn1/asn1.h
deleted file mode 100644
index 894f048d2..000000000
--- a/Source/charon/asn1/asn1.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/**
- * @file asn1.h
- *
- * @brief Definition of asn1_rule_t and other ASN1 stuff.
- *
- */
-
-/*
- * Copyright (C) 2006 Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef ASN1_H_
-#define ASN1_H_
-
-#include <types.h>
-
-typedef enum asn1_type_t asn1_type_t;
-
-/**
- * @brief Real and some special ASN1 types.
- *
- * @ingroup asn1
- */
-enum asn1_type_t {
- /**
- * End of a sequence, set, choice
- */
- ASN1_END = 0x00,
- ASN1_BOOLEAN = 0x01,
- ASN1_INTEGER = 0x02,
- ASN1_BITSTRING = 0x03,
- ASN1_OCTETSTRING = 0x04,
- ASN1_NULL = 0x05,
- ASN1_OID = 0x06,
- ASN1_ENUMERATED = 0x0A,
- ASN1_UTF8STRING = 0x0C,
- ASN1_NUMERICSTRING = 0x12,
- ASN1_PRINTABLESTRING = 0x13,
- ASN1_T61STRING = 0x14,
- ASN1_VIDEOTEXSTRING = 0x15,
- ASN1_IA5STRING = 0x16,
- ASN1_UTCTIME = 0x17,
- ASN1_GENERALIZEDTIME = 0x18,
- ASN1_GRAPHICSTRING = 0x19,
- ASN1_VISIBLESTRING = 0x1A,
- ASN1_GENERALSTRING = 0x1B,
- ASN1_UNIVERSALSTRING = 0x1C,
- ASN1_BMPSTRING = 0x1E,
- ASN1_CONSTRUCTED = 0x20,
- ASN1_SEQUENCE = 0x30,
- ASN1_SET = 0x31,
- /**
- * EXCPLICIT tags
- */
- ASN1_TAG_E_0 = 0xA0,
- ASN1_TAG_E_1 = 0xA1,
- ASN1_TAG_E_2 = 0xA2,
- ASN1_TAG_E_3 = 0xA3,
- ASN1_TAG_E_4 = 0xA4,
- ASN1_TAG_E_5 = 0xA5,
- ASN1_TAG_E_6 = 0xA6,
- ASN1_TAG_E_7 = 0xA7,
- /**
- * IMPLICIT tags
- */
- ASN1_TAG_I_0 = 0x80,
- ASN1_TAG_I_1 = 0x81,
- ASN1_TAG_I_2 = 0x82,
- ASN1_TAG_I_3 = 0x83,
- ASN1_TAG_I_4 = 0x84,
- ASN1_TAG_I_5 = 0x85,
- ASN1_TAG_I_6 = 0x86,
- ASN1_TAG_I_7 = 0x87,
- /**
- * Begin of a choice
- */
- ASN1_CHOICE = 0xFE,
- /**
- * ANY type
- */
- ASN1_ANY = 0xFF,
-};
-
-/**
- * String mappings for asn1_type_t
- */
-extern mapping_t asn1_type_m[];
-
-
-typedef enum asn1_flag_t asn1_flag_t;
-
-/**
- * @brief Flags used to build ASN1 rules.
- *
- * @ingroup asn1
- */
-enum asn1_flag_t {
- /**
- * Field is optional
- */
- ASN1_OPTIONAL = 0x01,
- /**
- * Field has a default value and is therefore optional
- */
- ASN1_DEFAULT = 0x02,
- /**
- * Convert this INTEGER to an mpz_t
- */
- ASN1_MPZ = 0x04,
- /**
- * SEQUENCE or SET OF
- */
- ASN1_OF = 0x08,
- /**
- * Parse this Sequence in a RAW chunk too.
- * Used for crypto calculations...
- */
- ASN1_RAW = 0x10,
-};
-
-/**
- * String mappings for asn1_flag_t
- */
-extern mapping_t asn1_flag_m[];
-
-
-typedef struct asn1_rule_t asn1_rule_t;
-
-/**
- * @brief Single rule of a complet ruleset.
- *
- * This rule containing a type, flags and additional
- * data allow modellation of complex ASN1 structures and
- * allow their en- and decoding...
- *
- * @ingroup asn1
- */
-struct asn1_rule_t {
- /**
- * ASN1 type
- */
- asn1_type_t type;
- /**
- * implicit or explicit tag, if any
- */
- asn1_flag_t flags;
- /**
- * offset of data in structure
- */
- u_int data_offset;
- /**
- * offset to a boolean, which says if optional
- * data is available at data_offset. Used if
- * flags & ASN1_OPTIONAL.
- * default value, used if flags & ASN1_DEFAULT
- */
- u_int additional;
-};
-
-
-#endif /* ASN1_H_ */
diff --git a/Source/charon/asn1/der_decoder.c b/Source/charon/asn1/der_decoder.c
deleted file mode 100644
index 9ded40f59..000000000
--- a/Source/charon/asn1/der_decoder.c
+++ /dev/null
@@ -1,501 +0,0 @@
-/**
- * @file der_decoder.c
- *
- * @brief Implementation of der_decoder_t.
- */
-
-/*
- * Copyright (C) 2000-2004 Andreas Steffen
- * Copyright (C) 2006 Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * Some parts taken over from pluto/asn1.c
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <gmp.h>
-
-#include "der_decoder.h"
-
-#include <utils/allocator.h>
-#include <daemon.h>
-
-
-
-typedef struct private_der_decoder_t private_der_decoder_t;
-
-/**
- * Private data of a der_decoder_t object.
- */
-struct private_der_decoder_t {
- /**
- * Public interface for this signer.
- */
- der_decoder_t public;
-
- /**
- * Rule which was just processed
- */
- asn1_rule_t *rule;
-
- /**
- * First rule of the whole ruleset
- */
- asn1_rule_t *first_rule;
-
- /**
- * Output data struct
- */
- void *output;
-
- /**
- * Complex things like this need a logger ;-)
- */
- logger_t *logger;
-};
-
-status_t read_hdr(private_der_decoder_t *this, chunk_t *data);
-
-/**
- * Read a sequence from data, parse its contents recursivly
- */
-status_t read_sequence(private_der_decoder_t *this, chunk_t data)
-{
- status_t status;
- asn1_rule_t *next_rule;
-
- while(TRUE)
- {
- next_rule = this->rule + 1;
- if (next_rule->type == ASN1_END)
- {
- this->rule++;
- break;
- }
- status = read_hdr(this, &data);
- if (status != SUCCESS)
- {
- return status;
- }
- }
-
- this->logger->log(this->logger, CONTROL|LEVEL2, "Sequence end");
- return SUCCESS;
-}
-
-/**
- * Read choice of data, parse if one of the choosable types arise
- */
-status_t read_choice(private_der_decoder_t *this, chunk_t *data)
-{
- status_t status = PARSE_ERROR;
- asn1_rule_t *next_rule;
- bool found = FALSE;
-
- this->logger->log_chunk(this->logger, CONTROL|LEVEL2, "Choice data", *data);
-
- while(TRUE)
- {
- next_rule = this->rule + 1;
- if (next_rule->type == ASN1_END)
- {
- this->rule++;
- return status;
- }
- if (!found && *(data->ptr) == next_rule->type)
- {
- found = TRUE;
- status = read_hdr(this, data);
- }
- else
- {
- this->rule++;
- }
- }
- this->logger->log(this->logger, CONTROL|LEVEL2, "Choice end");
- return status;
-}
-
-/**
- * Read a utc or generalized time
- */
-status_t read_time(private_der_decoder_t *this, chunk_t data)
-{
- struct tm t;
- time_t tz_offset;
- u_char *eot = NULL;
- const char* format;
- time_t *result = (time_t*)((u_int8_t*)this->output + this->rule->data_offset);
-
- /* TODO: Test it */
- this->logger->log_chunk(this->logger, CONTROL|LEVEL2, "TIME", data);
-
- if ((eot = memchr(data.ptr, 'Z', data.len)) != NULL)
- {
- /* Zulu time with a zero time zone offset */
- tz_offset = 0;
- }
- else if ((eot = memchr(data.ptr, '+', data.len)) != NULL)
- {
- int tz_hour, tz_min;
-
- sscanf(eot+1, "%2d%2d", &tz_hour, &tz_min);
- /* positive time zone offset */
- tz_offset = 3600*tz_hour + 60*tz_min;
- }
- else if ((eot = memchr(data.ptr, '-', data.len)) != NULL)
- {
- int tz_hour, tz_min;
-
- sscanf(eot+1, "%2d%2d", &tz_hour, &tz_min);
- /* negative time zone offset */
- tz_offset = -3600*tz_hour - 60*tz_min;
- }
- else
- {
- /* error in time format */
- return PARSE_ERROR;
- }
-
- if (this->rule->type == ASN1_UTCTIME)
- {
- format = "%2d%2d%2d%2d%2d";
- }
- else
- {
- format = "%4d%2d%2d%2d%2d";
- }
-
- sscanf(data.ptr, format, &t.tm_year, &t.tm_mon, &t.tm_mday, &t.tm_hour, &t.tm_min);
-
- /* is there a seconds field? */
- if ((eot - data.ptr) == ((this->rule->type == ASN1_UTCTIME)?12:14))
- {
- sscanf(eot-2, "%2d", &t.tm_sec);
- }
- else
- {
- t.tm_sec = 0;
- }
-
- /* representation of year */
- if (t.tm_year >= 1900)
- {
- t.tm_year -= 1900;
- }
- else if (t.tm_year >= 100)
- {
- return PARSE_ERROR;
- }
- else if (t.tm_year < 50)
- {
- t.tm_year += 100;
- }
-
- /* representation of month 0..11*/
- t.tm_mon--;
-
- /* set daylight saving time to off */
- t.tm_isdst = 0;
-
- /* compensate timezone */
-
- *result = mktime(&t) - timezone - tz_offset;
- return SUCCESS;
-}
-
-/**
- * Read an integer as u_int or as mpz_t
- */
-status_t read_int(private_der_decoder_t *this, chunk_t data)
-{
- this->logger->log_chunk(this->logger, CONTROL|LEVEL2, "ASN1_INTEGER", data);
-
- if (this->rule->flags & ASN1_MPZ)
- {
- mpz_t *mpz = (mpz_t*)((u_int8_t*)this->output + this->rule->data_offset);
- mpz_import(*mpz, data.len, 1, 1, 1, 0, data.ptr);
- }
- else
- {
- u_int *integ = (u_int*)((u_int8_t*)this->output + this->rule->data_offset);
-
- *integ = 0;
- while (data.len-- > 0)
- {
- *integ = 256 * (*integ) + *data.ptr++;
- }
- }
- return SUCCESS;
-}
-
-/**
- * Read boolean value
- */
-status_t read_bool(private_der_decoder_t *this, chunk_t data)
-{
- this->logger->log_chunk(this->logger, CONTROL|LEVEL2, "ASN1_BOOLEAN", data);
-
- bool *boolean = (u_int*)((u_int8_t*)this->output + this->rule->data_offset);
-
- *boolean = *data.ptr;
-
- return SUCCESS;
-}
-
-/**
- * Read an OID
- */
-status_t read_oid(private_der_decoder_t *this, chunk_t data)
-{
- this->logger->log_chunk(this->logger, CONTROL|LEVEL2, "ASN1_OID", data);
- /* TODO: OID parsing stuff */
- return SUCCESS;
-}
-
-/**
- * Read a bitstring
- */
-status_t read_bitstring(private_der_decoder_t *this, chunk_t data)
-{
- /* TODO: cleanly determine amount of unused bits */
-
- /* skip "unused-bits-in-following-byte"-byte */
- data.ptr += 1;
- data.len -= 1;
-
- if (data.len < 1)
- {
- return FAILED;
- }
-
- chunk_t *chunk = (chunk_t*)((u_int8_t*)this->output + this->rule->data_offset);
-
- *chunk = allocator_clone_chunk(data);
-
- this->logger->log_chunk(this->logger, CONTROL|LEVEL2, "ASN1_BITSTRING", data);
- return SUCCESS;
-}
-
-/**
- * Read any type which appears in a chunk
- */
-status_t read_any(private_der_decoder_t *this, chunk_t data)
-{
- chunk_t *chunk = (chunk_t*)((u_int8_t*)this->output + this->rule->data_offset);
-
- *chunk = allocator_clone_chunk(data);
-
- this->logger->log_chunk(this->logger, CONTROL|LEVEL2, "ASN1_ANY", data);
- return SUCCESS;
-}
-
-/**
- * Read the length field of a type
- */
-u_int32_t read_length(chunk_t *data)
-{
- u_int8_t n;
- size_t len;
-
- if (data->len < 1)
- {
- return -1;
- }
-
- /* read first octet of length field */
- n = *data->ptr;
- data->ptr++; data->len--;
-
- if ((n & 0x80) == 0)
- {
- /* single length octet */
- return n;
- }
-
- /* composite length, determine number of length octets */
- n &= 0x7f;
-
- if (n > data->len)
- {
- /* length longer than available bytes */
- return -1;
- }
-
- if (n > sizeof(len))
- {
- /* larger than size_t can hold */
- return -1;
- }
-
- len = 0;
- while (n-- > 0)
- {
- len = 256 * len + *data->ptr;
- data->ptr++; data->len--;
- }
- return len;
-}
-
-/**
- * Read the next field
- */
-status_t read_hdr(private_der_decoder_t *this, chunk_t *data)
-{
- chunk_t inner;
- /* TODO: Redo this that an average mid-european can understand it */
-
-beginning:
- /* advance to the next rule */
- this->rule++;
-
- this->logger->log(this->logger, CONTROL|LEVEL2, "reading rule %d %s",
- this->rule - this->first_rule,
- mapping_find(asn1_type_m, this->rule->type));
-
- switch (this->rule->type)
- {
- case ASN1_END:
- /* ignore, handled outside */
- return SUCCESS;
- case ASN1_CHOICE:
- /* CHOICE has no type/length */
- break;
- default:
- /* anything else has type/length */
- if (data->len == 0)
- {
- goto beginning;
- }
- this->logger->log_chunk(this->logger, CONTROL|LEVEL3, "reading from:", *data);
-
- /* read type, advance in data */
- if (this->rule->type != ASN1_ANY && *(data->ptr) != this->rule->type)
- {
- if (this->rule->flags & ASN1_OPTIONAL)
- {
- goto beginning;
- }
- if (this->rule->flags & ASN1_DEFAULT)
- {
- goto beginning;
- }
- this->logger->log(this->logger, CONTROL|LEVEL2, "Bad byte found: %x, %x expected",
- *data->ptr, this->rule->type);
- return PARSE_ERROR;
- }
- data->ptr++;
- data->len--;
-
- /* read length, advance in data */
- inner.len = read_length(data);
- if (inner.len == -1)
- {
- this->logger->log(this->logger, CONTROL|LEVEL2, "Error reading length");
- return PARSE_ERROR;
- }
- this->logger->log(this->logger, CONTROL|LEVEL2, "Length is %d", inner.len);
- inner.ptr = data->ptr;
-
- /* advance in data, at the size of the inner */
- data->ptr += inner.len;
- data->len -= inner.len;
- }
-
- /* process inner */
- while (TRUE)
- {
- switch (this->rule->type)
- {
- case ASN1_INTEGER:
- return read_int(this, inner);
- case ASN1_BOOLEAN:
- return read_bool(this, inner);
- case ASN1_SEQUENCE:
- case ASN1_SET:
- return read_sequence(this, inner);
- case ASN1_TAG_E_0:
- case ASN1_TAG_E_1:
- case ASN1_TAG_E_2:
- case ASN1_TAG_E_3:
- case ASN1_TAG_E_4:
- case ASN1_TAG_E_5:
- case ASN1_TAG_E_6:
- case ASN1_TAG_E_7:
- return read_hdr(this, &inner);
- case ASN1_TAG_I_0:
- case ASN1_TAG_I_1:
- case ASN1_TAG_I_2:
- case ASN1_TAG_I_3:
- case ASN1_TAG_I_4:
- case ASN1_TAG_I_5:
- case ASN1_TAG_I_6:
- case ASN1_TAG_I_7:
- this->rule++;
- continue;
- case ASN1_OID:
- return read_oid(this, inner);
- case ASN1_CHOICE:
- return read_choice(this, data);
- case ASN1_NULL:
- return SUCCESS;
- case ASN1_ANY:
- return read_any(this, inner);
- case ASN1_UTCTIME:
- return read_time(this, inner);
- case ASN1_GENERALIZEDTIME:
- return read_time(this, inner);
- case ASN1_BITSTRING:
- return read_bitstring(this, inner);
- case ASN1_OCTETSTRING:
- return read_any(this, inner);
- default:
- return NOT_SUPPORTED;
- }
- }
-}
-
-/**
- * Implements der_decoder_t.decode
- */
-status_t decode(private_der_decoder_t *this, chunk_t input, void *output)
-{
- this->rule = this->first_rule - 1;
- this->output = output;
- /* start parsing recursivly */
- return read_hdr(this, &input);
-}
-
-/**
- * Implementation of der_decoder.destroy.
- */
-static void destroy(private_der_decoder_t *this)
-{
- allocator_free(this);
-}
-
-/*
- * Described in header.
- */
-der_decoder_t *der_decoder_create(asn1_rule_t *rules)
-{
- private_der_decoder_t *this = allocator_alloc_thing(private_der_decoder_t);
-
- /* public functions */
- this->public.decode = (status_t (*) (der_decoder_t*,chunk_t,void*))decode;
- this->public.destroy = (void (*) (der_decoder_t*))destroy;
-
- this->first_rule = rules;
- this->logger = charon->logger_manager->get_logger(charon->logger_manager, DER_DECODER);
-
- return &(this->public);
-}
diff --git a/Source/charon/asn1/der_decoder.h b/Source/charon/asn1/der_decoder.h
deleted file mode 100644
index 68731b5d9..000000000
--- a/Source/charon/asn1/der_decoder.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * @file der_decoder.h
- *
- * @brief Interface of der_decoder_t.
- *
- */
-
-/*
- * Copyright (C) 2006 Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef DER_DECODER_H_
-#define DER_DECODER_H_
-
-#include <types.h>
-#include <asn1/asn1.h>
-
-typedef struct der_decoder_t der_decoder_t;
-
-/**
- * @brief Decode ASN1 DER encoded chunks.
- *
- * @b Constructors:
- * - der_decoder_create()
- *
- * @todo A lot.
- *
- * @ingroup asn1
- */
-struct der_decoder_t {
-
- /**
- * @brief Decode a chunk of bytes to a data structure
- *
- * @param der_decoder calling object
- * @param input chunk of data to decode
- * @param output data structure where decoded data is written
- * @return
- * - PARSE_ERROR
- * - FAILED
- * - NOT_SUPPORTED
- * - or SUCCESS sometimes
- */
- status_t (*decode) (der_decoder_t *this, chunk_t input, void *output);
-
- /**
- * @brief Destroys a der_decoder object.
- *
- * @param der_decoder calling object
- */
- void (*destroy) (der_decoder_t *this);
-};
-
-
-/**
- * @brief Create a der_decoder instance.
- *
- * The instance needs ASN1 rules to know how to decode
- * data...
- *
- * @param rules set of ASN1 coding rules
- * @return der_decoder_t object
- *
- * @ingroup ans1
- */
-der_decoder_t * der_decoder_create(asn1_rule_t* rules);
-
-#endif /* DER_DECODER_H_ */
diff --git a/Source/charon/asn1/der_encoder.c b/Source/charon/asn1/der_encoder.c
deleted file mode 100644
index 669a140ed..000000000
--- a/Source/charon/asn1/der_encoder.c
+++ /dev/null
@@ -1,218 +0,0 @@
-/**
- * @file der_encoder.c
- *
- * @brief Implementation of der_encoder_t.
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <gmp.h>
-
-#include "der_encoder.h"
-
-#include <utils/allocator.h>
-#include <daemon.h>
-
-
-
-typedef struct private_der_encoder_t private_der_encoder_t;
-
-/**
- * Private data of a der_encoder_t object.
- */
-struct private_der_encoder_t {
- /**
- * Public interface for this signer.
- */
- der_encoder_t public;
-
- asn1_rule_t *rule;
-
- asn1_rule_t *first_rule;
-
- void *output;
-
- logger_t *logger;
-};
-
-status_t read_hdr(private_der_encoder_t *this, chunk_t *data);
-
-status_t read_sequence(private_der_encoder_t *this, chunk_t data)
-{
- while (this->rule->type != ASN1_END)
- {
- read_hdr(this, &data);
- }
- return SUCCESS;
-}
-
-
-status_t read_int(private_der_encoder_t *this, chunk_t data)
-{
- this->logger->log_chunk(this->logger, CONTROL|LEVEL2, "ASN1_INTEGER", data);
- u_int *integ = (u_int*)((u_int8_t*)this->output + this->rule->data_offset);
-
- *integ = 0;
- while (data.len-- > 0)
- {
- *integ = 256 * (*integ) + *data.ptr++;
- }
- return SUCCESS;
-}
-
-status_t read_mpz(private_der_encoder_t *this, chunk_t data)
-{
- this->logger->log_chunk(this->logger, CONTROL|LEVEL2, "ASN1_INTEGER as mpz", data);
- mpz_t *mpz = (mpz_t*)((u_int8_t*)this->output + this->rule->data_offset);
-
- mpz_import(*mpz, data.len, 1, 1, 1, 0, data.ptr);
- return SUCCESS;
-}
-
-u_int32_t read_length(chunk_t *data)
-{
- u_int8_t n;
- size_t len;
-
- /* read first octet of length field */
- n = *data->ptr++;
-
- if ((n & 0x80) == 0)
- {
- /* single length octet */
- return n;
- }
-
- /* composite length, determine number of length octets */
- n &= 0x7f;
-
- if (n > data->len)
- {
- /* length longer than available bytes */
- return -1;
- }
-
- if (n > sizeof(len))
- {
- /* larger than size_t can hold */
- return -1;
- }
-
- len = 0;
- while (n-- > 0)
- {
- len = 256 * len + *data->ptr++;
- }
- return len;
-}
-
-status_t read_hdr(private_der_encoder_t *this, chunk_t *data)
-{
- chunk_t inner;
-
- /* advance to the next rule */
- this->rule++;
-
- if (this->rule->type == ASN1_END)
- {
- return SUCCESS;
- }
-
- this->logger->log(this->logger, CONTROL|LEVEL2, "reading header of rule %s",
- mapping_find(asn1_type_m, this->rule->type));
-
- this->logger->log_chunk(this->logger, CONTROL|LEVEL2, "reading from:", *data);
-
- /* read type, advance in data */
- if (*(data->ptr) != this->rule->type)
- {
- this->logger->log(this->logger, CONTROL|LEVEL2, "Bad byte found (%x)", *data->ptr);
- return PARSE_ERROR;
- }
- data->ptr++;
- data->len--;
-
- /* read length, advance in data */
- inner.len = read_length(data);
- if (inner.len == -1)
- {
- this->logger->log(this->logger, CONTROL|LEVEL2, "Error reading length");
- return PARSE_ERROR;
- }
- this->logger->log(this->logger, CONTROL|LEVEL2, "Length is %d",
- inner.len);
- inner.ptr = data->ptr;
-
- /* advance in data */
- data->ptr += inner.len;
- data->len -= inner.len;
-
- /* process inner */
- switch (this->rule->type)
- {
- case ASN1_INTEGER:
- if (this->rule->flags & ASN1_MPZ)
- {
- read_mpz(this, inner);
- }
- else
- {
- read_int(this, inner);
- }
- break;
- case ASN1_SEQUENCE:
- read_sequence(this, inner);
- break;
- default:
- break;
- }
-
- return SUCCESS;
-}
-
-
-
-status_t decode(private_der_encoder_t *this, chunk_t input, void *output)
-{
- this->rule = this->first_rule - 1;
- this->output = output;
- return read_hdr(this, &input);
-}
-
-/**
- * Implementation of der_encoder.destroy.
- */
-static void destroy(private_der_encoder_t *this)
-{
- allocator_free(this);
-}
-
-/*
- * Described in header.
- */
-der_encoder_t *der_encoder_create(asn1_rule_t *rules)
-{
- private_der_encoder_t *this = allocator_alloc_thing(private_der_encoder_t);
-
- /* public functions */
- this->public.decode = (status_t (*) (der_encoder_t*,chunk_t,void*))decode;
- this->public.destroy = (void (*) (der_encoder_t*))destroy;
-
- this->first_rule = rules;
- this->logger = charon->logger_manager->get_logger(charon->logger_manager, DER_DECODER);
-
- return &(this->public);
-}
diff --git a/Source/charon/asn1/der_encoder.h b/Source/charon/asn1/der_encoder.h
deleted file mode 100644
index ee4443eb8..000000000
--- a/Source/charon/asn1/der_encoder.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * @file der_encoder.h
- *
- * @brief Interface of der_encoder_t.
- *
- */
-
-/*
- * Copyright (C) 2006 Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef DER_ENCODER_H_
-#define DER_ENCODER_H_
-
-#include <types.h>
-
-typedef struct der_encoder_t der_encoder_t;
-
-/**
- * @brief Decode der_encoded bytes to usable structures.
- *
- * @b Constructors:
- * - der_encoder_create()
- *
- * @ingroup asn1
- */
-struct der_encoder_t {
-
- status_t encode(der_encoder_t *this, void *input, chunk_t output);
-
- /**
- * @brief Destroys a der_encoder object.
- *
- * @param der_encoder calling object
- */
- void (*destroy) (der_encoder_t *this);
-};
-
-
-/**
- * @brief Create a der_encoder instance.
- *
- * @return der_encoder_t object
- *
- * @ingroup ans1
- */
-der_encoder_t * der_encoder_create(asn1_rule_t *rules);
-
-#endif /* DER_ENCODER_H_ */
diff --git a/Source/charon/charon-support.patch b/Source/charon/charon-support.patch
deleted file mode 100644
index 20004d42f..000000000
--- a/Source/charon/charon-support.patch
+++ /dev/null
@@ -1,867 +0,0 @@
-diff -Naur strongswan-2.6.3/Makefile.inc strongswan-2.6.3-charon/Makefile.inc
---- strongswan-2.6.3/Makefile.inc 2006-01-25 18:23:15.000000000 +0100
-+++ strongswan-2.6.3-charon/Makefile.inc 2006-03-21 09:26:23.000000000 +0100
-@@ -284,6 +284,9 @@
- # include PKCS11-based smartcard support
- USE_SMARTCARD?=false
-
-+# support IKEv2 via charon
-+USE_IKEV2?=true
-+
- # Default PKCS11 library
- # Uncomment this line if using OpenSC <= 0.9.6
- PKCS11_DEFAULT_LIB=\"/usr/lib/pkcs11/opensc-pkcs11.so\"
-diff -Naur strongswan-2.6.3/programs/Makefile strongswan-2.6.3-charon/programs/Makefile
---- strongswan-2.6.3/programs/Makefile 2006-01-01 16:14:08.000000000 +0100
-+++ strongswan-2.6.3-charon/programs/Makefile 2006-03-21 09:26:23.000000000 +0100
-@@ -32,6 +32,10 @@
- SUBDIRS+=showpolicy
- endif
-
-+ifeq ($(USE_IKEV2),true)
-+SUBDIRS+=charon
-+endif
-+
- def:
- @echo "Please read doc/intro.html or INSTALL before running make"
- @false
-diff -Naur strongswan-2.6.3/programs/ipsec/ipsec.in strongswan-2.6.3-charon/programs/ipsec/ipsec.in
---- strongswan-2.6.3/programs/ipsec/ipsec.in 2006-03-09 21:09:33.000000000 +0100
-+++ strongswan-2.6.3-charon/programs/ipsec/ipsec.in 2006-03-21 09:49:10.000000000 +0100
-@@ -123,6 +123,10 @@
- down)
- shift
- $IPSEC_EXECDIR/whack --name "$1" --terminate
-+ if test -e $IPSEC_EXECDIR/stroke
-+ then
-+ $IPSEC_EXECDIR/stroke --name "$1" --terminate
-+ fi
- exit 0
- ;;
- listalgs|listpubkeys|listcerts|listcacerts|\
-@@ -134,11 +138,19 @@
- op="$1"
- shift
- $IPSEC_EXECDIR/whack "$@" "--$op"
-+ if test -e $IPSEC_EXECDIR/stroke
-+ then
-+ $IPSEC_EXECDIR/stroke "$@" "--$op"
-+ fi
- exit 0
- ;;
- ready)
- shift
- $IPSEC_EXECDIR/whack --listen
-+ if test -e $IPSEC_EXECDIR/stroke
-+ then
-+ $IPSEC_EXECDIR/stroke --listen
-+ fi
- exit 0
- ;;
- reload)
-@@ -180,8 +192,16 @@
- if test $# -eq 0
- then
- $IPSEC_EXECDIR/whack "--$op"
-+ if test -e $IPSEC_EXECDIR/stroke
-+ then
-+ $IPSEC_EXECDIR/stroke "--$op"
-+ fi
- else
- $IPSEC_EXECDIR/whack --name "$1" "--$op"
-+ if test -e $IPSEC_EXECDIR/stroke
-+ then
-+ $IPSEC_EXECDIR/stroke --name "$1" "--$op"
-+ fi
- fi
- exit 0
- ;;
-diff -Naur strongswan-2.6.3/programs/pluto/Makefile strongswan-2.6.3-charon/programs/pluto/Makefile
---- strongswan-2.6.3/programs/pluto/Makefile 2006-01-25 18:22:19.000000000 +0100
-+++ strongswan-2.6.3-charon/programs/pluto/Makefile 2006-03-21 10:00:41.000000000 +0100
-@@ -170,6 +170,11 @@
- LIBSPLUTO+= -ldl
- endif
-
-+# enable IKEv2 support
-+ifeq ($(USE_IKEV2),true)
-+ DEFINES+= -DIKEV2
-+endif
-+
- # This compile option activates the leak detective
- ifeq ($(USE_LEAK_DETECTIVE),true)
- DEFINES+= -DLEAK_DETECTIVE
-diff -Naur strongswan-2.6.3/programs/pluto/demux.c strongswan-2.6.3-charon/programs/pluto/demux.c
---- strongswan-2.6.3/programs/pluto/demux.c 2005-02-18 22:08:59.000000000 +0100
-+++ strongswan-2.6.3-charon/programs/pluto/demux.c 2006-03-21 09:26:24.000000000 +0100
-@@ -1229,6 +1229,15 @@
- if (md->packet_pbs.roof - md->packet_pbs.cur >= (ptrdiff_t)isakmp_hdr_desc.size)
- {
- struct isakmp_hdr *hdr = (struct isakmp_hdr *)md->packet_pbs.cur;
-+#ifdef IKEV2
-+ if ((hdr->isa_version >> ISA_MAJ_SHIFT) == 0x2 &&
-+ (hdr->isa_version & ISA_MIN_MASK) == 0x0)
-+ {
-+ /* IKEv2 is handled from charon, ignore */
-+ return;
-+ }
-+ else
-+#endif /* IKEV2 */
- if ((hdr->isa_version >> ISA_MAJ_SHIFT) != ISAKMP_MAJOR_VERSION)
- {
- SEND_NOTIFICATION(INVALID_MAJOR_VERSION);
-diff -Naur strongswan-2.6.3/programs/starter/Makefile strongswan-2.6.3-charon/programs/starter/Makefile
---- strongswan-2.6.3/programs/starter/Makefile 2006-02-17 20:34:02.000000000 +0100
-+++ strongswan-2.6.3-charon/programs/starter/Makefile 2006-03-21 09:26:24.000000000 +0100
-@@ -34,6 +34,11 @@
- DEFINES+= -DLEAK_DETECTIVE
- endif
-
-+# Enable charon support
-+ifeq ($(USE_IKEV2),true)
-+ DEFINES+= -DIKEV2
-+endif
-+
- INCLUDES=-I${FREESWANDIR}/linux/include
- CFLAGS=$(DEFINES) $(INCLUDES) -Wall
- CFLAGS+=-DIPSEC_EXECDIR=\"${FINALLIBEXECDIR}\" -DIPSEC_CONFDDIR=\"${FINALCONFDDIR}\"
-@@ -46,6 +51,11 @@
- starterwhack.o klips.o netkey.o interfaces.o exec.o cmp.o confread.o \
- loglite.o ${PLUTO_OBJS}
-
-+# Build charon-only objs
-+ifeq ($(USE_IKEV2),true)
-+ OBJS+= invokecharon.o starterstroke.o
-+endif
-+
- DISTSRC=$(OBJS:.o=.c)
- DISTSRC+=cmp.h confread.h confwrite.h exec.h files.h interfaces.h klips.h netkey.h
- DISTSRC+=parser.h args.h invokepluto.h starterwhack.h keywords.h keywords.txt
-diff -Naur strongswan-2.6.3/programs/starter/args.c strongswan-2.6.3-charon/programs/starter/args.c
---- strongswan-2.6.3/programs/starter/args.c 2006-03-10 21:37:10.000000000 +0100
-+++ strongswan-2.6.3-charon/programs/starter/args.c 2006-03-21 09:26:24.000000000 +0100
-@@ -86,6 +86,10 @@
-
- static const char *LST_keyexchange[] = {
- "ike",
-+#ifdef IKEV2
-+ "ikev1",
-+ "ikev2",
-+#endif /* IKEV2 */
- NULL
- };
-
-diff -Naur strongswan-2.6.3/programs/starter/files.h strongswan-2.6.3-charon/programs/starter/files.h
---- strongswan-2.6.3/programs/starter/files.h 2006-02-04 19:52:58.000000000 +0100
-+++ strongswan-2.6.3-charon/programs/starter/files.h 2006-03-21 09:26:24.000000000 +0100
-@@ -37,8 +37,15 @@
- #define SECRETS_FILE IPSEC_CONFDIR"/ipsec.secrets"
-
- #define PLUTO_CMD IPSEC_EXECDIR"/pluto"
--#define CTL_FILE DEFAULT_CTLBASE CTL_SUFFIX
--#define PID_FILE DEFAULT_CTLBASE PID_SUFFIX
-+#define PLUTO_CTL_FILE DEFAULT_CTLBASE CTL_SUFFIX
-+#define PLUTO_PID_FILE DEFAULT_CTLBASE PID_SUFFIX
-+
-+#ifdef IKEV2
-+#define CHARON_CMD IPSEC_EXECDIR"/charon"
-+#define CHARON_BASE "/var/run/charon"
-+#define CHARON_CTL_FILE CHARON_BASE CTL_SUFFIX
-+#define CHARON_PID_FILE CHARON_BASE PID_SUFFIX
-+#endif /* IKEV2 */
-
- #define DYNIP_DIR "/var/run/dynip"
- #define INFO_FILE "/var/run/ipsec.info"
-diff -Naur strongswan-2.6.3/programs/starter/invokecharon.c strongswan-2.6.3-charon/programs/starter/invokecharon.c
---- strongswan-2.6.3/programs/starter/invokecharon.c 1970-01-01 01:00:00.000000000 +0100
-+++ strongswan-2.6.3-charon/programs/starter/invokecharon.c 2006-03-21 09:26:24.000000000 +0100
-@@ -0,0 +1,168 @@
-+/* strongSwan charon launcher
-+ * Copyright (C) 2001-2002 Mathieu Lafon - Arkoon Network Security
-+ * Copyright (C) 2006 Martin Willi - Hochschule fuer Technik Rapperswil
-+ *
-+ * Ported from invokepluto.c to fit charons needs.
-+ *
-+ * This program is free software; you can redistribute it and/or modify it
-+ * under the terms of the GNU General Public License as published by the
-+ * Free Software Foundation; either version 2 of the License, or (at your
-+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
-+ *
-+ * This program is distributed in the hope that it will be useful, but
-+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-+ * for more details.
-+ *
-+ * RCSID $Id: invokecharon.c $
-+ */
-+
-+#include <sys/types.h>
-+#include <sys/stat.h>
-+#include <unistd.h>
-+#include <signal.h>
-+#include <string.h>
-+#include <stdlib.h>
-+#include <errno.h>
-+
-+#include <freeswan.h>
-+
-+#include "../pluto/constants.h"
-+#include "../pluto/defs.h"
-+#include "../pluto/log.h"
-+
-+#include "confread.h"
-+#include "invokecharon.h"
-+#include "files.h"
-+
-+static int _charon_pid = 0;
-+static int _stop_requested;
-+
-+pid_t
-+starter_charon_pid(void)
-+{
-+ return _charon_pid;
-+}
-+
-+void
-+starter_charon_sigchild(pid_t pid)
-+{
-+ if (pid == _charon_pid)
-+ {
-+ _charon_pid = 0;
-+ if (!_stop_requested)
-+ {
-+ plog("charon has died -- restart scheduled (%dsec)"
-+ , CHARON_RESTART_DELAY);
-+ alarm(CHARON_RESTART_DELAY); // restart in 5 sec
-+ }
-+ unlink(CHARON_PID_FILE);
-+ }
-+}
-+
-+int
-+starter_stop_charon (void)
-+{
-+ pid_t pid;
-+ int i;
-+
-+ pid = _charon_pid;
-+ if (pid)
-+ {
-+ _stop_requested = 1;
-+
-+ /* be more and more aggressive */
-+ for (i = 0; i < 20 && (pid = _charon_pid) != 0; i++)
-+ {
-+ if (i == 0)
-+ kill(pid, SIGINT);
-+ else if (i < 10)
-+ kill(pid, SIGTERM);
-+ else
-+ kill(pid, SIGKILL);
-+ usleep(20000);
-+ }
-+ if (_charon_pid == 0)
-+ return 0;
-+ plog("starter_stop_charon(): can't stop charon !!!");
-+ return -1;
-+ }
-+ else
-+ {
-+ plog("stater_stop_charon(): charon is not started...");
-+ }
-+ return -1;
-+}
-+
-+
-+int
-+starter_start_charon (starter_config_t *cfg, bool debug)
-+{
-+ int pid, i;
-+ struct stat stb;
-+ char *arg[] = {
-+ CHARON_CMD, NULL
-+ };
-+
-+ if (_charon_pid)
-+ {
-+ plog("starter_start_charon(): charon already started...");
-+ return -1;
-+ }
-+ else
-+ {
-+ unlink(CHARON_CTL_FILE);
-+ _stop_requested = 0;
-+
-+ pid = fork();
-+ switch (pid)
-+ {
-+ case -1:
-+ plog("can't fork(): %s", strerror(errno));
-+ return -1;
-+ case 0:
-+ /* child */
-+ setsid();
-+ sigprocmask(SIG_SETMASK, 0, NULL);
-+ execv(arg[0], arg);
-+ plog("can't execv(%s,...): %s", arg[0], strerror(errno));
-+ exit(1);
-+ default:
-+ /* father */
-+ _charon_pid = pid;
-+ for (i = 0; i < 50 && _charon_pid; i++)
-+ {
-+ /* wait for charon */
-+ usleep(20000);
-+ if (stat(CHARON_PID_FILE, &stb) == 0)
-+ {
-+ DBG(DBG_CONTROL,
-+ DBG_log("charon (%d) started", _charon_pid)
-+ )
-+ return 0;
-+ }
-+ }
-+ if (_charon_pid)
-+ {
-+ /* If charon is started but with no ctl file, stop it */
-+ plog("charon too long to start... - kill kill");
-+ for (i = 0; i < 20 && (pid = _charon_pid) != 0; i++)
-+ {
-+ if (i == 0)
-+ kill(pid, SIGINT);
-+ else if (i < 10)
-+ kill(pid, SIGTERM);
-+ else
-+ kill(pid, SIGKILL);
-+ usleep(20000);
-+ }
-+ }
-+ else
-+ {
-+ plog("charon refused to be started");
-+ }
-+ return -1;
-+ }
-+ }
-+ return -1;
-+}
-diff -Naur strongswan-2.6.3/programs/starter/invokecharon.h strongswan-2.6.3-charon/programs/starter/invokecharon.h
---- strongswan-2.6.3/programs/starter/invokecharon.h 1970-01-01 01:00:00.000000000 +0100
-+++ strongswan-2.6.3-charon/programs/starter/invokecharon.h 2006-03-21 09:26:24.000000000 +0100
-@@ -0,0 +1,31 @@
-+/* strongSwan charon launcher
-+ * Copyright (C) 2001-2002 Mathieu Lafon - Arkoon Network Security
-+ * Copyright (C) 2006 Martin Willi - Hochschule fuer Technik Rapperswil
-+ *
-+ * Ported from invokepluto.h to fit charons needs.
-+ *
-+ * This program is free software; you can redistribute it and/or modify it
-+ * under the terms of the GNU General Public License as published by the
-+ * Free Software Foundation; either version 2 of the License, or (at your
-+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
-+ *
-+ * This program is distributed in the hope that it will be useful, but
-+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-+ * for more details.
-+ *
-+ * RCSID $Id: invokecharon.h $
-+ */
-+
-+#ifndef _STARTER_CHARON_H_
-+#define _STARTER_CHARON_H_
-+
-+#define CHARON_RESTART_DELAY 5
-+
-+extern void starter_charon_sigchild (pid_t pid);
-+extern pid_t starter_charon_pid (void);
-+extern int starter_stop_charon (void);
-+extern int starter_start_charon(struct starter_config *cfg, bool debug);
-+
-+#endif /* _STARTER_CHARON_H_ */
-+
-diff -Naur strongswan-2.6.3/programs/starter/invokepluto.c strongswan-2.6.3-charon/programs/starter/invokepluto.c
---- strongswan-2.6.3/programs/starter/invokepluto.c 2006-02-17 22:41:50.000000000 +0100
-+++ strongswan-2.6.3-charon/programs/starter/invokepluto.c 2006-03-21 09:26:24.000000000 +0100
-@@ -54,7 +54,7 @@
- , PLUTO_RESTART_DELAY);
- alarm(PLUTO_RESTART_DELAY); // restart in 5 sec
- }
-- unlink(PID_FILE);
-+ unlink(PLUTO_PID_FILE);
- }
- }
-
-@@ -203,7 +203,7 @@
- }
- else
- {
-- unlink(CTL_FILE);
-+ unlink(PLUTO_CTL_FILE);
- _stop_requested = 0;
-
- if (cfg->setup.prepluto)
-@@ -252,7 +252,7 @@
- {
- /* wait for pluto */
- usleep(20000);
-- if (stat(CTL_FILE, &stb) == 0)
-+ if (stat(PLUTO_CTL_FILE, &stb) == 0)
- {
- DBG(DBG_CONTROL,
- DBG_log("pluto (%d) started", _pluto_pid)
-diff -Naur strongswan-2.6.3/programs/starter/starter.c strongswan-2.6.3-charon/programs/starter/starter.c
---- strongswan-2.6.3/programs/starter/starter.c 2006-02-15 19:37:46.000000000 +0100
-+++ strongswan-2.6.3-charon/programs/starter/starter.c 2006-03-21 09:26:24.000000000 +0100
-@@ -37,6 +37,7 @@
- #include "files.h"
- #include "starterwhack.h"
- #include "invokepluto.h"
-+#include "invokecharon.h"
- #include "klips.h"
- #include "netkey.h"
- #include "cmp.h"
-@@ -47,6 +48,9 @@
- #define FLAG_ACTION_RELOAD 0x04
- #define FLAG_ACTION_QUIT 0x08
- #define FLAG_ACTION_LISTEN 0x10
-+#ifdef IKEV2
-+#define FLAG_ACTION_START_CHARON 0x20
-+#endif /* IKEV2 */
-
- static unsigned int _action_ = 0;
-
-@@ -65,6 +69,10 @@
- {
- if (pid == starter_pluto_pid())
- name = " (Pluto)";
-+#ifdef IKEV2
-+ if (pid == starter_charon_pid())
-+ name = " (Charon)";
-+#endif /* IKEV2 */
- if (WIFSIGNALED(status))
- DBG(DBG_CONTROL,
- DBG_log("child %d%s has been killed by sig %d\n",
-@@ -87,6 +95,10 @@
-
- if (pid == starter_pluto_pid())
- starter_pluto_sigchild(pid);
-+#ifdef IKEV2
-+ if (pid == starter_charon_pid())
-+ starter_charon_sigchild(pid);
-+#endif /* IKEV2 */
- }
- }
- break;
-@@ -97,6 +109,9 @@
-
- case SIGALRM:
- _action_ |= FLAG_ACTION_START_PLUTO;
-+#ifdef IKEV2
-+ _action_ |= FLAG_ACTION_START_CHARON;
-+#endif /* IKEV2 */
- break;
-
- case SIGHUP:
-@@ -193,6 +208,9 @@
- signal(SIGQUIT, fsig);
- signal(SIGALRM, fsig);
- signal(SIGUSR1, fsig);
-+
-+
-+ plog("Starting strongSwan IPsec %s [starter]...", ipsec_version_code());
-
- /* verify that we can start */
- if (getuid() != 0)
-@@ -201,12 +219,24 @@
- exit(1);
- }
-
-- if (stat(PID_FILE, &stb) == 0)
-+ if (stat(PLUTO_PID_FILE, &stb) == 0)
- {
-- plog("pluto is already running (%s exists) -- aborting", PID_FILE);
-- exit(1);
-+ plog("pluto is already running (%s exists) -- skipping pluto start", PLUTO_PID_FILE);
- }
--
-+ else
-+ {
-+ _action_ |= FLAG_ACTION_START_PLUTO;
-+ }
-+#ifdef IKEV2
-+ if (stat(CHARON_PID_FILE, &stb) == 0)
-+ {
-+ plog("charon is already running (%s exists) -- skipping charon start", CHARON_PID_FILE);
-+ }
-+ else
-+ {
-+ _action_ |= FLAG_ACTION_START_CHARON;
-+ }
-+#endif /* IKEV2 */
- if (stat(DEV_RANDOM, &stb) != 0)
- {
- plog("unable to start strongSwan IPsec -- no %s!", DEV_RANDOM);
-@@ -247,7 +277,11 @@
-
- last_reload = time(NULL);
-
-- plog("Starting strongSwan IPsec %s [starter]...", ipsec_version_code());
-+ if (stat(MY_PID_FILE, &stb) == 0)
-+ {
-+ plog("starter is already running (%s exists) -- no fork done", MY_PID_FILE);
-+ exit(0);
-+ }
-
- /* fork if we're not debugging stuff */
- if (!no_fork)
-@@ -296,17 +330,19 @@
- , &cfg->defaultroute);
- }
-
-- _action_ = FLAG_ACTION_START_PLUTO;
--
- for (;;)
- {
- /*
-- * Stop pluto (if started) and exit
-- */
-+ * Stop pluto/charon (if started) and exit
-+ */
- if (_action_ & FLAG_ACTION_QUIT)
- {
- if (starter_pluto_pid())
- starter_stop_pluto();
-+#ifdef IKEV2
-+ if (starter_charon_pid())
-+ starter_stop_charon();
-+#endif IKEV2
- if (has_netkey)
- starter_netkey_cleanup();
- else
-@@ -337,6 +373,9 @@
- if (conn->state == STATE_ADDED)
- {
- starter_whack_del_conn(conn);
-+#ifdef IKEV2
-+ starter_stroke_del_conn(conn);
-+#endif /* IKEV2 */
- conn->state = STATE_TO_ADD;
- }
- }
-@@ -427,6 +466,9 @@
- {
- if (conn->state == STATE_ADDED)
- starter_whack_del_conn(conn);
-+#ifdef IKEV2
-+ starter_stroke_del_conn(conn);
-+#endif /* IKEV2 */
- }
-
- /* Look for new ca sections that are already loaded */
-@@ -502,6 +544,27 @@
- conn->state = STATE_TO_ADD;
- }
- }
-+
-+#ifdef IKEV2
-+ /*
-+ * Start charon
-+ */
-+ if (_action_ & FLAG_ACTION_START_CHARON)
-+ {
-+ if (starter_charon_pid() == 0)
-+ {
-+ DBG(DBG_CONTROL,
-+ DBG_log("Attempting to start charon...")
-+ )
-+ if (starter_start_charon(cfg, no_fork) != 0)
-+ {
-+ /* schedule next try */
-+ alarm(PLUTO_RESTART_DELAY);
-+ }
-+ }
-+ _action_ &= ~FLAG_ACTION_START_CHARON;
-+ }
-+#endif /* IKEV2 */
-
- /*
- * Tell pluto to reread its interfaces
-@@ -536,11 +599,36 @@
- conn->id = id++;
- }
- starter_whack_add_conn(conn);
-+#ifdef IKEV2
-+ starter_stroke_add_conn(conn);
-+#endif /* IKEV2 */
- conn->state = STATE_ADDED;
- if (conn->startup == STARTUP_START)
-- starter_whack_initiate_conn(conn);
-+ {
-+#ifdef IKEV2
-+ if (conn->keyexchange == 2)
-+ {
-+ starter_stroke_initiate_conn(conn);
-+ }
-+ else
-+#endif /* IKEV2 */
-+ {
-+ starter_whack_initiate_conn(conn);
-+ }
-+ }
- else if (conn->startup == STARTUP_ROUTE)
-- starter_whack_route_conn(conn);
-+ {
-+#ifdef IKEV2
-+ if (conn->keyexchange == 2)
-+ {
-+ starter_stroke_route_conn(conn);
-+ }
-+ else
-+#endif /* IKEV2 */
-+ {
-+ starter_whack_route_conn(conn);
-+ }
-+ }
- }
- }
- }
-diff -Naur strongswan-2.6.3/programs/starter/starterstroke.c strongswan-2.6.3-charon/programs/starter/starterstroke.c
---- strongswan-2.6.3/programs/starter/starterstroke.c 1970-01-01 01:00:00.000000000 +0100
-+++ strongswan-2.6.3-charon/programs/starter/starterstroke.c 2006-03-21 09:26:24.000000000 +0100
-@@ -0,0 +1,193 @@
-+/* Stroke for charon is the counterpart to whack from pluto
-+ * Copyright (C) 2006 Martin Willi - Hochschule fuer Technik Rapperswil
-+ *
-+ * This program is free software; you can redistribute it and/or modify it
-+ * under the terms of the GNU General Public License as published by the
-+ * Free Software Foundation; either version 2 of the License, or (at your
-+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
-+ *
-+ * This program is distributed in the hope that it will be useful, but
-+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-+ * for more details.
-+ *
-+ * RCSID $Id: starterstroke.c $
-+ */
-+
-+#include <sys/types.h>
-+#include <sys/socket.h>
-+#include <sys/un.h>
-+#include <linux/stddef.h>
-+#include <unistd.h>
-+#include <stdlib.h>
-+#include <errno.h>
-+#include <netinet/in.h>
-+#include <arpa/inet.h>
-+
-+#include <freeswan.h>
-+
-+#include "../pluto/constants.h"
-+#include "../pluto/defs.h"
-+#include "../pluto/log.h"
-+
-+#include "starterstroke.h"
-+#include "confread.h"
-+#include "files.h"
-+
-+typedef struct stroke_msg_t stroke_msg_t;
-+
-+struct stroke_msg_t {
-+ /* length of this message with all strings */
-+ u_int16_t length;
-+ /* type of the message */
-+ enum {
-+ /* initiate a connection */
-+ STR_INITIATE,
-+ /* install SPD entries for a connection */
-+ STR_INSTALL,
-+ /* add a connection */
-+ STR_ADD_CONN,
-+ /* delete a connection */
-+ STR_DEL_CONN,
-+ /* more to come */
-+ } type;
-+ union {
-+ /* data for STR_INITIATE, STR_INSTALL */
-+ struct {
-+ char *name;
-+ } initiate, install;
-+ /* data for STR_ADD_CONN */
-+ struct {
-+ char *name;
-+ struct {
-+ char *id;
-+ char *address;
-+ char *subnet;
-+ u_int8_t subnet_mask;
-+ } me, other;
-+ } add_conn;
-+ };
-+ u_int8_t buffer[];
-+};
-+
-+static char* push_string(stroke_msg_t **strm, char *string)
-+{
-+ stroke_msg_t *stroke_msg;
-+ size_t string_length;
-+
-+ if (string == NULL)
-+ {
-+ return NULL;
-+ }
-+ stroke_msg = *strm;
-+ string_length = strlen(string) + 1;
-+ stroke_msg->length += string_length;
-+
-+ stroke_msg = realloc(stroke_msg, stroke_msg->length);
-+ strcpy((char*)stroke_msg + stroke_msg->length - string_length, string);
-+
-+ *strm = stroke_msg;
-+ return (char*)(u_int)stroke_msg->length - string_length;
-+}
-+
-+static int
-+send_stroke_msg (stroke_msg_t *msg)
-+{
-+ struct sockaddr_un ctl_addr = { AF_UNIX, CHARON_CTL_FILE };
-+ int sock;
-+
-+ sock = socket(AF_UNIX, SOCK_STREAM, 0);
-+ if (sock < 0)
-+ {
-+ plog("socket() failed: %s", strerror(errno));
-+ return -1;
-+ }
-+ if (connect(sock, (struct sockaddr *)&ctl_addr,
-+ offsetof(struct sockaddr_un, sun_path) + strlen(ctl_addr.sun_path)) < 0)
-+ {
-+ plog("connect(charon_ctl) failed: %s", strerror(errno));
-+ close(sock);
-+ return -1;
-+ }
-+
-+ /* send message */
-+ if (write(sock, msg, msg->length) != msg->length)
-+ {
-+ plog("write(charon_ctl) failed: %s", strerror(errno));
-+ close(sock);
-+ return -1;
-+ }
-+
-+ close(sock);
-+ return 0;
-+}
-+
-+static char *
-+connection_name(starter_conn_t *conn)
-+{
-+ /* if connection name is '%auto', create a new name like conn_xxxxx */
-+ static char buf[32];
-+
-+ if (streq(conn->name, "%auto"))
-+ {
-+ sprintf(buf, "conn_%ld", conn->id);
-+ return buf;
-+ }
-+ return conn->name;
-+}
-+
-+
-+int starter_stroke_add_conn(starter_conn_t *conn)
-+{
-+ stroke_msg_t *msg = malloc(sizeof(stroke_msg_t));
-+ int res;
-+
-+ msg->length = sizeof(stroke_msg_t);
-+ msg->type = STR_ADD_CONN;
-+
-+ msg->add_conn.name = push_string(&msg, connection_name(conn));
-+
-+ msg->add_conn.me.id = push_string(&msg, conn->left.id);
-+ msg->add_conn.me.address = push_string(&msg, inet_ntoa(conn->left.addr.u.v4.sin_addr));
-+ msg->add_conn.me.subnet = push_string(&msg, inet_ntoa(conn->left.subnet.addr.u.v4.sin_addr));
-+ msg->add_conn.me.subnet_mask = conn->left.subnet.maskbits;
-+
-+ msg->add_conn.other.id = push_string(&msg, conn->right.id);
-+ msg->add_conn.other.address = push_string(&msg, inet_ntoa(conn->right.addr.u.v4.sin_addr));
-+ msg->add_conn.other.subnet = push_string(&msg, inet_ntoa(conn->right.subnet.addr.u.v4.sin_addr));
-+ msg->add_conn.other.subnet_mask = conn->right.subnet.maskbits;
-+
-+ res = send_stroke_msg(msg);
-+ free(msg);
-+ return res;
-+}
-+
-+int starter_stroke_del_conn(starter_conn_t *conn)
-+{
-+ return 0;
-+}
-+int starter_stroke_route_conn(starter_conn_t *conn)
-+{
-+ stroke_msg_t *msg = malloc(sizeof(stroke_msg_t));
-+ int res;
-+
-+ msg->length = sizeof(stroke_msg_t);
-+ msg->type = STR_INSTALL;
-+ msg->install.name = push_string(&msg, connection_name(conn));
-+ res = send_stroke_msg(msg);
-+ free(msg);
-+ return res;
-+}
-+
-+int starter_stroke_initiate_conn(starter_conn_t *conn)
-+{
-+ stroke_msg_t *msg = malloc(sizeof(stroke_msg_t));
-+ int res;
-+
-+ msg->length = sizeof(stroke_msg_t);
-+ msg->type = STR_INITIATE;
-+ msg->initiate.name = push_string(&msg, connection_name(conn));
-+ res = send_stroke_msg(msg);
-+ free(msg);
-+ return res;
-+}
-diff -Naur strongswan-2.6.3/programs/starter/starterstroke.h strongswan-2.6.3-charon/programs/starter/starterstroke.h
---- strongswan-2.6.3/programs/starter/starterstroke.h 1970-01-01 01:00:00.000000000 +0100
-+++ strongswan-2.6.3-charon/programs/starter/starterstroke.h 2006-03-21 09:26:24.000000000 +0100
-@@ -0,0 +1,27 @@
-+/* Stroke for charon is the counterpart to whack from pluto
-+ * Copyright (C) 2006 Martin Willi - Hochschule fuer Technik Rapperswil
-+ *
-+ * This program is free software; you can redistribute it and/or modify it
-+ * under the terms of the GNU General Public License as published by the
-+ * Free Software Foundation; either version 2 of the License, or (at your
-+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
-+ *
-+ * This program is distributed in the hope that it will be useful, but
-+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-+ * for more details.
-+ *
-+ * RCSID $Id: starterstroke.h $
-+ */
-+
-+#ifndef _STARTER_STROKE_H_
-+#define _STARTER_STROKE_H_
-+
-+#include "confread.h"
-+
-+extern int starter_stroke_add_conn(starter_conn_t *conn);
-+extern int starter_stroke_del_conn(starter_conn_t *conn);
-+extern int starter_stroke_route_conn(starter_conn_t *conn);
-+extern int starter_stroke_initiate_conn(starter_conn_t *conn);
-+
-+#endif /* _STARTER_STROKE_H_ */
-diff -Naur strongswan-2.6.3/programs/starter/starterwhack.c strongswan-2.6.3-charon/programs/starter/starterwhack.c
---- strongswan-2.6.3/programs/starter/starterwhack.c 2006-02-08 21:56:07.000000000 +0100
-+++ strongswan-2.6.3-charon/programs/starter/starterwhack.c 2006-03-21 09:26:24.000000000 +0100
-@@ -54,7 +54,7 @@
- static int
- send_whack_msg (whack_message_t *msg)
- {
-- struct sockaddr_un ctl_addr = { AF_UNIX, CTL_FILE };
-+ struct sockaddr_un ctl_addr = { AF_UNIX, PLUTO_CTL_FILE };
- int sock;
- ssize_t len;
- char *str_next, *str_roof;
diff --git a/Source/charon/config/Makefile.config b/Source/charon/config/Makefile.config
index 58ff4e69e..c95bccb8d 100644
--- a/Source/charon/config/Makefile.config
+++ b/Source/charon/config/Makefile.config
@@ -12,26 +12,26 @@
# for more details.
#
-CONFIG_DIR= $(MAIN_DIR)config/
+CONFIG_DIR= $(CHARON_DIR)config/
-OBJS+= $(BUILD_DIR)connection.o
+CHARON_OBJS+= $(BUILD_DIR)connection.o
$(BUILD_DIR)connection.o : $(CONFIG_DIR)connection.c $(CONFIG_DIR)connection.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)policy.o
+CHARON_OBJS+= $(BUILD_DIR)policy.o
$(BUILD_DIR)policy.o : $(CONFIG_DIR)policy.c $(CONFIG_DIR)policy.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)traffic_selector.o
+CHARON_OBJS+= $(BUILD_DIR)traffic_selector.o
$(BUILD_DIR)traffic_selector.o : $(CONFIG_DIR)traffic_selector.c $(CONFIG_DIR)traffic_selector.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)proposal.o
+CHARON_OBJS+= $(BUILD_DIR)proposal.o
$(BUILD_DIR)proposal.o : $(CONFIG_DIR)proposal.c $(CONFIG_DIR)proposal.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)configuration.o
+CHARON_OBJS+= $(BUILD_DIR)configuration.o
$(BUILD_DIR)configuration.o : $(CONFIG_DIR)configuration.c $(CONFIG_DIR)configuration.h
$(CC) $(CFLAGS) -c -o $@ $< \ No newline at end of file
diff --git a/Source/charon/config/connection.h b/Source/charon/config/connection.h
index 9ec26b778..8ecce9d66 100644
--- a/Source/charon/config/connection.h
+++ b/Source/charon/config/connection.h
@@ -24,11 +24,11 @@
#define CONNECTION_H_
#include <types.h>
-#include <network/host.h>
+#include <utils/host.h>
#include <utils/linked_list.h>
#include <utils/identification.h>
#include <config/proposal.h>
-#include <transforms/diffie_hellman.h>
+#include <crypto/diffie_hellman.h>
typedef enum auth_method_t auth_method_t;
diff --git a/Source/charon/config/credential_store.h b/Source/charon/config/credential_store.h
index 27f957aa1..27f1a287d 100755
--- a/Source/charon/config/credential_store.h
+++ b/Source/charon/config/credential_store.h
@@ -24,8 +24,8 @@
#define CREDENTIAL_STORE_H_
#include <types.h>
-#include <transforms/rsa/rsa_private_key.h>
-#include <transforms/rsa/rsa_public_key.h>
+#include <crypto/rsa/rsa_private_key.h>
+#include <crypto/rsa/rsa_public_key.h>
typedef struct credential_store_t credential_store_t;
diff --git a/Source/charon/config/proposal.h b/Source/charon/config/proposal.h
index 9c75406cc..48e3ad8d5 100644
--- a/Source/charon/config/proposal.h
+++ b/Source/charon/config/proposal.h
@@ -26,10 +26,10 @@
#include <types.h>
#include <utils/identification.h>
#include <utils/linked_list.h>
-#include <network/host.h>
-#include <transforms/crypters/crypter.h>
-#include <transforms/signers/signer.h>
-#include <transforms/diffie_hellman.h>
+#include <utils/host.h>
+#include <crypto/crypters/crypter.h>
+#include <crypto/signers/signer.h>
+#include <crypto/diffie_hellman.h>
#include <config/traffic_selector.h>
diff --git a/Source/charon/config/traffic_selector.h b/Source/charon/config/traffic_selector.h
index 7e59b53fc..5ac5bdeb1 100644
--- a/Source/charon/config/traffic_selector.h
+++ b/Source/charon/config/traffic_selector.h
@@ -24,7 +24,7 @@
#define TRAFFIC_SELECTOR_H_
#include <types.h>
-#include <network/host.h>
+#include <utils/host.h>
typedef enum ts_type_t ts_type_t;
diff --git a/Source/charon/daemon.h b/Source/charon/daemon.h
index a64845e4e..9f4d73887 100644
--- a/Source/charon/daemon.h
+++ b/Source/charon/daemon.h
@@ -41,6 +41,61 @@
#include <config/credential_store.h>
/**
+ * @mainpage
+ *
+ * @section Threading Architecture
+ *
+ * All IKEv2 stuff is handled in charon. It uses a newer and more flexible
+ * architecture than pluto. Charon uses a thread-pool, which allows parallel
+ * execution SA-management. Beside the thread-pool, there are some special purpose
+ * threads which do their job for the common health of the daemon.
+ @verbatim
+ +------+
+ | E Q |
+ | v u |---+ +------+ +------+
+ | e e | | | | | IKE- |
+ | n u | +-----------+ | |--| SA |
+ | t e | | | | I M | +------+
+ +------------+ | - | | Scheduler | | K a |
+ | receiver | +------+ | | | E n | +------+
+ +----+-------+ +-----------+ | - a | | IKE- |
+ | | +------+ | | S g |--| SA |
+ +-------+--+ +-----| J Q |---+ +------------+ | A e | +------+
+ -| socket | | o u | | | | - r |
+ +-------+--+ | b e | | Thread- | | |
+ | | - u | | Pool | | |
+ +----+-------+ | e |------| |---| |
+ | sender | +------+ +------------+ +------+
+ +----+-------+
+ | +------+
+ | | S Q |
+ | | e u |
+ | | n e |
+ +------------| d u |
+ | - e |
+ +--+---+
+ @endverbatim
+ * The thread-pool is the heart of the architecture. It processes jobs from a
+ * (fully synchronized) job-queue. Mostly, a job is associated with a specific
+ * IKE SA. These IKE SAs are synchronized, only one thread can work one an IKE SA.
+ * This makes it unnecesary to use further synchronisation methods once a IKE SA
+ * is checked out. The (rather complex) synchronization of IKE SAs is completely
+ * done in the IKE SA manager.
+ * The sceduler is responsible for event firing. It waits until a event in the
+ * (fully synchronized) event-queue is ready for processing and pushes the event
+ * down to the job-queue. A thread form the pool will pick it up as quick as
+ * possible. Every thread can queue events or jobs. Furter, an event can place a
+ * packet in the send-queue. The sender thread waits for those packets and sends
+ * them over the wire, via the socket. The receiver does exactly the opposite of
+ * the sender. It waits on the socket, reads in packets an places them on the
+ * job-queue for further processing by a thread from the pool.
+ * There are even more threads, not drawn in the upper scheme. The stroke thread
+ * is responsible for reading and processessing commands from another process. The
+ * kernel interface thread handles communication from and to the kernel via a
+ * netlink socket. It waits for kernel events and processes them appropriately.
+ */
+
+/**
* Name of the daemon.
*/
#define DAEMON_NAME "charon"
diff --git a/Source/charon/definitions.c b/Source/charon/definitions.c
deleted file mode 100644
index 59c97a29b..000000000
--- a/Source/charon/definitions.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * @file definitions.c
- *
- * @brief General purpose definitions and macros.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "definitions.h"
-
-/*
- * Described in header.
- */
-char *mapping_find(mapping_t * maps, int value)
-{
- int i = 0;
- while (maps[i].value != MAPPING_END)
- {
- if (maps[i].value == value)
- {
- return maps[i].string;
- }
- i++;
- }
- return "INVALID MAPPING";
-}
diff --git a/Source/charon/definitions.h b/Source/charon/definitions.h
deleted file mode 100644
index 4ca46063a..000000000
--- a/Source/charon/definitions.h
+++ /dev/null
@@ -1,292 +0,0 @@
-/**
- * @file definitions.h
- *
- * @brief General purpose definitions and macros.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- * Copyright (C) 1998, 1999 D. Hugh Redelmeier. (Endian stuff)
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef DEFINITIONS_H_
-#define DEFINITIONS_H_
-
-
-
-/* stolen from strongswan */
-#if linux
-# if defined(i386) && !defined(__i386__)
-# define __i386__ 1
-# define MYHACKFORTHIS 1
-# endif
-# include <endian.h>
-# ifdef MYHACKFORTHIS
-# undef __i386__
-# undef MYHACKFORTHIS
-# endif
-#elif !(defined(BIG_ENDIAN) && defined(LITTLE_ENDIAN) && defined(BYTE_ORDER))
- /* we don't know how to do this, so we require the macros to be defined
- * with compiler flags:
- * -DBIG_ENDIAN=4321 -DLITTLE_ENDIAN=1234 -DBYTE_ORDER=BIG_ENDIAN
- * or -DBIG_ENDIAN=4321 -DLITTLE_ENDIAN=1234 -DBYTE_ORDER=LITTLE_ENDIAN
- * Thse match the GNU definitions
- */
-# include <sys/endian.h>
-#endif
-
-#ifndef BIG_ENDIAN
- #error "BIG_ENDIAN must be defined"
-#endif
-
-#ifndef LITTLE_ENDIAN
- #error "LITTLE_ENDIAN must be defined"
-#endif
-
-#ifndef BYTE_ORDER
- #error "BYTE_ORDER must be defined"
-#endif
-
-/**
- * @mainpage
- *
- * @section Threading Architecture
- *
- * All IKEv2 stuff is handled in charon. It uses a newer and more flexible
- * architecture than pluto. Charon uses a thread-pool, which allows parallel
- * execution SA-management. Beside the thread-pool, there are some special purpose
- * threads which do their job for the common health of the daemon.
- @verbatim
- +------+
- | E Q |
- | v u |---+ +------+ +------+
- | e e | | | | | IKE- |
- | n u | +-----------+ | |--| SA |
- | t e | | | | I M | +------+
- +------------+ | - | | Scheduler | | K a |
- | receiver | +------+ | | | E n | +------+
- +----+-------+ +-----------+ | - a | | IKE- |
- | | +------+ | | S g |--| SA |
- +-------+--+ +-----| J Q |---+ +------------+ | A e | +------+
- -| socket | | o u | | | | - r |
- +-------+--+ | b e | | Thread- | | |
- | | - u | | Pool | | |
- +----+-------+ | e |------| |---| |
- | sender | +------+ +------------+ +------+
- +----+-------+
- | +------+
- | | S Q |
- | | e u |
- | | n e |
- +------------| d u |
- | - e |
- +--+---+
- @endverbatim
- * The thread-pool is the heart of the architecture. It processes jobs from a
- * (fully synchronized) job-queue. Mostly, a job is associated with a specific
- * IKE SA. These IKE SAs are synchronized, only one thread can work one an IKE SA.
- * This makes it unnecesary to use further synchronisation methods once a IKE SA
- * is checked out. The (rather complex) synchronization of IKE SAs is completely
- * done in the IKE SA manager.
- * The sceduler is responsible for event firing. It waits until a event in the
- * (fully synchronized) event-queue is ready for processing and pushes the event
- * down to the job-queue. A thread form the pool will pick it up as quick as
- * possible. Every thread can queue events or jobs. Furter, an event can place a
- * packet in the send-queue. The sender thread waits for those packets and sends
- * them over the wire, via the socket. The receiver does exactly the opposite of
- * the sender. It waits on the socket, reads in packets an places them on the
- * job-queue for further processing by a thread from the pool.
- * There are even more threads, not drawn in the upper scheme. The stroke thread
- * is responsible for reading and processessing commands from another process. The
- * kernel interface thread handles communication from and to the kernel via a
- * netlink socket. It waits for kernel events and processes them appropriately.
- */
-
-/**
- * @defgroup config config
- *
- * Classes implementing configuration related things.
- */
-
-/**
- * @defgroup encoding encoding
- *
- * Classes used to encode and decode IKEv2 messages.
- */
-
-/**
- * @defgroup network network
- *
- * Classes for network relevant stuff.
- */
-
- /**
- * @defgroup payloads payloads
- *
- * Classes representing specific IKEv2 payloads.
- *
- * @ingroup encoding
- */
-
-/**
- * @defgroup sa sa
- *
- * Security association and helper classes.
- */
-
-
-/**
- * @defgroup states states
- *
- * Varius states in which an IKE SA can be.
- *
- * @ingroup sa
- */
-
-/**
- * @defgroup queues queues
- *
- * Different kind of queues.
- */
-
- /**
- * @defgroup jobs jobs
- *
- * Jobs used in job queue and event queue.
- *
- * @ingroup queues
- */
-
-/**
- * @defgroup testcases testcases
- *
- * Testcases used to test the different classes in seperate module tests.
- */
-
-/**
- * @defgroup transforms transforms
- *
- * Transform algorithms of different kind.
- */
-
-/**
- * @defgroup rsa rsa
- *
- * RSA public key algorithm.
- *
- * @ingroup transforms
- */
-
-/**
- * @defgroup prfs prfs
- *
- * Pseudo random functions.
- *
- * @ingroup transforms
- */
-
-/**
- * @defgroup signers signers
- *
- * Symmetric signing algorithms, used to ensure message integrity.
- *
- * @ingroup transforms
- */
-
-/**
- * @defgroup crypters crypters
- *
- * Symmetric encryption algorithms, used to encrypt and decrypt.
- *
- * @ingroup transforms
- */
-
-/**
- * @defgroup hashers hashers
- *
- * Hashing algorithms.
- *
- * @ingroup transforms
- */
-/**
- * @defgroup asn1 asn1
- *
- * ASN1 structure definition, en-/decoder of for DER
- *
- * @todo Implement a der_encoder_t class.
- */
-
-/**
- * @defgroup utils utils
- *
- * Generic helper classes.
- */
-
-/**
- * @defgroup threads threads
- *
- * Threaded classes, which will do their job alone.
- */
-
-/**
- * Macro gives back larger of two values.
- */
-#define max(x,y) (x > y ? x : y)
-
-/**
- * Macro gives back smaller of two values.
- */
-#define min(x,y) (x < y ? x : y)
-
-/**
- * Debug macro to follow control flow
- */
-#define POS printf("%s, line %d\n", __FILE__, __LINE__)
-
-/**
- * Papping entry which defines the end of a mapping_t array.
- */
-#define MAPPING_END (-1)
-
-
-typedef struct mapping_t mapping_t;
-
-/**
- * @brief Mapping entry, where enum-to-string mappings are stored.
- */
-struct mapping_t
-{
- /**
- * Enumeration value.
- */
- int value;
-
- /**
- * Mapped string.
- */
- char *string;
-};
-
-
-/**
- * @brief Find a mapping_string in the mapping[].
- *
- * @param mappings mappings array
- * @param value enum-value to get the string from
- *
- */
-char *mapping_find(mapping_t *mappings, int value);
-
-#endif /*DEFINITIONS_H_*/
diff --git a/Source/charon/doc/Architecture.txt b/Source/charon/doc/Architecture.txt
deleted file mode 100644
index 3e8855fa9..000000000
--- a/Source/charon/doc/Architecture.txt
+++ /dev/null
@@ -1,128 +0,0 @@
- strongSwans overall design
-============================
-
-IKEv1 and IKEv2 is handled in different keying daemons. The ole IKEv1 stuff is
-completely handled in pluto, as it was all the times. IKEv2 is handled in the
-new keying daemon, which is called charon.
-Daemon control is done over unix sockets. Pluto uses whack, as it did for years.
-Charon uses another socket interface, called stroke. Stroke uses another
-format as whack and therefore is not compatible to whack. The starter utility,
-wich does fast configuration parsing, speaks both the protocols, whack and
-stroke. It also handles daemon startup and termination.
-Pluto uses starter for some commands, for other it uses the whack utility. To be
-as close to pluto as possible, charon has the same split up of commands to
-starter and stroke. All commands are wrapped together in the ipsec script, which
-allows transparent control of both daemons.
-
- +-----------------------------------------+
- | ipsec |
- +-----+--------------+---------------+----+
- | | |
- | | |
- | +-----+-----+ |
- +-----+----+ | | +-----+----+
- | | | starter | | |
- | stroke | | | | whack |
- | | +---+--+----+ | |
- +------+---+ | | +--+-------+
- | | | |
- +---+------+ | | +------+--+
- | | | | | |
- | charon +----+ +----+ pluto |
- | | | |
- +-----+----+ +----+----+
- | |
- +-----+----+ |
- | LSF | |
- +-----+----+ |
- | |
- +-----+----+ +----+----+
- | RAW Sock | | UDP/500 |
- +----------+ +---------+
-
-Since IKEv2 uses the same port as IKEv1, both daemons must listen to UDP port
-500. Under Linux, there is no clean way to set up two sockets at the same port.
-To reslove this problem, charon uses a RAW socket, as they are used in network
-sniffers. An installed Linux Socket Filter (LSF) filters out all none-IKEv2
-traffic. Pluto receives any IKE message, independant of charons behavior.
-Therefore plutos behavior is changed to discard any IKEv2 traffic silently.
-
-
- IKEv2 keying daemon: charon
-=============================
-
- Threading modell
-------------------
-
-All IKEv2 stuff is handled in charon. It uses a newer and more flexible
-architecture than pluto. Charon uses a thread-pool, which allows parallel
-execution SA-management. Beside the thread-pool, there are some special purpose
-threads which do their job for the common health of the daemon.
-
- +------+
- | E Q |
- | v u |---+ +------+ +------+
- | e e | | | | | IKE- |
- | n u | +-----------+ | |--| SA |
- | t e | | | | I M | +------+
- +------------+ | - | | Scheduler | | K a |
- | receiver | +------+ | | | E n | +------+
- +----+-------+ +-----------+ | - a | | IKE- |
- | | +------+ | | S g |--| SA |
- +-------+--+ +-----| J Q |---+ +------------+ | A e | +------+
- -| socket | | o u | | | | - r |
- +-------+--+ | b e | | Thread- | | |
- | | - u | | Pool | | |
- +----+-------+ | e |------| |---| |
- | sender | +------+ +------------+ +------+
- +----+-------+
- | +------+
- | | S Q |
- | | e u |
- | | n e |
- +------------| d u |
- | - e |
- +--+---+
-
-The thread-pool is the heart of the architecture. It processes jobs from a
-(fully synchronized) job-queue. Mostly, a job is associated with a specific
-IKE SA. These IKE SAs are synchronized, only one thread can work one an IKE SA.
-This makes it unnecesary to use further synchronisation methods once a IKE SA
-is checked out. The (rather complex) synchronization of IKE SAs is completely
-done in the IKE SA manager.
-The sceduler is responsible for event firing. It waits until a event in the
-(fully synchronized) event-queue is ready for processing and pushes the event
-down to the job-queue. A thread form the pool will pick it up as quick as
-possible. Every thread can queue events or jobs. Furter, an event can place a
-packet in the send-queue. The sender thread waits for those packets and sends
-them over the wire, via the socket. The receiver does exactly the opposite of
-the sender. It waits on the socket, reads in packets an places them on the
-job-queue for further processing by a thread from the pool.
-There are even more threads, not drawn in the upper scheme. The stroke thread
-is responsible for reading and processessing commands from another process. The
-kernel interface thread handles communication from and to the kernel via a
-netlink socket. It waits for kernel events and processes them appropriately.
-
-
- configuration backends
-------------------------
-
-The configuration architecture for charon is complex, but is flexible and
-extensible. All configuration stuff is split up in multiple parts:
-
-connection Defines a connection between two hosts. Proposals define with
- wich algorithms a IKE SA should be set up.
-policy Defines the rules to apply ontop of a connection. A policy is
- defined between two IDs. Proposals and traffic selectors allow
- fine grained configuration of the CHILD SAs (AH and ESP) to set
- up.
-credential A credential is something used for authentication, such as a
- preshared key, a RSA private or public key, certificate, ...
-configuration The configuration itself handles daemon related configuration
- stuff, such as interface binding or logging settings.
-
-These configuration types are defined as interfaces, and are currently
-implemented only in the stroke class. Through the modular design, parts could be
-replaced with more powerful backends, such as a RADIUS server for the
-credentials, a SQL database for the connections, policy definitions on an LDAP
-server, and so on...
diff --git a/Source/charon/doc/Todo-list.txt b/Source/charon/doc/Todo-list.txt
deleted file mode 100644
index 404e45e9e..000000000
--- a/Source/charon/doc/Todo-list.txt
+++ /dev/null
@@ -1,41 +0,0 @@
- TODO-List for charon
-======================
-
-+ = done, - = todo, ordered by priority
-
-+ private key loading: der, without passphrase
-+ load all private keys from ipsec.d/private/ in stroke.c
-+ handle leftcert and rightcert in starterstroke.c/stroke.c
-+ load specified certs in stroke.c
-+ extract public keys from certs
-+ public key authentication
-+ release for Andreas
-
-+ stroke loglevels
-+ stroke up
-+ ike_sa_manager checkout_by_hosts
-+ stroke down
-+ stroke output redirection
-+ stroke status
-
-- libx509
- - new charon build - libstrong?
- - transforms
- - utils (plus host)
- - integrate asn1 parser/oid (asn1/oid)
- - integrate PEM loading (pem)
- - ... (more to come, for sure)
-
-- ipsec.secrets parsing
-
-- certificate DN parsing
-- certificate subjectAltName parsing
-- certificate lookup via ID
-- certificate validation/chaining
-- certificate exchange
-
-- trapping
-
-- delete notify, when to send?
-- notifys on connection setup failure
-- create child sa message \ No newline at end of file
diff --git a/Source/charon/encoding/Makefile.encoding b/Source/charon/encoding/Makefile.encoding
index 2f5576ae6..ccdb42f79 100644
--- a/Source/charon/encoding/Makefile.encoding
+++ b/Source/charon/encoding/Makefile.encoding
@@ -12,17 +12,17 @@
# for more details.
#
-ENCODING_DIR= $(MAIN_DIR)encoding/
+ENCODING_DIR= $(CHARON_DIR)encoding/
-OBJS+= $(BUILD_DIR)generator.o
+CHARON_OBJS+= $(BUILD_DIR)generator.o
$(BUILD_DIR)generator.o : $(ENCODING_DIR)generator.c $(ENCODING_DIR)generator.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)parser.o
+CHARON_OBJS+= $(BUILD_DIR)parser.o
$(BUILD_DIR)parser.o : $(ENCODING_DIR)parser.c $(ENCODING_DIR)parser.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)message.o
+CHARON_OBJS+= $(BUILD_DIR)message.o
$(BUILD_DIR)message.o : $(ENCODING_DIR)message.c $(ENCODING_DIR)message.h
$(CC) $(CFLAGS) -c -o $@ $<
diff --git a/Source/charon/encoding/message.h b/Source/charon/encoding/message.h
index ef4491c80..e3a72f439 100644
--- a/Source/charon/encoding/message.h
+++ b/Source/charon/encoding/message.h
@@ -29,8 +29,8 @@
#include <encoding/payloads/ike_header.h>
#include <encoding/payloads/notify_payload.h>
#include <utils/linked_list.h>
-#include <transforms/crypters/crypter.h>
-#include <transforms/signers/signer.h>
+#include <crypto/crypters/crypter.h>
+#include <crypto/signers/signer.h>
typedef struct message_t message_t;
diff --git a/Source/charon/encoding/payloads/Makefile.payloads b/Source/charon/encoding/payloads/Makefile.payloads
index 19b9a3bb4..61d920907 100644
--- a/Source/charon/encoding/payloads/Makefile.payloads
+++ b/Source/charon/encoding/payloads/Makefile.payloads
@@ -14,95 +14,95 @@
PAYLOADS_DIR= $(ENCODING_DIR)payloads/
-OBJS+= $(BUILD_DIR)encodings.o
+CHARON_OBJS+= $(BUILD_DIR)encodings.o
$(BUILD_DIR)encodings.o : $(PAYLOADS_DIR)encodings.c $(PAYLOADS_DIR)encodings.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)ike_header.o
+CHARON_OBJS+= $(BUILD_DIR)ike_header.o
$(BUILD_DIR)ike_header.o : $(PAYLOADS_DIR)ike_header.c $(PAYLOADS_DIR)ike_header.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)ke_payload.o
+CHARON_OBJS+= $(BUILD_DIR)ke_payload.o
$(BUILD_DIR)ke_payload.o : $(PAYLOADS_DIR)ke_payload.c $(PAYLOADS_DIR)ke_payload.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)nonce_payload.o
+CHARON_OBJS+= $(BUILD_DIR)nonce_payload.o
$(BUILD_DIR)nonce_payload.o : $(PAYLOADS_DIR)nonce_payload.c $(PAYLOADS_DIR)nonce_payload.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)notify_payload.o
+CHARON_OBJS+= $(BUILD_DIR)notify_payload.o
$(BUILD_DIR)notify_payload.o : $(PAYLOADS_DIR)notify_payload.c $(PAYLOADS_DIR)notify_payload.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)id_payload.o
+CHARON_OBJS+= $(BUILD_DIR)id_payload.o
$(BUILD_DIR)id_payload.o : $(PAYLOADS_DIR)id_payload.c $(PAYLOADS_DIR)id_payload.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)auth_payload.o
+CHARON_OBJS+= $(BUILD_DIR)auth_payload.o
$(BUILD_DIR)auth_payload.o : $(PAYLOADS_DIR)auth_payload.c $(PAYLOADS_DIR)auth_payload.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)cert_payload.o
+CHARON_OBJS+= $(BUILD_DIR)cert_payload.o
$(BUILD_DIR)cert_payload.o : $(PAYLOADS_DIR)cert_payload.c $(PAYLOADS_DIR)cert_payload.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)certreq_payload.o
+CHARON_OBJS+= $(BUILD_DIR)certreq_payload.o
$(BUILD_DIR)certreq_payload.o : $(PAYLOADS_DIR)certreq_payload.c $(PAYLOADS_DIR)certreq_payload.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)delete_payload.o
+CHARON_OBJS+= $(BUILD_DIR)delete_payload.o
$(BUILD_DIR)delete_payload.o : $(PAYLOADS_DIR)delete_payload.c $(PAYLOADS_DIR)delete_payload.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)vendor_id_payload.o
+CHARON_OBJS+= $(BUILD_DIR)vendor_id_payload.o
$(BUILD_DIR)vendor_id_payload.o : $(PAYLOADS_DIR)vendor_id_payload.c $(PAYLOADS_DIR)vendor_id_payload.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)cp_payload.o
+CHARON_OBJS+= $(BUILD_DIR)cp_payload.o
$(BUILD_DIR)cp_payload.o : $(PAYLOADS_DIR)cp_payload.c $(PAYLOADS_DIR)cp_payload.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)configuration_attribute.o
+CHARON_OBJS+= $(BUILD_DIR)configuration_attribute.o
$(BUILD_DIR)configuration_attribute.o : $(PAYLOADS_DIR)configuration_attribute.c $(PAYLOADS_DIR)configuration_attribute.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)eap_payload.o
+CHARON_OBJS+= $(BUILD_DIR)eap_payload.o
$(BUILD_DIR)eap_payload.o : $(PAYLOADS_DIR)eap_payload.c $(PAYLOADS_DIR)eap_payload.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)unknown_payload.o
+CHARON_OBJS+= $(BUILD_DIR)unknown_payload.o
$(BUILD_DIR)unknown_payload.o : $(PAYLOADS_DIR)unknown_payload.c $(PAYLOADS_DIR)unknown_payload.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)ts_payload.o
+CHARON_OBJS+= $(BUILD_DIR)ts_payload.o
$(BUILD_DIR)ts_payload.o : $(PAYLOADS_DIR)ts_payload.c $(PAYLOADS_DIR)ts_payload.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)traffic_selector_substructure.o
+CHARON_OBJS+= $(BUILD_DIR)traffic_selector_substructure.o
$(BUILD_DIR)traffic_selector_substructure.o : $(PAYLOADS_DIR)traffic_selector_substructure.c $(PAYLOADS_DIR)traffic_selector_substructure.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)payload.o
+CHARON_OBJS+= $(BUILD_DIR)payload.o
$(BUILD_DIR)payload.o : $(PAYLOADS_DIR)payload.c $(PAYLOADS_DIR)payload.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)proposal_substructure.o
+CHARON_OBJS+= $(BUILD_DIR)proposal_substructure.o
$(BUILD_DIR)proposal_substructure.o : $(PAYLOADS_DIR)proposal_substructure.c $(PAYLOADS_DIR)proposal_substructure.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)sa_payload.o
+CHARON_OBJS+= $(BUILD_DIR)sa_payload.o
$(BUILD_DIR)sa_payload.o : $(PAYLOADS_DIR)sa_payload.c $(PAYLOADS_DIR)sa_payload.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)transform_attribute.o
+CHARON_OBJS+= $(BUILD_DIR)transform_attribute.o
$(BUILD_DIR)transform_attribute.o : $(PAYLOADS_DIR)transform_attribute.c $(PAYLOADS_DIR)transform_attribute.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)transform_substructure.o
+CHARON_OBJS+= $(BUILD_DIR)transform_substructure.o
$(BUILD_DIR)transform_substructure.o : $(PAYLOADS_DIR)transform_substructure.c $(PAYLOADS_DIR)transform_substructure.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)encryption_payload.o
+CHARON_OBJS+= $(BUILD_DIR)encryption_payload.o
$(BUILD_DIR)encryption_payload.o : $(PAYLOADS_DIR)encryption_payload.c $(PAYLOADS_DIR)encryption_payload.h
$(CC) $(CFLAGS) -c -o $@ $<
diff --git a/Source/charon/encoding/payloads/encryption_payload.c b/Source/charon/encoding/payloads/encryption_payload.c
index da48c8349..70bbe9701 100644
--- a/Source/charon/encoding/payloads/encryption_payload.c
+++ b/Source/charon/encoding/payloads/encryption_payload.c
@@ -34,7 +34,7 @@
#include <encoding/parser.h>
#include <utils/iterator.h>
#include <utils/randomizer.h>
-#include <transforms/signers/signer.h>
+#include <crypto/signers/signer.h>
@@ -294,7 +294,12 @@ static status_t encrypt(private_encryption_payload_t *this)
/* build padding */
block_size = this->crypter->get_block_size(this->crypter);
padding.len = block_size - ((this->decrypted.len + 1) % block_size);
- randomizer->allocate_pseudo_random_bytes(randomizer, padding.len, &padding);
+ status = randomizer->allocate_pseudo_random_bytes(randomizer, padding.len, &padding);
+ if (status != SUCCESS)
+ {
+ randomizer->destroy(randomizer);
+ return status;
+ }
/* concatenate payload data, padding, padding len */
to_crypt.len = this->decrypted.len + padding.len + 1;
@@ -306,8 +311,14 @@ static status_t encrypt(private_encryption_payload_t *this)
/* build iv */
iv.len = block_size;
- randomizer->allocate_pseudo_random_bytes(randomizer, iv.len, &iv);
+ status = randomizer->allocate_pseudo_random_bytes(randomizer, iv.len, &iv);
randomizer->destroy(randomizer);
+ if (status != SUCCESS)
+ {
+ allocator_free_chunk(&to_crypt);
+ allocator_free_chunk(&padding);
+ return status;
+ }
this->logger->log_chunk(this->logger, RAW|LEVEL2, "data before encryption with padding", to_crypt);
diff --git a/Source/charon/encoding/payloads/encryption_payload.h b/Source/charon/encoding/payloads/encryption_payload.h
index 7119a72a0..77be246c5 100644
--- a/Source/charon/encoding/payloads/encryption_payload.h
+++ b/Source/charon/encoding/payloads/encryption_payload.h
@@ -23,8 +23,8 @@
#define ENCRYPTION_PAYLOAD_H_
#include <types.h>
-#include <transforms/crypters/crypter.h>
-#include <transforms/signers/signer.h>
+#include <crypto/crypters/crypter.h>
+#include <crypto/signers/signer.h>
#include <encoding/payloads/payload.h>
#include <utils/linked_list.h>
diff --git a/Source/charon/encoding/payloads/traffic_selector_substructure.h b/Source/charon/encoding/payloads/traffic_selector_substructure.h
index 1129ac845..755917055 100644
--- a/Source/charon/encoding/payloads/traffic_selector_substructure.h
+++ b/Source/charon/encoding/payloads/traffic_selector_substructure.h
@@ -26,7 +26,7 @@
#include <types.h>
#include <encoding/payloads/payload.h>
-#include <network/host.h>
+#include <utils/host.h>
#include <config/traffic_selector.h>
/**
diff --git a/Source/charon/encoding/payloads/transform_substructure.h b/Source/charon/encoding/payloads/transform_substructure.h
index 62def3309..f6af3ee59 100644
--- a/Source/charon/encoding/payloads/transform_substructure.h
+++ b/Source/charon/encoding/payloads/transform_substructure.h
@@ -28,10 +28,10 @@
#include <encoding/payloads/payload.h>
#include <encoding/payloads/transform_attribute.h>
#include <utils/linked_list.h>
-#include <transforms/diffie_hellman.h>
-#include <transforms/signers/signer.h>
-#include <transforms/prfs/prf.h>
-#include <transforms/crypters/crypter.h>
+#include <crypto/diffie_hellman.h>
+#include <crypto/signers/signer.h>
+#include <crypto/prfs/prf.h>
+#include <crypto/crypters/crypter.h>
#include <config/proposal.h>
diff --git a/Source/charon/network/Makefile.network b/Source/charon/network/Makefile.network
index 034468354..fd99bd085 100644
--- a/Source/charon/network/Makefile.network
+++ b/Source/charon/network/Makefile.network
@@ -12,17 +12,13 @@
# for more details.
#
-NETWORK_DIR= $(MAIN_DIR)network/
+NETWORK_DIR= $(CHARON_DIR)network/
-OBJS+= $(BUILD_DIR)packet.o
+CHARON_OBJS+= $(BUILD_DIR)packet.o
$(BUILD_DIR)packet.o : $(NETWORK_DIR)packet.c $(NETWORK_DIR)packet.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)socket.o
+CHARON_OBJS+= $(BUILD_DIR)socket.o
$(BUILD_DIR)socket.o : $(NETWORK_DIR)socket.c $(NETWORK_DIR)socket.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-OBJS+= $(BUILD_DIR)host.o
-$(BUILD_DIR)host.o : $(NETWORK_DIR)host.c $(NETWORK_DIR)host.h
$(CC) $(CFLAGS) -c -o $@ $< \ No newline at end of file
diff --git a/Source/charon/network/host.c b/Source/charon/network/host.c
deleted file mode 100644
index 245df8b05..000000000
--- a/Source/charon/network/host.c
+++ /dev/null
@@ -1,365 +0,0 @@
-/**
- * @file host.c
- *
- * @brief Implementation of host_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "host.h"
-
-#include <utils/allocator.h>
-
-
-typedef struct private_host_t private_host_t;
-
-/**
- * @brief Private Data of a host object.
- */
-struct private_host_t {
- /**
- * Public data
- */
- host_t public;
-
- /**
- * Address family to use, such as AF_INET or AF_INET6
- */
- int family;
-
- /**
- * string representation of host
- */
- char *string;
-
- /**
- * low-lewel structure, wich stores the address
- */
- union {
- struct sockaddr address;
- struct sockaddr_in address4;
- };
- /**
- * length of address structure
- */
- socklen_t socklen;
-};
-
-
-/**
- * implements host_t.get_sockaddr
- */
-static sockaddr_t *get_sockaddr(private_host_t *this)
-{
- return &(this->address);
-}
-
-/**
- * implements host_t.get_sockaddr_len
- */
-static socklen_t *get_sockaddr_len(private_host_t *this)
-{
- return &(this->socklen);
-}
-
-/**
- * Implementation of host_t.is_default_route.
- */
-static bool is_default_route (private_host_t *this)
-{
- switch (this->family)
- {
- case AF_INET:
- {
- static u_int8_t default_route[4] = {0x00,0x00,0x00,0x00};
-
- if (memcmp(default_route,&(this->address4.sin_addr.s_addr),4) == 0)
- {
- return TRUE;
- }
- return FALSE;
- }
- default:
- {
- /* empty chunk is returned */
- return FALSE;
- }
- }
-}
-
-/**
- * implements host_t.get_address
- */
-static char *get_address(private_host_t *this)
-{
- switch (this->family)
- {
- case AF_INET:
- {
- char *string;
- /* we need to clone it, since inet_ntoa overwrites
- * internal buffer on subsequent calls
- */
- allocator_free(this->string);
- string = inet_ntoa(this->address4.sin_addr);
- this->string = allocator_alloc(strlen(string)+1);
- strcpy(this->string, string);
- return this->string;
- }
- default:
- {
- return "(family not supported)";
- }
- }
-}
-
-/**
- * Implementation of host_t.get_address_as_chunk.
- */
-static chunk_t get_address_as_chunk(private_host_t *this)
-{
- chunk_t address = CHUNK_INITIALIZER;
-
- switch (this->family)
- {
- case AF_INET:
- {
- /* allocate 4 bytes for IPV4 address*/
- address.ptr = allocator_alloc(4);
- address.len = 4;
- memcpy(address.ptr,&(this->address4.sin_addr.s_addr),4);
- }
- default:
- {
- /* empty chunk is returned */
- return address;
- }
- }
-}
-
-static xfrm_address_t get_xfrm_addr(private_host_t *this)
-{
- switch (this->family)
- {
- case AF_INET:
- {
- return (xfrm_address_t)(this->address4.sin_addr.s_addr);
- }
- default:
- {
- /* todo */
- return (xfrm_address_t)(this->address4.sin_addr.s_addr);
- }
- }
-}
-
-static int get_family(private_host_t *this)
-{
- return this->family;
-}
-
-/**
- * implements host_t.get_port
- */
-static u_int16_t get_port(private_host_t *this)
-{
- switch (this->family)
- {
- case AF_INET:
- {
- return ntohs(this->address4.sin_port);
- }
- default:
- {
- return 0;
- }
- }
-}
-
-
-/**
- * Implements host_t.clone.
- */
-static private_host_t *clone(private_host_t *this)
-{
- private_host_t *new = allocator_alloc_thing(private_host_t);
-
-
- memcpy(new, this, sizeof(private_host_t));
- if (this->string)
- {
- new->string = allocator_alloc(strlen(this->string)+1);
- strcpy(new->string, this->string);
- }
- return new;
-}
-
-/**
- * Impelements host_t.ip_equals
- */
-static bool ip_equals(private_host_t *this, private_host_t *other)
-{
- switch (this->family)
- {
- /* IPv4 */
- case AF_INET:
- {
- if ((this->address4.sin_family == other->address4.sin_family) &&
- (this->address4.sin_addr.s_addr == other->address4.sin_addr.s_addr))
- {
- return TRUE;
- }
- }
- }
- return FALSE;
-}
-
-/**
- * Impelements host_t.equals
- */
-static bool equals(private_host_t *this, private_host_t *other)
-{
- switch (this->family)
- {
- /* IPv4 */
- case AF_INET:
- {
- if ((this->address4.sin_family == other->address4.sin_family) &&
- (this->address4.sin_addr.s_addr == other->address4.sin_addr.s_addr) &&
- (this->address4.sin_port == other->address4.sin_port))
- {
- return TRUE;
- }
- }
- }
- return FALSE;
-}
-
-/**
- * Implements host_t.destroy
- */
-static void destroy(private_host_t *this)
-{
- allocator_free(this->string);
- allocator_free(this);
-}
-
-/**
- * Creates an empty host_t object
- */
-static private_host_t *host_create_empty()
-{
- private_host_t *this = allocator_alloc_thing(private_host_t);
-
- this->public.get_sockaddr = (sockaddr_t* (*) (host_t*))get_sockaddr;
- this->public.get_sockaddr_len = (socklen_t*(*) (host_t*))get_sockaddr_len;
- this->public.clone = (host_t* (*) (host_t*))clone;
- this->public.get_family = (int (*) (host_t*))get_family;
- this->public.get_xfrm_addr = (xfrm_address_t (*) (host_t *))get_xfrm_addr;
- this->public.get_address = (char* (*) (host_t *))get_address;
- this->public.get_address_as_chunk = (chunk_t (*) (host_t *)) get_address_as_chunk;
- this->public.get_port = (u_int16_t (*) (host_t *))get_port;
- this->public.ip_equals = (bool (*) (host_t *,host_t *)) ip_equals;
- this->public.equals = (bool (*) (host_t *,host_t *)) equals;
- this->public.is_default_route = (bool (*) (host_t *)) is_default_route;
- this->public.destroy = (void (*) (host_t*))destroy;
-
- this->string = NULL;
-
- return this;
-}
-
-/*
- * Described in header.
- */
-host_t *host_create(int family, char *address, u_int16_t port)
-{
- private_host_t *this = host_create_empty();
-
- this->family = family;
-
- switch (family)
- {
- /* IPv4 */
- case AF_INET:
- {
- this->address4.sin_family = AF_INET;
- this->address4.sin_addr.s_addr = inet_addr(address);
- this->address4.sin_port = htons(port);
- this->socklen = sizeof(struct sockaddr_in);
- return &(this->public);
- }
- default:
- {
- allocator_free(this);
- return NULL;
-
- }
- }
-
-}
-
-/*
- * Described in header.
- */
-host_t *host_create_from_chunk(int family, chunk_t address, u_int16_t port)
-{
- private_host_t *this = host_create_empty();
-
- this->family = family;
- switch (family)
- {
- /* IPv4 */
- case AF_INET:
- {
- if (address.len != 4)
- {
- break;
- }
- this->address4.sin_family = AF_INET;
- memcpy(&(this->address4.sin_addr.s_addr),address.ptr,4);
- this->address4.sin_port = htons(port);
- this->socklen = sizeof(struct sockaddr_in);
- return &(this->public);
- }
- }
- allocator_free(this);
- return NULL;
-}
-
-/*
- * Described in header.
- */
-host_t *host_create_from_sockaddr(sockaddr_t *sockaddr)
-{
- chunk_t address;
-
- switch (sockaddr->sa_family)
- {
- /* IPv4 */
- case AF_INET:
- {
- struct sockaddr_in *sin = (struct sockaddr_in *)sockaddr;
- address.ptr = (void*)&(sin->sin_addr.s_addr);
- address.len = 4;
- return host_create_from_chunk(AF_INET, address, ntohs(sin->sin_port));
- }
- default:
- return NULL;
- }
-}
-
diff --git a/Source/charon/network/host.h b/Source/charon/network/host.h
deleted file mode 100644
index d81efffa6..000000000
--- a/Source/charon/network/host.h
+++ /dev/null
@@ -1,225 +0,0 @@
-/**
- * @file host.h
- *
- * @brief Interface of host_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef HOST_H_
-#define HOST_H_
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <linux/xfrm.h>
-
-#include <types.h>
-
-
-typedef struct host_t host_t;
-
-/**
- * @brief Representates a Host
- *
- * Host object, identifies a address:port pair and defines some
- * useful functions on it.
- *
- * @b Constructors:
- * - host_create()
- * - host_create_from_chunk()
- * - host_create_from_sockaddr()
- *
- * @todo Add IPv6 support
- *
- * @ingroup network
- */
-struct host_t {
-
- /**
- * @brief Build a clone of this host object.
- *
- * @param this object to clone
- * @return cloned host
- */
- host_t *(*clone) (host_t *this);
-
- /**
- * @brief Get a pointer to the internal sockaddr struct.
- *
- * This is used for sending and receiving via sockets.
- *
- * @param this object to clone
- * @return pointer to the internal sockaddr structure
- */
- sockaddr_t *(*get_sockaddr) (host_t *this);
-
- /**
- * @brief Get the length of the sockaddr struct.
- *
- * Sepending on the family, the length of the sockaddr struct
- * is different. Use this function to get the length of the sockaddr
- * struct returned by get_sock_addr.
- *
- * This is used for sending and receiving via sockets.
- *
- * @param this object to clone
- * @return length of the sockaddr struct
- */
- socklen_t *(*get_sockaddr_len) (host_t *this);
-
- /**
- * @brief Gets the address as xfrm_address_t.
- *
- * This function allows the conversion to an
- * xfrm_address_t, used for netlink communication
- * with the kernel.
- *
- * @see kernel_interface_t.
- *
- * @param this calling object
- * @return address in xfrm_address_t format
- */
- xfrm_address_t (*get_xfrm_addr) (host_t *this);
-
- /**
- * @brief Gets the family of the address
- *
- * @param this calling object
- * @return family
- */
- int (*get_family) (host_t *this);
-
- /**
- * @brief get the address of this host
- *
- * Mostly used for debugging purposes.
- * @warning string must NOT be freed
- *
- * @param this object
- * @return address string,
- */
- char* (*get_address) (host_t *this);
-
- /**
- * @brief Checks if the ip address of host is set to default route.
- *
- * @param this calling object
- * @return
- * - TRUE if host has IP 0.0.0.0 for default route
- * - FALSE otherwise
- */
- bool (*is_default_route) (host_t *this);
-
- /**
- * @brief get the address of this host as chunk_t
- *
- * @warning returned chunk has to get destroyed by caller.
- *
- * @param this object
- * @return address string,
- */
- chunk_t (*get_address_as_chunk) (host_t *this);
-
- /**
- * @brief get the port of this host
- *
- * Mostly used for debugging purposes.
- *
- * @param this object to clone
- * @return port number
- */
- u_int16_t (*get_port) (host_t *this);
-
- /**
- * @brief Compare the ips of two hosts hosts.
- *
- * @param this object to compare
- * @param other the other to compare
- * @return TRUE if addresses are equal.
- */
- bool (*ip_equals) (host_t *this, host_t *other);
-
- /**
- * @brief Compare two hosts, with port.
- *
- * @param this object to compare
- * @param other the other to compare
- * @return TRUE if addresses and ports are equal.
- */
- bool (*equals) (host_t *this, host_t *other);
-
- /**
- * @brief Destroy this host object
- *
- * @param this calling
- * @return SUCCESS in any case
- */
- void (*destroy) (host_t *this);
-};
-
-/**
- * @brief Constructor to create a host_t object from an address string
- *
- * Currently supports only IPv4!
- *
- * @param family Address family to use for this object, such as AF_INET or AF_INET6
- * @param address string of an address, such as "152.96.193.130"
- * @param port port number
- * @return
- * - host_t object
- * - NULL, if family not supported.
- *
- * @ingroup network
- */
-host_t *host_create(int family, char *address, u_int16_t port);
-
-/**
- * @brief Constructor to create a host_t object from an address chunk
- *
- * Currently supports only IPv4!
- *
- * @param family Address family to use for this object, such as AF_INET or AF_INET6
- * @param address address as 4 byte chunk_t in networ order
- * @param port port number
- * @return
- * - host_t object
- * - NULL, if family not supported or chunk_t length not 4 bytes.
- *
- * @ingroup network
- */
-host_t *host_create_from_chunk(int family, chunk_t address, u_int16_t port);
-
-/**
- * @brief Constructor to create a host_t object from a sockaddr struct
- *
- * Currently supports only IPv4!
- *
- * @param sockaddr sockaddr struct which contains family, address and port
- * @return
- * - host_t object
- * - NULL, if family not supported.
- *
- * @ingroup network
- */
-host_t *host_create_from_sockaddr(sockaddr_t *sockaddr);
-
-
-#endif /*HOST_H_*/
diff --git a/Source/charon/network/packet.h b/Source/charon/network/packet.h
index ddebf5f9b..a2620d391 100644
--- a/Source/charon/network/packet.h
+++ b/Source/charon/network/packet.h
@@ -25,7 +25,7 @@
#include <types.h>
-#include <network/host.h>
+#include <utils/host.h>
typedef struct packet_t packet_t;
diff --git a/Source/charon/queues/Makefile.queues b/Source/charon/queues/Makefile.queues
index 8f671d899..eeb012d2b 100644
--- a/Source/charon/queues/Makefile.queues
+++ b/Source/charon/queues/Makefile.queues
@@ -12,17 +12,17 @@
# for more details.
#
-QUEUES_DIR= $(MAIN_DIR)queues/
+QUEUES_DIR= $(CHARON_DIR)queues/
-OBJS+= $(BUILD_DIR)event_queue.o
+CHARON_OBJS+= $(BUILD_DIR)event_queue.o
$(BUILD_DIR)event_queue.o : $(QUEUES_DIR)event_queue.c $(QUEUES_DIR)event_queue.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)job_queue.o
+CHARON_OBJS+= $(BUILD_DIR)job_queue.o
$(BUILD_DIR)job_queue.o : $(QUEUES_DIR)job_queue.c $(QUEUES_DIR)job_queue.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)send_queue.o
+CHARON_OBJS+= $(BUILD_DIR)send_queue.o
$(BUILD_DIR)send_queue.o : $(QUEUES_DIR)send_queue.c $(QUEUES_DIR)send_queue.h
$(CC) $(CFLAGS) -c -o $@ $<
diff --git a/Source/charon/queues/jobs/Makefile.jobs b/Source/charon/queues/jobs/Makefile.jobs
index 658dd1293..db89987bc 100644
--- a/Source/charon/queues/jobs/Makefile.jobs
+++ b/Source/charon/queues/jobs/Makefile.jobs
@@ -14,27 +14,27 @@
JOBS_DIR= $(QUEUES_DIR)jobs/
-OBJS+= $(BUILD_DIR)delete_half_open_ike_sa_job.o
+CHARON_OBJS+= $(BUILD_DIR)delete_half_open_ike_sa_job.o
$(BUILD_DIR)delete_half_open_ike_sa_job.o : $(JOBS_DIR)delete_half_open_ike_sa_job.c $(JOBS_DIR)delete_half_open_ike_sa_job.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)delete_established_ike_sa_job.o
+CHARON_OBJS+= $(BUILD_DIR)delete_established_ike_sa_job.o
$(BUILD_DIR)delete_established_ike_sa_job.o : $(JOBS_DIR)delete_established_ike_sa_job.c $(JOBS_DIR)delete_established_ike_sa_job.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)incoming_packet_job.o
+CHARON_OBJS+= $(BUILD_DIR)incoming_packet_job.o
$(BUILD_DIR)incoming_packet_job.o : $(JOBS_DIR)incoming_packet_job.c $(JOBS_DIR)incoming_packet_job.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)initiate_ike_sa_job.o
+CHARON_OBJS+= $(BUILD_DIR)initiate_ike_sa_job.o
$(BUILD_DIR)initiate_ike_sa_job.o : $(JOBS_DIR)initiate_ike_sa_job.c $(JOBS_DIR)initiate_ike_sa_job.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)retransmit_request_job.o
+CHARON_OBJS+= $(BUILD_DIR)retransmit_request_job.o
$(BUILD_DIR)retransmit_request_job.o : $(JOBS_DIR)retransmit_request_job.c $(JOBS_DIR)retransmit_request_job.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)job.o
+CHARON_OBJS+= $(BUILD_DIR)job.o
$(BUILD_DIR)job.o : $(JOBS_DIR)job.c $(JOBS_DIR)job.h
$(CC) $(CFLAGS) -c -o $@ $<
\ No newline at end of file
diff --git a/Source/charon/sa/Makefile.sa b/Source/charon/sa/Makefile.sa
index 4c3e11bbc..825c19959 100644
--- a/Source/charon/sa/Makefile.sa
+++ b/Source/charon/sa/Makefile.sa
@@ -12,25 +12,25 @@
# for more details.
#
-SA_DIR= $(MAIN_DIR)sa/
+SA_DIR= $(CHARON_DIR)sa/
-OBJS+= $(BUILD_DIR)ike_sa_id.o
+CHARON_OBJS+= $(BUILD_DIR)ike_sa_id.o
$(BUILD_DIR)ike_sa_id.o : $(SA_DIR)ike_sa_id.c $(SA_DIR)ike_sa_id.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)ike_sa_manager.o
+CHARON_OBJS+= $(BUILD_DIR)ike_sa_manager.o
$(BUILD_DIR)ike_sa_manager.o : $(SA_DIR)ike_sa_manager.c $(SA_DIR)ike_sa_manager.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)ike_sa.o
+CHARON_OBJS+= $(BUILD_DIR)ike_sa.o
$(BUILD_DIR)ike_sa.o : $(SA_DIR)ike_sa.c $(SA_DIR)ike_sa.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)authenticator.o
+CHARON_OBJS+= $(BUILD_DIR)authenticator.o
$(BUILD_DIR)authenticator.o : $(SA_DIR)authenticator.c $(SA_DIR)authenticator.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)child_sa.o
+CHARON_OBJS+= $(BUILD_DIR)child_sa.o
$(BUILD_DIR)child_sa.o : $(SA_DIR)child_sa.c $(SA_DIR)child_sa.h
$(CC) $(CFLAGS) -c -o $@ $<
diff --git a/Source/charon/sa/child_sa.h b/Source/charon/sa/child_sa.h
index 34542274c..96978dae3 100644
--- a/Source/charon/sa/child_sa.h
+++ b/Source/charon/sa/child_sa.h
@@ -25,7 +25,7 @@
#define CHILD_SA_H_
#include <types.h>
-#include <transforms/prf_plus.h>
+#include <crypto/prf_plus.h>
#include <encoding/payloads/proposal_substructure.h>
typedef struct child_sa_t child_sa_t;
diff --git a/Source/charon/sa/ike_sa.c b/Source/charon/sa/ike_sa.c
index 89f3fff29..43de291d1 100644
--- a/Source/charon/sa/ike_sa.c
+++ b/Source/charon/sa/ike_sa.c
@@ -29,9 +29,9 @@
#include <utils/linked_list.h>
#include <utils/logger_manager.h>
#include <utils/randomizer.h>
-#include <transforms/diffie_hellman.h>
-#include <transforms/prf_plus.h>
-#include <transforms/crypters/crypter.h>
+#include <crypto/diffie_hellman.h>
+#include <crypto/prf_plus.h>
+#include <crypto/crypters/crypter.h>
#include <encoding/payloads/sa_payload.h>
#include <encoding/payloads/nonce_payload.h>
#include <encoding/payloads/ke_payload.h>
diff --git a/Source/charon/sa/ike_sa.h b/Source/charon/sa/ike_sa.h
index 16c0111f6..92c73391f 100644
--- a/Source/charon/sa/ike_sa.h
+++ b/Source/charon/sa/ike_sa.h
@@ -32,9 +32,9 @@
#include <config/configuration.h>
#include <utils/logger.h>
#include <utils/randomizer.h>
-#include <transforms/prfs/prf.h>
-#include <transforms/crypters/crypter.h>
-#include <transforms/signers/signer.h>
+#include <crypto/prfs/prf.h>
+#include <crypto/crypters/crypter.h>
+#include <crypto/signers/signer.h>
#include <config/connection.h>
#include <config/policy.h>
diff --git a/Source/charon/sa/states/Makefile.states b/Source/charon/sa/states/Makefile.states
index 69517ea96..a258ebef0 100644
--- a/Source/charon/sa/states/Makefile.states
+++ b/Source/charon/sa/states/Makefile.states
@@ -14,30 +14,30 @@
STATES_DIR= $(SA_DIR)states/
-OBJS+= $(BUILD_DIR)ike_auth_requested.o
+CHARON_OBJS+= $(BUILD_DIR)ike_auth_requested.o
$(BUILD_DIR)ike_auth_requested.o : $(STATES_DIR)ike_auth_requested.c $(STATES_DIR)ike_auth_requested.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)ike_sa_established.o
+CHARON_OBJS+= $(BUILD_DIR)ike_sa_established.o
$(BUILD_DIR)ike_sa_established.o : $(STATES_DIR)ike_sa_established.c $(STATES_DIR)ike_sa_established.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)ike_sa_init_requested.o
+CHARON_OBJS+= $(BUILD_DIR)ike_sa_init_requested.o
$(BUILD_DIR)ike_sa_init_requested.o : $(STATES_DIR)ike_sa_init_requested.c $(STATES_DIR)ike_sa_init_requested.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)ike_sa_init_responded.o
+CHARON_OBJS+= $(BUILD_DIR)ike_sa_init_responded.o
$(BUILD_DIR)ike_sa_init_responded.o : $(STATES_DIR)ike_sa_init_responded.c $(STATES_DIR)ike_sa_init_responded.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)initiator_init.o
+CHARON_OBJS+= $(BUILD_DIR)initiator_init.o
$(BUILD_DIR)initiator_init.o : $(STATES_DIR)initiator_init.c $(STATES_DIR)initiator_init.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)responder_init.o
+CHARON_OBJS+= $(BUILD_DIR)responder_init.o
$(BUILD_DIR)responder_init.o : $(STATES_DIR)responder_init.c $(STATES_DIR)responder_init.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)state.o
+CHARON_OBJS+= $(BUILD_DIR)state.o
$(BUILD_DIR)state.o : $(STATES_DIR)state.c $(STATES_DIR)state.h
$(CC) $(CFLAGS) -c -o $@ $< \ No newline at end of file
diff --git a/Source/charon/sa/states/ike_auth_requested.c b/Source/charon/sa/states/ike_auth_requested.c
index 16eea7b03..b037cfcd9 100644
--- a/Source/charon/sa/states/ike_auth_requested.c
+++ b/Source/charon/sa/states/ike_auth_requested.c
@@ -29,8 +29,8 @@
#include <encoding/payloads/id_payload.h>
#include <encoding/payloads/auth_payload.h>
#include <encoding/payloads/notify_payload.h>
-#include <transforms/signers/signer.h>
-#include <transforms/crypters/crypter.h>
+#include <crypto/signers/signer.h>
+#include <crypto/crypters/crypter.h>
#include <sa/states/ike_sa_established.h>
#include <sa/authenticator.h>
#include <sa/child_sa.h>
diff --git a/Source/charon/sa/states/ike_sa_init_requested.c b/Source/charon/sa/states/ike_sa_init_requested.c
index a5b7fbcbd..8d3ae55ed 100644
--- a/Source/charon/sa/states/ike_sa_init_requested.c
+++ b/Source/charon/sa/states/ike_sa_init_requested.c
@@ -31,7 +31,7 @@
#include <encoding/payloads/id_payload.h>
#include <encoding/payloads/auth_payload.h>
#include <encoding/payloads/ts_payload.h>
-#include <transforms/diffie_hellman.h>
+#include <crypto/diffie_hellman.h>
#include <sa/states/ike_auth_requested.h>
#include <sa/states/initiator_init.h>
#include <sa/authenticator.h>
diff --git a/Source/charon/sa/states/ike_sa_init_requested.h b/Source/charon/sa/states/ike_sa_init_requested.h
index 1fe0a6d1d..0a43afad1 100644
--- a/Source/charon/sa/states/ike_sa_init_requested.h
+++ b/Source/charon/sa/states/ike_sa_init_requested.h
@@ -27,7 +27,7 @@
#include <types.h>
#include <sa/ike_sa.h>
#include <sa/states/state.h>
-#include <transforms/diffie_hellman.h>
+#include <crypto/diffie_hellman.h>
typedef struct ike_sa_init_requested_t ike_sa_init_requested_t;
diff --git a/Source/charon/sa/states/ike_sa_init_responded.c b/Source/charon/sa/states/ike_sa_init_responded.c
index eef8ea3c4..52548749a 100644
--- a/Source/charon/sa/states/ike_sa_init_responded.c
+++ b/Source/charon/sa/states/ike_sa_init_responded.c
@@ -31,8 +31,8 @@
#include <encoding/payloads/id_payload.h>
#include <encoding/payloads/auth_payload.h>
#include <encoding/payloads/notify_payload.h>
-#include <transforms/signers/signer.h>
-#include <transforms/crypters/crypter.h>
+#include <crypto/signers/signer.h>
+#include <crypto/crypters/crypter.h>
#include <sa/states/ike_sa_established.h>
diff --git a/Source/charon/sa/states/initiator_init.c b/Source/charon/sa/states/initiator_init.c
index 18ffe0e0a..85885130f 100644
--- a/Source/charon/sa/states/initiator_init.c
+++ b/Source/charon/sa/states/initiator_init.c
@@ -28,7 +28,7 @@
#include <sa/states/ike_sa_init_requested.h>
#include <utils/allocator.h>
#include <queues/jobs/retransmit_request_job.h>
-#include <transforms/diffie_hellman.h>
+#include <crypto/diffie_hellman.h>
#include <encoding/payloads/sa_payload.h>
#include <encoding/payloads/ke_payload.h>
#include <encoding/payloads/nonce_payload.h>
@@ -92,7 +92,7 @@ struct private_initiator_init_t {
* @param this calling object
* @param request message_t object to add the NONCE payload
*/
- void (*build_nonce_payload) (private_initiator_init_t *this,message_t *request);
+ status_t (*build_nonce_payload) (private_initiator_init_t *this,message_t *request);
/**
* Destroy function called internally of this class after state change to state
@@ -177,9 +177,14 @@ status_t retry_initiate_connection (private_initiator_init_t *this, diffie_hellm
this->build_ke_payload(this, message);
/* build Nonce payload */
- this->build_nonce_payload(this,message);
-
-
+ status = this->build_nonce_payload(this, message);
+ if (status != SUCCESS)
+ {
+ this->logger->log(this->logger, ERROR, "Building nonce payload failed. Aborting");
+ message->destroy(message);
+ return DELETE_ME;
+ }
+
/* message can now be sent (must not be destroyed) */
status = this->ike_sa->send_request(this->ike_sa, message);
if (status != SUCCESS)
@@ -251,17 +256,22 @@ static void build_ke_payload(private_initiator_init_t *this, message_t *request)
/**
* Implementation of private_initiator_init_t.build_nonce_payload.
*/
-static void build_nonce_payload(private_initiator_init_t *this, message_t *request)
+static status_t build_nonce_payload(private_initiator_init_t *this, message_t *request)
{
nonce_payload_t *nonce_payload;
randomizer_t *randomizer;
+ status_t status;
this->logger->log(this->logger, CONTROL|LEVEL1, "Building NONCE payload");
this->logger->log(this->logger, CONTROL|LEVEL2, "Get pseudo random bytes for NONCE");
randomizer = this->ike_sa->get_randomizer(this->ike_sa);
- randomizer->allocate_pseudo_random_bytes(randomizer, NONCE_SIZE, &(this->sent_nonce));
+ status = randomizer->allocate_pseudo_random_bytes(randomizer, NONCE_SIZE, &(this->sent_nonce));
+ if (status != SUCCESS)
+ {
+ return status;
+ }
this->logger->log(this->logger, RAW|LEVEL2, "Initiator NONCE",&(this->sent_nonce));
@@ -271,6 +281,7 @@ static void build_nonce_payload(private_initiator_init_t *this, message_t *reque
this->logger->log(this->logger, CONTROL|LEVEL2, "Add NONCE payload to message");
request->add_payload(request, (payload_t *) nonce_payload);
+ return SUCCESS;
}
/**
diff --git a/Source/charon/sa/states/responder_init.c b/Source/charon/sa/states/responder_init.c
index 2710080a0..32aa6db86 100644
--- a/Source/charon/sa/states/responder_init.c
+++ b/Source/charon/sa/states/responder_init.c
@@ -30,7 +30,7 @@
#include <encoding/payloads/ke_payload.h>
#include <encoding/payloads/nonce_payload.h>
#include <encoding/payloads/notify_payload.h>
-#include <transforms/diffie_hellman.h>
+#include <crypto/diffie_hellman.h>
typedef struct private_responder_init_t private_responder_init_t;
@@ -428,6 +428,7 @@ static status_t build_nonce_payload(private_responder_init_t *this,nonce_payload
{
nonce_payload_t *nonce_payload;
randomizer_t *randomizer;
+ status_t status;
this->logger->log(this->logger, CONTROL | LEVEL2, "Process received NONCE payload");
allocator_free(this->received_nonce.ptr);
@@ -439,7 +440,11 @@ static status_t build_nonce_payload(private_responder_init_t *this,nonce_payload
this->logger->log(this->logger, CONTROL | LEVEL2, "Create new NONCE value.");
randomizer = this->ike_sa->get_randomizer(this->ike_sa);
- randomizer->allocate_pseudo_random_bytes(randomizer, NONCE_SIZE, &(this->sent_nonce));
+ status = randomizer->allocate_pseudo_random_bytes(randomizer, NONCE_SIZE, &(this->sent_nonce));
+ if (status != SUCCESS)
+ {
+ return status;
+ }
this->logger->log(this->logger, CONTROL|LEVEL2, "Building NONCE payload");
nonce_payload = nonce_payload_create();
diff --git a/Source/charon/stroke.c b/Source/charon/stroke.c
deleted file mode 100644
index 5062c26f7..000000000
--- a/Source/charon/stroke.c
+++ /dev/null
@@ -1,304 +0,0 @@
-/* Stroke for charon is the counterpart to whack from pluto
- * Copyright (C) 2006 Martin Willi - Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/fcntl.h>
-#include <unistd.h>
-#include <dirent.h>
-#include <errno.h>
-#include <stdio.h>
-#include <linux/stddef.h>
-
-#include "stroke.h"
-
-static char* push_string(stroke_msg_t **strm, char *string)
-{
- stroke_msg_t *stroke_msg;
- size_t string_length;
-
- if (string == NULL)
- {
- return NULL;
- }
- stroke_msg = *strm;
- string_length = strlen(string) + 1;
- stroke_msg->length += string_length;
-
- stroke_msg = realloc(stroke_msg, stroke_msg->length);
- strcpy((char*)stroke_msg + stroke_msg->length - string_length, string);
-
- *strm = stroke_msg;
- return (char*)(u_int)stroke_msg->length - string_length;
-}
-
-static int send_stroke_msg (stroke_msg_t *msg)
-{
- struct sockaddr_un ctl_addr = { AF_UNIX, STROKE_SOCKET };
- int sock;
- char buffer[64];
- int byte_count;
-
- sock = socket(AF_UNIX, SOCK_STREAM, 0);
- if (sock < 0)
- {
- fprintf(stderr, "Opening unix socket %s: %s\n", STROKE_SOCKET, strerror(errno));
- return -1;
- }
- if (connect(sock, (struct sockaddr *)&ctl_addr,
- offsetof(struct sockaddr_un, sun_path) + strlen(ctl_addr.sun_path)) < 0)
- {
- fprintf(stderr, "Connect to socket failed: %s\n", strerror(errno));
- close(sock);
- return -1;
- }
-
- /* send message */
- if (write(sock, msg, msg->length) != msg->length)
- {
- fprintf(stderr, "writing to socket failed: %s\n", strerror(errno));
- close(sock);
- return -1;
- }
-
- while ((byte_count = read(sock, buffer, sizeof(buffer)-1)) > 0)
- {
- buffer[byte_count] = '\0';
- printf("%s", buffer);
- }
- if (byte_count < 0)
- {
- fprintf(stderr, "reading from socket failed: %s\n", strerror(errno));
- }
-
- close(sock);
- return 0;
-}
-
-static int add_connection(char *name,
- char *my_id, char *other_id,
- char *my_cert, char *other_cert,
- char *my_addr, char *other_addr,
- char *my_net, char *other_net,
- u_int my_netmask, u_int other_netmask)
-{
- stroke_msg_t *msg = malloc(sizeof(stroke_msg_t));
- int res;
-
- msg->length = sizeof(stroke_msg_t);
- msg->type = STR_ADD_CONN;
-
- msg->add_conn.name = push_string(&msg, name);
-
- msg->add_conn.me.id = push_string(&msg, my_id);
- msg->add_conn.me.cert = push_string(&msg, my_cert);
- msg->add_conn.me.address = push_string(&msg, my_addr);
- msg->add_conn.me.subnet = push_string(&msg, my_net);
- msg->add_conn.me.subnet_mask = my_netmask;
-
- msg->add_conn.other.id = push_string(&msg, other_id);
- msg->add_conn.other.cert = push_string(&msg, other_cert);
- msg->add_conn.other.address = push_string(&msg, other_addr);
- msg->add_conn.other.subnet = push_string(&msg, other_net);
- msg->add_conn.other.subnet_mask = other_netmask;
-
- res = send_stroke_msg(msg);
- free(msg);
- return res;
-}
-
-static int initiate_connection(char *name)
-{
- stroke_msg_t *msg = malloc(sizeof(stroke_msg_t));
- int res;
-
- msg->length = sizeof(stroke_msg_t);
- msg->type = STR_INITIATE;
- msg->initiate.name = push_string(&msg, name);
- res = send_stroke_msg(msg);
- free(msg);
- return res;
-}
-
-static int terminate_connection(char *name)
-{
- stroke_msg_t *msg = malloc(sizeof(stroke_msg_t));
- int res;
-
- msg->length = sizeof(stroke_msg_t);
- msg->type = STR_TERMINATE;
- msg->initiate.name = push_string(&msg, name);
- res = send_stroke_msg(msg);
- free(msg);
- return res;
-}
-
-static int show_status()
-{
- stroke_msg_t *msg = malloc(sizeof(stroke_msg_t));
- int res;
-
- msg->length = sizeof(stroke_msg_t);
- msg->type = STR_STATUS;
- res = send_stroke_msg(msg);
- free(msg);
- return res;
-}
-
-static int set_logtype(char *context, char *type, int enable)
-{
- stroke_msg_t *msg = malloc(sizeof(stroke_msg_t));
- int res;
-
- msg->length = sizeof(stroke_msg_t);
- msg->type = STR_LOGTYPE;
- msg->logtype.context = push_string(&msg, context);
- msg->logtype.type = push_string(&msg, type);
- msg->logtype.enable = enable;
- res = send_stroke_msg(msg);
- free(msg);
- return res;
-}
-
-static int set_loglevel(char *context, u_int level)
-{
- stroke_msg_t *msg = malloc(sizeof(stroke_msg_t));
- int res;
-
- msg->length = sizeof(stroke_msg_t);
- msg->type = STR_LOGLEVEL;
- msg->loglevel.context = push_string(&msg, context);
- msg->loglevel.level = level;
- res = send_stroke_msg(msg);
- free(msg);
- return res;
-}
-
-static void exit_error(char *error)
-{
- if (error)
- {
- fprintf(stderr, "%s\n", error);
- }
- exit(-1);
-}
-
-static void exit_usage(char *error)
-{
- printf("Usage:\n");
- printf(" Add a connection:\n");
- printf(" stroke add NAME MY_ID OTHER_ID MY_CERT OTHER_CERT\\\n");
- printf(" MY_ADDR OTHER_ADDR MY_NET OTHER_NET\\\n");
- printf(" MY_NETBITS OTHER_NETBITS\n");
- printf(" where: ID is any IKEv2 ID (currently only IPv4 adresses\n");
- printf(" CERT is a certificate filename\n");
- printf(" ADDR is a IPv4 address\n");
- printf(" NET is a IPv4 address of the subnet to tunnel\n");
- printf(" NETBITS is the size of the subnet, as the \"24\" in 192.168.0.0/24\n");
- printf(" Initiate a connection:\n");
- printf(" stroke up NAME\n");
- printf(" where: NAME is a connection name added with \"stroke add\"\n");
- printf(" Terminate a connection:\n");
- printf(" stroke down NAME\n");
- printf(" where: NAME is a connection name added with \"stroke add\"\n");
- printf(" Set logtype for a logging context:\n");
- printf(" stroke logtype CONTEXT TYPE ENABLE\n");
- printf(" where: CONTEXT is PARSR|GNRAT|IKESA|SAMGR|CHDSA|MESSG|TPOOL|WORKR|SCHED|\n");
- printf(" SENDR|RECVR|SOCKT|TESTR|DAEMN|CONFG|ENCPL|PAYLD\n");
- printf(" TYPE is CONTROL|ERROR|AUDIT|RAW|PRIVATE\n");
- printf(" ENABLE is 0|1\n");
- printf(" Set loglevel for a logging context:\n");
- printf(" stroke loglevel CONTEXT LEVEL\n");
- printf(" where: CONTEXT is PARSR|GNRAT|IKESA|SAMGR|CHDSA|MESSG|TPOOL|WORKR|SCHED|\n");
- printf(" SENDR|RECVR|SOCKT|TESTR|DAEMN|CONFG|ENCPL|PAYLD\n");
- printf(" LEVEL is 0|1|2|3\n");
- printf(" Show connection status:\n");
- printf(" stroke status\n");
- exit_error(error);
-}
-
-int main(int argc, char *argv[])
-{
- int res;
-
- if (argc < 2)
- {
- exit_usage(NULL);
- }
-
- if (strcmp(argv[1], "status") == 0 ||
- strcmp(argv[1], "statusall") == 0)
- {
- res = show_status();
- }
-
- else if (strcmp(argv[1], "up") == 0)
- {
- if (argc < 3)
- {
- exit_usage("\"up\" needs a connection name");
- }
- res = initiate_connection(argv[2]);
- }
- else if (strcmp(argv[1], "down") == 0)
- {
- if (argc < 3)
- {
- exit_usage("\"down\" needs a connection name");
- }
- res = terminate_connection(argv[2]);
- }
- else if (strcmp(argv[1], "add") == 0)
- {
- if (argc < 13)
- {
- exit_usage("\"add\" needs more parameters...");
- }
- res = add_connection(argv[2],
- argv[3], argv[4],
- argv[5], argv[6],
- argv[7], argv[8],
- argv[9], argv[10],
- atoi(argv[11]), atoi(argv[12]));
- }
- else if (strcmp(argv[1], "logtype") == 0)
- {
- if (argc < 5)
- {
- exit_usage("\"logtype\" needs more parameters...");
- }
- res = set_logtype(argv[2], argv[3], atoi(argv[4]));
- }
- else if (strcmp(argv[1], "loglevel") == 0)
- {
- if (argc < 4)
- {
- exit_usage("\"logtype\" needs more parameters...");
- }
- res = set_loglevel(argv[2], atoi(argv[3]));
- }
- else
- {
- exit_usage(NULL);
- }
-
- if (res)
- {
- exit_error("communication with charon failed!\n");
- }
- return 0;
-}
diff --git a/Source/charon/stroke.h b/Source/charon/stroke.h
deleted file mode 100644
index 2f756798d..000000000
--- a/Source/charon/stroke.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * @file stroke.h
- *
- * @brief Definition of stroke_msg_t.
- *
- */
-
-/*
- * Copyright (C) 2006 Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef STROKE_H_
-#define STROKE_H_
-
-#define STROKE_SOCKET "/var/run/charon.ctl"
-
-/**
- * @brief A stroke message sent over the unix socket.
- *
- */
-typedef struct stroke_msg_t stroke_msg_t;
-
-struct stroke_msg_t {
- /* length of this message with all strings */
- u_int16_t length;
- /* type of the message */
- enum {
- /* initiate a connection */
- STR_INITIATE,
- /* install SPD entries for a connection */
- STR_INSTALL,
- /* add a connection */
- STR_ADD_CONN,
- /* delete a connection */
- STR_DEL_CONN,
- /* terminate connection */
- STR_TERMINATE,
- /* show connection status */
- STR_STATUS,
- /* set a log type to log/not log */
- STR_LOGTYPE,
- /* set the verbosity of a logging context */
- STR_LOGLEVEL,
- /* more to come */
- } type;
- union {
- /* data for STR_INITIATE, STR_INSTALL, STR_UP, STR_DOWN */
- struct {
- char *name;
- } initiate, install, terminate;
- /* data for STR_ADD_CONN */
- struct {
- char *name;
- struct {
- char *id;
- char *cert;
- char *address;
- char *subnet;
- u_int8_t subnet_mask;
- } me, other;
- } add_conn;
- struct {
- char *context;
- char *type;
- int enable;
- } logtype;
- struct {
- char *context;
- u_int level;
- } loglevel;
- };
- u_int8_t buffer[];
-};
-
-#endif /* STROKE_H_ */
diff --git a/Source/charon/testcases/Makefile.testcases b/Source/charon/testcases/Makefile.testcases
deleted file mode 100644
index b6113fa06..000000000
--- a/Source/charon/testcases/Makefile.testcases
+++ /dev/null
@@ -1,142 +0,0 @@
-# Copyright (C) 2005 Jan Hutter, Martin Willi
-# Hochschule fuer Technik Rapperswil
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the
-# Free Software Foundation; either version 2 of the License, or (at your
-# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# for more details.
-#
-
-TESTCASES_DIR= $(MAIN_DIR)testcases/
-
-
-TEST_OBJS+= $(BUILD_DIR)aes_cbc_crypter_test.o
-$(BUILD_DIR)aes_cbc_crypter_test.o : $(TESTCASES_DIR)aes_cbc_crypter_test.c $(TESTCASES_DIR)aes_cbc_crypter_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-
-TEST_OBJS+= $(BUILD_DIR)diffie_hellman_test.o
-$(BUILD_DIR)diffie_hellman_test.o : $(TESTCASES_DIR)diffie_hellman_test.c $(TESTCASES_DIR)diffie_hellman_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)event_queue_test.o
-$(BUILD_DIR)event_queue_test.o : $(TESTCASES_DIR)event_queue_test.c $(TESTCASES_DIR)event_queue_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)generator_test.o
-$(BUILD_DIR)generator_test.o : $(TESTCASES_DIR)generator_test.c $(TESTCASES_DIR)generator_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)ike_sa_id_test.o
-$(BUILD_DIR)ike_sa_id_test.o : $(TESTCASES_DIR)ike_sa_id_test.c $(TESTCASES_DIR)ike_sa_id_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)job_queue_test.o
-$(BUILD_DIR)job_queue_test.o : $(TESTCASES_DIR)job_queue_test.c $(TESTCASES_DIR)job_queue_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)parser_test.o
-$(BUILD_DIR)parser_test.o : $(TESTCASES_DIR)parser_test.c $(TESTCASES_DIR)parser_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)hasher_test.o
-$(BUILD_DIR)hasher_test.o : $(TESTCASES_DIR)hasher_test.c $(TESTCASES_DIR)hasher_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)ike_sa_manager_test.o
-$(BUILD_DIR)ike_sa_manager_test.o : $(TESTCASES_DIR)ike_sa_manager_test.c $(TESTCASES_DIR)ike_sa_manager_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)linked_list_test.o
-$(BUILD_DIR)linked_list_test.o : $(TESTCASES_DIR)linked_list_test.c $(TESTCASES_DIR)linked_list_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)hmac_test.o
-$(BUILD_DIR)hmac_test.o : $(TESTCASES_DIR)hmac_test.c $(TESTCASES_DIR)hmac_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)hmac_signer_test.o
-$(BUILD_DIR)hmac_signer_test.o : $(TESTCASES_DIR)hmac_signer_test.c $(TESTCASES_DIR)hmac_signer_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)scheduler_test.o
-$(BUILD_DIR)scheduler_test.o : $(TESTCASES_DIR)scheduler_test.c $(TESTCASES_DIR)scheduler_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)prf_plus_test.o
-$(BUILD_DIR)prf_plus_test.o : $(TESTCASES_DIR)prf_plus_test.c $(TESTCASES_DIR)prf_plus_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)send_queue_test.o
-$(BUILD_DIR)send_queue_test.o : $(TESTCASES_DIR)send_queue_test.c $(TESTCASES_DIR)send_queue_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)socket_test.o
-$(BUILD_DIR)socket_test.o : $(TESTCASES_DIR)socket_test.c $(TESTCASES_DIR)socket_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)packet_test.o
-$(BUILD_DIR)packet_test.o : $(TESTCASES_DIR)packet_test.c $(TESTCASES_DIR)packet_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)testcases.o
-$(BUILD_DIR)testcases.o : $(TESTCASES_DIR)testcases.c
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)receiver_test.o
-$(BUILD_DIR)receiver_test.o : $(TESTCASES_DIR)receiver_test.c $(TESTCASES_DIR)receiver_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)ike_sa_test.o
-$(BUILD_DIR)ike_sa_test.o : $(TESTCASES_DIR)ike_sa_test.c $(TESTCASES_DIR)ike_sa_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)sender_test.o
-$(BUILD_DIR)sender_test.o : $(TESTCASES_DIR)sender_test.c $(TESTCASES_DIR)sender_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)thread_pool_test.o
-$(BUILD_DIR)thread_pool_test.o : $(TESTCASES_DIR)thread_pool_test.c $(TESTCASES_DIR)thread_pool_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)encryption_payload_test.o
-$(BUILD_DIR)encryption_payload_test.o : $(TESTCASES_DIR)encryption_payload_test.c $(TESTCASES_DIR)encryption_payload_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)connection_test.o
-$(BUILD_DIR)connection_test.o : $(TESTCASES_DIR)connection_test.c $(TESTCASES_DIR)connection_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)policy_test.o
-$(BUILD_DIR)policy_test.o : $(TESTCASES_DIR)policy_test.c $(TESTCASES_DIR)policy_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)proposal_test.o
-$(BUILD_DIR)proposal_test.o : $(TESTCASES_DIR)proposal_test.c $(TESTCASES_DIR)proposal_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)rsa_test.o
-$(BUILD_DIR)rsa_test.o : $(TESTCASES_DIR)rsa_test.c $(TESTCASES_DIR)rsa_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)kernel_interface_test.o
-$(BUILD_DIR)kernel_interface_test.o : $(TESTCASES_DIR)kernel_interface_test.c $(TESTCASES_DIR)kernel_interface_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)child_sa_test.o
-$(BUILD_DIR)child_sa_test.o : $(TESTCASES_DIR)child_sa_test.c $(TESTCASES_DIR)child_sa_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)der_decoder_test.o
-$(BUILD_DIR)der_decoder_test.o : $(TESTCASES_DIR)der_decoder_test.c $(TESTCASES_DIR)der_decoder_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-TEST_OBJS+= $(BUILD_DIR)certificate_test.o
-$(BUILD_DIR)certificate_test.o : $(TESTCASES_DIR)certificate_test.c $(TESTCASES_DIR)certificate_test.h
- $(CC) $(CFLAGS) -c -o $@ $<
- \ No newline at end of file
diff --git a/Source/charon/testcases/aes_cbc_crypter_test.c b/Source/charon/testcases/aes_cbc_crypter_test.c
deleted file mode 100644
index 1ea2983cd..000000000
--- a/Source/charon/testcases/aes_cbc_crypter_test.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/**
- * @file aes_cbc_crypter_test.c
- *
- * @brief Tests for the aes_cbc_crypter_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <string.h>
-
-#include "aes_cbc_crypter_test.h"
-
-#include <utils/allocator.h>
-#include <daemon.h>
-
-void test_aes_cbc_crypter(protected_tester_t *tester)
-{
- /*
- * Test 1 of RFC3602
- * Key : 0x06a9214036b8a15b512e03d534120006
- * IV : 0x3dafba429d9eb430b422da802c9fac41
- * Plaintext : "Single block msg"
- * Ciphertext: 0xe353779c1079aeb82708942dbe77181a
- */
- crypter_t *crypter;
- u_int8_t key1[] = {0x06,0xa9,0x21,0x40,0x36,0xb8,0xa1,0x5b,
- 0x51,0x2e,0x03,0xd5,0x34,0x12,0x00,0x06};
- chunk_t key1_chunk = {ptr: key1, len : 16};
- u_int8_t iv1[] = {0x3d,0xaf,0xba,0x42,0x9d,0x9e,0xb4,0x30,
- 0xb4,0x22,0xda,0x80,0x2c,0x9f,0xac,0x41};
- chunk_t iv1_chunk = {ptr: iv1, len : 16};
- u_int8_t ciphertext1[] = { 0xe3,0x53,0x77,0x9c,0x10,0x79,0xae,0xb8,
- 0x27,0x08,0x94,0x2d,0xbe,0x77,0x18,0x1a};
-
- chunk_t expected_encrypted1 = {ptr: ciphertext1, len : 16};
- char * plaintext1 = "Single block msg";
- chunk_t data1 = {ptr: plaintext1, len : 16};
- chunk_t encrypted1;
- chunk_t decrypted1;
- logger_t *logger;
-
- logger = charon->logger_manager->get_logger(charon->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");
- allocator_free_chunk(&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);
-
- allocator_free_chunk(&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");
- allocator_free_chunk(&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);
-
- allocator_free_chunk(&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");
- allocator_free_chunk(&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);
-
- allocator_free_chunk(&decrypted3);
-
- crypter->destroy(crypter);
-}
-
diff --git a/Source/charon/testcases/aes_cbc_crypter_test.h b/Source/charon/testcases/aes_cbc_crypter_test.h
deleted file mode 100644
index 611863636..000000000
--- a/Source/charon/testcases/aes_cbc_crypter_test.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * @file aes_cbc_crypter_test.h
- *
- * @brief Tests for the aes_cbc_crypter_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef AES_CBC_CRYPTER_TEST_H_
-#define AES_CBC_CRYPTER_TEST_H_
-
-#include <transforms/crypters/aes_cbc_crypter.h>
-#include <utils/tester.h>
-
-/**
- * @brief Test function used to test the aes_cbc_crypter_t class.
- *
- * @param tester associated tester object
- *
- * @ingroup testcases
- */
-void test_aes_cbc_crypter(protected_tester_t *tester);
-
-#endif /* AES_CBC_CRYPTER_TEST_H_ */
diff --git a/Source/charon/testcases/certificate_test.c b/Source/charon/testcases/certificate_test.c
deleted file mode 100644
index c950e0094..000000000
--- a/Source/charon/testcases/certificate_test.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- * @file certificate_test.c
- *
- * @brief Tests for the certificate_t class.
- *
- */
-
-/*
- * Copyright (C) 2006 Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "certificate_test.h"
-
-#include <daemon.h>
-#include <transforms/certificate.h>
-#include <utils/allocator.h>
-#include <utils/logger.h>
-
-
-
-static char certificate_buffer[] = {
- 0x30,0x82,0x02,0xf9,0x30,0x82,0x01,0xe1,0xa0,0x03,0x02,0x01,0x02,0x02,0x11,0x00,
- 0xfe,0xae,0xe3,0xcf,0x00,0x27,0x8d,0xa0,0xe1,0xfa,0xb2,0x07,0xd4,0x15,0x40,0x93,
- 0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x05,0x05,0x00,0x30,
- 0x38,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x43,0x48,0x31,0x19,
- 0x30,0x17,0x06,0x03,0x55,0x04,0x0a,0x13,0x10,0x4c,0x69,0x6e,0x75,0x78,0x20,0x73,
- 0x74,0x72,0x6f,0x6e,0x67,0x53,0x77,0x61,0x6e,0x31,0x0e,0x30,0x0c,0x06,0x03,0x55,
- 0x04,0x03,0x13,0x05,0x6d,0x61,0x65,0x6e,0x6f,0x30,0x1e,0x17,0x0d,0x30,0x36,0x30,
- 0x33,0x32,0x37,0x30,0x36,0x35,0x32,0x33,0x38,0x5a,0x17,0x0d,0x31,0x31,0x30,0x33,
- 0x32,0x36,0x30,0x36,0x35,0x32,0x33,0x38,0x5a,0x30,0x38,0x31,0x0b,0x30,0x09,0x06,
- 0x03,0x55,0x04,0x06,0x13,0x02,0x43,0x48,0x31,0x19,0x30,0x17,0x06,0x03,0x55,0x04,
- 0x0a,0x13,0x10,0x4c,0x69,0x6e,0x75,0x78,0x20,0x73,0x74,0x72,0x6f,0x6e,0x67,0x53,
- 0x77,0x61,0x6e,0x31,0x0e,0x30,0x0c,0x06,0x03,0x55,0x04,0x03,0x13,0x05,0x6d,0x61,
- 0x65,0x6e,0x6f,0x30,0x82,0x01,0x22,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,
- 0x0d,0x01,0x01,0x01,0x05,0x00,0x03,0x82,0x01,0x0f,0x00,0x30,0x82,0x01,0x0a,0x02,
- 0x82,0x01,0x01,0x00,0xe3,0x75,0x56,0xb9,0x68,0x46,0xa6,0x3e,0x6c,0x19,0x36,0xfb,
- 0x9a,0xb4,0xbc,0xc1,0x22,0x47,0xc0,0x00,0x8a,0x44,0x1c,0xa7,0x44,0x2e,0x73,0x50,
- 0xfc,0xd2,0x91,0x9c,0xaa,0xc3,0xa3,0x88,0x8c,0x4b,0x33,0xef,0x9a,0x52,0x89,0x9c,
- 0x8e,0x01,0x62,0x21,0x7a,0x75,0x5e,0xa3,0x3b,0xc0,0xb0,0x58,0xc0,0xc0,0xce,0x77,
- 0xe0,0x84,0x9a,0x9e,0xc1,0x51,0x71,0xc7,0xc4,0xa0,0x1e,0xf0,0x8e,0xb3,0x90,0x3e,
- 0xcd,0xe3,0x7d,0x8e,0x11,0x7b,0x92,0x5d,0x4a,0x37,0x3b,0x4b,0xb3,0x3d,0x58,0x9a,
- 0x8b,0x51,0x39,0x15,0xcd,0x27,0xd4,0x5b,0xad,0x5e,0xa5,0x07,0x94,0x29,0x0f,0x02,
- 0x0c,0x61,0x85,0x97,0x3b,0xc4,0xcf,0x5d,0x17,0x86,0x4d,0x96,0x5e,0x42,0xe9,0xf2,
- 0x72,0x2f,0xd4,0x58,0x4d,0x02,0xf8,0x0f,0xbd,0xe7,0x37,0xc8,0xa9,0x87,0xfe,0xab,
- 0x26,0x37,0x13,0x90,0x65,0x2d,0x51,0x41,0x18,0x18,0xdf,0x48,0x21,0x87,0x70,0x61,
- 0xcb,0x1b,0x62,0xad,0xaf,0x65,0xd2,0x29,0x27,0x93,0x58,0x7b,0xea,0x89,0xdd,0x58,
- 0x01,0x6d,0xeb,0x60,0xd8,0xc3,0x82,0x07,0x2c,0x67,0x39,0xc3,0x68,0xfc,0xcd,0xeb,
- 0xe9,0x7c,0x67,0xe3,0x1b,0x7a,0x50,0xf9,0x36,0x68,0xea,0xe2,0x15,0x01,0xee,0x99,
- 0xf2,0x52,0xe0,0x0a,0x8e,0x5f,0x63,0xb1,0x61,0x7a,0x38,0x88,0x07,0xae,0xb0,0x8d,
- 0x44,0x26,0xe8,0xce,0x1b,0x6f,0xcd,0x05,0x4b,0x94,0x9d,0xee,0xb5,0xeb,0x28,0xc4,
- 0x93,0x47,0xfd,0x47,0x40,0x45,0x58,0xc0,0x3e,0x44,0x74,0x7b,0x78,0x8d,0xc8,0x25,
- 0xc1,0xe1,0x0a,0x43,0x02,0x03,0x01,0x00,0x01,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,
- 0x86,0xf7,0x0d,0x01,0x01,0x05,0x05,0x00,0x03,0x82,0x01,0x01,0x00,0x77,0xfd,0xd2,
- 0x68,0x7e,0xb9,0xc2,0x40,0xb4,0xa3,0xea,0xe8,0x15,0x55,0x18,0xfe,0xe3,0x80,0xe0,
- 0x73,0xf9,0xe1,0xe5,0xe2,0x91,0xf5,0xa7,0xcb,0xdf,0xfb,0xc1,0x36,0xa6,0x55,0x6a,
- 0xd9,0x27,0xcd,0xef,0x64,0x30,0x70,0xd8,0x4b,0x72,0x7c,0xd1,0x9c,0x32,0xf8,0xb4,
- 0x15,0x7f,0xd7,0x79,0x0c,0x9f,0x24,0xf8,0x50,0xea,0xc7,0xd9,0xef,0x1f,0xf1,0x76,
- 0x3c,0x19,0xdb,0x61,0xb7,0x35,0x97,0xf9,0x03,0x87,0x42,0x77,0x23,0xd8,0xfe,0xd1,
- 0x74,0xf2,0x1e,0x95,0x87,0x5f,0x42,0x80,0x8e,0xee,0x6c,0x19,0x7b,0x2c,0x25,0xe6,
- 0xf9,0xdb,0x24,0x35,0x94,0x65,0x44,0xa0,0x56,0x6f,0x7f,0x57,0x2e,0x1a,0xcd,0xa6,
- 0xed,0x7f,0x42,0xf2,0x64,0xd4,0xf9,0x3f,0xc1,0x46,0xf6,0xc8,0xb1,0xb2,0x80,0x75,
- 0x3e,0xd1,0xa8,0x5e,0x07,0xd0,0x3b,0x35,0x81,0x49,0x93,0x77,0xd2,0xcf,0xf7,0xb6,
- 0xd0,0xeb,0xe5,0xf3,0x2c,0x03,0x52,0xc7,0x6d,0x02,0x26,0xa6,0xdc,0x39,0xcd,0x4d,
- 0x9e,0xca,0x99,0x01,0x01,0x73,0xd6,0x55,0x89,0x93,0x12,0xa0,0xc5,0xe6,0xa7,0x9a,
- 0xdc,0x5f,0x9f,0x5c,0x2c,0x2b,0xdb,0x23,0xa5,0xee,0x69,0x15,0x1f,0x3a,0xf1,0x76,
- 0x36,0xb5,0x77,0x18,0x57,0xff,0xff,0xf7,0x45,0x59,0xce,0x1b,0x0b,0x56,0xcb,0x09,
- 0x00,0x12,0x17,0xb8,0xa2,0x81,0x86,0x70,0x29,0x63,0x99,0x76,0xff,0x18,0x80,0x2b,
- 0x9b,0x5e,0x04,0xb1,0xcc,0xe4,0x15,0x90,0x29,0xa6,0x40,0xdd,0x85,0x38,0xd7,0xfe,
- 0x10,0xb5,0x97,0x6e,0x62,0x60,0xb9,0x02,0x67,0xef,0xf1,0xab,0xb3,
-};
-
-/**
- * Described in header.
- */
-void test_certificate(protected_tester_t *tester)
-{
- chunk_t certificate = {certificate_buffer, sizeof(certificate_buffer)};
-
- certificate_t *cert = certificate_create_from_chunk(certificate);
-
- //certificate_t *cert = certificate_create_from_file("myCert.der");
-
- cert->destroy(cert);
-}
diff --git a/Source/charon/testcases/certificate_test.h b/Source/charon/testcases/certificate_test.h
deleted file mode 100644
index 8dcbd0f93..000000000
--- a/Source/charon/testcases/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 <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-
-#ifndef CERTIFICATE_TEST_H_
-#define CERTIFICATE_TEST_H_
-
-#include <utils/tester.h>
-
-/**
- * @brief Test function used to test the certificate_t functionality.
- *
- * @param tester associated protected_tester_t object
- *
- * @ingroup testcases
- */
-void test_certificate(protected_tester_t *tester);
-
-#endif /* CERTIFICATE_TEST_H_ */
-
-
-
-
diff --git a/Source/charon/testcases/child_sa_test.c b/Source/charon/testcases/child_sa_test.c
deleted file mode 100644
index 0a3aec9f2..000000000
--- a/Source/charon/testcases/child_sa_test.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
- * @file child_sa_test.c
- *
- * @brief Tests for the child_sa_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "child_sa_test.h"
-
-#include <daemon.h>
-#include <sa/child_sa.h>
-#include <utils/allocator.h>
-#include <utils/logger.h>
-
-
-/**
- * Described in header.
- */
-void test_child_sa(protected_tester_t *tester)
-{
- proposal_t *proposal1, *proposal2;
- linked_list_t *list;
- host_t *local_me, *remote_me;
- host_t *local_other, *remote_other;
- child_sa_t *local_sa, *remote_sa;
- prf_plus_t *local_prf_plus, *remote_prf_plus;
- prf_t *local_prf, *remote_prf;
- u_int8_t key_buffer[] = {0x01,0x02,0x03,0x04};
- chunk_t key = {key_buffer, sizeof(key_buffer)};
- status_t status;
-
- /* setup test data */
- local_me = host_create(AF_INET, "192.168.0.1", 0);
- local_other = host_create(AF_INET, "192.168.0.2", 0);
- remote_me = host_create(AF_INET, "192.168.0.3", 0);
- remote_other = host_create(AF_INET, "192.168.0.4", 0);
-
- local_sa = child_sa_create(local_me, local_other);
- remote_sa = child_sa_create(remote_me, remote_other);
-
- proposal1 = proposal_create(1);
- proposal1->add_algorithm(proposal1, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 16);
-
- proposal2 = proposal_create(2);
- proposal2->add_algorithm(proposal2, PROTO_AH, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 0);
-
- list = linked_list_create();
- list->insert_last(list, proposal1);
- list->insert_last(list, proposal2);
-
- local_prf = prf_create(PRF_HMAC_SHA1);
- remote_prf = prf_create(PRF_HMAC_SHA1);
- local_prf->set_key(local_prf, key);
- remote_prf->set_key(remote_prf, key);
- local_prf_plus = prf_plus_create(local_prf, key);
- remote_prf_plus = prf_plus_create(remote_prf, key);
-
- /*
- * local plays initiator
- ***********************
- */
- status = local_sa->alloc(local_sa, list);
- tester->assert_true(tester, status == SUCCESS, "spi allocation");
-
- status = remote_sa->add(remote_sa, proposal1, remote_prf_plus);
- tester->assert_true(tester, status == SUCCESS, "sa add");
-
- status = local_sa->update(local_sa, proposal1, local_prf_plus);
- tester->assert_true(tester, status == SUCCESS, "sa update");
-
- /* cleanup */
- proposal1->destroy(proposal1);
- proposal2->destroy(proposal2);
- list->destroy(list);
- local_prf->destroy(local_prf);
- local_prf_plus->destroy(local_prf_plus);
- remote_prf->destroy(remote_prf);
- remote_prf_plus->destroy(remote_prf_plus);
- local_sa->destroy(local_sa);
- remote_sa->destroy(remote_sa);
- local_me->destroy(local_me);
- local_other->destroy(local_other);
- remote_me->destroy(remote_me);
- remote_other->destroy(remote_other);
-
-
-}
diff --git a/Source/charon/testcases/child_sa_test.h b/Source/charon/testcases/child_sa_test.h
deleted file mode 100644
index ef92499fe..000000000
--- a/Source/charon/testcases/child_sa_test.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * @file child_sa_test.h
- *
- * @brief Tests for the child_sa_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-
-#ifndef CHILD_SA_TEST_H_
-#define CHILD_SA_TEST_H_
-
-#include <utils/tester.h>
-
-/**
- * @brief Test function used to test the child_sa_t functionality.
- *
- * @param tester associated protected_tester_t object
- *
- * @ingroup testcases
- */
-void test_child_sa(protected_tester_t *tester);
-
-#endif /* CHILD_SA_TEST_H_ */
-
-
-
-
diff --git a/Source/charon/testcases/connection_test.c b/Source/charon/testcases/connection_test.c
deleted file mode 100644
index ae8ed3c04..000000000
--- a/Source/charon/testcases/connection_test.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * @file connection_test.c
- *
- * @brief Tests for the connection_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "connection_test.h"
-
-#include <config/connection.h>
-#include <utils/allocator.h>
-#include <transforms/prfs/prf.h>
-
-
-/**
- * Described in header.
- */
-void test_connection(protected_tester_t *tester)
-{
- host_t *alice = host_create(AF_INET, "192.168.0.1", 500);
- host_t *bob = host_create(AF_INET, "192.168.0.2", 500);
- identification_t *alice_id = identification_create_from_string(AF_INET, "192.168.0.1");
- identification_t *bob_id = identification_create_from_string(AF_INET, "192.168.0.2");
- connection_t *connection = connection_create(alice, bob, alice_id, bob_id, RSA_DIGITAL_SIGNATURE);
- proposal_t *prop1, *prop2, *prop3, *prop4;
- linked_list_t *list;
-
- prop1 = proposal_create(1);
- prop1->add_algorithm(prop1, PROTO_IKE, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 20);
- prop1->add_algorithm(prop1, PROTO_IKE, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 20);
- prop1->add_algorithm(prop1, PROTO_IKE, PSEUDO_RANDOM_FUNCTION, PRF_HMAC_SHA1, 20);
- prop1->add_algorithm(prop1, PROTO_IKE, DIFFIE_HELLMAN_GROUP, MODP_2048_BIT, 0);
-
- prop2 = proposal_create(2);
- prop2->add_algorithm(prop2, PROTO_IKE, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 20);
- prop2->add_algorithm(prop2, PROTO_IKE, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 20);
- prop2->add_algorithm(prop2, PROTO_IKE, PSEUDO_RANDOM_FUNCTION, PRF_HMAC_MD5, 20);
- prop2->add_algorithm(prop2, PROTO_IKE, DIFFIE_HELLMAN_GROUP, MODP_1024_BIT, 0);
-
- prop3 = proposal_create(3);
- prop3->add_algorithm(prop3, PROTO_IKE, ENCRYPTION_ALGORITHM, ENCR_DES, 20);
- prop3->add_algorithm(prop3, PROTO_IKE, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 20);
- prop3->add_algorithm(prop3, PROTO_IKE, PSEUDO_RANDOM_FUNCTION, PRF_HMAC_MD5, 20);
- prop3->add_algorithm(prop3, PROTO_IKE, DIFFIE_HELLMAN_GROUP, MODP_768_BIT, 0);
-
- prop4 = proposal_create(4);
- prop4->add_algorithm(prop4, PROTO_IKE, ENCRYPTION_ALGORITHM, ENCR_3DES, 20);
- prop4->add_algorithm(prop4, PROTO_IKE, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 20);
- prop4->add_algorithm(prop4, PROTO_IKE, PSEUDO_RANDOM_FUNCTION, PRF_HMAC_TIGER, 20);
- prop4->add_algorithm(prop4, PROTO_IKE, DIFFIE_HELLMAN_GROUP, MODP_768_BIT, 0);
-
- 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/Source/charon/testcases/connection_test.h b/Source/charon/testcases/connection_test.h
deleted file mode 100644
index 4d2a1d89e..000000000
--- a/Source/charon/testcases/connection_test.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * @file connection_test.h
- *
- * @brief Tests for the connection_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-
-#ifndef INIT_CONFIG_TEST_H_
-#define INIT_CONFIG_TEST_H_
-
-#include <utils/tester.h>
-
-/**
- * @brief Test function used to test the connection_t functionality.
- *
- * @param tester associated protected_tester_t object
- *
- * @ingroup testcases
- */
-void test_connection(protected_tester_t *tester);
-
-#endif /* INIT_CONFIG_TEST_H_ */
diff --git a/Source/charon/testcases/der_decoder_test.c b/Source/charon/testcases/der_decoder_test.c
deleted file mode 100644
index c5683fae8..000000000
--- a/Source/charon/testcases/der_decoder_test.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/**
- * @file der_decoder_test.c
- *
- * @brief Tests for the der_decoder_t class.
- *
- */
-
-/*
- * Copyright (C) 2006 Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "der_decoder_test.h"
-
-#include <daemon.h>
-#include <asn1/der_decoder.h>
-#include <utils/allocator.h>
-#include <utils/logger.h>
-
-
-
-static char private_key_buffer[] = {
- 0x30,0x82,0x04,0xa2,0x02,0x00,0x02,0x82,0x01,0x01,0x00,0x9b,0x28,0x10,0x02,0xd2,
- 0x43,0x5b,0x2b,0x7c,0x81,0xce,0x2b,0x77,0xb4,0xbf,0x5f,0x2a,0x9a,0x96,0xc9,0xa4,
- 0xd7,0xbb,0xb3,0xfb,0xc1,0x8a,0xad,0xbe,0x21,0x4e,0xd7,0x15,0xc4,0x8c,0x0a,0x88,
- 0x5b,0x02,0xa9,0xcd,0x2e,0xee,0xd3,0x5e,0xb9,0xfd,0x27,0x0b,0xdb,0xf6,0xe7,0xb7,
- 0x39,0xc1,0xfa,0x34,0x3f,0xa7,0xe4,0x04,0xaf,0xa8,0xc2,0x36,0x4e,0xf5,0x0c,0xf1,
- 0x9b,0x92,0x26,0x32,0x20,0xdb,0x04,0xf5,0xb8,0x2e,0xf5,0xfc,0x47,0xd3,0x2a,0xa1,
- 0x2d,0x5b,0x68,0x2c,0x5e,0xc6,0xc9,0x35,0x57,0x7b,0x65,0x17,0xd7,0x5d,0x10,0x5c,
- 0x51,0xfb,0xcb,0x95,0xd1,0x17,0x42,0xa9,0xfd,0xd1,0xc4,0x32,0x1f,0x13,0xf2,0xeb,
- 0x6b,0x91,0x01,0xe9,0x89,0x19,0x3a,0x2b,0x6d,0xae,0x91,0x27,0xe2,0x5e,0x06,0x5b,
- 0x99,0xfb,0x20,0x3c,0xc4,0x92,0x20,0xc4,0x68,0x24,0x6b,0x74,0xdc,0x6d,0xf7,0xa8,
- 0x10,0x1b,0xdf,0x20,0xed,0x4e,0x90,0x0e,0x3d,0xf6,0xef,0x3a,0x94,0x8b,0x12,0x61,
- 0xac,0xed,0x95,0xbc,0xe2,0xed,0xb9,0x22,0xc2,0xdd,0xc7,0x19,0x68,0x09,0x14,0x71,
- 0xb0,0x37,0xf7,0xbd,0x65,0x11,0x31,0x9d,0x89,0x6e,0x21,0xcf,0x60,0xc1,0x8d,0xbe,
- 0x31,0x96,0xd2,0xdd,0x0e,0x20,0x38,0x07,0xd5,0xea,0xda,0xc8,0x9a,0x47,0x5b,0x05,
- 0xce,0x7d,0xf7,0x4e,0xcd,0xbb,0x89,0xdd,0x46,0x16,0x8f,0x39,0x9d,0x32,0x19,0xaf,
- 0x6e,0xc4,0xb3,0x6c,0x79,0x5a,0x70,0x11,0x8f,0xe2,0x75,0x33,0x09,0xc8,0xf6,0xd7,
- 0x40,0x25,0xe7,0xa3,0xf0,0x6f,0x9a,0xdb,0x35,0x74,0xc1,0x02,0x03,0x01,0x00,0x01,
- 0x02,0x82,0x01,0x00,0x12,0x42,0x38,0x58,0x21,0xfc,0x51,0x34,0xa0,0x8b,0x4f,0x58,
- 0x28,0x2c,0x7a,0x14,0xd8,0x98,0xfb,0xee,0x5b,0x85,0x69,0x0e,0x63,0x83,0x16,0xd9,
- 0xc9,0x5f,0xcc,0x12,0x5d,0xa5,0x15,0x41,0xd6,0xb8,0x0c,0x6b,0xda,0x67,0x3a,0x83,
- 0x09,0xf3,0xb8,0x89,0xd4,0x1d,0xc7,0x99,0x8f,0x23,0x59,0xe3,0x78,0x2b,0x41,0x8b,
- 0xab,0x78,0x2c,0x7e,0x3b,0xbb,0xe0,0xf4,0x96,0xa8,0xd3,0x1d,0xc6,0xea,0x67,0x91,
- 0x2c,0x30,0x1c,0xe9,0x4f,0xb8,0xa2,0xc3,0x5d,0x2c,0xf9,0x99,0x1c,0x6c,0xee,0xd7,
- 0x16,0x28,0x3c,0x5a,0x32,0x35,0xb8,0x3a,0xf3,0xa7,0xa6,0x35,0x02,0xba,0xbf,0x67,
- 0xab,0x44,0xe1,0x09,0x9b,0x48,0x5d,0xa5,0x9e,0xf4,0xb7,0xf4,0xd1,0xfc,0x68,0x9e,
- 0x98,0x26,0x69,0x28,0xcc,0x19,0x75,0xf2,0x61,0x0e,0x23,0xeb,0xf9,0x6d,0x2c,0x2b,
- 0x01,0x3f,0x4d,0x18,0x41,0xc5,0x31,0x9d,0x1c,0x20,0x81,0x4e,0x38,0x92,0xd5,0xbb,
- 0xd7,0xe7,0x49,0x0c,0x3a,0xf3,0x8f,0x9e,0xf0,0xb3,0x32,0x1e,0xa7,0x77,0xe8,0x9c,
- 0xf3,0xce,0x88,0x66,0xcc,0xe8,0x16,0xbb,0xfd,0xbc,0x62,0xc7,0xc3,0xeb,0x0a,0xf5,
- 0xd8,0x53,0x02,0x6c,0x45,0xcb,0x1d,0xa3,0x96,0xfb,0xa5,0x26,0x18,0x7f,0x04,0x9f,
- 0x80,0x4a,0xdb,0x3b,0x74,0xcf,0x0d,0x45,0xf4,0xd5,0x49,0xe9,0x27,0x54,0x9c,0x57,
- 0x92,0x48,0x78,0x52,0xb6,0x40,0x89,0x3f,0xf3,0x95,0x06,0x3d,0x90,0xab,0xa0,0x8a,
- 0xc7,0x54,0xf1,0x63,0xcf,0xa6,0xd2,0x83,0x1e,0x69,0x54,0xe0,0x77,0x2c,0x9e,0x3a,
- 0x4f,0xdd,0x14,0x6d,0x02,0x81,0x81,0x00,0xd9,0x40,0x76,0x90,0x7c,0xe7,0x3b,0xa3,
- 0x59,0x23,0x14,0x6b,0xf3,0x5f,0x6e,0x6b,0x82,0x34,0xf6,0xbd,0x3e,0xfb,0x65,0xac,
- 0x2f,0x46,0xd5,0x6e,0x9b,0xb8,0x62,0x80,0xc3,0x0c,0xa9,0xa6,0x00,0xd6,0xb8,0x1c,
- 0x12,0x8d,0x4d,0xd0,0x64,0x29,0x4c,0xac,0x38,0xe8,0x6c,0xe4,0x82,0x02,0x4e,0x10,
- 0xd5,0x39,0x19,0x29,0x0c,0x58,0x3f,0x68,0xa0,0x11,0x0e,0x11,0x74,0x22,0x2b,0x7e,
- 0xc2,0xa7,0x88,0xe3,0x33,0xe8,0xb4,0x50,0x6e,0x0c,0x54,0xc5,0x3f,0xb7,0x16,0xcb,
- 0x39,0xed,0x23,0xd0,0x66,0x26,0x57,0xf9,0xcb,0xc9,0xac,0xe2,0xa4,0xb8,0xba,0xd8,
- 0xd2,0x1f,0x4a,0xed,0x73,0x89,0xda,0x42,0x27,0x5a,0x26,0x30,0x33,0xc8,0x42,0x2a,
- 0x3d,0xc5,0xf3,0xc2,0x29,0x3d,0x58,0x67,0x02,0x81,0x81,0x00,0xb6,0xd4,0x61,0x05,
- 0x49,0xcb,0xf4,0x29,0x8a,0x22,0xd3,0xa3,0x7c,0x9c,0xd2,0x07,0xa4,0x66,0xe4,0x36,
- 0xfa,0x5e,0xf6,0x64,0xb7,0x59,0x74,0x2f,0x36,0x6d,0x12,0xd0,0xc9,0x4d,0xf8,0xd1,
- 0xba,0xd1,0xee,0xd2,0x78,0xcd,0x51,0x69,0x33,0x6a,0x03,0xff,0xc2,0x35,0x1d,0x0d,
- 0x9c,0x0a,0x87,0x5e,0x09,0xa3,0x23,0x4c,0xab,0xc3,0x4c,0x4a,0x1c,0xa4,0xc5,0xe2,
- 0x70,0x42,0x1c,0xcf,0xea,0x79,0xfb,0xb9,0x87,0x67,0x4d,0xc3,0xfc,0xcc,0x86,0x9d,
- 0xfa,0xea,0x99,0xa5,0x1b,0xc1,0x96,0xf4,0x79,0x4d,0x66,0x12,0x8f,0x90,0x98,0xb4,
- 0xa1,0x3b,0xd6,0x2f,0x64,0xb4,0x5f,0x8f,0x47,0x7f,0x43,0xa5,0x6d,0xeb,0x06,0x58,
- 0xfb,0x04,0x9e,0xef,0xaf,0x88,0x35,0x88,0xa1,0x15,0x30,0x97,0x02,0x81,0x80,0x59,
- 0xbe,0xe0,0x7b,0xc5,0xad,0x3c,0x1c,0xb9,0x98,0xdd,0x39,0xce,0xfa,0xd0,0x41,0x87,
- 0x33,0x5b,0xee,0x47,0x93,0x50,0xa7,0xf5,0x8b,0xbc,0x65,0x89,0xdc,0x7c,0x8c,0x96,
- 0x86,0xa7,0x9a,0x54,0xe4,0x5e,0x7f,0xf2,0x45,0xff,0x2c,0x24,0x04,0x4f,0x91,0x21,
- 0x9d,0x1a,0x46,0xb7,0x52,0x3e,0x6f,0x83,0xb5,0xa7,0xa8,0x26,0x5a,0x5a,0x2f,0x5d,
- 0x58,0x4e,0x48,0x75,0x82,0x1c,0x17,0xac,0x4f,0xcb,0x23,0x98,0x70,0xfb,0xf3,0xf1,
- 0xd2,0x14,0x3e,0xbb,0x98,0x65,0xc9,0x24,0x2f,0xcb,0x48,0xae,0xba,0x0e,0x43,0xb9,
- 0xa4,0xa1,0x4f,0xab,0x1e,0x48,0xc9,0x82,0xdb,0xbc,0x77,0x24,0xf0,0x80,0x82,0x2d,
- 0x81,0x77,0x1f,0x18,0x75,0x14,0xa8,0x20,0x86,0xa2,0xb0,0xc5,0x9a,0x7a,0xe7,0x02,
- 0x81,0x80,0x1b,0x6d,0xb1,0x40,0x81,0xd9,0xbf,0x3f,0x9c,0x21,0xad,0x6e,0x91,0x7b,
- 0x55,0x67,0x20,0x1a,0xef,0x91,0xef,0xed,0xdf,0x39,0x2c,0xe8,0x96,0xad,0x9e,0x94,
- 0xae,0x85,0xf4,0x2d,0x66,0x6e,0xd0,0x80,0x3e,0x3c,0x05,0x33,0x88,0x4b,0x28,0x13,
- 0x77,0x96,0x1f,0x24,0xa8,0xbf,0x29,0xf1,0xca,0x6d,0x29,0x34,0xf8,0x4e,0xc0,0x56,
- 0x04,0x53,0xfa,0x08,0x1e,0x47,0xe2,0x5f,0x88,0xc3,0x08,0x82,0x54,0x69,0x79,0x0e,
- 0xde,0x73,0xd0,0xb1,0x3e,0x60,0xe5,0x0b,0xdd,0x11,0x10,0x20,0xf2,0xec,0xaa,0x66,
- 0x1a,0x32,0x1e,0xa7,0xaa,0xc1,0x2e,0x8f,0x33,0x8a,0xd8,0xa8,0xd6,0xcd,0x40,0x04,
- 0xaf,0xb9,0x59,0xcc,0x30,0x9f,0x98,0xc9,0x10,0xaf,0x14,0xbe,0x72,0x89,0x94,0xe1,
- 0x00,0xf1,0x02,0x81,0x81,0x00,0xd6,0xac,0x26,0xd2,0x42,0x5b,0x16,0xa9,0x39,0x02,
- 0x63,0x76,0xa4,0xf5,0x40,0x3a,0xde,0xfa,0xea,0xd8,0xd3,0x12,0xee,0x44,0x00,0xfe,
- 0xcb,0xa1,0x78,0x18,0xaa,0xa7,0x08,0xea,0x5e,0x36,0x52,0x28,0x0d,0x02,0x5a,0x9e,
- 0x2d,0xc1,0x22,0x29,0x08,0x4f,0xed,0xff,0xa9,0xa6,0x08,0x8d,0x77,0xa4,0x5c,0xae,
- 0xa7,0x8a,0x19,0x90,0xc2,0x12,0xc8,0x0f,0xb8,0x24,0xb5,0xba,0x45,0x2f,0xa6,0xc2,
- 0x10,0x4c,0x0d,0x7e,0xf2,0xfd,0x11,0x26,0x16,0x34,0xbe,0x08,0x25,0x41,0x8b,0xcc,
- 0x60,0xe7,0x02,0x3e,0x6a,0x54,0x05,0x80,0x66,0x2d,0x55,0x06,0xe6,0xbe,0x9b,0x15,
- 0x9d,0xd3,0x5d,0xc4,0x6b,0x3f,0x74,0xa6,0x24,0xbc,0x7f,0x13,0xdf,0xe3,0x51,0x86,
- 0x64,0x0f,0x1d,0x1f,0xf2,0x1e,
-};
-
-asn1_rule_t private_key_rules[] = {
- {ASN1_SEQUENCE, 0, 0, 0},
- { ASN1_INTEGER, 0, 0, 0},
- { ASN1_INTEGER, ASN1_MPZ, 0, 0},
- { ASN1_INTEGER, ASN1_MPZ, 0, 0},
- { ASN1_INTEGER, ASN1_MPZ, 0, 0},
- { ASN1_INTEGER, ASN1_MPZ, 0, 0},
- { ASN1_INTEGER, ASN1_MPZ, 0, 0},
- { ASN1_INTEGER, ASN1_MPZ, 0, 0},
- { ASN1_INTEGER, ASN1_MPZ, 0, 0},
- { ASN1_INTEGER, ASN1_MPZ, 0, 0},
- {ASN1_END, 0, 0, 0},
-};
-
-/**
- * Described in header.
- */
-void test_der_decoder(protected_tester_t *tester)
-{
- chunk_t private_key = {private_key_buffer, sizeof(private_key_buffer)};
-
- der_decoder_t *dd = der_decoder_create(private_key_rules);
-
- dd->decode(dd, private_key, NULL);
-
- dd->destroy(dd);
-
-}
-
-
-
diff --git a/Source/charon/testcases/der_decoder_test.h b/Source/charon/testcases/der_decoder_test.h
deleted file mode 100644
index e7a7b7b62..000000000
--- a/Source/charon/testcases/der_decoder_test.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * @file der_decoder_test.h
- *
- * @brief Tests for the der_decoder_t class.
- *
- */
-
-/*
- * Copyright (C) 2006 Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-
-#ifndef DER_DECODER_TEST_H_
-#define DER_DECODER_TEST_H_
-
-#include <utils/tester.h>
-
-/**
- * @brief Test function used to test the der_decoder_t functionality.
- *
- * @param tester associated protected_tester_t object
- *
- * @ingroup testcases
- */
-void test_der_decoder(protected_tester_t *tester);
-
-#endif /* DER_DECODER_TEST_H_ */
-
-
-
-
diff --git a/Source/charon/testcases/diffie_hellman_test.c b/Source/charon/testcases/diffie_hellman_test.c
deleted file mode 100644
index 7a7462268..000000000
--- a/Source/charon/testcases/diffie_hellman_test.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * @file diffie_hellman_test.c
- *
- * @brief Tests for the diffie_hellman_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "diffie_hellman_test.h"
-
-#include "../transforms/diffie_hellman.h"
-
-#include <daemon.h>
-#include <utils/logger_manager.h>
-#include <utils/allocator.h>
-#include <encoding/payloads/transform_substructure.h>
-
-/*
- * described in Header-File
- */
-void test_diffie_hellman(protected_tester_t *tester)
-{
- diffie_hellman_t *my_diffie_hellman, *other_diffie_hellman;
- logger_t *logger;
- chunk_t my_public_value, other_public_value;
- chunk_t my_secret, other_secret;
-
- logger = charon->logger_manager->get_logger(charon->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);
-
- allocator_free(my_public_value.ptr);
- allocator_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");
-
- allocator_free(my_secret.ptr);
- allocator_free(other_secret.ptr);
-
- my_diffie_hellman->destroy(my_diffie_hellman);
- other_diffie_hellman->destroy(other_diffie_hellman);
-}
diff --git a/Source/charon/testcases/diffie_hellman_test.h b/Source/charon/testcases/diffie_hellman_test.h
deleted file mode 100644
index e6e3ff608..000000000
--- a/Source/charon/testcases/diffie_hellman_test.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * @file diffie_hellman_test.h
- *
- * @brief Tests for the diffie_hellman_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef DIFFIE_HELLMAN_TEST_H_
-#define DIFFIE_HELLMAN_TEST_H_
-
-#include <utils/tester.h>
-
-/**
- * @brief Test function used to test the diffie_hellman_t functionality.
- *
- * @param tester associated tester object
- *
- * @ingroup testcases
- */
-void test_diffie_hellman(protected_tester_t *tester);
-
-#endif /*DIFFIE_HELLMAN_TEST_H_*/
diff --git a/Source/charon/testcases/encryption_payload_test.c b/Source/charon/testcases/encryption_payload_test.c
deleted file mode 100644
index 45572374b..000000000
--- a/Source/charon/testcases/encryption_payload_test.c
+++ /dev/null
@@ -1,138 +0,0 @@
-/**
- * @file encryption_payload_test.c
- *
- * @brief Tests for the encryption_payload_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "encryption_payload_test.h"
-
-#include <daemon.h>
-#include <utils/logger_manager.h>
-#include <utils/allocator.h>
-#include <encoding/generator.h>
-#include <encoding/parser.h>
-#include <encoding/payloads/encryption_payload.h>
-#include <encoding/payloads/nonce_payload.h>
-#include <transforms/crypters/crypter.h>
-#include <transforms/signers/signer.h>
-
-/*
- * described in Header-File
- */
-void test_encryption_payload(protected_tester_t *tester)
-{
- encryption_payload_t *encryption_payload;
- nonce_payload_t *nonce_payload;
- crypter_t *crypter;
- signer_t *signer;
- chunk_t nonce, got_nonce;
- chunk_t data;
- chunk_t key;
- generator_t *generator;
- parser_t *parser;
- status_t status;
- logger_t *logger;
- iterator_t *iterator;
-
-
- u_int8_t key_bytes[] = {
- 0x01,0x01,0x01,0x01,
- 0x01,0x01,0x01,0x01,
- 0x01,0x01,0x01,0x01,
- 0x01,0x01,0x01,0x01
- };
- key.ptr = key_bytes;
- key.len = sizeof(key_bytes);
-
- logger = charon->logger_manager->get_logger(charon->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);
-
- allocator_free(data.ptr);
- allocator_free(got_nonce.ptr);
- encryption_payload->destroy(encryption_payload);
- crypter->destroy(crypter);
- signer->destroy(signer);
- generator->destroy(generator);
- parser->destroy(parser);
-}
diff --git a/Source/charon/testcases/encryption_payload_test.h b/Source/charon/testcases/encryption_payload_test.h
deleted file mode 100644
index 5e6353bfd..000000000
--- a/Source/charon/testcases/encryption_payload_test.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * @file encryption_payload_test.h
- *
- * @brief Tests for the encryption_payload_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef ENCRYPTION_PAYLOAD_TEST_H_
-#define ENCRYPTION_PAYLOAD_TEST_H_
-
-#include <utils/tester.h>
-
-/**
- * @brief Test function used to test the encryption_payload_t functionality.
- *
- * @param tester associated tester object
- *
- * @ingroup testcases
- */
-void test_encryption_payload(protected_tester_t *tester);
-
-#endif /*ENCRYPTION_PAYLOAD_TEST_H_*/
diff --git a/Source/charon/testcases/event_queue_test.c b/Source/charon/testcases/event_queue_test.c
deleted file mode 100644
index 5366dca07..000000000
--- a/Source/charon/testcases/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 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <stdlib.h>
-#include <pthread.h>
-
-#include "event_queue_test.h"
-
-#include <utils/allocator.h>
-#include <queues/event_queue.h>
-#include <queues/jobs/initiate_ike_sa_job.h>
-
-/**
- * Number of different times to insert per thread
- */
-#define EVENT_QUEUE_TIMES 5
-/**
- * Number of entries per time per thread
- */
-#define EVENT_QUEUE_ENTRY_PER_TIME 20
-
-/**
- * Number of test-thread
- */
-#define EVENT_QUEUE_INSERT_THREADS 1
-
-/**
- * @brief Informations for the involved test-thread used in this test
- *
- */
-typedef struct event_queue_test_s event_queue_test_t;
-
-struct event_queue_test_s{
- protected_tester_t *tester;
- event_queue_t *event_queue;
-
- /**
- * number of different event times to be inserted in the event-queue by each thread
- */
- int insert_times_count;
-
- /**
- * number of event to insert at one time
- */
- int entries_per_time;
-};
-
-
-static void event_queue_insert_thread(event_queue_test_t * testinfos)
-{
- timeval_t current_time;
- timeval_t time;
- job_t * job;
- int i,j;
- connection_t *connection;
-
- gettimeofday(&current_time,NULL);
- for (i = 0; i < testinfos->insert_times_count;i++)
- {
-
- for (j = 0; j < testinfos->entries_per_time;j++)
- {
- job = (job_t *) initiate_ike_sa_job_create(connection);
- time.tv_usec = 0;
- time.tv_sec = current_time.tv_sec + i;
-
- testinfos->event_queue->add_absolute(testinfos->event_queue,job,time);
- }
- }
-}
-
-
-void test_event_queue(protected_tester_t *tester)
-{
- event_queue_t * event_queue = event_queue_create();
- event_queue_test_t testinfos;
- pthread_t threads[EVENT_QUEUE_INSERT_THREADS];
- int i,j, number_of_total_events;
- timeval_t current_time, start_time;
-
- testinfos.tester = tester;
- testinfos.event_queue = event_queue;
- testinfos.insert_times_count = EVENT_QUEUE_TIMES;
- testinfos.entries_per_time = EVENT_QUEUE_ENTRY_PER_TIME;
-
- number_of_total_events = EVENT_QUEUE_ENTRY_PER_TIME * EVENT_QUEUE_TIMES * EVENT_QUEUE_INSERT_THREADS;
-
- gettimeofday(&start_time,NULL);
-
- for (i = 0; i < EVENT_QUEUE_INSERT_THREADS; i++)
- {
- int retval;
- retval = pthread_create( &(threads[i]), NULL,(void*(*)(void*)) &event_queue_insert_thread, (void*) &testinfos);
- tester->assert_true(tester,(retval== 0), "thread creation call check");
- }
-
-
- /* wait for all threads */
- for (i = 0; i < EVENT_QUEUE_INSERT_THREADS; i++)
- {
- 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(&current_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/Source/charon/testcases/event_queue_test.h b/Source/charon/testcases/event_queue_test.h
deleted file mode 100644
index 5f8c47fad..000000000
--- a/Source/charon/testcases/event_queue_test.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * @file event_queue_test.h
- *
- * @brief Tests to test the Event-Queue type event_queue_t
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef EVENT_QUEUE_TEST_H_
-#define EVENT_QUEUE_TEST_H_
-
-#include <utils/tester.h>
-
-/**
- * @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/Source/charon/testcases/generator_test.c b/Source/charon/testcases/generator_test.c
deleted file mode 100644
index c611a3e6c..000000000
--- a/Source/charon/testcases/generator_test.c
+++ /dev/null
@@ -1,1411 +0,0 @@
-/**
- * @file generator_test.c
- *
- * @brief Tests for the generator_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <string.h>
-
-#include "generator_test.h"
-
-#include <daemon.h>
-#include <encoding/generator.h>
-#include <utils/allocator.h>
-#include <utils/logger_manager.h>
-#include <utils/logger.h>
-#include <encoding/payloads/encodings.h>
-#include <encoding/payloads/ike_header.h>
-#include <encoding/payloads/transform_attribute.h>
-#include <encoding/payloads/transform_substructure.h>
-#include <encoding/payloads/proposal_substructure.h>
-#include <encoding/payloads/sa_payload.h>
-#include <encoding/payloads/ke_payload.h>
-#include <encoding/payloads/notify_payload.h>
-#include <encoding/payloads/nonce_payload.h>
-#include <encoding/payloads/id_payload.h>
-#include <encoding/payloads/auth_payload.h>
-#include <encoding/payloads/cert_payload.h>
-#include <encoding/payloads/certreq_payload.h>
-#include <encoding/payloads/ts_payload.h>
-#include <encoding/payloads/delete_payload.h>
-#include <encoding/payloads/vendor_id_payload.h>
-#include <encoding/payloads/cp_payload.h>
-#include <encoding/payloads/eap_payload.h>
-
-/*
- * 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 = charon->logger_manager->get_logger(charon->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");
- allocator_free_chunk(&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");
- allocator_free_chunk(&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 = charon->logger_manager->get_logger(charon->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");
- allocator_free_chunk(&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");
-
- allocator_free_chunk(&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");
-
- allocator_free_chunk(&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 = charon->logger_manager->get_logger(charon->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");
-
- allocator_free_chunk(&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 = charon->logger_manager->get_logger(charon->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");
-
- allocator_free_chunk(&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 = charon->logger_manager->get_logger(charon->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");
-
- allocator_free_chunk(&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(1);
- proposal1->add_algorithm(proposal1, PROTO_IKE, ENCRYPTION_ALGORITHM, 1, 20);
- proposal1->add_algorithm(proposal1, PROTO_IKE, PSEUDO_RANDOM_FUNCTION, 2, 22);
- proposal1->add_algorithm(proposal1, PROTO_IKE, INTEGRITY_ALGORITHM, 3, 24);
- proposal1->add_algorithm(proposal1, PROTO_IKE, DIFFIE_HELLMAN_GROUP, 4, 0);
-
- proposal2 = proposal_create(2);
- proposal2->add_algorithm(proposal2, PROTO_IKE, ENCRYPTION_ALGORITHM, 5, 26);
- proposal2->add_algorithm(proposal2, PROTO_IKE, PSEUDO_RANDOM_FUNCTION, 6, 28);
- proposal2->add_algorithm(proposal2, PROTO_IKE, INTEGRITY_ALGORITHM, 7, 30);
- proposal2->add_algorithm(proposal2, PROTO_IKE, DIFFIE_HELLMAN_GROUP, 8, 0);
-
- 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);
- allocator_free_chunk(&generated_data);
- generator->destroy(generator);
-
-
- /* --------------------------- */
- /* test with automatic created child proposals */
-
- generator = generator_create();
- tester->assert_true(tester,(generator != NULL), "generator create check");
-
-
- proposal1 = proposal_create(1);
-
- proposal1->add_algorithm(proposal1, PROTO_AH, INTEGRITY_ALGORITHM, AUTH_HMAC_MD5_96, 20);
- proposal1->add_algorithm(proposal1, PROTO_AH, DIFFIE_HELLMAN_GROUP, MODP_2048_BIT, 0);
- proposal1->add_algorithm(proposal1, PROTO_AH, EXTENDED_SEQUENCE_NUMBERS, EXT_SEQ_NUMBERS, 0);
- proposal1->set_spi(proposal1, PROTO_AH, 0x01010101l);
-
- proposal1->add_algorithm(proposal1, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 20);
- proposal1->add_algorithm(proposal1, PROTO_ESP, DIFFIE_HELLMAN_GROUP, MODP_1024_BIT, 0);
- proposal1->set_spi(proposal1, PROTO_ESP, 0x02020202);
-
-
- proposal2->add_algorithm(proposal2, PROTO_AH, INTEGRITY_ALGORITHM, AUTH_HMAC_MD5_96, 20);
- proposal2->add_algorithm(proposal2, PROTO_AH, DIFFIE_HELLMAN_GROUP, MODP_2048_BIT, 0);
- proposal2->add_algorithm(proposal2, PROTO_AH, EXTENDED_SEQUENCE_NUMBERS, EXT_SEQ_NUMBERS, 0);
- proposal2->set_spi(proposal2, PROTO_AH, 0x01010101);
-
- proposal2->add_algorithm(proposal2, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 32);
- proposal2->add_algorithm(proposal2, PROTO_ESP, INTEGRITY_ALGORITHM, AUTH_HMAC_MD5_96, 20);
- proposal2->add_algorithm(proposal2, PROTO_ESP, DIFFIE_HELLMAN_GROUP, MODP_1024_BIT, 0);
- proposal2->set_spi(proposal2, PROTO_ESP, 0x02020202);
-
- list->insert_last(list, (void*)proposal1);
- list->insert_last(list, (void*)proposal2);
-
- sa_payload = sa_payload_create_from_proposal_list(list);
- tester->assert_true(tester,(sa_payload != NULL), "sa_payload create check");
-
- generator->generate_payload(generator,(payload_t *)sa_payload);
- generator->write_to_chunk(generator,&generated_data);
- logger->log_chunk(logger,RAW,"generated",generated_data);
-
- u_int8_t expected_generation3[] = {
- 0x00,0x00,0x00,0xA0, /* payload header*/
-
- /* suite 1 */
- 0x02,0x00,0x00,0x28, /* a proposal */
- 0x01,0x02,0x04,0x03,
- 0x01,0x01,0x01,0x01,
- 0x03,0x00,0x00,0x0C, /* transform 1 */
- 0x03,0x00,0x00,0x01,
- 0x80,0x0E,0x00,0x14, /* keylength attribute with 20 bytes length */
-
- 0x03,0x00,0x00,0x08, /* transform 2 */
- 0x04,0x00,0x00,0x0E,
-
- 0x00,0x00,0x00,0x08, /* transform 3 */
- 0x05,0x00,0x00,0x01,
-
-
- 0x02,0x00,0x00,0x20, /* a proposal */
- 0x01,0x03,0x04,0x02,
- 0x02,0x02,0x02,0x02,
-
- 0x03,0x00,0x00,0x0C, /* transform 1 */
- 0x01,0x00,0x00,0x0C,
- 0x80,0x0E,0x00,0x20, /* keylength attribute with 32 bytes length */
-
- 0x00,0x00,0x00,0x08, /* transform 2 */
- 0x04,0x00,0x00,0x02,
-
- /* suite 2 */
- 0x02,0x00,0x00,0x28, /* a proposal */
- 0x02,0x02,0x04,0x03,
- 0x01,0x01,0x01,0x01,
- 0x03,0x00,0x00,0x0C, /* transform 1 */
- 0x03,0x00,0x00,0x01,
- 0x80,0x0E,0x00,0x14, /* keylength attribute with 20 bytes length */
-
- 0x03,0x00,0x00,0x08, /* transform 2 */
- 0x04,0x00,0x00,0x0E,
-
- 0x00,0x00,0x00,0x08, /* transform 3 */
- 0x05,0x00,0x00,0x01,
-
-
- 0x00,0x00,0x00,0x2C, /* a proposal */
- 0x02,0x03,0x04,0x03,
- 0x02,0x02,0x02,0x02,
-
- 0x03,0x00,0x00,0x0C, /* transform 1 */
- 0x01,0x00,0x00,0x0C,
- 0x80,0x0E,0x00,0x20, /* keylength attribute with 32 bytes length */
-
- 0x03,0x00,0x00,0x0C, /* transform 2 */
- 0x03,0x00,0x00,0x01,
- 0x80,0x0E,0x00,0x14, /* keylength attribute with 20 bytes length */
-
- 0x00,0x00,0x00,0x08, /* transform 3 */
- 0x04,0x00,0x00,0x02,
-
- };
-
-
- logger->log_bytes(logger,RAW,"expected",expected_generation3,sizeof(expected_generation3));
-
- tester->assert_true(tester,(memcmp(expected_generation3,generated_data.ptr,sizeof(expected_generation3)) == 0), "compare generated data");
-
- sa_payload->destroy(sa_payload);
- proposal1->destroy(proposal1);
- proposal2->destroy(proposal2);
- list->destroy(list);
- allocator_free_chunk(&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 = charon->logger_manager->get_logger(charon->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");
-
- allocator_free_chunk(&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 spi,notification_data;
-
- logger = charon->logger_manager->get_logger(charon->logger_manager,TESTER);
-
- /* create generator */
- generator = generator_create();
- tester->assert_true(tester,(generator != NULL), "generator create check");
-
- notify_payload = notify_payload_create();
-
-
- spi.ptr = "12345";
- spi.len = strlen(spi.ptr);
-
- notification_data.ptr = "67890";
- notification_data.len = strlen(notification_data.ptr);
-
- notify_payload->set_protocol_id(notify_payload,255);
- notify_payload->set_notify_message_type(notify_payload,63333); /* Hex F765 */
- notify_payload->set_spi(notify_payload,spi);
- notify_payload->set_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,0x12,
- 0xFF,0x05,0xF7,0x65,
- /* spi */
- 0x31,0x32,0x33,0x34,
- 0x35,
- /* 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");
-
- allocator_free_chunk(&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 = charon->logger_manager->get_logger(charon->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");
-
- allocator_free_chunk(&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 = charon->logger_manager->get_logger(charon->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");
-
- allocator_free_chunk(&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 = charon->logger_manager->get_logger(charon->logger_manager,TESTER);
-
- /* create generator */
- generator = generator_create();
- tester->assert_true(tester,(generator != NULL), "generator create check");
-
- auth_payload = auth_payload_create(FALSE);
-
-
- 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");
-
- allocator_free_chunk(&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 = charon->logger_manager->get_logger(charon->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");
-
- allocator_free_chunk(&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 = charon->logger_manager->get_logger(charon->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,PGP_CERTIFICATE);
- 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");
-
- allocator_free_chunk(&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 = charon->logger_manager->get_logger(charon->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,PGP_CERTIFICATE);
- 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");
-
- allocator_free_chunk(&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 = charon->logger_manager->get_logger(charon->logger_manager,TESTER);
-
- /* create generator */
- generator = generator_create();
- tester->assert_true(tester,(generator != NULL), "generator create check");
-
- delete_payload = delete_payload_create();
-
-
- spis.ptr = "123456789012";
- spis.len = strlen(spis.ptr);
-
- delete_payload->set_protocol_id(delete_payload, PROTO_AH);
- 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");
-
- allocator_free_chunk(&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 = charon->logger_manager->get_logger(charon->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");
-
- allocator_free_chunk(&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 = charon->logger_manager->get_logger(charon->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");
-
- allocator_free_chunk(&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 = charon->logger_manager->get_logger(charon->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");
-
- allocator_free_chunk(&generated_data);
-
- eap_payload->destroy(eap_payload);
- generator->destroy(generator);
-}
diff --git a/Source/charon/testcases/generator_test.h b/Source/charon/testcases/generator_test.h
deleted file mode 100644
index 204255fb7..000000000
--- a/Source/charon/testcases/generator_test.h
+++ /dev/null
@@ -1,183 +0,0 @@
-/**
- * @file generator_test.h
- *
- * @brief Tests for the generator_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef GENERATOR_TEST_H_
-#define GENERATOR_TEST_H_
-
-#include <utils/tester.h>
-
-/**
- * @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/Source/charon/testcases/hasher_test.c b/Source/charon/testcases/hasher_test.c
deleted file mode 100644
index e9df91258..000000000
--- a/Source/charon/testcases/hasher_test.c
+++ /dev/null
@@ -1,172 +0,0 @@
-/**
- * @file hasher_test.h
- *
- * @brief Tests for the hasher_t classes.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <string.h>
-
-#include "hasher_test.h"
-
-#include <utils/allocator.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_block_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...");
- allocator_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_block_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...");
- allocator_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/Source/charon/testcases/hasher_test.h b/Source/charon/testcases/hasher_test.h
deleted file mode 100644
index 8590cabec..000000000
--- a/Source/charon/testcases/hasher_test.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * @file hasher_test.h
- *
- * @brief Tests for the hasher_t classes.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef HASHER_TEST_H_
-#define HASHER_TEST_H_
-
-#include <transforms/hashers/hasher.h>
-#include <transforms/hashers/md5_hasher.h>
-#include <transforms/hashers/sha1_hasher.h>
-#include <utils/tester.h>
-
-/**
- * @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/Source/charon/testcases/hmac_signer_test.c b/Source/charon/testcases/hmac_signer_test.c
deleted file mode 100644
index 0cfbfdbd0..000000000
--- a/Source/charon/testcases/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 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-
-#include <string.h>
-
-#include "hmac_signer_test.h"
-
-#include <transforms/signers/signer.h>
-#include <utils/allocator.h>
-#include <daemon.h>
-
-
-/*
- * 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 = charon->logger_manager->get_logger(charon->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]);
- allocator_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 = charon->logger_manager->get_logger(charon->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]);
- allocator_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/Source/charon/testcases/hmac_signer_test.h b/Source/charon/testcases/hmac_signer_test.h
deleted file mode 100644
index 4a2459a8e..000000000
--- a/Source/charon/testcases/hmac_signer_test.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * @file hmac_signer_test.h
- *
- * @brief Tests for the hmac_signer_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef HMAC_SIGNER_TEST_H_
-#define HMAC_SIGNER_TEST_H_
-
-#include <utils/tester.h>
-
-/**
- * @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/Source/charon/testcases/hmac_test.c b/Source/charon/testcases/hmac_test.c
deleted file mode 100644
index 1ad17f659..000000000
--- a/Source/charon/testcases/hmac_test.c
+++ /dev/null
@@ -1,409 +0,0 @@
-/**
- * @file hmac_test.h
- *
- * @brief Tests for the hmac_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <string.h>
-
-#include "hmac_test.h"
-
-#include <transforms/hmac.h>
-#include <utils/allocator.h>
-
-
-/*
- * 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");
- allocator_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");
- allocator_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");
- allocator_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");
- allocator_free(digest[3].ptr);
-}
diff --git a/Source/charon/testcases/hmac_test.h b/Source/charon/testcases/hmac_test.h
deleted file mode 100644
index a61666e04..000000000
--- a/Source/charon/testcases/hmac_test.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * @file hmac_test.h
- *
- * @brief Tests for the hmac_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef HMAC_TEST_H_
-#define HMAC_TEST_H_
-
-#include <transforms/hmac.h>
-#include <utils/tester.h>
-
-/**
- * @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/Source/charon/testcases/ike_sa_id_test.c b/Source/charon/testcases/ike_sa_id_test.c
deleted file mode 100644
index ba44363fb..000000000
--- a/Source/charon/testcases/ike_sa_id_test.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * @file ike_sa_id_test.c
- *
- * @brief Tests for the ike_sa_id_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "ike_sa_id_test.h"
-
-#include <sa/ike_sa_id.h>
-
-/*
- * 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/Source/charon/testcases/ike_sa_id_test.h b/Source/charon/testcases/ike_sa_id_test.h
deleted file mode 100644
index 75429e4fb..000000000
--- a/Source/charon/testcases/ike_sa_id_test.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * @file ike_sa_id_test.h
- *
- * @brief Tests for the ike_sa_id_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef IKE_SA_ID_TEST_H_
-#define IKE_SA_ID_TEST_H_
-
-#include <utils/tester.h>
-
-/**
- * @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/Source/charon/testcases/ike_sa_manager_test.c b/Source/charon/testcases/ike_sa_manager_test.c
deleted file mode 100644
index 5247be7f0..000000000
--- a/Source/charon/testcases/ike_sa_manager_test.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/**
- * @file ike_sa_manager_test.c
- *
- * @brief Tests for the ike_sa_manager_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <string.h>
-#include <pthread.h>
-#include <unistd.h>
-
-#include "ike_sa_manager_test.h"
-
-#include <types.h>
-#include <sa/ike_sa_manager.h>
-
-
-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/Source/charon/testcases/ike_sa_manager_test.h b/Source/charon/testcases/ike_sa_manager_test.h
deleted file mode 100644
index c3e9f99f1..000000000
--- a/Source/charon/testcases/ike_sa_manager_test.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * @file ike_sa_manager_test.h
- *
- * @brief Tests for the ike_sa_manager_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef IKE_SA_MANAGER_TEST_H_
-#define IKE_SA_MANAGER_TEST_H_
-
-#include <utils/tester.h>
-
-/**
- * @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/Source/charon/testcases/ike_sa_test.c b/Source/charon/testcases/ike_sa_test.c
deleted file mode 100644
index 798b5edc9..000000000
--- a/Source/charon/testcases/ike_sa_test.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * @file ike_sa_test.c
- *
- * @brief Tests for the ike_sa_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "ike_sa_test.h"
-
-#include <types.h>
-#include <encoding/message.h>
-#include <sa/ike_sa.h>
-
-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/Source/charon/testcases/ike_sa_test.h b/Source/charon/testcases/ike_sa_test.h
deleted file mode 100644
index e93bc34fd..000000000
--- a/Source/charon/testcases/ike_sa_test.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * @file ike_sa_test.h
- *
- * @brief Tests for the ike_sa_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef IKE_SA_TEST_H_
-#define IKE_SA_TEST_H_
-
-#include <utils/tester.h>
-
-/**
- * @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/Source/charon/testcases/job_queue_test.c b/Source/charon/testcases/job_queue_test.c
deleted file mode 100644
index e7c93b68c..000000000
--- a/Source/charon/testcases/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 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-
-#include <stdlib.h>
-#include <pthread.h>
-#include <unistd.h>
-
-#include "job_queue_test.h"
-
-#include <utils/allocator.h>
-#include <queues/job_queue.h>
-#include <queues/jobs/initiate_ike_sa_job.h>
-
-
-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/Source/charon/testcases/job_queue_test.h b/Source/charon/testcases/job_queue_test.h
deleted file mode 100644
index f2d3edc4c..000000000
--- a/Source/charon/testcases/job_queue_test.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * @file job_queue_test.h
- *
- * @brief Tests for the job_queue_test_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef JOB_QUEUE_TEST_H_
-#define JOB_QUEUE_TEST_H_
-
-#include <utils/tester.h>
-
-/**
- * @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/Source/charon/testcases/kernel_interface_test.c b/Source/charon/testcases/kernel_interface_test.c
deleted file mode 100644
index 400531072..000000000
--- a/Source/charon/testcases/kernel_interface_test.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * @file kernel_interface_test.h
- *
- * @brief Tests for the kernel_interface_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-
-#include "kernel_interface_test.h"
-
-#include <daemon.h>
-#include <threads/kernel_interface.h>
-#include <utils/allocator.h>
-#include <utils/logger.h>
-#include <network/host.h>
-
-
-/*
- * described in Header-File
- */
-void test_kernel_interface(protected_tester_t *tester)
-{
- kernel_interface_t *kernel_interface;
- u_int32_t spi;
- host_t *me, *other, *left, *right;
- status_t status;
-
- u_int8_t enc_key_bytes[] = {
- 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
- 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08
- };
-
- u_int8_t inc_key_bytes[] = {
- 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
- 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08
- };
-
- chunk_t enc_key,inc_key;
- enc_key.ptr = enc_key_bytes;
- enc_key.len = sizeof(enc_key_bytes);
- inc_key.ptr = inc_key_bytes;
- inc_key.len = sizeof(inc_key_bytes);
-
-
-
- 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, 50, 1234, &spi);
- tester->assert_true(tester, status == SUCCESS, "spi get");
-
- status = kernel_interface->add_sa(kernel_interface, me, other, spi, 50, 1234, ENCR_AES_CBC, enc_key,AUTH_UNDEFINED,inc_key,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, TRUE, FALSE, 1234);
- tester->assert_true(tester, status == SUCCESS, "add policy");
-
- me->destroy(me);
- other->destroy(other);
- left->destroy(left);
- right->destroy(right);
-
- kernel_interface->destroy(kernel_interface);
-
-}
diff --git a/Source/charon/testcases/kernel_interface_test.h b/Source/charon/testcases/kernel_interface_test.h
deleted file mode 100644
index fc8dab4b6..000000000
--- a/Source/charon/testcases/kernel_interface_test.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * @file kernel_interface_test.h
- *
- * @brief Tests for the kernel_interface_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef KERNEL_INTERFACE_TEST_H_
-#define KERNEL_INTERFACE_TEST_H_
-
-#include <utils/tester.h>
-
-/**
- * @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);
-
-
-#endif /*KERNEL_INTERFACE_TEST_H_*/
diff --git a/Source/charon/testcases/linked_list_test.c b/Source/charon/testcases/linked_list_test.c
deleted file mode 100644
index 3d5666f64..000000000
--- a/Source/charon/testcases/linked_list_test.c
+++ /dev/null
@@ -1,241 +0,0 @@
-/**
- * @file linked_list_test.c
- *
- * @brief Tests for the linked_list_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <string.h>
-
-#include "linked_list_test.h"
-
-#include <utils/linked_list.h>
-
- /*
- * 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/Source/charon/testcases/linked_list_test.h b/Source/charon/testcases/linked_list_test.h
deleted file mode 100644
index a9773f8f0..000000000
--- a/Source/charon/testcases/linked_list_test.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * @file linked_list_test.h
- *
- * @brief Tests for the linked_list_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef LINKED_LIST_TEST_H_
-#define LINKED_LIST_TEST_H_
-
-#include <utils/tester.h>
-
-/**
- * @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/Source/charon/testcases/packet_test.c b/Source/charon/testcases/packet_test.c
deleted file mode 100644
index 9ba099cd2..000000000
--- a/Source/charon/testcases/packet_test.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * @file packet_test.c
- *
- * @brief Tests for the packet_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <string.h>
-
-#include "packet_test.h"
-
-#include <daemon.h>
-#include <network/packet.h>
-#include <utils/allocator.h>
-#include <utils/logger_manager.h>
-
-
-/*
- * 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 = allocator_alloc(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/Source/charon/testcases/packet_test.h b/Source/charon/testcases/packet_test.h
deleted file mode 100644
index 8bc297e1b..000000000
--- a/Source/charon/testcases/packet_test.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * @file packet_test.h
- *
- * @brief Tests for the packet_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef PACKET_TEST_H_
-#define PACKET_TEST_H_
-
-#include <utils/tester.h>
-
-/**
- * @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/Source/charon/testcases/parser_test.c b/Source/charon/testcases/parser_test.c
deleted file mode 100644
index 81a6556f3..000000000
--- a/Source/charon/testcases/parser_test.c
+++ /dev/null
@@ -1,964 +0,0 @@
-/**
- * @file parser_test.c
- *
- * @brief Tests for the parser_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <string.h>
-
-#include "parser_test.h"
-
-#include <utils/allocator.h>
-#include <utils/logger_manager.h>
-#include <encoding/generator.h>
-#include <encoding/parser.h>
-#include <encoding/payloads/encodings.h>
-#include <encoding/payloads/ike_header.h>
-#include <encoding/payloads/sa_payload.h>
-#include <encoding/payloads/nonce_payload.h>
-#include <encoding/payloads/id_payload.h>
-#include <encoding/payloads/ke_payload.h>
-#include <encoding/payloads/notify_payload.h>
-#include <encoding/payloads/auth_payload.h>
-#include <encoding/payloads/cert_payload.h>
-#include <encoding/payloads/certreq_payload.h>
-#include <encoding/payloads/ts_payload.h>
-#include <encoding/payloads/delete_payload.h>
-#include <encoding/payloads/vendor_id_payload.h>
-#include <encoding/payloads/cp_payload.h>
-#include <encoding/payloads/eap_payload.h>
-
-
-/*
- * 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)
- {
- allocator_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)
- {
- allocator_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);
- allocator_free_chunk(&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);
- allocator_free_chunk(&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_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**)&notify_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_message_type(notify_payload) == 1), "notify message type");
-
- result = notify_payload->get_spi(notify_payload);
- tester->assert_false(tester,(memcmp(notify_bytes + 8, result.ptr, result.len)), "parsed spi");
-
- 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);
- allocator_free_chunk(&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) == 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);
- allocator_free_chunk(&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) == DNS_SIGNED_KEY), "is DNS_SIGNED_KEY encoding");
- tester->assert_true(tester,(result.len == 12), "parsed data lenght");
- tester->assert_false(tester,(memcmp(certreq_bytes + 5, result.ptr, result.len)), "parsed data");
- certreq_payload->destroy(certreq_payload);
- allocator_free_chunk(&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/Source/charon/testcases/parser_test.h b/Source/charon/testcases/parser_test.h
deleted file mode 100644
index 4956df13e..000000000
--- a/Source/charon/testcases/parser_test.h
+++ /dev/null
@@ -1,170 +0,0 @@
-/**
- * @file parser_test.h
- *
- * @brief Tests for the parser_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef PARSER_TEST_H_
-#define PARSER_TEST_H_
-
-#include <utils/tester.h>
-
-/**
- * @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/Source/charon/testcases/policy_test.c b/Source/charon/testcases/policy_test.c
deleted file mode 100644
index d511f4ae4..000000000
--- a/Source/charon/testcases/policy_test.c
+++ /dev/null
@@ -1,247 +0,0 @@
-/**
- * @file policy_test.c
- *
- * @brief Tests for the policy_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "policy_test.h"
-
-#include <daemon.h>
-#include <config/policy.h>
-#include <config/traffic_selector.h>
-#include <utils/allocator.h>
-#include <utils/logger.h>
-#include <encoding/payloads/ts_payload.h>
-
-
-/**
- * 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 = charon->logger_manager->get_logger(charon->logger_manager, TESTER);
- logger->disable_level(logger, FULL);
-
- alice = identification_create_from_string(ID_IPV4_ADDR, "152.96.193.131");
- bob = identification_create_from_string(ID_IPV4_ADDR, "152.96.193.130");
- policy = policy_create(alice, bob);
-
- tester->assert_true(tester, (policy != NULL), "policy construction");
-
-
- /*
- * test proposal getting and selection
- *
- */
-
- /* esp only prop */
- proposal1 = proposal_create(1);
- proposal1->add_algorithm(proposal1, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 16);
-
- /* ah only prop */
- proposal2 = proposal_create(2);
- proposal2->add_algorithm(proposal2, PROTO_AH, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 20);
-
- /* ah and esp prop */
- proposal3 = proposal_create(3);
- proposal3->add_algorithm(proposal3, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_3DES, 16);
- proposal3->add_algorithm(proposal3, PROTO_AH, INTEGRITY_ALGORITHM, AUTH_HMAC_MD5_96, 20);
-
-
- policy->add_proposal(policy, proposal1);
- policy->add_proposal(policy, proposal2);
- policy->add_proposal(policy, proposal3);
-
-
- proposals_list = policy->get_proposals(policy);
- tester->assert_true(tester, (proposals_list->get_count(proposals_list) == 3), "proposal count");
-
-
- proposals_list = linked_list_create();
- proposal1 = proposal_create(1);
- proposal1->add_algorithm(proposal1, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 32);
- proposal2 = proposal_create(2);
- proposal2->add_algorithm(proposal2, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 16);
- proposal2->add_algorithm(proposal2, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_3DES, 16);
- proposal2->add_algorithm(proposal2, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_BLOWFISH, 0);
- proposal2->add_algorithm(proposal2, PROTO_AH, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 20);
- proposal2->add_algorithm(proposal2, PROTO_AH, INTEGRITY_ALGORITHM, AUTH_HMAC_MD5_96, 20);
-
- proposals_list->insert_last(proposals_list, proposal1);
- proposals_list->insert_last(proposals_list, proposal2);
-
- proposal_sel = policy->select_proposal(policy, proposals_list);
- tester->assert_false(tester, proposal_sel == NULL, "proposal select");
- /* check ESP encryption algo */
- iterator = proposal_sel->create_algorithm_iterator(proposal_sel, PROTO_ESP, ENCRYPTION_ALGORITHM);
- tester->assert_false(tester, iterator == NULL, "algorithm select ESP");
- while (iterator->has_next(iterator))
- {
- algorithm_t *algo;
- iterator->current(iterator, (void**)&algo);
- tester->assert_true(tester, algo->algorithm == ENCR_3DES, "ESP encryption algo");
- tester->assert_true(tester, algo->key_size == 16, "ESP encryption keysize");
- }
- iterator->destroy(iterator);
- iterator = proposal_sel->create_algorithm_iterator(proposal_sel, PROTO_AH, INTEGRITY_ALGORITHM);
- /* check AH integrity algo */
- tester->assert_false(tester, iterator == NULL, "algorithm select AH");
- while (iterator->has_next(iterator))
- {
- algorithm_t *algo;
- iterator->current(iterator, (void**)&algo);
- tester->assert_true(tester, algo->algorithm == AUTH_HMAC_MD5_96, "ESP encryption algo");
- tester->assert_true(tester, algo->key_size == 20, "ESP encryption keysize");
- }
- iterator->destroy(iterator);
-
- proposal_sel->destroy(proposal_sel);
-
- /* cleanup */
- proposal1->destroy(proposal1);
- proposal1->destroy(proposal2);
- proposals_list->destroy(proposals_list);
-
-// /*
-// * 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]);
-// allocator_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]);
-// allocator_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; i<count; i++)
-// {
-// chunk_t fa_res = ts_result[i]->get_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");
-//
-// allocator_free(fa_res.ptr);
-// allocator_free(fa_ref.ptr);
-// allocator_free(ta_res.ptr);
-// allocator_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]);
-// allocator_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/Source/charon/testcases/policy_test.h b/Source/charon/testcases/policy_test.h
deleted file mode 100644
index 6c8072a9c..000000000
--- a/Source/charon/testcases/policy_test.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * @file policy_test.h
- *
- * @brief Tests for the policy_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-
-#ifndef SA_CONFIG_TEST_H_
-#define SA_CONFIG_TEST_H_
-
-#include <utils/tester.h>
-
-/**
- * @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/Source/charon/testcases/prf_plus_test.c b/Source/charon/testcases/prf_plus_test.c
deleted file mode 100644
index b91d84124..000000000
--- a/Source/charon/testcases/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 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <string.h>
-
-#include "prf_plus_test.h"
-
-#include <transforms/prf_plus.h>
-#include <utils/allocator.h>
-
-
-/*
- * 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/Source/charon/testcases/prf_plus_test.h b/Source/charon/testcases/prf_plus_test.h
deleted file mode 100644
index 702589d1e..000000000
--- a/Source/charon/testcases/prf_plus_test.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * @file prf_plus_test.h
- *
- * @brief Tests for the prf_plus_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef PRF_PLUS_TEST_H_
-#define PRF_PLUS_TEST_H_
-
-#include <transforms/prf_plus.h>
-#include <utils/tester.h>
-
-/**
- * @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/Source/charon/testcases/proposal_test.c b/Source/charon/testcases/proposal_test.c
deleted file mode 100644
index 8df2bf403..000000000
--- a/Source/charon/testcases/proposal_test.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * @file proposal_test.c
- *
- * @brief Tests for the proposal_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "proposal_test.h"
-
-#include <daemon.h>
-#include <config/proposal.h>
-#include <utils/allocator.h>
-#include <utils/logger.h>
-
-
-/**
- * Described in header.
- */
-void test_proposal(protected_tester_t *tester)
-{
- proposal_t *proposal1, *proposal2, *proposal3;
- iterator_t *iterator;
- algorithm_t *algo;
- bool result;
-
- proposal1 = proposal_create(1);
- proposal1->add_algorithm(proposal1, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_3DES, 0);
- proposal1->add_algorithm(proposal1, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 32);
- proposal1->add_algorithm(proposal1, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 16);
- proposal1->add_algorithm(proposal1, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_BLOWFISH, 0);
- proposal1->add_algorithm(proposal1, PROTO_ESP, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 20);
- proposal1->add_algorithm(proposal1, PROTO_ESP, INTEGRITY_ALGORITHM, AUTH_HMAC_MD5_96, 20);
- proposal1->add_algorithm(proposal1, PROTO_AH, DIFFIE_HELLMAN_GROUP, MODP_1024_BIT, 0);
- proposal1->add_algorithm(proposal1, PROTO_AH, DIFFIE_HELLMAN_GROUP, MODP_2048_BIT, 0);
-
- proposal2 = proposal_create(2);
- proposal2->add_algorithm(proposal2, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_3IDEA, 0);
- proposal2->add_algorithm(proposal2, PROTO_ESP, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 16);
- proposal2->add_algorithm(proposal2, PROTO_ESP, INTEGRITY_ALGORITHM, AUTH_HMAC_MD5_96, 20);
- proposal1->add_algorithm(proposal2, PROTO_AH, DIFFIE_HELLMAN_GROUP, MODP_1024_BIT, 0);
-
- /* ah and esp prop */
- proposal3 = proposal1->select(proposal1, proposal2);
- tester->assert_false(tester, proposal3 == NULL, "proposal select");
- if (proposal3)
- {
- result = proposal3->get_algorithm(proposal3, PROTO_ESP, ENCRYPTION_ALGORITHM, &algo);
- tester->assert_true(tester, result, "encryption algo select");
- tester->assert_true(tester, algo->algorithm == ENCR_AES_CBC, "encryption algo");
- tester->assert_true(tester, algo->key_size == 16, "encryption keylen");
-
-
- result = proposal3->get_algorithm(proposal3, PROTO_ESP, INTEGRITY_ALGORITHM, &algo);
- tester->assert_true(tester, result, "integrity algo select");
- tester->assert_true(tester, algo->algorithm == AUTH_HMAC_MD5_96, "integrity algo");
- tester->assert_true(tester, algo->key_size == 20, "integrity keylen");
-
- iterator = proposal3->create_algorithm_iterator(proposal3, PROTO_ESP, INTEGRITY_ALGORITHM);
- tester->assert_false(tester, iterator == NULL, "integrity algo select");
- while(iterator->has_next(iterator))
- {
- iterator->current(iterator, (void**)&algo);
- tester->assert_true(tester, algo->algorithm == AUTH_HMAC_MD5_96, "integrity algo");
- tester->assert_true(tester, algo->key_size == 20, "integrity keylen");
- }
- iterator->destroy(iterator);
-
- iterator = proposal3->create_algorithm_iterator(proposal3, PROTO_AH, DIFFIE_HELLMAN_GROUP );
- tester->assert_false(tester, iterator == NULL, "dh group algo select");
- while(iterator->has_next(iterator))
- {
- iterator->current(iterator, (void**)&algo);
- tester->assert_true(tester, algo->algorithm == MODP_1024_BIT, "dh group algo");
- tester->assert_true(tester, algo->key_size == 0, "dh gorup keylen");
- }
- iterator->destroy(iterator);
-
- proposal3->destroy(proposal3);
- }
-
- proposal1->destroy(proposal1);
- proposal2->destroy(proposal2);
- return;
-}
diff --git a/Source/charon/testcases/proposal_test.h b/Source/charon/testcases/proposal_test.h
deleted file mode 100644
index 059af11cc..000000000
--- a/Source/charon/testcases/proposal_test.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * @file proposal_test.h
- *
- * @brief Tests for the proposal_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-
-#ifndef CHILD_PROPOSAL_TEST_H_
-#define CHILD_PROPOSAL_TEST_H_
-
-#include <utils/tester.h>
-
-/**
- * @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/Source/charon/testcases/receiver_test.c b/Source/charon/testcases/receiver_test.c
deleted file mode 100644
index ed93a9f44..000000000
--- a/Source/charon/testcases/receiver_test.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * @file receiver_test.c
- *
- * @brief Tests for the receiver_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <string.h>
-#include <unistd.h>
-
-#include "receiver_test.h"
-
-#include <daemon.h>
-#include <threads/receiver.h>
-#include <network/packet.h>
-#include <network/socket.h>
-#include <queues/send_queue.h>
-#include <queues/job_queue.h>
-#include <queues/jobs/incoming_packet_job.h>
-#include <encoding/payloads/encodings.h>
-#include <utils/allocator.h>
-
-/**
- * Number of packets to send by sender-thread
- */
-#define NUMBER_OF_PACKETS_TO_SEND 100
-
-/**
- * Port to send the packets to
- */
-#define PORT_TO_SEND 4600
-
-/**
- * Destination IP Address
- */
-#define DESTINATION_IP "127.0.0.1"
-
-void test_receiver(protected_tester_t *tester)
-{
- int i;
- receiver_t *receiver;
- packet_t *packet;
- job_t *job;
- packet_t *received_packet;
- receiver = receiver_create();
- chunk_t test_data;
-
- for (i = 0; i < NUMBER_OF_PACKETS_TO_SEND; i++)
- {
- packet = packet_create();
- packet->set_destination(packet, host_create(AF_INET,DESTINATION_IP,PORT_TO_SEND));
- test_data.ptr = allocator_alloc_thing(int);
- test_data.len = ( sizeof(int));
- *((int *) (test_data.ptr)) = i;
- packet->set_data(packet, test_data);
- charon->socket->send(charon->socket, packet);
- packet->destroy(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));
- test_data = received_packet->get_data(received_packet);
- tester->assert_true(tester, (test_data.len == (sizeof(int))), "received data length check");
- tester->assert_true(tester, (i == *((int *)(test_data.ptr))), "received data value check");
- received_packet->destroy(received_packet);
-
- job->destroy(job);
- }
-
- receiver->destroy(receiver);
-}
diff --git a/Source/charon/testcases/receiver_test.h b/Source/charon/testcases/receiver_test.h
deleted file mode 100644
index 59b87df16..000000000
--- a/Source/charon/testcases/receiver_test.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * @file receiver_test.h
- *
- * @brief Tests for the receiver_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef RECEIVER_TEST_H_
-#define RECEIVER_TEST_H_
-
-#include <utils/tester.h>
-
-/**
- * @brief Test function for the type receiver_t.
- *
- * @param tester tester object
- *
- * @ingroup testcases
- */
-void test_receiver(protected_tester_t *tester);
-
-#endif /*RECEIVER_TEST_H_*/
diff --git a/Source/charon/testcases/rsa_test.c b/Source/charon/testcases/rsa_test.c
deleted file mode 100644
index fcc3008d2..000000000
--- a/Source/charon/testcases/rsa_test.c
+++ /dev/null
@@ -1,227 +0,0 @@
-/**
- * @file rsa_test.h
- *
- * @brief Tests for the hasher_t classes.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <string.h>
-
-#include "rsa_test.h"
-
-#include <daemon.h>
-#include <utils/allocator.h>
-#include <utils/logger.h>
-#include <transforms/certificate.h>
-
-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;
- certificate_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 = charon->logger_manager->get_logger(charon->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)");
-//
-// allocator_free(signature.ptr);
-//
-// private_key->destroy(private_key);
-// public_key->destroy(public_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)");
-
- allocator_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 = certificate_create_from_file("alice-cert.der");
- 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)");
-
- allocator_free(signature.ptr);
-
- certificate->destroy(certificate);
- public_key->destroy(public_key);
- private_key->destroy(private_key);
-
-}
diff --git a/Source/charon/testcases/rsa_test.h b/Source/charon/testcases/rsa_test.h
deleted file mode 100644
index aba5b869c..000000000
--- a/Source/charon/testcases/rsa_test.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * @file rsa_test.h
- *
- * @brief Tests for the rsa_public_key_t and rsa_private_key classes.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef RSA_TEST_H
-#define RSA_TEST_H
-
-#include <transforms/rsa/rsa_public_key.h>
-#include <transforms/rsa/rsa_private_key.h>
-
-#include <utils/tester.h>
-
-/**
- * @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/Source/charon/testcases/scheduler_test.c b/Source/charon/testcases/scheduler_test.c
deleted file mode 100644
index de7346d83..000000000
--- a/Source/charon/testcases/scheduler_test.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * @file scheduler_test.c
- *
- * @brief Tests for the scheduler_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <string.h>
-#include <unistd.h>
-
-#include "scheduler_test.h"
-
-#include <daemon.h>
-#include <threads/scheduler.h>
-#include <queues/event_queue.h>
-#include <queues/job_queue.h>
-#include <queues/jobs/incoming_packet_job.h>
-
-
-/**
- * @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/Source/charon/testcases/scheduler_test.h b/Source/charon/testcases/scheduler_test.h
deleted file mode 100644
index 746848e49..000000000
--- a/Source/charon/testcases/scheduler_test.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * @file scheduler_test.h
- *
- * @brief Tests for the scheduler_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef SCHEDULER_TEST_H_
-#define SCHEDULER_TEST_H_
-
-#include <utils/tester.h>
-
-/**
- * @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/Source/charon/testcases/send_queue_test.c b/Source/charon/testcases/send_queue_test.c
deleted file mode 100644
index a56f8e5a2..000000000
--- a/Source/charon/testcases/send_queue_test.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/**
- * @file send_queue_test.c
- *
- * @brief Tests for the send_queue_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <pthread.h>
-
-#include "send_queue_test.h"
-
-#include <queues/send_queue.h>
-
-
-/**
- * @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(AF_INET);
- 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/Source/charon/testcases/send_queue_test.h b/Source/charon/testcases/send_queue_test.h
deleted file mode 100644
index 138657e10..000000000
--- a/Source/charon/testcases/send_queue_test.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * @file send_queue_test.h
- *
- * @brief Tests for the send_queue_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef SEND_QUEUE_TEST_H_
-#define SEND_QUEUE_TEST_H_
-
-#include <utils/tester.h>
-
-/**
- * @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/Source/charon/testcases/sender_test.c b/Source/charon/testcases/sender_test.c
deleted file mode 100644
index 003cf761e..000000000
--- a/Source/charon/testcases/sender_test.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * @file sender_test.h
- *
- * @brief Tests for the sender_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <string.h>
-
-#include "sender_test.h"
-
-#include <daemon.h>
-#include <threads/sender.h>
-#include <network/packet.h>
-#include <network/socket.h>
-#include <queues/send_queue.h>
-#include <queues/job_queue.h>
-#include <utils/allocator.h>
-
-/**
- * Number of packets to send by sender-thread
- */
-#define NUMBER_OF_PACKETS_TO_SEND 50
-
-/**
- * Port to send the packets to
- */
-#define PORT_TO_SEND 4600
-
-/**
- * Destination IP Address
- */
-#define DESTINATION_IP "127.0.0.1"
-
-void test_sender(protected_tester_t *tester)
-{
- int i;
- sender_t *sender;
- packet_t *packet;
- packet_t *received_packet;
- chunk_t packet_data;
- sender = sender_create();
-
- for (i = 0; i < NUMBER_OF_PACKETS_TO_SEND; i++)
- {
- packet = packet_create(AF_INET);
- packet->set_destination(packet, host_create(AF_INET,DESTINATION_IP,PORT_TO_SEND));
- packet_data.ptr = allocator_alloc_thing(int);
- packet_data.len = ( sizeof(int));
- *((int *) (packet_data.ptr)) = i;
- packet->set_data(packet, packet_data);
- charon->send_queue->add(charon->send_queue,packet);
- }
-
- for (i = 0; i < NUMBER_OF_PACKETS_TO_SEND; i++)
- {
- charon->socket->receive(charon->socket,&received_packet);
- packet_data = received_packet->get_data(received_packet);
- tester->assert_true(tester, (packet_data.len == (sizeof(int))), "received data length check");
- tester->assert_true(tester, (i == *((int *)(packet_data.ptr))), "received data value check");
- received_packet->destroy(received_packet);
- }
-
- sender->destroy(sender);
-}
diff --git a/Source/charon/testcases/sender_test.h b/Source/charon/testcases/sender_test.h
deleted file mode 100644
index 1fdfed69d..000000000
--- a/Source/charon/testcases/sender_test.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * @file sender_test.h
- *
- * @brief Tests for the sender_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef SENDER_TEST_H_
-#define SENDER_TEST_H_
-
-#include <utils/tester.h>
-
-/**
- * @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/Source/charon/testcases/socket_test.c b/Source/charon/testcases/socket_test.c
deleted file mode 100644
index 360bf697c..000000000
--- a/Source/charon/testcases/socket_test.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * @file socket_test.c
- *
- * @brief Tests for the socket_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "socket_test.h"
-
-#include <network/socket.h>
-#include <utils/allocator.h>
-
-/*
- * Description in header file
- */
-void test_socket(protected_tester_t *tester)
-{
- int packet_count = 5;
- int current;
- socket_t *skt = socket_create(4500);
- packet_t *pkt = packet_create(AF_INET);
- char *test_string = "Testing functionality of socket_t";
- chunk_t data;
-
-
- data.ptr = allocator_alloc(strlen(test_string) + 1);
- memcpy(data.ptr,test_string,strlen(test_string) + 1);
- data.len = strlen(test_string) + 1;
-
- /* send to previously bound socket */
- pkt->set_destination(pkt, host_create(AF_INET, "127.0.0.1", 4500));
- pkt->set_data(pkt, 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);
- data = pkt->get_data(pkt);
- tester->assert_false(tester, strcmp(test_string, data.ptr), "packet exchange");
- pkt->destroy(pkt);
- }
-
- skt->destroy(skt);
-
-}
diff --git a/Source/charon/testcases/socket_test.h b/Source/charon/testcases/socket_test.h
deleted file mode 100644
index a59995297..000000000
--- a/Source/charon/testcases/socket_test.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * @file socket_test.h
- *
- * @brief Tests for the socket_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef SOCKET_TEST_H_
-#define SOCKET_TEST_H_
-
-#include <utils/tester.h>
-
-/**
- * @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/Source/charon/testcases/testcases.c b/Source/charon/testcases/testcases.c
deleted file mode 100644
index 627ab6e88..000000000
--- a/Source/charon/testcases/testcases.c
+++ /dev/null
@@ -1,275 +0,0 @@
-/**
- * @file tests.c
- *
- * @brief Main for all testcases.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-
-#include <stdio.h>
-
-#include <daemon.h>
-
-#include <queues/job_queue.h>
-#include <queues/event_queue.h>
-#include <queues/send_queue.h>
-#include <config/configuration.h>
-#include <sa/ike_sa_manager.h>
-#include <network/socket.h>
-#include <utils/logger_manager.h>
-#include <utils/allocator.h>
-#include <utils/tester.h>
-#include <testcases/linked_list_test.h>
-#include <testcases/thread_pool_test.h>
-#include <testcases/job_queue_test.h>
-#include <testcases/event_queue_test.h>
-#include <testcases/send_queue_test.h>
-#include <testcases/socket_test.h>
-#include <testcases/sender_test.h>
-#include <testcases/scheduler_test.h>
-#include <testcases/receiver_test.h>
-#include <testcases/ike_sa_id_test.h>
-#include <testcases/ike_sa_test.h>
-#include <testcases/ike_sa_manager_test.h>
-#include <testcases/generator_test.h>
-#include <testcases/parser_test.h>
-#include <testcases/packet_test.h>
-#include <testcases/diffie_hellman_test.h>
-#include <testcases/hasher_test.h>
-#include <testcases/hmac_test.h>
-#include <testcases/prf_plus_test.h>
-#include <testcases/aes_cbc_crypter_test.h>
-#include <testcases/hmac_signer_test.h>
-#include <testcases/encryption_payload_test.h>
-#include <testcases/connection_test.h>
-#include <testcases/policy_test.h>
-#include <testcases/proposal_test.h>
-#include <testcases/rsa_test.h>
-#include <testcases/kernel_interface_test.h>
-#include <testcases/child_sa_test.h>
-#include <testcases/der_decoder_test.h>
-#include <testcases/certificate_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 receiver_test = {test_receiver,"Receiver"};
-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_test = {test_kernel_interface, "Kernel Interface"};
-test_t child_sa_test = {test_child_sa, "Child SA"};
-test_t der_decoder_test = {test_der_decoder, "DER decoder"};
-test_t certificate_test = {test_certificate, "X509 Certificate"};
-
-
-daemon_t* charon;
-
-static void daemon_kill(daemon_t *this, char* none)
-{
- this->logger_manager->destroy(this->logger_manager);
- //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);
- allocator_free(charon);
-}
-
-/**
- * @brief Create the dummy daemon for testing.
- *
- * @return created daemon_t
- */
-daemon_t *daemon_create()
-{
- charon = allocator_alloc_thing(daemon_t);
-
- /* assign methods */
- charon->kill = daemon_kill;
-
- charon->logger_manager = logger_manager_create(0);
- //charon->socket = socket_create(4510);
- 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,
- &receiver_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;
-
- /* allocator needs initialization */
- allocator_init();
-
- daemon_create();
-
- //charon->logger_manager->enable_log_level(charon->logger_manager, ALL_LOGGERS, FULL);
- charon->logger_manager->set_output(charon->logger_manager, ALL_LOGGERS, stdout);
-
- tester_t *tester = tester_create(test_output, FALSE);
-
- //tester->perform_tests(tester,all_tests);
- tester->perform_test(tester,&rsa_test);
-
-
- tester->destroy(tester);
-
- charon->kill(charon, NULL);
-
-#ifdef LEAK_DETECTIVE
- /* Leaks are reported on stderr */
- report_memory_leaks(void);
-#endif
-
- return 0;
-}
diff --git a/Source/charon/testcases/thread_pool_test.c b/Source/charon/testcases/thread_pool_test.c
deleted file mode 100644
index ee7a5101f..000000000
--- a/Source/charon/testcases/thread_pool_test.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * @file thread_pool_test.c
- *
- * @brief Tests for the thread_pool_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <stdlib.h>
-
-#include "thread_pool_test.h"
-
-#include <threads/thread_pool.h>
-
-/*
- * 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/Source/charon/testcases/thread_pool_test.h b/Source/charon/testcases/thread_pool_test.h
deleted file mode 100644
index bdae797b7..000000000
--- a/Source/charon/testcases/thread_pool_test.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * @file thread_pool_test.h
- *
- * @brief Tests for the thread_pool_t class.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef THREAD_POOL_TEST_H_
-#define THREAD_POOL_TEST_H_
-
-#include <utils/tester.h>
-
-/**
- * @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_*/
diff --git a/Source/charon/threads/Makefile.threads b/Source/charon/threads/Makefile.threads
index 043f547bc..949c1ad24 100644
--- a/Source/charon/threads/Makefile.threads
+++ b/Source/charon/threads/Makefile.threads
@@ -12,28 +12,28 @@
# for more details.
#
-THREADS_DIR= $(MAIN_DIR)threads/
+THREADS_DIR= $(CHARON_DIR)threads/
-OBJS+= $(BUILD_DIR)receiver.o
+CHARON_OBJS+= $(BUILD_DIR)receiver.o
$(BUILD_DIR)receiver.o : $(THREADS_DIR)receiver.c $(THREADS_DIR)receiver.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)scheduler.o
+CHARON_OBJS+= $(BUILD_DIR)scheduler.o
$(BUILD_DIR)scheduler.o : $(THREADS_DIR)scheduler.c $(THREADS_DIR)scheduler.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)sender.o
+CHARON_OBJS+= $(BUILD_DIR)sender.o
$(BUILD_DIR)sender.o : $(THREADS_DIR)sender.c $(THREADS_DIR)sender.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)thread_pool.o
+CHARON_OBJS+= $(BUILD_DIR)thread_pool.o
$(BUILD_DIR)thread_pool.o : $(THREADS_DIR)thread_pool.c $(THREADS_DIR)thread_pool.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)kernel_interface.o
+CHARON_OBJS+= $(BUILD_DIR)kernel_interface.o
$(BUILD_DIR)kernel_interface.o :$(THREADS_DIR)kernel_interface.c $(THREADS_DIR)kernel_interface.h
$(CC) $(CFLAGS) -c -o $@ $<
-OBJS+= $(BUILD_DIR)stroke_interface.o
+CHARON_OBJS+= $(BUILD_DIR)stroke_interface.o
$(BUILD_DIR)stroke_interface.o :$(THREADS_DIR)stroke_interface.c $(THREADS_DIR)stroke_interface.h
$(CC) $(CFLAGS) -c -o $@ $<
diff --git a/Source/charon/threads/kernel_interface.h b/Source/charon/threads/kernel_interface.h
index f7621afd9..ceafa6468 100644
--- a/Source/charon/threads/kernel_interface.h
+++ b/Source/charon/threads/kernel_interface.h
@@ -25,7 +25,7 @@
#include <linux/xfrm.h>
-#include <network/host.h>
+#include <utils/host.h>
#include <encoding/payloads/proposal_substructure.h>
typedef struct kernel_interface_t kernel_interface_t;
diff --git a/Source/charon/threads/stroke_interface.c b/Source/charon/threads/stroke_interface.c
index 5ef2737ff..4468a37cf 100755
--- a/Source/charon/threads/stroke_interface.c
+++ b/Source/charon/threads/stroke_interface.c
@@ -36,7 +36,7 @@
#include <stroke.h>
#include <types.h>
#include <daemon.h>
-#include <transforms/certificate.h>
+#include <crypto/certificate.h>
#include <utils/allocator.h>
#include <queues/jobs/initiate_ike_sa_job.h>
diff --git a/Source/charon/transforms/Makefile.transforms b/Source/charon/transforms/Makefile.transforms
deleted file mode 100644
index 4be5d270b..000000000
--- a/Source/charon/transforms/Makefile.transforms
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2005 Jan Hutter, Martin Willi
-# Hochschule fuer Technik Rapperswil
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the
-# Free Software Foundation; either version 2 of the License, or (at your
-# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# for more details.
-#
-
-TRANSFORMS_DIR= $(MAIN_DIR)transforms/
-
-include $(TRANSFORMS_DIR)crypters/Makefile.crypters
-include $(TRANSFORMS_DIR)hashers/Makefile.hashers
-include $(TRANSFORMS_DIR)prfs/Makefile.prfs
-include $(TRANSFORMS_DIR)signers/Makefile.signers
-include $(TRANSFORMS_DIR)rsa/Makefile.rsa
-
-OBJS+= $(BUILD_DIR)diffie_hellman.o
-$(BUILD_DIR)diffie_hellman.o : $(TRANSFORMS_DIR)diffie_hellman.c $(TRANSFORMS_DIR)diffie_hellman.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-OBJS+= $(BUILD_DIR)hmac.o
-$(BUILD_DIR)hmac.o : $(TRANSFORMS_DIR)hmac.c $(TRANSFORMS_DIR)hmac.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-OBJS+= $(BUILD_DIR)prf_plus.o
-$(BUILD_DIR)prf_plus.o : $(TRANSFORMS_DIR)prf_plus.c $(TRANSFORMS_DIR)prf_plus.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-OBJS+= $(BUILD_DIR)certificate.o
-$(BUILD_DIR)certificate.o : $(TRANSFORMS_DIR)certificate.c $(TRANSFORMS_DIR)certificate.h
- $(CC) $(CFLAGS) -c -o $@ $<
diff --git a/Source/charon/transforms/certificate.c b/Source/charon/transforms/certificate.c
deleted file mode 100755
index 2c8f30bf3..000000000
--- a/Source/charon/transforms/certificate.c
+++ /dev/null
@@ -1,230 +0,0 @@
-/**
- * @file certificate.c
- *
- * @brief Implementation of certificate_t.
- *
- */
-
-/*
- * Copyright (C) 2006 Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <gmp.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-#include "certificate.h"
-
-#include <daemon.h>
-#include <utils/allocator.h>
-#include <asn1/der_decoder.h>
-
-
-typedef struct private_certificate_t private_certificate_t;
-
-/**
- * Private data of a certificate_t object.
- */
-struct private_certificate_t {
- /**
- * Public interface for this signer.
- */
- certificate_t public;
-
- u_int version;
-
- u_int serial;
-
- chunk_t sign_alg;
-
- time_t not_before;
-
- time_t not_after;
-
- chunk_t pubkey;
-
- chunk_t pubkey_alg;
-
- bool has_issuer_uid;
- chunk_t issuer_uid;
-
- bool has_subject_uid;
- chunk_t subject_uid;
-
- chunk_t tbs_cert;
- chunk_t signature;
-
- rsa_public_key_t *public_key;
-};
-
-#define OSET(x) offsetof(private_certificate_t, x)
-
-/**
- * Rules for de-/encoding of a certificate from/in ASN1
- */
-static asn1_rule_t certificate_rules[] = {
- {ASN1_SEQUENCE, 0, 0, 0 }, /* certificate */
- { ASN1_SEQUENCE, ASN1_RAW, OSET(tbs_cert), 0 }, /* tbsCertificate */
- { ASN1_TAG_E_0, ASN1_DEFAULT, OSET(version), 0 }, /* EXPLICIT */
- { ASN1_INTEGER, ASN1_DEFAULT, OSET(version), 0 }, /* version DEFAULT v1(0) */
- { ASN1_INTEGER, 0, OSET(serial), 0 }, /* serialNumber */
- { ASN1_SEQUENCE, 0, 0, 0 }, /* signature */
- { ASN1_OID, 0, OSET(sign_alg), 0 }, /* algorithm-oid */
- { ASN1_NULL, 0, 0, 0 }, /* parameters */
- { ASN1_END, 0, 0, 0 }, /* signature */
- { ASN1_SEQUENCE, ASN1_OF, 0, 0 }, /* issuer */
-// { ASN1_SET, ASN1_OF, 0, 0, }, /* RelativeDistinguishedName */
-// { ASN1_SEQUENCE, 0, 0, 0, }, /* AttributeTypeAndValue */
-// { ASN1_OID, 0, 0, 0 }, /* AttributeType */
-// { ASN1_ANY, 0, 0, 0 }, /* AttributeValue */
-// { ASN1_END, 0, 0, 0 }, /* AttributeTypeAndValue */
-// { ASN1_END, 0, 0, 0 }, /* RelativeDistinguishedName */
- { ASN1_END, 0, 0, 0 }, /* issuer */
- { ASN1_SEQUENCE, 0, 0, 0 }, /* validity */
- { ASN1_CHOICE, 0, 0, 0 }, /* notBefore */
- { ASN1_UTCTIME, 0, OSET(not_before), 0 }, /* utcTime */
- { ASN1_GENERALIZEDTIME, 0, OSET(not_before), 0 }, /* generalTime */
- { ASN1_END, 0, 0, 0 }, /* notBefore */
- { ASN1_CHOICE, 0, 0, 0 }, /* notAfter */
- { ASN1_UTCTIME, 0, OSET(not_after), 0 }, /* utcTime */
- { ASN1_GENERALIZEDTIME, 0, OSET(not_after), 0 }, /* generalTime */
- { ASN1_END, 0, 0, 0 }, /* notAfter */
- { ASN1_END, 0, 0, 0 }, /* validity */
- { ASN1_SEQUENCE, ASN1_OF, 0, 0 }, /* subject */
-// { ASN1_SET, ASN1_OF, 0, 0, }, /* RelativeDistinguishedName */
-// { ASN1_SEQUENCE, 0, 0, 0, }, /* AttributeTypeAndValue */
-// { ASN1_OID, 0, 0, 0 }, /* AttributeType */
-// { ASN1_ANY, 0, 0, 0 }, /* AttributeValue */
-// { ASN1_END, 0, 0, 0 }, /* AttributeTypeAndValue */
-// { ASN1_END, 0, 0, 0 }, /* RelativeDistinguishedName */
- { ASN1_END, 0, 0, 0 }, /* subject */
- { ASN1_SEQUENCE, 0, 0, 0 }, /* subjectPublicKeyInfo */
- { ASN1_SEQUENCE, 0, 0, 0 }, /* algorithm */
- { ASN1_OID, 0, OSET(pubkey_alg), 0 }, /* algorithm-oid */
- { ASN1_NULL, 0, 0, 0 }, /* parameters */
- { ASN1_END, 0, 0, 0 }, /* algorithm */
- { ASN1_BITSTRING, 0, OSET(pubkey), 0 }, /* subjectPublicKey */
- { ASN1_END, 0, 0, 0 }, /* subjectPublicKeyInfo */
- { ASN1_TAG_I_1, ASN1_OPTIONAL, 0, OSET(has_issuer_uid)}, /* IMPLICIT */
- { ASN1_BITSTRING, ASN1_OPTIONAL, OSET(issuer_uid), 0 }, /* issuerUniqueID OPTIONAL */
- { ASN1_TAG_I_2, ASN1_OPTIONAL, 0, OSET(has_subject_uid)},/* IMPLICIT */
- { ASN1_BITSTRING, ASN1_OPTIONAL, OSET(subject_uid), 0 }, /* subjectUniqueID OPTIONAL */
- { ASN1_TAG_E_3, ASN1_OPTIONAL, 0, 0 }, /* EXPLICIT */
- { ASN1_SEQUENCE, ASN1_OF|ASN1_OPTIONAL, 0, 0 }, /* extensions OPTIONAL */
-// { ASN1_SEQUENCE, 0, 0, 0, }, /* extension */
-// { ASN1_OID, 0, 0, 0 }, /* extnID */
-// { ASN1_BOOLEAN, ASN1_DEFAULT, 0, FALSE }, /* critical */
-// { ASN1_OCTETSTRING, 0, 0, 0, }, /* extnValue */
-// { ASN1_END, 0, 0, 0, }, /* extension */
- { ASN1_END, 0, 0, 0, }, /* extensions */
- { ASN1_END, 0, 0, 0 }, /* tbsCertificate */
- { ASN1_SEQUENCE, 0, 0, 0 }, /* signatureAlgorithm */
- { ASN1_OID, 0, OSET(sign_alg), 0 }, /* algorithm-oid */
- { ASN1_NULL, 0, 0, 0 }, /* parameters */
- { ASN1_END, 0, 0, 0 }, /* signatureAlgorithm */
- { ASN1_BITSTRING, 0, OSET(signature), 0 }, /* signatureValue */
- {ASN1_END, 0, 0, 0 }, /* certificate */
-};
-
-/**
- * Implementation of certificate.get_public_key.
- */
-static rsa_public_key_t *get_public_key(private_certificate_t *this)
-{
- return this->public_key->clone(this->public_key);
-}
-
-/**
- * Implementation of certificate.destroy.
- */
-static void destroy(private_certificate_t *this)
-{
- this->public_key->destroy(this->public_key);
- allocator_free(this->pubkey.ptr);
- allocator_free(this->signature.ptr);
- allocator_free(this->tbs_cert.ptr);
- allocator_free(this);
-}
-
-/*
- * Described in header.
- */
-certificate_t *certificate_create_from_chunk(chunk_t chunk)
-{
- private_certificate_t *this = allocator_alloc_thing(private_certificate_t);
- der_decoder_t *dd;
-
- /* public functions */
- this->public.get_public_key = (rsa_public_key_t *(*) (certificate_t*))get_public_key;
- this->public.destroy = (void (*) (certificate_t*))destroy;
-
- /* initialize */
- this->pubkey = CHUNK_INITIALIZER;
- this->signature = CHUNK_INITIALIZER;
- this->tbs_cert = CHUNK_INITIALIZER;
-
- dd = der_decoder_create(certificate_rules);
-
- if (dd->decode(dd, chunk, this) != SUCCESS)
- {
- allocator_free(this);
- dd->destroy(dd);
- return NULL;
- }
- dd->destroy(dd);
-
- this->public_key = rsa_public_key_create_from_chunk(this->pubkey);
- if (this->public_key == NULL)
- {
- allocator_free(this->pubkey.ptr);
- allocator_free(this);
- return NULL;
- }
-
- return &this->public;
-}
-
-/*
- * Described in header.
- */
-certificate_t *certificate_create_from_file(char *filename)
-{
- struct stat stb;
- FILE *file;
- char *buffer;
- chunk_t chunk;
-
- if (stat(filename, &stb) == -1)
- {
- return NULL;
- }
-
- buffer = alloca(stb.st_size);
-
- file = fopen(filename, "r");
- if (file == NULL)
- {
- return NULL;
- }
-
- if (fread(buffer, stb.st_size, 1, file) == -1)
- {
- return NULL;
- }
-
- chunk.ptr = buffer;
- chunk.len = stb.st_size;
-
- return certificate_create_from_chunk(chunk);
-}
diff --git a/Source/charon/transforms/certificate.h b/Source/charon/transforms/certificate.h
deleted file mode 100755
index 69baed0da..000000000
--- a/Source/charon/transforms/certificate.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * @file certificate.h
- *
- * @brief Interface of certificate_t.
- *
- */
-
-/*
- * Copyright (C) 2006 Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef CERTIFICATE_H_
-#define CERTIFICATE_H_
-
-#include <types.h>
-#include <definitions.h>
-#include <transforms/rsa/rsa_public_key.h>
-
-
-typedef struct certificate_t certificate_t;
-
-/**
- * @brief X509 certificate.
- *
- * @b Constructors:
- * - certificate_create_from_chunk()
- *
- * @ingroup transforms
- */
-struct certificate_t {
-
- /**
- * @brief Get the RSA public key from the certificate.
- *
- * @param this calling object
- * @return public_key
- */
- rsa_public_key_t *(*get_public_key) (certificate_t *this);
-
- /**
- * @brief Destroys the private key.
- *
- * @param this private key to destroy
- */
- void (*destroy) (certificate_t *this);
-};
-
-/**
- * @brief Read a certificate from a blob.
- *
- * @return created certificate_t.
- *
- * @ingroup transforms
- */
-certificate_t *certificate_create_from_chunk(chunk_t chunk);
-
-certificate_t *certificate_create_from_file(char *filename);
-
-#endif /* CERTIFICATE_H_ */
diff --git a/Source/charon/transforms/crypters/Makefile.crypters b/Source/charon/transforms/crypters/Makefile.crypters
deleted file mode 100644
index 232787cd8..000000000
--- a/Source/charon/transforms/crypters/Makefile.crypters
+++ /dev/null
@@ -1,23 +0,0 @@
-# Copyright (C) 2005 Jan Hutter, Martin Willi
-# Hochschule fuer Technik Rapperswil
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the
-# Free Software Foundation; either version 2 of the License, or (at your
-# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# for more details.
-#
-
-CRYPTERS_DIR= $(TRANSFORMS_DIR)crypters/
-
-OBJS+= $(BUILD_DIR)crypter.o
-$(BUILD_DIR)crypter.o : $(CRYPTERS_DIR)crypter.c $(CRYPTERS_DIR)crypter.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-OBJS+= $(BUILD_DIR)aes_cbc_crypter.o
-$(BUILD_DIR)aes_cbc_crypter.o : $(CRYPTERS_DIR)aes_cbc_crypter.c $(CRYPTERS_DIR)aes_cbc_crypter.h
- $(CC) $(CFLAGS) -c -o $@ $<
diff --git a/Source/charon/transforms/crypters/aes_cbc_crypter.c b/Source/charon/transforms/crypters/aes_cbc_crypter.c
deleted file mode 100644
index d5d0f9a60..000000000
--- a/Source/charon/transforms/crypters/aes_cbc_crypter.c
+++ /dev/null
@@ -1,1628 +0,0 @@
-/**
- * @file aes_cbc_crypter.c
- *
- * @brief Implementation of aes_cbc_crypter_t
- *
- */
-
- /*
- * Copyright (C) 2001 Dr B. R. Gladman <brg@gladman.uk.net>
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "aes_cbc_crypter.h"
-
-#include <utils/allocator.h>
-
-
-/*
- * The number of key schedule words for different block and key lengths
- * allowing for method of computation which requires the length to be a
- * multiple of the key length. This version of AES implementation supports
- * all three keylengths 16, 24 and 32 bytes!
- *
- * Nk = 4 6 8
- * -------------
- * Nb = 4 | 60 60 64
- * 6 | 96 90 96
- * 8 | 120 120 120
- */
-#define AES_KS_LENGTH 120
-#define AES_RC_LENGTH 29
-
-#define AES_BLOCK_SIZE 16
-
-typedef struct private_aes_cbc_crypter_t private_aes_cbc_crypter_t;
-
-/**
- * @brief Class implementing the AES symmetric encryption algorithm.
- *
- * @ingroup crypters
- */
-struct private_aes_cbc_crypter_t {
-
- /**
- * Public part of this class.
- */
- aes_cbc_crypter_t public;
-
- /**
- * Number of words in the key input block.
- */
- u_int32_t aes_Nkey;
-
- /**
- * The number of cipher rounds.
- */
- u_int32_t aes_Nrnd;
-
- /**
- * The encryption key schedule.
- */
- u_int32_t aes_e_key[AES_KS_LENGTH];
-
- /**
- * The decryption key schedule.
- */
- u_int32_t aes_d_key[AES_KS_LENGTH];
-
- /**
- * The number of columns in the cipher state.
- */
- u_int32_t aes_Ncol;
-
- /**
- * Key size of this AES cypher object.
- */
- u_int32_t key_size;
-
- /**
- * Decrypts a block.
- *
- * No memory gets allocated.
- *
- * @param this calling object
- * @param[in] in_blk block to decrypt
- * @param[out] out_blk decrypted data are written to this location
- */
- void (*decrypt_block) (const private_aes_cbc_crypter_t *this, const unsigned char in_blk[], unsigned char out_blk[]);
-
- /**
- * Encrypts a block.
- *
- * No memory gets allocated.
- *
- * @param this calling object
- * @param[in] in_blk block to encrypt
- * @param[out] out_blk encrypted data are written to this location
- */
- void (*encrypt_block) (const private_aes_cbc_crypter_t *this, const unsigned char in_blk[], unsigned char out_blk[]);
-};
-
-
-/* ugly macro stuff */
-
-/* 1. Define UNROLL for full loop unrolling in encryption and decryption.
- * 2. Define PARTIAL_UNROLL to unroll two loops in encryption and decryption.
- * 3. Define FIXED_TABLES for compiled rather than dynamic tables.
- * 4. Define FF_TABLES to use tables for field multiplies and inverses.
- * Do not enable this without understanding stack space requirements.
- * 5. Define ARRAYS to use arrays to hold the local state block. If this
- * is not defined, individually declared 32-bit words are used.
- * 6. Define FAST_VARIABLE if a high speed variable block implementation
- * is needed (essentially three separate fixed block size code sequences)
- * 7. Define either ONE_TABLE or FOUR_TABLES for a fast table driven
- * version using 1 table (2 kbytes of table space) or 4 tables (8
- * kbytes of table space) for higher speed.
- * 8. Define either ONE_LR_TABLE or FOUR_LR_TABLES for a further speed
- * increase by using tables for the last rounds but with more table
- * space (2 or 8 kbytes extra).
- * 9. If neither ONE_TABLE nor FOUR_TABLES is defined, a compact but
- * slower version is provided.
- * 10. If fast decryption key scheduling is needed define ONE_IM_TABLE
- * or FOUR_IM_TABLES for higher speed (2 or 8 kbytes extra).
- */
-
-#define UNROLL
-//#define PARTIAL_UNROLL
-
-#define FIXED_TABLES
-//#define FF_TABLES
-//#define ARRAYS
-#define FAST_VARIABLE
-
-//#define ONE_TABLE
-#define FOUR_TABLES
-
-//#define ONE_LR_TABLE
-#define FOUR_LR_TABLES
-
-//#define ONE_IM_TABLE
-#define FOUR_IM_TABLES
-
-#if defined(UNROLL) && defined (PARTIAL_UNROLL)
-#error both UNROLL and PARTIAL_UNROLL are defined
-#endif
-
-#if defined(ONE_TABLE) && defined (FOUR_TABLES)
-#error both ONE_TABLE and FOUR_TABLES are defined
-#endif
-
-#if defined(ONE_LR_TABLE) && defined (FOUR_LR_TABLES)
-#error both ONE_LR_TABLE and FOUR_LR_TABLES are defined
-#endif
-
-#if defined(ONE_IM_TABLE) && defined (FOUR_IM_TABLES)
-#error both ONE_IM_TABLE and FOUR_IM_TABLES are defined
-#endif
-
-#if defined(AES_BLOCK_SIZE) && AES_BLOCK_SIZE != 16 && AES_BLOCK_SIZE != 24 && AES_BLOCK_SIZE != 32
-#error an illegal block size has been specified
-#endif
-
-/**
- * Rotates bytes within words by n positions, moving bytes
- * to higher index positions with wrap around into low positions.
- */
-#define upr(x,n) (((x) << 8 * (n)) | ((x) >> (32 - 8 * (n))))
-/**
- * Moves bytes by n positions to higher index positions in
- * words but without wrap around.
- */
-#define ups(x,n) ((x) << 8 * (n))
-
-/**
- * Extracts a byte from a word.
- */
-#define bval(x,n) ((unsigned char)((x) >> 8 * (n)))
-#define bytes2word(b0, b1, b2, b3) \
- ((u_int32_t)(b3) << 24 | (u_int32_t)(b2) << 16 | (u_int32_t)(b1) << 8 | (b0))
-
-
-/* little endian processor without data alignment restrictions: AES_LE_OK */
-/* original code: i386 */
-#if defined(i386) || defined(_I386) || defined(__i386__) || defined(__i386)
-#define AES_LE_OK 1
-/* added (tested): alpha --jjo */
-#elif defined(__alpha__)|| defined (__alpha)
-#define AES_LE_OK 1
-/* added (tested): ia64 --jjo */
-#elif defined(__ia64__)|| defined (__ia64)
-#define AES_LE_OK 1
-#endif
-
-#ifdef AES_LE_OK
-/* little endian processor without data alignment restrictions */
-#define word_in(x) *(u_int32_t*)(x)
-#define const_word_in(x) *(const u_int32_t*)(x)
-#define word_out(x,v) *(u_int32_t*)(x) = (v)
-#define const_word_out(x,v) *(const u_int32_t*)(x) = (v)
-#else
-/* slower but generic big endian or with data alignment restrictions */
-/* some additional "const" touches to stop "gcc -Wcast-qual" complains --jjo */
-#define word_in(x) ((u_int32_t)(((unsigned char *)(x))[0])|((u_int32_t)(((unsigned char *)(x))[1])<<8)|((u_int32_t)(((unsigned char *)(x))[2])<<16)|((u_int32_t)(((unsigned char *)(x))[3])<<24))
-#define const_word_in(x) ((const u_int32_t)(((const unsigned char *)(x))[0])|((const u_int32_t)(((const unsigned char *)(x))[1])<<8)|((const u_int32_t)(((const unsigned char *)(x))[2])<<16)|((const u_int32_t)(((const unsigned char *)(x))[3])<<24))
-#define word_out(x,v) ((unsigned char *)(x))[0]=(v),((unsigned char *)(x))[1]=((v)>>8),((unsigned char *)(x))[2]=((v)>>16),((unsigned char *)(x))[3]=((v)>>24)
-#define const_word_out(x,v) ((const unsigned char *)(x))[0]=(v),((const unsigned char *)(x))[1]=((v)>>8),((const unsigned char *)(x))[2]=((v)>>16),((const unsigned char *)(x))[3]=((v)>>24)
-#endif
-
-// Disable at least some poor combinations of options
-
-#if !defined(ONE_TABLE) && !defined(FOUR_TABLES)
-#define FIXED_TABLES
-#undef UNROLL
-#undef ONE_LR_TABLE
-#undef FOUR_LR_TABLES
-#undef ONE_IM_TABLE
-#undef FOUR_IM_TABLES
-#elif !defined(FOUR_TABLES)
-#ifdef FOUR_LR_TABLES
-#undef FOUR_LR_TABLES
-#define ONE_LR_TABLE
-#endif
-#ifdef FOUR_IM_TABLES
-#undef FOUR_IM_TABLES
-#define ONE_IM_TABLE
-#endif
-#elif !defined(AES_BLOCK_SIZE)
-#if defined(UNROLL)
-#define PARTIAL_UNROLL
-#undef UNROLL
-#endif
-#endif
-
-// the finite field modular polynomial and elements
-
-#define ff_poly 0x011b
-#define ff_hi 0x80
-
-// multiply four bytes in GF(2^8) by 'x' {02} in parallel
-
-#define m1 0x80808080
-#define m2 0x7f7f7f7f
-#define m3 0x0000001b
-#define FFmulX(x) ((((x) & m2) << 1) ^ ((((x) & m1) >> 7) * m3))
-
-// The following defines provide alternative definitions of FFmulX that might
-// give improved performance if a fast 32-bit multiply is not available. Note
-// that a temporary variable u needs to be defined where FFmulX is used.
-
-// #define FFmulX(x) (u = (x) & m1, u |= (u >> 1), ((x) & m2) << 1) ^ ((u >> 3) | (u >> 6))
-// #define m4 0x1b1b1b1b
-// #define FFmulX(x) (u = (x) & m1, ((x) & m2) << 1) ^ ((u - (u >> 7)) & m4)
-
-// perform column mix operation on four bytes in parallel
-
-#define fwd_mcol(x) (f2 = FFmulX(x), f2 ^ upr(x ^ f2,3) ^ upr(x,2) ^ upr(x,1))
-
-#if defined(FIXED_TABLES)
-
-// the S-Box table
-
-static const unsigned char s_box[256] =
-{
- 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5,
- 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
- 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0,
- 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
- 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc,
- 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
- 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a,
- 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
- 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0,
- 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
- 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b,
- 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
- 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85,
- 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
- 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5,
- 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
- 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17,
- 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
- 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88,
- 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
- 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c,
- 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
- 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9,
- 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
- 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6,
- 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
- 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e,
- 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
- 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94,
- 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
- 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68,
- 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
-};
-
-// the inverse S-Box table
-
-static const unsigned char inv_s_box[256] =
-{
- 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38,
- 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb,
- 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87,
- 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb,
- 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d,
- 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e,
- 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2,
- 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25,
- 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16,
- 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92,
- 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda,
- 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84,
- 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a,
- 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06,
- 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02,
- 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b,
- 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea,
- 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73,
- 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85,
- 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e,
- 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89,
- 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b,
- 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20,
- 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4,
- 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31,
- 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f,
- 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d,
- 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef,
- 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0,
- 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61,
- 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26,
- 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d
-};
-
-#define w0(p) 0x000000##p
-
-// Number of elements required in this table for different
-// block and key lengths is:
-//
-// Nk = 4 6 8
-// ----------
-// Nb = 4 | 10 8 7
-// 6 | 19 12 11
-// 8 | 29 19 14
-//
-// this table can be a table of bytes if the key schedule
-// code is adjusted accordingly
-
-static const u_int32_t rcon_tab[29] =
-{
- w0(01), w0(02), w0(04), w0(08),
- w0(10), w0(20), w0(40), w0(80),
- w0(1b), w0(36), w0(6c), w0(d8),
- w0(ab), w0(4d), w0(9a), w0(2f),
- w0(5e), w0(bc), w0(63), w0(c6),
- w0(97), w0(35), w0(6a), w0(d4),
- w0(b3), w0(7d), w0(fa), w0(ef),
- w0(c5)
-};
-
-#undef w0
-
-#define r0(p,q,r,s) 0x##p##q##r##s
-#define r1(p,q,r,s) 0x##q##r##s##p
-#define r2(p,q,r,s) 0x##r##s##p##q
-#define r3(p,q,r,s) 0x##s##p##q##r
-#define w0(p) 0x000000##p
-#define w1(p) 0x0000##p##00
-#define w2(p) 0x00##p##0000
-#define w3(p) 0x##p##000000
-
-#if defined(FIXED_TABLES) && (defined(ONE_TABLE) || defined(FOUR_TABLES))
-
-// data for forward tables (other than last round)
-
-#define f_table \
- r(a5,63,63,c6), r(84,7c,7c,f8), r(99,77,77,ee), r(8d,7b,7b,f6),\
- r(0d,f2,f2,ff), r(bd,6b,6b,d6), r(b1,6f,6f,de), r(54,c5,c5,91),\
- r(50,30,30,60), r(03,01,01,02), r(a9,67,67,ce), r(7d,2b,2b,56),\
- r(19,fe,fe,e7), r(62,d7,d7,b5), r(e6,ab,ab,4d), r(9a,76,76,ec),\
- r(45,ca,ca,8f), r(9d,82,82,1f), r(40,c9,c9,89), r(87,7d,7d,fa),\
- r(15,fa,fa,ef), r(eb,59,59,b2), r(c9,47,47,8e), r(0b,f0,f0,fb),\
- r(ec,ad,ad,41), r(67,d4,d4,b3), r(fd,a2,a2,5f), r(ea,af,af,45),\
- r(bf,9c,9c,23), r(f7,a4,a4,53), r(96,72,72,e4), r(5b,c0,c0,9b),\
- r(c2,b7,b7,75), r(1c,fd,fd,e1), r(ae,93,93,3d), r(6a,26,26,4c),\
- r(5a,36,36,6c), r(41,3f,3f,7e), r(02,f7,f7,f5), r(4f,cc,cc,83),\
- r(5c,34,34,68), r(f4,a5,a5,51), r(34,e5,e5,d1), r(08,f1,f1,f9),\
- r(93,71,71,e2), r(73,d8,d8,ab), r(53,31,31,62), r(3f,15,15,2a),\
- r(0c,04,04,08), r(52,c7,c7,95), r(65,23,23,46), r(5e,c3,c3,9d),\
- r(28,18,18,30), r(a1,96,96,37), r(0f,05,05,0a), r(b5,9a,9a,2f),\
- r(09,07,07,0e), r(36,12,12,24), r(9b,80,80,1b), r(3d,e2,e2,df),\
- r(26,eb,eb,cd), r(69,27,27,4e), r(cd,b2,b2,7f), r(9f,75,75,ea),\
- r(1b,09,09,12), r(9e,83,83,1d), r(74,2c,2c,58), r(2e,1a,1a,34),\
- r(2d,1b,1b,36), r(b2,6e,6e,dc), r(ee,5a,5a,b4), r(fb,a0,a0,5b),\
- r(f6,52,52,a4), r(4d,3b,3b,76), r(61,d6,d6,b7), r(ce,b3,b3,7d),\
- r(7b,29,29,52), r(3e,e3,e3,dd), r(71,2f,2f,5e), r(97,84,84,13),\
- r(f5,53,53,a6), r(68,d1,d1,b9), r(00,00,00,00), r(2c,ed,ed,c1),\
- r(60,20,20,40), r(1f,fc,fc,e3), r(c8,b1,b1,79), r(ed,5b,5b,b6),\
- r(be,6a,6a,d4), r(46,cb,cb,8d), r(d9,be,be,67), r(4b,39,39,72),\
- r(de,4a,4a,94), r(d4,4c,4c,98), r(e8,58,58,b0), r(4a,cf,cf,85),\
- r(6b,d0,d0,bb), r(2a,ef,ef,c5), r(e5,aa,aa,4f), r(16,fb,fb,ed),\
- r(c5,43,43,86), r(d7,4d,4d,9a), r(55,33,33,66), r(94,85,85,11),\
- r(cf,45,45,8a), r(10,f9,f9,e9), r(06,02,02,04), r(81,7f,7f,fe),\
- r(f0,50,50,a0), r(44,3c,3c,78), r(ba,9f,9f,25), r(e3,a8,a8,4b),\
- r(f3,51,51,a2), r(fe,a3,a3,5d), r(c0,40,40,80), r(8a,8f,8f,05),\
- r(ad,92,92,3f), r(bc,9d,9d,21), r(48,38,38,70), r(04,f5,f5,f1),\
- r(df,bc,bc,63), r(c1,b6,b6,77), r(75,da,da,af), r(63,21,21,42),\
- r(30,10,10,20), r(1a,ff,ff,e5), r(0e,f3,f3,fd), r(6d,d2,d2,bf),\
- r(4c,cd,cd,81), r(14,0c,0c,18), r(35,13,13,26), r(2f,ec,ec,c3),\
- r(e1,5f,5f,be), r(a2,97,97,35), r(cc,44,44,88), r(39,17,17,2e),\
- r(57,c4,c4,93), r(f2,a7,a7,55), r(82,7e,7e,fc), r(47,3d,3d,7a),\
- r(ac,64,64,c8), r(e7,5d,5d,ba), r(2b,19,19,32), r(95,73,73,e6),\
- r(a0,60,60,c0), r(98,81,81,19), r(d1,4f,4f,9e), r(7f,dc,dc,a3),\
- r(66,22,22,44), r(7e,2a,2a,54), r(ab,90,90,3b), r(83,88,88,0b),\
- r(ca,46,46,8c), r(29,ee,ee,c7), r(d3,b8,b8,6b), r(3c,14,14,28),\
- r(79,de,de,a7), r(e2,5e,5e,bc), r(1d,0b,0b,16), r(76,db,db,ad),\
- r(3b,e0,e0,db), r(56,32,32,64), r(4e,3a,3a,74), r(1e,0a,0a,14),\
- r(db,49,49,92), r(0a,06,06,0c), r(6c,24,24,48), r(e4,5c,5c,b8),\
- r(5d,c2,c2,9f), r(6e,d3,d3,bd), r(ef,ac,ac,43), r(a6,62,62,c4),\
- r(a8,91,91,39), r(a4,95,95,31), r(37,e4,e4,d3), r(8b,79,79,f2),\
- r(32,e7,e7,d5), r(43,c8,c8,8b), r(59,37,37,6e), r(b7,6d,6d,da),\
- r(8c,8d,8d,01), r(64,d5,d5,b1), r(d2,4e,4e,9c), r(e0,a9,a9,49),\
- r(b4,6c,6c,d8), r(fa,56,56,ac), r(07,f4,f4,f3), r(25,ea,ea,cf),\
- r(af,65,65,ca), r(8e,7a,7a,f4), r(e9,ae,ae,47), r(18,08,08,10),\
- r(d5,ba,ba,6f), r(88,78,78,f0), r(6f,25,25,4a), r(72,2e,2e,5c),\
- r(24,1c,1c,38), r(f1,a6,a6,57), r(c7,b4,b4,73), r(51,c6,c6,97),\
- r(23,e8,e8,cb), r(7c,dd,dd,a1), r(9c,74,74,e8), r(21,1f,1f,3e),\
- r(dd,4b,4b,96), r(dc,bd,bd,61), r(86,8b,8b,0d), r(85,8a,8a,0f),\
- r(90,70,70,e0), r(42,3e,3e,7c), r(c4,b5,b5,71), r(aa,66,66,cc),\
- r(d8,48,48,90), r(05,03,03,06), r(01,f6,f6,f7), r(12,0e,0e,1c),\
- r(a3,61,61,c2), r(5f,35,35,6a), r(f9,57,57,ae), r(d0,b9,b9,69),\
- r(91,86,86,17), r(58,c1,c1,99), r(27,1d,1d,3a), r(b9,9e,9e,27),\
- r(38,e1,e1,d9), r(13,f8,f8,eb), r(b3,98,98,2b), r(33,11,11,22),\
- r(bb,69,69,d2), r(70,d9,d9,a9), r(89,8e,8e,07), r(a7,94,94,33),\
- r(b6,9b,9b,2d), r(22,1e,1e,3c), r(92,87,87,15), r(20,e9,e9,c9),\
- r(49,ce,ce,87), r(ff,55,55,aa), r(78,28,28,50), r(7a,df,df,a5),\
- r(8f,8c,8c,03), r(f8,a1,a1,59), r(80,89,89,09), r(17,0d,0d,1a),\
- r(da,bf,bf,65), r(31,e6,e6,d7), r(c6,42,42,84), r(b8,68,68,d0),\
- r(c3,41,41,82), r(b0,99,99,29), r(77,2d,2d,5a), r(11,0f,0f,1e),\
- r(cb,b0,b0,7b), r(fc,54,54,a8), r(d6,bb,bb,6d), r(3a,16,16,2c)
-
-// data for inverse tables (other than last round)
-
-#define i_table \
- r(50,a7,f4,51), r(53,65,41,7e), r(c3,a4,17,1a), r(96,5e,27,3a),\
- r(cb,6b,ab,3b), r(f1,45,9d,1f), r(ab,58,fa,ac), r(93,03,e3,4b),\
- r(55,fa,30,20), r(f6,6d,76,ad), r(91,76,cc,88), r(25,4c,02,f5),\
- r(fc,d7,e5,4f), r(d7,cb,2a,c5), r(80,44,35,26), r(8f,a3,62,b5),\
- r(49,5a,b1,de), r(67,1b,ba,25), r(98,0e,ea,45), r(e1,c0,fe,5d),\
- r(02,75,2f,c3), r(12,f0,4c,81), r(a3,97,46,8d), r(c6,f9,d3,6b),\
- r(e7,5f,8f,03), r(95,9c,92,15), r(eb,7a,6d,bf), r(da,59,52,95),\
- r(2d,83,be,d4), r(d3,21,74,58), r(29,69,e0,49), r(44,c8,c9,8e),\
- r(6a,89,c2,75), r(78,79,8e,f4), r(6b,3e,58,99), r(dd,71,b9,27),\
- r(b6,4f,e1,be), r(17,ad,88,f0), r(66,ac,20,c9), r(b4,3a,ce,7d),\
- r(18,4a,df,63), r(82,31,1a,e5), r(60,33,51,97), r(45,7f,53,62),\
- r(e0,77,64,b1), r(84,ae,6b,bb), r(1c,a0,81,fe), r(94,2b,08,f9),\
- r(58,68,48,70), r(19,fd,45,8f), r(87,6c,de,94), r(b7,f8,7b,52),\
- r(23,d3,73,ab), r(e2,02,4b,72), r(57,8f,1f,e3), r(2a,ab,55,66),\
- r(07,28,eb,b2), r(03,c2,b5,2f), r(9a,7b,c5,86), r(a5,08,37,d3),\
- r(f2,87,28,30), r(b2,a5,bf,23), r(ba,6a,03,02), r(5c,82,16,ed),\
- r(2b,1c,cf,8a), r(92,b4,79,a7), r(f0,f2,07,f3), r(a1,e2,69,4e),\
- r(cd,f4,da,65), r(d5,be,05,06), r(1f,62,34,d1), r(8a,fe,a6,c4),\
- r(9d,53,2e,34), r(a0,55,f3,a2), r(32,e1,8a,05), r(75,eb,f6,a4),\
- r(39,ec,83,0b), r(aa,ef,60,40), r(06,9f,71,5e), r(51,10,6e,bd),\
- r(f9,8a,21,3e), r(3d,06,dd,96), r(ae,05,3e,dd), r(46,bd,e6,4d),\
- r(b5,8d,54,91), r(05,5d,c4,71), r(6f,d4,06,04), r(ff,15,50,60),\
- r(24,fb,98,19), r(97,e9,bd,d6), r(cc,43,40,89), r(77,9e,d9,67),\
- r(bd,42,e8,b0), r(88,8b,89,07), r(38,5b,19,e7), r(db,ee,c8,79),\
- r(47,0a,7c,a1), r(e9,0f,42,7c), r(c9,1e,84,f8), r(00,00,00,00),\
- r(83,86,80,09), r(48,ed,2b,32), r(ac,70,11,1e), r(4e,72,5a,6c),\
- r(fb,ff,0e,fd), r(56,38,85,0f), r(1e,d5,ae,3d), r(27,39,2d,36),\
- r(64,d9,0f,0a), r(21,a6,5c,68), r(d1,54,5b,9b), r(3a,2e,36,24),\
- r(b1,67,0a,0c), r(0f,e7,57,93), r(d2,96,ee,b4), r(9e,91,9b,1b),\
- r(4f,c5,c0,80), r(a2,20,dc,61), r(69,4b,77,5a), r(16,1a,12,1c),\
- r(0a,ba,93,e2), r(e5,2a,a0,c0), r(43,e0,22,3c), r(1d,17,1b,12),\
- r(0b,0d,09,0e), r(ad,c7,8b,f2), r(b9,a8,b6,2d), r(c8,a9,1e,14),\
- r(85,19,f1,57), r(4c,07,75,af), r(bb,dd,99,ee), r(fd,60,7f,a3),\
- r(9f,26,01,f7), r(bc,f5,72,5c), r(c5,3b,66,44), r(34,7e,fb,5b),\
- r(76,29,43,8b), r(dc,c6,23,cb), r(68,fc,ed,b6), r(63,f1,e4,b8),\
- r(ca,dc,31,d7), r(10,85,63,42), r(40,22,97,13), r(20,11,c6,84),\
- r(7d,24,4a,85), r(f8,3d,bb,d2), r(11,32,f9,ae), r(6d,a1,29,c7),\
- r(4b,2f,9e,1d), r(f3,30,b2,dc), r(ec,52,86,0d), r(d0,e3,c1,77),\
- r(6c,16,b3,2b), r(99,b9,70,a9), r(fa,48,94,11), r(22,64,e9,47),\
- r(c4,8c,fc,a8), r(1a,3f,f0,a0), r(d8,2c,7d,56), r(ef,90,33,22),\
- r(c7,4e,49,87), r(c1,d1,38,d9), r(fe,a2,ca,8c), r(36,0b,d4,98),\
- r(cf,81,f5,a6), r(28,de,7a,a5), r(26,8e,b7,da), r(a4,bf,ad,3f),\
- r(e4,9d,3a,2c), r(0d,92,78,50), r(9b,cc,5f,6a), r(62,46,7e,54),\
- r(c2,13,8d,f6), r(e8,b8,d8,90), r(5e,f7,39,2e), r(f5,af,c3,82),\
- r(be,80,5d,9f), r(7c,93,d0,69), r(a9,2d,d5,6f), r(b3,12,25,cf),\
- r(3b,99,ac,c8), r(a7,7d,18,10), r(6e,63,9c,e8), r(7b,bb,3b,db),\
- r(09,78,26,cd), r(f4,18,59,6e), r(01,b7,9a,ec), r(a8,9a,4f,83),\
- r(65,6e,95,e6), r(7e,e6,ff,aa), r(08,cf,bc,21), r(e6,e8,15,ef),\
- r(d9,9b,e7,ba), r(ce,36,6f,4a), r(d4,09,9f,ea), r(d6,7c,b0,29),\
- r(af,b2,a4,31), r(31,23,3f,2a), r(30,94,a5,c6), r(c0,66,a2,35),\
- r(37,bc,4e,74), r(a6,ca,82,fc), r(b0,d0,90,e0), r(15,d8,a7,33),\
- r(4a,98,04,f1), r(f7,da,ec,41), r(0e,50,cd,7f), r(2f,f6,91,17),\
- r(8d,d6,4d,76), r(4d,b0,ef,43), r(54,4d,aa,cc), r(df,04,96,e4),\
- r(e3,b5,d1,9e), r(1b,88,6a,4c), r(b8,1f,2c,c1), r(7f,51,65,46),\
- r(04,ea,5e,9d), r(5d,35,8c,01), r(73,74,87,fa), r(2e,41,0b,fb),\
- r(5a,1d,67,b3), r(52,d2,db,92), r(33,56,10,e9), r(13,47,d6,6d),\
- r(8c,61,d7,9a), r(7a,0c,a1,37), r(8e,14,f8,59), r(89,3c,13,eb),\
- r(ee,27,a9,ce), r(35,c9,61,b7), r(ed,e5,1c,e1), r(3c,b1,47,7a),\
- r(59,df,d2,9c), r(3f,73,f2,55), r(79,ce,14,18), r(bf,37,c7,73),\
- r(ea,cd,f7,53), r(5b,aa,fd,5f), r(14,6f,3d,df), r(86,db,44,78),\
- r(81,f3,af,ca), r(3e,c4,68,b9), r(2c,34,24,38), r(5f,40,a3,c2),\
- r(72,c3,1d,16), r(0c,25,e2,bc), r(8b,49,3c,28), r(41,95,0d,ff),\
- r(71,01,a8,39), r(de,b3,0c,08), r(9c,e4,b4,d8), r(90,c1,56,64),\
- r(61,84,cb,7b), r(70,b6,32,d5), r(74,5c,6c,48), r(42,57,b8,d0)
-
-// generate the required tables in the desired endian format
-
-#undef r
-#define r r0
-
-#if defined(ONE_TABLE)
-static const u_int32_t ft_tab[256] =
- { f_table };
-#elif defined(FOUR_TABLES)
-static const u_int32_t ft_tab[4][256] =
-{ { f_table },
-#undef r
-#define r r1
- { f_table },
-#undef r
-#define r r2
- { f_table },
-#undef r
-#define r r3
- { f_table }
-};
-#endif
-
-#undef r
-#define r r0
-#if defined(ONE_TABLE)
-static const u_int32_t it_tab[256] =
- { i_table };
-#elif defined(FOUR_TABLES)
-static const u_int32_t it_tab[4][256] =
-{ { i_table },
-#undef r
-#define r r1
- { i_table },
-#undef r
-#define r r2
- { i_table },
-#undef r
-#define r r3
- { i_table }
-};
-#endif
-
-#endif
-
-#if defined(FIXED_TABLES) && (defined(ONE_LR_TABLE) || defined(FOUR_LR_TABLES))
-
-// data for inverse tables (last round)
-
-#define li_table \
- w(52), w(09), w(6a), w(d5), w(30), w(36), w(a5), w(38),\
- w(bf), w(40), w(a3), w(9e), w(81), w(f3), w(d7), w(fb),\
- w(7c), w(e3), w(39), w(82), w(9b), w(2f), w(ff), w(87),\
- w(34), w(8e), w(43), w(44), w(c4), w(de), w(e9), w(cb),\
- w(54), w(7b), w(94), w(32), w(a6), w(c2), w(23), w(3d),\
- w(ee), w(4c), w(95), w(0b), w(42), w(fa), w(c3), w(4e),\
- w(08), w(2e), w(a1), w(66), w(28), w(d9), w(24), w(b2),\
- w(76), w(5b), w(a2), w(49), w(6d), w(8b), w(d1), w(25),\
- w(72), w(f8), w(f6), w(64), w(86), w(68), w(98), w(16),\
- w(d4), w(a4), w(5c), w(cc), w(5d), w(65), w(b6), w(92),\
- w(6c), w(70), w(48), w(50), w(fd), w(ed), w(b9), w(da),\
- w(5e), w(15), w(46), w(57), w(a7), w(8d), w(9d), w(84),\
- w(90), w(d8), w(ab), w(00), w(8c), w(bc), w(d3), w(0a),\
- w(f7), w(e4), w(58), w(05), w(b8), w(b3), w(45), w(06),\
- w(d0), w(2c), w(1e), w(8f), w(ca), w(3f), w(0f), w(02),\
- w(c1), w(af), w(bd), w(03), w(01), w(13), w(8a), w(6b),\
- w(3a), w(91), w(11), w(41), w(4f), w(67), w(dc), w(ea),\
- w(97), w(f2), w(cf), w(ce), w(f0), w(b4), w(e6), w(73),\
- w(96), w(ac), w(74), w(22), w(e7), w(ad), w(35), w(85),\
- w(e2), w(f9), w(37), w(e8), w(1c), w(75), w(df), w(6e),\
- w(47), w(f1), w(1a), w(71), w(1d), w(29), w(c5), w(89),\
- w(6f), w(b7), w(62), w(0e), w(aa), w(18), w(be), w(1b),\
- w(fc), w(56), w(3e), w(4b), w(c6), w(d2), w(79), w(20),\
- w(9a), w(db), w(c0), w(fe), w(78), w(cd), w(5a), w(f4),\
- w(1f), w(dd), w(a8), w(33), w(88), w(07), w(c7), w(31),\
- w(b1), w(12), w(10), w(59), w(27), w(80), w(ec), w(5f),\
- w(60), w(51), w(7f), w(a9), w(19), w(b5), w(4a), w(0d),\
- w(2d), w(e5), w(7a), w(9f), w(93), w(c9), w(9c), w(ef),\
- w(a0), w(e0), w(3b), w(4d), w(ae), w(2a), w(f5), w(b0),\
- w(c8), w(eb), w(bb), w(3c), w(83), w(53), w(99), w(61),\
- w(17), w(2b), w(04), w(7e), w(ba), w(77), w(d6), w(26),\
- w(e1), w(69), w(14), w(63), w(55), w(21), w(0c), w(7d),
-
-// generate the required tables in the desired endian format
-
-#undef r
-#define r(p,q,r,s) w0(q)
-#if defined(ONE_LR_TABLE)
-static const u_int32_t fl_tab[256] =
- { f_table };
-#elif defined(FOUR_LR_TABLES)
-static const u_int32_t fl_tab[4][256] =
-{ { f_table },
-#undef r
-#define r(p,q,r,s) w1(q)
- { f_table },
-#undef r
-#define r(p,q,r,s) w2(q)
- { f_table },
-#undef r
-#define r(p,q,r,s) w3(q)
- { f_table }
-};
-#endif
-
-#undef w
-#define w w0
-#if defined(ONE_LR_TABLE)
-static const u_int32_t il_tab[256] =
- { li_table };
-#elif defined(FOUR_LR_TABLES)
-static const u_int32_t il_tab[4][256] =
-{ { li_table },
-#undef w
-#define w w1
- { li_table },
-#undef w
-#define w w2
- { li_table },
-#undef w
-#define w w3
- { li_table }
-};
-#endif
-
-#endif
-
-#if defined(FIXED_TABLES) && (defined(ONE_IM_TABLE) || defined(FOUR_IM_TABLES))
-
-#define m_table \
- r(00,00,00,00), r(0b,0d,09,0e), r(16,1a,12,1c), r(1d,17,1b,12),\
- r(2c,34,24,38), r(27,39,2d,36), r(3a,2e,36,24), r(31,23,3f,2a),\
- r(58,68,48,70), r(53,65,41,7e), r(4e,72,5a,6c), r(45,7f,53,62),\
- r(74,5c,6c,48), r(7f,51,65,46), r(62,46,7e,54), r(69,4b,77,5a),\
- r(b0,d0,90,e0), r(bb,dd,99,ee), r(a6,ca,82,fc), r(ad,c7,8b,f2),\
- r(9c,e4,b4,d8), r(97,e9,bd,d6), r(8a,fe,a6,c4), r(81,f3,af,ca),\
- r(e8,b8,d8,90), r(e3,b5,d1,9e), r(fe,a2,ca,8c), r(f5,af,c3,82),\
- r(c4,8c,fc,a8), r(cf,81,f5,a6), r(d2,96,ee,b4), r(d9,9b,e7,ba),\
- r(7b,bb,3b,db), r(70,b6,32,d5), r(6d,a1,29,c7), r(66,ac,20,c9),\
- r(57,8f,1f,e3), r(5c,82,16,ed), r(41,95,0d,ff), r(4a,98,04,f1),\
- r(23,d3,73,ab), r(28,de,7a,a5), r(35,c9,61,b7), r(3e,c4,68,b9),\
- r(0f,e7,57,93), r(04,ea,5e,9d), r(19,fd,45,8f), r(12,f0,4c,81),\
- r(cb,6b,ab,3b), r(c0,66,a2,35), r(dd,71,b9,27), r(d6,7c,b0,29),\
- r(e7,5f,8f,03), r(ec,52,86,0d), r(f1,45,9d,1f), r(fa,48,94,11),\
- r(93,03,e3,4b), r(98,0e,ea,45), r(85,19,f1,57), r(8e,14,f8,59),\
- r(bf,37,c7,73), r(b4,3a,ce,7d), r(a9,2d,d5,6f), r(a2,20,dc,61),\
- r(f6,6d,76,ad), r(fd,60,7f,a3), r(e0,77,64,b1), r(eb,7a,6d,bf),\
- r(da,59,52,95), r(d1,54,5b,9b), r(cc,43,40,89), r(c7,4e,49,87),\
- r(ae,05,3e,dd), r(a5,08,37,d3), r(b8,1f,2c,c1), r(b3,12,25,cf),\
- r(82,31,1a,e5), r(89,3c,13,eb), r(94,2b,08,f9), r(9f,26,01,f7),\
- r(46,bd,e6,4d), r(4d,b0,ef,43), r(50,a7,f4,51), r(5b,aa,fd,5f),\
- r(6a,89,c2,75), r(61,84,cb,7b), r(7c,93,d0,69), r(77,9e,d9,67),\
- r(1e,d5,ae,3d), r(15,d8,a7,33), r(08,cf,bc,21), r(03,c2,b5,2f),\
- r(32,e1,8a,05), r(39,ec,83,0b), r(24,fb,98,19), r(2f,f6,91,17),\
- r(8d,d6,4d,76), r(86,db,44,78), r(9b,cc,5f,6a), r(90,c1,56,64),\
- r(a1,e2,69,4e), r(aa,ef,60,40), r(b7,f8,7b,52), r(bc,f5,72,5c),\
- r(d5,be,05,06), r(de,b3,0c,08), r(c3,a4,17,1a), r(c8,a9,1e,14),\
- r(f9,8a,21,3e), r(f2,87,28,30), r(ef,90,33,22), r(e4,9d,3a,2c),\
- r(3d,06,dd,96), r(36,0b,d4,98), r(2b,1c,cf,8a), r(20,11,c6,84),\
- r(11,32,f9,ae), r(1a,3f,f0,a0), r(07,28,eb,b2), r(0c,25,e2,bc),\
- r(65,6e,95,e6), r(6e,63,9c,e8), r(73,74,87,fa), r(78,79,8e,f4),\
- r(49,5a,b1,de), r(42,57,b8,d0), r(5f,40,a3,c2), r(54,4d,aa,cc),\
- r(f7,da,ec,41), r(fc,d7,e5,4f), r(e1,c0,fe,5d), r(ea,cd,f7,53),\
- r(db,ee,c8,79), r(d0,e3,c1,77), r(cd,f4,da,65), r(c6,f9,d3,6b),\
- r(af,b2,a4,31), r(a4,bf,ad,3f), r(b9,a8,b6,2d), r(b2,a5,bf,23),\
- r(83,86,80,09), r(88,8b,89,07), r(95,9c,92,15), r(9e,91,9b,1b),\
- r(47,0a,7c,a1), r(4c,07,75,af), r(51,10,6e,bd), r(5a,1d,67,b3),\
- r(6b,3e,58,99), r(60,33,51,97), r(7d,24,4a,85), r(76,29,43,8b),\
- r(1f,62,34,d1), r(14,6f,3d,df), r(09,78,26,cd), r(02,75,2f,c3),\
- r(33,56,10,e9), r(38,5b,19,e7), r(25,4c,02,f5), r(2e,41,0b,fb),\
- r(8c,61,d7,9a), r(87,6c,de,94), r(9a,7b,c5,86), r(91,76,cc,88),\
- r(a0,55,f3,a2), r(ab,58,fa,ac), r(b6,4f,e1,be), r(bd,42,e8,b0),\
- r(d4,09,9f,ea), r(df,04,96,e4), r(c2,13,8d,f6), r(c9,1e,84,f8),\
- r(f8,3d,bb,d2), r(f3,30,b2,dc), r(ee,27,a9,ce), r(e5,2a,a0,c0),\
- r(3c,b1,47,7a), r(37,bc,4e,74), r(2a,ab,55,66), r(21,a6,5c,68),\
- r(10,85,63,42), r(1b,88,6a,4c), r(06,9f,71,5e), r(0d,92,78,50),\
- r(64,d9,0f,0a), r(6f,d4,06,04), r(72,c3,1d,16), r(79,ce,14,18),\
- r(48,ed,2b,32), r(43,e0,22,3c), r(5e,f7,39,2e), r(55,fa,30,20),\
- r(01,b7,9a,ec), r(0a,ba,93,e2), r(17,ad,88,f0), r(1c,a0,81,fe),\
- r(2d,83,be,d4), r(26,8e,b7,da), r(3b,99,ac,c8), r(30,94,a5,c6),\
- r(59,df,d2,9c), r(52,d2,db,92), r(4f,c5,c0,80), r(44,c8,c9,8e),\
- r(75,eb,f6,a4), r(7e,e6,ff,aa), r(63,f1,e4,b8), r(68,fc,ed,b6),\
- r(b1,67,0a,0c), r(ba,6a,03,02), r(a7,7d,18,10), r(ac,70,11,1e),\
- r(9d,53,2e,34), r(96,5e,27,3a), r(8b,49,3c,28), r(80,44,35,26),\
- r(e9,0f,42,7c), r(e2,02,4b,72), r(ff,15,50,60), r(f4,18,59,6e),\
- r(c5,3b,66,44), r(ce,36,6f,4a), r(d3,21,74,58), r(d8,2c,7d,56),\
- r(7a,0c,a1,37), r(71,01,a8,39), r(6c,16,b3,2b), r(67,1b,ba,25),\
- r(56,38,85,0f), r(5d,35,8c,01), r(40,22,97,13), r(4b,2f,9e,1d),\
- r(22,64,e9,47), r(29,69,e0,49), r(34,7e,fb,5b), r(3f,73,f2,55),\
- r(0e,50,cd,7f), r(05,5d,c4,71), r(18,4a,df,63), r(13,47,d6,6d),\
- r(ca,dc,31,d7), r(c1,d1,38,d9), r(dc,c6,23,cb), r(d7,cb,2a,c5),\
- r(e6,e8,15,ef), r(ed,e5,1c,e1), r(f0,f2,07,f3), r(fb,ff,0e,fd),\
- r(92,b4,79,a7), r(99,b9,70,a9), r(84,ae,6b,bb), r(8f,a3,62,b5),\
- r(be,80,5d,9f), r(b5,8d,54,91), r(a8,9a,4f,83), r(a3,97,46,8d)
-
-#undef r
-#define r r0
-
-#if defined(ONE_IM_TABLE)
-static const u_int32_t im_tab[256] =
- { m_table };
-#elif defined(FOUR_IM_TABLES)
-static const u_int32_t im_tab[4][256] =
-{ { m_table },
-#undef r
-#define r r1
- { m_table },
-#undef r
-#define r r2
- { m_table },
-#undef r
-#define r r3
- { m_table }
-};
-#endif
-
-#endif
-
-#else
-
-static int tab_gen = 0;
-
-static unsigned char s_box[256]; // the S box
-static unsigned char inv_s_box[256]; // the inverse S box
-static u_int32_t rcon_tab[AES_RC_LENGTH]; // table of round constants
-
-#if defined(ONE_TABLE)
-static u_int32_t ft_tab[256];
-static u_int32_t it_tab[256];
-#elif defined(FOUR_TABLES)
-static u_int32_t ft_tab[4][256];
-static u_int32_t it_tab[4][256];
-#endif
-
-#if defined(ONE_LR_TABLE)
-static u_int32_t fl_tab[256];
-static u_int32_t il_tab[256];
-#elif defined(FOUR_LR_TABLES)
-static u_int32_t fl_tab[4][256];
-static u_int32_t il_tab[4][256];
-#endif
-
-#if defined(ONE_IM_TABLE)
-static u_int32_t im_tab[256];
-#elif defined(FOUR_IM_TABLES)
-static u_int32_t im_tab[4][256];
-#endif
-
-// Generate the tables for the dynamic table option
-
-#if !defined(FF_TABLES)
-
-// It will generally be sensible to use tables to compute finite
-// field multiplies and inverses but where memory is scarse this
-// code might sometimes be better.
-
-// return 2 ^ (n - 1) where n is the bit number of the highest bit
-// set in x with x in the range 1 < x < 0x00000200. This form is
-// used so that locals within FFinv can be bytes rather than words
-
-static unsigned char hibit(const u_int32_t x)
-{ unsigned char r = (unsigned char)((x >> 1) | (x >> 2));
-
- r |= (r >> 2);
- r |= (r >> 4);
- return (r + 1) >> 1;
-}
-
-// return the inverse of the finite field element x
-
-static unsigned char FFinv(const unsigned char x)
-{ unsigned char p1 = x, p2 = 0x1b, n1 = hibit(x), n2 = 0x80, v1 = 1, v2 = 0;
-
- if(x < 2) return x;
-
- for(;;)
- {
- if(!n1) return v1;
-
- while(n2 >= n1)
- {
- n2 /= n1; p2 ^= p1 * n2; v2 ^= v1 * n2; n2 = hibit(p2);
- }
-
- if(!n2) return v2;
-
- while(n1 >= n2)
- {
- n1 /= n2; p1 ^= p2 * n1; v1 ^= v2 * n1; n1 = hibit(p1);
- }
- }
-}
-
-// define the finite field multiplies required for Rijndael
-
-#define FFmul02(x) ((((x) & 0x7f) << 1) ^ ((x) & 0x80 ? 0x1b : 0))
-#define FFmul03(x) ((x) ^ FFmul02(x))
-#define FFmul09(x) ((x) ^ FFmul02(FFmul02(FFmul02(x))))
-#define FFmul0b(x) ((x) ^ FFmul02((x) ^ FFmul02(FFmul02(x))))
-#define FFmul0d(x) ((x) ^ FFmul02(FFmul02((x) ^ FFmul02(x))))
-#define FFmul0e(x) FFmul02((x) ^ FFmul02((x) ^ FFmul02(x)))
-
-#else
-
-#define FFinv(x) ((x) ? pow[255 - log[x]]: 0)
-
-#define FFmul02(x) (x ? pow[log[x] + 0x19] : 0)
-#define FFmul03(x) (x ? pow[log[x] + 0x01] : 0)
-#define FFmul09(x) (x ? pow[log[x] + 0xc7] : 0)
-#define FFmul0b(x) (x ? pow[log[x] + 0x68] : 0)
-#define FFmul0d(x) (x ? pow[log[x] + 0xee] : 0)
-#define FFmul0e(x) (x ? pow[log[x] + 0xdf] : 0)
-
-#endif
-
-// The forward and inverse affine transformations used in the S-box
-
-#define fwd_affine(x) \
- (w = (u_int32_t)x, w ^= (w<<1)^(w<<2)^(w<<3)^(w<<4), 0x63^(unsigned char)(w^(w>>8)))
-
-#define inv_affine(x) \
- (w = (u_int32_t)x, w = (w<<1)^(w<<3)^(w<<6), 0x05^(unsigned char)(w^(w>>8)))
-
-static void gen_tabs(void)
-{ u_int32_t i, w;
-
-#if defined(FF_TABLES)
-
- unsigned char pow[512], log[256];
-
- // log and power tables for GF(2^8) finite field with
- // 0x011b as modular polynomial - the simplest primitive
- // root is 0x03, used here to generate the tables
-
- i = 0; w = 1;
- do
- {
- pow[i] = (unsigned char)w;
- pow[i + 255] = (unsigned char)w;
- log[w] = (unsigned char)i++;
- w ^= (w << 1) ^ (w & ff_hi ? ff_poly : 0);
- }
- while (w != 1);
-
-#endif
-
- for(i = 0, w = 1; i < AES_RC_LENGTH; ++i)
- {
- rcon_tab[i] = bytes2word(w, 0, 0, 0);
- w = (w << 1) ^ (w & ff_hi ? ff_poly : 0);
- }
-
- for(i = 0; i < 256; ++i)
- { unsigned char b;
-
- s_box[i] = b = fwd_affine(FFinv((unsigned char)i));
-
- w = bytes2word(b, 0, 0, 0);
-#if defined(ONE_LR_TABLE)
- fl_tab[i] = w;
-#elif defined(FOUR_LR_TABLES)
- fl_tab[0][i] = w;
- fl_tab[1][i] = upr(w,1);
- fl_tab[2][i] = upr(w,2);
- fl_tab[3][i] = upr(w,3);
-#endif
- w = bytes2word(FFmul02(b), b, b, FFmul03(b));
-#if defined(ONE_TABLE)
- ft_tab[i] = w;
-#elif defined(FOUR_TABLES)
- ft_tab[0][i] = w;
- ft_tab[1][i] = upr(w,1);
- ft_tab[2][i] = upr(w,2);
- ft_tab[3][i] = upr(w,3);
-#endif
- inv_s_box[i] = b = FFinv(inv_affine((unsigned char)i));
-
- w = bytes2word(b, 0, 0, 0);
-#if defined(ONE_LR_TABLE)
- il_tab[i] = w;
-#elif defined(FOUR_LR_TABLES)
- il_tab[0][i] = w;
- il_tab[1][i] = upr(w,1);
- il_tab[2][i] = upr(w,2);
- il_tab[3][i] = upr(w,3);
-#endif
- w = bytes2word(FFmul0e(b), FFmul09(b), FFmul0d(b), FFmul0b(b));
-#if defined(ONE_TABLE)
- it_tab[i] = w;
-#elif defined(FOUR_TABLES)
- it_tab[0][i] = w;
- it_tab[1][i] = upr(w,1);
- it_tab[2][i] = upr(w,2);
- it_tab[3][i] = upr(w,3);
-#endif
-#if defined(ONE_IM_TABLE)
- im_tab[b] = w;
-#elif defined(FOUR_IM_TABLES)
- im_tab[0][b] = w;
- im_tab[1][b] = upr(w,1);
- im_tab[2][b] = upr(w,2);
- im_tab[3][b] = upr(w,3);
-#endif
-
- }
-}
-
-#endif
-
-#define no_table(x,box,vf,rf,c) bytes2word( \
- box[bval(vf(x,0,c),rf(0,c))], \
- box[bval(vf(x,1,c),rf(1,c))], \
- box[bval(vf(x,2,c),rf(2,c))], \
- box[bval(vf(x,3,c),rf(3,c))])
-
-#define one_table(x,op,tab,vf,rf,c) \
- ( tab[bval(vf(x,0,c),rf(0,c))] \
- ^ op(tab[bval(vf(x,1,c),rf(1,c))],1) \
- ^ op(tab[bval(vf(x,2,c),rf(2,c))],2) \
- ^ op(tab[bval(vf(x,3,c),rf(3,c))],3))
-
-#define four_tables(x,tab,vf,rf,c) \
- ( tab[0][bval(vf(x,0,c),rf(0,c))] \
- ^ tab[1][bval(vf(x,1,c),rf(1,c))] \
- ^ tab[2][bval(vf(x,2,c),rf(2,c))] \
- ^ tab[3][bval(vf(x,3,c),rf(3,c))])
-
-#define vf1(x,r,c) (x)
-#define rf1(r,c) (r)
-#define rf2(r,c) ((r-c)&3)
-
-#if defined(FOUR_LR_TABLES)
-#define ls_box(x,c) four_tables(x,fl_tab,vf1,rf2,c)
-#elif defined(ONE_LR_TABLE)
-#define ls_box(x,c) one_table(x,upr,fl_tab,vf1,rf2,c)
-#else
-#define ls_box(x,c) no_table(x,s_box,vf1,rf2,c)
-#endif
-
-#if defined(FOUR_IM_TABLES)
-#define inv_mcol(x) four_tables(x,im_tab,vf1,rf1,0)
-#elif defined(ONE_IM_TABLE)
-#define inv_mcol(x) one_table(x,upr,im_tab,vf1,rf1,0)
-#else
-#define inv_mcol(x) \
- (f9 = (x),f2 = FFmulX(f9), f4 = FFmulX(f2), f8 = FFmulX(f4), f9 ^= f8, \
- f2 ^= f4 ^ f8 ^ upr(f2 ^ f9,3) ^ upr(f4 ^ f9,2) ^ upr(f9,1))
-#endif
-
-#define nc (this->aes_Ncol)
-
-// Initialise the key schedule from the user supplied key. The key
-// length is now specified in bytes - 16, 24 or 32 as appropriate.
-// This corresponds to bit lengths of 128, 192 and 256 bits, and
-// to Nk values of 4, 6 and 8 respectively.
-
-#define mx(t,f) (*t++ = inv_mcol(*f),f++)
-#define cp(t,f) *t++ = *f++
-
-#if AES_BLOCK_SIZE == 16
-#define cpy(d,s) cp(d,s); cp(d,s); cp(d,s); cp(d,s)
-#define mix(d,s) mx(d,s); mx(d,s); mx(d,s); mx(d,s)
-#elif AES_BLOCK_SIZE == 24
-#define cpy(d,s) cp(d,s); cp(d,s); cp(d,s); cp(d,s); \
- cp(d,s); cp(d,s)
-#define mix(d,s) mx(d,s); mx(d,s); mx(d,s); mx(d,s); \
- mx(d,s); mx(d,s)
-#elif AES_BLOCK_SIZE == 32
-#define cpy(d,s) cp(d,s); cp(d,s); cp(d,s); cp(d,s); \
- cp(d,s); cp(d,s); cp(d,s); cp(d,s)
-#define mix(d,s) mx(d,s); mx(d,s); mx(d,s); mx(d,s); \
- mx(d,s); mx(d,s); mx(d,s); mx(d,s)
-#else
-
-#define cpy(d,s) \
-switch(nc) \
-{ case 8: cp(d,s); cp(d,s); \
- case 6: cp(d,s); cp(d,s); \
- case 4: cp(d,s); cp(d,s); \
- cp(d,s); cp(d,s); \
-}
-
-#define mix(d,s) \
-switch(nc) \
-{ case 8: mx(d,s); mx(d,s); \
- case 6: mx(d,s); mx(d,s); \
- case 4: mx(d,s); mx(d,s); \
- mx(d,s); mx(d,s); \
-}
-
-#endif
-
-// y = output word, x = input word, r = row, c = column
-// for r = 0, 1, 2 and 3 = column accessed for row r
-
-#if defined(ARRAYS)
-#define s(x,c) x[c]
-#else
-#define s(x,c) x##c
-#endif
-
-// I am grateful to Frank Yellin for the following constructions
-// which, given the column (c) of the output state variable that
-// is being computed, return the input state variables which are
-// needed for each row (r) of the state
-
-// For the fixed block size options, compilers reduce these two
-// expressions to fixed variable references. For variable block
-// size code conditional clauses will sometimes be returned
-
-#define unused 77 // Sunset Strip
-
-#define fwd_var(x,r,c) \
- ( r==0 ? \
- ( c==0 ? s(x,0) \
- : c==1 ? s(x,1) \
- : c==2 ? s(x,2) \
- : c==3 ? s(x,3) \
- : c==4 ? s(x,4) \
- : c==5 ? s(x,5) \
- : c==6 ? s(x,6) \
- : s(x,7)) \
- : r==1 ? \
- ( c==0 ? s(x,1) \
- : c==1 ? s(x,2) \
- : c==2 ? s(x,3) \
- : c==3 ? nc==4 ? s(x,0) : s(x,4) \
- : c==4 ? s(x,5) \
- : c==5 ? nc==8 ? s(x,6) : s(x,0) \
- : c==6 ? s(x,7) \
- : s(x,0)) \
- : r==2 ? \
- ( c==0 ? nc==8 ? s(x,3) : s(x,2) \
- : c==1 ? nc==8 ? s(x,4) : s(x,3) \
- : c==2 ? nc==4 ? s(x,0) : nc==8 ? s(x,5) : s(x,4) \
- : c==3 ? nc==4 ? s(x,1) : nc==8 ? s(x,6) : s(x,5) \
- : c==4 ? nc==8 ? s(x,7) : s(x,0) \
- : c==5 ? nc==8 ? s(x,0) : s(x,1) \
- : c==6 ? s(x,1) \
- : s(x,2)) \
- : \
- ( c==0 ? nc==8 ? s(x,4) : s(x,3) \
- : c==1 ? nc==4 ? s(x,0) : nc==8 ? s(x,5) : s(x,4) \
- : c==2 ? nc==4 ? s(x,1) : nc==8 ? s(x,6) : s(x,5) \
- : c==3 ? nc==4 ? s(x,2) : nc==8 ? s(x,7) : s(x,0) \
- : c==4 ? nc==8 ? s(x,0) : s(x,1) \
- : c==5 ? nc==8 ? s(x,1) : s(x,2) \
- : c==6 ? s(x,2) \
- : s(x,3)))
-
-#define inv_var(x,r,c) \
- ( r==0 ? \
- ( c==0 ? s(x,0) \
- : c==1 ? s(x,1) \
- : c==2 ? s(x,2) \
- : c==3 ? s(x,3) \
- : c==4 ? s(x,4) \
- : c==5 ? s(x,5) \
- : c==6 ? s(x,6) \
- : s(x,7)) \
- : r==1 ? \
- ( c==0 ? nc==4 ? s(x,3) : nc==8 ? s(x,7) : s(x,5) \
- : c==1 ? s(x,0) \
- : c==2 ? s(x,1) \
- : c==3 ? s(x,2) \
- : c==4 ? s(x,3) \
- : c==5 ? s(x,4) \
- : c==6 ? s(x,5) \
- : s(x,6)) \
- : r==2 ? \
- ( c==0 ? nc==4 ? s(x,2) : nc==8 ? s(x,5) : s(x,4) \
- : c==1 ? nc==4 ? s(x,3) : nc==8 ? s(x,6) : s(x,5) \
- : c==2 ? nc==8 ? s(x,7) : s(x,0) \
- : c==3 ? nc==8 ? s(x,0) : s(x,1) \
- : c==4 ? nc==8 ? s(x,1) : s(x,2) \
- : c==5 ? nc==8 ? s(x,2) : s(x,3) \
- : c==6 ? s(x,3) \
- : s(x,4)) \
- : \
- ( c==0 ? nc==4 ? s(x,1) : nc==8 ? s(x,4) : s(x,3) \
- : c==1 ? nc==4 ? s(x,2) : nc==8 ? s(x,5) : s(x,4) \
- : c==2 ? nc==4 ? s(x,3) : nc==8 ? s(x,6) : s(x,5) \
- : c==3 ? nc==8 ? s(x,7) : s(x,0) \
- : c==4 ? nc==8 ? s(x,0) : s(x,1) \
- : c==5 ? nc==8 ? s(x,1) : s(x,2) \
- : c==6 ? s(x,2) \
- : s(x,3)))
-
-#define si(y,x,k,c) s(y,c) = const_word_in(x + 4 * c) ^ k[c]
-#define so(y,x,c) word_out(y + 4 * c, s(x,c))
-
-#if defined(FOUR_TABLES)
-#define fwd_rnd(y,x,k,c) s(y,c)= (k)[c] ^ four_tables(x,ft_tab,fwd_var,rf1,c)
-#define inv_rnd(y,x,k,c) s(y,c)= (k)[c] ^ four_tables(x,it_tab,inv_var,rf1,c)
-#elif defined(ONE_TABLE)
-#define fwd_rnd(y,x,k,c) s(y,c)= (k)[c] ^ one_table(x,upr,ft_tab,fwd_var,rf1,c)
-#define inv_rnd(y,x,k,c) s(y,c)= (k)[c] ^ one_table(x,upr,it_tab,inv_var,rf1,c)
-#else
-#define fwd_rnd(y,x,k,c) s(y,c) = fwd_mcol(no_table(x,s_box,fwd_var,rf1,c)) ^ (k)[c]
-#define inv_rnd(y,x,k,c) s(y,c) = inv_mcol(no_table(x,inv_s_box,inv_var,rf1,c) ^ (k)[c])
-#endif
-
-#if defined(FOUR_LR_TABLES)
-#define fwd_lrnd(y,x,k,c) s(y,c)= (k)[c] ^ four_tables(x,fl_tab,fwd_var,rf1,c)
-#define inv_lrnd(y,x,k,c) s(y,c)= (k)[c] ^ four_tables(x,il_tab,inv_var,rf1,c)
-#elif defined(ONE_LR_TABLE)
-#define fwd_lrnd(y,x,k,c) s(y,c)= (k)[c] ^ one_table(x,ups,fl_tab,fwd_var,rf1,c)
-#define inv_lrnd(y,x,k,c) s(y,c)= (k)[c] ^ one_table(x,ups,il_tab,inv_var,rf1,c)
-#else
-#define fwd_lrnd(y,x,k,c) s(y,c) = no_table(x,s_box,fwd_var,rf1,c) ^ (k)[c]
-#define inv_lrnd(y,x,k,c) s(y,c) = no_table(x,inv_s_box,inv_var,rf1,c) ^ (k)[c]
-#endif
-
-#if AES_BLOCK_SIZE == 16
-
-#if defined(ARRAYS)
-#define locals(y,x) x[4],y[4]
-#else
-#define locals(y,x) x##0,x##1,x##2,x##3,y##0,y##1,y##2,y##3
-// the following defines prevent the compiler requiring the declaration
-// of generated but unused variables in the fwd_var and inv_var macros
-#define b04 unused
-#define b05 unused
-#define b06 unused
-#define b07 unused
-#define b14 unused
-#define b15 unused
-#define b16 unused
-#define b17 unused
-#endif
-#define l_copy(y, x) s(y,0) = s(x,0); s(y,1) = s(x,1); \
- s(y,2) = s(x,2); s(y,3) = s(x,3);
-#define state_in(y,x,k) si(y,x,k,0); si(y,x,k,1); si(y,x,k,2); si(y,x,k,3)
-#define state_out(y,x) so(y,x,0); so(y,x,1); so(y,x,2); so(y,x,3)
-#define round(rm,y,x,k) rm(y,x,k,0); rm(y,x,k,1); rm(y,x,k,2); rm(y,x,k,3)
-
-#elif AES_BLOCK_SIZE == 24
-
-#if defined(ARRAYS)
-#define locals(y,x) x[6],y[6]
-#else
-#define locals(y,x) x##0,x##1,x##2,x##3,x##4,x##5, \
- y##0,y##1,y##2,y##3,y##4,y##5
-#define b06 unused
-#define b07 unused
-#define b16 unused
-#define b17 unused
-#endif
-#define l_copy(y, x) s(y,0) = s(x,0); s(y,1) = s(x,1); \
- s(y,2) = s(x,2); s(y,3) = s(x,3); \
- s(y,4) = s(x,4); s(y,5) = s(x,5);
-#define state_in(y,x,k) si(y,x,k,0); si(y,x,k,1); si(y,x,k,2); \
- si(y,x,k,3); si(y,x,k,4); si(y,x,k,5)
-#define state_out(y,x) so(y,x,0); so(y,x,1); so(y,x,2); \
- so(y,x,3); so(y,x,4); so(y,x,5)
-#define round(rm,y,x,k) rm(y,x,k,0); rm(y,x,k,1); rm(y,x,k,2); \
- rm(y,x,k,3); rm(y,x,k,4); rm(y,x,k,5)
-#else
-
-#if defined(ARRAYS)
-#define locals(y,x) x[8],y[8]
-#else
-#define locals(y,x) x##0,x##1,x##2,x##3,x##4,x##5,x##6,x##7, \
- y##0,y##1,y##2,y##3,y##4,y##5,y##6,y##7
-#endif
-#define l_copy(y, x) s(y,0) = s(x,0); s(y,1) = s(x,1); \
- s(y,2) = s(x,2); s(y,3) = s(x,3); \
- s(y,4) = s(x,4); s(y,5) = s(x,5); \
- s(y,6) = s(x,6); s(y,7) = s(x,7);
-
-#if AES_BLOCK_SIZE == 32
-
-#define state_in(y,x,k) si(y,x,k,0); si(y,x,k,1); si(y,x,k,2); si(y,x,k,3); \
- si(y,x,k,4); si(y,x,k,5); si(y,x,k,6); si(y,x,k,7)
-#define state_out(y,x) so(y,x,0); so(y,x,1); so(y,x,2); so(y,x,3); \
- so(y,x,4); so(y,x,5); so(y,x,6); so(y,x,7)
-#define round(rm,y,x,k) rm(y,x,k,0); rm(y,x,k,1); rm(y,x,k,2); rm(y,x,k,3); \
- rm(y,x,k,4); rm(y,x,k,5); rm(y,x,k,6); rm(y,x,k,7)
-#else
-
-#define state_in(y,x,k) \
-switch(nc) \
-{ case 8: si(y,x,k,7); si(y,x,k,6); \
- case 6: si(y,x,k,5); si(y,x,k,4); \
- case 4: si(y,x,k,3); si(y,x,k,2); \
- si(y,x,k,1); si(y,x,k,0); \
-}
-
-#define state_out(y,x) \
-switch(nc) \
-{ case 8: so(y,x,7); so(y,x,6); \
- case 6: so(y,x,5); so(y,x,4); \
- case 4: so(y,x,3); so(y,x,2); \
- so(y,x,1); so(y,x,0); \
-}
-
-#if defined(FAST_VARIABLE)
-
-#define round(rm,y,x,k) \
-switch(nc) \
-{ case 8: rm(y,x,k,7); rm(y,x,k,6); \
- rm(y,x,k,5); rm(y,x,k,4); \
- rm(y,x,k,3); rm(y,x,k,2); \
- rm(y,x,k,1); rm(y,x,k,0); \
- break; \
- case 6: rm(y,x,k,5); rm(y,x,k,4); \
- rm(y,x,k,3); rm(y,x,k,2); \
- rm(y,x,k,1); rm(y,x,k,0); \
- break; \
- case 4: rm(y,x,k,3); rm(y,x,k,2); \
- rm(y,x,k,1); rm(y,x,k,0); \
- break; \
-}
-#else
-
-#define round(rm,y,x,k) \
-switch(nc) \
-{ case 8: rm(y,x,k,7); rm(y,x,k,6); \
- case 6: rm(y,x,k,5); rm(y,x,k,4); \
- case 4: rm(y,x,k,3); rm(y,x,k,2); \
- rm(y,x,k,1); rm(y,x,k,0); \
-}
-
-#endif
-
-#endif
-#endif
-
-/**
- * Implementation of private_aes_cbc_crypter_t.encrypt_block.
- */
-static void encrypt_block(const private_aes_cbc_crypter_t *this, const unsigned char in_blk[], unsigned char out_blk[])
-{ u_int32_t locals(b0, b1);
- const u_int32_t *kp = this->aes_e_key;
-
-#if !defined(ONE_TABLE) && !defined(FOUR_TABLES)
- u_int32_t f2;
-#endif
-
- state_in(b0, in_blk, kp); kp += nc;
-
-#if defined(UNROLL)
-
- switch(this->aes_Nrnd)
- {
- case 14: round(fwd_rnd, b1, b0, kp );
- round(fwd_rnd, b0, b1, kp + nc ); kp += 2 * nc;
- case 12: round(fwd_rnd, b1, b0, kp );
- round(fwd_rnd, b0, b1, kp + nc ); kp += 2 * nc;
- case 10: round(fwd_rnd, b1, b0, kp );
- round(fwd_rnd, b0, b1, kp + nc);
- round(fwd_rnd, b1, b0, kp + 2 * nc);
- round(fwd_rnd, b0, b1, kp + 3 * nc);
- round(fwd_rnd, b1, b0, kp + 4 * nc);
- round(fwd_rnd, b0, b1, kp + 5 * nc);
- round(fwd_rnd, b1, b0, kp + 6 * nc);
- round(fwd_rnd, b0, b1, kp + 7 * nc);
- round(fwd_rnd, b1, b0, kp + 8 * nc);
- round(fwd_lrnd, b0, b1, kp + 9 * nc);
- }
-
-#elif defined(PARTIAL_UNROLL)
- { u_int32_t rnd;
-
- for(rnd = 0; rnd < (this->aes_Nrnd >> 1) - 1; ++rnd)
- {
- round(fwd_rnd, b1, b0, kp);
- round(fwd_rnd, b0, b1, kp + nc); kp += 2 * nc;
- }
-
- round(fwd_rnd, b1, b0, kp);
- round(fwd_lrnd, b0, b1, kp + nc);
- }
-#else
- { u_int32_t rnd;
-
- for(rnd = 0; rnd < this->aes_Nrnd - 1; ++rnd)
- {
- round(fwd_rnd, b1, b0, kp);
- l_copy(b0, b1); kp += nc;
- }
-
- round(fwd_lrnd, b0, b1, kp);
- }
-#endif
-
- state_out(out_blk, b0);
-}
-
-/**
- * Implementation of private_aes_cbc_crypter_t.decrypt_block.
- */
-static void decrypt_block(const private_aes_cbc_crypter_t *this, const unsigned char in_blk[], unsigned char out_blk[])
-{ u_int32_t locals(b0, b1);
- const u_int32_t *kp = this->aes_d_key;
-
-#if !defined(ONE_TABLE) && !defined(FOUR_TABLES)
- u_int32_t f2, f4, f8, f9;
-#endif
-
- state_in(b0, in_blk, kp); kp += nc;
-
-#if defined(UNROLL)
-
- switch(this->aes_Nrnd)
- {
- case 14: round(inv_rnd, b1, b0, kp );
- round(inv_rnd, b0, b1, kp + nc ); kp += 2 * nc;
- case 12: round(inv_rnd, b1, b0, kp );
- round(inv_rnd, b0, b1, kp + nc ); kp += 2 * nc;
- case 10: round(inv_rnd, b1, b0, kp );
- round(inv_rnd, b0, b1, kp + nc);
- round(inv_rnd, b1, b0, kp + 2 * nc);
- round(inv_rnd, b0, b1, kp + 3 * nc);
- round(inv_rnd, b1, b0, kp + 4 * nc);
- round(inv_rnd, b0, b1, kp + 5 * nc);
- round(inv_rnd, b1, b0, kp + 6 * nc);
- round(inv_rnd, b0, b1, kp + 7 * nc);
- round(inv_rnd, b1, b0, kp + 8 * nc);
- round(inv_lrnd, b0, b1, kp + 9 * nc);
- }
-
-#elif defined(PARTIAL_UNROLL)
- { u_int32_t rnd;
-
- for(rnd = 0; rnd < (this->aes_Nrnd >> 1) - 1; ++rnd)
- {
- round(inv_rnd, b1, b0, kp);
- round(inv_rnd, b0, b1, kp + nc); kp += 2 * nc;
- }
-
- round(inv_rnd, b1, b0, kp);
- round(inv_lrnd, b0, b1, kp + nc);
- }
-#else
- { u_int32_t rnd;
-
- for(rnd = 0; rnd < this->aes_Nrnd - 1; ++rnd)
- {
- round(inv_rnd, b1, b0, kp);
- l_copy(b0, b1); kp += nc;
- }
-
- round(inv_lrnd, b0, b1, kp);
- }
-#endif
-
- state_out(out_blk, b0);
-}
-
-/**
- * Implementation of crypter_t.decrypt.
- */
-static status_t decrypt (private_aes_cbc_crypter_t *this, chunk_t data, chunk_t iv, chunk_t *decrypted)
-{
- int ret, pos;
- const u_int32_t *iv_i;
- u_int8_t *in, *out;
-
- ret = data.len;
- if (((data.len) % 16) != 0)
- {
- /* data length must be padded to a multiple of blocksize */
- return INVALID_ARG;
- }
-
- decrypted->ptr = allocator_alloc(data.len);
- if (decrypted->ptr == NULL)
- {
- return OUT_OF_RES;
- }
- decrypted->len = data.len;
-
- in = data.ptr;
- out = decrypted->ptr;
-
- pos=data.len-16;
- in+=pos;
- out+=pos;
- while(pos>=0) {
- this->decrypt_block(this,in,out);
- if (pos==0)
- iv_i=(const u_int32_t*) (iv.ptr);
- else
- iv_i=(const u_int32_t*) (in-16);
- *((u_int32_t *)(&out[ 0])) ^= iv_i[0];
- *((u_int32_t *)(&out[ 4])) ^= iv_i[1];
- *((u_int32_t *)(&out[ 8])) ^= iv_i[2];
- *((u_int32_t *)(&out[12])) ^= iv_i[3];
- in-=16;
- out-=16;
- pos-=16;
- }
-
- return SUCCESS;
-}
-
-
-/**
- * Implementation of crypter_t.decrypt.
- */
-static status_t encrypt (private_aes_cbc_crypter_t *this, chunk_t data, chunk_t iv, chunk_t *encrypted)
-{
- int ret, pos;
- const u_int32_t *iv_i;
- u_int8_t *in, *out;
-
- ret = data.len;
- if (((data.len) % 16) != 0)
- {
- /* data length must be padded to a multiple of blocksize */
- return INVALID_ARG;
- }
-
- encrypted->ptr = allocator_alloc(data.len);
- if (encrypted->ptr == NULL)
- {
- return OUT_OF_RES;
- }
- encrypted->len = data.len;
-
- in = data.ptr;
- out = encrypted->ptr;
-
- pos=0;
- while(pos<data.len)
- {
- if (pos==0)
- iv_i=(const u_int32_t*) iv.ptr;
- else
- iv_i=(const u_int32_t*) (out-16);
- *((u_int32_t *)(&out[ 0])) = iv_i[0]^*((const u_int32_t *)(&in[ 0]));
- *((u_int32_t *)(&out[ 4])) = iv_i[1]^*((const u_int32_t *)(&in[ 4]));
- *((u_int32_t *)(&out[ 8])) = iv_i[2]^*((const u_int32_t *)(&in[ 8]));
- *((u_int32_t *)(&out[12])) = iv_i[3]^*((const u_int32_t *)(&in[12]));
- this->encrypt_block(this,out,out);
- in+=16;
- out+=16;
- pos+=16;
- }
- return SUCCESS;
-}
-
-/**
- * Implementation of crypter_t.get_block_size.
- */
-static size_t get_block_size (private_aes_cbc_crypter_t *this)
-{
- return AES_BLOCK_SIZE;
-}
-
-/**
- * Implementation of crypter_t.get_key_size.
- */
-static size_t get_key_size (private_aes_cbc_crypter_t *this)
-{
- return this->key_size;
-}
-
-/**
- * Implementation of crypter_t.set_key.
- */
-static status_t set_key (private_aes_cbc_crypter_t *this, chunk_t key)
-{
- u_int32_t *kf, *kt, rci, f = 0;
- u_int8_t *in_key = key.ptr;
-
- if (key.len != this->key_size)
- {
- return INVALID_ARG;
- }
-
- this->aes_Nrnd = (this->aes_Nkey > (this->aes_Ncol) ? this->aes_Nkey : (this->aes_Ncol)) + 6;
-
- this->aes_e_key[0] = const_word_in(in_key );
- this->aes_e_key[1] = const_word_in(in_key + 4);
- this->aes_e_key[2] = const_word_in(in_key + 8);
- this->aes_e_key[3] = const_word_in(in_key + 12);
-
- kf = this->aes_e_key;
- kt = kf + nc * (this->aes_Nrnd + 1) - this->aes_Nkey;
- rci = 0;
-
- switch(this->aes_Nkey)
- {
- case 4: do
- { kf[4] = kf[0] ^ ls_box(kf[3],3) ^ rcon_tab[rci++];
- kf[5] = kf[1] ^ kf[4];
- kf[6] = kf[2] ^ kf[5];
- kf[7] = kf[3] ^ kf[6];
- kf += 4;
- }
- while(kf < kt);
- break;
-
- case 6: this->aes_e_key[4] = const_word_in(in_key + 16);
- this->aes_e_key[5] = const_word_in(in_key + 20);
- do
- { kf[ 6] = kf[0] ^ ls_box(kf[5],3) ^ rcon_tab[rci++];
- kf[ 7] = kf[1] ^ kf[ 6];
- kf[ 8] = kf[2] ^ kf[ 7];
- kf[ 9] = kf[3] ^ kf[ 8];
- kf[10] = kf[4] ^ kf[ 9];
- kf[11] = kf[5] ^ kf[10];
- kf += 6;
- }
- while(kf < kt);
- break;
-
- case 8: this->aes_e_key[4] = const_word_in(in_key + 16);
- this->aes_e_key[5] = const_word_in(in_key + 20);
- this->aes_e_key[6] = const_word_in(in_key + 24);
- this->aes_e_key[7] = const_word_in(in_key + 28);
- do
- { kf[ 8] = kf[0] ^ ls_box(kf[7],3) ^ rcon_tab[rci++];
- kf[ 9] = kf[1] ^ kf[ 8];
- kf[10] = kf[2] ^ kf[ 9];
- kf[11] = kf[3] ^ kf[10];
- kf[12] = kf[4] ^ ls_box(kf[11],0);
- kf[13] = kf[5] ^ kf[12];
- kf[14] = kf[6] ^ kf[13];
- kf[15] = kf[7] ^ kf[14];
- kf += 8;
- }
- while (kf < kt);
- break;
- }
-
- if(!f)
- {
- u_int32_t i;
-
- kt = this->aes_d_key + nc * this->aes_Nrnd;
- kf = this->aes_e_key;
-
- cpy(kt, kf); kt -= 2 * nc;
-
- for(i = 1; i < this->aes_Nrnd; ++i)
- {
-#if defined(ONE_TABLE) || defined(FOUR_TABLES)
-#if !defined(ONE_IM_TABLE) && !defined(FOUR_IM_TABLES)
- u_int32_t f2, f4, f8, f9;
-#endif
- mix(kt, kf);
-#else
- cpy(kt, kf);
-#endif
- kt -= 2 * nc;
- }
- cpy(kt, kf);
- }
-
- return SUCCESS;
-}
-
-/**
- * Implementation of crypter_t.destroy and aes_cbc_crypter_t.destroy.
- */
-static void destroy (private_aes_cbc_crypter_t *this)
-{
- allocator_free(this);
-}
-
-/*
- * Described in header
- */
-aes_cbc_crypter_t *aes_cbc_crypter_create(size_t key_size)
-{
- private_aes_cbc_crypter_t *this = allocator_alloc_thing(private_aes_cbc_crypter_t);
-
- #if !defined(FIXED_TABLES)
- if(!tab_gen) { gen_tabs(); tab_gen = 1; }
- #endif
-
- this->key_size = key_size;
- switch(key_size) {
- case 32: /* bytes */
- this->aes_Ncol = 8;
- this->aes_Nkey = 8;
- break;
- case 24: /* bytes */
- this->aes_Ncol = 6;
- this->aes_Nkey = 6;
- break;
- case 16: /* bytes */
- this->aes_Ncol = 4;
- this->aes_Nkey = 4;
- break;
- default:
- allocator_free(this);
- return NULL;
- }
-
- /* functions of crypter_t interface */
- this->public.crypter_interface.encrypt = (status_t (*) (crypter_t *, chunk_t,chunk_t, chunk_t *)) encrypt;
- this->public.crypter_interface.decrypt = (status_t (*) (crypter_t *, chunk_t , chunk_t, chunk_t *)) decrypt;
- this->public.crypter_interface.get_block_size = (size_t (*) (crypter_t *)) get_block_size;
- this->public.crypter_interface.get_key_size = (size_t (*) (crypter_t *)) get_key_size;
- this->public.crypter_interface.set_key = (status_t (*) (crypter_t *,chunk_t)) set_key;
- this->public.crypter_interface.destroy = (void (*) (crypter_t *)) destroy;
-
- /* private functions */
- this->decrypt_block = decrypt_block;
- this->encrypt_block = encrypt_block;
-
- return &(this->public);
-}
diff --git a/Source/charon/transforms/crypters/aes_cbc_crypter.h b/Source/charon/transforms/crypters/aes_cbc_crypter.h
deleted file mode 100644
index b2c93348e..000000000
--- a/Source/charon/transforms/crypters/aes_cbc_crypter.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * @file aes_cbc_crypter.h
- *
- * @brief Interface of aes_cbc_crypter_t
- *
- */
-
-/*
- * Copyright (C) 2001 Dr B. R. Gladman <brg@gladman.uk.net>
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef AES_CBC_CRYPTER_H_
-#define AES_CBC_CRYPTER_H_
-
-#include <transforms/crypters/crypter.h>
-
-
-typedef struct aes_cbc_crypter_t aes_cbc_crypter_t;
-
-/**
- * @brief Class implementing the AES symmetric encryption algorithm.
- *
- * @b Constructors:
- * - aes_cbc_crypter_create()
- *
- * @ingroup crypters
- */
-struct aes_cbc_crypter_t {
-
- /**
- * The crypter_t interface.
- */
- crypter_t crypter_interface;
-};
-
-/**
- * @brief Constructor to create aes_cbc_crypter_t objects.
- *
- * Supported key sizes are: 16, 24 or 32.
- *
- * @param key_size key size in bytes
- * @return
- * - aes_cbc_crypter_t object
- * - NULL if key size not supported
- */
-aes_cbc_crypter_t *aes_cbc_crypter_create(size_t key_size);
-
-
-#endif /* AES_CBC_CRYPTER_H_ */
diff --git a/Source/charon/transforms/crypters/crypter.c b/Source/charon/transforms/crypters/crypter.c
deleted file mode 100644
index 37b96304e..000000000
--- a/Source/charon/transforms/crypters/crypter.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * @file crypter.c
- *
- * @brief Generic constructor for crypter_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-
-#include "crypter.h"
-
-#include <transforms/crypters/aes_cbc_crypter.h>
-
-
-/**
- * String mappings for encryption_algorithm_t.
- */
-mapping_t encryption_algorithm_m[] = {
-{ENCR_UNDEFINED, "ENCR_UNDEFINED"},
-{ENCR_DES_IV64, "ENCR_DES_IV64"},
-{ENCR_DES, "ENCR_DES"},
-{ENCR_3DES, "ENCR_3DES"},
-{ENCR_RC5, "ENCR_RC5"},
-{ENCR_IDEA, "ENCR_IDEA"},
-{ENCR_CAST, "ENCR_CAST"},
-{ENCR_BLOWFISH, "ENCR_BLOWFISH"},
-{ENCR_3IDEA, "ENCR_3IDEA"},
-{ENCR_DES_IV32, "ENCR_DES_IV32"},
-{ENCR_NULL, "ENCR_NULL"},
-{ENCR_AES_CBC, "ENCR_AES_CBC"},
-{ENCR_AES_CTR, "ENCR_AES_CTR"},
-{MAPPING_END, NULL}
-};
-
-/*
- * Described in header.
- */
-crypter_t *crypter_create(encryption_algorithm_t encryption_algorithm, size_t key_size)
-{
- switch (encryption_algorithm)
- {
- case ENCR_AES_CBC:
- {
- return (crypter_t*)aes_cbc_crypter_create(key_size);
- }
- default:
- return NULL;
- }
-}
diff --git a/Source/charon/transforms/crypters/crypter.h b/Source/charon/transforms/crypters/crypter.h
deleted file mode 100644
index 9c219f5cc..000000000
--- a/Source/charon/transforms/crypters/crypter.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/**
- * @file crypter.h
- *
- * @brief Interface crypter_t
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef CRYPTER_H_
-#define CRYPTER_H_
-
-#include <types.h>
-
-typedef enum encryption_algorithm_t encryption_algorithm_t;
-
-/**
- * @brief Encryption algorithm, as in IKEv2 RFC 3.3.2.
- *
- * Currently only the following algorithms are implemented and therefore supported:
- * - ENCR_AES_CBC
- *
- * @todo Implement more enryption algorithms, such as 3DES
- *
- * @ingroup crypters
- */
-enum encryption_algorithm_t {
- ENCR_UNDEFINED = 1024,
- ENCR_DES_IV64 = 1,
- ENCR_DES = 2,
- ENCR_3DES = 3,
- ENCR_RC5 = 4,
- ENCR_IDEA = 5,
- ENCR_CAST = 6,
- ENCR_BLOWFISH = 7,
- ENCR_3IDEA = 8,
- ENCR_DES_IV32 = 9,
- ENCR_NULL = 11,
- /**
- * Implemented in class aes_cbc_crypter_t.
- */
- ENCR_AES_CBC = 12,
- ENCR_AES_CTR = 13
-};
-
-/**
- * String mappings for encryption_algorithm_t.
- */
-extern mapping_t encryption_algorithm_m[];
-
-
-typedef struct crypter_t crypter_t;
-
-/**
- * @brief Generic interface for symmetric encryption algorithms.
- *
- * @b Constructors:
- * - crypter_create()
- *
- * @ingroup crypters
- */
-struct crypter_t {
- /**
- * @brief Encrypt a chunk of data and allocate space for the encrypted value.
- *
- * @param this calling object
- * @param data data to encrypt
- * @param iv initializing vector
- * @param[out] encrypted pointer where the encrypted bytes will be written
- * @return
- * - SUCCESS
- * - INVALID_ARG if data size not a multiple of block size
- */
- status_t (*encrypt) (crypter_t *this, chunk_t data, chunk_t iv, chunk_t *encrypted);
-
- /**
- * @brief Decrypt a chunk of data and allocate space for the decrypted value.
- *
- * @param this calling object
- * @param data data to decrypt
- * @param iv initializing vector
- * @param[out] encrypted pointer where the decrypted bytes will be written
- * @return
- * - SUCCESS
- * - INVALID_ARG if data size not a multiple of block size
- */
- status_t (*decrypt) (crypter_t *this, chunk_t data, chunk_t iv, chunk_t *decrypted);
-
- /**
- * @brief Get the block size of this crypter_t object.
- *
- * @param this calling object
- * @return block size in bytes
- */
- size_t (*get_block_size) (crypter_t *this);
-
- /**
- * @brief Get the key size of this crypter_t object.
- *
- * @param this calling object
- * @return key size in bytes
- */
- size_t (*get_key_size) (crypter_t *this);
-
- /**
- * @brief Set the key for this crypter_t object.
- *
- * @param this calling object
- * @param key key to set
- * @return
- * - SUCCESS
- * - INVALID_ARG if key length invalid
- */
- status_t (*set_key) (crypter_t *this, chunk_t key);
-
- /**
- * @brief Destroys a crypter_t object.
- *
- * @param this calling object
- */
- void (*destroy) (crypter_t *this);
-};
-
-/**
- * @brief Generic constructor for crypter_t objects.
- *
- * Currently only the following algorithms are implemented and therefore supported:
- * - ENCR_AES_CBC
- *
- * The key_size is ignored for algorithms with fixed key size.
- *
- * @param encryption_algorithm Algorithm to use for crypter
- * @param key_size size of the key in bytes
- * @return
- * - crypter_t object
- * - NULL if encryption algorithm/key_size is not supported
- */
-crypter_t *crypter_create(encryption_algorithm_t encryption_algorithm, size_t key_size);
-
-#endif /*CRYPTER_H_*/
diff --git a/Source/charon/transforms/diffie_hellman.c b/Source/charon/transforms/diffie_hellman.c
deleted file mode 100644
index 88900eb61..000000000
--- a/Source/charon/transforms/diffie_hellman.c
+++ /dev/null
@@ -1,611 +0,0 @@
-/**
- * @file diffie_hellman.c
- *
- * @brief Implementation of diffie_hellman_t.
- *
- */
-
-/*
- * Copyright (C) 1998-2002 D. Hugh Redelmeier.
- * Copyright (C) 1999, 2000, 2001 Henry Spencer.
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <gmp.h>
-#include <stdio.h>
-
-#include "diffie_hellman.h"
-
-#include <daemon.h>
-#include <utils/allocator.h>
-#include <utils/randomizer.h>
-
-
-/**
- * String mappings for diffie_hellman_group_t.
- */
-mapping_t diffie_hellman_group_m[] = {
- {MODP_UNDEFINED, "MODP_UNDEFINED"},
- {MODP_768_BIT, "MODP_768_BIT"},
- {MODP_1024_BIT, "MODP_1024_BIT"},
- {MODP_1536_BIT, "MODP_1536_BIT"},
- {MODP_2048_BIT, "MODP_2048_BIT"},
- {MODP_3072_BIT, "MODP_3072_BIT"},
- {MODP_4096_BIT, "MODP_4096_BIT"},
- {MODP_6144_BIT, "MODP_6144_BIT"},
- {MODP_8192_BIT, "MODP_8192_BIT"},
- {MAPPING_END, NULL}
-};
-
-
-/**
- * Modulus of Group 1 (MODP_768_BIT).
- */
-static u_int8_t group1_modulus[] = {
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC9,0x0F,0xDA,0xA2,0x21,0x68,0xC2,0x34,
- 0xC4,0xC6,0x62,0x8B,0x80 ,0xDC,0x1C,0xD1,0x29,0x02,0x4E,0x08,0x8A,0x67,0xCC,0x74,
- 0x02,0x0B,0xBE,0xA6,0x3B,0x13,0x9B,0x22,0x51,0x4A,0x08,0x79,0x8E,0x34,0x04,0xDD,
- 0xEF,0x95,0x19,0xB3,0xCD,0x3A,0x43,0x1B,0x30,0x2B,0x0A,0x6D,0xF2,0x5F,0x14,0x37,
- 0x4F,0xE1,0x35,0x6D,0x6D,0x51,0xC2,0x45,0xE4,0x85,0xB5,0x76,0x62,0x5E,0x7E,0xC6,
- 0xF4,0x4C,0x42,0xE9,0xA6,0x3A,0x36,0x20,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
-};
-
-/**
- * Modulus of Group 2 (MODP_1024_BIT).
- */
-static u_int8_t group2_modulus[] = {
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC9,0x0F,0xDA,0xA2,0x21,0x68,0xC2,0x34,
- 0xC4,0xC6,0x62,0x8B,0x80,0xDC,0x1C,0xD1,0x29,0x02,0x4E,0x08,0x8A,0x67,0xCC,0x74,
- 0x02,0x0B,0xBE,0xA6,0x3B,0x13,0x9B,0x22,0x51,0x4A,0x08,0x79,0x8E,0x34,0x04,0xDD,
- 0xEF,0x95,0x19,0xB3,0xCD,0x3A,0x43,0x1B,0x30,0x2B,0x0A,0x6D,0xF2,0x5F,0x14,0x37,
- 0x4F,0xE1,0x35,0x6D,0x6D,0x51,0xC2,0x45,0xE4,0x85,0xB5,0x76,0x62,0x5E,0x7E,0xC6,
- 0xF4,0x4C,0x42,0xE9,0xA6,0x37,0xED,0x6B,0x0B,0xFF,0x5C,0xB6,0xF4,0x06,0xB7,0xED,
- 0xEE,0x38,0x6B,0xFB,0x5A,0x89,0x9F,0xA5,0xAE,0x9F,0x24,0x11,0x7C,0x4B,0x1F,0xE6,
- 0x49,0x28,0x66,0x51,0xEC,0xE6,0x53,0x81,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
-};
-
-/**
- * Modulus of Group 5 (MODP_1536_BIT).
- */
-static u_int8_t group5_modulus[] = {
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC9,0x0F,0xDA,0xA2,0x21,0x68,0xC2,0x34,
- 0xC4,0xC6,0x62,0x8B,0x80,0xDC,0x1C,0xD1,0x29,0x02,0x4E,0x08,0x8A,0x67,0xCC,0x74,
- 0x02,0x0B,0xBE,0xA6,0x3B,0x13,0x9B,0x22,0x51,0x4A,0x08,0x79,0x8E,0x34,0x04,0xDD,
- 0xEF,0x95,0x19,0xB3,0xCD,0x3A,0x43,0x1B,0x30,0x2B,0x0A,0x6D,0xF2,0x5F,0x14,0x37,
- 0x4F,0xE1,0x35,0x6D,0x6D,0x51,0xC2,0x45,0xE4,0x85,0xB5,0x76,0x62,0x5E,0x7E,0xC6,
- 0xF4,0x4C,0x42,0xE9,0xA6,0x37,0xED,0x6B,0x0B,0xFF,0x5C,0xB6,0xF4,0x06,0xB7,0xED,
- 0xEE,0x38,0x6B,0xFB,0x5A,0x89,0x9F,0xA5,0xAE,0x9F,0x24,0x11,0x7C,0x4B,0x1F,0xE6,
- 0x49,0x28,0x66,0x51,0xEC,0xE4,0x5B,0x3D,0xC2,0x00,0x7C,0xB8,0xA1,0x63,0xBF,0x05,
- 0x98,0xDA,0x48,0x36,0x1C,0x55,0xD3,0x9A,0x69,0x16,0x3F,0xA8,0xFD,0x24,0xCF,0x5F,
- 0x83,0x65,0x5D,0x23,0xDC,0xA3,0xAD,0x96,0x1C,0x62,0xF3,0x56,0x20,0x85,0x52,0xBB,
- 0x9E,0xD5,0x29,0x07,0x70,0x96,0x96,0x6D,0x67,0x0C,0x35,0x4E,0x4A,0xBC,0x98,0x04,
- 0xF1,0x74,0x6C,0x08,0xCA,0x23,0x73,0x27,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
-};
-/**
- * Modulus of Group 14 (MODP_2048_BIT).
- */
-static u_int8_t group14_modulus[] = {
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC9,0x0F,0xDA,0xA2,0x21,0x68,0xC2,0x34,
- 0xC4,0xC6,0x62,0x8B,0x80,0xDC,0x1C,0xD1,0x29,0x02,0x4E,0x08,0x8A,0x67,0xCC,0x74,
- 0x02,0x0B,0xBE,0xA6,0x3B,0x13,0x9B,0x22,0x51,0x4A,0x08,0x79,0x8E,0x34,0x04,0xDD,
- 0xEF,0x95,0x19,0xB3,0xCD,0x3A,0x43,0x1B,0x30,0x2B,0x0A,0x6D,0xF2,0x5F,0x14,0x37,
- 0x4F,0xE1,0x35,0x6D,0x6D,0x51,0xC2,0x45,0xE4,0x85,0xB5,0x76,0x62,0x5E,0x7E,0xC6,
- 0xF4,0x4C,0x42,0xE9,0xA6,0x37,0xED,0x6B,0x0B,0xFF,0x5C,0xB6,0xF4,0x06,0xB7,0xED,
- 0xEE,0x38,0x6B,0xFB,0x5A,0x89,0x9F,0xA5,0xAE,0x9F,0x24,0x11,0x7C,0x4B,0x1F,0xE6,
- 0x49,0x28,0x66,0x51,0xEC,0xE4,0x5B,0x3D,0xC2,0x00,0x7C,0xB8,0xA1,0x63,0xBF,0x05,
- 0x98,0xDA,0x48,0x36,0x1C,0x55,0xD3,0x9A,0x69,0x16,0x3F,0xA8,0xFD,0x24,0xCF,0x5F,
- 0x83,0x65,0x5D,0x23,0xDC,0xA3,0xAD,0x96,0x1C,0x62,0xF3,0x56,0x20,0x85,0x52,0xBB,
- 0x9E,0xD5,0x29,0x07,0x70,0x96,0x96,0x6D,0x67,0x0C,0x35,0x4E,0x4A,0xBC,0x98,0x04,
- 0xF1,0x74,0x6C,0x08,0xCA,0x18,0x21,0x7C,0x32,0x90,0x5E,0x46,0x2E,0x36,0xCE,0x3B,
- 0xE3,0x9E,0x77,0x2C,0x18,0x0E,0x86,0x03,0x9B,0x27,0x83,0xA2,0xEC,0x07,0xA2,0x8F,
- 0xB5,0xC5,0x5D,0xF0,0x6F,0x4C,0x52,0xC9,0xDE,0x2B,0xCB,0xF6,0x95,0x58,0x17,0x18,
- 0x39,0x95,0x49,0x7C,0xEA,0x95,0x6A,0xE5,0x15,0xD2,0x26,0x18,0x98,0xFA,0x05,0x10,
- 0x15,0x72,0x8E,0x5A,0x8A,0xAC,0xAA,0x68,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
-};
-
-/**
- * Modulus of Group 15 (MODP_3072_BIT).
- */
-static u_int8_t group15_modulus[] = {
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC9,0x0F,0xDA,0xA2,0x21,0x68,0xC2,0x34,
- 0xC4,0xC6,0x62,0x8B,0x80,0xDC,0x1C,0xD1,0x29,0x02,0x4E,0x08,0x8A,0x67,0xCC,0x74,
- 0x02,0x0B,0xBE,0xA6,0x3B,0x13,0x9B,0x22,0x51,0x4A,0x08,0x79,0x8E,0x34,0x04,0xDD,
- 0xEF,0x95,0x19,0xB3,0xCD,0x3A,0x43,0x1B,0x30,0x2B,0x0A,0x6D,0xF2,0x5F,0x14,0x37,
- 0x4F,0xE1,0x35,0x6D,0x6D,0x51,0xC2,0x45,0xE4,0x85,0xB5,0x76,0x62,0x5E,0x7E,0xC6,
- 0xF4,0x4C,0x42,0xE9,0xA6,0x37,0xED,0x6B,0x0B,0xFF,0x5C,0xB6,0xF4,0x06,0xB7,0xED,
- 0xEE,0x38,0x6B,0xFB,0x5A,0x89,0x9F,0xA5,0xAE,0x9F,0x24,0x11,0x7C,0x4B,0x1F,0xE6,
- 0x49,0x28,0x66,0x51,0xEC,0xE4,0x5B,0x3D,0xC2,0x00,0x7C,0xB8,0xA1,0x63,0xBF,0x05,
- 0x98,0xDA,0x48,0x36,0x1C,0x55,0xD3,0x9A,0x69,0x16,0x3F,0xA8,0xFD,0x24,0xCF,0x5F,
- 0x83,0x65,0x5D,0x23,0xDC,0xA3,0xAD,0x96,0x1C,0x62,0xF3,0x56,0x20,0x85,0x52,0xBB,
- 0x9E,0xD5,0x29,0x07,0x70,0x96,0x96,0x6D,0x67,0x0C,0x35,0x4E,0x4A,0xBC,0x98,0x04,
- 0xF1,0x74,0x6C,0x08,0xCA,0x18,0x21,0x7C,0x32,0x90,0x5E,0x46,0x2E,0x36,0xCE,0x3B,
- 0xE3,0x9E,0x77,0x2C,0x18,0x0E,0x86,0x03,0x9B,0x27,0x83,0xA2,0xEC,0x07,0xA2,0x8F,
- 0xB5,0xC5,0x5D,0xF0,0x6F,0x4C,0x52,0xC9,0xDE,0x2B,0xCB,0xF6,0x95,0x58,0x17,0x18,
- 0x39,0x95,0x49,0x7C,0xEA,0x95,0x6A,0xE5,0x15,0xD2,0x26,0x18,0x98,0xFA,0x05,0x10,
- 0x15,0x72,0x8E,0x5A,0x8A,0xAA,0xC4,0x2D,0xAD,0x33,0x17,0x0D,0x04,0x50,0x7A,0x33,
- 0xA8,0x55,0x21,0xAB,0xDF,0x1C,0xBA,0x64,0xEC,0xFB,0x85,0x04,0x58,0xDB,0xEF,0x0A,
- 0x8A,0xEA,0x71,0x57,0x5D,0x06,0x0C,0x7D,0xB3,0x97,0x0F,0x85,0xA6,0xE1,0xE4,0xC7,
- 0xAB,0xF5,0xAE,0x8C,0xDB,0x09,0x33,0xD7,0x1E,0x8C,0x94,0xE0,0x4A,0x25,0x61,0x9D,
- 0xCE,0xE3,0xD2,0x26,0x1A,0xD2,0xEE,0x6B,0xF1,0x2F,0xFA,0x06,0xD9,0x8A,0x08,0x64,
- 0xD8,0x76,0x02,0x73,0x3E,0xC8,0x6A,0x64,0x52,0x1F,0x2B,0x18,0x17,0x7B,0x20,0x0C,
- 0xBB,0xE1,0x17,0x57,0x7A,0x61,0x5D,0x6C,0x77,0x09,0x88,0xC0,0xBA,0xD9,0x46,0xE2,
- 0x08,0xE2,0x4F,0xA0,0x74,0xE5,0xAB,0x31,0x43,0xDB,0x5B,0xFC,0xE0,0xFD,0x10,0x8E,
- 0x4B,0x82,0xD1,0x20,0xA9,0x3A,0xD2,0xCA,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
-};
-
-/**
- * Modulus of Group 16 (MODP_4096_BIT).
- */
-static u_int8_t group16_modulus[] = {
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC9,0x0F,0xDA,0xA2,0x21,0x68,0xC2,0x34,
- 0xC4,0xC6,0x62,0x8B,0x80,0xDC,0x1C,0xD1,0x29,0x02,0x4E,0x08,0x8A,0x67,0xCC,0x74,
- 0x02,0x0B,0xBE,0xA6,0x3B,0x13,0x9B,0x22,0x51,0x4A,0x08,0x79,0x8E,0x34,0x04,0xDD,
- 0xEF,0x95,0x19,0xB3,0xCD,0x3A,0x43,0x1B,0x30,0x2B,0x0A,0x6D,0xF2,0x5F,0x14,0x37,
- 0x4F,0xE1,0x35,0x6D,0x6D,0x51,0xC2,0x45,0xE4,0x85,0xB5,0x76,0x62,0x5E,0x7E,0xC6,
- 0xF4,0x4C,0x42,0xE9,0xA6,0x37,0xED,0x6B,0x0B,0xFF,0x5C,0xB6,0xF4,0x06,0xB7,0xED,
- 0xEE,0x38,0x6B,0xFB,0x5A,0x89,0x9F,0xA5,0xAE,0x9F,0x24,0x11,0x7C,0x4B,0x1F,0xE6,
- 0x49,0x28,0x66,0x51,0xEC,0xE4,0x5B,0x3D,0xC2,0x00,0x7C,0xB8,0xA1,0x63,0xBF,0x05,
- 0x98,0xDA,0x48,0x36,0x1C,0x55,0xD3,0x9A,0x69,0x16,0x3F,0xA8,0xFD,0x24,0xCF,0x5F,
- 0x83,0x65,0x5D,0x23,0xDC,0xA3,0xAD,0x96,0x1C,0x62,0xF3,0x56,0x20,0x85,0x52,0xBB,
- 0x9E,0xD5,0x29,0x07,0x70,0x96,0x96,0x6D,0x67,0x0C,0x35,0x4E,0x4A,0xBC,0x98,0x04,
- 0xF1,0x74,0x6C,0x08,0xCA,0x18,0x21,0x7C,0x32,0x90,0x5E,0x46,0x2E,0x36,0xCE,0x3B,
- 0xE3,0x9E,0x77,0x2C,0x18,0x0E,0x86,0x03,0x9B,0x27,0x83,0xA2,0xEC,0x07,0xA2,0x8F,
- 0xB5,0xC5,0x5D,0xF0,0x6F,0x4C,0x52,0xC9,0xDE,0x2B,0xCB,0xF6,0x95,0x58,0x17,0x18,
- 0x39,0x95,0x49,0x7C,0xEA,0x95,0x6A,0xE5,0x15,0xD2,0x26,0x18,0x98,0xFA,0x05,0x10,
- 0x15,0x72,0x8E,0x5A,0x8A,0xAA,0xC4,0x2D,0xAD,0x33,0x17,0x0D,0x04,0x50,0x7A,0x33,
- 0xA8,0x55,0x21,0xAB,0xDF,0x1C,0xBA,0x64,0xEC,0xFB,0x85,0x04,0x58,0xDB,0xEF,0x0A,
- 0x8A,0xEA,0x71,0x57,0x5D,0x06,0x0C,0x7D,0xB3,0x97,0x0F,0x85,0xA6,0xE1,0xE4,0xC7,
- 0xAB,0xF5,0xAE,0x8C,0xDB,0x09,0x33,0xD7,0x1E,0x8C,0x94,0xE0,0x4A,0x25,0x61,0x9D,
- 0xCE,0xE3,0xD2,0x26,0x1A,0xD2,0xEE,0x6B,0xF1,0x2F,0xFA,0x06,0xD9,0x8A,0x08,0x64,
- 0xD8,0x76,0x02,0x73,0x3E,0xC8,0x6A,0x64,0x52,0x1F,0x2B,0x18,0x17,0x7B,0x20,0x0C,
- 0xBB,0xE1,0x17,0x57,0x7A,0x61,0x5D,0x6C,0x77,0x09,0x88,0xC0,0xBA,0xD9,0x46,0xE2,
- 0x08,0xE2,0x4F,0xA0,0x74,0xE5,0xAB,0x31,0x43,0xDB,0x5B,0xFC,0xE0,0xFD,0x10,0x8E,
- 0x4B,0x82,0xD1,0x20,0xA9,0x21,0x08,0x01,0x1A,0x72,0x3C,0x12,0xA7,0x87,0xE6,0xD7,
- 0x88,0x71,0x9A,0x10,0xBD,0xBA,0x5B,0x26,0x99,0xC3,0x27,0x18,0x6A,0xF4,0xE2,0x3C,
- 0x1A,0x94,0x68,0x34,0xB6,0x15,0x0B,0xDA,0x25,0x83,0xE9,0xCA,0x2A,0xD4,0x4C,0xE8,
- 0xDB,0xBB,0xC2,0xDB,0x04,0xDE,0x8E,0xF9,0x2E,0x8E,0xFC,0x14,0x1F,0xBE,0xCA,0xA6,
- 0x28,0x7C,0x59,0x47,0x4E,0x6B,0xC0,0x5D,0x99,0xB2,0x96,0x4F,0xA0,0x90,0xC3,0xA2,
- 0x23,0x3B,0xA1,0x86,0x51,0x5B,0xE7,0xED,0x1F,0x61,0x29,0x70,0xCE,0xE2,0xD7,0xAF,
- 0xB8,0x1B,0xDD,0x76,0x21,0x70,0x48,0x1C,0xD0,0x06,0x91,0x27,0xD5,0xB0,0x5A,0xA9,
- 0x93,0xB4,0xEA,0x98,0x8D,0x8F,0xDD,0xC1,0x86,0xFF,0xB7,0xDC,0x90,0xA6,0xC0,0x8F,
- 0x4D,0xF4,0x35,0xC9,0x34,0x06,0x31,0x99,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
-};
-
-/**
- * Modulus of Group 17 (MODP_6144_BIT).
- */
-static u_int8_t group17_modulus[] = {
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC9,0x0F,0xDA,0xA2,0x21,0x68,0xC2,0x34,
- 0xC4,0xC6,0x62,0x8B,0x80,0xDC,0x1C,0xD1,0x29,0x02,0x4E,0x08,0x8A,0x67,0xCC,0x74,
- 0x02,0x0B,0xBE,0xA6,0x3B,0x13,0x9B,0x22,0x51,0x4A,0x08,0x79,0x8E,0x34,0x04,0xDD,
- 0xEF,0x95,0x19,0xB3,0xCD,0x3A,0x43,0x1B,0x30,0x2B,0x0A,0x6D,0xF2,0x5F,0x14,0x37,
- 0x4F,0xE1,0x35,0x6D,0x6D,0x51,0xC2,0x45,0xE4,0x85,0xB5,0x76,0x62,0x5E,0x7E,0xC6,
- 0xF4,0x4C,0x42,0xE9,0xA6,0x37,0xED,0x6B,0x0B,0xFF,0x5C,0xB6,0xF4,0x06,0xB7,0xED,
- 0xEE,0x38,0x6B,0xFB,0x5A,0x89,0x9F,0xA5,0xAE,0x9F,0x24,0x11,0x7C,0x4B,0x1F,0xE6,
- 0x49,0x28,0x66,0x51,0xEC,0xE4,0x5B,0x3D,0xC2,0x00,0x7C,0xB8,0xA1,0x63,0xBF,0x05,
- 0x98,0xDA,0x48,0x36,0x1C,0x55,0xD3,0x9A,0x69,0x16,0x3F,0xA8,0xFD,0x24,0xCF,0x5F,
- 0x83,0x65,0x5D,0x23,0xDC,0xA3,0xAD,0x96,0x1C,0x62,0xF3,0x56,0x20,0x85,0x52,0xBB,
- 0x9E,0xD5,0x29,0x07,0x70,0x96,0x96,0x6D,0x67,0x0C,0x35,0x4E,0x4A,0xBC,0x98,0x04,
- 0xF1,0x74,0x6C,0x08,0xCA,0x18,0x21,0x7C,0x32,0x90,0x5E,0x46,0x2E,0x36,0xCE,0x3B,
- 0xE3,0x9E,0x77,0x2C,0x18,0x0E,0x86,0x03,0x9B,0x27,0x83,0xA2,0xEC,0x07,0xA2,0x8F,
- 0xB5,0xC5,0x5D,0xF0,0x6F,0x4C,0x52,0xC9,0xDE,0x2B,0xCB,0xF6,0x95,0x58,0x17,0x18,
- 0x39,0x95,0x49,0x7C,0xEA,0x95,0x6A,0xE5,0x15,0xD2,0x26,0x18,0x98,0xFA,0x05,0x10,
- 0x15,0x72,0x8E,0x5A,0x8A,0xAA,0xC4,0x2D,0xAD,0x33,0x17,0x0D,0x04,0x50,0x7A,0x33,
- 0xA8,0x55,0x21,0xAB,0xDF,0x1C,0xBA,0x64,0xEC,0xFB,0x85,0x04,0x58,0xDB,0xEF,0x0A,
- 0x8A,0xEA,0x71,0x57,0x5D,0x06,0x0C,0x7D,0xB3,0x97,0x0F,0x85,0xA6,0xE1,0xE4,0xC7,
- 0xAB,0xF5,0xAE,0x8C,0xDB,0x09,0x33,0xD7,0x1E,0x8C,0x94,0xE0,0x4A,0x25,0x61,0x9D,
- 0xCE,0xE3,0xD2,0x26,0x1A,0xD2,0xEE,0x6B,0xF1,0x2F,0xFA,0x06,0xD9,0x8A,0x08,0x64,
- 0xD8,0x76,0x02,0x73,0x3E,0xC8,0x6A,0x64,0x52,0x1F,0x2B,0x18,0x17,0x7B,0x20,0x0C,
- 0xBB,0xE1,0x17,0x57,0x7A,0x61,0x5D,0x6C,0x77,0x09,0x88,0xC0,0xBA,0xD9,0x46,0xE2,
- 0x08,0xE2,0x4F,0xA0,0x74,0xE5,0xAB,0x31,0x43,0xDB,0x5B,0xFC,0xE0,0xFD,0x10,0x8E,
- 0x4B,0x82,0xD1,0x20,0xA9,0x21,0x08,0x01,0x1A,0x72,0x3C,0x12,0xA7,0x87,0xE6,0xD7,
- 0x88,0x71,0x9A,0x10,0xBD,0xBA,0x5B,0x26,0x99,0xC3,0x27,0x18,0x6A,0xF4,0xE2,0x3C,
- 0x1A,0x94,0x68,0x34,0xB6,0x15,0x0B,0xDA,0x25,0x83,0xE9,0xCA,0x2A,0xD4,0x4C,0xE8,
- 0xDB,0xBB,0xC2,0xDB,0x04,0xDE,0x8E,0xF9,0x2E,0x8E,0xFC,0x14,0x1F,0xBE,0xCA,0xA6,
- 0x28,0x7C,0x59,0x47,0x4E,0x6B,0xC0,0x5D,0x99,0xB2,0x96,0x4F,0xA0,0x90,0xC3,0xA2,
- 0x23,0x3B,0xA1,0x86,0x51,0x5B,0xE7,0xED,0x1F,0x61,0x29,0x70,0xCE,0xE2,0xD7,0xAF,
- 0xB8,0x1B,0xDD,0x76,0x21,0x70,0x48,0x1C,0xD0,0x06,0x91,0x27,0xD5,0xB0,0x5A,0xA9,
- 0x93,0xB4,0xEA,0x98,0x8D,0x8F,0xDD,0xC1,0x86,0xFF,0xB7,0xDC,0x90,0xA6,0xC0,0x8F,
- 0x4D,0xF4,0x35,0xC9,0x34,0x02,0x84,0x92,0x36,0xC3,0xFA,0xB4,0xD2,0x7C,0x70,0x26,
- 0xC1,0xD4,0xDC,0xB2,0x60,0x26,0x46,0xDE,0xC9,0x75,0x1E,0x76,0x3D,0xBA,0x37,0xBD,
- 0xF8,0xFF,0x94,0x06,0xAD,0x9E,0x53,0x0E,0xE5,0xDB,0x38,0x2F,0x41,0x30,0x01,0xAE,
- 0xB0,0x6A,0x53,0xED,0x90,0x27,0xD8,0x31,0x17,0x97,0x27,0xB0,0x86,0x5A,0x89,0x18,
- 0xDA,0x3E,0xDB,0xEB,0xCF,0x9B,0x14,0xED,0x44,0xCE,0x6C,0xBA,0xCE,0xD4,0xBB,0x1B,
- 0xDB,0x7F,0x14,0x47,0xE6,0xCC,0x25,0x4B,0x33,0x20,0x51,0x51,0x2B,0xD7,0xAF,0x42,
- 0x6F,0xB8,0xF4,0x01,0x37,0x8C,0xD2,0xBF,0x59,0x83,0xCA,0x01,0xC6,0x4B,0x92,0xEC,
- 0xF0,0x32,0xEA,0x15,0xD1,0x72,0x1D,0x03,0xF4,0x82,0xD7,0xCE,0x6E,0x74,0xFE,0xF6,
- 0xD5,0x5E,0x70,0x2F,0x46,0x98,0x0C,0x82,0xB5,0xA8,0x40,0x31,0x90,0x0B,0x1C,0x9E,
- 0x59,0xE7,0xC9,0x7F,0xBE,0xC7,0xE8,0xF3,0x23,0xA9,0x7A,0x7E,0x36,0xCC,0x88,0xBE,
- 0x0F,0x1D,0x45,0xB7,0xFF,0x58,0x5A,0xC5,0x4B,0xD4,0x07,0xB2,0x2B,0x41,0x54,0xAA,
- 0xCC,0x8F,0x6D,0x7E,0xBF,0x48,0xE1,0xD8,0x14,0xCC,0x5E,0xD2,0x0F,0x80,0x37,0xE0,
- 0xA7,0x97,0x15,0xEE,0xF2,0x9B,0xE3,0x28,0x06,0xA1,0xD5,0x8B,0xB7,0xC5,0xDA,0x76,
- 0xF5,0x50,0xAA,0x3D,0x8A,0x1F,0xBF,0xF0,0xEB,0x19,0xCC,0xB1,0xA3,0x13,0xD5,0x5C,
- 0xDA,0x56,0xC9,0xEC,0x2E,0xF2,0x96,0x32,0x38,0x7F,0xE8,0xD7,0x6E,0x3C,0x04,0x68,
- 0x04,0x3E,0x8F,0x66,0x3F,0x48,0x60,0xEE,0x12,0xBF,0x2D,0x5B,0x0B,0x74,0x74,0xD6,
- 0xE6,0x94,0xF9,0x1E,0x6D,0xCC,0x40,0x24,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
-};
-
-/**
- * Modulus of Group 18 (MODP_8192_BIT).
- */
-static u_int8_t group18_modulus[] = {
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC9,0x0F,0xDA,0xA2,0x21,0x68,0xC2,0x34,
- 0xC4,0xC6,0x62,0x8B,0x80,0xDC,0x1C,0xD1,0x29,0x02,0x4E,0x08,0x8A,0x67,0xCC,0x74,
- 0x02,0x0B,0xBE,0xA6,0x3B,0x13,0x9B,0x22,0x51,0x4A,0x08,0x79,0x8E,0x34,0x04,0xDD,
- 0xEF,0x95,0x19,0xB3,0xCD,0x3A,0x43,0x1B,0x30,0x2B,0x0A,0x6D,0xF2,0x5F,0x14,0x37,
- 0x4F,0xE1,0x35,0x6D,0x6D,0x51,0xC2,0x45,0xE4,0x85,0xB5,0x76,0x62,0x5E,0x7E,0xC6,
- 0xF4,0x4C,0x42,0xE9,0xA6,0x37,0xED,0x6B,0x0B,0xFF,0x5C,0xB6,0xF4,0x06,0xB7,0xED,
- 0xEE,0x38,0x6B,0xFB,0x5A,0x89,0x9F,0xA5,0xAE,0x9F,0x24,0x11,0x7C,0x4B,0x1F,0xE6,
- 0x49,0x28,0x66,0x51,0xEC,0xE4,0x5B,0x3D,0xC2,0x00,0x7C,0xB8,0xA1,0x63,0xBF,0x05,
- 0x98,0xDA,0x48,0x36,0x1C,0x55,0xD3,0x9A,0x69,0x16,0x3F,0xA8,0xFD,0x24,0xCF,0x5F,
- 0x83,0x65,0x5D,0x23,0xDC,0xA3,0xAD,0x96,0x1C,0x62,0xF3,0x56,0x20,0x85,0x52,0xBB,
- 0x9E,0xD5,0x29,0x07,0x70,0x96,0x96,0x6D,0x67,0x0C,0x35,0x4E,0x4A,0xBC,0x98,0x04,
- 0xF1,0x74,0x6C,0x08,0xCA,0x18,0x21,0x7C,0x32,0x90,0x5E,0x46,0x2E,0x36,0xCE,0x3B,
- 0xE3,0x9E,0x77,0x2C,0x18,0x0E,0x86,0x03,0x9B,0x27,0x83,0xA2,0xEC,0x07,0xA2,0x8F,
- 0xB5,0xC5,0x5D,0xF0,0x6F,0x4C,0x52,0xC9,0xDE,0x2B,0xCB,0xF6,0x95,0x58,0x17,0x18,
- 0x39,0x95,0x49,0x7C,0xEA,0x95,0x6A,0xE5,0x15,0xD2,0x26,0x18,0x98,0xFA,0x05,0x10,
- 0x15,0x72,0x8E,0x5A,0x8A,0xAA,0xC4,0x2D,0xAD,0x33,0x17,0x0D,0x04,0x50,0x7A,0x33,
- 0xA8,0x55,0x21,0xAB,0xDF,0x1C,0xBA,0x64,0xEC,0xFB,0x85,0x04,0x58,0xDB,0xEF,0x0A,
- 0x8A,0xEA,0x71,0x57,0x5D,0x06,0x0C,0x7D,0xB3,0x97,0x0F,0x85,0xA6,0xE1,0xE4,0xC7,
- 0xAB,0xF5,0xAE,0x8C,0xDB,0x09,0x33,0xD7,0x1E,0x8C,0x94,0xE0,0x4A,0x25,0x61,0x9D,
- 0xCE,0xE3,0xD2,0x26,0x1A,0xD2,0xEE,0x6B,0xF1,0x2F,0xFA,0x06,0xD9,0x8A,0x08,0x64,
- 0xD8,0x76,0x02,0x73,0x3E,0xC8,0x6A,0x64,0x52,0x1F,0x2B,0x18,0x17,0x7B,0x20,0x0C,
- 0xBB,0xE1,0x17,0x57,0x7A,0x61,0x5D,0x6C,0x77,0x09,0x88,0xC0,0xBA,0xD9,0x46,0xE2,
- 0x08,0xE2,0x4F,0xA0,0x74,0xE5,0xAB,0x31,0x43,0xDB,0x5B,0xFC,0xE0,0xFD,0x10,0x8E,
- 0x4B,0x82,0xD1,0x20,0xA9,0x21,0x08,0x01,0x1A,0x72,0x3C,0x12,0xA7,0x87,0xE6,0xD7,
- 0x88,0x71,0x9A,0x10,0xBD,0xBA,0x5B,0x26,0x99,0xC3,0x27,0x18,0x6A,0xF4,0xE2,0x3C,
- 0x1A,0x94,0x68,0x34,0xB6,0x15,0x0B,0xDA,0x25,0x83,0xE9,0xCA,0x2A,0xD4,0x4C,0xE8,
- 0xDB,0xBB,0xC2,0xDB,0x04,0xDE,0x8E,0xF9,0x2E,0x8E,0xFC,0x14,0x1F,0xBE,0xCA,0xA6,
- 0x28,0x7C,0x59,0x47,0x4E,0x6B,0xC0,0x5D,0x99,0xB2,0x96,0x4F,0xA0,0x90,0xC3,0xA2,
- 0x23,0x3B,0xA1,0x86,0x51,0x5B,0xE7,0xED,0x1F,0x61,0x29,0x70,0xCE,0xE2,0xD7,0xAF,
- 0xB8,0x1B,0xDD,0x76,0x21,0x70,0x48,0x1C,0xD0,0x06,0x91,0x27,0xD5,0xB0,0x5A,0xA9,
- 0x93,0xB4,0xEA,0x98,0x8D,0x8F,0xDD,0xC1,0x86,0xFF,0xB7,0xDC,0x90,0xA6,0xC0,0x8F,
- 0x4D,0xF4,0x35,0xC9,0x34,0x02,0x84,0x92,0x36,0xC3,0xFA,0xB4,0xD2,0x7C,0x70,0x26,
- 0xC1,0xD4,0xDC,0xB2,0x60,0x26,0x46,0xDE,0xC9,0x75,0x1E,0x76,0x3D,0xBA,0x37,0xBD,
- 0xF8,0xFF,0x94,0x06,0xAD,0x9E,0x53,0x0E,0xE5,0xDB,0x38,0x2F,0x41,0x30,0x01,0xAE,
- 0xB0,0x6A,0x53,0xED,0x90,0x27,0xD8,0x31,0x17,0x97,0x27,0xB0,0x86,0x5A,0x89,0x18,
- 0xDA,0x3E,0xDB,0xEB,0xCF,0x9B,0x14,0xED,0x44,0xCE,0x6C,0xBA,0xCE,0xD4,0xBB,0x1B,
- 0xDB,0x7F,0x14,0x47,0xE6,0xCC,0x25,0x4B,0x33,0x20,0x51,0x51,0x2B,0xD7,0xAF,0x42,
- 0x6F,0xB8,0xF4,0x01,0x37,0x8C,0xD2,0xBF,0x59,0x83,0xCA,0x01,0xC6,0x4B,0x92,0xEC,
- 0xF0,0x32,0xEA,0x15,0xD1,0x72,0x1D,0x03,0xF4,0x82,0xD7,0xCE,0x6E,0x74,0xFE,0xF6,
- 0xD5,0x5E,0x70,0x2F,0x46,0x98,0x0C,0x82,0xB5,0xA8,0x40,0x31,0x90,0x0B,0x1C,0x9E,
- 0x59,0xE7,0xC9,0x7F,0xBE,0xC7,0xE8,0xF3,0x23,0xA9,0x7A,0x7E,0x36,0xCC,0x88,0xBE,
- 0x0F,0x1D,0x45,0xB7,0xFF,0x58,0x5A,0xC5,0x4B,0xD4,0x07,0xB2,0x2B,0x41,0x54,0xAA,
- 0xCC,0x8F,0x6D,0x7E,0xBF,0x48,0xE1,0xD8,0x14,0xCC,0x5E,0xD2,0x0F,0x80,0x37,0xE0,
- 0xA7,0x97,0x15,0xEE,0xF2,0x9B,0xE3,0x28,0x06,0xA1,0xD5,0x8B,0xB7,0xC5,0xDA,0x76,
- 0xF5,0x50,0xAA,0x3D,0x8A,0x1F,0xBF,0xF0,0xEB,0x19,0xCC,0xB1,0xA3,0x13,0xD5,0x5C,
- 0xDA,0x56,0xC9,0xEC,0x2E,0xF2,0x96,0x32,0x38,0x7F,0xE8,0xD7,0x6E,0x3C,0x04,0x68,
- 0x04,0x3E,0x8F,0x66,0x3F,0x48,0x60,0xEE,0x12,0xBF,0x2D,0x5B,0x0B,0x74,0x74,0xD6,
- 0xE6,0x94,0xF9,0x1E,0x6D,0xBE,0x11,0x59,0x74,0xA3,0x92,0x6F,0x12,0xFE,0xE5,0xE4,
- 0x38,0x77,0x7C,0xB6,0xA9,0x32,0xDF,0x8C,0xD8,0xBE,0xC4,0xD0,0x73,0xB9,0x31,0xBA,
- 0x3B,0xC8,0x32,0xB6,0x8D,0x9D,0xD3,0x00,0x74,0x1F,0xA7,0xBF,0x8A,0xFC,0x47,0xED,
- 0x25,0x76,0xF6,0x93,0x6B,0xA4,0x24,0x66,0x3A,0xAB,0x63,0x9C,0x5A,0xE4,0xF5,0x68,
- 0x34,0x23,0xB4,0x74,0x2B,0xF1,0xC9,0x78,0x23,0x8F,0x16,0xCB,0xE3,0x9D,0x65,0x2D,
- 0xE3,0xFD,0xB8,0xBE,0xFC,0x84,0x8A,0xD9,0x22,0x22,0x2E,0x04,0xA4,0x03,0x7C,0x07,
- 0x13,0xEB,0x57,0xA8,0x1A,0x23,0xF0,0xC7,0x34,0x73,0xFC,0x64,0x6C,0xEA,0x30,0x6B,
- 0x4B,0xCB,0xC8,0x86,0x2F,0x83,0x85,0xDD,0xFA,0x9D,0x4B,0x7F,0xA2,0xC0,0x87,0xE8,
- 0x79,0x68,0x33,0x03,0xED,0x5B,0xDD,0x3A,0x06,0x2B,0x3C,0xF5,0xB3,0xA2,0x78,0xA6,
- 0x6D,0x2A,0x13,0xF8,0x3F,0x44,0xF8,0x2D,0xDF,0x31,0x0E,0xE0,0x74,0xAB,0x6A,0x36,
- 0x45,0x97,0xE8,0x99,0xA0,0x25,0x5D,0xC1,0x64,0xF3,0x1C,0xC5,0x08,0x46,0x85,0x1D,
- 0xF9,0xAB,0x48,0x19,0x5D,0xED,0x7E,0xA1,0xB1,0xD5,0x10,0xBD,0x7E,0xE7,0x4D,0x73,
- 0xFA,0xF3,0x6B,0xC3,0x1E,0xCF,0xA2,0x68,0x35,0x90,0x46,0xF4,0xEB,0x87,0x9F,0x92,
- 0x40,0x09,0x43,0x8B,0x48,0x1C,0x6C,0xD7,0x88,0x9A,0x00,0x2E,0xD5,0xEE,0x38,0x2B,
- 0xC9,0x19,0x0D,0xA6,0xFC,0x02,0x6E,0x47,0x95,0x58,0xE4,0x47,0x56,0x77,0xE9,0xAA,
- 0x9E,0x30,0x50,0xE2,0x76,0x56,0x94,0xDF,0xC8,0x1F,0x56,0xE8,0x80,0xB9,0x6E,0x71,
- 0x60,0xC9,0x80,0xDD,0x98,0xED,0xD3,0xDF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
-};
-
-typedef struct modulus_info_entry_t modulus_info_entry_t;
-
-/**
- * Entry of the modulus list.
- */
-struct modulus_info_entry_t {
- /**
- * Group number as it is defined in file transform_substructure.h.
- */
- diffie_hellman_group_t group;
-
- /**
- * Pointer to first byte of modulus (network order).
- */
- u_int8_t *modulus;
-
- /*
- * Length of modulus in bytes.
- */
- size_t modulus_length;
-
- /*
- * Generator value.
- */
- u_int16_t generator;
-};
-
-
-/**
- * All supported modulus values.
- */
-static modulus_info_entry_t modulus_info_entries[] = {
- {MODP_768_BIT,group1_modulus,sizeof(group1_modulus),2},
- {MODP_1024_BIT,group2_modulus,sizeof(group2_modulus),2},
- {MODP_1536_BIT,group5_modulus,sizeof(group5_modulus),2},
- {MODP_2048_BIT,group14_modulus,sizeof(group14_modulus),2},
- {MODP_3072_BIT,group15_modulus,sizeof(group15_modulus),2},
- {MODP_4096_BIT,group16_modulus,sizeof(group16_modulus),2},
- {MODP_6144_BIT,group17_modulus,sizeof(group17_modulus),2},
- {MODP_8192_BIT,group18_modulus,sizeof(group18_modulus),2},
-};
-
-typedef struct private_diffie_hellman_t private_diffie_hellman_t;
-
-/**
- * Private data of an diffie_hellman_t object.
- *
- */
-struct private_diffie_hellman_t {
- /**
- * Public diffie_hellman_t interface.
- */
- diffie_hellman_t public;
-
- /**
- * Diffie Hellman group number.
- */
- u_int16_t dh_group_number;
-
- /**
- * Modulus.
- */
- mpz_t modulus;
-
- /**
- * Modulus length.
- */
- size_t modulus_length;
-
- /*
- * Generator value.
- */
- u_int16_t generator;
-
- /**
- * My private value .
- */
- mpz_t my_private_value;
-
- /**
- * My public value.
- */
- mpz_t my_public_value;
-
- /**
- * Other public value.
- */
- mpz_t other_public_value;
-
- /**
- * Shared secret.
- */
- mpz_t shared_secret;
-
- /**
- * True if shared secret is computed and stored in my_public_value.
- */
- bool shared_secret_is_computed;
-
- /**
- * Sets the modulus for a specific diffie hellman group.
- *
- * @param this calling object
- * @return
- * SUCCESS if modulus could be found
- * NOT_FOUND if modulus not supported
- */
- status_t (*set_modulus) (private_diffie_hellman_t *this);
-
- /**
- * Makes sure my public value is computed.
- *
- * @param this calling object
- */
- void (*compute_public_value) (private_diffie_hellman_t *this);
-
- /**
- * Computes shared secret (other public value must be available).
- *
- * @param this calling object
- */
- void (*compute_shared_secret) (private_diffie_hellman_t *this);
-};
-
-/**
- * Implementation of private_diffie_hellman_t.set_modulus.
- */
-static status_t set_modulus(private_diffie_hellman_t *this)
-{
- int i;
- status_t status = NOT_FOUND;
-
- for (i = 0; i < (sizeof(modulus_info_entries) / sizeof(modulus_info_entry_t)); i++)
- {
- if (modulus_info_entries[i].group == this->dh_group_number)
- {
- chunk_t modulus_chunk;
- modulus_chunk.ptr = modulus_info_entries[i].modulus;
- modulus_chunk.len = modulus_info_entries[i].modulus_length;
- mpz_import(this->modulus, modulus_chunk.len, 1, 1, 1, 0, modulus_chunk.ptr);
- this->modulus_length = modulus_chunk.len;
- this->generator = modulus_info_entries[i].generator;
- status = SUCCESS;
- break;
- }
- }
- return status;
-}
-
-/**
- * Implementation of diffie_hellman_t.set_other_public_value.
- */
-static void set_other_public_value(private_diffie_hellman_t *this,chunk_t public_value)
-{
- mpz_import(this->other_public_value, public_value.len, 1, 1, 1, 0, public_value.ptr);
- this->compute_shared_secret(this);
-}
-
-/**
- * Implementation of diffie_hellman_t.get_other_public_value.
- */
-static status_t get_other_public_value(private_diffie_hellman_t *this,chunk_t *public_value)
-{
- if (!this->shared_secret_is_computed)
- {
- return FAILED;
- }
- public_value->len = this->modulus_length;
- public_value->ptr = mpz_export(NULL, NULL, 1, public_value->len, 1, 0, this->other_public_value);
- return SUCCESS;
-}
-
-/**
- * Implementation of private_diffie_hellman_t.compute_shared_secret.
- */
-static void compute_shared_secret (private_diffie_hellman_t *this)
-{
- /* initialize my public value */
- mpz_init(this->shared_secret);
- /* calculate my public value */
- mpz_powm(this->shared_secret,this->other_public_value,this->my_private_value,this->modulus);
-
- this->shared_secret_is_computed = TRUE;
-}
-
-/**
- * Implementation of private_diffie_hellman_t.compute_public_value.
- */
-static void compute_public_value (private_diffie_hellman_t *this)
-{
- mpz_t generator;
- /* initialize generator and set it*/
- mpz_init_set_ui (generator,this->generator);
- /* initialize my public value */
- mpz_init(this->my_public_value);
- /* calculate my public value */
- mpz_powm(this->my_public_value,generator,this->my_private_value,this->modulus);
- /* generator not used anymore */
- mpz_clear(generator);
-}
-
-/**
- * Implementation of diffie_hellman_t.get_my_public_value.
- */
-static void get_my_public_value(private_diffie_hellman_t *this,chunk_t *public_value)
-{
- public_value->len = this->modulus_length;
- public_value->ptr = mpz_export(NULL, NULL, 1, public_value->len, 1, 0, this->my_public_value);
-}
-
-/**
- * Implementation of diffie_hellman_t.get_shared_secret.
- */
-static status_t get_shared_secret(private_diffie_hellman_t *this,chunk_t *secret)
-{
- if (!this->shared_secret_is_computed)
- {
- return FAILED;
- }
- secret->len = this->modulus_length;
- secret->ptr = mpz_export(NULL, NULL, 1, secret->len, 1, 0, this->shared_secret);
- return SUCCESS;
-}
-
-/**
- * Implementation of diffie_hellman_t.get_dh_group.
- */
-static diffie_hellman_group_t get_dh_group(private_diffie_hellman_t *this)
-{
- return this->dh_group_number;
-}
-
-/**
- * Implementation of diffie_hellman_t.destroy.
- */
-static void destroy(private_diffie_hellman_t *this)
-{
- mpz_clear(this->modulus);
- mpz_clear(this->my_private_value);
- mpz_clear(this->my_public_value);
- mpz_clear(this->other_public_value);
-
- if (this->shared_secret_is_computed)
- {
- /* other public value gets initialized together with shared secret */
- mpz_clear(this->shared_secret);
- }
- allocator_free(this);
-}
-
-/*
- * Described in header.
- */
-diffie_hellman_t *diffie_hellman_create(diffie_hellman_group_t dh_group_number)
-{
- private_diffie_hellman_t *this = allocator_alloc_thing(private_diffie_hellman_t);
- randomizer_t *randomizer;
- chunk_t random_bytes;
-
- /* public functions */
- this->public.get_shared_secret = (status_t (*)(diffie_hellman_t *, chunk_t *)) get_shared_secret;
- this->public.set_other_public_value = (void (*)(diffie_hellman_t *, chunk_t )) set_other_public_value;
- this->public.get_other_public_value = (status_t (*)(diffie_hellman_t *, chunk_t *)) get_other_public_value;
- this->public.get_my_public_value = (void (*)(diffie_hellman_t *, chunk_t *)) get_my_public_value;
- this->public.get_dh_group = (diffie_hellman_group_t (*)(diffie_hellman_t *)) get_dh_group;
- this->public.destroy = (void (*)(diffie_hellman_t *)) destroy;
-
- /* private functions */
- this->set_modulus = set_modulus;
- this->compute_public_value = compute_public_value;
- this->compute_shared_secret = compute_shared_secret;
-
- /* private variables */
- this->dh_group_number = dh_group_number;
- mpz_init(this->modulus);
- mpz_init(this->other_public_value);
- mpz_init(this->my_private_value);
-
- /* set this->modulus */
- if (this->set_modulus(this) != SUCCESS)
- {
- allocator_free(this);
- return NULL;
- }
- randomizer = randomizer_create();
- if (randomizer == NULL)
- {
- allocator_free(this);
- return NULL;
- }
- randomizer->allocate_pseudo_random_bytes(randomizer, this->modulus_length, &random_bytes);
-
- mpz_import(this->my_private_value, random_bytes.len, 1, 1, 1, 0, random_bytes.ptr);
- allocator_free_chunk(&random_bytes);
-
- randomizer->destroy(randomizer);
-
- this->compute_public_value(this);
-
- this->shared_secret_is_computed = FALSE;
-
- return &(this->public);
-}
diff --git a/Source/charon/transforms/diffie_hellman.h b/Source/charon/transforms/diffie_hellman.h
deleted file mode 100644
index 48a165557..000000000
--- a/Source/charon/transforms/diffie_hellman.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/**
- * @file diffie_hellman.h
- *
- * @brief Interface of diffie_hellman_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef DIFFIE_HELLMAN_H_
-#define DIFFIE_HELLMAN_H_
-
-#include <types.h>
-
-
-typedef enum diffie_hellman_group_t diffie_hellman_group_t;
-
-/**
- * @brief Diffie-Hellman group.
- *
- * The modulus (or group) to use for a Diffie-Hellman calculation.
- *
- * See IKEv2 RFC 3.3.2 and RFC 3526.
- *
- * @ingroup transforms
- */
-enum diffie_hellman_group_t {
- MODP_UNDEFINED = 1024,
- MODP_768_BIT = 1,
- MODP_1024_BIT = 2,
- MODP_1536_BIT = 5,
- MODP_2048_BIT = 14,
- MODP_3072_BIT = 15,
- MODP_4096_BIT = 16,
- MODP_6144_BIT = 17,
- MODP_8192_BIT = 18
-};
-
-/**
- * String mappings for diffie_hellman_group_t.
- */
-extern mapping_t diffie_hellman_group_m[];
-
-
-typedef struct diffie_hellman_t diffie_hellman_t;
-
-/**
- * @brief Implementation of the widely used Diffie-Hellman algorithm.
- *
- * @b Constructors:
- * - diffie_hellman_create()
- *
- * @ingroup transforms
- */
-struct diffie_hellman_t {
-
- /**
- * @brief Returns the shared secret of this diffie hellman exchange.
- *
- * @warning Space for returned secret is allocated and must be
- * freed by the caller.
- *
- * @param this calling diffie_hellman_t object
- * @param[out] secret shared secret will be written into this chunk
- * @return
- * - SUCCESS
- * - FAILED if not both DH values are set
- */
- status_t (*get_shared_secret) (diffie_hellman_t *this, chunk_t *secret);
-
- /**
- * @brief Sets the public value of partner.
- *
- * chunk gets cloned and can be destroyed afterwards.
- *
- * @param this calling diffie_hellman_t object
- * @param public_value public value of partner
- */
- void (*set_other_public_value) (diffie_hellman_t *this, chunk_t public_value);
-
- /**
- * @brief Gets the public value of partner.
- *
- * @warning Space for returned chunk is allocated and must be
- * freed by the caller.
- *
- * @param this calling diffie_hellman_t object
- * @param[out] public_value public value of partner is stored at this location
- * @return
- * - SUCCESS
- * - FAILED if other public value not set
- */
- status_t (*get_other_public_value) (diffie_hellman_t *this, chunk_t *public_value);
-
- /**
- * @brief Gets the public value of caller
- *
- * @warning Space for returned chunk is allocated and must be
- * freed by the caller.
- *
- * @param this calling diffie_hellman_t object
- * @param[out] public_value public value of caller is stored at this location
- */
- void (*get_my_public_value) (diffie_hellman_t *this, chunk_t *public_value);
-
- /**
- * @brief Get the DH group used.
- *
- * @param this calling diffie_hellman_t object
- * @return DH group set in construction
- */
- diffie_hellman_group_t (*get_dh_group) (diffie_hellman_t *this);
-
- /**
- * @brief Destroys an diffie_hellman_t object.
- *
- * @param this diffie_hellman_t object to destroy
- */
- void (*destroy) (diffie_hellman_t *this);
-};
-
-/**
- * @brief Creates a new diffie_hellman_t object.
- *
- * The first diffie hellman public value gets automatically created.
- *
- * @param dh_group_number Diffie Hellman group number to use
- * @return
- * - diffie_hellman_t object
- * - NULL if dh group not supported
- *
- * @ingroup transforms
- */
-diffie_hellman_t *diffie_hellman_create(diffie_hellman_group_t dh_group_number);
-
-#endif /*DIFFIE_HELLMAN_H_*/
diff --git a/Source/charon/transforms/hashers/Makefile.hashers b/Source/charon/transforms/hashers/Makefile.hashers
deleted file mode 100644
index fc26f8ade..000000000
--- a/Source/charon/transforms/hashers/Makefile.hashers
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright (C) 2005 Jan Hutter, Martin Willi
-# Hochschule fuer Technik Rapperswil
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the
-# Free Software Foundation; either version 2 of the License, or (at your
-# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# for more details.
-#
-
-HASHERS_DIR= $(TRANSFORMS_DIR)hashers/
-
-OBJS+= $(BUILD_DIR)hasher.o
-$(BUILD_DIR)hasher.o : $(HASHERS_DIR)hasher.c $(HASHERS_DIR)hasher.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-OBJS+= $(BUILD_DIR)sha1_hasher.o
-$(BUILD_DIR)sha1_hasher.o : $(HASHERS_DIR)sha1_hasher.c $(HASHERS_DIR)sha1_hasher.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-OBJS+= $(BUILD_DIR)md5_hasher.o
-$(BUILD_DIR)md5_hasher.o : $(HASHERS_DIR)md5_hasher.c $(HASHERS_DIR)md5_hasher.h
- $(CC) $(CFLAGS) -c -o $@ $<
diff --git a/Source/charon/transforms/hashers/hasher.c b/Source/charon/transforms/hashers/hasher.c
deleted file mode 100644
index 71811c16a..000000000
--- a/Source/charon/transforms/hashers/hasher.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * @file hasher.c
- *
- * @brief Generic constructor for hasher_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-
-#include "hasher.h"
-
-#include <transforms/hashers/sha1_hasher.h>
-#include <transforms/hashers/md5_hasher.h>
-
-/**
- * String mappings for hash_algorithm_t.
- */
-mapping_t hash_algorithm_m[] = {
- {HASH_MD2,"HASH_MD2"},
- {HASH_MD5,"HASH_MD5"},
- {HASH_SHA1,"HASH_SHA1"},
- {HASH_SHA256,"HASH_SHA256"},
- {HASH_SHA384,"HASH_SHA384"},
- {HASH_SHA512,"HASH_SHA512"},
- {MAPPING_END, NULL}
-};
-
-/*
- * Described in header.
- */
-hasher_t *hasher_create(hash_algorithm_t hash_algorithm)
-{
- switch (hash_algorithm)
- {
- case HASH_SHA1:
- {
- return (hasher_t*)sha1_hasher_create();
- }
- case HASH_MD5:
- {
- return (hasher_t*)md5_hasher_create();
- }
- default:
- return NULL;
- }
-}
diff --git a/Source/charon/transforms/hashers/hasher.h b/Source/charon/transforms/hashers/hasher.h
deleted file mode 100644
index a4d6f14d7..000000000
--- a/Source/charon/transforms/hashers/hasher.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/**
- * @file hasher.h
- *
- * @brief Interface hasher_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef HASHER_H_
-#define HASHER_H_
-
-
-#include <types.h>
-
-
-typedef enum hash_algorithm_t hash_algorithm_t;
-
-/**
- * @brief Algorithms to use for hashing.
- *
- * Currently only the following algorithms are implemented and therefore supported:
- * - HASH_MD5
- * - HASH_SHA1
- *
- * @ingroup hashers
- *
- */
-enum hash_algorithm_t {
- HASH_MD2,
- /**
- * Implemented in class md5_hasher_t.
- */
- HASH_MD5,
- /**
- * Implemented in class sha1_hasher_t.
- */
- HASH_SHA1,
- HASH_SHA256,
- HASH_SHA384,
- HASH_SHA512,
-};
-
-/**
- * String mappings for hash_algorithm_t.
- */
-extern mapping_t hash_algorithm_m[];
-
-
-typedef struct hasher_t hasher_t;
-
-/**
- * @brief Generic interface for all hash functions.
- *
- * @b Constructors:
- * - hasher_create()
- * - md5_hasher_create()
- * - sha1_hasher_create()
- *
- * @see
- * - md5_hasher_t
- * - sha1_hasher_t
- *
- * @todo Implement more hash algorithms
- *
- * @ingroup hashers
- */
-struct hasher_t {
- /**
- * @brief Hash data and write it in the buffer.
- *
- * If the parameter hash is NULL, no result is written back
- * an more data can be appended to already hashed data.
- * If not, the result is written back and the hasher is reseted.
- *
- * @warning: the hash output parameter must hold at least
- * hash_t.get_block_size bytes.
- *
- * @param this calling object
- * @param data data to hash
- * @param[out] hash pointer where the hash will be written
- */
- void (*get_hash) (hasher_t *this, chunk_t data, u_int8_t *hash);
-
- /**
- * @brief Hash data and allocate space for the hash.
- *
- * If the parameter hash is NULL, no result is written back
- * an more data can be appended to already hashed data.
- * If not, the result is written back and the hasher is reseted.
- *
- * @param this calling object
- * @param data chunk with data to hash
- * @param[out] hash chunk which will hold allocated hash
- */
- void (*allocate_hash) (hasher_t *this, chunk_t data, chunk_t *hash);
-
- /**
- * @brief Get the block size of this hashing function.
- *
- * @param this calling object
- * @return block size in bytes
- */
- size_t (*get_block_size) (hasher_t *this);
-
- /**
- * @brief Resets the hashers state, which allows
- * computation of a completely new hash.
- *
- * @param this calling object
- */
- void (*reset) (hasher_t *this);
-
- /**
- * @brief Destroys a hasher object.
- *
- * @param this calling object
- */
- void (*destroy) (hasher_t *this);
-};
-
-/**
- * @brief Generic interface to create a hasher_t.
- *
- * @param hash_algorithm Algorithm to use for hashing
- * @return
- * - hasher_t object
- * - NULL if algorithm not supported
- *
- * @ingroup hashers
- */
-hasher_t *hasher_create(hash_algorithm_t hash_algorithm);
-
-#endif /*HASHER_H_*/
diff --git a/Source/charon/transforms/hashers/md5_hasher.c b/Source/charon/transforms/hashers/md5_hasher.c
deleted file mode 100644
index cd883d92c..000000000
--- a/Source/charon/transforms/hashers/md5_hasher.c
+++ /dev/null
@@ -1,393 +0,0 @@
-/**
- * @file md5_hasher.c
- *
- * @brief Implementation of md5_hasher_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- * Copyright (C) 1991-1992, RSA Data Security, Inc. Created 1991.
- * All rights reserved.
- *
- * Derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm.
- * Ported to fulfill hasher_t interface.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "md5_hasher.h"
-
-#include <definitions.h>
-#include <utils/allocator.h>
-
-#define BLOCK_SIZE_MD5 16
-
-
-/* Constants for MD5Transform routine. */
-#define S11 7
-#define S12 12
-#define S13 17
-#define S14 22
-#define S21 5
-#define S22 9
-#define S23 14
-#define S24 20
-#define S31 4
-#define S32 11
-#define S33 16
-#define S34 23
-#define S41 6
-#define S42 10
-#define S43 15
-#define S44 21
-
-static u_int8_t PADDING[64] = {
- 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-};
-
-/*
- * ugly macro stuff
- */
-/* F, G, H and I are basic MD5 functions.
- */
-#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
-#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
-#define H(x, y, z) ((x) ^ (y) ^ (z))
-#define I(x, y, z) ((y) ^ ((x) | (~z)))
-
-/* ROTATE_LEFT rotates x left n bits.
- */
-#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
-
-/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
-Rotation is separate from addition to prevent recomputation.
- */
-#define FF(a, b, c, d, x, s, ac) { \
- (a) += F ((b), (c), (d)) + (x) + (u_int32_t)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-#define GG(a, b, c, d, x, s, ac) { \
- (a) += G ((b), (c), (d)) + (x) + (u_int32_t)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-#define HH(a, b, c, d, x, s, ac) { \
- (a) += H ((b), (c), (d)) + (x) + (u_int32_t)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-#define II(a, b, c, d, x, s, ac) { \
- (a) += I ((b), (c), (d)) + (x) + (u_int32_t)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-
-
-
-typedef struct private_md5_hasher_t private_md5_hasher_t;
-
-/**
- * Private data structure with hasing context.
- */
-struct private_md5_hasher_t {
- /**
- * Public interface for this hasher.
- */
- md5_hasher_t public;
-
- /*
- * State of the hasher.
- */
- u_int32_t state[5];
- u_int32_t count[2];
- u_int8_t buffer[64];
-};
-
-
-#if BYTE_ORDER != LITTLE_ENDIAN
-
-/* Encodes input (u_int32_t) into output (u_int8_t). Assumes len is
- * a multiple of 4.
- */
-static void Encode (u_int8_t *output, u_int32_t *input, size_t *len)
-{
- size_t i, j;
-
- for (i = 0, j = 0; j < len; i++, j += 4)
- {
- output[j] = (u_int8_t)(input[i] & 0xff);
- output[j+1] = (u_int8_t)((input[i] >> 8) & 0xff);
- output[j+2] = (u_int8_t)((input[i] >> 16) & 0xff);
- output[j+3] = (u_int8_t)((input[i] >> 24) & 0xff);
- }
-}
-
-/* Decodes input (u_int8_t) into output (u_int32_t). Assumes len is
- * a multiple of 4.
- */
-static void Decode(u_int32_t *output, u_int8_t *input, size_t len)
-{
- size_t i, j;
-
- for (i = 0, j = 0; j < len; i++, j += 4)
- {
- output[i] = ((u_int32_t)input[j]) | (((u_int32_t)input[j+1]) << 8) |
- (((u_int32_t)input[j+2]) << 16) | (((u_int32_t)input[j+3]) << 24);
- }
-}
-
-#elif BYTE_ORDER == LITTLE_ENDIAN
- #define Encode memcpy
- #define Decode memcpy
-#endif
-
-/* MD5 basic transformation. Transforms state based on block.
- */
-static void MD5Transform(u_int32_t state[4], u_int8_t block[64])
-{
- u_int32_t a = state[0], b = state[1], c = state[2], d = state[3], x[16];
-
- Decode(x, block, 64);
-
- /* Round 1 */
- FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
- FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
- FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
- FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
- FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
- FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
- FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
- FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
- FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
- FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
- FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
- FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
- FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
- FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
- FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
- FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
-
- /* Round 2 */
- GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
- GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
- GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
- GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
- GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
- GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */
- GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
- GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
- GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
- GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
- GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
- GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
- GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
- GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
- GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
- GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
-
- /* Round 3 */
- HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
- HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
- HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
- HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
- HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
- HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
- HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
- HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
- HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
- HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
- HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
- HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
- HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
- HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
- HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
- HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
-
- /* Round 4 */
- II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
- II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
- II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
- II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
- II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
- II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
- II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
- II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
- II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
- II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
- II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
- II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
- II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
- II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
- II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
- II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
-
- state[0] += a;
- state[1] += b;
- state[2] += c;
- state[3] += d;
-}
-
-/* MD5 block update operation. Continues an MD5 message-digest
- * operation, processing another message block, and updating the
- * context.
- */
-static void MD5Update(private_md5_hasher_t *this, u_int8_t *input, size_t inputLen)
-{
- u_int32_t i;
- size_t index, partLen;
-
- /* Compute number of bytes mod 64 */
- index = (u_int8_t)((this->count[0] >> 3) & 0x3F);
-
- /* Update number of bits */
- if ((this->count[0] += (inputLen << 3)) < (inputLen << 3))
- {
- this->count[1]++;
- }
- this->count[1] += (inputLen >> 29);
-
- partLen = 64 - index;
-
- /* Transform as many times as possible. */
- if (inputLen >= partLen)
- {
- memcpy(&this->buffer[index], input, partLen);
- MD5Transform (this->state, this->buffer);
-
- for (i = partLen; i + 63 < inputLen; i += 64)
- {
- MD5Transform (this->state, &input[i]);
- }
- index = 0;
- }
- else
- {
- i = 0;
- }
-
- /* Buffer remaining input */
- memcpy(&this->buffer[index], &input[i], inputLen-i);
-}
-
-/* MD5 finalization. Ends an MD5 message-digest operation, writing the
- * the message digest and zeroizing the context.
- */
-static void MD5Final (private_md5_hasher_t *this, u_int8_t digest[16])
-{
- u_int8_t bits[8];
- size_t index, padLen;
-
- /* Save number of bits */
- Encode (bits, this->count, 8);
-
- /* Pad out to 56 mod 64. */
- index = (size_t)((this->count[0] >> 3) & 0x3f);
- padLen = (index < 56) ? (56 - index) : (120 - index);
- MD5Update (this, PADDING, padLen);
-
- /* Append length (before padding) */
- MD5Update (this, bits, 8);
-
- if (digest != NULL) /* Bill Simpson's padding */
- {
- /* store state in digest */
- Encode (digest, this->state, 16);
- }
-}
-
-
-
-/**
- * Implementation of hasher_t.get_hash.
- */
-static void get_hash(private_md5_hasher_t *this, chunk_t chunk, u_int8_t *buffer)
-{
- MD5Update(this, chunk.ptr, chunk.len);
- if (buffer != NULL)
- {
- MD5Final(this, buffer);
- this->public.hasher_interface.reset(&(this->public.hasher_interface));
- }
-}
-
-
-/**
- * Implementation of hasher_t.allocate_hash.
- */
-static void allocate_hash(private_md5_hasher_t *this, chunk_t chunk, chunk_t *hash)
-{
- chunk_t allocated_hash;
-
- MD5Update(this, chunk.ptr, chunk.len);
- if (hash != NULL)
- {
- allocated_hash.ptr = allocator_alloc(BLOCK_SIZE_MD5);
- allocated_hash.len = BLOCK_SIZE_MD5;
-
- MD5Final(this, allocated_hash.ptr);
- this->public.hasher_interface.reset(&(this->public.hasher_interface));
-
- *hash = allocated_hash;
- }
-}
-
-/**
- * Implementation of hasher_t.get_block_size.
- */
-static size_t get_block_size(private_md5_hasher_t *this)
-{
- return BLOCK_SIZE_MD5;
-}
-
-/**
- * Implementation of hasher_t.reset.
- */
-static void reset(private_md5_hasher_t *this)
-{
- this->state[0] = 0x67452301;
- this->state[1] = 0xefcdab89;
- this->state[2] = 0x98badcfe;
- this->state[3] = 0x10325476;
- this->count[0] = 0;
- this->count[1] = 0;
-}
-
-/**
- * Implementation of hasher_t.destroy.
- */
-static void destroy(private_md5_hasher_t *this)
-{
- allocator_free(this);
-}
-
-/*
- * Described in header.
- */
-md5_hasher_t *md5_hasher_create()
-{
- private_md5_hasher_t *this = allocator_alloc_thing(private_md5_hasher_t);
-
- this->public.hasher_interface.get_hash = (void (*) (hasher_t*, chunk_t, u_int8_t*))get_hash;
- this->public.hasher_interface.allocate_hash = (void (*) (hasher_t*, chunk_t, chunk_t*))allocate_hash;
- this->public.hasher_interface.get_block_size = (size_t (*) (hasher_t*))get_block_size;
- this->public.hasher_interface.reset = (void (*) (hasher_t*))reset;
- this->public.hasher_interface.destroy = (void (*) (hasher_t*))destroy;
-
- /* initialize */
- this->public.hasher_interface.reset(&(this->public.hasher_interface));
-
- return &(this->public);
-}
diff --git a/Source/charon/transforms/hashers/md5_hasher.h b/Source/charon/transforms/hashers/md5_hasher.h
deleted file mode 100644
index b32acc062..000000000
--- a/Source/charon/transforms/hashers/md5_hasher.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * @file md5_hasher.h
- *
- * @brief Interface for md5_hasher_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef MD5_HASHER_H_
-#define MD5_HASHER_H_
-
-#include <transforms/hashers/hasher.h>
-
-
-typedef struct md5_hasher_t md5_hasher_t;
-
-/**
- * @brief Implementation of hasher_t interface using the
- * MD5 algorithm.
- *
- * @b Constructors:
- * - hasher_create() using HASH_MD5 as algorithm
- * - md5_hasher_create()
- *
- * @see hasher_t
- *
- * @ingroup hashers
- */
-struct md5_hasher_t {
-
- /**
- * Generic hasher_t interface for this hasher.
- */
- hasher_t hasher_interface;
-};
-
-/**
- * @brief Creates a new md5_hasher_t.
- *
- * @return md5_hasher_t object
- *
- * @ingroup hashers
- */
-md5_hasher_t *md5_hasher_create();
-
-#endif /*MD5_HASHER_H_*/
diff --git a/Source/charon/transforms/hashers/sha1_hasher.c b/Source/charon/transforms/hashers/sha1_hasher.c
deleted file mode 100644
index 2fa659f74..000000000
--- a/Source/charon/transforms/hashers/sha1_hasher.c
+++ /dev/null
@@ -1,268 +0,0 @@
-/**
- * @file sha1_hasher.c
- *
- * @brief Implementation of hasher_sha_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * Ported from Steve Reid's <steve@edmweb.com> implementation
- * "SHA1 in C" found in strongSwan.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "sha1_hasher.h"
-
-#include <definitions.h>
-#include <utils/allocator.h>
-
-#define BLOCK_SIZE_SHA1 20
-
-/*
- * ugly macro stuff
- */
-#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
-
-#if BYTE_ORDER == LITTLE_ENDIAN
- #define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) |(rol(block->l[i],8)&0x00FF00FF))
-#elif BYTE_ORDER == BIG_ENDIAN
- #define blk0(i) block->l[i]
-#else
- #error "Endianness not defined!"
-#endif
-#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] ^block->l[(i+2)&15]^block->l[i&15],1))
-
-/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
-#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
-#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
-#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
-#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
-#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
-
-
-typedef struct private_sha1_hasher_t private_sha1_hasher_t;
-
-/**
- * Private data structure with hasing context.
- */
-struct private_sha1_hasher_t {
- /**
- * Public interface for this hasher.
- */
- sha1_hasher_t public;
-
- /*
- * State of the hasher.
- */
- u_int32_t state[5];
- u_int32_t count[2];
- u_int8_t buffer[64];
-};
-
-/*
- * Hash a single 512-bit block. This is the core of the algorithm. *
- */
-static void SHA1Transform(u_int32_t state[5], const unsigned char buffer[64])
-{
- u_int32_t a, b, c, d, e;
- typedef union {
- u_int8_t c[64];
- u_int32_t l[16];
- } CHAR64LONG16;
- CHAR64LONG16 block[1]; /* use array to appear as a pointer */
- memcpy(block, buffer, 64);
-
- /* Copy context->state[] to working vars */
- a = state[0];
- b = state[1];
- c = state[2];
- d = state[3];
- e = state[4];
- /* 4 rounds of 20 operations each. Loop unrolled. */
- R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
- R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
- R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
- R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
- R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
- R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
- R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
- R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
- R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
- R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
- R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
- R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
- R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
- R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
- R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
- R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
- R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
- R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
- R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
- R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
- /* Add the working vars back into context.state[] */
- state[0] += a;
- state[1] += b;
- state[2] += c;
- state[3] += d;
- state[4] += e;
- /* Wipe variables */
- a = b = c = d = e = 0;
- memset(block, '\0', sizeof(block));
-}
-
-/*
- * Run your data through this.
- */
-static void SHA1Update(private_sha1_hasher_t* this, u_int8_t *data, u_int32_t len)
-{
- u_int32_t i;
- u_int32_t j;
-
- j = this->count[0];
- if ((this->count[0] += len << 3) < j)
- {
- this->count[1]++;
- }
- this->count[1] += (len>>29);
- j = (j >> 3) & 63;
- if ((j + len) > 63)
- {
- memcpy(&this->buffer[j], data, (i = 64-j));
- SHA1Transform(this->state, this->buffer);
- for ( ; i + 63 < len; i += 64)
- {
- SHA1Transform(this->state, &data[i]);
- }
- j = 0;
- }
- else
- {
- i = 0;
- }
- memcpy(&this->buffer[j], &data[i], len - i);
-}
-
-
-/*
- * Add padding and return the message digest.
- */
-static void SHA1Final(private_sha1_hasher_t *this, u_int8_t *digest)
-{
- u_int32_t i;
- u_int8_t finalcount[8];
- u_int8_t c;
-
- for (i = 0; i < 8; i++)
- {
- finalcount[i] = (u_int8_t)((this->count[(i >= 4 ? 0 : 1)]
- >> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */
- }
- c = 0200;
- SHA1Update(this, &c, 1);
- while ((this->count[0] & 504) != 448)
- {
- c = 0000;
- SHA1Update(this, &c, 1);
- }
- SHA1Update(this, finalcount, 8); /* Should cause a SHA1Transform() */
- for (i = 0; i < 20; i++)
- {
- digest[i] = (u_int8_t)((this->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
- }
-}
-
-
-/**
- * Implementation of hasher_t.get_hash.
- */
-static void get_hash(private_sha1_hasher_t *this, chunk_t chunk, u_int8_t *buffer)
-{
- SHA1Update(this, chunk.ptr, chunk.len);
- if (buffer != NULL)
- {
- SHA1Final(this, buffer);
- this->public.hasher_interface.reset(&(this->public.hasher_interface));
- }
-}
-
-
-/**
- * Implementation of hasher_t.allocate_hash.
- */
-static void allocate_hash(private_sha1_hasher_t *this, chunk_t chunk, chunk_t *hash)
-{
- chunk_t allocated_hash;
-
- SHA1Update(this, chunk.ptr, chunk.len);
- if (hash != NULL)
- {
- allocated_hash.ptr = allocator_alloc(BLOCK_SIZE_SHA1);
- allocated_hash.len = BLOCK_SIZE_SHA1;
-
- SHA1Final(this, allocated_hash.ptr);
- this->public.hasher_interface.reset(&(this->public.hasher_interface));
-
- *hash = allocated_hash;
- }
-}
-
-/**
- * Implementation of hasher_t.get_block_size.
- */
-static size_t get_block_size(private_sha1_hasher_t *this)
-{
- return BLOCK_SIZE_SHA1;
-}
-
-/**
- * Implementation of hasher_t.reset.
- */
-static void reset(private_sha1_hasher_t *this)
-{
- this->state[0] = 0x67452301;
- this->state[1] = 0xEFCDAB89;
- this->state[2] = 0x98BADCFE;
- this->state[3] = 0x10325476;
- this->state[4] = 0xC3D2E1F0;
- this->count[0] = 0;
- this->count[1] = 0;
-}
-/**
- * Implementation of hasher_t.destroy.
- */
-static void destroy(private_sha1_hasher_t *this)
-{
- allocator_free(this);
-}
-
-
-/*
- * Described in header.
- */
-sha1_hasher_t *sha1_hasher_create()
-{
- private_sha1_hasher_t *this = allocator_alloc_thing(private_sha1_hasher_t);
-
- this->public.hasher_interface.get_hash = (void (*) (hasher_t*, chunk_t, u_int8_t*))get_hash;
- this->public.hasher_interface.allocate_hash = (void (*) (hasher_t*, chunk_t, chunk_t*))allocate_hash;
- this->public.hasher_interface.get_block_size = (size_t (*) (hasher_t*))get_block_size;
- this->public.hasher_interface.reset = (void (*) (hasher_t*))reset;
- this->public.hasher_interface.destroy = (void (*) (hasher_t*))destroy;
-
- /* initialize */
- this->public.hasher_interface.reset(&(this->public.hasher_interface));
-
- return &(this->public);
-}
diff --git a/Source/charon/transforms/hashers/sha1_hasher.h b/Source/charon/transforms/hashers/sha1_hasher.h
deleted file mode 100644
index 43ad0ae20..000000000
--- a/Source/charon/transforms/hashers/sha1_hasher.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * @file sha1_hasher.h
- *
- * @brief Interface of sha1_hasher_t
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef SHA1_HASHER_H_
-#define SHA1_HASHER_H_
-
-#include <transforms/hashers/hasher.h>
-
-
-typedef struct sha1_hasher_t sha1_hasher_t;
-
-/**
- * @brief Implementation of hasher_t interface using the
- * SHA1 algorithm.
- *
- * @b Constructors:
- * - hasher_create() using HASH_SHA1 as algorithm
- * - sha1_hasher_create()
- *
- * @see hasher_t
- *
- * @ingroup hashers
- */
-struct sha1_hasher_t {
-
- /**
- * Generic hasher_t interface for this hasher.
- */
- hasher_t hasher_interface;
-};
-
-/**
- * @brief Creates a new sha1_hasher_t.
- *
- * @return sha1_hasher_t object
- *
- * @ingroup hashers
- */
-sha1_hasher_t *sha1_hasher_create();
-
-#endif /*SHA1_HASHER_H_*/
diff --git a/Source/charon/transforms/hmac.c b/Source/charon/transforms/hmac.c
deleted file mode 100644
index dc31af3eb..000000000
--- a/Source/charon/transforms/hmac.c
+++ /dev/null
@@ -1,210 +0,0 @@
-/**
- * @file hmac.c
- *
- * @brief Implementation of hmac_t.
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General hmac License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General hmac License
- * for more details.
- */
-
-
-#include "hmac.h"
-
-#include <utils/allocator.h>
-
-
-typedef struct private_hmac_t private_hmac_t;
-
-/**
- * Private data of a hmac_t object.
- *
- * The variable names are the same as in the RFC.
- */
-struct private_hmac_t {
- /**
- * Public hmac_t interface.
- */
- hmac_t hmac;
-
- /**
- * Block size, as in RFC.
- */
- u_int8_t b;
-
- /**
- * Hash function.
- */
- hasher_t *h;
-
- /**
- * Previously xor'ed key using opad.
- */
- chunk_t opaded_key;
-
- /**
- * Previously xor'ed key using ipad.
- */
- chunk_t ipaded_key;
-};
-
-/**
- * Implementation of hmac_t.get_mac.
- */
-static void get_mac(private_hmac_t *this, chunk_t data, u_int8_t *out)
-{
- /* H(K XOR opad, H(K XOR ipad, text))
- *
- * if out is NULL, we append text to the inner hash.
- * else, we complete the inner and do the outer.
- *
- */
-
- u_int8_t buffer[this->h->get_block_size(this->h)];
- chunk_t inner;
-
- if (out == NULL)
- {
- /* append data to inner */
- this->h->get_hash(this->h, data, NULL);
- }
- else
- {
- /* append and do outer hash */
- inner.ptr = buffer;
- inner.len = this->h->get_block_size(this->h);
-
- /* complete inner */
- this->h->get_hash(this->h, data, buffer);
-
- /* do outer */
- this->h->get_hash(this->h, this->opaded_key, NULL);
- this->h->get_hash(this->h, inner, out);
-
- /* reinit for next call */
- this->h->get_hash(this->h, this->ipaded_key, NULL);
- }
-}
-
-/**
- * Implementation of hmac_t.allocate_mac.
- */
-static void allocate_mac(private_hmac_t *this, chunk_t data, chunk_t *out)
-{
- /* allocate space and use get_mac */
- if (out == NULL)
- {
- /* append mode */
- this->hmac.get_mac(&(this->hmac), data, NULL);
- }
- else
- {
- out->len = this->h->get_block_size(this->h);
- out->ptr = allocator_alloc(out->len);
- this->hmac.get_mac(&(this->hmac), data, out->ptr);
- }
-}
-
-/**
- * Implementation of hmac_t.get_block_size.
- */
-static size_t get_block_size(private_hmac_t *this)
-{
- return this->h->get_block_size(this->h);
-}
-
-/**
- * Implementation of hmac_t.set_key.
- */
-static void set_key(private_hmac_t *this, chunk_t key)
-{
- int i;
- u_int8_t buffer[this->b];
-
- memset(buffer, 0, this->b);
-
- if (key.len > this->b)
- {
- /* if key is too long, it will be hashed */
- this->h->get_hash(this->h, key, buffer);
- }
- else
- {
- /* if not, just copy it in our pre-padded k */
- memcpy(buffer, key.ptr, key.len);
- }
-
- /* apply ipad and opad to key */
- for (i = 0; i < this->b; i++)
- {
- this->ipaded_key.ptr[i] = buffer[i] ^ 0x36;
- this->opaded_key.ptr[i] = buffer[i] ^ 0x5C;
- }
-
- /* begin hashing of inner pad */
- this->h->reset(this->h);
- this->h->get_hash(this->h, this->ipaded_key, NULL);
-}
-
-/**
- * Implementation of hmac_t.destroy.
- */
-static void destroy(private_hmac_t *this)
-{
- this->h->destroy(this->h);
- allocator_free(this->opaded_key.ptr);
- allocator_free(this->ipaded_key.ptr);
- allocator_free(this);
-}
-
-/*
- * Described in header
- */
-hmac_t *hmac_create(hash_algorithm_t hash_algorithm)
-{
- private_hmac_t *this;
-
- this = allocator_alloc_thing(private_hmac_t);
-
- /* set hmac_t methods */
- this->hmac.get_mac = (void (*)(hmac_t *,chunk_t,u_int8_t*))get_mac;
- this->hmac.allocate_mac = (void (*)(hmac_t *,chunk_t,chunk_t*))allocate_mac;
- this->hmac.get_block_size = (size_t (*)(hmac_t *))get_block_size;
- this->hmac.set_key = (void (*)(hmac_t *,chunk_t))set_key;
- this->hmac.destroy = (void (*)(hmac_t *))destroy;
-
- /* set b, according to hasher */
- switch (hash_algorithm)
- {
- case HASH_SHA1:
- case HASH_MD5:
- this->b = 64;
- break;
- default:
- allocator_free(this);
- return NULL;
- }
-
- /* build the hasher */
- this->h = hasher_create(hash_algorithm);
-
- /* build ipad and opad */
- this->opaded_key.ptr = allocator_alloc(this->b);
- this->opaded_key.len = this->b;
-
- this->ipaded_key.ptr = allocator_alloc(this->b);
- this->ipaded_key.len = this->b;
-
- return &(this->hmac);
-}
diff --git a/Source/charon/transforms/hmac.h b/Source/charon/transforms/hmac.h
deleted file mode 100644
index efc96eff9..000000000
--- a/Source/charon/transforms/hmac.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/**
- * @file hmac.h
- *
- * @brief Interface of hmac_t.
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef HMAC_H_
-#define HMAC_H_
-
-#include <transforms/hashers/hasher.h>
-#include <definitions.h>
-
-
-typedef struct hmac_t hmac_t;
-
-/**
- * @brief Message authentication using hash functions.
- *
- * This class implements the message authenticaion algorithm
- * described in RFC2104. It uses a hash function, wich must
- * be implemented as a hasher_t class.
- *
- * See http://www.faqs.org/rfcs/rfc2104.html for RFC.
- * @see
- * - hasher_t
- * - prf_hmac_t
- *
- * @b Constructors:
- * - hmac_create()
- *
- * @ingroup transforms
- */
-struct hmac_t {
- /**
- * @brief Generate message authentication code.
- *
- * If buffer is NULL, no result is given back. A next call will
- * append the data to already supplied data. If buffer is not NULL,
- * the mac of all apended data is calculated, returned and the
- * state of the hmac_t is reseted.
- *
- * @param this calling object
- * @param data chunk of data to authenticate
- * @param[out] buffer pointer where the generated bytes will be written
- */
- void (*get_mac) (hmac_t *this, chunk_t data, u_int8_t *buffer);
-
- /**
- * @brief Generates message authentication code and
- * allocate space for them.
- *
- * If chunk is NULL, no result is given back. A next call will
- * append the data to already supplied. If chunk is not NULL,
- * the mac of all apended data is calculated, returned and the
- * state of the hmac_t reset;
- *
- * @param this calling object
- * @param data chunk of data to authenticate
- * @param[out] chunk chunk which will hold generated bytes
- */
- void (*allocate_mac) (hmac_t *this, chunk_t data, chunk_t *chunk);
-
- /**
- * @brief Get the block size of this hmac_t object.
- *
- * @param this calling object
- * @return block size in bytes
- */
- size_t (*get_block_size) (hmac_t *this);
-
- /**
- * @brief Set the key for this hmac_t object.
- *
- * Any key length is accepted.
- *
- * @param this calling object
- * @param key key to set
- */
- void (*set_key) (hmac_t *this, chunk_t key);
-
- /**
- * @brief Destroys a hmac_t object.
- *
- * @param this calling object
- */
- void (*destroy) (hmac_t *this);
-};
-
-/**
- * @brief Creates a new hmac_t object.
- *
- * Creates a hasher_t object internally.
- *
- * @param hash_algorithm hash algorithm to use
- * @return
- * - hmac_t object
- * - NULL if hash algorithm is not supported
- *
- * @ingroup transforms
- */
-hmac_t *hmac_create(hash_algorithm_t hash_algorithm);
-
-#endif /*HMAC_H_*/
diff --git a/Source/charon/transforms/prf_plus.c b/Source/charon/transforms/prf_plus.c
deleted file mode 100644
index f0f4a11c6..000000000
--- a/Source/charon/transforms/prf_plus.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/**
- * @file prf_plus.c
- *
- * @brief Implementation of prf_plus_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-
-#include "prf_plus.h"
-
-#include <utils/allocator.h>
-#include <definitions.h>
-
-typedef struct private_prf_plus_t private_prf_plus_t;
-
-/**
- * Private data of an prf_plus_t object.
- *
- */
-struct private_prf_plus_t {
- /**
- * Public interface of prf_plus_t.
- */
- prf_plus_t public;
-
- /**
- * PRF to use.
- */
- prf_t *prf;
-
- /**
- * Initial seed.
- */
- chunk_t seed;
-
- /**
- * Buffer to store current PRF result.
- */
- chunk_t buffer;
-
- /**
- * Already given out bytes in current buffer.
- */
- size_t given_out;
-
- /**
- * Octet which will be appended to the seed.
- */
- u_int8_t appending_octet;
-};
-
-/**
- * Implementation of prf_plus_t.get_bytes.
- */
-static void get_bytes(private_prf_plus_t *this, size_t length, u_int8_t *buffer)
-{
- chunk_t appending_chunk;
- size_t bytes_in_round;
- size_t total_bytes_written = 0;
-
- appending_chunk.ptr = &(this->appending_octet);
- appending_chunk.len = 1;
-
- while (length > 0)
- { /* still more to do... */
- if (this->buffer.len == this->given_out)
- { /* no bytes left in buffer, get next*/
- this->prf->get_bytes(this->prf, this->buffer, NULL);
- this->prf->get_bytes(this->prf, this->seed, NULL);
- this->prf->get_bytes(this->prf, appending_chunk, this->buffer.ptr);
- this->given_out = 0;
- this->appending_octet++;
- }
- /* how many bytes can we write in this round ? */
- bytes_in_round = min(length, this->buffer.len - this->given_out);
- /* copy bytes from buffer with offset */
- memcpy(buffer + total_bytes_written, this->buffer.ptr + this->given_out, bytes_in_round);
-
- length -= bytes_in_round;
- this->given_out += bytes_in_round;
- total_bytes_written += bytes_in_round;
- }
-}
-
-/**
- * Implementation of prf_plus_t.allocate_bytes.
- */
-static void allocate_bytes(private_prf_plus_t *this, size_t length, chunk_t *chunk)
-{
- chunk->ptr = allocator_alloc(length);
- chunk->len = length;
- this->public.get_bytes(&(this->public), length, chunk->ptr);
-}
-
-/**
- * Implementation of prf_plus_t.destroy.
- */
-static void destroy(private_prf_plus_t *this)
-{
- allocator_free(this->buffer.ptr);
- allocator_free(this->seed.ptr);
- allocator_free(this);
-}
-
-/*
- * Description in header.
- */
-prf_plus_t *prf_plus_create(prf_t *prf, chunk_t seed)
-{
- private_prf_plus_t *this;
- chunk_t appending_chunk;
-
- this = allocator_alloc_thing(private_prf_plus_t);
-
- /* set public methods */
- this->public.get_bytes = (void (*)(prf_plus_t *,size_t,u_int8_t*))get_bytes;
- this->public.allocate_bytes = (void (*)(prf_plus_t *,size_t,chunk_t*))allocate_bytes;
- this->public.destroy = (void (*)(prf_plus_t *))destroy;
-
- /* take over prf */
- this->prf = prf;
-
- /* allocate buffer for prf output */
- this->buffer.len = prf->get_block_size(prf);
- this->buffer.ptr = allocator_alloc(this->buffer.len);
-
- this->appending_octet = 0x01;
-
- /* clone seed */
- this->seed.ptr = allocator_clone_bytes(seed.ptr, seed.len);
- this->seed.len = seed.len;
-
- /* do the first run */
- appending_chunk.ptr = &(this->appending_octet);
- appending_chunk.len = 1;
- this->prf->get_bytes(this->prf, this->seed, NULL);
- this->prf->get_bytes(this->prf, appending_chunk, this->buffer.ptr);
- this->given_out = 0;
- this->appending_octet++;
-
- return &(this->public);
-}
diff --git a/Source/charon/transforms/prf_plus.h b/Source/charon/transforms/prf_plus.h
deleted file mode 100644
index 829191786..000000000
--- a/Source/charon/transforms/prf_plus.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * @file prf_plus.h
- *
- * @brief Interface for prf_plus.h.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef PRF_PLUS_H_
-#define PRF_PLUS_H_
-
-
-#include <transforms/prfs/prf.h>
-
-
-typedef struct prf_plus_t prf_plus_t;
-
-/**
- * @brief Implementation of the prf+ function described in IKEv2 RFC.
- *
- * This class implements the prf+ algorithm. Internally it uses a pseudo random
- * function, which implements the prf_t interface.
- *
- * See IKEv2 RFC 2.13.
- *
- * @b Constructors:
- * - prf_plus_create()
- *
- * @ingroup transforms
- */
-struct prf_plus_t {
- /**
- * @brief Get pseudo random bytes.
- *
- * Get the next few bytes of the prf+ output. Space
- * must be allocated by the caller.
- *
- * @param this calling object
- * @param length number of bytes to get
- * @param[out] buffer pointer where the generated bytes will be written
- */
- void (*get_bytes) (prf_plus_t *this, size_t length, u_int8_t *buffer);
-
- /**
- * @brief Allocate pseudo random bytes.
- *
- * Get the next few bytes of the prf+ output. This function
- * will allocate the required space.
- *
- * @param this calling object
- * @param length number of bytes to get
- * @param[out] chunk chunk which will hold generated bytes
- */
- void (*allocate_bytes) (prf_plus_t *this, size_t length, chunk_t *chunk);
-
- /**
- * @brief Destroys a prf_plus_t object.
- *
- * @param this calling object
- */
- void (*destroy) (prf_plus_t *this);
-};
-
-/**
- * @brief Creates a new prf_plus_t object.
- *
- * Seed will be cloned. prf will
- * not be cloned, must be destroyed outside after
- * prf_plus_t usage.
- *
- * @param prf prf object to use
- * @param seed input seed for prf
- * @return prf_plus_t object
- *
- * @ingroup transforms
- */
-prf_plus_t *prf_plus_create(prf_t *prf, chunk_t seed);
-
-#endif /*PRF_PLUS_H_*/
diff --git a/Source/charon/transforms/prfs/hmac_prf.c b/Source/charon/transforms/prfs/hmac_prf.c
deleted file mode 100644
index ce4330090..000000000
--- a/Source/charon/transforms/prfs/hmac_prf.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/**
- * @file hmac_prf.c
- *
- * @brief Implementation for hmac_prf_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "hmac_prf.h"
-
-#include <utils/allocator.h>
-#include <transforms/hmac.h>
-
-
-typedef struct private_hmac_prf_t private_hmac_prf_t;
-
-/**
- * Private data of a hma_prf_t object.
- */
-struct private_hmac_prf_t {
- /**
- * Public hmac_prf_t interface.
- */
- hmac_prf_t public;
-
- /**
- * Hmac to use for generation.
- */
- hmac_t *hmac;
-};
-
-/**
- * Implementation of prf_t.get_bytes.
- */
-static void get_bytes(private_hmac_prf_t *this, chunk_t seed, u_int8_t *buffer)
-{
- this->hmac->get_mac(this->hmac, seed, buffer);
-}
-
-/**
- * Implementation of prf_t.allocate_bytes.
- */
-static void allocate_bytes(private_hmac_prf_t *this, chunk_t seed, chunk_t *chunk)
-{
- this->hmac->allocate_mac(this->hmac, seed, chunk);
-}
-
-/**
- * Implementation of prf_t.get_block_size.
- */
-static size_t get_block_size(private_hmac_prf_t *this)
-{
- return this->hmac->get_block_size(this->hmac);
-}
-
-/**
- * Implementation of prf_t.get_block_size.
- */
-static size_t get_key_size(private_hmac_prf_t *this)
-{
- /* for HMAC prfs, IKEv2 uses block size as key size */
- return this->hmac->get_block_size(this->hmac);
-}
-
-/**
- * Implementation of prf_t.set_key.
- */
-static void set_key(private_hmac_prf_t *this, chunk_t key)
-{
- this->hmac->set_key(this->hmac, key);
-}
-
-/**
- * Implementation of prf_t.destroy.
- */
-static void destroy(private_hmac_prf_t *this)
-{
- allocator_free(this);
- this->hmac->destroy(this->hmac);
-}
-
-/*
- * Described in header.
- */
-hmac_prf_t *hmac_prf_create(hash_algorithm_t hash_algorithm)
-{
- private_hmac_prf_t *this = allocator_alloc_thing(private_hmac_prf_t);
-
- this->public.prf_interface.get_bytes = (void (*) (prf_t *,chunk_t,u_int8_t*))get_bytes;
- this->public.prf_interface.allocate_bytes = (void (*) (prf_t*,chunk_t,chunk_t*))allocate_bytes;
- this->public.prf_interface.get_block_size = (size_t (*) (prf_t*))get_block_size;
- this->public.prf_interface.get_key_size = (size_t (*) (prf_t*))get_key_size;
- this->public.prf_interface.set_key = (void (*) (prf_t *,chunk_t))set_key;
- this->public.prf_interface.destroy = (void (*) (prf_t *))destroy;
-
- this->hmac = hmac_create(hash_algorithm);
- if (this->hmac == NULL)
- {
- allocator_free(this);
- return NULL;
- }
-
- return &(this->public);
-}
diff --git a/Source/charon/transforms/prfs/hmac_prf.h b/Source/charon/transforms/prfs/hmac_prf.h
deleted file mode 100644
index 6ccfceef2..000000000
--- a/Source/charon/transforms/prfs/hmac_prf.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * @file hmac_prf.h
- *
- * @brief Interface of hmac_prf_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef PRF_HMAC_H_
-#define PRF_HMAC_H_
-
-#include <types.h>
-#include <transforms/prfs/prf.h>
-#include <transforms/hashers/hasher.h>
-
-typedef struct hmac_prf_t hmac_prf_t;
-
-/**
- * @brief Implementation of prf_t interface using the
- * HMAC algorithm.
- *
- * This simply wraps a hmac_t in a prf_t. More a question of
- * interface matching.
- *
- * @b Constructors:
- * - hmac_prf_create()
- *
- * @ingroup prfs
- */
-struct hmac_prf_t {
-
- /**
- * Generic prf_t interface for this hmac_prf_t class.
- */
- prf_t prf_interface;
-};
-
-/**
- * @brief Creates a new hmac_prf_t object.
- *
- * @param hash_algorithm hmac's hash algorithm
- * @return
- * - hmac_prf_t object
- * - NULL if hash not supported
- *
- * @ingroup prfs
- */
-hmac_prf_t *hmac_prf_create(hash_algorithm_t hash_algorithm);
-
-#endif /*PRF_HMAC_SHA1_H_*/
diff --git a/Source/charon/transforms/prfs/prf.c b/Source/charon/transforms/prfs/prf.c
deleted file mode 100644
index b9bd7a51a..000000000
--- a/Source/charon/transforms/prfs/prf.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * @file prf.c
- *
- * @brief Generic constructor for all prf_t
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-
-#include "prf.h"
-
-#include <transforms/hashers/hasher.h>
-#include <transforms/prfs/hmac_prf.h>
-
-
-/**
- * String mappings for encryption_algorithm_t.
- */
-mapping_t pseudo_random_function_m[] = {
-{PRF_UNDEFINED, "PRF_UNDEFINED"},
-{PRF_HMAC_MD5, "PRF_HMAC_MD5"},
-{PRF_HMAC_SHA1, "PRF_HMAC_SHA1"},
-{PRF_HMAC_TIGER, "PRF_HMAC_TIGER"},
-{PRF_AES128_CBC, "PRF_AES128_CBC"},
-{MAPPING_END, NULL}
-};
-
-/*
- * Described in header.
- */
-prf_t *prf_create(pseudo_random_function_t pseudo_random_function)
-{
- switch (pseudo_random_function)
- {
- case PRF_HMAC_SHA1:
- {
- return (prf_t*)hmac_prf_create(HASH_SHA1);
- }
- case PRF_HMAC_MD5:
- {
- return (prf_t*)hmac_prf_create(HASH_MD5);
- }
- case PRF_HMAC_TIGER:
- case PRF_AES128_CBC:
- default:
- return NULL;
- }
-}
-
-
-
-
-
diff --git a/Source/charon/transforms/prfs/prf.h b/Source/charon/transforms/prfs/prf.h
deleted file mode 100644
index b1c1e6a66..000000000
--- a/Source/charon/transforms/prfs/prf.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/**
- * @file prf.h
- *
- * @brief Interface prf_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef PRF_H_
-#define PRF_H_
-
-#include <types.h>
-
-typedef enum pseudo_random_function_t pseudo_random_function_t;
-
-/**
- * @brief Pseudo random function, as in IKEv2 RFC 3.3.2.
- *
- * Currently only the following algorithms are implemented and therefore supported:
- * - PRF_HMAC_MD5
- * - PRF_HMAC_SHA1
- *
- * @ingroup prfs
- */
-enum pseudo_random_function_t {
- PRF_UNDEFINED = 1024,
- /**
- * Implemented in class hmac_prf_t.
- */
- PRF_HMAC_MD5 = 1,
- /**
- * Implemented in class hmac_prf_t.
- */
- PRF_HMAC_SHA1 = 2,
- PRF_HMAC_TIGER = 3,
- PRF_AES128_CBC = 4
-};
-
-/**
- * String mappings for encryption_algorithm_t.
- */
-extern mapping_t pseudo_random_function_m[];
-
-
-typedef struct prf_t prf_t;
-
-/**
- * @brief Generic interface for pseudo-random-functions.
- *
- * @b Constructors:
- * - prf_create()
- * - hmac_prf_create()
- *
- * @todo Implement more prf algorithms
- *
- * @ingroup prfs
- */
-struct prf_t {
- /**
- * @brief Generates pseudo random bytes and writes them
- * in the buffer.
- *
- * @param this calling object
- * @param seed a chunk containing the seed for the next bytes
- * @param[out] buffer pointer where the generated bytes will be written
- */
- void (*get_bytes) (prf_t *this, chunk_t seed, u_int8_t *buffer);
-
- /**
- * @brief Generates pseudo random bytes and allocate space for them.
- *
- * @param this calling object
- * @param seed a chunk containing the seed for the next bytes
- * @param[out] chunk chunk which will hold generated bytes
- */
- void (*allocate_bytes) (prf_t *this, chunk_t seed, chunk_t *chunk);
-
- /**
- * @brief Get the block size of this prf_t object.
- *
- * @param this calling object
- * @return block size in bytes
- */
- size_t (*get_block_size) (prf_t *this);
-
- /**
- * @brief Get the key size of this prf_t object.
- *
- * @param this calling object
- * @return key size in bytes
- */
- size_t (*get_key_size) (prf_t *this);
-
- /**
- * @brief Set the key for this prf_t object.
- *
- * @param this calling object
- * @param key key to set
- */
- void (*set_key) (prf_t *this, chunk_t key);
-
- /**
- * @brief Destroys a prf object.
- *
- * @param this calling object
- */
- void (*destroy) (prf_t *this);
-};
-
-/**
- * @brief Generic constructor for a prf_t oject.
- *
- * @param pseudo_random_function Algorithm to use
- * @return
- * - prf_t object
- * - NULL if prf algorithm not supported
- *
- * @ingroup prfs
- */
-prf_t *prf_create(pseudo_random_function_t pseudo_random_function);
-
-#endif /*PRF_H_*/
diff --git a/Source/charon/transforms/rsa/Makefile.rsa b/Source/charon/transforms/rsa/Makefile.rsa
deleted file mode 100644
index 4afe373e7..000000000
--- a/Source/charon/transforms/rsa/Makefile.rsa
+++ /dev/null
@@ -1,23 +0,0 @@
-# Copyright (C) 2005 Jan Hutter, Martin Willi
-# Hochschule fuer Technik Rapperswil
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the
-# Free Software Foundation; either version 2 of the License, or (at your
-# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# for more details.
-#
-
-RSA_DIR= $(TRANSFORMS_DIR)rsa/
-
-OBJS+= $(BUILD_DIR)rsa_private_key.o
-$(BUILD_DIR)rsa_private_key.o : $(RSA_DIR)rsa_private_key.c $(RSA_DIR)rsa_private_key.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-OBJS+= $(BUILD_DIR)rsa_public_key.o
-$(BUILD_DIR)rsa_public_key.o : $(RSA_DIR)rsa_public_key.c $(RSA_DIR)rsa_public_key.h
- $(CC) $(CFLAGS) -c -o $@ $< \ No newline at end of file
diff --git a/Source/charon/transforms/rsa/rsa_private_key.c b/Source/charon/transforms/rsa/rsa_private_key.c
deleted file mode 100644
index 231aee962..000000000
--- a/Source/charon/transforms/rsa/rsa_private_key.c
+++ /dev/null
@@ -1,597 +0,0 @@
-/**
- * @file rsa_private_key.c
- *
- * @brief Implementation of rsa_private_key_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <gmp.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-#include "rsa_private_key.h"
-
-#include <daemon.h>
-#include <utils/allocator.h>
-#include <asn1/der_decoder.h>
-
-
-/*
- * Oids for hash algorithms are defined in
- * rsa_public_key.c.
- */
-extern u_int8_t md2_oid[18];
-extern u_int8_t md5_oid[18];
-extern u_int8_t sha1_oid[15];
-extern u_int8_t sha256_oid[19];
-extern u_int8_t sha384_oid[19];
-extern u_int8_t sha512_oid[19];
-
-
-/**
- * Public exponent to use for key generation.
- */
-#define PUBLIC_EXPONENT 0x10001
-
-
-typedef struct private_rsa_private_key_t private_rsa_private_key_t;
-
-/**
- * Private data of a rsa_private_key_t object.
- */
-struct private_rsa_private_key_t {
- /**
- * Public interface for this signer.
- */
- rsa_private_key_t public;
-
- /**
- * Version of key, as encoded in PKCS#1
- */
- u_int version;
-
- /**
- * Public modulus.
- */
- mpz_t n;
-
- /**
- * Public exponent.
- */
- mpz_t e;
-
- /**
- * Private prime 1.
- */
- mpz_t p;
-
- /**
- * Private Prime 2.
- */
- mpz_t q;
-
- /**
- * Private exponent.
- */
- mpz_t d;
-
- /**
- * Private exponent 1.
- */
- mpz_t exp1;
-
- /**
- * Private exponent 2.
- */
- mpz_t exp2;
-
- /**
- * Private coefficient.
- */
- mpz_t coeff;
-
- /**
- * Keysize in bytes.
- */
- size_t k;
-
- /**
- * @brief Implements the RSADP algorithm specified in PKCS#1.
- *
- * @param this calling object
- * @param data data to process
- * @return processed data
- */
- chunk_t (*rsadp) (private_rsa_private_key_t *this, chunk_t data);
-
- /**
- * @brief Implements the RSASP1 algorithm specified in PKCS#1.
- * @param this calling object
- * @param data data to process
- * @return processed data
- */
- chunk_t (*rsasp1) (private_rsa_private_key_t *this, chunk_t data);
-
- /**
- * @brief Generate a prime value.
- *
- * @param this calling object
- * @param prime_size size of the prime, in bytes
- * @param[out] prime uninitialized mpz
- */
- void (*compute_prime) (private_rsa_private_key_t *this, size_t prime_size, mpz_t *prime);
-
-};
-
-/**
- * Rules for de-/encoding of a private key from/in ASN1
- */
-static asn1_rule_t rsa_private_key_rules[] = {
- {ASN1_SEQUENCE, 0, 0, 0},
- { ASN1_INTEGER, 0, offsetof(private_rsa_private_key_t, version), 0},
- { ASN1_INTEGER, ASN1_MPZ, offsetof(private_rsa_private_key_t, n), 0},
- { ASN1_INTEGER, ASN1_MPZ, offsetof(private_rsa_private_key_t, e), 0},
- { ASN1_INTEGER, ASN1_MPZ, offsetof(private_rsa_private_key_t, d), 0},
- { ASN1_INTEGER, ASN1_MPZ, offsetof(private_rsa_private_key_t, p), 0},
- { ASN1_INTEGER, ASN1_MPZ, offsetof(private_rsa_private_key_t, q), 0},
- { ASN1_INTEGER, ASN1_MPZ, offsetof(private_rsa_private_key_t, exp1), 0},
- { ASN1_INTEGER, ASN1_MPZ, offsetof(private_rsa_private_key_t, exp2), 0},
- { ASN1_INTEGER, ASN1_MPZ, offsetof(private_rsa_private_key_t, coeff), 0},
- {ASN1_END, 0, 0, 0},
-};
-
-static private_rsa_private_key_t *rsa_private_key_create_empty();
-
-/**
- * Implementation of private_rsa_private_key_t.compute_prime.
- */
-static void compute_prime(private_rsa_private_key_t *this, size_t prime_size, mpz_t *prime)
-{
- randomizer_t *randomizer;
- chunk_t random_bytes;
-
- randomizer = randomizer_create();
- mpz_init(*prime);
-
- do
- {
- randomizer->allocate_random_bytes(randomizer, prime_size, &random_bytes);
-
- /* make sure most significant bit is set */
- random_bytes.ptr[0] = random_bytes.ptr[0] | 0x80;
-
- /* convert chunk to mpz value */
- mpz_import(*prime, random_bytes.len, 1, 1, 1, 0, random_bytes.ptr);
-
- /* get next prime */
- mpz_nextprime (*prime, *prime);
-
- allocator_free(random_bytes.ptr);
- }
- /* check if it isnt too large */
- while (((mpz_sizeinbase(*prime, 2) + 7) / 8) > prime_size);
-
- randomizer->destroy(randomizer);
-}
-
-/**
- * Implementation of private_rsa_private_key_t.rsadp and private_rsa_private_key_t.rsasp1.
- */
-static chunk_t rsadp(private_rsa_private_key_t *this, chunk_t data)
-{
- mpz_t t1, t2;
- chunk_t decrypted;
-
- mpz_init(t1);
- mpz_init(t2);
-
- mpz_import(t1, data.len, 1, 1, 1, 0, data.ptr);
-
- mpz_powm(t2, t1, this->exp1, this->p); /* m1 = c^dP mod p */
- mpz_powm(t1, t1, this->exp2, this->q); /* m2 = c^dQ mod Q */
- mpz_sub(t2, t2, t1); /* h = qInv (m1 - m2) mod p */
- mpz_mod(t2, t2, this->p);
- mpz_mul(t2, t2, this->coeff);
- mpz_mod(t2, t2, this->p);
-
- mpz_mul(t2, t2, this->q); /* m = m2 + h q */
- mpz_add(t1, t1, t2);
-
- decrypted.len = this->k;
- decrypted.ptr = mpz_export(NULL, NULL, 1, decrypted.len, 1, 0, t1);
-
- mpz_clear(t1);
- mpz_clear(t2);
-
- return decrypted;
-}
-
-/**
- * Implementation of rsa_private_key.build_emsa_signature.
- */
-static status_t build_emsa_pkcs1_signature(private_rsa_private_key_t *this, hash_algorithm_t hash_algorithm, chunk_t data, chunk_t *signature)
-{
- hasher_t *hasher;
- chunk_t hash;
- chunk_t oid;
- chunk_t em;
-
- /* get oid string prepended to hash */
- switch (hash_algorithm)
- {
- case HASH_MD2:
- {
- oid.ptr = md2_oid;
- oid.len = sizeof(md2_oid);
- break;
- }
- case HASH_MD5:
- {
- oid.ptr = md5_oid;
- oid.len = sizeof(md5_oid);
- break;
- }
- case HASH_SHA1:
- {
- oid.ptr = sha1_oid;
- oid.len = sizeof(sha1_oid);
- break;
- }
- case HASH_SHA256:
- {
- oid.ptr = sha256_oid;
- oid.len = sizeof(sha256_oid);
- break;
- }
- case HASH_SHA384:
- {
- oid.ptr = sha384_oid;
- oid.len = sizeof(sha384_oid);
- break;
- }
- case HASH_SHA512:
- {
- oid.ptr = sha512_oid;
- oid.len = sizeof(sha512_oid);
- break;
- }
- default:
- {
- return NOT_SUPPORTED;
- }
- }
-
- /* get hasher */
- hasher = hasher_create(hash_algorithm);
- if (hasher == NULL)
- {
- return NOT_SUPPORTED;
- }
-
- /* build hash */
- hasher->allocate_hash(hasher, data, &hash);
- hasher->destroy(hasher);
-
- /* build chunk to rsa-decrypt:
- * EM = 0x00 || 0x01 || PS || 0x00 || T.
- * PS = 0xFF padding, with length to fill em
- * T = oid || hash
- */
- em.len = this->k;
- em.ptr = allocator_alloc(em.len);
-
- /* fill em with padding */
- memset(em.ptr, 0xFF, em.len);
- /* set magic bytes */
- *(em.ptr) = 0x00;
- *(em.ptr+1) = 0x01;
- *(em.ptr + em.len - hash.len - oid.len - 1) = 0x00;
- /* set hash */
- memcpy(em.ptr + em.len - hash.len, hash.ptr, hash.len);
- /* set oid */
- memcpy(em.ptr + em.len - hash.len - oid.len, oid.ptr, oid.len);
-
-
- /* build signature */
- *signature = this->rsasp1(this, em);
-
- allocator_free(hash.ptr);
- allocator_free(em.ptr);
-
- return SUCCESS;
-}
-
-/**
- * Implementation of rsa_private_key.get_key.
- */
-static status_t get_key(private_rsa_private_key_t *this, chunk_t *key)
-{
- chunk_t n, e, p, q, d, exp1, exp2, coeff;
-
- n.len = this->k;
- n.ptr = mpz_export(NULL, NULL, 1, n.len, 1, 0, this->n);
- e.len = this->k;
- e.ptr = mpz_export(NULL, NULL, 1, e.len, 1, 0, this->e);
- p.len = this->k;
- p.ptr = mpz_export(NULL, NULL, 1, p.len, 1, 0, this->p);
- q.len = this->k;
- q.ptr = mpz_export(NULL, NULL, 1, q.len, 1, 0, this->q);
- d.len = this->k;
- d.ptr = mpz_export(NULL, NULL, 1, d.len, 1, 0, this->d);
- exp1.len = this->k;
- exp1.ptr = mpz_export(NULL, NULL, 1, exp1.len, 1, 0, this->exp1);
- exp2.len = this->k;
- exp2.ptr = mpz_export(NULL, NULL, 1, exp2.len, 1, 0, this->exp2);
- coeff.len = this->k;
- coeff.ptr = mpz_export(NULL, NULL, 1, coeff.len, 1, 0, this->coeff);
-
- key->len = this->k * 8;
- key->ptr = allocator_alloc(key->len);
- memcpy(key->ptr + this->k * 0, n.ptr , n.len);
- memcpy(key->ptr + this->k * 1, e.ptr, e.len);
- memcpy(key->ptr + this->k * 2, p.ptr, p.len);
- memcpy(key->ptr + this->k * 3, q.ptr, q.len);
- memcpy(key->ptr + this->k * 4, d.ptr, d.len);
- memcpy(key->ptr + this->k * 5, exp1.ptr, exp1.len);
- memcpy(key->ptr + this->k * 6, exp2.ptr, exp2.len);
- memcpy(key->ptr + this->k * 7, coeff.ptr, coeff.len);
-
- allocator_free(n.ptr);
- allocator_free(e.ptr);
- allocator_free(p.ptr);
- allocator_free(q.ptr);
- allocator_free(d.ptr);
- allocator_free(exp1.ptr);
- allocator_free(exp2.ptr);
- allocator_free(coeff.ptr);
-
- return SUCCESS;
-}
-
-/**
- * Implementation of rsa_private_key.save_key.
- */
-static status_t save_key(private_rsa_private_key_t *this, char *file)
-{
- return NOT_SUPPORTED;
-}
-
-/**
- * Implementation of rsa_private_key.get_public_key.
- */
-rsa_public_key_t *get_public_key(private_rsa_private_key_t *this)
-{
- return NULL;
-}
-
-/**
- * Implementation of rsa_private_key.belongs_to.
- */
-bool belongs_to(private_rsa_private_key_t *this, rsa_public_key_t *public)
-{
- if (mpz_cmp(this->n, *public->get_modulus(public)) == 0)
- {
- return TRUE;
- }
- return FALSE;
-}
-
-/**
- * Implementation of rsa_private_key.clone.
- */
-static rsa_private_key_t* _clone(private_rsa_private_key_t *this)
-{
- private_rsa_private_key_t *clone = rsa_private_key_create_empty();
-
- mpz_init_set(clone->n, this->n);
- mpz_init_set(clone->e, this->e);
- mpz_init_set(clone->p, this->p);
- mpz_init_set(clone->q, this->q);
- mpz_init_set(clone->d, this->d);
- mpz_init_set(clone->exp1, this->exp1);
- mpz_init_set(clone->exp2, this->exp2);
- mpz_init_set(clone->coeff, this->coeff);
- clone->k = this->k;
-
- return &clone->public;
-}
-
-/**
- * Implementation of rsa_private_key.destroy.
- */
-static void destroy(private_rsa_private_key_t *this)
-{
- mpz_clear(this->n);
- mpz_clear(this->e);
- mpz_clear(this->p);
- mpz_clear(this->q);
- mpz_clear(this->d);
- mpz_clear(this->exp1);
- mpz_clear(this->exp2);
- mpz_clear(this->coeff);
- allocator_free(this);
-}
-
-/**
- * Internal generic constructor
- */
-static private_rsa_private_key_t *rsa_private_key_create_empty()
-{
- private_rsa_private_key_t *this = allocator_alloc_thing(private_rsa_private_key_t);
-
- /* public functions */
- this->public.build_emsa_pkcs1_signature = (status_t (*) (rsa_private_key_t*,hash_algorithm_t,chunk_t,chunk_t*))build_emsa_pkcs1_signature;
- this->public.get_key = (status_t (*) (rsa_private_key_t*,chunk_t*))get_key;
- this->public.save_key = (status_t (*) (rsa_private_key_t*,char*))save_key;
- this->public.get_public_key = (rsa_public_key_t *(*) (rsa_private_key_t*))get_public_key;
- this->public.belongs_to = (bool (*) (rsa_private_key_t*,rsa_public_key_t*))belongs_to;
- this->public.clone = (rsa_private_key_t*(*)(rsa_private_key_t*))_clone;
- this->public.destroy = (void (*) (rsa_private_key_t*))destroy;
-
- /* private functions */
- this->rsadp = rsadp;
- this->rsasp1 = rsadp; /* same algorithm */
- this->compute_prime = compute_prime;
-
- return this;
-}
-
-/*
- * See header
- */
-rsa_private_key_t *rsa_private_key_create(size_t key_size)
-{
- mpz_t p, q, n, e, d, exp1, exp2, coeff;
- mpz_t m, q1, t;
- private_rsa_private_key_t *this;
-
- this = rsa_private_key_create_empty();
-
- key_size = key_size / 8;
-
- mpz_init(t);
- mpz_init(n);
- mpz_init(d);
- mpz_init(exp1);
- mpz_init(exp2);
- mpz_init(coeff);
-
- /* Get values of primes p and q */
- this->compute_prime(this, key_size/2, &p);
- this->compute_prime(this, key_size/2, &q);
-
- /* Swapping Primes so p is larger then q */
- if (mpz_cmp(p, q) < 0)
- {
- mpz_set(t, p);
- mpz_set(p, q);
- mpz_set(q, t);
- }
-
- mpz_mul(n, p, q); /* n = p*q */
- mpz_init_set_ui(e, PUBLIC_EXPONENT); /* assign public exponent */
- mpz_init_set(m, p); /* m = p */
- mpz_sub_ui(m, m, 1); /* m = m -1 */
- mpz_init_set(q1, q); /* q1 = q */
- mpz_sub_ui(q1, q1, 1); /* q1 = q1 -1 */
- mpz_gcd(t, m, q1); /* t = gcd(p-1, q-1) */
- mpz_mul(m, m, q1); /* m = (p-1)*(q-1) */
- mpz_divexact(m, m, t); /* m = m / t */
- mpz_gcd(t, m, e); /* t = gcd(m, e) (greatest common divisor) */
-
- mpz_invert(d, e, m); /* e has an inverse mod m */
- if (mpz_cmp_ui(d, 0) < 0) /* make sure d is positive */
- {
- mpz_add(d, d, m);
- }
- mpz_sub_ui(t, p, 1); /* t = p-1 */
- mpz_mod(exp1, d, t); /* exp1 = d mod p-1 */
- mpz_sub_ui(t, q, 1); /* t = q-1 */
- mpz_mod(exp2, d, t); /* exp2 = d mod q-1 */
-
- mpz_invert(coeff, q, p); /* coeff = q^-1 mod p */
- if (mpz_cmp_ui(coeff, 0) < 0) /* make coeff d is positive */
- {
- mpz_add(coeff, coeff, p);
- }
-
- mpz_clear(q1);
- mpz_clear(m);
- mpz_clear(t);
-
- /* apply values */
- *(this->p) = *p;
- *(this->q) = *q;
- *(this->n) = *n;
- *(this->e) = *e;
- *(this->d) = *d;
- *(this->exp1) = *exp1;
- *(this->exp2) = *exp2;
- *(this->coeff) = *coeff;
-
- /* set key size in bytes */
- this->k = key_size;
-
- return &this->public;
-}
-
-/*
- * see header
- */
-rsa_private_key_t *rsa_private_key_create_from_chunk(chunk_t chunk)
-{
- private_rsa_private_key_t *this;
- der_decoder_t *dd;
- status_t status;
-
- this = rsa_private_key_create_empty();
-
- mpz_init(this->n);
- mpz_init(this->e);
- mpz_init(this->p);
- mpz_init(this->q);
- mpz_init(this->d);
- mpz_init(this->exp1);
- mpz_init(this->exp2);
- mpz_init(this->coeff);
-
- dd = der_decoder_create(rsa_private_key_rules);
- status = dd->decode(dd, chunk, this);
- dd->destroy(dd);
- if (status != SUCCESS)
- {
- destroy(this);
- return NULL;
- }
- this->k = (mpz_sizeinbase(this->n, 2) + 7) / 8;
- return &this->public;
-}
-
-/*
- * see header
- */
-rsa_private_key_t *rsa_private_key_create_from_file(char *filename, char *passphrase)
-{
- chunk_t chunk;
- struct stat stb;
- FILE *file;
- char *buffer;
-
- if (stat(filename, &stb) == -1)
- {
- return NULL;
- }
-
- buffer = alloca(stb.st_size);
-
- file = fopen(filename, "r");
- if (file == NULL)
- {
- return NULL;
- }
-
- if (fread(buffer, stb.st_size, 1, file) != 1)
- {
- return NULL;
- }
-
- chunk.ptr = buffer;
- chunk.len = stb.st_size;
-
- return rsa_private_key_create_from_chunk(chunk);
-}
diff --git a/Source/charon/transforms/rsa/rsa_private_key.h b/Source/charon/transforms/rsa/rsa_private_key.h
deleted file mode 100644
index 3ca760042..000000000
--- a/Source/charon/transforms/rsa/rsa_private_key.h
+++ /dev/null
@@ -1,185 +0,0 @@
-/**
- * @file rsa_private_key.h
- *
- * @brief Interface of rsa_private_key_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef RSA_PRIVATE_KEY_H_
-#define RSA_PRIVATE_KEY_H_
-
-#include <types.h>
-#include <definitions.h>
-#include <transforms/rsa/rsa_public_key.h>
-#include <transforms/hashers/hasher.h>
-
-
-typedef struct rsa_private_key_t rsa_private_key_t;
-
-/**
- * @brief RSA private key with associated functions.
- *
- * Currently only supports signing using EMSA encoding.
- *
- * @b Constructors:
- * - rsa_private_key_create()
- * - rsa_private_key_create_from_chunk()
- * - rsa_private_key_create_from_file()
- *
- * @see rsa_public_key_t
- *
- * @todo Implement get_key(), save_key(), get_public_key()
- *
- * @ingroup rsa
- */
-struct rsa_private_key_t {
-
- /**
- * @brief Build a signature over a chunk using EMSA-PKCS1 encoding.
- *
- * This signature creates a hash using the specified hash algorithm, concatenates
- * it with an ASN1-OID of the hash algorithm and runs the RSASP1 function
- * on it.
- *
- * @param this calling object
- * @param hash_algorithm hash algorithm to use for hashing
- * @param data data to sign
- * @param[out] signature allocated signature
- * @return
- * - SUCCESS
- * - INVALID_STATE, if key not set
- * - NOT_SUPPORTED, if hash algorithm not supported
- */
- status_t (*build_emsa_pkcs1_signature) (rsa_private_key_t *this, hash_algorithm_t hash_algorithm, chunk_t data, chunk_t *signature);
-
- /**
- * @brief Gets the key.
- *
- * UNIMPLEMENTED!
- *
- * @param this calling object
- * @param key key (in a propriarity format)
- * @return
- * - SUCCESS
- * - INVALID_STATE, if key not set
- */
- status_t (*get_key) (rsa_private_key_t *this, chunk_t *key);
-
- /**
- * @brief Saves a key to a file.
- *
- * Not implemented!
- *
- * @param this calling object
- * @param file file to which the key should be written.
- * @return NOT_SUPPORTED
- */
- status_t (*save_key) (rsa_private_key_t *this, char *file);
-
- /**
- * @brief Generate a new key.
- *
- * Generates a new private_key with specified key size
- *
- * @param this calling object
- * @param key_size size of the key in bits
- * @return
- * - SUCCESS
- * - INVALID_ARG if key_size invalid
- */
- status_t (*generate_key) (rsa_private_key_t *this, size_t key_size);
-
- /**
- * @brief Create a rsa_public_key_t with the public
- * parts of the key.
- *
- * @param this calling object
- * @return public_key
- */
- rsa_public_key_t *(*get_public_key) (rsa_private_key_t *this);
-
- /**
- * @brief Check if a private key belongs to a public key.
- *
- * Compares the public part of the private key with the
- * public key, return TRUE if it equals.
- *
- * @param this private key
- * @param public public key
- * @return TRUE, if keys belong together
- */
- bool (*belongs_to) (rsa_private_key_t *this, rsa_public_key_t *public);
-
- /**
- * @brief Clone the private key.
- *
- * @param this private key to clone
- * @return clone of this
- */
- rsa_private_key_t *(*clone) (rsa_private_key_t *this);
-
- /**
- * @brief Destroys the private key.
- *
- * @param this private key to destroy
- */
- void (*destroy) (rsa_private_key_t *this);
-};
-
-/**
- * @brief Generate a new RSA key with specified key lenght.
- *
- * @param key_size size of the key in bits
- * @return generated rsa_private_key_t.
- *
- * @ingroup rsa
- */
-rsa_private_key_t *rsa_private_key_create(size_t key_size);
-
-/**
- * @brief Load an RSA private key from a chunk.
- *
- * Load a key from a chunk, encoded as described in PKCS#1
- * (ASN1 DER encoded).
- *
- * @param chunk chunk containing the DER encoded key
- * @return loaded rsa_private_key_t, or NULL
- *
- * @ingroup rsa
- */
-rsa_private_key_t *rsa_private_key_create_from_chunk(chunk_t chunk);
-
-/**
- * @brief Load an RSA private key from a file.
- *
- * Load a key from a file, which is either in a unencrypted binary
- * format (DER), or in a (encrypted) PEM format. The supplied
- * passphrase is used to decrypt an ecrypted key.
- *
- * @param filename filename which holds the key
- * @param passphrase optional passphase for decryption
- * @return loaded rsa_private_key_t, or NULL
- *
- * @todo Implement PEM file loading
- * @todo Implement key decryption
- *
- * @ingroup rsa
- */
-rsa_private_key_t *rsa_private_key_create_from_file(char *filename, char *passphrase);
-
-#endif /*RSA_PRIVATE_KEY_H_*/
diff --git a/Source/charon/transforms/rsa/rsa_public_key.c b/Source/charon/transforms/rsa/rsa_public_key.c
deleted file mode 100644
index 5a3df1f10..000000000
--- a/Source/charon/transforms/rsa/rsa_public_key.c
+++ /dev/null
@@ -1,468 +0,0 @@
-/**
- * @file rsa_public_key.c
- *
- * @brief Implementation of rsa_public_key_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <gmp.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-#include "rsa_public_key.h"
-
-#include <daemon.h>
-#include <utils/allocator.h>
-#include <transforms/hashers/hasher.h>
-#include <asn1/der_decoder.h>
-
-/*
- * For simplicity,
- * we use these predefined values for
- * hash algorithm OIDs. These also contain
- * the length of the following hash.
- * These values are also used in rsa_private_key.c.
- */
-
-u_int8_t md2_oid[] = {
- 0x30,0x20,0x30,0x0c,0x06,0x08,0x2a,0x86,
- 0x48,0x86,0xf7,0x0d,0x02,0x02,0x05,0x00,
- 0x04,0x10
-};
-
-u_int8_t md5_oid[] = {
- 0x30,0x20,0x30,0x0c,0x06,0x08,0x2a,0x86,
- 0x48,0x86,0xf7,0x0d,0x02,0x05,0x05,0x00,
- 0x04,0x10
-};
-
-u_int8_t sha1_oid[] = {
- 0x30,0x21,0x30,0x09,0x06,0x05,0x2b,0x0e,
- 0x03,0x02,0x1a,0x05,0x00,0x04,0x14
-};
-
-u_int8_t sha256_oid[] = {
- 0x30,0x31,0x30,0x0d,0x06,0x09,0x60,0x86,
- 0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,
- 0x00,0x04,0x20
-};
-
-u_int8_t sha384_oid[] = {
- 0x30,0x41,0x30,0x0d,0x06,0x09,0x60,0x86,
- 0x48,0x01,0x65,0x03,0x04,0x02,0x02,0x05,
- 0x00,0x04,0x30
-};
-
-u_int8_t sha512_oid[] = {
- 0x30,0x51,0x30,0x0d,0x06,0x09,0x60,0x86,
- 0x48,0x01,0x65,0x03,0x04,0x02,0x03,0x05,
- 0x00,0x04,0x40
-};
-
-
-typedef struct private_rsa_public_key_t private_rsa_public_key_t;
-
-/**
- * Private data structure with signing context.
- */
-struct private_rsa_public_key_t {
- /**
- * Public interface for this signer.
- */
- rsa_public_key_t public;
-
- /**
- * Public modulus.
- */
- mpz_t n;
-
- /**
- * Public exponent.
- */
- mpz_t e;
-
- /**
- * Keysize in bytes.
- */
- size_t k;
-
- /**
- * @brief Implements the RSAEP algorithm specified in PKCS#1.
- *
- * @param this calling object
- * @param data data to process
- * @return processed data
- */
- chunk_t (*rsaep) (private_rsa_public_key_t *this, chunk_t data);
-
- /**
- * @brief Implements the RSASVP1 algorithm specified in PKCS#1.
- *
- * @param this calling object
- * @param data data to process
- * @return processed data
- */
- chunk_t (*rsavp1) (private_rsa_public_key_t *this, chunk_t data);
-};
-
-
-typedef struct rsa_public_key_info_t rsa_public_key_info_t;
-
-/**
- * KeyInfo, as it appears in a public key file
- */
-struct rsa_public_key_info_t {
- /**
- * Algorithm for this key
- */
- chunk_t algorithm_oid;
-
- /**
- * Public key, parseable with rsa_public_key_rules
- */
- chunk_t public_key;
-};
-
-/**
- * Rules for de-/encoding of a public key from/in ASN1
- */
-static asn1_rule_t rsa_public_key_rules[] = {
- {ASN1_SEQUENCE, 0, 0, 0},
- { ASN1_INTEGER, ASN1_MPZ, offsetof(private_rsa_public_key_t, n), 0},
- { ASN1_INTEGER, ASN1_MPZ, offsetof(private_rsa_public_key_t, e), 0},
- {ASN1_END, 0, 0, 0},
-};
-
-/**
- * Rules for de-/encoding of a PublicKeyInfo from/in ASN1
- */
-static asn1_rule_t rsa_public_key_info_rules[] = {
- {ASN1_SEQUENCE, 0, 0, 0},
- { ASN1_SEQUENCE, 0, 0, 0},
- { ASN1_OID, 0, offsetof(rsa_public_key_info_t, algorithm_oid), 0},
- { ASN1_NULL, 0, 0, 0},
- { ASN1_END, 0, 0, 0},
- { ASN1_BITSTRING, 0, offsetof(rsa_public_key_info_t, public_key), 0},
- {ASN1_END, 0, 0, 0},
-};
-
-private_rsa_public_key_t *rsa_public_key_create_empty();
-
-/**
- * Implementation of private_rsa_public_key_t.rsaep and private_rsa_public_key_t.rsavp1
- */
-static chunk_t rsaep(private_rsa_public_key_t *this, chunk_t data)
-{
- mpz_t m, c;
- chunk_t encrypted;
-
- mpz_init(c);
- mpz_init(m);
-
- mpz_import(m, data.len, 1, 1, 1, 0, data.ptr);
-
- mpz_powm(c, m, this->e, this->n);
-
- encrypted.len = this->k;
- encrypted.ptr = mpz_export(NULL, NULL, 1, encrypted.len, 1, 0, c);
-
- mpz_clear(c);
- mpz_clear(m);
-
- return encrypted;
-}
-
-/**
- * Implementation of rsa_public_key.verify_emsa_pkcs1_signature.
- */
-static status_t verify_emsa_pkcs1_signature(private_rsa_public_key_t *this, chunk_t data, chunk_t signature)
-{
- hasher_t *hasher = NULL;
- chunk_t hash;
- chunk_t em;
- u_int8_t *pos;
-
- if (signature.len > this->k)
- {
- return INVALID_ARG;
- }
-
- /* unpack signature */
- em = this->rsavp1(this, signature);
-
- /* result should look like this:
- * EM = 0x00 || 0x01 || PS || 0x00 || T.
- * PS = 0xFF padding, with length to fill em
- * T = oid || hash
- */
-
- /* check magic bytes */
- if ((*(em.ptr) != 0x00) ||
- (*(em.ptr+1) != 0x01))
- {
- allocator_free(em.ptr);
- return FAILED;
- }
-
- /* find magic 0x00 */
- pos = em.ptr + 2;
- while (pos <= em.ptr + em.len)
- {
- if (*pos == 0x00)
- {
- /* found magic byte, stop */
- pos++;
- break;
- }
- else if (*pos != 0xFF)
- {
- /* bad padding, decryption failed ?!*/
- allocator_free(em.ptr);
- return FAILED;
- }
- pos++;
- }
-
- if (pos + 20 > em.ptr + em.len)
- {
- /* not enought room for oid compare */
- allocator_free(em.ptr);
- return FAILED;
- }
-
- if (memcmp(md2_oid, pos, sizeof(md2_oid)) == 0)
- {
- hasher = hasher_create(HASH_MD2);
- pos += sizeof(md2_oid);
- }
- else if (memcmp(md5_oid, pos, sizeof(md5_oid)) == 0)
- {
- hasher = hasher_create(HASH_MD5);
- pos += sizeof(md5_oid);
- }
- else if (memcmp(sha1_oid, pos, sizeof(sha1_oid)) == 0)
- {
- hasher = hasher_create(HASH_SHA1);
- pos += sizeof(sha1_oid);
- }
- else if (memcmp(sha256_oid, pos, sizeof(sha256_oid)) == 0)
- {
- hasher = hasher_create(HASH_SHA256);
- pos += sizeof(sha256_oid);
- }
- else if (memcmp(sha384_oid, pos, sizeof(sha384_oid)) == 0)
- {
- hasher = hasher_create(HASH_SHA384);
- pos += sizeof(sha384_oid);
- }
- else if (memcmp(sha512_oid, pos, sizeof(sha512_oid)) == 0)
- {
- hasher = hasher_create(HASH_SHA512);
- pos += sizeof(sha512_oid);
- }
-
- if (hasher == NULL)
- {
- /* not supported hash algorithm */
- allocator_free(em.ptr);
- return NOT_SUPPORTED;
- }
-
- if (pos + hasher->get_block_size(hasher) != em.ptr + em.len)
- {
- /* bad length */
- allocator_free(em.ptr);
- hasher->destroy(hasher);
- return FAILED;
- }
-
- /* build own hash for a compare */
- hasher->allocate_hash(hasher, data, &hash);
- hasher->destroy(hasher);
-
- if (memcmp(hash.ptr, pos, hash.len) != 0)
- {
- /* hash does not equal */
- allocator_free(hash.ptr);
- allocator_free(em.ptr);
- return FAILED;
-
- }
-
- /* seems good */
- allocator_free(hash.ptr);
- allocator_free(em.ptr);
- return SUCCESS;
-}
-
-/**
- * Implementation of rsa_public_key.get_key.
- */
-static status_t get_key(private_rsa_public_key_t *this, chunk_t *key)
-{
- chunk_t n, e;
-
- n.len = this->k;
- n.ptr = mpz_export(NULL, NULL, 1, n.len, 1, 0, this->n);
- e.len = this->k;
- e.ptr = mpz_export(NULL, NULL, 1, e.len, 1, 0, this->e);
-
- key->len = this->k * 2;
- key->ptr = allocator_alloc(key->len);
- memcpy(key->ptr, n.ptr, n.len);
- memcpy(key->ptr + n.len, e.ptr, e.len);
- allocator_free(n.ptr);
- allocator_free(e.ptr);
-
- return SUCCESS;
-}
-
-/**
- * Implementation of rsa_public_key.save_key.
- */
-static status_t save_key(private_rsa_public_key_t *this, char *file)
-{
- return NOT_SUPPORTED;
-}
-
-/**
- * Implementation of rsa_public_key.get_modulus.
- */
-static mpz_t *get_modulus(private_rsa_public_key_t *this)
-{
- return &this->n;
-}
-
-/**
- * Implementation of rsa_public_key.clone.
- */
-static rsa_public_key_t* _clone(private_rsa_public_key_t *this)
-{
- private_rsa_public_key_t *clone = rsa_public_key_create_empty();
-
- mpz_init_set(clone->n, this->n);
- mpz_init_set(clone->e, this->e);
- clone->k = this->k;
-
- return &clone->public;
-}
-
-/**
- * Implementation of rsa_public_key.destroy.
- */
-static void destroy(private_rsa_public_key_t *this)
-{
- mpz_clear(this->n);
- mpz_clear(this->e);
- allocator_free(this);
-}
-
-/**
- * Generic private constructor
- */
-private_rsa_public_key_t *rsa_public_key_create_empty()
-{
- private_rsa_public_key_t *this = allocator_alloc_thing(private_rsa_public_key_t);
-
- /* public functions */
- this->public.verify_emsa_pkcs1_signature = (status_t (*) (rsa_public_key_t*,chunk_t,chunk_t))verify_emsa_pkcs1_signature;
- this->public.get_key = (status_t (*) (rsa_public_key_t*,chunk_t*))get_key;
- this->public.save_key = (status_t (*) (rsa_public_key_t*,char*))save_key;
- this->public.get_modulus = (mpz_t *(*) (rsa_public_key_t*))get_modulus;
- this->public.clone = (rsa_public_key_t* (*) (rsa_public_key_t*))_clone;
- this->public.destroy = (void (*) (rsa_public_key_t*))destroy;
-
- /* private functions */
- this->rsaep = rsaep;
- this->rsavp1 = rsaep; /* same algorithm */
-
- return this;
-}
-
-/*
- * See header
- */
-rsa_public_key_t *rsa_public_key_create_from_chunk(chunk_t chunk)
-{
- der_decoder_t *dd;
- status_t status;
- private_rsa_public_key_t *this;
-
- this = rsa_public_key_create_empty();
- mpz_init(this->n);
- mpz_init(this->e);
-
- dd = der_decoder_create(rsa_public_key_rules);
- status = dd->decode(dd, chunk, this);
- dd->destroy(dd);
- if (status != SUCCESS)
- {
- destroy(this);
- return NULL;
- }
- this->k = (mpz_sizeinbase(this->n, 2) + 7) / 8;
- return &this->public;
-}
-
-/*
- * See header
- */
-rsa_public_key_t *rsa_public_key_create_from_file(char *filename)
-{
- struct stat stb;
- FILE *file;
- char *buffer;
- chunk_t chunk;
- rsa_public_key_info_t key_info = {CHUNK_INITIALIZER, CHUNK_INITIALIZER};
- der_decoder_t *dd;
- status_t status;
- rsa_public_key_t *public_key = NULL;
-
- if (stat(filename, &stb) == -1)
- {
- return NULL;
- }
-
- buffer = alloca(stb.st_size);
-
- file = fopen(filename, "r");
- if (file == NULL)
- {
- return NULL;
- }
-
- if (fread(buffer, stb.st_size, 1, file) != 1)
- {
- return NULL;
- }
-
- chunk.ptr = buffer;
- chunk.len = stb.st_size;
-
- /* parse public key info first */
- dd = der_decoder_create(rsa_public_key_info_rules);
- status = dd->decode(dd, chunk, &key_info);
- dd->destroy(dd);
- allocator_free_chunk(&key_info.algorithm_oid);
- if (status == SUCCESS)
- {
- public_key = rsa_public_key_create_from_chunk(chunk);
- }
- allocator_free_chunk(&key_info.public_key);
- return public_key;
-}
diff --git a/Source/charon/transforms/rsa/rsa_public_key.h b/Source/charon/transforms/rsa/rsa_public_key.h
deleted file mode 100644
index ef79153d6..000000000
--- a/Source/charon/transforms/rsa/rsa_public_key.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/**
- * @file rsa_public_key.h
- *
- * @brief Interface of rsa_public_key_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef RSA_PUBLIC_KEY_H_
-#define RSA_PUBLIC_KEY_H_
-
-#include <gmp.h>
-
-#include <types.h>
-#include <definitions.h>
-
-
-typedef struct rsa_public_key_t rsa_public_key_t;
-
-/**
- * @brief RSA public key with associated functions.
- *
- * Currently only supports signature verification using
- * the EMSA encoding (see PKCS1)
- *
- * @b Constructors:
- * - rsa_public_key_create_from_chunk()
- * - rsa_public_key_create_from_file()
- * - rsa_private_key_t.get_public_key()
- *
- * @see rsa_private_key_t
- *
- * @todo Implement getkey() and savekey()
- *
- * @ingroup rsa
- */
-struct rsa_public_key_t {
-
- /**
- * @brief Verify a EMSA-PKCS1 encodined signature.
- *
- * Processes the supplied signature with the RSAVP1 function,
- * selects the hash algorithm form the resultign ASN1-OID and
- * verifies the hash against the supplied data.
- *
- * @param this rsa_public_key to use
- * @param data data to sign
- * @param signature signature to verify
- * @return
- * - SUCCESS, if signature ok
- * - INVALID_STATE, if key not set
- * - NOT_SUPPORTED, if hash algorithm not supported
- * - INVALID_ARG, if signature is not a signature
- * - FAILED if signature invalid or unable to verify
- */
- status_t (*verify_emsa_pkcs1_signature) (rsa_public_key_t *this, chunk_t data, chunk_t signature);
-
- /**
- * @brief Gets the key.
- *
- * Currently uses a proprietary format which is only inteded
- * for testing. This should be replaced with a proper
- * ASN1 encoded key format, when charon gets the ASN1
- * capabilities.
- *
- * @param this calling object
- * @param key key (in a propriarity format)
- * @return
- * - SUCCESS
- * - INVALID_STATE, if key not set
- */
- status_t (*get_key) (rsa_public_key_t *this, chunk_t *key);
-
- /**
- * @brief Saves a key to a file.
- *
- * Not implemented!
- *
- * @param this calling object
- * @param file file to which the key should be written.
- * @return NOT_SUPPORTED
- */
- status_t (*save_key) (rsa_public_key_t *this, char *file);
-
- /**
- * @brief Get the modulus of the key.
- *
- * @param this calling object
- * @return modulus (n) of the key
- */
- mpz_t *(*get_modulus) (rsa_public_key_t *this);
-
- /**
- * @brief Clone the public key.
- *
- * @param this public key to clone
- * @return clone of this
- */
- rsa_public_key_t *(*clone) (rsa_public_key_t *this);
-
- /**
- * @brief Destroys the public key.
- *
- * @param this public key to destroy
- */
- void (*destroy) (rsa_public_key_t *this);
-};
-
-/**
- * @brief Load an RSA public key from a chunk.
- *
- * Load a key from a chunk, encoded in the more frequently
- * used PublicKeyInfo struct (ASN1 DER encoded).
- *
- * @param chunk chunk containing the DER encoded key
- * @return loaded rsa_public_key_t, or NULL
- *
- * @todo Check OID in PublicKeyInfo
- *
- * @ingroup rsa
- */
-rsa_public_key_t *rsa_public_key_create_from_chunk(chunk_t chunk);
-
-/**
- * @brief Load an RSA public key from a file.
- *
- * Load a key from a file, which is either in binary
- * format (DER), or in PEM format.
- *
- * @param filename filename which holds the key
- * @return loaded rsa_public_key_t, or NULL
- *
- * @todo Implement PEM file loading
- *
- * @ingroup rsa
- */
-rsa_public_key_t *rsa_public_key_create_from_file(char *filename);
-
-#endif /*RSA_PUBLIC_KEY_H_*/
diff --git a/Source/charon/transforms/signers/Makefile.signers b/Source/charon/transforms/signers/Makefile.signers
deleted file mode 100644
index 861125c56..000000000
--- a/Source/charon/transforms/signers/Makefile.signers
+++ /dev/null
@@ -1,23 +0,0 @@
-# Copyright (C) 2005 Jan Hutter, Martin Willi
-# Hochschule fuer Technik Rapperswil
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the
-# Free Software Foundation; either version 2 of the License, or (at your
-# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# for more details.
-#
-
-SIGNERS_DIR= $(TRANSFORMS_DIR)signers/
-
-OBJS+= $(BUILD_DIR)signer.o
-$(BUILD_DIR)signer.o : $(SIGNERS_DIR)signer.c $(SIGNERS_DIR)signer.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-OBJS+= $(BUILD_DIR)hmac_signer.o
-$(BUILD_DIR)hmac_signer.o : $(SIGNERS_DIR)hmac_signer.c $(SIGNERS_DIR)hmac_signer.h
- $(CC) $(CFLAGS) -c -o $@ $<
diff --git a/Source/charon/transforms/signers/hmac_signer.c b/Source/charon/transforms/signers/hmac_signer.c
deleted file mode 100644
index ee029011f..000000000
--- a/Source/charon/transforms/signers/hmac_signer.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/**
- * @file hmac_signer.c
- *
- * @brief Implementation of hmac_signer_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "hmac_signer.h"
-
-#include <utils/allocator.h>
-#include <transforms/prfs/hmac_prf.h>
-
-/**
- * This class represents a hmac signer with 12 byte (96 bit) output.
- */
-#define BLOCK_SIZE 12
-
-typedef struct private_hmac_signer_t private_hmac_signer_t;
-
-/**
- * Private data structure with signing context.
- */
-struct private_hmac_signer_t {
- /**
- * Public interface of hmac_signer_t.
- */
- hmac_signer_t public;
-
- /*
- * Assigned hmac function.
- */
- prf_t *hmac_prf;
-};
-
-/**
- * Implementation of signer_t.get_signature.
- */
-static void get_signature (private_hmac_signer_t *this, chunk_t data, u_int8_t *buffer)
-{
- u_int8_t full_mac[this->hmac_prf->get_block_size(this->hmac_prf)];
-
- this->hmac_prf->get_bytes(this->hmac_prf,data,full_mac);
-
- /* copy mac aka signature :-) */
- memcpy(buffer,full_mac,BLOCK_SIZE);
-}
-
-/**
- * Implementation of signer_t.allocate_signature.
- */
-static void allocate_signature (private_hmac_signer_t *this, chunk_t data, chunk_t *chunk)
-{
- chunk_t signature;
- u_int8_t full_mac[this->hmac_prf->get_block_size(this->hmac_prf)];
-
- this->hmac_prf->get_bytes(this->hmac_prf,data,full_mac);
-
- signature.ptr = allocator_alloc(BLOCK_SIZE);
- signature.len = BLOCK_SIZE;
-
- /* copy signature */
- memcpy(signature.ptr,full_mac,BLOCK_SIZE);
-
- *chunk = signature;
-}
-
-/**
- * Implementation of signer_t.verify_signature.
- */
-static bool verify_signature (private_hmac_signer_t *this, chunk_t data, chunk_t signature)
-{
- u_int8_t full_mac[this->hmac_prf->get_block_size(this->hmac_prf)];
-
- this->hmac_prf->get_bytes(this->hmac_prf,data,full_mac);
-
- if (signature.len != BLOCK_SIZE)
- {
- return FALSE;
- }
-
- /* compare mac aka signature :-) */
- if (memcmp(signature.ptr,full_mac,BLOCK_SIZE) == 0)
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
-}
-
-/**
- * Implementation of signer_t.get_key_size.
- */
-static size_t get_key_size (private_hmac_signer_t *this)
-{
- /* for HMAC signer, IKEv2 uses block size as key size */
- return this->hmac_prf->get_block_size(this->hmac_prf);
-}
-
-/**
- * Implementation of signer_t.get_block_size.
- */
-static size_t get_block_size (private_hmac_signer_t *this)
-{
- return BLOCK_SIZE;
-}
-
-/**
- * Implementation of signer_t.set_key.
- */
-static void set_key (private_hmac_signer_t *this, chunk_t key)
-{
- this->hmac_prf->set_key(this->hmac_prf,key);
-}
-
-/**
- * Implementation of signer_t.destroy.
- */
-static status_t destroy(private_hmac_signer_t *this)
-{
- this->hmac_prf->destroy(this->hmac_prf);
- allocator_free(this);
- return SUCCESS;
-}
-
-/*
- * Described in header
- */
-hmac_signer_t *hmac_signer_create(hash_algorithm_t hash_algoritm)
-{
- private_hmac_signer_t *this = allocator_alloc_thing(private_hmac_signer_t);
-
- this->hmac_prf = (prf_t *) hmac_prf_create(hash_algoritm);
-
- if (this->hmac_prf == NULL)
- {
- /* algorithm not supported */
- allocator_free(this);
- return NULL;
- }
-
- /* interface functions */
- this->public.signer_interface.get_signature = (void (*) (signer_t*, chunk_t, u_int8_t*))get_signature;
- this->public.signer_interface.allocate_signature = (void (*) (signer_t*, chunk_t, chunk_t*))allocate_signature;
- this->public.signer_interface.verify_signature = (bool (*) (signer_t*, chunk_t, chunk_t))verify_signature;
- this->public.signer_interface.get_key_size = (size_t (*) (signer_t*))get_key_size;
- this->public.signer_interface.get_block_size = (size_t (*) (signer_t*))get_block_size;
- this->public.signer_interface.set_key = (void (*) (signer_t*,chunk_t))set_key;
- this->public.signer_interface.destroy = (void (*) (signer_t*))destroy;
-
- return &(this->public);
-}
diff --git a/Source/charon/transforms/signers/hmac_signer.h b/Source/charon/transforms/signers/hmac_signer.h
deleted file mode 100644
index 8cbe80ecd..000000000
--- a/Source/charon/transforms/signers/hmac_signer.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * @file hmac_signer.h
- *
- * @brief Interface of hmac_signer_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef HMAC_SIGNER_H_
-#define HMAC_SIGNER_H_
-
-#include <transforms/signers/signer.h>
-#include <transforms/hashers/hasher.h>
-
-typedef struct hmac_signer_t hmac_signer_t;
-
-/**
- * @brief Implementation of signer_t interface using the
- * HMAC algorithm in combination with either MD5 or SHA1.
- *
- * @ingroup signers
- */
-struct hmac_signer_t {
-
- /**
- * generic signer_t interface for this signer
- */
- signer_t signer_interface;
-};
-
-/**
- * @brief Creates a new hmac_signer_t.
- *
- * @param hash_algoritm Hash algorithm to use with signer
- * @return
- * - hmac_signer_t
- * - NULL if hash algorithm not supported
- *
- * @ingroup signers
- */
-hmac_signer_t *hmac_signer_create(hash_algorithm_t hash_algoritm);
-
-
-#endif /*HMAC_SIGNER_H_*/
diff --git a/Source/charon/transforms/signers/signer.c b/Source/charon/transforms/signers/signer.c
deleted file mode 100644
index 55e3cfc45..000000000
--- a/Source/charon/transforms/signers/signer.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * @file signer.c
- *
- * @brief Implementation of generic signer_t constructor.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "signer.h"
-
-#include <transforms/signers/hmac_signer.h>
-
-/**
- * String mappings for integrity_algorithm_t.
- */
-mapping_t integrity_algorithm_m[] = {
- {AUTH_UNDEFINED, "AUTH_UNDEFINED"},
- {AUTH_HMAC_MD5_96, "AUTH_HMAC_MD5_96"},
- {AUTH_HMAC_SHA1_96, "AUTH_HMAC_SHA1_96"},
- {AUTH_DES_MAC, "AUTH_DES_MAC"},
- {AUTH_KPDK_MD5, "AUTH_KPDK_MD5"},
- {AUTH_AES_XCBC_96, "AUTH_AES_XCBC_96"},
- {MAPPING_END, NULL}
-};
-
-
-/*
- * Described in header.
- */
-signer_t *signer_create(integrity_algorithm_t integrity_algorithm)
-{
- switch(integrity_algorithm)
- {
- case AUTH_HMAC_SHA1_96:
- {
- return ((signer_t *) hmac_signer_create(HASH_SHA1));
- }
- case AUTH_HMAC_MD5_96:
- {
- return ((signer_t *) hmac_signer_create(HASH_MD5));
- }
- default:
- return NULL;
- }
-}
diff --git a/Source/charon/transforms/signers/signer.h b/Source/charon/transforms/signers/signer.h
deleted file mode 100644
index 9625af813..000000000
--- a/Source/charon/transforms/signers/signer.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/**
- * @file signer.h
- *
- * @brief Interface for signer_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef SIGNER_H_
-#define SIGNER_H_
-
-#include <types.h>
-#include <definitions.h>
-
-typedef enum integrity_algorithm_t integrity_algorithm_t;
-
-/**
- * @brief Integrity algorithm, as in IKEv2 RFC 3.3.2.
- *
- * Currently only the following algorithms are implemented and therefore supported:
- * - AUTH_HMAC_MD5_96
- * - AUTH_HMAC_SHA1_96
- *
- * @ingroup signers
- */
-enum integrity_algorithm_t {
- AUTH_UNDEFINED = 1024,
- /**
- * Implemented in class hmac_signer_t.
- */
- AUTH_HMAC_MD5_96 = 1,
- /**
- * Implemented in class hmac_signer_t.
- */
- AUTH_HMAC_SHA1_96 = 2,
- AUTH_DES_MAC = 3,
- AUTH_KPDK_MD5 = 4,
- AUTH_AES_XCBC_96 = 5
-};
-
-/**
- * String mappings for integrity_algorithm_t.
- */
-extern mapping_t integrity_algorithm_m[];
-
-
-typedef struct signer_t signer_t;
-
-/**
- * @brief Generig interface for a symmetric signature algorithm.
- *
- * @b Constructors:
- * - signer_create()
- * - hmac_signer_create()
- *
- * @todo Implement more integrity algorithms
- *
- * @ingroup signers
- */
-struct signer_t {
- /**
- * @brief Generate a signature.
- *
- * @param this calling object
- * @param data a chunk containing the data to sign
- * @param[out] buffer pointer where the signature will be written
- */
- void (*get_signature) (signer_t *this, chunk_t data, u_int8_t *buffer);
-
- /**
- * @brief Generate a signature and allocate space for it.
- *
- * @param this calling object
- * @param data a chunk containing the data to sign
- * @param[out] chunk chunk which will hold the allocated signature
- */
- void (*allocate_signature) (signer_t *this, chunk_t data, chunk_t *chunk);
-
- /**
- * @brief Verify a signature.
- *
- * @param this calling object
- * @param data a chunk containing the data to verify
- * @param signature a chunk containing the signature
- * @return TRUE, if signature is valid, FALSE otherwise
- */
- bool (*verify_signature) (signer_t *this, chunk_t data, chunk_t signature);
-
- /**
- * @brief Get the block size of this signature algorithm.
- *
- * @param this calling object
- * @return block size in bytes
- */
- size_t (*get_block_size) (signer_t *this);
-
- /**
- * @brief Get the key size of the signature algorithm.
- *
- * @param this calling object
- * @return key size in bytes
- */
- size_t (*get_key_size) (signer_t *this);
-
- /**
- * @brief Set the key for this object.
- *
- * @param this calling object
- * @param key key to set
- */
- void (*set_key) (signer_t *this, chunk_t key);
-
- /**
- * @brief Destroys a signer_t object.
- *
- * @param this calling object
- */
- void (*destroy) (signer_t *this);
-};
-
-/**
- * @brief Creates a new signer_t object.
- *
- * @param integrity_algorithm Algorithm to use for signing and verifying.
- * @return
- * - signer_t object
- * - NULL if signer not supported
- *
- * @ingroup signers
- */
-signer_t *signer_create(integrity_algorithm_t integrity_algorithm);
-
-#endif /*SIGNER_H_*/
diff --git a/Source/charon/types.c b/Source/charon/types.c
deleted file mode 100644
index 47a763e83..000000000
--- a/Source/charon/types.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * @file types.c
- *
- * @brief Generic types.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "types.h"
-
-
-/**
- * String mappings for type status_t.
- */
-mapping_t status_m[] = {
- {SUCCESS, "SUCCESS"},
- {FAILED, "FAILED"},
- {OUT_OF_RES, "OUT_OF_RES"},
- {ALREADY_DONE, "ALREADY_DONE"},
- {NOT_SUPPORTED, "NOT_SUPPORTED"},
- {INVALID_ARG, "INVALID_ARG"},
- {NOT_FOUND, "NOT_FOUND"},
- {PARSE_ERROR, "PARSE_ERROR"},
- {VERIFY_ERROR, "VERIFY_ERROR"},
- {INVALID_STATE, "INVALID_STATE"},
- {DELETE_ME, "DELETE_ME"},
- {CREATED, "CREATED"},
- {MAPPING_END, NULL}
-};
-
-/**
- * Empty chunk.
- */
-chunk_t CHUNK_INITIALIZER = {NULL,0};
diff --git a/Source/charon/types.h b/Source/charon/types.h
deleted file mode 100644
index 9c405dee5..000000000
--- a/Source/charon/types.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/**
- * @file types.h
- *
- * @brief Generic types.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-
-#ifndef TYPES_H_
-#define TYPES_H_
-
-#include <gmp.h>
-#include <sys/types.h>
-#include <stdlib.h>
-
-#include <definitions.h>
-
-
-typedef enum status_t status_t;
-
-/**
- * Return values of function calls.
- */
-enum status_t {
- /**
- * Call succeeded.
- */
- SUCCESS,
-
- /**
- * Call failed.
- */
- FAILED,
-
- /**
- * Out of ressources.
- */
-
- OUT_OF_RES,
- /**
- * Already done.
- */
- ALREADY_DONE,
-
- /**
- * Not supported.
- */
- NOT_SUPPORTED,
-
- /**
- * One of the arguments is invalid.
- */
- INVALID_ARG,
-
- /**
- * Something could not be found.
- */
- NOT_FOUND,
-
- /**
- * Error while parsing.
- */
- PARSE_ERROR,
-
- /**
- * Error while verifying.
- */
- VERIFY_ERROR,
-
- /**
- * Object in invalid state.
- */
- INVALID_STATE,
-
- /**
- * Delete object which function belongs to.
- */
- DELETE_ME,
-
- /**
- * An object got created.
- */
- CREATED,
-};
-
-
-/**
- * String mappings for type status_t.
- */
-extern mapping_t status_m[];
-
-/**
- * Handle struct timeval like an own type.
- */
-typedef struct timeval timeval_t;
-
-/**
- * Handle struct timespec like an own type.
- */
-typedef struct timespec timespec_t;
-
-/**
- * Handle struct chunk_t like an own type.
- */
-typedef struct sockaddr sockaddr_t;
-
-/**
- * Use struct chunk_t as chunk_t.
- */
-typedef struct chunk_t chunk_t;
-
-/**
- * General purpose pointer/length abstraction.
- */
-struct chunk_t {
- /**
- * Pointer to start of data
- */
- u_char *ptr;
-
- /**
- * Length of data in bytes
- */
- size_t len;
-};
-
-/**
- * {NULL, 0}-chunk, handy for initialization
- * of chunks.
- */
-extern chunk_t CHUNK_INITIALIZER;
-
-/**
- * General purpose boolean type.
- */
-typedef int bool;
-#define FALSE 0
-#define TRUE 1
-
-#endif /*TYPES_H_*/
diff --git a/Source/charon/utils/Makefile.utils b/Source/charon/utils/Makefile.utils
deleted file mode 100644
index 01e3bab32..000000000
--- a/Source/charon/utils/Makefile.utils
+++ /dev/null
@@ -1,44 +0,0 @@
-# Copyright (C) 2005 Jan Hutter, Martin Willi
-# Hochschule fuer Technik Rapperswil
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the
-# Free Software Foundation; either version 2 of the License, or (at your
-# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# for more details.
-#
-
-UTILS_DIR= $(MAIN_DIR)utils/
-
-
-OBJS+= $(BUILD_DIR)allocator.o
-$(BUILD_DIR)allocator.o : $(UTILS_DIR)allocator.c $(UTILS_DIR)allocator.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-OBJS+= $(BUILD_DIR)linked_list.o
-$(BUILD_DIR)linked_list.o : $(UTILS_DIR)linked_list.c $(UTILS_DIR)linked_list.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-OBJS+= $(BUILD_DIR)logger.o
-$(BUILD_DIR)logger.o : $(UTILS_DIR)logger.c $(UTILS_DIR)logger.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-OBJS+= $(BUILD_DIR)logger_manager.o
-$(BUILD_DIR)logger_manager.o : $(UTILS_DIR)logger_manager.c $(UTILS_DIR)logger_manager.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-OBJS+= $(BUILD_DIR)randomizer.o
-$(BUILD_DIR)randomizer.o : $(UTILS_DIR)randomizer.c $(UTILS_DIR)randomizer.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-OBJS+= $(BUILD_DIR)tester.o
-$(BUILD_DIR)tester.o : $(UTILS_DIR)tester.c $(UTILS_DIR)tester.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-OBJS+= $(BUILD_DIR)identification.o
-$(BUILD_DIR)identification.o : $(UTILS_DIR)identification.c $(UTILS_DIR)identification.h
- $(CC) $(CFLAGS) -c -o $@ $<
diff --git a/Source/charon/utils/allocator.c b/Source/charon/utils/allocator.c
deleted file mode 100644
index 0ed197c62..000000000
--- a/Source/charon/utils/allocator.c
+++ /dev/null
@@ -1,445 +0,0 @@
-/**
- * @file allocator.c
- *
- * @brief Implementation of allocator_t.
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <stddef.h>
-#include <stdlib.h>
-#include <pthread.h>
-#include <string.h>
-#include <assert.h>
-#include <stdio.h>
-#include <gmp.h>
-
-#include "allocator.h"
-
-
-#ifdef LEAK_DETECTIVE
-
-typedef union memory_hdr_t memory_hdr_t;
-
-/**
- * @brief Header of each allocated memory area.
- *
- * Ideas stolen from pluto's defs.c.
- *
- * Used to detect memory leaks.
- */
-union memory_hdr_t {
- /**
- * Informations.
- */
- struct {
- /**
- * Filename withing memory was allocated.
- */
- const char *filename;
- /**
- * Line number in given file.
- */
- size_t line;
- /**
- * Allocated memory size. Needed for reallocation.
- */
- size_t size_of_memory;
- /**
- * Link to the previous and next memory area.
- */
- memory_hdr_t *older, *newer;
- } info;
- /**
- * Force maximal alignment ?
- *
- */
- unsigned long junk;
-};
-
-typedef struct private_allocator_t private_allocator_t;
-
-/**
- * @brief Private allocator_t object.
- *
- * Contains private variables of allocator_t object.
- */
-struct private_allocator_t
-{
- /**
- * Public part of an allocator_t object.
- */
- allocator_t public;
-
- /**
- * Global list of allocations.
- *
- * Thread-save through mutex.
- */
- memory_hdr_t *allocations;
-
- /**
- * Mutex used to make sure, all functions are thread-save.
- */
- pthread_mutex_t mutex;
-
- /**
- * Number of allocations done
- */
- u_int32_t allocs;
-
- /**
- * Number of frees done
- */
- u_int32_t frees;
-
- /**
- * Allocates memory with LEAK_DETECTION and
- * returns an empty data area filled with zeros.
- *
- * @param this private_allocator_t object
- * @param bytes number of bytes to allocate
- * @param file filename from which the memory is allocated
- * @param line line number in specific file
- * @param use_mutex if FALSE no mutex is used for allocation
- * @return pointer to allocated memory area
- */
- void * (*allocate_special) (private_allocator_t *this,size_t bytes, char * file,int line, bool use_mutex);
-};
-
-/**
- * Implementation of private_allocator_t.allocate_special.
- */
-static void *allocate_special(private_allocator_t *this,size_t bytes, char * file,int line, bool use_mutex)
-{
- memory_hdr_t *allocated_memory = malloc(sizeof(memory_hdr_t) + bytes);
-
- this->allocs++;
-
- if (allocated_memory == NULL)
- {
- /* TODO LOG this case */
- exit(-1);
- }
-
- if (use_mutex)
- {
- pthread_mutex_lock( &(this->mutex));
- }
-
- allocated_memory->info.line = line;
- allocated_memory->info.filename = file;
- allocated_memory->info.size_of_memory = bytes;
- allocated_memory->info.older = this->allocations;
- if (this->allocations != NULL)
- {
- this->allocations->info.newer = allocated_memory;
- }
- this->allocations = allocated_memory;
- allocated_memory->info.newer = NULL;
-
- /* fill memory with zero's */
- memset(allocated_memory+1, '\0', bytes);
- if (use_mutex)
- {
- pthread_mutex_unlock(&(this->mutex));
- }
-
- /* real memory starts after header */
- return (allocated_memory+1);
-}
-
-/**
- * Implementation of allocator_t.allocate.
- */
-static void * allocate(allocator_t *allocator,size_t bytes, char * file,int line)
-{
- private_allocator_t *this = (private_allocator_t *) allocator;
- return (this->allocate_special(this,bytes, file,line,TRUE));
-}
-
-/**
- * Implementation of allocator_t.allocate_as_chunk.
- */
-static chunk_t allocate_as_chunk(allocator_t *allocator,size_t bytes, char * file,int line)
-{
- private_allocator_t *this = (private_allocator_t *) allocator;
- chunk_t new_chunk;
- new_chunk.ptr = this->allocate_special(this,bytes, file,line,TRUE);
- new_chunk.len = (new_chunk.ptr == NULL) ? 0 : bytes;
- return new_chunk;
-}
-
-/**
- * Implementation of allocator_t.free_pointer.
- */
-static void free_pointer(allocator_t *allocator, void * pointer)
-{
- private_allocator_t *this = (private_allocator_t *) allocator;
- memory_hdr_t *allocated_memory;
-
-
- if (pointer == NULL)
- {
- return;
- }
- this->frees++;
- pthread_mutex_lock( &(this->mutex));
- allocated_memory = ((memory_hdr_t *)pointer) - 1;
-
- if (allocated_memory->info.older != NULL)
- {
- assert(allocated_memory->info.older->info.newer == allocated_memory);
- allocated_memory->info.older->info.newer = allocated_memory->info.newer;
- }
- if (allocated_memory->info.newer == NULL)
- {
- assert(allocated_memory == this->allocations);
- this->allocations = allocated_memory->info.older;
- }
- else
- {
- assert(allocated_memory->info.newer->info.older == allocated_memory);
- allocated_memory->info.newer->info.older = allocated_memory->info.older;
- }
- pthread_mutex_unlock(&(this->mutex));
- free(allocated_memory);
-}
-
-/**
- * Implementation of allocator_t.reallocate.
- */
-static void * reallocate(allocator_t *allocator, void * old, size_t bytes, char * file,int line)
-{
- private_allocator_t *this = (private_allocator_t *) allocator;
- memory_hdr_t *allocated_memory;
-
-
- pthread_mutex_lock( &(this->mutex));
- allocated_memory = ((memory_hdr_t *)old) - 1;
-
- void *new_space = this->allocate_special(this,bytes,file,line,FALSE);
-
- if (old != NULL)
- {
- /* the smaller size is copied to avoid overflows */
- memcpy(new_space,old,(allocated_memory->info.size_of_memory < bytes) ? allocated_memory->info.size_of_memory : bytes);
- }
- pthread_mutex_unlock(&(this->mutex));
- this->public.free_pointer(&(this->public),old);
-
- return new_space;
-}
-
-/**
- * Implementation of allocator_t.clone_bytes.
- */
-static void * clone_bytes(allocator_t *allocator,void * to_clone, size_t bytes, char * file, int line)
-{
- private_allocator_t *this = (private_allocator_t *) allocator;
-
- if (to_clone == NULL)
- {
- return NULL;
- }
-
-
- void *new_space = this->allocate_special(this,bytes,file,line,TRUE);
-
- if (new_space == NULL)
- {
- return NULL;
- }
-
- memcpy(new_space,to_clone,bytes);
-
- return new_space;
-}
-
-/**
- * Implementation of allocator_t.clone_chunk.
- */
-static chunk_t clone_chunk(allocator_t *allocator, chunk_t chunk, char * file, int line)
-{
- private_allocator_t *this = (private_allocator_t *) allocator;
- chunk_t clone = CHUNK_INITIALIZER;
-
- if (chunk.ptr && chunk.len > 0)
- {
- clone.ptr = this->allocate_special(this,chunk.len,file,line,TRUE);
- clone.len = chunk.len;
- memcpy(clone.ptr, chunk.ptr, chunk.len);
- }
-
- return clone;
-}
-
-/**
- * Implementation of allocator_t.allocator_report_memory_leaks.
- */
-static void allocator_report_memory_leaks(allocator_t *allocator)
-{
- private_allocator_t *this = (private_allocator_t *) allocator;
- memory_hdr_t *p = this->allocations;
- memory_hdr_t *pprev = NULL;
- unsigned long n = 0;
-
- pthread_mutex_lock(&(this->mutex));
-
- while (p != NULL)
- {
- assert(pprev == p->info.newer);
- pprev = p;
- p = p->info.older;
- n++;
- if (p == NULL || pprev->info.filename != p->info.filename)
- {
- if (n != 1)
- fprintf(stderr,"LEAK: \"%lu * %s, line %d\"\n", n, pprev->info.filename,pprev->info.line);
- else
- fprintf(stderr,"LEAK: \"%s, line %d\"\n", pprev->info.filename,pprev->info.line);
- n = 0;
- }
- }
- pthread_mutex_unlock( &(this->mutex));
- fprintf(stderr, "Allocator statistics: %d allocs, %d frees\n", this->allocs, this->frees);
-}
-
-/**
- * Only Initiation of allocator object.
- *
- * All allocation macros use this object.
- */
-static private_allocator_t allocator = {
- public: {allocate: allocate,
- allocate_as_chunk: allocate_as_chunk,
- free_pointer: free_pointer,
- reallocate: reallocate,
- clone_bytes : clone_bytes,
- clone_chunk : clone_chunk,
- report_memory_leaks: allocator_report_memory_leaks},
- allocations: NULL,
- allocate_special : allocate_special,
- mutex: PTHREAD_MUTEX_INITIALIZER,
- allocs: 0,
- frees: 0
-};
-
-
-allocator_t *global_allocator = &(allocator.public);
-
-/*
- * Alloc function for gmp.
- */
-void *gmp_alloc(size_t bytes)
-{
- return allocator.allocate_special(&allocator, bytes, "[ gmp internal ]", 0 , TRUE);
-}
-
-/*
- * Realloc function for gmp.
- */
-void *gmp_realloc(void *old, size_t old_bytes, size_t new_bytes)
-{
- return global_allocator->reallocate(global_allocator, old, new_bytes, "[ gmp internal ]", 0);
-}
-/*
- * Free function for gmp.
- */
-void gmp_free(void *ptr, size_t bytes)
-{
- free_pointer(global_allocator, ptr);
-}
-
-/*
- * Described in header
- */
-void allocator_init()
-{
- mp_set_memory_functions (gmp_alloc, gmp_realloc, gmp_free);
-}
-
-#else /* !LEAK_DETECTION */
-
-/*
- * Described in header.
- */
-chunk_t allocator_alloc_as_chunk(size_t bytes)
-{
- chunk_t new_chunk;
- new_chunk.ptr = malloc(bytes);
- if (new_chunk.ptr == NULL)
- {
- exit(-1);
- }
- new_chunk.len = bytes;
- return new_chunk;
-
-}
-
-/*
- * Described in header.
- */
-void * allocator_realloc(void * old, size_t newsize)
-{
- void *data = realloc(old,newsize);
- return data;
-}
-
-/*
- * Described in header.
- */
-void * allocator_clone_bytes(void * pointer, size_t size)
-{
-
- void *data;
- data = malloc(size);
-
- if (data == NULL){exit(-1);}
- memmove(data,pointer,size);
-
- return (data);
-}
-
-/**
- * Described in header.
- */
-chunk_t allocator_clone_chunk(chunk_t chunk)
-{
- chunk_t clone = CHUNK_INITIALIZER;
-
- if (chunk.ptr && chunk.len > 0)
- {
- clone.ptr = malloc(chunk.len);
- if (clone.ptr == NULL) {exit(-1);}
- clone.len = chunk.len;
- memcpy(clone.ptr, chunk.ptr, chunk.len);
- }
-
- return clone;
-}
-
-/*
- * Described in header.
- */
-void allocator_free_chunk(chunk_t *chunk)
-{
- free(chunk->ptr);
- chunk->ptr = NULL;
- chunk->len = 0;
-}
-
-#endif /* LEAK_DETECTION */
diff --git a/Source/charon/utils/allocator.h b/Source/charon/utils/allocator.h
deleted file mode 100644
index 5b00496f6..000000000
--- a/Source/charon/utils/allocator.h
+++ /dev/null
@@ -1,324 +0,0 @@
-/**
- * @file allocator.h
- *
- * @brief Interface of allocator_t.
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef ALLOCATOR_H_
-#define ALLOCATOR_H_
-
-#include <stdlib.h>
-#include <stddef.h>
-#include <string.h>
-
-#include <types.h>
-
-
-/**
- * Macro to allocate a special type.
- *
- * @param thing object on which a sizeof is performed
- * @return pointer to allocated memory
- *
- * @ingroup utils
- */
-#define allocator_alloc_thing_as_chunk(thing) (allocator_alloc_as_chunk(sizeof(thing)))
-
-/**
- * Macro to allocate a special type as chunk_t.
- *
- * @param thing object on which a sizeof is performed
- * @return chunk_t pointing to allocated memory
- *
- * @ingroup utils
- */
-#define allocator_alloc_thing(thing) (allocator_alloc(sizeof(thing)))
-
-#ifdef LEAK_DETECTIVE
-
- typedef struct allocator_t allocator_t;
-
- /**
- *@brief Allocater object use to detect memory leaks.
- *
- * @ingroup utils
- */
- struct allocator_t {
-
- /**
- * Allocates memory with LEAK_DETECTION and
- * returns an empty data area filled with zeros.
- *
- * @warning Use this function not directly, only with assigned macros
- * #allocator_alloc and #allocator_alloc_thing.
- *
- * @param this allocator_t object
- * @param bytes number of bytes to allocate
- * @param file filename from which the memory is allocated
- * @param line line number in specific file
- * @return pointer to allocated memory area
- */
- void * (*allocate) (allocator_t *this,size_t bytes, char * file,int line);
-
- /**
- * Allocates memory with LEAK_DETECTION and
- * returns an chunk pointing to an empy data area filled with zeros.
- *
- * @warning Use this function not directly, only with assigned
- * macros #allocator_alloc_as_chunk and
- * #allocator_alloc_thing_as_chunk.
- *
- * @param this allocator_t object
- * @param bytes number of bytes to allocate
- * @param file filename from which the memory is allocated
- * @param line line number in specific file
- * @return pointer to allocated memory area
- */
- chunk_t (*allocate_as_chunk) (allocator_t *this,size_t bytes, char * file,int line);
-
- /**
- * Reallocates memory with LEAK_DETECTION and
- * returns an empty data area filled with zeros.
- *
- * @warning Use this function not directly, only with assigned macro
- * #allocator_realloc.
- *
- * @param this allocator_t object
- * @param old pointer to the old data area
- * @param bytes number of bytes to allocate
- * @param file filename from which the memory is allocated
- * @param line line number in specific file
- * @return pointer to reallocated memory area
- */
- void * (*reallocate) (allocator_t *this,void * old, size_t bytes, char * file, int line);
-
- /**
- * Clones memory with LEAK_DETECTION and returns a cloned data area.
- *
- * @warning Use this function not directly, only with assigned macro
- * #allocator_clone_bytes.
- *
- * @param this allocator_t object
- * @param old pointer to the old data area
- * @param bytes number of bytes to allocate
- * @param file filename from which the memory is allocated
- * @param line line number in specific file
- * @return pointer to reallocated memory area
- */
- void * (*clone_bytes) (allocator_t *this,void * to_clone, size_t bytes, char * file, int line);
-
- /**
- * Clones a chunk with LEAK_DETECTION and returns a cloned chunk.
- *
- * @warning Use this function not directly, only with assigned macro
- * #allocator_clone_chunk-
- *
- * @param this allocator_t object
- * @param chunk chunk to clone
- * @param file filename from which the memory is allocated
- * @param line line number in specific file
- * @return pointer to reallocated memory
- */
- chunk_t (*clone_chunk) (allocator_t *this, chunk_t chunk, char * file, int line);
-
- /**
- * Frees memory with LEAK_DETECTION.
- *
- * @warning Use this function not directly, only with assigned macro
- * #allocator_free.
- *
- * @param this allocator_t object
- * @param pointer pointer to the data area to free
- */
- void (*free_pointer) (allocator_t *this,void * pointer);
-
- /**
- * Report memory leaks to stderr.
- *
- * @warning Use this function not directly, only with assigned macro
- * #report_memory_leaks
- *
- * @param this allocator_t object
- */
- void (*report_memory_leaks) (allocator_t *this);
- };
-
-
- /**
- * @brief Initialize the allocator.
- *
- * Setup the allocator (set allocation functions for libgmp)
- */
- void allocator_init();
-
- /**
- * @brief Global allocater_t object.
- *
- * Only accessed over macros.
- */
- extern allocator_t *global_allocator;
-
-
- /**
- * Macro to allocate some memory.
- *
- * See #allocator_t.allocate for description.
- *
- * @ingroup utils
- */
- #define allocator_alloc(bytes) (global_allocator->allocate(global_allocator,bytes,__FILE__,__LINE__))
-
- /**
- * Macro to allocate some memory for a chunk_t.
- *
- * See #allocator_t.allocate_as_chunk for description.
- *
- * @ingroup utils
- */
- #define allocator_alloc_as_chunk(bytes) (global_allocator->allocate_as_chunk(global_allocator,bytes,__FILE__,__LINE__))
-
- /**
- * Macro to reallocate some memory.
- *
- * See #allocator_t.reallocate for description.
- *
- * @ingroup utils
- */
- #define allocator_realloc(old,bytes) (global_allocator->reallocate(global_allocator,old,bytes,__FILE__, __LINE__))
-
- /**
- * Macro to clone some memory.
- *
- * See #allocator_t.*clone_bytes for description.
- *
- * @ingroup utils
- */
- #define allocator_clone_bytes(old,bytes) (global_allocator->clone_bytes(global_allocator,old,bytes,__FILE__, __LINE__))
-
- /**
- * Macro to clone a chunk and its contents
- *
- * See #allocator_t.clone_chunk for description.
- *
- * @ingroup utils
- */
- #define allocator_clone_chunk(chunk) (global_allocator->clone_chunk(global_allocator,chunk,__FILE__, __LINE__))
-
- /**
- * Macro to free some memory.
- *
- * See #allocator_t.free_pointer for description.
- *
- * @ingroup utils
- */
- #define allocator_free(pointer) (global_allocator->free_pointer(global_allocator,pointer))
-
- /**
- * Macro to free a chunk.
- */
- #define allocator_free_chunk(chunk){ \
- global_allocator->free_pointer(global_allocator,(chunk)->ptr); \
- (chunk)->ptr = NULL; \
- (chunk)->len = 0; \
- }
-
- /**
- * Macro to report memory leaks.
- *
- * See #allocator_s.report_memory_leaks for description.
- *
- * @ingroup utils
- */
- #define report_memory_leaks(void) (global_allocator->report_memory_leaks(global_allocator))
-#else
-
- /**
- * Macro to allocate some memory.
- *
- * @ingroup utils
- */
- #define allocator_alloc(bytes) (malloc(bytes))
-
- /**
- * Allocate some memory as chunk.
- *
- * @ingroup utils
- */
- chunk_t allocator_alloc_as_chunk(size_t bytes);
-
- /**
- * Reallocate some memory.
- *
- * @ingroup utils
- */
- void * allocator_realloc(void * old, size_t newsize);
-
- /**
- * Free allocated memory.
- *
- * @ingroup utils
- */
- #define allocator_free(pointer) (free(pointer))
-
- /**
- * Clone bytes.
- *
- *
- * @param pointer pointer to read data from
- * @param size number of bytes to clone
- *
- * @ingroup utils
- */
- void * allocator_clone_bytes(void * pointer, size_t size);
-
- /**
- * Clone a chunk and its contents.
- *
- *
- * @param chunk chunk to clone
- * @return cloned chunk
- *
- * @ingroup utils
- */
- chunk_t allocator_clone_chunk(chunk_t chunk);
-
- /**
- * Frees memory used by chunk.
- *
- * @param chunk pointer of chunk to free
- *
- * @ingroup utils
- */
- void allocator_free_chunk(chunk_t *chunk);
-
- /**
- * Report memory leaks.
- *
- * @ingroup utils
- */
- #define report_memory_leaks() {}
-
- /**
- * Initialize the allocator.
- *
- * @ingroup utils
- */
- #define allocator_init() {}
-#endif
-
-#endif /*ALLOCATOR_H_*/
diff --git a/Source/charon/utils/identification.c b/Source/charon/utils/identification.c
deleted file mode 100644
index 72d1610af..000000000
--- a/Source/charon/utils/identification.c
+++ /dev/null
@@ -1,291 +0,0 @@
-/**
- * @file identification.c
- *
- * @brief Implementation of identification_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include "identification.h"
-
-#include <utils/allocator.h>
-
-/**
- * String mappings for id_type_t.
- */
-mapping_t id_type_m[] = {
- {ID_IPV4_ADDR, "ID_IPV4_ADDR"},
- {ID_FQDN, "ID_FQDN"},
- {ID_RFC822_ADDR, "ID_RFC822_ADDR"},
- {ID_IPV6_ADDR, "ID_IPV6_ADDR"},
- {ID_DER_ASN1_DN, "ID_DER_ASN1_DN"},
- {ID_DER_ASN1_GN, "ID_DER_ASN1_GN"},
- {ID_KEY_ID, "ID_KEY_ID"},
- {MAPPING_END, NULL}
-};
-
-
-typedef struct private_identification_t private_identification_t;
-
-/**
- * Private data of an identification_t object.
- */
-struct private_identification_t {
- /**
- * Public interface.
- */
- identification_t public;
-
- /**
- * String representation of this ID.
- */
- char *string;
-
- /**
- * Encoded representation of this ID.
- */
- chunk_t encoded;
-
- /**
- * Type of this ID.
- */
- id_type_t type;
-};
-
-static private_identification_t *identification_create();
-
-/**
- * Implementation of identification_t.get_encoding.
- */
-static chunk_t get_encoding(private_identification_t *this)
-{
- return this->encoded;
-}
-
-/**
- * Implementation of identification_t.get_type.
- */
-static id_type_t get_type(private_identification_t *this)
-{
- return this->type;
-}
-
-/**
- * Implementation of identification_t.get_string.
- */
-static char *get_string(private_identification_t *this)
-{
- return this->string;
-}
-
-/**
- * Implementation of identification_t.equals.
- */
-static bool equals (private_identification_t *this,private_identification_t *other)
-{
- if (this->type == other->type)
- {
- if (this->encoded.len != other->encoded.len)
- {
- return FALSE;
- }
- if (memcmp(this->encoded.ptr,other->encoded.ptr,this->encoded.len) == 0)
- {
- return TRUE;
- }
- }
- return FALSE;
-}
-
-/**
- * Implementation of identification_t.belongs_to.
- */
-static bool belongs_to(private_identification_t *this, private_identification_t *other)
-{
- if (this->public.equals(&this->public, &other->public))
- {
- return TRUE;
- }
-
- if (this->type == other->type && this->type == ID_IPV4_ADDR)
- {
- /* is this %any (0.0.0.0)?*/
- if (*((u_int32_t*)this->encoded.ptr) == 0)
- {
- return TRUE;
- }
- /* TODO: Do we need subnet support? */
- }
- return FALSE;
-}
-
-/**
- * Implementation of identification_t.clone.
- */
-static identification_t *clone(private_identification_t *this)
-{
- private_identification_t *clone = identification_create();
-
- clone->type = this->type;
- clone->encoded = allocator_clone_chunk(this->encoded);
- clone->string = allocator_alloc(strlen(this->string) + 1);
- strcpy(clone->string, this->string);
-
- return &clone->public;
-}
-
-/**
- * Implementation of identification_t.destroy.
- */
-static void destroy(private_identification_t *this)
-{
- allocator_free(this->string);
- allocator_free(this->encoded.ptr);
- allocator_free(this);
-}
-
-/*
- * Generic constructor used for the other constructors.
- *
- * @return private_identification_t object
- */
-static private_identification_t *identification_create()
-{
- private_identification_t *this = allocator_alloc_thing(private_identification_t);
-
- this->public.equals = (bool (*) (identification_t*,identification_t*))equals;
- this->public.belongs_to = (bool (*) (identification_t*,identification_t*))belongs_to;
- this->public.get_encoding = (chunk_t (*) (identification_t*))get_encoding;
- this->public.get_type = (id_type_t (*) (identification_t*))get_type;
- this->public.get_string = (char* (*) (identification_t*))get_string;
- this->public.clone = (identification_t* (*) (identification_t*))clone;
- this->public.destroy = (void (*) (identification_t*))destroy;
-
- this->string = NULL;
- this->encoded = CHUNK_INITIALIZER;
-
- return this;
-}
-
-
-/*
- * Described in header.
- */
-identification_t *identification_create_from_string(id_type_t type, char *string)
-{
- private_identification_t *this = identification_create();
-
- this->type = type;
- switch (type)
- {
- case ID_IPV4_ADDR:
- {
- /* convert string */
- this->encoded.len = 4;
- this->encoded.ptr = allocator_alloc(this->encoded.len);
- if (inet_aton(string, ((struct in_addr*)(this->encoded.ptr))) == 0)
- {
- allocator_free(this->encoded.ptr);
- allocator_free(this);
- return NULL;
- }
- /* clone string */
- this->string = allocator_alloc(strlen(string)+1);
- strcpy(this->string, string);
- return &(this->public);
- }
- case ID_IPV6_ADDR:
- case ID_FQDN:
- case ID_RFC822_ADDR:
- case ID_DER_ASN1_DN:
- case ID_DER_ASN1_GN:
- case ID_KEY_ID:
- default:
- {
- /* not supported */
- allocator_free(this);
- return NULL;
- }
- }
-}
-
-/*
- * Described in header.
- */
-identification_t *identification_create_from_encoding(id_type_t type, chunk_t encoded)
-{
- char *string;
- private_identification_t *this = identification_create();
-
- this->encoded = allocator_clone_chunk(encoded);
-
- this->type = type;
- switch (type)
- {
- case ID_IPV4_ADDR:
- {
- string = inet_ntoa(*((struct in_addr*)(encoded.ptr)));
- break;
- }
- case ID_IPV6_ADDR:
- {
- string = "[ID_IPV6_ADDR]";
- break;
- }
- case ID_FQDN:
- {
- string = "[ID_FQDN]";
- break;
- }
- case ID_RFC822_ADDR:
- {
- string = "[ID_RFC822_ADDR]";
- break;
- }
- case ID_DER_ASN1_DN:
- {
- string = "[ID_DER_ASN1_DN]";
- break;
- }
- case ID_DER_ASN1_GN:
- {
- string = "[ID_DER_ASN1_GN]";
- break;
- }
- case ID_KEY_ID:
- {
- string = "[ID_KEY_ID]";
- break;
- }
- default:
- {
- string = "[unknown id_type_t]";
- }
- }
-
- /* build string, must be cloned since
- * inet_ntoa points to a subsequently
- * overwritten buffer */
- this->string = allocator_alloc(strlen(string)+1);
- strcpy(this->string, string);
-
- return &(this->public);
-}
diff --git a/Source/charon/utils/identification.h b/Source/charon/utils/identification.h
deleted file mode 100644
index b973da9a4..000000000
--- a/Source/charon/utils/identification.h
+++ /dev/null
@@ -1,211 +0,0 @@
-/**
- * @file identification.h
- *
- * @brief Interface of identification_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-
-#ifndef IDENTIFICATION_H_
-#define IDENTIFICATION_H_
-
-
-#include "types.h"
-
-typedef enum id_type_t id_type_t;
-
-/**
- * @brief ID Types in a ID payload.
- *
- * @see
- * - identification_t
- * - id_payload_t
- *
- * @ingroup utils
- */
-enum id_type_t {
-
- /**
- * ID data is a single four (4) octet IPv4 address.
- */
- ID_IPV4_ADDR = 1,
-
- /**
- * ID data is a fully-qualified domain name string.
- * An example of a ID_FQDN is, "example.com".
- * The string MUST not contain any terminators (e.g., NULL, CR, etc.).
- */
- ID_FQDN = 2,
-
- /**
- * ID data is a fully-qualified RFC822 email address string, An example of
- * a ID_RFC822_ADDR is, "jsmith@example.com". The string MUST
- * not contain any terminators.
- */
- ID_RFC822_ADDR = 3,
-
- /**
- * ID data is a single sixteen (16) octet IPv6 address.
- */
- ID_IPV6_ADDR = 5,
-
- /**
- * ID data is the binary DER encoding of an ASN.1 X.500 Distinguished Name
- * [X.501].
- */
- ID_DER_ASN1_DN = 9,
-
- /**
- * ID data is the binary DER encoding of an ASN.1 X.500 GeneralName
- * [X.509].
- */
- ID_DER_ASN1_GN = 10,
-
- /**
- * ID data is an opaque octet stream which may be used to pass vendor-
- * specific information necessary to do certain proprietary
- * types of identification.
- */
- ID_KEY_ID = 11
-};
-
-/**
- * String mappings for id_type_t.
- */
-extern mapping_t id_type_m[];
-
-typedef struct identification_t identification_t;
-
-/**
- * @brief Generic identification, such as used in ID payload.
- *
- * The following types are possible:
- * - ID_IPV4_ADDR
- * - ID_FQDN*
- * - ID_RFC822_ADDR*
- * - ID_IPV6_ADDR*
- * - ID_DER_ASN1_DN*
- * - ID_DER_ASN1_GN*
- * - ID_KEY_ID*
- * (* = string conversion not supported)
- *
- * @b Constructors:
- * - identification_create_from_string()
- * - identification_create_from_encoding()
- *
- * @todo Support for other ID types then ID_IPV4_ADDR.
- *
- * @ingroup utils
- */
-struct identification_t {
-
- /**
- * @brief Get the encoding of this id, to send over
- * the network.
- *
- * @warning Result points to internal data, do NOT free!
- *
- * @param this the identification_t object
- * @return a chunk containing the encoded bytes
- */
- chunk_t (*get_encoding) (identification_t *this);
-
- /**
- * @brief Get the type of this identification.
- *
- * @param this the identification_t object
- * @return id_type_t
- */
- id_type_t (*get_type) (identification_t *this);
-
- /**
- * @brief Get a string representation of this id.
- *
- * @warning Result points to internal data, do NOT free!
- *
- * @param this the identification_t object
- * @return string
- */
- char *(*get_string) (identification_t *this);
-
- /**
- * @brief Check if two identification_t objects are equal.
- *
- * @param this the identification_t object
- * @param other other identification_t object
- * @return TRUE if the IDs are equal
- */
- bool (*equals) (identification_t *this,identification_t *other);
-
- /**
- * @brief Check if an ID belongs to a wildcard ID.
- *
- * An identification_t may contain wildcards, such as
- * *@strongswan.org. This call checks if a given ID
- * (e.g. tester@strongswan.org) belongs to a such wildcard
- * ID. Returns TRUE if IDs are identical.
- *
- * @param this the ID containing a wildcard
- * @param other the ID without wildcard
- * @return TRUE if other belongs to this
- */
- bool (*belongs_to) (identification_t *this, identification_t *other);
-
- /**
- * @brief Clone a identification_t instance.
- *
- * @param this the identification_t object to clone
- * @return clone of this
- */
- identification_t *(*clone) (identification_t *this);
-
- /**
- * @brief Destroys a identification_t object.
- *
- * @param this identification_t object
- */
- void (*destroy) (identification_t *this);
-};
-
-/**
- * @brief Creates an identification_t object from a string.
- *
- * @param type type of this id, such as ID_IPV4_ADDR
- * @param string input string, which will be converted
- * @return
- * - created identification_t object, or
- * - NULL if type not supported.
- *
- * @ingroup utils
- */
-identification_t * identification_create_from_string(id_type_t type, char *string);
-
-
-/**
- * @brief Creates an identification_t object from an encoded chunk.
- *
- * @param type type of this id, such as ID_IPV4_ADDR
- * @param encoded encoded bytes, such as from identification_t.get_encoding
- * @return identification_t object
- *
- * @ingroup utils
- */
-identification_t * identification_create_from_encoding(id_type_t type, chunk_t encoded);
-
-
-#endif /* IDENTIFICATION_H_ */
diff --git a/Source/charon/utils/iterator.h b/Source/charon/utils/iterator.h
deleted file mode 100644
index de81db8e9..000000000
--- a/Source/charon/utils/iterator.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/**
- * @file iterator.h
- *
- * @brief Interface iterator_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef ITERATOR_H_
-#define ITERATOR_H_
-
-typedef struct iterator_t iterator_t;
-
-/**
- * @brief Iterator interface, allows iteration over collections.
- *
- * iterator_t defines an interface for iterating over collections.
- * It allows searching, deleting, updating and inserting.
- *
- * Thanks to JMP for iterator lessons :-)
- *
- * @b Constructors:
- * - via linked_list_t.create_iterator, or
- * - any other class which supports the iterator_t interface
- *
- * @see linked_list_t
- *
- * @ingroup utils
- */
-struct iterator_t {
-
- /**
- * @brief Iterate over all items.
- *
- * The easy way to iterate over items.
- *
- * @param this calling object
- * @param[out] value item
- * @return
- * - TRUE, if more elements are avaiable,
- * - FALSE otherwise
- */
- bool (*iterate) (iterator_t *this, void** value);
-
- /**
- * @brief Moves to the next element, if available.
- *
- * A newly created iterator_t object doesn't point to any item.
- * Call iterator_t.has_next first to point it to the first item.
- *
- * @param this calling object
- * @return
- * - TRUE, if more elements are avaiable,
- * - FALSE otherwise
- */
- bool (*has_next) (iterator_t *this);
-
- /**
- * @brief Returns the current value at the iterator position.
- *
- * @param this calling object
- * @param[out] value value is set to the current value at iterator position
- * @return
- * - SUCCESS
- * - FAILED if iterator on an invalid position
- */
- status_t (*current) (iterator_t *this, void **value);
-
- /**
- * @brief Inserts a new item before the given iterator position.
- *
- * The iterator position is not changed after inserting
- *
- * @param this calling iterator
- * @param[in] item value to insert in list
- */
- void (*insert_before) (iterator_t *this, void *item);
-
- /**
- * @brief Inserts a new item after the given iterator position.
- *
- * The iterator position is not changed after inserting.
- *
- * @param this calling iterator
- * @param[in] item value to insert in list
- */
- void (*insert_after) (iterator_t *this, void *item);
-
- /**
- * @brief Replace the current item at current iterator position.
- *
- * The iterator position is not changed after replacing.
- *
- * @param this calling iterator
- * @param[out] old_item old value will be written here(can be NULL)
- * @param[in] new_item new value
- *
- * @return
- * - SUCCESS
- * - FAILED if iterator is on an invalid position
- */
- status_t (*replace) (iterator_t *this, void **old_item, void *new_item);
-
- /**
- * @brief Removes an element from list at the given iterator position.
- *
- * The position of the iterator is set in the following order:
- * - to the item before, if available
- * - otherwise to the item after, if available
- * - otherwise it gets reseted
- *
- * @param linked_list calling object
- * @return
- * - SUCCESS
- * - FAILED if iterator is on an invalid position
- */
- status_t (*remove) (iterator_t *iterator);
-
- /**
- * @brief Resets the iterator position.
- *
- * After reset, the iterator_t objects doesn't point to an element.
- * A call to iterator_t.has_next is necessary to do any other operations
- * with the resetted iterator.
- *
- * @param this calling object
- */
- void (*reset) (iterator_t *this);
-
- /**
- * @brief Destroys an iterator.
- *
- * @param this iterator to destroy
- *
- */
- void (*destroy) (iterator_t *this);
-};
-
-#endif /*ITERATOR_H_*/
diff --git a/Source/charon/utils/linked_list.c b/Source/charon/utils/linked_list.c
deleted file mode 100644
index 7ad07dbdd..000000000
--- a/Source/charon/utils/linked_list.c
+++ /dev/null
@@ -1,729 +0,0 @@
-/**
- * @file linked_list.c
- *
- * @brief Implementation of linked_list_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <stdlib.h>
-
-#include "linked_list.h"
-
-#include <utils/allocator.h>
-
-
-
-typedef struct linked_list_element_t linked_list_element_t;
-
-/**
- * @brief Element in a linked list.
- *
- * This element holds a pointer to the value it represents.
- */
-struct linked_list_element_t {
-
- /**
- * Value of a list item.
- */
- void *value;
-
- /**
- * Previous list element.
- *
- * NULL if first element in list.
- */
- linked_list_element_t *previous;
-
- /**
- * Next list element.
- *
- * NULL if last element in list.
- */
- linked_list_element_t *next;
-
- /**
- * Destroys a linked_list_element object.
- *
- * @param linked_list_element_t calling object
- */
- void (*destroy) (linked_list_element_t *this);
-};
-
-/**
- * Implementation of linked_list_element_t.destroy.
- */
-static void linked_list_element_destroy(linked_list_element_t *this)
-{
- allocator_free(this);
-}
-
-/**
- * @brief Creates an empty linked list object.
- *
- * @warning Only the pointer to the value is stored.
- *
- * @param[in] value value of item to be set
- * @return linked_list_element_t object
- */
-
-linked_list_element_t *linked_list_element_create(void *value)
-{
- linked_list_element_t *this = allocator_alloc_thing(linked_list_element_t);
-
- this->destroy = linked_list_element_destroy;
-
- this->previous=NULL;
- this->next=NULL;
- this->value = value;
-
- return (this);
-}
-
-
-typedef struct private_linked_list_t private_linked_list_t;
-
-/**
- * Private data of a linked_list_t object.
- *
- */
-struct private_linked_list_t {
- /**
- * Public part of linked list.
- */
- linked_list_t public;
-
- /**
- * Number of items in the list.
- */
- int count;
-
- /**
- * First element in list.
- * NULL if no elements in list.
- */
- linked_list_element_t *first;
-
- /**
- * Last element in list.
- * NULL if no elements in list.
- */
- linked_list_element_t *last;
-};
-
-
-typedef struct private_iterator_t private_iterator_t;
-
-/**
- * Private variables and functions of linked list iterator.
- */
-struct private_iterator_t {
- /**
- * Public part of linked list iterator.
- */
- iterator_t public;
-
- /**
- * Associated linked list.
- */
- private_linked_list_t * list;
-
- /**
- * Current element of the iterator.
- */
- linked_list_element_t *current;
-
- /**
- * Direction of iterator.
- */
- bool forward;
-};
-
-/**
- * Implementation of iterator_t.has_next.
- */
-static bool iterate(private_iterator_t *this, void** value)
-{
- if (this->list->count == 0)
- {
- return FALSE;
- }
- if (this->current == NULL)
- {
- this->current = (this->forward) ? this->list->first : this->list->last;
- *value = this->current->value;
- return TRUE;
- }
- if (this->forward)
- {
- if (this->current->next == NULL)
- {
- return FALSE;
- }
- this->current = this->current->next;
- *value = this->current->value;
- return TRUE;
- }
- /* backward */
- if (this->current->previous == NULL)
- {
- return FALSE;
- }
- this->current = this->current->previous;
- *value = this->current->value;
- return TRUE;
-}
-
-/**
- * Implementation of iterator_t.has_next.
- */
-static bool iterator_has_next(private_iterator_t *this)
-{
- if (this->list->count == 0)
- {
- return FALSE;
- }
- if (this->current == NULL)
- {
- this->current = (this->forward) ? this->list->first : this->list->last;
- return TRUE;
- }
- if (this->forward)
- {
- if (this->current->next == NULL)
- {
- return FALSE;
- }
- this->current = this->current->next;
- return TRUE;
- }
- /* backward */
- if (this->current->previous == NULL)
- {
- return FALSE;
- }
- this->current = this->current->previous;
- return TRUE;
-}
-
-/**
- * Implementation of iterator_t.current.
- */
-static status_t iterator_current(private_iterator_t *this, void **value)
-{
- if (this->current == NULL)
- {
- return NOT_FOUND;
- }
- *value = this->current->value;
- return SUCCESS;
-}
-
-/**
- * Implementation of iterator_t.reset.
- */
-static void iterator_reset(private_iterator_t *this)
-{
- this->current = NULL;
-}
-
-/**
- * Implementation of iterator_t.remove.
- */
-static status_t remove(private_iterator_t *this)
-{
- linked_list_element_t *new_current;
-
- if (this->current == NULL)
- {
- return NOT_FOUND;
- }
-
- if (this->list->count == 0)
- {
- return NOT_FOUND;
- }
- /* find out the new iterator position */
- if (this->current->previous != NULL)
- {
- new_current = this->current->previous;
- }
- else if (this->current->next != NULL)
- {
- new_current = this->current->next;
- }
- else
- {
- new_current = NULL;
- }
-
- /* now delete the entry :-) */
- if (this->current->previous == NULL)
- {
- if (this->current->next == NULL)
- {
- this->list->first = NULL;
- this->list->last = NULL;
- }
- else
- {
- this->current->next->previous = NULL;
- this->list->first = this->current->next;
- }
- }
- else if (this->current->next == NULL)
- {
- this->current->previous->next = NULL;
- this->list->last = this->current->previous;
- }
- else
- {
- this->current->previous->next = this->current->next;
- this->current->next->previous = this->current->previous;
- }
-
- this->list->count--;
- this->current->destroy(this->current);
- /* set the new iterator position */
- this->current = new_current;
- return SUCCESS;
-}
-
-/**
- * Implementation of iterator_t.insert_before.
- */
-static void insert_before(private_iterator_t * iterator, void *item)
-{
- if (iterator->current == NULL)
- {
- iterator->list->public.insert_first(&(iterator->list->public), item);
- }
-
- linked_list_element_t *element =(linked_list_element_t *) linked_list_element_create(item);
-
- if (iterator->current->previous == NULL)
- {
- iterator->current->previous = element;
- element->next = iterator->current;
- iterator->list->first = element;
- }
- else
- {
- iterator->current->previous->next = element;
- element->previous = iterator->current->previous;
- iterator->current->previous = element;
- element->next = iterator->current;
- }
-
- iterator->list->count++;
-}
-
-/**
- * Implementation of iterator_t.replace.
- */
-status_t replace (private_iterator_t *this, void **old_item, void *new_item)
-{
- if (this->current == NULL)
- {
- return NOT_FOUND;
- }
- if (old_item != NULL)
- {
- *old_item = this->current->value;
- }
- this->current->value = new_item;
-
- return SUCCESS;
-}
-
-/**
- * Implementation of iterator_t.insert_after.
- */
-static void insert_after(private_iterator_t * iterator, void *item)
-{
- if (iterator->current == NULL)
- {
- iterator->list->public.insert_first(&(iterator->list->public),item);
- return;
- }
-
- linked_list_element_t *element =(linked_list_element_t *) linked_list_element_create(item);
-
- if (iterator->current->next == NULL)
- {
- iterator->current->next = element;
- element->previous = iterator->current;
- iterator->list->last = element;
- }
- else
- {
- iterator->current->next->previous = element;
- element->next = iterator->current->next;
- iterator->current->next = element;
- element->previous = iterator->current;
- }
- iterator->list->count++;
-}
-
-/**
- * Implementation of iterator_t.destroy.
- */
-static void iterator_destroy(private_iterator_t *this)
-{
- allocator_free(this);
-}
-
-/**
- * Implementation of linked_list_t.get_count.
- */
-static int get_count(private_linked_list_t *this)
-{
- return this->count;
-}
-
-/**
- * Implementation of linked_list_t.call_on_items.
- */
-static void call_on_items(private_linked_list_t *this, void(*func)(void*))
-{
- iterator_t *iterator;
- void *item;
-
- iterator = this->public.create_iterator(&(this->public),TRUE);
-
- while (iterator->has_next(iterator))
- {
- iterator->current(iterator, &item);
- (*func)(item);
- }
- iterator->destroy(iterator);
-}
-
-/**
- * Implementation of linked_list_t.insert_first.
- */
-static void insert_first(private_linked_list_t *this, void *item)
-{
- linked_list_element_t *element;
-
- element =(linked_list_element_t *) linked_list_element_create(item);
-
- if (this->count == 0)
- {
- /* first entry in list */
- this->first = element;
- this->last = element;
- element->previous = NULL;
- element->next = NULL;
- }
- else
- {
- linked_list_element_t *old_first_element = this->first;
- element->next = old_first_element;
- element->previous = NULL;
- old_first_element->previous = element;
- this->first = element;
- }
-
- this->count++;
-}
-
-/**
- * Implementation of linked_list_t.remove_first.
- */
-static status_t remove_first(private_linked_list_t *this, void **item)
-{
- if (this->count == 0)
- {
- return NOT_FOUND;
- }
-
- linked_list_element_t *element = this->first;
-
- if (element->next != NULL)
- {
- element->next->previous = NULL;
- }
- this->first = element->next;
-
- if (item != NULL)
- {
- *item = element->value;
- }
-
- this->count--;
-
- element->destroy(element);
-
- return SUCCESS;
-}
-
-/**
- * Implementation of linked_list_t.get_first.
- */
-static status_t get_first(private_linked_list_t *this, void **item)
-{
- if (this->count == 0)
- {
- return NOT_FOUND;
- }
-
- *item = this->first->value;
-
- return SUCCESS;
-}
-
-/**
- * Implementation of linked_list_t.insert_last.
- */
-static void insert_last(private_linked_list_t *this, void *item)
-{
- linked_list_element_t *element = (linked_list_element_t *) linked_list_element_create(item);
-
- if (this->count == 0)
- {
- /* first entry in list */
- this->first = element;
- this->last = element;
- element->previous = NULL;
- element->next = NULL;
- }
- else
- {
-
- linked_list_element_t *old_last_element = this->last;
- element->previous = old_last_element;
- element->next = NULL;
- old_last_element->next = element;
- this->last = element;
- }
-
- this->count++;
-}
-
-/**
- * Implementation of linked_list_t.remove_last.
- */
-static status_t remove_last(private_linked_list_t *this, void **item)
-{
- if (this->count == 0)
- {
- return NOT_FOUND;
- }
-
- linked_list_element_t *element = this->last;
-
- if (element->previous != NULL)
- {
- element->previous->next = NULL;
- }
- this->last = element->previous;
-
- if (item != NULL)
- {
- *item = element->value;
- }
-
- this->count--;
-
- element->destroy(element);
-
- return SUCCESS;
-}
-
-/**
- * Implementation of linked_list_t.insert_at_position.
- */
-static status_t insert_at_position (private_linked_list_t *this,size_t position, void *item)
-{
- linked_list_element_t *current_element;
- int i;
-
- if (this->count <= position)
- {
- return INVALID_ARG;
- }
-
- current_element = this->first;
-
- for (i = 0; i < position;i++)
- {
- current_element = current_element->next;
- }
-
- if (current_element == NULL)
- {
- this->public.insert_last(&(this->public),item);
- return SUCCESS;
- }
-
- linked_list_element_t *element =(linked_list_element_t *) linked_list_element_create(item);
-
-
- if (current_element->previous == NULL)
- {
- current_element->previous = element;
- element->next = current_element;
- this->first = element;
- }
- else
- {
- current_element->previous->next = element;
- element->previous = current_element->previous;
- current_element->previous = element;
- element->next = current_element;
- }
-
-
- this->count++;
- return SUCCESS;
-}
-
-/**
- * Implementation of linked_list_t.remove_at_position.
- */
-static status_t remove_at_position (private_linked_list_t *this,size_t position, void **item)
-{
- iterator_t *iterator;
- int i;
-
- if (this->count <= position)
- {
- return INVALID_ARG;
- }
-
- iterator = this->public.create_iterator(&(this->public),TRUE);
-
- iterator->has_next(iterator);
- for (i = 0; i < position;i++)
- {
- iterator->has_next(iterator);
- }
- iterator->current(iterator,item);
- iterator->remove(iterator);
- iterator->destroy(iterator);
-
- return SUCCESS;
-}
-
-/**
- * Implementation of linked_list_t.get_at_position.
- */
-static status_t get_at_position (private_linked_list_t *this,size_t position, void **item)
-{
- int i;
- iterator_t *iterator;
- status_t status;
- if (this->count <= position)
- {
- return INVALID_ARG;
- }
-
- iterator = this->public.create_iterator(&(this->public),TRUE);
-
- iterator->has_next(iterator);
- for (i = 0; i < position;i++)
- {
- iterator->has_next(iterator);
- }
- status = iterator->current(iterator,item);
- iterator->destroy(iterator);
- return status;
-}
-
-/**
- * Implementation of linked_list_t.get_last.
- */
-static status_t get_last(private_linked_list_t *this, void **item)
-{
- if (this->count == 0)
- {
- return NOT_FOUND;
- }
-
- *item = this->last->value;
-
- return SUCCESS;
-}
-
-/**
- * Implementation of linked_list_t.create_iterator.
- */
-static iterator_t *create_iterator (private_linked_list_t *linked_list,bool forward)
-{
- private_iterator_t *this = allocator_alloc_thing(private_iterator_t);
-
- this->public.iterate = (bool (*) (iterator_t *this, void **value)) iterate;
- this->public.has_next = (bool (*) (iterator_t *this)) iterator_has_next;
- this->public.current = (status_t (*) (iterator_t *this, void **value)) iterator_current;
- this->public.insert_before = (void (*) (iterator_t *this, void *item)) insert_before;
- this->public.insert_after = (void (*) (iterator_t *this, void *item)) insert_after;
- this->public.replace = (status_t (*) (iterator_t *, void **, void *)) replace;
- this->public.remove = (status_t (*) (iterator_t *this)) remove;
- this->public.reset = (void (*) (iterator_t *this)) iterator_reset;
- this->public.destroy = (void (*) (iterator_t *this)) iterator_destroy;
-
- this->forward = forward;
- this->current = NULL;
- this->list = linked_list;
-
- return &(this->public);
-}
-
-/**
- * Implementation of linked_list_t.destroy.
- */
-static void linked_list_destroy(private_linked_list_t *this)
-{
- void * value;
- /* Remove all list items before destroying list */
- while (this->public.remove_first(&(this->public),&value) != NOT_FOUND)
- {
- /* values are not destroyed so memory leaks are possible
- * if list is not empty when deleting */
- }
- allocator_free(this);
-}
-
-/*
- * Described in header.
- */
-linked_list_t *linked_list_create()
-{
- private_linked_list_t *this = allocator_alloc_thing(private_linked_list_t);
-
- this->public.get_count = (int (*) (linked_list_t *)) get_count;
- this->public.create_iterator = (iterator_t * (*) (linked_list_t *,bool )) create_iterator;
- this->public.call_on_items = (void (*) (linked_list_t *, void(*func)(void*)))call_on_items;
- this->public.get_first = (status_t (*) (linked_list_t *, void **item)) get_first;
- this->public.get_last = (status_t (*) (linked_list_t *, void **item)) get_last;
- this->public.insert_first = (void (*) (linked_list_t *, void *item)) insert_first;
- this->public.insert_last = (void (*) (linked_list_t *, void *item)) insert_last;
- this->public.remove_first = (status_t (*) (linked_list_t *, void **item)) remove_first;
- this->public.remove_last = (status_t (*) (linked_list_t *, void **item)) remove_last;
- this->public.insert_at_position =(status_t (*) (linked_list_t *,size_t, void *)) insert_at_position;
- this->public.remove_at_position =(status_t (*) (linked_list_t *,size_t, void **)) remove_at_position;
- this->public.get_at_position =(status_t (*) (linked_list_t *,size_t, void **)) get_at_position;
-
- this->public.destroy = (void (*) (linked_list_t *)) linked_list_destroy;
-
- this->count = 0;
- this->first = NULL;
- this->last = NULL;
-
- return (&(this->public));
-}
diff --git a/Source/charon/utils/linked_list.h b/Source/charon/utils/linked_list.h
deleted file mode 100644
index 8647f064d..000000000
--- a/Source/charon/utils/linked_list.h
+++ /dev/null
@@ -1,203 +0,0 @@
-/**
- * @file linked_list.h
- *
- * @brief Interface of linked_list_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef LINKED_LIST_H_
-#define LINKED_LIST_H_
-
-#include <types.h>
-#include <utils/iterator.h>
-
-
-typedef struct linked_list_t linked_list_t;
-
-/**
- * @brief Class implementing a double linked list (named only as linked list).
- *
- * @warning Access to an object of this type is not thread-save.
- *
- * @b Costructors:
- * - linked_list_create()
- *
- * @see
- * - job_queue_t
- * - event_queue_t
- * - send_queue_t
- *
- * @ingroup utils
- */
-struct linked_list_t {
-
- /**
- * @brief Gets the count of items in the list.
- *
- * @param linked_list calling object
- * @return number of items in list
- */
- int (*get_count) (linked_list_t *linked_list);
-
- /**
- * @brief Creates a iterator for the given list.
- *
- * @warning Created iterator_t object has to get destroyed by the caller.
- *
- * @param linked_list calling object
- * @param forward iterator direction (TRUE: front to end)
- * @return new iterator_t object
- */
- iterator_t * (*create_iterator) (linked_list_t *linked_list, bool forward);
-
- /**
- * @brief Call a function with list element as argument.
- *
- * This method accepts a function, which will be called for
- * each list element once. The function must accept the list
- * element as the first argument. Handy for destruction of
- * list elements.
- *
- * @todo Additional vararg which are passed to the
- * function would be nice...
- *
- * @param linked_list calling object
- * @param func function to call
- */
- void (*call_on_items) (linked_list_t *linked_list, void(*func)(void*));
-
- /**
- * @brief Inserts a new item at the beginning of the list.
- *
- * @param linked_list calling object
- * @param[in] item item value to insert in list
- */
- void (*insert_first) (linked_list_t *linked_list, void *item);
-
- /**
- * @brief Removes the first item in the list and returns its value.
- *
- * @param linked_list calling object
- * @param[out] item returned value of first item, or NULL
- * @return
- * - SUCCESS
- * - NOT_FOUND, if list is empty
- */
- status_t (*remove_first) (linked_list_t *linked_list, void **item);
-
- /**
- * @brief Returns the value of the first list item without removing it.
- *
- * @param linked_list calling object
- * @param[out] item item returned value of first item
- * @return
- * - SUCCESS
- * - NOT_FOUND, if list is empty
- */
- status_t (*get_first) (linked_list_t *linked_list, void **item);
-
- /**
- * @brief Inserts a new item at the end of the list.
- *
- * @param linked_list calling object
- * @param[in] item item value to insert into list
- */
- void (*insert_last) (linked_list_t *linked_list, void *item);
-
- /**
- * @brief Inserts a new item at a given position in the list.
- *
- * @param linked_list calling object
- * @param position position starting at 0 to insert new entry
- * @param[in] item item value to insert into list
- * @return
- * - SUCCESS
- * - INVALID_ARG if position not existing
- */
- status_t (*insert_at_position) (linked_list_t *linked_list,size_t position, void *item);
-
- /**
- * @brief Removes an item from a given position in the list.
- *
- * @param linked_list calling object
- * @param position position starting at 0 to remove entry from
- * @param[out] item removed item will be stored at this location
- * @return
- * - SUCCESS
- * - INVALID_ARG if position not existing
- */
- status_t (*remove_at_position) (linked_list_t *linked_list,size_t position, void **item);
-
- /**
- * @brief Get an item from a given position in the list.
- *
- * @param linked_list calling object
- * @param position position starting at 0 to get entry from
- * @param[out] item item will be stored at this location
- * @return
- * - SUCCESS
- * - INVALID_ARG if position not existing
- */
- status_t (*get_at_position) (linked_list_t *linked_list,size_t position, void **item);
-
- /**
- * @brief Removes the last item in the list and returns its value.
- *
- * @param linked_list calling object
- * @param[out] item returned value of last item, or NULL
- * @return
- * - SUCCESS
- * - NOT_FOUND if list is empty
- */
- status_t (*remove_last) (linked_list_t *linked_list, void **item);
-
- /**
- * @brief Returns the value of the last list item without removing it.
- *
- * @param linked_list calling object
- * @param[out] item returned value of last item
- * @return
- * - SUCCESS
- * - NOT_FOUND if list is empty
- */
- status_t (*get_last) (linked_list_t *linked_list, void **item);
-
- /**
- * @brief Destroys a linked_list object.
- *
- * @warning All items are removed before deleting the list. The
- * associated values are NOT destroyed.
- * Destroying an list which is not empty may cause
- * memory leaks!
- *
- * @param linked_list calling object
- */
- void (*destroy) (linked_list_t *linked_list);
-};
-
-/**
- * @brief Creates an empty linked list object.
- *
- * @return linked_list_t object.
- *
- * @ingroup utils
- */
-linked_list_t *linked_list_create();
-
-
-#endif /*LINKED_LIST_H_*/
diff --git a/Source/charon/utils/logger.c b/Source/charon/utils/logger.c
deleted file mode 100644
index c66de481e..000000000
--- a/Source/charon/utils/logger.c
+++ /dev/null
@@ -1,360 +0,0 @@
-/**
- * @file logger.c
- *
- * @brief Implementation of logger_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <syslog.h>
-#include <stdarg.h>
-#include <string.h>
-#include <stdio.h>
-#include <time.h>
-#include <pthread.h>
-
-#include "logger.h"
-
-#include <daemon.h>
-#include <utils/allocator.h>
-
-/**
- * Maximum length of a log entry (only used for logger_s.log).
- */
-#define MAX_LOG 8192
-
-
-typedef struct private_logger_t private_logger_t;
-
-/**
- * @brief Private data of a logger_t object.
- */
-struct private_logger_t {
- /**
- * Public data.
- */
- logger_t public;
- /**
- * Detail-level of logger.
- */
- log_level_t level;
- /**
- * Name of logger.
- */
- char *name;
- /**
- * File to write log output to.
- * NULL for syslog.
- */
- FILE *output;
-
- /**
- * Should a thread_id be included in the log?
- */
- bool log_thread_id;
-
- /**
- * Applies a prefix to string and stores it in buffer.
- *
- * @warning: buffer must be at least have MAX_LOG size.
- */
- void (*prepend_prefix) (private_logger_t *this, log_level_t loglevel, char *string, char *buffer);
-};
-
-/**
- * Implementation of private_logger_t.prepend_prefix.
- */
-static void prepend_prefix(private_logger_t *this, log_level_t loglevel, char *string, char *buffer)
-{
- char log_type, log_details;
- if (loglevel & CONTROL)
- {
- log_type = '~';
- }
- else if (loglevel & ERROR)
- {
- log_type = '!';
- }
- else if (loglevel & RAW)
- {
- log_type = '#';
- }
- else if (loglevel & PRIVATE)
- {
- log_type = '?';
- }
- else if (loglevel & AUDIT)
- {
- log_type = '>';
- }
- else
- {
- log_type = '-';
- }
-
- if (loglevel & (LEVEL3 - LEVEL2))
- {
- log_details = '3';
- }
- else if (loglevel & (LEVEL2 - LEVEL1))
- {
- log_details = '2';
- }
- else if (loglevel & LEVEL1)
- {
- log_details = '1';
- }
- else
- {
- log_details = '0';
- }
-
- if (this->log_thread_id)
- {
- snprintf(buffer, MAX_LOG, "[%c%c] [%s] @%u %s", log_type, log_details, this->name, (int)pthread_self(), string);
- }
- else
- {
- snprintf(buffer, MAX_LOG, "[%c%c] [%s] %s", log_type, log_details, this->name, string);
- }
-}
-
-/**
- * Implementation of logger_t.log.
- *
- * Yes, logg is wrong written :-).
- */
-static void logg(private_logger_t *this, log_level_t loglevel, char *format, ...)
-{
- if ((this->level & loglevel) == loglevel)
- {
- char buffer[MAX_LOG];
- va_list args;
-
-
- if (this->output == NULL)
- {
- /* syslog */
- this->prepend_prefix(this, loglevel, format, buffer);
- va_start(args, format);
- vsyslog(LOG_INFO, buffer, args);
- va_end(args);
- }
- else
- {
- /* File output */
- this->prepend_prefix(this, loglevel, format, buffer);
- va_start(args, format);
- vfprintf(this->output, buffer, args);
- va_end(args);
- fprintf(this->output, "\n");
- }
-
- }
-}
-
-/**
- * Implementation of logger_t.log_bytes.
- */
-static void log_bytes(private_logger_t *this, log_level_t loglevel, char *label, char *bytes, size_t len)
-{
- static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-
-
- if ((this->level & loglevel) == loglevel)
- {
- char buffer[MAX_LOG];
- char ascii_buffer[17];
- char *format;
- char *buffer_pos;
- char *bytes_pos, *bytes_roof;
- int i;
- int line_start = 0;
-
- /* since me can't do multi-line output to syslog,
- * we must do multiple syslogs. To avoid
- * problems in output order, lock this by a mutex.
- */
- pthread_mutex_lock(&mutex);
-
-
- format = "%s (%d bytes @%p)";
- this->prepend_prefix(this, loglevel, format, buffer);
-
- if (this->output == NULL)
- {
- syslog(LOG_INFO, buffer, label, len);
- }
- else
- {
- fprintf(this->output, buffer, label, len, bytes);
- fprintf(this->output, "\n");
- }
-
- bytes_pos = bytes;
- bytes_roof = bytes + len;
- buffer_pos = buffer;
- memset(ascii_buffer, 0, 17);
-
- for (i = 1; bytes_pos < bytes_roof; i++)
- {
- static char hexdig[] = "0123456789ABCDEF";
- *buffer_pos++ = hexdig[(*bytes_pos >> 4) & 0xF];
- *buffer_pos++ = hexdig[ *bytes_pos & 0xF];
- if ((i % 16) == 0)
- {
- *buffer_pos++ = '\0';
- buffer_pos = buffer;
- if (this->output == NULL)
- {
- syslog(LOG_INFO, "[=>] [%5d ] %s %s", line_start, buffer, ascii_buffer);
- }
- else
- {
- fprintf(this->output, "[=>] [%5d ] %s %s\n", line_start, buffer, ascii_buffer);
- }
- memset(ascii_buffer, 0, 16);
- line_start += 16;
- }
- else if ((i % 4) == 0)
- {
- *buffer_pos++ = ' ';
- // *buffer_pos++ = ' ';
- }
- else
- {
- *buffer_pos++ = ' ';
- }
-
- if (*bytes_pos > 31 && *bytes_pos < 127)
- {
- ascii_buffer[(i % 16)] = *bytes_pos;
- }
- else
- {
- ascii_buffer[(i % 16)] = '*';
- }
-
- bytes_pos++;
- }
-
- *buffer_pos++ = '\0';
- if (buffer_pos > buffer + 1)
- {
- buffer_pos = buffer;
- if (this->output == NULL)
- {
- syslog(LOG_INFO, "[=>] [%5d ] %s %16s", line_start, buffer, ascii_buffer);
- }
- else
- {
- fprintf(this->output, "[=>] [%5d ] %s %16s\n", line_start, buffer, ascii_buffer);
- }
- }
- pthread_mutex_unlock(&mutex);
- }
-}
-
-/**
- * Implementation of logger_t.log_chunk.
- */
-static void log_chunk(logger_t *this, log_level_t loglevel, char *label, chunk_t chunk)
-{
- this->log_bytes(this, loglevel, label, chunk.ptr, chunk.len);
-}
-
-/**
- * Implementation of logger_t.enable_level.
- */
-static void enable_level(private_logger_t *this, log_level_t log_level)
-{
- this->level |= log_level;
-}
-
-/**
- * Implementation of logger_t.disable_level.
- */
-static void disable_level(private_logger_t *this, log_level_t log_level)
-{
- this->level &= ~log_level;
-}
-
-/**
- * Implementation of logger_t.set_output.
- */
-static void set_output(private_logger_t *this, FILE * output)
-{
- this->output = output;
-}
-
-/**
- * Implementation of logger_t.get_level.
- */
-static log_level_t get_level(private_logger_t *this)
-{
- return this->level;
-}
-
-/**
- * Implementation of logger_t.destroy.
- */
-static void destroy(private_logger_t *this)
-{
- allocator_free(this->name);
- allocator_free(this);
-}
-
-/*
- * Described in header.
- */
-logger_t *logger_create(char *logger_name, log_level_t log_level, bool log_thread_id, FILE * output)
-{
- private_logger_t *this = allocator_alloc_thing(private_logger_t);
-
- /* public functions */
- this->public.log = (void(*)(logger_t*,log_level_t,char*,...))logg;
- this->public.log_bytes = (void(*)(logger_t*, log_level_t, char*,char*,size_t))log_bytes;
- this->public.log_chunk = log_chunk;
- this->public.enable_level = (void(*)(logger_t*,log_level_t))enable_level;
- this->public.disable_level = (void(*)(logger_t*,log_level_t))disable_level;
- this->public.get_level = (log_level_t(*)(logger_t*))get_level;
- this->public.set_output = (void(*)(logger_t*,FILE*))set_output;
- this->public.destroy = (void(*)(logger_t*))destroy;
-
- /* private functions */
- this->prepend_prefix = prepend_prefix;
-
- if (logger_name == NULL)
- {
- logger_name = "";
- }
-
- /* private variables */
- this->level = log_level;
- this->log_thread_id = log_thread_id;
- this->name = allocator_alloc(strlen(logger_name) + 1);
-
- strcpy(this->name,logger_name);
- this->output = output;
-
- if (output == NULL)
- {
- openlog(DAEMON_NAME, 0, LOG_DAEMON);
- }
-
- return (logger_t*)this;
-}
diff --git a/Source/charon/utils/logger.h b/Source/charon/utils/logger.h
deleted file mode 100644
index 637915e8b..000000000
--- a/Source/charon/utils/logger.h
+++ /dev/null
@@ -1,199 +0,0 @@
-/**
- * @file logger.h
- *
- * @brief Interface of logger_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef LOGGER_H_
-#define LOGGER_H_
-
-#include <stdio.h>
-
-#include <types.h>
-
-
-typedef enum log_level_t log_level_t;
-
-/**
- * @brief Log Levels supported by the logger object.
- *
- * Logleves are devided in two different kinds:
- * - levels to specify the type of the log
- * - levels to specify the detail-level of the log
- *
- * Use combinations of these to build detailed loglevels, such
- * as CONTROL|MORE fore a detailed cotrol level, or
- * use RAW to see all raw data dumps (except private).
- *
- * @ingroup utils
- */
-enum log_level_t {
- /**
- * Control flow.
- */
- CONTROL = 1,
- /**
- * Error reporting.
- */
- ERROR = 2,
- /**
- * Logs important for the sysadmin.
- */
- AUDIT = 4,
- /**
- * Raw data dumps.
- */
- RAW = 8,
- /**
- * Private data dumps.
- */
- PRIVATE = 16,
-
- /**
- * Log most important output, can be omitted.
- */
- LEVEL0 = 0,
- /**
- * Log more detailed output.
- */
- LEVEL1 = 32,
- /**
- * Log even more detailed output.
- */
- LEVEL2 = LEVEL1 + 64,
- /**
- * Use maximum detailed output.
- */
- LEVEL3 = LEVEL2 + 128,
-
- /**
- * Summary for all types with all detail-levels.
- */
- FULL = LEVEL3 + CONTROL + ERROR + RAW + PRIVATE + AUDIT
-};
-
-typedef struct logger_t logger_t;
-
-/**
- * @brief Class to simplify logging.
- *
- * @b Constructors:
- * - logger_create()
- *
- * @ingroup utils
- */
-struct logger_t {
-
- /**
- * @brief Log an entry, using printf()-like params.
- *
- * All specified loglevels must be activated that
- * the log is done.
- *
- * @param this logger_t object
- * @param loglevel or'ed set of log_level_t's
- * @param format printf like format string
- * @param ... printf like parameters
- */
- void (*log) (logger_t *this, log_level_t log_level, char *format, ...);
-
- /**
- * @brief Log some bytes, useful for debugging.
- *
- * All specified loglevels must be activated that
- * the log is done.
- *
- * @param this logger_t object
- * @param loglevel or'ed set of log_level_t's
- * @param label a labeling name, logged with the bytes
- * @param bytes pointer to the bytes to dump
- * @param len number of bytes to dump
- */
- void (*log_bytes) (logger_t *this, log_level_t loglevel, char *label, char *bytes, size_t len);
-
- /**
- * @brief Log a chunk, useful for debugging.
- *
- * All specified loglevels must be activated that
- * the log is done.
- *
- * @param this logger_t object
- * @param loglevel or'ed set of log_level_t's
- * @param label a labeling name, logged with the bytes
- * @param chunk chunk to log
- */
- void (*log_chunk) (logger_t *this, log_level_t loglevel, char *label, chunk_t chunk);
-
- /**
- * @brief Enables a loglevel for the current logger_t object.
- *
- * @param this logger_t object
- * @param log_level loglevel to enable
- */
- void (*enable_level) (logger_t *this, log_level_t log_level);
-
- /**
- * @brief Disables a loglevel for the current logger_t object.
- *
- * @param this logger_t object
- * @param log_level loglevel to enable
- */
- void (*disable_level) (logger_t *this, log_level_t log_level);
-
- /**
- * @brief Set the output of the logger.
- *
- * Use NULL for syslog.
- *
- * @param this logger_t object
- * @param output file, where log output should be written
- */
- void (*set_output) (logger_t *this, FILE *output);
-
- /**
- * @brief Get the currently used loglevel.
- *
- * @param this logger_t object
- * @return currently used loglevel
- */
- log_level_t (*get_level) (logger_t *this);
-
- /**
- * @brief Destroys a logger_t object.
- *
- * @param this logger_t object
- */
- void (*destroy) (logger_t *this);
-};
-
-/**
- * @brief Constructor to create a logger_t object.
- *
- * @param logger_name name for the logger_t object
- * @param log_level or'ed set of log_levels to assign to the new logger_t object
- * @param log_thread_id TRUE if thread id should also be logged
- * @param output FILE * if log has to go on a file output, NULL for syslog
- * @return logger_t object
- *
- * @ingroup utils
- */
-logger_t *logger_create(char *logger_name, log_level_t log_level, bool log_thread_id, FILE * output);
-
-
-#endif /*LOGGER_H_*/
diff --git a/Source/charon/utils/logger_manager.c b/Source/charon/utils/logger_manager.c
deleted file mode 100644
index 8270191a9..000000000
--- a/Source/charon/utils/logger_manager.c
+++ /dev/null
@@ -1,212 +0,0 @@
-/**
- * @file logger_manager.c
- *
- * @brief Implementation of logger_manager_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-
-#include "logger_manager.h"
-
-#include <daemon.h>
-#include <definitions.h>
-#include <utils/allocator.h>
-#include <utils/linked_list.h>
-
-/**
- * String mappings for logger_context_t
- */
-mapping_t logger_context_t_mappings[] = {
- {PARSER, "PARSER"},
- {GENERATOR, "GENERATOR"},
- {IKE_SA, "IKE_SA"},
- {IKE_SA_MANAGER, "IKE_SA_MANAGER"},
- {CHILD_SA, "CHILD_SA"},
- {MESSAGE, "MESSAGE"},
- {THREAD_POOL, "THREAD_POOL"},
- {WORKER, "WORKER"},
- {SCHEDULER, "SCHEDULER"},
- {SENDER, "SENDER"},
- {RECEIVER, "RECEIVER"},
- {SOCKET, "SOCKET"},
- {TESTER, "TESTER"},
- {DAEMON, "DAEMON"},
- {CONFIG, "CONFIG"},
- {ENCRYPTION_PAYLOAD, "ENCRYPTION_PAYLOAD"},
- {PAYLOAD, "PAYLOAD"},
- {DER_DECODER, "DER_DECODER"},
- {DER_ENCODER, "DER_ENCODER"},
- {MAPPING_END, NULL},
-};
-
-#define DEFAULT_OUTPUT NULL
-
-struct {
- char *name;
- log_level_t level;
- bool log_thread_ids;
- FILE *output;
-} logger_defaults[] = {
- { "PARSR", ERROR|CONTROL|AUDIT|LEVEL0, TRUE, DEFAULT_OUTPUT}, /* PARSER */
- { "GNRAT", ERROR|CONTROL|AUDIT|LEVEL0, TRUE, DEFAULT_OUTPUT}, /* GENERATOR */
- { "IKESA", ERROR|CONTROL|AUDIT|LEVEL0, TRUE, DEFAULT_OUTPUT}, /* IKE_SA */
- { "SAMGR", ERROR|CONTROL|AUDIT|LEVEL0, TRUE, DEFAULT_OUTPUT}, /* IKE_SA_MANAGER */
- { "CHDSA", ERROR|CONTROL|AUDIT|LEVEL0, TRUE, DEFAULT_OUTPUT}, /* CHILD_SA */
- { "MESSG", ERROR|CONTROL|AUDIT|LEVEL0, TRUE, DEFAULT_OUTPUT}, /* MESSAGE */
- { "TPOOL", ERROR|CONTROL|AUDIT|LEVEL0, FALSE, DEFAULT_OUTPUT}, /* THREAD_POOL */
- { "WORKR", ERROR|CONTROL|AUDIT|LEVEL0, TRUE, DEFAULT_OUTPUT}, /* WORKER */
- { "SCHED", ERROR|CONTROL|AUDIT|LEVEL0, FALSE, DEFAULT_OUTPUT}, /* SCHEDULER */
- { "SENDR", ERROR|CONTROL|AUDIT|LEVEL0, FALSE, DEFAULT_OUTPUT}, /* SENDER */
- { "RECVR", ERROR|CONTROL|AUDIT|LEVEL0, FALSE, DEFAULT_OUTPUT}, /* RECEIVER */
- { "SOCKT", ERROR|CONTROL|AUDIT|LEVEL0, FALSE, DEFAULT_OUTPUT}, /* SOCKET */
- { "TESTR", ERROR|CONTROL|AUDIT|LEVEL0, FALSE, DEFAULT_OUTPUT}, /* TESTER */
- { "DAEMN", ERROR|CONTROL|AUDIT|LEVEL0, FALSE, DEFAULT_OUTPUT}, /* DAEMON */
- { "CONFG", ERROR|CONTROL|AUDIT|LEVEL0, TRUE, DEFAULT_OUTPUT}, /* CONFIG */
- { "ENCPL", ERROR|CONTROL|AUDIT|LEVEL0, TRUE, DEFAULT_OUTPUT}, /* ENCRYPTION_PAYLOAD */
- { "PAYLD", ERROR|CONTROL|AUDIT|LEVEL0, TRUE, DEFAULT_OUTPUT}, /* PAYLOAD */
- { "DERDC", ERROR|CONTROL|AUDIT|LEVEL0, TRUE, DEFAULT_OUTPUT}, /* DER_DECODER */
- { "DEREC", ERROR|CONTROL|AUDIT|LEVEL0, TRUE, DEFAULT_OUTPUT}, /* DER_ENCODER */
-};
-
-
-typedef struct private_logger_manager_t private_logger_manager_t;
-
-/**
- * Private data of logger_manager_t object.
- */
-struct private_logger_manager_t {
- /**
- * Public data.
- */
- logger_manager_t public;
-
- /**
- * Array of loggers, one for each context
- */
- logger_t *loggers[LOGGER_CONTEXT_ROOF];
-
-};
-
-/**
- * Implementation of logger_manager_t.get_logger.
- */
-static logger_t *get_logger(private_logger_manager_t *this, logger_context_t context)
-{
- return this->loggers[context];
-}
-
-/**
- * Implementation of logger_manager_t.get_log_level.
- */
-static log_level_t get_log_level (private_logger_manager_t *this, logger_context_t context)
-{
- return this->loggers[context]->get_level(this->loggers[context]);
-}
-
-/**
- * Implementation of private_logger_manager_t.enable_log_level.
- */
-static void enable_log_level(private_logger_manager_t *this, logger_context_t context, log_level_t level)
-{
- if (context == ALL_LOGGERS)
- {
- for (context = 0; context < LOGGER_CONTEXT_ROOF; context++)
- {
- this->loggers[context]->enable_level(this->loggers[context], level);
- }
- }
- else
- {
- this->loggers[context]->enable_level(this->loggers[context], level);
- }
-}
-
-/**
- * Implementation of private_logger_manager_t.disable_log_level.
- */
-static void disable_log_level(private_logger_manager_t *this, logger_context_t context, log_level_t level)
-{
- if (context == ALL_LOGGERS)
- {
- for (context = 0; context < LOGGER_CONTEXT_ROOF; context++)
- {
- this->loggers[context]->disable_level(this->loggers[context], level);
- }
- }
- else
- {
- this->loggers[context]->disable_level(this->loggers[context], level);
- }
-}
-
-/**
- * Implementation of private_logger_manager_t.set_output.
- */
-static void set_output(private_logger_manager_t *this, logger_context_t context, FILE *output)
-{
- if (context == ALL_LOGGERS)
- {
- for (context = 0; context < LOGGER_CONTEXT_ROOF; context++)
- {
- this->loggers[context]->set_output(this->loggers[context], output);
- }
- }
- else
- {
- this->loggers[context]->set_output(this->loggers[context], output);
- }
-}
-
-
-/**
- * Implementation of logger_manager_t.destroy.
- */
-static void destroy(private_logger_manager_t *this)
-{
- int i;
- for (i = 0; i < LOGGER_CONTEXT_ROOF; i++)
- {
- this->loggers[i]->destroy(this->loggers[i]);
- }
- allocator_free(this);
-}
-
-/*
- * Described in header.
- */
-logger_manager_t *logger_manager_create(log_level_t default_log_level)
-{
- private_logger_manager_t *this = allocator_alloc_thing(private_logger_manager_t);
- int i;
-
- this->public.get_logger = (logger_t *(*)(logger_manager_t*,logger_context_t context))get_logger;
- this->public.get_log_level = (log_level_t (*)(logger_manager_t *, logger_context_t)) get_log_level;
- this->public.enable_log_level = (void (*)(logger_manager_t *, logger_context_t, log_level_t)) enable_log_level;
- this->public.disable_log_level = (void (*)(logger_manager_t *, logger_context_t, log_level_t)) disable_log_level;
- this->public.set_output = (void (*)(logger_manager_t *, logger_context_t, FILE*)) set_output;
- this->public.destroy = (void(*)(logger_manager_t*))destroy;
-
- for (i = 0; i < LOGGER_CONTEXT_ROOF; i++)
- {
- this->loggers[i] = logger_create(logger_defaults[i].name, logger_defaults[i].level,
- logger_defaults[i].log_thread_ids, stdout);//logger_defaults[i].output);
- }
-
- return &this->public;
-}
-
diff --git a/Source/charon/utils/logger_manager.h b/Source/charon/utils/logger_manager.h
deleted file mode 100644
index bc8f0e62f..000000000
--- a/Source/charon/utils/logger_manager.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/**
- * @file logger_manager.h
- *
- * @brief Interface of logger_manager_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef LOGGER_MANAGER_H_
-#define LOGGER_MANAGER_H_
-
-#include <pthread.h>
-
-#include <utils/logger.h>
-
-
-typedef enum logger_context_t logger_context_t;
-
-/**
- * @brief Context of a specific logger.
- *
- * @ingroup utils
- */
-enum logger_context_t {
- ALL_LOGGERS = -1,
- PARSER = 0,
- GENERATOR,
- IKE_SA,
- IKE_SA_MANAGER,
- CHILD_SA,
- MESSAGE,
- THREAD_POOL,
- WORKER,
- SCHEDULER,
- SENDER,
- RECEIVER,
- SOCKET,
- TESTER,
- DAEMON,
- CONFIG,
- ENCRYPTION_PAYLOAD,
- PAYLOAD,
- DER_DECODER,
- DER_ENCODER,
- LOGGER_CONTEXT_ROOF,
-};
-
-
-typedef struct logger_manager_t logger_manager_t;
-
-/**
- * @brief Class to manage logger_t objects.
- *
- * The logger manager manages all logger_t object in a list and
- * allows their manipulation. Via a logger_context_t, the loglevel
- * of a specific logging type can be adjusted at runtime.
- *
- * @b Constructors:
- * - logger_manager_create()
- *
- * @see logger_t
- *
- * @ingroup utils
- */
-struct logger_manager_t {
-
- /**
- * @brief Gets a logger_t object for a specific logger context.
- *
- * @param this logger_manager_t object
- * @param context logger_context to use the logger for
- * @param name name for the new logger. Context name is already included
- * and has not to be specified (so NULL is allowed)
- * @return logger_t object
- */
- logger_t *(*get_logger) (logger_manager_t *this, logger_context_t context);
-
- /**
- * @brief Returns the set log_level of a specific context.
- *
- * @param this calling object
- * @param context context to check level
- * @return log_level for the given logger_context
- */
- log_level_t (*get_log_level) (logger_manager_t *this, logger_context_t context);
-
- /**
- * @brief Enables a logger level of a specific context.
- *
- * Use context ALL_LOGGERS to manipulate all loggers.
- *
- * @param this calling object
- * @param context context to set level
- * @param log_level logger level to eanble
- */
- void (*enable_log_level) (logger_manager_t *this, logger_context_t context,log_level_t log_level);
-
- /**
- * @brief Disables a logger level of a specific context.
- *
- * Use context ALL_LOGGERS to manipulate all loggers.
- *
- * @param this calling object
- * @param context context to set level
- * @param log_level logger level to disable
- */
- void (*disable_log_level) (logger_manager_t *this, logger_context_t context,log_level_t log_level);
-
- /**
- * @brief Sets the output of a logger.
- *
- * Use context ALL_LOGGERS to redirect all loggers.
- *
- * @param this calling object
- * @param context context to set output
- * @param log_level logger level to disable
- */
- void (*set_output) (logger_manager_t *this, logger_context_t context, FILE *output);
-
- /**
- * @brief Destroys a logger_manager_t object.
- *
- * All managed logger_t objects are also destroyed.
- *
- * @param this logger_manager_t object
- */
- void (*destroy) (logger_manager_t *this);
-};
-
-/**
- * @brief Constructor to create a logger_manager_t object.
- *
- * @param default_log_level default log level for all context
- * @return logger_manager_t object
- *
- * @ingroup utils
- */
-logger_manager_t *logger_manager_create(log_level_t default_log_level);
-
-
-#endif /*LOGGER_MANAGER_H_*/
diff --git a/Source/charon/utils/randomizer.c b/Source/charon/utils/randomizer.c
deleted file mode 100644
index bab2c071e..000000000
--- a/Source/charon/utils/randomizer.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/**
- * @file randomizer.c
- *
- * @brief Implementation of randomizer_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-#include "randomizer.h"
-
-#include <utils/allocator.h>
-#include <daemon.h>
-
-typedef struct private_randomizer_t private_randomizer_t;
-
-/**
- * Private data of an randomizer_t object.
- */
-struct private_randomizer_t {
-
- /**
- * Public randomizer_t interface.
- */
- randomizer_t public;
-
- /**
- * @brief Reads a specific number of bytes from random or pseudo random device.
- *
- * @param this calling object
- * @param pseudo_random TRUE, if from pseudo random bytes should be read,
- * FALSE for true random bytes
- * @param bytes number of bytes to read
- * @param[out] buffer pointer to buffer where to write the data in.
- * Size of buffer has to be at least bytes.
- */
- void (*get_bytes_from_device) (private_randomizer_t *this,bool pseudo_random, size_t bytes, u_int8_t *buffer);
-
- /**
- * Random device name.
- */
- char *random_dev_name;
-
- /**
- * Pseudo random device name.
- */
- char *pseudo_random_dev_name;
-};
-
-
-/**
- * Implementation of private_randomizer_t.get_bytes_from_device.
- */
-static void get_bytes_from_device(private_randomizer_t *this,bool pseudo_random, size_t bytes, u_int8_t *buffer)
-{
- /* number of bytes already done */
- size_t ndone;
- /* device file descriptor */
- int device;
- size_t got;
- char * device_name;
-
- device_name = (pseudo_random) ? this->pseudo_random_dev_name : this->random_dev_name;
-
- // open device
- device = open(device_name, 0);
- if (device < 0) {
- charon->kill(charon,"Random device could not be opened");
- }
- ndone = 0;
-
- /* read until nbytes are read */
- while (ndone < bytes)
- {
- got = read(device, buffer + ndone, bytes - ndone);
- if (got < 0) {
- charon->kill(charon,"Read from random device failed");
- }
- if (got == 0) {
- charon->kill(charon,"Read from random device failed");
- }
- ndone += got;
- }
- /* close device */
- close(device);
-}
-
-/**
- * Implementation of randomizer_t.get_random_bytes.
- */
-static void get_random_bytes(private_randomizer_t *this,size_t bytes, u_int8_t *buffer)
-{
- return (this->get_bytes_from_device(this, FALSE, bytes, buffer));
-}
-
-/**
- * Implementation of randomizer_t.allocate_random_bytes.
- */
-static void allocate_random_bytes(private_randomizer_t *this, size_t bytes, chunk_t *chunk)
-{
- chunk->len = bytes;
- chunk->ptr = allocator_alloc(bytes);
- return (this->get_bytes_from_device(this, FALSE, bytes, chunk->ptr));
-}
-
-/**
- * Implementation of randomizer_t.get_pseudo_random_bytes.
- */
-static void get_pseudo_random_bytes(private_randomizer_t *this,size_t bytes, u_int8_t *buffer)
-{
- return (this->get_bytes_from_device(this, TRUE, bytes, buffer));
-}
-
-/**
- * Implementation of randomizer_t.allocate_pseudo_random_bytes.
- */
-static void allocate_pseudo_random_bytes(private_randomizer_t *this, size_t bytes, chunk_t *chunk)
-{
- chunk->len = bytes;
- chunk->ptr = allocator_alloc(bytes);
- return (this->get_bytes_from_device(this, TRUE, bytes, chunk->ptr));
-}
-
-/**
- * Implementation of randomizer_t.destroy.
- */
-static void destroy(private_randomizer_t *this)
-{
- allocator_free(this->random_dev_name);
- allocator_free(this->pseudo_random_dev_name);
- allocator_free(this);
-}
-
-/*
- * Described in header.
- */
-randomizer_t *randomizer_create(void)
-{
- return randomizer_create_on_devices(DEFAULT_RANDOM_DEVICE,DEFAULT_PSEUDO_RANDOM_DEVICE);
-}
-
-/*
- * Described in header.
- */
-randomizer_t *randomizer_create_on_devices(char * random_dev_name,char * prandom_dev_name)
-{
- private_randomizer_t *this = allocator_alloc_thing(private_randomizer_t);
-
- /* public functions */
- this->public.get_random_bytes = (void (*) (randomizer_t *,size_t, u_int8_t *)) get_random_bytes;
- this->public.allocate_random_bytes = (void (*) (randomizer_t *,size_t, chunk_t *)) allocate_random_bytes;
- this->public.get_pseudo_random_bytes = (void (*) (randomizer_t *,size_t, u_int8_t *)) get_pseudo_random_bytes;
- this->public.allocate_pseudo_random_bytes = (void (*) (randomizer_t *,size_t, chunk_t *)) allocate_pseudo_random_bytes;
- this->public.destroy = (void (*) (randomizer_t *))destroy;
-
- /* private functions */
- this->get_bytes_from_device = get_bytes_from_device;
-
- /* private fields */
- this->random_dev_name = allocator_alloc(strlen(random_dev_name) + 1);
- strcpy(this->random_dev_name,random_dev_name);
- this->pseudo_random_dev_name = allocator_alloc(strlen(prandom_dev_name) + 1);
- strcpy(this->pseudo_random_dev_name,prandom_dev_name);
-
- return &(this->public);
-}
diff --git a/Source/charon/utils/randomizer.h b/Source/charon/utils/randomizer.h
deleted file mode 100644
index 509b7d515..000000000
--- a/Source/charon/utils/randomizer.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * @file randomizer.h
- *
- * @brief Interface of randomizer_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef RANDOMIZER_H_
-#define RANDOMIZER_H_
-
-#include <types.h>
-
-
-/**
- * Default random device used when no device is given.
- */
-#define DEFAULT_RANDOM_DEVICE "/dev/random"
-
-/**
- * Pseudo random device used when no device is given.
- */
-#define DEFAULT_PSEUDO_RANDOM_DEVICE "/dev/urandom"
-
-typedef struct randomizer_t randomizer_t;
-
-/**
- * @brief Class used to get random and pseudo random values.
- *
- * This class is thread save as file system read calls are thread save.
- *
- * @b Constructors:
- * - randomizer_create()
- * - randomizer_create_on_devices()
- *
- * @ingroup utils
- */
-struct randomizer_t {
-
- /**
- * @brief Reads a specific number of bytes from random device.
- *
- * @param this calling randomizer_t object
- * @param bytes number of bytes to read
- * @param[out] buffer pointer to buffer where to write the data in.
- * Size of buffer has to be at least bytes.
- */
- void (*get_random_bytes) (randomizer_t *this,size_t bytes, u_int8_t *buffer);
-
- /**
- * @brief Allocates space and writes in random bytes.
- *
- * @param this calling randomizer_t object
- * @param bytes number of bytes to allocate
- * @param[out] chunk chunk which will hold the allocated random bytes
- */
- void (*allocate_random_bytes) (randomizer_t *this, size_t bytes, chunk_t *chunk);
-
- /**
- * @brief Reads a specific number of bytes from pseudo random device.
- *
- * @param this calling randomizer_t object
- * @param bytes number of bytes to read
- * @param[out] buffer pointer to buffer where to write the data in.
- * size of buffer has to be at least bytes.
- */
- void (*get_pseudo_random_bytes) (randomizer_t *this,size_t bytes, u_int8_t *buffer);
-
- /**
- * @brief Allocates space and writes in pseudo random bytes.
- *
- * @param this calling randomizer_t object
- * @param bytes number of bytes to allocate
- * @param[out] chunk chunk which will hold the allocated random bytes
- */
- void (*allocate_pseudo_random_bytes) (randomizer_t *this, size_t bytes, chunk_t *chunk);
-
- /**
- * @brief Destroys a randomizer_t object.
- *
- * @param this randomizer_t object to destroy
- */
- void (*destroy) (randomizer_t *this);
-};
-
-/**
- * @brief Creates a randomizer_t object
- *
- * @return
- * - created randomizer_t, or
- * - NULL if failed
- *
- * @ingroup utils
- */
-randomizer_t *randomizer_create();
-
-/**
- * @brief Creates an randomizer_t object with specific random device names.
- *
- * @param random_dev_name device name for random values, etc /dev/random
- * @param prandom_dev_name device name for pseudo random values, etc /dev/urandom
- * @return randomizer_t object
- *
- * @ingroup utils
- */
-randomizer_t *randomizer_create_on_devices(char * random_dev_name,char * prandom_dev_name);
-
-#endif /*RANDOMIZER_H_*/
diff --git a/Source/charon/utils/tester.c b/Source/charon/utils/tester.c
deleted file mode 100644
index 20dea2e82..000000000
--- a/Source/charon/utils/tester.c
+++ /dev/null
@@ -1,257 +0,0 @@
-/**
- * @file tester.c
- *
- * @brief Implementation of tester_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-
-#include <stdlib.h>
-#include <string.h>
-#include <pthread.h>
-#include <sys/time.h>
-
-#include "tester.h"
-
-#include <utils/allocator.h>
-#include <utils/linked_list.h>
-#include <queues/job_queue.h>
-
-
-typedef struct private_tester_t private_tester_t;
-
-/**
- * @brief Private Data of tester_t class.
- *
- */
-struct private_tester_t {
-
- /**
- * Protected interface of tester_t.
- */
- protected_tester_t protected;
-
- /**
- * Runs a specific test.
- *
- * @param tester associated tester object
- * @param test_function test function to perform
- * @param test_name name for the given test
- */
- void (*run_test) (private_tester_t *tester, void (*test_function) (protected_tester_t * tester), char * test_name);
-
- /**
- * Returns the difference of to timeval structs in microseconds.
- *
- * @warning this function is also defined in the event queue
- * in later improvements, this function can be added to a general
- * class type!
- *
- * @param end_time end time
- * @param start_time start time
- *
- * @TODO make object function or move to utils!
- *
- * @return difference in microseconds
- */
- long (*time_difference) (private_tester_t *tester,struct timeval *end_time, struct timeval *start_time);
-
- /**
- * Output is written into this file.
- */
- FILE* output;
-
- /**
- * Number of already performed tests.
- */
- int tests_count;
-
- /**
- * Number of failed tests.
- */
- int failed_tests_count;
-
- /**
- * Number of failed asserts in current test.
- */
- int failed_asserts_count;
-
- /**
- * TRUE if also succeeded asserts should be written to output.
- */
- bool display_succeeded_asserts;
-
- /**
- * Mutex to make this class thread-save.
- */
- pthread_mutex_t mutex;
-};
-
-/**
- * Implementation of tester_t.perform_tests.
- */
-static void perform_tests(private_tester_t *this,test_t **tests)
-{
- int current_test = 0;
- fprintf(this->output,"\nStart testing...\n\n");
- fprintf(this->output,"_____________________________________________________________________\n");
- fprintf(this->output,"Testname | running time\n");
- fprintf(this->output,"_______________________________________________________|_____________\n");
-
- while (tests[current_test] != NULL)
- {
- this->run_test(this,tests[current_test]->test_function,tests[current_test]->test_name);
- current_test++;
- }
- fprintf(this->output,"=====================================================================\n");
- fprintf(this->output,"End testing. %d of %d tests succeeded\n",this->tests_count - this->failed_tests_count,this->tests_count);
- fprintf(this->output,"=====================================================================\n");
-}
-
-/**
- * Implementation of tester_t.perform_test.
- */
-static void perform_test(private_tester_t *this, test_t *test)
-{
- test_t *tests[] = {test, NULL};
- return (perform_tests(this,tests));
-}
-
-/**
- * Returns the difference of to timeval structs in microseconds.
- *
- * @warning this function is also defined in the event queue
- * in later improvements, this function can be added to a general
- * class type!
- *
- * @param end_time end time
- * @param start_time start time
- *
- * @TODO make object function or move to utils!
- *
- * @return difference in microseconds
- */
-static long time_difference(private_tester_t *this,struct timeval *end_time, struct timeval *start_time)
-{
- long seconds, microseconds;
-
- seconds = (end_time->tv_sec - start_time->tv_sec);
- microseconds = (end_time->tv_usec - start_time->tv_usec);
- return ((seconds * 1000000) + microseconds);
-}
-
-
-/**
- * Implementation of private_tester_t.run_test.
- */
-static void run_test(private_tester_t *this, void (*test_function) (protected_tester_t * tester), char * test_name)
-{
- struct timeval start_time, end_time;
- long timediff;
- this->tests_count++;
- this->failed_asserts_count = 0;
- fprintf(this->output,"%-55s\n", test_name);
- gettimeofday(&start_time,NULL);
- test_function(&(this->protected));
- gettimeofday(&end_time,NULL);
- timediff = this->time_difference(this,&end_time, &start_time);
-
- if (this->failed_asserts_count > 0)
- {
- fprintf(this->output," => Test failed: %-37s|%10ld us\n",test_name,timediff);
- }else
- {
- fprintf(this->output,"\033[1A\033[55C|%10ld us\033[1B\033[80D",timediff);
- }
- if (this->failed_asserts_count > 0)
- {
- this->failed_tests_count++;
- }
-}
-
-
-/**
- * Implementation of tester_t.assert_true.
- */
-static void assert_true(private_tester_t *this, bool to_be_true,char * assert_name)
-{
- if (assert_name == NULL)
- {
- assert_name = "unknown";
- }
-
- pthread_mutex_lock(&(this->mutex));
- if (!to_be_true)
- {
- this->failed_asserts_count++;
- fprintf(this->output," check '%s' failed!\n", assert_name);
- }else
- {
- if (this->display_succeeded_asserts)
- {
- fprintf(this->output," check '%s' succeeded\n", assert_name);
- }
- }
- pthread_mutex_unlock(&(this->mutex));
-}
-
-/**
- * Implementation of tester_t.assert_false.
- */
-static void assert_false(private_tester_t *this, bool to_be_false,char * assert_name)
-{
- this->protected.assert_true(&(this->protected),(!to_be_false),assert_name);
-}
-
-/**
- * Implementation of tester_t.destroy.
- */
-static void destroy(private_tester_t *tester)
-{
- private_tester_t *this = (private_tester_t*) tester;
- pthread_mutex_destroy(&(this->mutex));
- allocator_free(this);
-}
-
-/*
- * Described in header.
- */
-tester_t *tester_create(FILE *output, bool display_succeeded_asserts)
-{
- private_tester_t *this = allocator_alloc_thing(private_tester_t);
-
- /* public functions */
- this->protected.public.destroy = (void (*) (tester_t *))destroy;
- this->protected.public.perform_tests = (void (*) (tester_t *, test_t**)) perform_tests;
- this->protected.public.perform_test = (void (*) (tester_t *, test_t*))perform_test;
- this->protected.assert_true = (void (*) (protected_tester_t *, bool, char*)) assert_true;
- this->protected.assert_false = (void (*) (protected_tester_t *, bool, char*)) assert_false;
-
- /* private functions */
- this->run_test = run_test;
- this->time_difference = time_difference;
-
- /* private data */
- this->display_succeeded_asserts = display_succeeded_asserts;
- this->failed_tests_count = 0;
- this->tests_count = 0;
- this->output = output;
- pthread_mutex_init(&(this->mutex),NULL);
-
- return &(this->protected.public);
-}
diff --git a/Source/charon/utils/tester.h b/Source/charon/utils/tester.h
deleted file mode 100644
index 3decb2039..000000000
--- a/Source/charon/utils/tester.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/**
- * @file tester.h
- *
- * @brief Interface of tester_t.
- *
- */
-
-/*
- * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef TESTER_H_
-#define TESTER_H_
-
-#include <stdio.h>
-
-#include <types.h>
-
-
-/* must be defined here cause it is used in test_t */
-typedef struct protected_tester_t protected_tester_t;
-
-typedef struct test_t test_t;
-
-/**
- * @brief Representing a specified test.
- *
- * @ingroup utils
- */
-struct test_t {
- /**
- * Testfunction called for this test.
- *
- * @param tester associated tester_t object
- */
- void (*test_function) (protected_tester_t * tester);
-
- /**
- * Name of the test.
- */
- char * test_name;
-};
-
-
-typedef struct tester_t tester_t;
-
-/**
- * @brief A class to perform tests.
- *
- * @b Constructors:
- * - tester_create()
- *
- * @ingroup utils
- */
-struct tester_t {
- /**
- * @brief Test all testcases in array tests with specific tester_t object.
- *
- * @param tester tester_t object
- * @param tests pointer to an array of test_t-pointers.
- * The last item has to be NULL to mark end of array.
- */
- void (*perform_tests) (tester_t *tester,test_t **tests);
-
- /**
- * @brief Run a specific test case.
- *
- * @param this tester_t object
- * @param test pointer to a test_t object which will be performed
- */
- void (*perform_test) (tester_t *tester, test_t *test);
-
- /**
- * @brief Destroys a tester_t object.
- *
- * @param tester tester_t object
- */
- void (*destroy) (tester_t *tester);
-};
-
-
-/**
- * @brief A class used in a specific testcase.
- *
- * For each testcase an object of this type is passed to the testfunction. The testfunction uses this
- * object to check specific asserts with protected_tester_t.assert_true and protected_tester_t.assert_false.
- *
- * @b Constructors:
- * - tester_create()
- *
- * @ingroup utils
- */
-struct protected_tester_t {
-
- /**
- * Public functions of a tester_t object
- */
- tester_t public;
-
- /**
- * @brief Is called in a testcase to check a specific situation for TRUE.
- *
- * Log-Values to the tester output are protected from multiple access.
- *
- * @param this tester_t object
- * @param to_be_true assert which has to be TRUE
- * @param assert_name name of the assertion
- */
- void (*assert_true) (protected_tester_t *tester, bool to_be_true, char *assert_name);
-
- /**
- * @brief Is called in a testcase to check a specific situation for FALSE.
- *
- * Log-Values to the tester output are protected from multiple access.
- *
- * @param this tester_t object
- * @param to_be_false assert which has to be FALSE
- * @param assert_name name of the assertion
- */
- void (*assert_false) (protected_tester_t *tester, bool to_be_false, char *assert_name);
-};
-
-
-/**
- * @brief Creates a tester_t object used to perform tests with.
- *
- * @param output test output is written to this output.
- * @param display_succeeded_asserts has to be TRUE, if all asserts should be displayed,
- * FALSE otherwise
- *
- * @return tester_t object
- *
- * @ingroup utils
- */
-tester_t *tester_create(FILE *output, bool display_succeeded_asserts);
-
-#endif /*TESTER_H_*/