]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
added skeleton for libgcrypt based crypto plugin
authorMartin Willi <martin@strongswan.org>
Thu, 4 Jun 2009 12:23:39 +0000 (14:23 +0200)
committerMartin Willi <martin@strongswan.org>
Tue, 9 Jun 2009 09:18:56 +0000 (11:18 +0200)
configure.in
src/libstrongswan/Makefile.am
src/libstrongswan/plugins/gcrypt/Makefile.am [new file with mode: 0644]
src/libstrongswan/plugins/gcrypt/gcrypt_plugin.c [new file with mode: 0644]
src/libstrongswan/plugins/gcrypt/gcrypt_plugin.h [new file with mode: 0644]

index 6832abaf1d9d10933a99b87b3177c764cd3261ac..d7af864b0cf7eef87eb8f5c4a8a572b5ff147d8b 100644 (file)
@@ -710,6 +710,16 @@ AC_ARG_ENABLE(
        fi],
 )
 
+AC_ARG_ENABLE(
+       [gcrypt],
+       AS_HELP_STRING([--enable-gcrypt],[enables the libgcrypt plugin. (default is NO).]),
+       [if test x$enableval = xyes; then
+               gcrypt=true
+        else
+               gcrypt=false
+       fi],
+)
+
 AC_ARG_ENABLE(
        [agent],
        AS_HELP_STRING([--enable-agent],[enables the ssh-agent signing plugin. (default is NO).]),
@@ -1006,6 +1016,11 @@ if test x$openssl = xtrue; then
        AC_CHECK_HEADER([openssl/evp.h],,[AC_MSG_ERROR([OpenSSL header openssl/evp.h not found!])])
 fi
 
+if test x$gcrypt = xtrue; then
+       AC_HAVE_LIBRARY([gcrypt],[LIBS="$LIBS"],[AC_MSG_ERROR([libgcrypt library not found])])
+       AC_CHECK_HEADER([gcrypt.h],,[AC_MSG_ERROR([libgcrypt header gcrypt.h not found!])])
+fi
+
 if test x$uci = xtrue; then
        AC_HAVE_LIBRARY([uci],[LIBS="$LIBS"],[AC_MSG_ERROR([UCI library libuci not found])])
        AC_CHECK_HEADER([uci.h],,[AC_MSG_ERROR([UCI header uci.h not found!])])
@@ -1109,6 +1124,10 @@ if test x$openssl = xtrue; then
        libstrongswan_plugins=${libstrongswan_plugins}" openssl"
        pluto_plugins=${pluto_plugins}" openssl"
 fi
+if test x$gcrypt = xtrue; then
+       libstrongswan_plugins=${libstrongswan_plugins}" gcrypt"
+       pluto_plugins=${pluto_plugins}" gcrypt"
+fi
 if test x$agent = xtrue; then
        libstrongswan_plugins=${libstrongswan_plugins}" agent"
 fi
@@ -1148,6 +1167,7 @@ AM_CONDITIONAL(USE_MYSQL, test x$mysql = xtrue)
 AM_CONDITIONAL(USE_SQLITE, test x$sqlite = xtrue)
 AM_CONDITIONAL(USE_PADLOCK, test x$padlock = xtrue)
 AM_CONDITIONAL(USE_OPENSSL, test x$openssl = xtrue)
+AM_CONDITIONAL(USE_GCRYPT, test x$gcrypt = xtrue)
 AM_CONDITIONAL(USE_AGENT, test x$agent = xtrue)
 
 dnl charon plugins
@@ -1243,6 +1263,7 @@ AC_OUTPUT(
        src/libstrongswan/plugins/sqlite/Makefile
        src/libstrongswan/plugins/padlock/Makefile
        src/libstrongswan/plugins/openssl/Makefile
+       src/libstrongswan/plugins/gcrypt/Makefile
        src/libstrongswan/plugins/agent/Makefile
        src/libstrongswan/fips/Makefile
        src/libfreeswan/Makefile
index c2a1a5a4fce8f511b09199a01e77844ad9daee7c..ca5f5e5e21c5b62fbcbccd3b5b877a262db9c601 100644 (file)
@@ -200,6 +200,10 @@ if USE_OPENSSL
   SUBDIRS += plugins/openssl
 endif
 
+if USE_GCRYPT
+  SUBDIRS += plugins/gcrypt
+endif
+
 if USE_AGENT
   SUBDIRS += plugins/agent
 endif
diff --git a/src/libstrongswan/plugins/gcrypt/Makefile.am b/src/libstrongswan/plugins/gcrypt/Makefile.am
new file mode 100644 (file)
index 0000000..237df30
--- /dev/null
@@ -0,0 +1,12 @@
+
+INCLUDES = -I$(top_srcdir)/src/libstrongswan
+
+AM_CFLAGS = -rdynamic
+
+plugin_LTLIBRARIES = libstrongswan-gcrypt.la
+
+libstrongswan_gcrypt_la_SOURCES = gcrypt_plugin.h gcrypt_plugin.c
+
+libstrongswan_gcrypt_la_LDFLAGS = -module
+libstrongswan_gcrypt_la_LIBADD  = -lgcrypt
+
diff --git a/src/libstrongswan/plugins/gcrypt/gcrypt_plugin.c b/src/libstrongswan/plugins/gcrypt/gcrypt_plugin.c
new file mode 100644 (file)
index 0000000..1b3c66d
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2009 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 "gcrypt_plugin.h"
+
+#include <library.h>
+
+typedef struct private_gcrypt_plugin_t private_gcrypt_plugin_t;
+
+/**
+ * private data of gcrypt_plugin
+ */
+struct private_gcrypt_plugin_t {
+
+       /**
+        * public functions
+        */
+       gcrypt_plugin_t public;
+};
+
+/**
+ * Implementation of gcrypt_plugin_t.destroy
+ */
+static void destroy(private_gcrypt_plugin_t *this)
+{
+       free(this);
+}
+
+/*
+ * see header file
+ */
+plugin_t *plugin_create()
+{
+       private_gcrypt_plugin_t *this = malloc_thing(private_gcrypt_plugin_t);
+       
+       this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
+       
+       return &this->public.plugin;
+}
+
diff --git a/src/libstrongswan/plugins/gcrypt/gcrypt_plugin.h b/src/libstrongswan/plugins/gcrypt/gcrypt_plugin.h
new file mode 100644 (file)
index 0000000..f2247ed
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+/**
+ * @defgroup gcrypt_p gcrypt
+ * @ingroup plugins
+ *
+ * @defgroup gcrypt_plugin gcrypt_plugin
+ * @{ @ingroup gcrypt_p
+ */
+
+#ifndef GCRYPT_PLUGIN_H_
+#define GCRYPT_PLUGIN_H_
+
+#include <plugins/plugin.h>
+
+typedef struct gcrypt_plugin_t gcrypt_plugin_t;
+
+/**
+ * Plugin implementing crypto functions via libgcrypt.
+ */
+struct gcrypt_plugin_t {
+
+       /**
+        * implements plugin interface
+        */
+       plugin_t plugin;
+};
+
+/**
+ * Create a gcrypt_plugin instance.
+ */
+plugin_t *plugin_create();
+
+#endif /** GCRYPT_PLUGIN_H_ @}*/