Added eap-dynamic plugin which can proxy any other EAP method

This commit is contained in:
Tobias Brunner 2012-08-23 14:42:23 +02:00
parent 7240914955
commit 700ff5def9
9 changed files with 332 additions and 1 deletions

View File

@ -154,6 +154,7 @@ ARG_ENABL_SET([eap-tls], [enable EAP TLS authentication module.])
ARG_ENABL_SET([eap-ttls], [enable EAP TTLS authentication module.])
ARG_ENABL_SET([eap-peap], [enable EAP PEAP authentication module.])
ARG_ENABL_SET([eap-tnc], [enable EAP TNC trusted network connect module.])
ARG_ENABL_SET([eap-dynamic], [enable dynamic EAP proxy module.])
ARG_ENABL_SET([eap-radius], [enable RADIUS proxy authentication module.])
ARG_DISBL_SET([xauth-generic], [disable generic XAuth backend.])
ARG_ENABL_SET([xauth-eap], [enable XAuth backend using EAP methods to verify passwords.])
@ -922,6 +923,7 @@ ADD_PLUGIN([eap-simaka-reauth], [c charon])
ADD_PLUGIN([eap-md5], [c charon nm])
ADD_PLUGIN([eap-gtc], [c charon nm])
ADD_PLUGIN([eap-mschapv2], [c charon nm])
ADD_PLUGIN([eap-dynamic], [c charon])
ADD_PLUGIN([eap-radius], [c charon])
ADD_PLUGIN([eap-tls], [c charon nm])
ADD_PLUGIN([eap-ttls], [c charon nm])
@ -1055,6 +1057,7 @@ AM_CONDITIONAL(USE_EAP_TLS, test x$eap_tls = xtrue)
AM_CONDITIONAL(USE_EAP_TTLS, test x$eap_ttls = xtrue)
AM_CONDITIONAL(USE_EAP_PEAP, test x$eap_peap = xtrue)
AM_CONDITIONAL(USE_EAP_TNC, test x$eap_tnc = xtrue)
AM_CONDITIONAL(USE_EAP_DYNAMIC, test x$eap_dynamic = xtrue)
AM_CONDITIONAL(USE_EAP_RADIUS, test x$eap_radius = xtrue)
AM_CONDITIONAL(USE_XAUTH_GENERIC, test x$xauth_generic = xtrue)
AM_CONDITIONAL(USE_XAUTH_EAP, test x$xauth_eap = xtrue)
@ -1222,6 +1225,7 @@ AC_OUTPUT(
src/libcharon/Makefile
src/libcharon/plugins/eap_aka/Makefile
src/libcharon/plugins/eap_aka_3gpp2/Makefile
src/libcharon/plugins/eap_dynamic/Makefile
src/libcharon/plugins/eap_identity/Makefile
src/libcharon/plugins/eap_md5/Makefile
src/libcharon/plugins/eap_gtc/Makefile

View File

@ -316,6 +316,13 @@ if MONOLITHIC
endif
endif
if USE_EAP_DYNAMIC
SUBDIRS += plugins/eap_dynamic
if MONOLITHIC
libcharon_la_LIBADD += plugins/eap_dynamic/libstrongswan-eap-dynamic.la
endif
endif
if USE_EAP_RADIUS
SUBDIRS += plugins/eap_radius
if MONOLITHIC

View File

@ -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-dynamic.la
else
plugin_LTLIBRARIES = libstrongswan-eap-dynamic.la
endif
libstrongswan_eap_dynamic_la_SOURCES = \
eap_dynamic_plugin.h eap_dynamic_plugin.c eap_dynamic.h eap_dynamic.c
libstrongswan_eap_dynamic_la_LDFLAGS = -module -avoid-version

View File

@ -0,0 +1,146 @@
/*
* Copyright (C) 2012 Tobias Brunner
* 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_dynamic.h"
#include <daemon.h>
#include <library.h>
typedef struct private_eap_dynamic_t private_eap_dynamic_t;
/**
* Private data of an eap_dynamic_t object.
*/
struct private_eap_dynamic_t {
/**
* Public authenticator_t interface.
*/
eap_dynamic_t public;
/**
* ID of the server
*/
identification_t *server;
/**
* ID of the peer
*/
identification_t *peer;
/**
* The proxied EAP method
*/
eap_method_t *method;
};
METHOD(eap_method_t, initiate, status_t,
private_eap_dynamic_t *this, eap_payload_t **out)
{
return FAILED;
}
METHOD(eap_method_t, process, status_t,
private_eap_dynamic_t *this, eap_payload_t *in, eap_payload_t **out)
{
return FAILED;
}
METHOD(eap_method_t, get_type, eap_type_t,
private_eap_dynamic_t *this, u_int32_t *vendor)
{
if (this->method)
{
return this->method->get_type(this->method, vendor);
}
*vendor = 0;
return EAP_DYNAMIC;
}
METHOD(eap_method_t, get_msk, status_t,
private_eap_dynamic_t *this, chunk_t *msk)
{
if (this->method)
{
return this->method->get_msk(this->method, msk);
}
return FAILED;
}
METHOD(eap_method_t, get_identifier, u_int8_t,
private_eap_dynamic_t *this)
{
if (this->method)
{
return this->method->get_identifier(this->method);
}
return 0;
}
METHOD(eap_method_t, set_identifier, void,
private_eap_dynamic_t *this, u_int8_t identifier)
{
if (this->method)
{
this->method->set_identifier(this->method, identifier);
}
}
METHOD(eap_method_t, is_mutual, bool,
private_eap_dynamic_t *this)
{
if (this->method)
{
return this->method->is_mutual(this->method);
}
return FALSE;
}
METHOD(eap_method_t, destroy, void,
private_eap_dynamic_t *this)
{
DESTROY_IF(this->method);
this->server->destroy(this->server);
this->peer->destroy(this->peer);
free(this);
}
/*
* Defined in header
*/
eap_dynamic_t *eap_dynamic_create(identification_t *server,
identification_t *peer)
{
private_eap_dynamic_t *this;
INIT(this,
.public = {
.interface = {
.initiate = _initiate,
.process = _process,
.get_type = _get_type,
.is_mutual = _is_mutual,
.get_msk = _get_msk,
.get_identifier = _get_identifier,
.set_identifier = _set_identifier,
.destroy = _destroy,
},
},
.peer = peer->clone(peer),
.server = server->clone(server),
);
return &this->public;
}

View File

@ -0,0 +1,52 @@
/*
* Copyright (C) 2012 Tobias Brunner
* 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_dynamic_i eap_dynamic
* @{ @ingroup eap_dynamic
*/
#ifndef EAP_DYNAMIC_H_
#define EAP_DYNAMIC_H_
typedef struct eap_dynamic_t eap_dynamic_t;
#include <sa/eap/eap_method.h>
/**
* Implementation of the eap_method_t interface for a virtual EAP method that
* proxies other EAP methods and supports the selection of the actual method
* by the client.
*/
struct eap_dynamic_t {
/**
* Implemented eap_method_t interface
*/
eap_method_t interface;
};
/**
* Create a dynamic EAP proxy serving any supported real method which is also
* supported (or selected) by the client.
*
* @param server ID of the EAP server
* @param peer ID of the EAP client
* @return eap_dynamic_t object
*/
eap_dynamic_t *eap_dynamic_create(identification_t *server,
identification_t *peer);
#endif /** EAP_DYNAMIC_H_ @}*/

View File

@ -0,0 +1,62 @@
/*
* Copyright (C) 2012 Tobias Brunner
* 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_dynamic_plugin.h"
#include "eap_dynamic.h"
#include <daemon.h>
METHOD(plugin_t, get_name, char*,
eap_dynamic_plugin_t *this)
{
return "eap-dynamic";
}
METHOD(plugin_t, get_features, int,
eap_dynamic_plugin_t *this, plugin_feature_t *features[])
{
static plugin_feature_t f[] = {
PLUGIN_CALLBACK(eap_method_register, eap_dynamic_create),
PLUGIN_PROVIDE(EAP_SERVER, EAP_DYNAMIC),
};
*features = f;
return countof(f);
}
METHOD(plugin_t, destroy, void,
eap_dynamic_plugin_t *this)
{
free(this);
}
/*
* see header file
*/
plugin_t *eap_dynamic_plugin_create()
{
eap_dynamic_plugin_t *this;
INIT(this,
.plugin = {
.get_name = _get_name,
.get_features = _get_features,
.destroy = _destroy,
},
);
return &this->plugin;
}

View File

@ -0,0 +1,43 @@
/*
* Copyright (C) 2012 Tobias Brunner
* 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_dynamic eap_dynamic
* @ingroup cplugins
*
* @defgroup eap_dynamic_plugin eap_dynamic_plugin
* @{ @ingroup eap_dynamic
*/
#ifndef EAP_DYNAMIC_PLUGIN_H_
#define EAP_DYNAMIC_PLUGIN_H_
#include <plugins/plugin.h>
typedef struct eap_dynamic_plugin_t eap_dynamic_plugin_t;
/**
* EAP plugin that can use any supported EAP method the client supports or
* prefers to use.
*/
struct eap_dynamic_plugin_t {
/**
* implements plugin interface
*/
plugin_t plugin;
};
#endif /** EAP_DYNAMIC_PLUGIN_H_ @}*/

View File

@ -114,6 +114,7 @@ eap_type_t eap_type_from_string(char *name)
{"peap", EAP_PEAP},
{"mschapv2", EAP_MSCHAPV2},
{"tnc", EAP_TNC},
{"dynamic", EAP_DYNAMIC},
{"radius", EAP_RADIUS},
};

View File

@ -71,7 +71,7 @@ enum eap_type_t {
EAP_EXPERIMENTAL = 255,
/** not a method, but an implementation providing different methods */
EAP_RADIUS = 256,
/** not a method, select actual method dynamically based on e.g. the ID */
/** not a method, select method dynamically based on client selection */
EAP_DYNAMIC = 257,
};