Added EAP-TLS plugin stub

This commit is contained in:
Martin Willi
2010-08-03 15:39:24 +02:00
parent 86a73f16ab
commit 2107953804
11 changed files with 301 additions and 1 deletions
+10
View File
@@ -0,0 +1,10 @@
INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
AM_CFLAGS = -rdynamic
plugin_LTLIBRARIES = libstrongswan-eap-tls.la
libstrongswan_eap_tls_la_SOURCES = eap_tls_plugin.h eap_tls_plugin.c \
eap_tls.h eap_tls.c
libstrongswan_eap_tls_la_LDFLAGS = -module -avoid-version
+122
View File
@@ -0,0 +1,122 @@
/*
* 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 <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_tls.h"
#include <daemon.h>
#include <library.h>
typedef struct private_eap_tls_t private_eap_tls_t;
/**
* Private data of an eap_tls_t object.
*/
struct private_eap_tls_t {
/**
* Public interface.
*/
eap_tls_t public;
/**
* ID of the server
*/
identification_t *server;
/**
* ID of the peer
*/
identification_t *peer;
/**
* Is this method instance acting as server?
*/
bool is_server;
};
METHOD(eap_method_t, initiate, status_t,
private_eap_tls_t *this, eap_payload_t **out)
{
return FAILED;
}
METHOD(eap_method_t, process, status_t,
private_eap_tls_t *this, eap_payload_t *in, eap_payload_t **out)
{
return FAILED;
}
METHOD(eap_method_t, get_type, eap_type_t,
private_eap_tls_t *this, u_int32_t *vendor)
{
*vendor = 0;
return EAP_TLS;
}
METHOD(eap_method_t, get_msk, status_t,
private_eap_tls_t *this, chunk_t *msk)
{
return FAILED;
}
METHOD(eap_method_t, is_mutual, bool,
private_eap_tls_t *this)
{
return TRUE;
}
METHOD(eap_method_t, destroy, void,
private_eap_tls_t *this)
{
this->peer->destroy(this->peer);
this->server->destroy(this->server);
free(this);
}
/**
* Generic private constructor
*/
static eap_tls_t *eap_tls_create(identification_t *server,
identification_t *peer, bool is_server)
{
private_eap_tls_t *this;
INIT(this,
.public.eap_method = {
.initiate = _initiate,
.process = _process,
.get_type = _get_type,
.is_mutual = _is_mutual,
.get_msk = _get_msk,
.destroy = _destroy,
},
.peer = peer->clone(peer),
.server = server->clone(server),
.is_server = is_server,
);
return &this->public;
}
eap_tls_t *eap_tls_create_server(identification_t *server,
identification_t *peer)
{
return eap_tls_create(server, peer, TRUE);
}
eap_tls_t *eap_tls_create_peer(identification_t *server,
identification_t *peer)
{
return eap_tls_create(server, peer, FALSE);
}
+59
View File
@@ -0,0 +1,59 @@
/*
* 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 <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_tls eap_tls
* @{ @ingroup eap_tls
*/
#ifndef EAP_TLS_H_
#define EAP_TLS_H_
typedef struct eap_tls_t eap_tls_t;
#include <sa/authenticators/eap/eap_method.h>
/**
* Implementation of eap_method_t using EAP-TLS.
*/
struct eap_tls_t {
/**
* Implements eap_method_t interface.
*/
eap_method_t eap_method;
};
/**
* Creates the EAP method EAP-TLS acting as server.
*
* @param server ID of the EAP server
* @param peer ID of the EAP client
* @return eap_tls_t object
*/
eap_tls_t *eap_tls_create_server(identification_t *server,
identification_t *peer);
/**
* Creates the EAP method EAP-TLS acting as peer.
*
* @param server ID of the EAP server
* @param peer ID of the EAP client
* @return eap_tls_t object
*/
eap_tls_t *eap_tls_create_peer(identification_t *server,
identification_t *peer);
#endif /** EAP_TLS_H_ @}*/
@@ -0,0 +1,50 @@
/*
* 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 <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_tls_plugin.h"
#include "eap_tls.h"
#include <daemon.h>
METHOD(plugin_t, destroy, void,
eap_tls_plugin_t *this)
{
charon->eap->remove_method(charon->eap,
(eap_constructor_t)eap_tls_create_server);
charon->eap->remove_method(charon->eap,
(eap_constructor_t)eap_tls_create_peer);
free(this);
}
/*
* see header file
*/
plugin_t *plugin_create()
{
eap_tls_plugin_t *this;
INIT(this,
.plugin.destroy = _destroy,
);
charon->eap->add_method(charon->eap, EAP_TLS, 0, EAP_SERVER,
(eap_constructor_t)eap_tls_create_server);
charon->eap->add_method(charon->eap, EAP_TLS, 0, EAP_PEER,
(eap_constructor_t)eap_tls_create_peer);
return &this->plugin;
}
@@ -0,0 +1,47 @@
/*
* 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 <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_tls eap_tls
* @ingroup cplugins
*
* @defgroup eap_tls_plugin eap_tls_plugin
* @{ @ingroup eap_tls
*/
#ifndef EAP_TLS_PLUGIN_H_
#define EAP_TLS_PLUGIN_H_
#include <plugins/plugin.h>
typedef struct eap_tls_plugin_t eap_tls_plugin_t;
/**
* EAP-TLS plugin
*/
struct eap_tls_plugin_t {
/**
* implements plugin interface
*/
plugin_t plugin;
};
/**
* Create a eap_tls_plugin instance.
*/
plugin_t *plugin_create();
#endif /** EAP_TLS_PLUGIN_H_ @}*/