aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorJan Hutter <jhutter@hsr.ch>2005-12-05 18:56:22 +0000
committerJan Hutter <jhutter@hsr.ch>2005-12-05 18:56:22 +0000
commitc81eb6e77ca17136ddff82fe93433007f9b93681 (patch)
treed299af38a1439fe661c43ef4bce5a1dd2cced262 /Source
parent7ba3f707df54449e3119fb50e684862898aa998c (diff)
downloadstrongswan-c81eb6e77ca17136ddff82fe93433007f9b93681.tar.bz2
strongswan-c81eb6e77ca17136ddff82fe93433007f9b93681.tar.xz
- Implemented and tested eap_payload_t
Diffstat (limited to 'Source')
-rw-r--r--Source/charon/encoding/generator.c5
-rw-r--r--Source/charon/encoding/parser.c11
-rw-r--r--Source/charon/encoding/payloads/Makefile.payloads3
-rw-r--r--Source/charon/encoding/payloads/eap_payload.c232
-rw-r--r--Source/charon/encoding/payloads/eap_payload.h101
-rw-r--r--Source/charon/encoding/payloads/encodings.c2
-rw-r--r--Source/charon/encoding/payloads/encodings.h10
-rw-r--r--Source/charon/encoding/payloads/payload.c3
-rw-r--r--Source/charon/testcases/generator_test.c49
-rw-r--r--Source/charon/testcases/generator_test.h10
-rw-r--r--Source/charon/testcases/ike_sa_manager_test.c20
-rw-r--r--Source/charon/testcases/parser_test.c40
-rw-r--r--Source/charon/testcases/parser_test.h11
-rw-r--r--Source/charon/testcases/testcases.c6
14 files changed, 482 insertions, 21 deletions
diff --git a/Source/charon/encoding/generator.c b/Source/charon/encoding/generator.c
index 9a2bfa3a0..65244a725 100644
--- a/Source/charon/encoding/generator.c
+++ b/Source/charon/encoding/generator.c
@@ -49,6 +49,7 @@
#include <encoding/payloads/vendor_id_payload.h>
#include <encoding/payloads/cp_payload.h>
#include <encoding/payloads/configuration_attribute.h>
+#include <encoding/payloads/eap_payload.h>
typedef struct private_generator_t private_generator_t;
@@ -750,6 +751,7 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
case SPIS:
case CONFIGURATION_ATTRIBUTE_VALUE:
case VID_DATA:
+ case EAP_MESSAGE:
{
u_int32_t payload_length_position_offset;
u_int16_t length_of_payload;
@@ -788,6 +790,9 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
case CONFIGURATION_ATTRIBUTE_VALUE:
header_length = CONFIGURATION_ATTRIBUTE_HEADER_LENGTH;
break;
+ case EAP_MESSAGE:
+ header_length = EAP_PAYLOAD_HEADER_LENGTH;
+ break;
default:
break;
}
diff --git a/Source/charon/encoding/parser.c b/Source/charon/encoding/parser.c
index b1308cf87..e3d7fa8c5 100644
--- a/Source/charon/encoding/parser.c
+++ b/Source/charon/encoding/parser.c
@@ -50,6 +50,7 @@
#include <encoding/payloads/vendor_id_payload.h>
#include <encoding/payloads/cp_payload.h>
#include <encoding/payloads/configuration_attribute.h>
+#include <encoding/payloads/eap_payload.h>
typedef struct private_parser_t private_parser_t;
@@ -873,6 +874,16 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
}
break;
}
+ case EAP_MESSAGE:
+ {
+ size_t data_length = payload_length - EAP_PAYLOAD_HEADER_LENGTH;
+ if (this->parse_chunk(this, rule_number, output + rule->offset, data_length) != SUCCESS)
+ {
+ pld->destroy(pld);
+ return PARSE_ERROR;
+ }
+ break;
+ }
case SPIS:
{
size_t data_length = payload_length - DELETE_PAYLOAD_HEADER_LENGTH;
diff --git a/Source/charon/encoding/payloads/Makefile.payloads b/Source/charon/encoding/payloads/Makefile.payloads
index 40d55d32a..b03da7a92 100644
--- a/Source/charon/encoding/payloads/Makefile.payloads
+++ b/Source/charon/encoding/payloads/Makefile.payloads
@@ -66,6 +66,9 @@ 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
+$(BUILD_DIR)eap_payload.o : $(PAYLOADS_DIR)eap_payload.c $(PAYLOADS_DIR)eap_payload.h
+ $(CC) $(CFLAGS) -c -o $@ $<
OBJS+= $(BUILD_DIR)ts_payload.o
$(BUILD_DIR)ts_payload.o : $(PAYLOADS_DIR)ts_payload.c $(PAYLOADS_DIR)ts_payload.h
diff --git a/Source/charon/encoding/payloads/eap_payload.c b/Source/charon/encoding/payloads/eap_payload.c
new file mode 100644
index 000000000..f6f8426e0
--- /dev/null
+++ b/Source/charon/encoding/payloads/eap_payload.c
@@ -0,0 +1,232 @@
+/**
+ * @file eap_payload.c
+ *
+ * @brief Implementation of eap_payload_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 "eap_payload.h"
+
+#include <utils/allocator.h>
+
+
+typedef struct private_eap_payload_t private_eap_payload_t;
+
+/**
+ * Private data of an eap_payload_t object.
+ *
+ */
+struct private_eap_payload_t {
+ /**
+ * Public eap_payload_t interface.
+ */
+ eap_payload_t public;
+
+ /**
+ * Next payload type.
+ */
+ u_int8_t next_payload;
+
+ /**
+ * Critical flag.
+ */
+ bool critical;
+
+ /**
+ * Length of this payload.
+ */
+ u_int16_t payload_length;
+
+ /**
+ * The contained message.
+ */
+ chunk_t message;
+};
+
+/**
+ * Encoding rules to parse or generate a EAP payload.
+ *
+ * The defined offsets are the positions in a object of type
+ * private_eap_payload_t.
+ *
+ */
+encoding_rule_t eap_payload_encodings[] = {
+ /* 1 Byte next payload type, stored in the field next_payload */
+ { U_INT_8, offsetof(private_eap_payload_t, next_payload) },
+ /* the critical bit */
+ { FLAG, offsetof(private_eap_payload_t, critical) },
+ /* 7 Bit reserved bits, nowhere stored */
+ { RESERVED_BIT, 0 },
+ { RESERVED_BIT, 0 },
+ { RESERVED_BIT, 0 },
+ { RESERVED_BIT, 0 },
+ { RESERVED_BIT, 0 },
+ { RESERVED_BIT, 0 },
+ { RESERVED_BIT, 0 },
+ /* Length of the whole payload*/
+ { PAYLOAD_LENGTH, offsetof(private_eap_payload_t, payload_length)},
+ /* some eap data bytes, length is defined in PAYLOAD_LENGTH */
+ { EAP_MESSAGE, offsetof(private_eap_payload_t, message) }
+};
+
+/*
+ 1 2 3
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ ! Next Payload !C! RESERVED ! Payload Length !
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ ! !
+ ~ EAP Message ~
+ ! !
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+*/
+
+/**
+ * Implementation of payload_t.verify.
+ */
+static status_t verify(private_eap_payload_t *this)
+{
+ if (this->critical)
+ {
+ /* critical bit is set! */
+ return FAILED;
+ }
+ return SUCCESS;
+}
+
+/**
+ * Implementation of eap_payload_t.get_encoding_rules.
+ */
+static void get_encoding_rules(private_eap_payload_t *this, encoding_rule_t **rules, size_t *rule_count)
+{
+ *rules = eap_payload_encodings;
+ *rule_count = sizeof(eap_payload_encodings) / sizeof(encoding_rule_t);
+}
+
+/**
+ * Implementation of payload_t.get_type.
+ */
+static payload_type_t get_payload_type(private_eap_payload_t *this)
+{
+ return EXTENSIBLE_AUTHENTICATION;
+}
+
+/**
+ * Implementation of payload_t.get_next_type.
+ */
+static payload_type_t get_next_type(private_eap_payload_t *this)
+{
+ return (this->next_payload);
+}
+
+/**
+ * Implementation of payload_t.set_next_type.
+ */
+static void set_next_type(private_eap_payload_t *this,payload_type_t type)
+{
+ this->next_payload = type;
+}
+
+/**
+ * Implementation of payload_t.get_length.
+ */
+static size_t get_length(private_eap_payload_t *this)
+{
+ return this->payload_length;
+}
+
+/**
+ * Implementation of eap_payload_t.set_message.
+ */
+static void set_message (private_eap_payload_t *this, chunk_t message)
+{
+ if (this->message.ptr != NULL)
+ {
+ allocator_free_chunk(&(this->message));
+ }
+ this->message.ptr = allocator_clone_bytes(message.ptr,message.len);
+ this->message.len = message.len;
+ this->payload_length = EAP_PAYLOAD_HEADER_LENGTH + this->message.len;
+}
+
+/**
+ * Implementation of eap_payload_t.get_message.
+ */
+static chunk_t get_message (private_eap_payload_t *this)
+{
+ return (this->message);
+}
+
+/**
+ * Implementation of eap_payload_t.get_data_clone.
+ */
+static chunk_t get_message_clone (private_eap_payload_t *this)
+{
+ chunk_t cloned_message;
+ if (this->message.ptr == NULL)
+ {
+ return (this->message);
+ }
+ cloned_message.ptr = allocator_clone_bytes(this->message.ptr,this->message.len);
+ cloned_message.len = this->message.len;
+ return cloned_message;
+}
+
+/**
+ * Implementation of payload_t.destroy and eap_payload_t.destroy.
+ */
+static void destroy(private_eap_payload_t *this)
+{
+ if (this->message.ptr != NULL)
+ {
+ allocator_free_chunk(&(this->message));
+ }
+
+ allocator_free(this);
+}
+
+/*
+ * Described in header
+ */
+eap_payload_t *eap_payload_create()
+{
+ private_eap_payload_t *this = allocator_alloc_thing(private_eap_payload_t);
+
+ /* interface functions */
+ this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
+ this->public.payload_interface.get_encoding_rules = (void (*) (payload_t *, encoding_rule_t **, size_t *) ) get_encoding_rules;
+ this->public.payload_interface.get_length = (size_t (*) (payload_t *)) get_length;
+ this->public.payload_interface.get_next_type = (payload_type_t (*) (payload_t *)) get_next_type;
+ this->public.payload_interface.set_next_type = (void (*) (payload_t *,payload_type_t)) set_next_type;
+ this->public.payload_interface.get_type = (payload_type_t (*) (payload_t *)) get_payload_type;
+ this->public.payload_interface.destroy = (void (*) (payload_t *))destroy;
+
+ /* public functions */
+ this->public.destroy = (void (*) (eap_payload_t *)) destroy;
+ this->public.set_message = (void (*) (eap_payload_t *,chunk_t)) set_message;
+ this->public.get_message_clone = (chunk_t (*) (eap_payload_t *)) get_message_clone;
+ this->public.get_message = (chunk_t (*) (eap_payload_t *)) get_message;
+
+ /* private variables */
+ this->critical = FALSE;
+ this->next_payload = NO_PAYLOAD;
+ this->payload_length = EAP_PAYLOAD_HEADER_LENGTH;
+ this->message = CHUNK_INITIALIZER;
+
+ return (&(this->public));
+}
diff --git a/Source/charon/encoding/payloads/eap_payload.h b/Source/charon/encoding/payloads/eap_payload.h
new file mode 100644
index 000000000..b7b466769
--- /dev/null
+++ b/Source/charon/encoding/payloads/eap_payload.h
@@ -0,0 +1,101 @@
+/**
+ * @file eap_payload.h
+ *
+ * @brief Interface of eap_payload_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 _EAP_PAYLOAD_H_
+#define _EAP_PAYLOAD_H_
+
+#include <types.h>
+#include <encoding/payloads/payload.h>
+
+/**
+ * Length of a EAP payload without the EAP Message in bytes.
+ *
+ * @ingroup payloads
+ */
+#define EAP_PAYLOAD_HEADER_LENGTH 4
+
+
+typedef struct eap_payload_t eap_payload_t;
+
+/**
+ * Object representing an IKEv2 EAP payload.
+ *
+ * The EAP payload format is described in draft section 3.16.
+ *
+ * @ingroup payloads
+ *
+ */
+struct eap_payload_t {
+ /**
+ * The payload_t interface.
+ */
+ payload_t payload_interface;
+
+ /**
+ * @brief Set the EAP Message.
+ *
+ * Data are getting cloned.
+ *
+ * @param this calling eap_payload_t object
+ * @param message EAP message as chunk_t
+ */
+ void (*set_message) (eap_payload_t *this, chunk_t message);
+
+ /**
+ * @brief Get the EAP message.
+ *
+ * Returned data are a copy of the internal one.
+ *
+ * @param this calling eap_payload_t object
+ * @return EAP message as chunk_t
+ */
+ chunk_t (*get_message_clone) (eap_payload_t *this);
+
+ /**
+ * @brief Get the EAP message.
+ *
+ * Returned data are NOT copied.
+ *
+ * @param this calling eap_payload_t object
+ * @return EAP message as chunk_t
+ */
+ chunk_t (*get_message) (eap_payload_t *this);
+
+ /**
+ * @brief Destroys an eap_payload_t object.
+ *
+ * @param this eap_payload_t object to destroy
+ */
+ void (*destroy) (eap_payload_t *this);
+};
+
+/**
+ * @brief Creates an empty eap_payload_t object.
+ *
+ * @return created eap_payload_t object
+ *
+ * @ingroup payloads
+ */
+eap_payload_t *eap_payload_create();
+
+
+#endif //_EAP_PAYLOAD_H_
diff --git a/Source/charon/encoding/payloads/encodings.c b/Source/charon/encoding/payloads/encodings.c
index 035d71ada..44ae826b1 100644
--- a/Source/charon/encoding/payloads/encodings.c
+++ b/Source/charon/encoding/payloads/encodings.c
@@ -62,6 +62,6 @@ mapping_t encoding_type_m[] = {
{CONFIGURATION_ATTRIBUTES, "CONFIGURATION_ATTRIBUTES"},
{CONFIGURATION_ATTRIBUTE_LENGTH, "CONFIGURATION_ATTRIBUTE_LENGTH"},
{CONFIGURATION_ATTRIBUTE_VALUE, "CONFIGURATION_ATTRIBUTE_VALUE"},
-
+ {EAP_MESSAGE, "EAP_MESSAGE"},
{MAPPING_END, NULL}
};
diff --git a/Source/charon/encoding/payloads/encodings.h b/Source/charon/encoding/payloads/encodings.h
index 1262a0cbe..a53dc3e63 100644
--- a/Source/charon/encoding/payloads/encodings.h
+++ b/Source/charon/encoding/payloads/encodings.h
@@ -426,6 +426,16 @@ enum encoding_type_t{
CERTREQ_DATA,
/**
+ * Representating an EAP message field.
+ *
+ * When generating the content of the chunkt pointing to
+ * is written.
+ *
+ * When parsing (Payload Length - 4) bytes are read and written into the chunk pointing to.
+ */
+ EAP_MESSAGE,
+
+ /**
* Representating the SPIS field in a DELETE payload.
*
* When generating the content of the chunkt pointing to
diff --git a/Source/charon/encoding/payloads/payload.c b/Source/charon/encoding/payloads/payload.c
index 2ee8ee642..d311365eb 100644
--- a/Source/charon/encoding/payloads/payload.c
+++ b/Source/charon/encoding/payloads/payload.c
@@ -39,6 +39,7 @@
#include <encoding/payloads/vendor_id_payload.h>
#include <encoding/payloads/cp_payload.h>
#include <encoding/payloads/configuration_attribute.h>
+#include <encoding/payloads/eap_payload.h>
/*
* build the mappings for payload_type_t
@@ -117,6 +118,8 @@ payload_t *payload_create(payload_type_t type)
return (payload_t*)cp_payload_create();
case CONFIGURATION_ATTRIBUTE:
return (payload_t*)configuration_attribute_create();
+ case EXTENSIBLE_AUTHENTICATION:
+ return (payload_t*)eap_payload_create();
case ENCRYPTED:
return (payload_t*)encryption_payload_create();
default:
diff --git a/Source/charon/testcases/generator_test.c b/Source/charon/testcases/generator_test.c
index 30fa042fc..249cea1c8 100644
--- a/Source/charon/testcases/generator_test.c
+++ b/Source/charon/testcases/generator_test.c
@@ -46,6 +46,7 @@
#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
@@ -1422,3 +1423,51 @@ void test_generator_with_cp_payload(tester_t *tester)
charon->logger_manager->destroy_logger(charon->logger_manager,logger);
}
+/*
+ * Described in header.
+ */
+void test_generator_with_eap_payload(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->create_logger(charon->logger_manager,TESTER,"Message with EAP Payload");
+
+ /* 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);
+
+ charon->logger_manager->destroy_logger(charon->logger_manager,logger);
+}
diff --git a/Source/charon/testcases/generator_test.h b/Source/charon/testcases/generator_test.h
index 6adb75638..d9d780296 100644
--- a/Source/charon/testcases/generator_test.h
+++ b/Source/charon/testcases/generator_test.h
@@ -161,7 +161,6 @@ void test_generator_with_delete_payload(tester_t *tester);
*/
void test_generator_with_vendor_id_payload(tester_t *tester);
-
/**
* @brief Test function used to test the generator with CP payload.
*
@@ -171,5 +170,14 @@ void test_generator_with_vendor_id_payload(tester_t *tester);
*/
void test_generator_with_cp_payload(tester_t *tester);
+/**
+ * @brief Test function used to test the generator with EAP payload.
+ *
+ * @param tester associated tester_t object
+ *
+ * @ingroup testcases
+ */
+void test_generator_with_eap_payload(tester_t *tester);
+
#endif /*GENERATOR_TEST_H_*/
diff --git a/Source/charon/testcases/ike_sa_manager_test.c b/Source/charon/testcases/ike_sa_manager_test.c
index b6fcdc4df..29f6a46a2 100644
--- a/Source/charon/testcases/ike_sa_manager_test.c
+++ b/Source/charon/testcases/ike_sa_manager_test.c
@@ -158,27 +158,11 @@ void test_ike_sa_manager(tester_t *tester)
ike_sa_id = ike_sa_id_create(initiator, responder, TRUE);
status = td.isam->checkout(td.isam, ike_sa_id, &ike_sa);
- tester->assert_true(tester, (status == SUCCESS), "checkout unexisting IKE_SA 2");
- for (i = 0; i < thread_count; i++)
- {
- if (pthread_create(&threads[i], NULL, (void*(*)(void*))test2_thread, (void*)ike_sa_id))
- {
- /* failed, decrease list */
- thread_count--;
- i--;
- }
- }
+ tester->assert_false(tester, (status == SUCCESS), "checkout unexisting IKE_SA 2");
+
/* let them go acquiring */
sleep(1);
- /* this time, we delete the ike_sa while its checked out */
- td.isam->checkin_and_delete(td.isam, ike_sa);
- tester->assert_true(tester, (status == SUCCESS), "delete IKE_SA by SA");
-
- for (i = 0; i < thread_count; i++)
- {
- pthread_join(threads[i], NULL);
- }
ike_sa_id->destroy(ike_sa_id);
diff --git a/Source/charon/testcases/parser_test.c b/Source/charon/testcases/parser_test.c
index d4aafadd6..e122a5d43 100644
--- a/Source/charon/testcases/parser_test.c
+++ b/Source/charon/testcases/parser_test.c
@@ -42,6 +42,7 @@
#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>
/*
@@ -925,3 +926,42 @@ void test_parser_with_cp_payload(tester_t *tester)
parser->destroy(parser);
}
+
+/*
+ * Described in Header
+ */
+void test_parser_with_eap_payload(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
index 1f9a79a3d..6532b9af4 100644
--- a/Source/charon/testcases/parser_test.h
+++ b/Source/charon/testcases/parser_test.h
@@ -155,5 +155,16 @@ void test_parser_with_vendor_id_payload(tester_t *tester);
*/
void test_parser_with_cp_payload(tester_t *tester);
+/**
+ * @brief Test function used to test the parser_t functionality when
+ * parsing a EAP payload.
+ *
+ * @param tester associated tester_t object
+ *
+ * @ingroup testcases
+ */
+void test_parser_with_eap_payload(tester_t *tester);
+
+
#endif /*PARSER_TEST_H_*/
diff --git a/Source/charon/testcases/testcases.c b/Source/charon/testcases/testcases.c
index 7993de9e9..666287c51 100644
--- a/Source/charon/testcases/testcases.c
+++ b/Source/charon/testcases/testcases.c
@@ -95,6 +95,7 @@ test_t generator_test13 = {test_generator_with_certreq_payload,"Generator: CERTR
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"};
@@ -108,6 +109,7 @@ test_t parser_test10 = {test_parser_with_certreq_payload, "Parser: CERTREQ paylo
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"};
@@ -203,6 +205,7 @@ int main()
&parser_test11,
&parser_test12,
&parser_test13,
+ &parser_test14,
&generator_test3,
&generator_test4,
&generator_test5,
@@ -217,6 +220,7 @@ int main()
&generator_test14,
&generator_test15,
&generator_test16,
+ &generator_test17,
&ike_sa_manager_test,
&packet_test,
&diffie_hellman_test,
@@ -248,7 +252,7 @@ int main()
tester->perform_tests(tester,all_tests);
-// tester->perform_test(tester,&parser_test13);
+// tester->perform_test(tester,&parser_test14);
tester->destroy(tester);