aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Steffen <andreas.steffen@strongswan.org>2010-08-30 15:36:24 +0200
committerAndreas Steffen <andreas.steffen@strongswan.org>2010-08-30 15:36:34 +0200
commitd93e2e5409b9d53ea0f2efb303691f0ce2d091ce (patch)
tree773fbb9c9bd4af4eaef7fb13bc8eb367832359bf /src
parent577893612fa7d5a9956bf9fbe60d1de77092810e (diff)
downloadstrongswan-d93e2e5409b9d53ea0f2efb303691f0ce2d091ce.tar.bz2
strongswan-d93e2e5409b9d53ea0f2efb303691f0ce2d091ce.tar.xz
created an eap-tnc method hull
Diffstat (limited to 'src')
-rw-r--r--src/libcharon/Makefile.am7
-rw-r--r--src/libcharon/plugins/eap_tnc/Makefile.am16
-rw-r--r--src/libcharon/plugins/eap_tnc/eap_tnc.c190
-rw-r--r--src/libcharon/plugins/eap_tnc/eap_tnc.h57
-rw-r--r--src/libcharon/plugins/eap_tnc/eap_tnc_plugin.c51
-rw-r--r--src/libcharon/plugins/eap_tnc/eap_tnc_plugin.h42
6 files changed, 363 insertions, 0 deletions
diff --git a/src/libcharon/Makefile.am b/src/libcharon/Makefile.am
index 3d72294bd..07ef13418 100644
--- a/src/libcharon/Makefile.am
+++ b/src/libcharon/Makefile.am
@@ -332,6 +332,13 @@ if MONOLITHIC
endif
endif
+if USE_EAP_TNC
+ SUBDIRS += plugins/eap_tnc
+if MONOLITHIC
+ libcharon_la_LIBADD += plugins/eap_tnc/libstrongswan-eap-tnc.la
+endif
+endif
+
if USE_TLS
if MONOLITHIC
# otherwise this library is linked to eap_tls
diff --git a/src/libcharon/plugins/eap_tnc/Makefile.am b/src/libcharon/plugins/eap_tnc/Makefile.am
new file mode 100644
index 000000000..ad77155b0
--- /dev/null
+++ b/src/libcharon/plugins/eap_tnc/Makefile.am
@@ -0,0 +1,16 @@
+
+INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libhydra \
+ -I$(top_srcdir)/src/libcharon
+
+AM_CFLAGS = -rdynamic
+
+if MONOLITHIC
+noinst_LTLIBRARIES = libstrongswan-eap-tnc.la
+else
+plugin_LTLIBRARIES = libstrongswan-eap-tnc.la
+endif
+
+libstrongswan_eap_tnc_la_SOURCES = \
+ eap_tnc_plugin.h eap_tnc_plugin.c eap_tnc.h eap_tnc.c
+
+libstrongswan_eap_tnc_la_LDFLAGS = -module -avoid-version
diff --git a/src/libcharon/plugins/eap_tnc/eap_tnc.c b/src/libcharon/plugins/eap_tnc/eap_tnc.c
new file mode 100644
index 000000000..5164d9a3a
--- /dev/null
+++ b/src/libcharon/plugins/eap_tnc/eap_tnc.c
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 2007 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_tnc.h"
+
+#include <daemon.h>
+#include <library.h>
+
+typedef struct private_eap_tnc_t private_eap_tnc_t;
+
+/**
+ * Private data of an eap_tnc_t object.
+ */
+struct private_eap_tnc_t {
+
+ /**
+ * Public authenticator_t interface.
+ */
+ eap_tnc_t public;
+
+ /**
+ * ID of the server
+ */
+ identification_t *server;
+
+ /**
+ * ID of the peer
+ */
+ identification_t *peer;
+};
+
+/**
+ * Flags of an EAP-TNC message
+ */
+typedef enum {
+ EAP_TNC_LENGTH = (1<<7),
+ EAP_TNC_MORE_FRAGS = (1<<6),
+ EAP_TNC_START = (1<<5),
+ EAP_TNC_DH = (1<<4),
+ EAP_TNC_VERSION = 0x07
+} eap_tnc_flags_t;
+
+/**
+ * EAP-TNC packet format
+ */
+typedef struct __attribute__((packed)) {
+ u_int8_t code;
+ u_int8_t identifier;
+ u_int16_t length;
+ u_int8_t type;
+ u_int8_t flags;
+} eap_tnc_packet_t;
+
+METHOD(eap_method_t, initiate_peer, status_t,
+ private_eap_tnc_t *this, eap_payload_t **out)
+{
+ /* peer never initiates */
+ return FAILED;
+}
+
+METHOD(eap_method_t, initiate_server, status_t,
+ private_eap_tnc_t *this, eap_payload_t **out)
+{
+ return NEED_MORE;
+}
+
+METHOD(eap_method_t, process_peer, status_t,
+ private_eap_tnc_t *this, eap_payload_t *in, eap_payload_t **out)
+{
+ eap_tnc_packet_t *pkt;
+ chunk_t data;
+
+ data = in->get_data(in);
+
+ pkt = (eap_tnc_packet_t*)data.ptr;
+ if (data.len < sizeof(eap_tnc_packet_t) ||
+ untoh16(&pkt->length) != data.len)
+ {
+ DBG1(DBG_IKE, "invalid EAP-TNC packet length");
+ return FAILED;
+ }
+ if (pkt->flags & EAP_TNC_START)
+ {
+ DBG1(DBG_IKE, "EAP-TNC version is v%u", pkt->flags & EAP_TNC_VERSION);
+ }
+ *out = eap_payload_create_nak(in->get_identifier(in));
+
+ return NEED_MORE;
+}
+
+METHOD(eap_method_t, process_server, status_t,
+ private_eap_tnc_t *this, eap_payload_t *in, eap_payload_t **out)
+{
+ chunk_t data;
+
+ data = in->get_data(in);
+ DBG2(DBG_IKE, "received EAP-TNC data: %B", &data);
+
+ return SUCCESS;
+}
+
+METHOD(eap_method_t, get_type, eap_type_t,
+ private_eap_tnc_t *this, u_int32_t *vendor)
+{
+ *vendor = 0;
+ return EAP_TNC;
+}
+
+METHOD(eap_method_t, get_msk, status_t,
+ private_eap_tnc_t *this, chunk_t *msk)
+{
+ return FAILED;
+}
+
+METHOD(eap_method_t, is_mutual, bool,
+ private_eap_tnc_t *this)
+{
+ return FALSE;
+}
+
+METHOD(eap_method_t, destroy, void,
+ private_eap_tnc_t *this)
+{
+ this->peer->destroy(this->peer);
+ this->server->destroy(this->server);
+ free(this);
+}
+
+/*
+ * See header
+ */
+eap_tnc_t *eap_tnc_create_server(identification_t *server, identification_t *peer)
+{
+ private_eap_tnc_t *this;
+
+ INIT(this,
+ .public = {
+ .eap_method = {
+ .initiate = _initiate_server,
+ .process = _process_server,
+ .get_type = _get_type,
+ .is_mutual = _is_mutual,
+ .get_msk = _get_msk,
+ .destroy = _destroy,
+ },
+ },
+ .peer = peer->clone(peer),
+ .server = server->clone(server),
+ );
+
+ return &this->public;
+}
+
+/*
+ * See header
+ */
+eap_tnc_t *eap_tnc_create_peer(identification_t *server, identification_t *peer)
+{
+ private_eap_tnc_t *this;
+
+ INIT(this,
+ .public = {
+ .eap_method = {
+ .initiate = _initiate_peer,
+ .process = _process_peer,
+ .get_type = _get_type,
+ .is_mutual = _is_mutual,
+ .get_msk = _get_msk,
+ .destroy = _destroy,
+ },
+ },
+ .peer = peer->clone(peer),
+ .server = server->clone(server),
+ );
+
+ return &this->public;
+}
+
diff --git a/src/libcharon/plugins/eap_tnc/eap_tnc.h b/src/libcharon/plugins/eap_tnc/eap_tnc.h
new file mode 100644
index 000000000..7e166fb60
--- /dev/null
+++ b/src/libcharon/plugins/eap_tnc/eap_tnc.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2010 Andreas Steffen
+ * 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.
+ */
+
+/**
+ * @defgroup eap_tnc_i eap_tnc
+ * @{ @ingroup eap_tnc
+ */
+
+#ifndef EAP_TNC_H_
+#define EAP_TNC_H_
+
+typedef struct eap_tnc_t eap_tnc_t;
+
+#include <sa/authenticators/eap/eap_method.h>
+
+/**
+ * Implementation of the eap_method_t interface using EAP-TNC.
+ */
+struct eap_tnc_t {
+
+ /**
+ * Implemented eap_method_t interface.
+ */
+ eap_method_t eap_method;
+};
+
+/**
+ * Creates the EAP method EAP-TNC acting as server.
+ *
+ * @param server ID of the EAP server
+ * @param peer ID of the EAP client
+ * @return eap_tnc_t object
+ */
+eap_tnc_t *eap_tnc_create_server(identification_t *server, identification_t *peer);
+
+/**
+ * Creates the EAP method EAP-TNC acting as peer.
+ *
+ * @param server ID of the EAP server
+ * @param peer ID of the EAP client
+ * @return eap_tnc_t object
+ */
+eap_tnc_t *eap_tnc_create_peer(identification_t *server, identification_t *peer);
+
+#endif /** EAP_TNC_H_ @}*/
diff --git a/src/libcharon/plugins/eap_tnc/eap_tnc_plugin.c b/src/libcharon/plugins/eap_tnc/eap_tnc_plugin.c
new file mode 100644
index 000000000..7430e4cac
--- /dev/null
+++ b/src/libcharon/plugins/eap_tnc/eap_tnc_plugin.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2010 Andreas Steffen
+ * 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_tnc_plugin.h"
+#include "eap_tnc.h"
+
+#include <daemon.h>
+
+METHOD(plugin_t, destroy, void,
+ eap_tnc_plugin_t *this)
+{
+ charon->eap->remove_method(charon->eap,
+ (eap_constructor_t)eap_tnc_create_server);
+ charon->eap->remove_method(charon->eap,
+ (eap_constructor_t)eap_tnc_create_peer);
+ free(this);
+}
+
+/*
+ * see header file
+ */
+plugin_t *eap_tnc_plugin_create()
+{
+ eap_tnc_plugin_t *this;
+
+ INIT(this,
+ .plugin = {
+ .destroy = _destroy,
+ },
+ );
+
+ charon->eap->add_method(charon->eap, EAP_TNC, 0, EAP_SERVER,
+ (eap_constructor_t)eap_tnc_create_server);
+ charon->eap->add_method(charon->eap, EAP_TNC, 0, EAP_PEER,
+ (eap_constructor_t)eap_tnc_create_peer);
+
+ return &this->plugin;
+}
+
diff --git a/src/libcharon/plugins/eap_tnc/eap_tnc_plugin.h b/src/libcharon/plugins/eap_tnc/eap_tnc_plugin.h
new file mode 100644
index 000000000..5ed4647c4
--- /dev/null
+++ b/src/libcharon/plugins/eap_tnc/eap_tnc_plugin.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2010 Andreas Steffen
+ * 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.
+ */
+
+/**
+ * @defgroup eap_tnc eap_tnc
+ * @ingroup cplugins
+ *
+ * @defgroup eap_tnc_plugin eap_tnc_plugin
+ * @{ @ingroup eap_tnc
+ */
+
+#ifndef EAP_TNC_PLUGIN_H_
+#define EAP_TNC_PLUGIN_H_
+
+#include <plugins/plugin.h>
+
+typedef struct eap_tnc_plugin_t eap_tnc_plugin_t;
+
+/**
+ * EAP-MD5 plugin
+ */
+struct eap_tnc_plugin_t {
+
+ /**
+ * implements plugin interface
+ */
+ plugin_t plugin;
+};
+
+#endif /** EAP_TNC_PLUGIN_H_ @}*/