From: Martin Willi Date: Thu, 30 Aug 2012 13:37:05 +0000 (+0200) Subject: Add a plugin stub for Microsoft Statement of Health EAP module X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4a294eb6ecb3af7304fa20cf5107744c71ac6da;p=thirdparty%2Fstrongswan.git Add a plugin stub for Microsoft Statement of Health EAP module --- diff --git a/configure.in b/configure.in index f233b0ab4d..50d3d3c913 100644 --- a/configure.in +++ b/configure.in @@ -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-ms-soh], [enable Microsoft Statement of Health EAP 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.]) @@ -929,6 +930,7 @@ ADD_PLUGIN([eap-tls], [c charon nm]) ADD_PLUGIN([eap-ttls], [c charon nm]) ADD_PLUGIN([eap-peap], [c charon nm]) ADD_PLUGIN([eap-tnc], [c charon]) +ADD_PLUGIN([eap-ms-soh], [c charon]) ADD_PLUGIN([xauth-generic], [c charon]) ADD_PLUGIN([xauth-eap], [c charon]) ADD_PLUGIN([xauth-pam], [c charon]) @@ -1057,6 +1059,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_MS_SOH, test x$eap_ms_soh = 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) @@ -1240,6 +1243,7 @@ AC_OUTPUT( src/libcharon/plugins/eap_ttls/Makefile src/libcharon/plugins/eap_peap/Makefile src/libcharon/plugins/eap_tnc/Makefile + src/libcharon/plugins/eap_ms_soh/Makefile src/libcharon/plugins/eap_radius/Makefile src/libcharon/plugins/xauth_generic/Makefile src/libcharon/plugins/xauth_eap/Makefile diff --git a/src/libcharon/Makefile.am b/src/libcharon/Makefile.am index 3869066a80..0c605d42c3 100644 --- a/src/libcharon/Makefile.am +++ b/src/libcharon/Makefile.am @@ -358,6 +358,13 @@ if MONOLITHIC endif endif +if USE_EAP_MS_SOH + SUBDIRS += plugins/eap_ms_soh +if MONOLITHIC + libcharon_la_LIBADD += plugins/eap_ms_soh/libstrongswan-eap-ms-soh.la +endif +endif + if USE_TLS if MONOLITHIC # otherwise this library is linked to eap_tls diff --git a/src/libcharon/plugins/eap_ms_soh/Makefile.am b/src/libcharon/plugins/eap_ms_soh/Makefile.am new file mode 100644 index 0000000000..ca7b04ea88 --- /dev/null +++ b/src/libcharon/plugins/eap_ms_soh/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-ms-soh.la +else +plugin_LTLIBRARIES = libstrongswan-eap-ms-soh.la +endif + +libstrongswan_eap_ms_soh_la_SOURCES = \ + eap_ms_soh_plugin.h eap_ms_soh_plugin.c eap_ms_soh.h eap_ms_soh.c + +libstrongswan_eap_ms_soh_la_LDFLAGS = -module -avoid-version diff --git a/src/libcharon/plugins/eap_ms_soh/eap_ms_soh.c b/src/libcharon/plugins/eap_ms_soh/eap_ms_soh.c new file mode 100644 index 0000000000..4cc249785b --- /dev/null +++ b/src/libcharon/plugins/eap_ms_soh/eap_ms_soh.c @@ -0,0 +1,132 @@ +/* + * Copyright (C) 2010 Martin Willi + * Copyright (C) 2010 revosec AG + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See . + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "eap_ms_soh.h" + +#include +#include + +typedef struct private_eap_ms_soh_t private_eap_ms_soh_t; + +/** + * Private data of an eap_ms_soh_t object. + */ +struct private_eap_ms_soh_t { + + /** + * Public interface. + */ + eap_ms_soh_t public; + + /** + * Current EAP packet identifier + */ + u_int8_t identifier; +}; + +METHOD(eap_method_t, initiate, status_t, + private_eap_ms_soh_t *this, eap_payload_t **out) +{ + return FAILED; +} + +METHOD(eap_method_t, process, status_t, + private_eap_ms_soh_t *this, eap_payload_t *in, eap_payload_t **out) +{ + return FAILED; +} + +METHOD(eap_method_t, get_type, eap_type_t, + private_eap_ms_soh_t *this, u_int32_t *vendor) +{ + *vendor = PEN_MICROSOFT; + return EAP_MS_SOH; +} + +METHOD(eap_method_t, get_msk, status_t, + private_eap_ms_soh_t *this, chunk_t *msk) +{ + return FAILED; +} + +METHOD(eap_method_t, get_identifier, u_int8_t, + private_eap_ms_soh_t *this) +{ + return this->identifier; +} + +METHOD(eap_method_t, set_identifier, void, + private_eap_ms_soh_t *this, u_int8_t identifier) +{ + this->identifier = identifier; +} + +METHOD(eap_method_t, is_mutual, bool, + private_eap_ms_soh_t *this) +{ + return TRUE; +} + +METHOD(eap_method_t, destroy, void, + private_eap_ms_soh_t *this) +{ + free(this); +} + +/** + * Generic private constructor + */ +static private_eap_ms_soh_t *create_empty() +{ + private_eap_ms_soh_t *this; + + INIT(this, + .public = { + .eap_method = { + .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, + }, + }, + ); + + return this; +} + +eap_ms_soh_t *eap_ms_soh_create_server(identification_t *server, + identification_t *peer) +{ + private_eap_ms_soh_t *this; + + this = create_empty(); + + /* generate a non-zero identifier */ + do { + this->identifier = random(); + } while (!this->identifier); + + return &this->public; +} + +eap_ms_soh_t *eap_ms_soh_create_peer(identification_t *server, + identification_t *peer) +{ + return &create_empty()->public; +} diff --git a/src/libcharon/plugins/eap_ms_soh/eap_ms_soh.h b/src/libcharon/plugins/eap_ms_soh/eap_ms_soh.h new file mode 100644 index 0000000000..3c726e9b27 --- /dev/null +++ b/src/libcharon/plugins/eap_ms_soh/eap_ms_soh.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2012 Martin Willi + * Copyright (C) 2012 revosec AG + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See . + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +/** + * @defgroup eap_ms_soh_i eap_ms_soh + * @{ @ingroup eap_ms_soh + */ + +#ifndef EAP_MS_SOH_H_ +#define EAP_MS_SOH_H_ + +typedef struct eap_ms_soh_t eap_ms_soh_t; + +#include + +/** + * Implementation of Microsoft vendor specific eap_method_t EAP-MS-SOH. + */ +struct eap_ms_soh_t { + + /** + * Implements eap_method_t interface. + */ + eap_method_t eap_method; +}; + +/** + * Creates the EAP method EAP-soh acting as server. + * + * @param server ID of the EAP server + * @param peer ID of the EAP client + * @return eap_ms_soh_t object + */ +eap_ms_soh_t *eap_ms_soh_create_server(identification_t *server, + identification_t *peer); + +/** + * Creates the EAP method EAP-soh acting as peer. + * + * @param server ID of the EAP server + * @param peer ID of the EAP client + * @return eap_ms_soh_t object + */ +eap_ms_soh_t *eap_ms_soh_create_peer(identification_t *server, + identification_t *peer); + +#endif /** EAP_MS_SOH_H_ @}*/ diff --git a/src/libcharon/plugins/eap_ms_soh/eap_ms_soh_plugin.c b/src/libcharon/plugins/eap_ms_soh/eap_ms_soh_plugin.c new file mode 100644 index 0000000000..35f99a8b66 --- /dev/null +++ b/src/libcharon/plugins/eap_ms_soh/eap_ms_soh_plugin.c @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2012 Martin Willi + * Copyright (C) 2012 revosec AG + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See . + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "eap_ms_soh_plugin.h" + +#include "eap_ms_soh.h" + +#include + +METHOD(plugin_t, get_name, char*, + eap_ms_soh_plugin_t *this) +{ + return "eap-ms-soh"; +} + +/** + * Callback function registering EAP-SOH + */ +static bool register_eap_ms_soh(plugin_t *plugin, plugin_feature_t *feature, + bool reg, void *data) +{ + if (reg) + { + charon->eap->add_method(charon->eap, EAP_MS_SOH, PEN_MICROSOFT, + data == eap_ms_soh_create_server ? EAP_SERVER : EAP_PEER, + (eap_constructor_t)data); + } + else + { + charon->eap->remove_method(charon->eap, (eap_constructor_t)data); + } + return TRUE; +} + +METHOD(plugin_t, get_features, int, + eap_ms_soh_plugin_t *this, plugin_feature_t *features[]) +{ + static plugin_feature_t f[] = { + PLUGIN_CALLBACK(register_eap_ms_soh, eap_ms_soh_create_server), + PLUGIN_PROVIDE(CUSTOM, "EAP-MS-SOH server"), + PLUGIN_CALLBACK(register_eap_ms_soh, eap_ms_soh_create_peer), + PLUGIN_PROVIDE(CUSTOM, "EAP-MS-SOH client"), + }; + *features = f; + return countof(f); +} + +METHOD(plugin_t, destroy, void, + eap_ms_soh_plugin_t *this) +{ + free(this); +} + +/* + * see header file + */ +plugin_t *eap_ms_soh_plugin_create() +{ + eap_ms_soh_plugin_t *this; + + INIT(this, + .plugin = { + .get_name = _get_name, + .get_features = _get_features, + .destroy = _destroy, + }, + ); + + return &this->plugin; +} diff --git a/src/libcharon/plugins/eap_ms_soh/eap_ms_soh_plugin.h b/src/libcharon/plugins/eap_ms_soh/eap_ms_soh_plugin.h new file mode 100644 index 0000000000..1039e851ab --- /dev/null +++ b/src/libcharon/plugins/eap_ms_soh/eap_ms_soh_plugin.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2012 Martin Willi + * Copyright (C) 2012 revosec AG + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See . + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +/** + * @defgroup eap_ms_soh eap_ms_soh + * @ingroup cplugins + * + * @defgroup eap_ms_soh_plugin eap_ms_soh_plugin + * @{ @ingroup eap_ms_soh + */ + +#ifndef EAP_MS_SOH_PLUGIN_H_ +#define EAP_MS_SOH_PLUGIN_H_ + +#include + +typedef struct eap_ms_soh_plugin_t eap_ms_soh_plugin_t; + +/** + * Plugin providing Microsoft specific EAP_MS_SOH (Statement of Health). + */ +struct eap_ms_soh_plugin_t { + + /** + * Implements plugin interface + */ + plugin_t plugin; +}; + +/** + * Create a eap_ms_soh_plugin instance. + */ +plugin_t *eap_ms_soh_plugin_create(); + +#endif /** EAP_MS_SOH_PLUGIN_H_ @}*/