implemented xauth as a pluto plugin

This commit is contained in:
Andreas Steffen
2010-05-18 13:51:27 +02:00
parent ea409980b9
commit 26ec52a405
22 changed files with 1071 additions and 476 deletions
+15
View File
@@ -0,0 +1,15 @@
INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libhydra \
-I$(top_srcdir)/src/libfreeswan -I$(top_srcdir)/src/whack \
-I$(top_srcdir)/src/pluto
AM_CFLAGS = -rdynamic
plugin_LTLIBRARIES = libstrongswan-xauth.la
libstrongswan_xauth_la_SOURCES = \
xauth_plugin.h xauth_plugin.c \
xauth_default_provider.c xauth_default_provider.h \
xauth_default_verifier.c xauth_default_verifier.h
libstrongswan_xauth_la_LDFLAGS = -module -avoid-version
@@ -0,0 +1,66 @@
/*
* 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 <keys.h>
#include "xauth_default_provider.h"
typedef struct private_xauth_default_provider_t private_xauth_default_provider_t;
/**
* private data of xauth_default_provider
*/
struct private_xauth_default_provider_t {
/**
* public functions
*/
xauth_provider_t public;
};
METHOD(xauth_provider_t, get_secret, bool,
private_xauth_default_provider_t *this, connection_t *c, chunk_t *secret)
{
identification_t *user, *server;
server = c->spd.that.id;
user = (c->xauth_identity) ? c->xauth_identity : c->spd.this.id;
return get_xauth_secret(user, server, secret);
}
METHOD(xauth_provider_t, destroy, void,
private_xauth_default_provider_t *this)
{
free(this);
}
/*
* Described in header.
*/
xauth_provider_t *xauth_default_provider_create()
{
private_xauth_default_provider_t *this;
INIT(this,
.public = {
.get_secret = _get_secret,
.destroy = _destroy,
}
);
return &this->public;
}
@@ -0,0 +1,33 @@
/*
* 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 xauth_default_provider xauth_default_provider
* @{ @ingroup xauth
*/
#ifndef XAUTH_DEFAULT_PROVIDER_H_
#define XAUTH_DEFAULT_PROVIDER_H_
#include <xauth/xauth_provider.h>
/**
* Create an xauth_default_provider instance.
*/
xauth_provider_t *xauth_default_provider_create();
#endif /** XAUTH_DEFAULT_PROVIDER_H_ @}*/
@@ -0,0 +1,74 @@
/*
* 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 <keys.h>
#include "xauth_default_verifier.h"
typedef struct private_xauth_default_verifier_t private_xauth_default_verifier_t;
/**
* private data of xauth_default_verifier
*/
struct private_xauth_default_verifier_t {
/**
* public functions
*/
xauth_verifier_t public;
};
METHOD(xauth_verifier_t, verify_secret, bool,
private_xauth_default_verifier_t *this, connection_t *c, chunk_t secret)
{
identification_t *user, *server;
chunk_t xauth_secret;
bool success = FALSE;
server = c->spd.this.id;
user = (c->xauth_identity) ? c->xauth_identity : c->spd.that.id;
if (get_xauth_secret(user, server, &xauth_secret))
{
success = chunk_equals(secret, xauth_secret);
chunk_clear(&xauth_secret);
}
return success;
}
METHOD(xauth_verifier_t, destroy, void,
private_xauth_default_verifier_t *this)
{
free(this);
}
/*
* Described in header.
*/
xauth_verifier_t *xauth_default_verifier_create()
{
private_xauth_default_verifier_t *this;
INIT(this,
.public = {
.verify_secret = _verify_secret,
.destroy = _destroy,
}
);
return &this->public;
}
@@ -0,0 +1,33 @@
/*
* 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 xauth_default_verifier xauth_default_verifier
* @{ @ingroup xauth
*/
#ifndef XAUTH_DEFAULT_VERIFIER_H_
#define XAUTH_DEFAULT_VERIFIER_H_
#include <xauth/xauth_verifier.h>
/**
* Create an xauth_default_verifier instance.
*/
xauth_verifier_t *xauth_default_verifier_create();
#endif /** XAUTH_DEFAULT_VERIFIER_H_ @}*/
+43
View File
@@ -0,0 +1,43 @@
/*
* 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 <pluto.h>
#include "xauth_plugin.h"
#include "xauth_default_provider.h"
#include "xauth_default_verifier.h"
/**
* Implementation of plugin_t.destroy
*/
static void destroy(xauth_plugin_t *this)
{
free(this);
}
/*
* see header file
*/
plugin_t *xauth_plugin_create()
{
xauth_plugin_t *this = malloc_thing(xauth_plugin_t);
this->plugin.destroy = (void(*)(plugin_t*))destroy;
pluto->xauth->add_provider(pluto->xauth, xauth_default_provider_create());
pluto->xauth->add_verifier(pluto->xauth, xauth_default_verifier_create());
return &this->plugin;
}
+42
View File
@@ -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 xauth xauth
* @ingroup pplugins
*
* @defgroup xauth_plugin xauth_plugin
* @{ @ingroup xauth
*/
#ifndef XAUTH_PLUGIN_H_
#define XAUTH_PLUGIN_H_
#include <plugins/plugin.h>
typedef struct xauth_plugin_t xauth_plugin_t;
/**
* XAUTH plugin
*/
struct xauth_plugin_t {
/**
* implements plugin interface
*/
plugin_t plugin;
};
#endif /** XAUTH_PLUGIN_H_ @}*/