diff options
author | Rene Mayrhofer <rene@mayrhofer.eu.org> | 2008-10-29 20:30:44 +0000 |
---|---|---|
committer | Rene Mayrhofer <rene@mayrhofer.eu.org> | 2008-10-29 20:30:44 +0000 |
commit | 74f0bbfc53cb5fa519e4e27ece53735ab51b397c (patch) | |
tree | 0dbab9c835be15577ff05b474b6361bb326d66ce /src/libstrongswan/plugins | |
parent | 5c1fa2516bda1ccf8eb00178c0beb196c2020a94 (diff) | |
download | vyos-strongswan-74f0bbfc53cb5fa519e4e27ece53735ab51b397c.tar.gz vyos-strongswan-74f0bbfc53cb5fa519e4e27ece53735ab51b397c.zip |
- New upstream release.
Diffstat (limited to 'src/libstrongswan/plugins')
52 files changed, 1932 insertions, 463 deletions
diff --git a/src/libstrongswan/plugins/aes/Makefile.in b/src/libstrongswan/plugins/aes/Makefile.in index ed3dfb621..55faa07f0 100644 --- a/src/libstrongswan/plugins/aes/Makefile.in +++ b/src/libstrongswan/plugins/aes/Makefile.in @@ -187,6 +187,8 @@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ +nm_CFLAGS = @nm_CFLAGS@ +nm_LIBS = @nm_LIBS@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ piddir = @piddir@ diff --git a/src/libstrongswan/plugins/agent/Makefile.am b/src/libstrongswan/plugins/agent/Makefile.am new file mode 100644 index 000000000..bc022aa26 --- /dev/null +++ b/src/libstrongswan/plugins/agent/Makefile.am @@ -0,0 +1,12 @@ + +INCLUDES = -I$(top_srcdir)/src/libstrongswan + +AM_CFLAGS = -rdynamic + +plugin_LTLIBRARIES = libstrongswan-agent.la + +libstrongswan_agent_la_SOURCES = agent_plugin.h agent_plugin.c \ + agent_private_key.c agent_private_key.h + +libstrongswan_agent_la_LDFLAGS = -module + diff --git a/src/libstrongswan/plugins/agent/Makefile.in b/src/libstrongswan/plugins/agent/Makefile.in new file mode 100644 index 000000000..eb38b537a --- /dev/null +++ b/src/libstrongswan/plugins/agent/Makefile.in @@ -0,0 +1,499 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = src/libstrongswan/plugins/agent +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(plugindir)" +pluginLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(plugin_LTLIBRARIES) +libstrongswan_agent_la_LIBADD = +am_libstrongswan_agent_la_OBJECTS = agent_plugin.lo \ + agent_private_key.lo +libstrongswan_agent_la_OBJECTS = $(am_libstrongswan_agent_la_OBJECTS) +libstrongswan_agent_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libstrongswan_agent_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libstrongswan_agent_la_SOURCES) +DIST_SOURCES = $(libstrongswan_agent_la_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +GPERF = @GPERF@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +IPSEC_ROUTING_TABLE = @IPSEC_ROUTING_TABLE@ +IPSEC_ROUTING_TABLE_PRIO = @IPSEC_ROUTING_TABLE_PRIO@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LINUX_HEADERS = @LINUX_HEADERS@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NMEDIT = @NMEDIT@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +confdir = @confdir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +gtk_CFLAGS = @gtk_CFLAGS@ +gtk_LIBS = @gtk_LIBS@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +ipsecdir = @ipsecdir@ +ipsecgroup = @ipsecgroup@ +ipsecuser = @ipsecuser@ +libdir = @libdir@ +libexecdir = @libexecdir@ +libstrongswan_plugins = @libstrongswan_plugins@ +linuxdir = @linuxdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +nm_CFLAGS = @nm_CFLAGS@ +nm_LIBS = @nm_LIBS@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +piddir = @piddir@ +plugindir = @plugindir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +resolv_conf = @resolv_conf@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +simreader = @simreader@ +srcdir = @srcdir@ +strongswan_conf = @strongswan_conf@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xml_CFLAGS = @xml_CFLAGS@ +xml_LIBS = @xml_LIBS@ +INCLUDES = -I$(top_srcdir)/src/libstrongswan +AM_CFLAGS = -rdynamic +plugin_LTLIBRARIES = libstrongswan-agent.la +libstrongswan_agent_la_SOURCES = agent_plugin.h agent_plugin.c \ + agent_private_key.c agent_private_key.h + +libstrongswan_agent_la_LDFLAGS = -module +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/libstrongswan/plugins/agent/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/libstrongswan/plugins/agent/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(plugindir)" || $(MKDIR_P) "$(DESTDIR)$(plugindir)" + @list='$(plugin_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pluginLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(plugindir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pluginLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(plugindir)/$$f"; \ + else :; fi; \ + done + +uninstall-pluginLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(plugin_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(plugindir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(plugindir)/$$p"; \ + done + +clean-pluginLTLIBRARIES: + -test -z "$(plugin_LTLIBRARIES)" || rm -f $(plugin_LTLIBRARIES) + @list='$(plugin_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libstrongswan-agent.la: $(libstrongswan_agent_la_OBJECTS) $(libstrongswan_agent_la_DEPENDENCIES) + $(libstrongswan_agent_la_LINK) -rpath $(plugindir) $(libstrongswan_agent_la_OBJECTS) $(libstrongswan_agent_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/agent_plugin.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/agent_private_key.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) +installdirs: + for dir in "$(DESTDIR)$(plugindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-pluginLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-pluginLTLIBRARIES + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-pluginLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-pluginLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-pluginLTLIBRARIES \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-pluginLTLIBRARIES + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/libstrongswan/plugins/agent/agent_plugin.c b/src/libstrongswan/plugins/agent/agent_plugin.c new file mode 100644 index 000000000..474171ad1 --- /dev/null +++ b/src/libstrongswan/plugins/agent/agent_plugin.c @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2008 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. + * + * $Id$ + */ + +#include "agent_plugin.h" + +#include <library.h> +#include "agent_private_key.h" + +typedef struct private_agent_plugin_t private_agent_plugin_t; + +/** + * private data of agent_plugin + */ +struct private_agent_plugin_t { + + /** + * public functions + */ + agent_plugin_t public; +}; + +/** + * Implementation of agent_plugin_t.agenttroy + */ +static void destroy(private_agent_plugin_t *this) +{ + lib->creds->remove_builder(lib->creds, + (builder_constructor_t)agent_private_key_builder); + free(this); +} + +/* + * see header file + */ +plugin_t *plugin_create() +{ + private_agent_plugin_t *this = malloc_thing(private_agent_plugin_t); + + this->public.plugin.destroy = (void(*)(plugin_t*))destroy; + + lib->creds->add_builder(lib->creds, CRED_PRIVATE_KEY, KEY_RSA, + (builder_constructor_t)agent_private_key_builder); + return &this->public.plugin; +} + diff --git a/src/libstrongswan/plugins/agent/agent_plugin.h b/src/libstrongswan/plugins/agent/agent_plugin.h new file mode 100644 index 000000000..d12dd44ac --- /dev/null +++ b/src/libstrongswan/plugins/agent/agent_plugin.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2008 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 agent_p agent + * @ingroup plugins + * + * @defgroup agent_plugin agent_plugin + * @{ @ingroup agent_p + */ + +#ifndef AGENT_PLUGIN_H_ +#define AGENT_PLUGIN_H_ + +#include <plugins/plugin.h> + +typedef struct agent_plugin_t agent_plugin_t; + +/** + * Plugin to use private keys loaded in a ssh-agent. + */ +struct agent_plugin_t { + + /** + * implements plugin interface + */ + plugin_t plugin; +}; + +/** + * Create a agent_plugin instance. + */ +plugin_t *plugin_create(); + +#endif /* AGENT_PLUGIN_H_ @}*/ diff --git a/src/libstrongswan/plugins/agent/agent_private_key.c b/src/libstrongswan/plugins/agent/agent_private_key.c new file mode 100644 index 000000000..a3b8eebf3 --- /dev/null +++ b/src/libstrongswan/plugins/agent/agent_private_key.c @@ -0,0 +1,590 @@ +/* + * Copyright (C) 2008 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. + * + * $Id$ + */ + +#include "agent_private_key.h" + +#include <stdlib.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <sys/un.h> +#include <arpa/inet.h> +#include <errno.h> + +#include <library.h> +#include <chunk.h> +#include <debug.h> +#include <asn1/asn1.h> +#include <asn1/oid.h> + +#ifndef UNIX_PATH_MAX +#define UNIX_PATH_MAX 108 +#endif /* UNIX_PATH_MAX */ + +typedef struct private_agent_private_key_t private_agent_private_key_t; +typedef enum agent_msg_type_t agent_msg_type_t; + +/** + * Private data of a agent_private_key_t object. + */ +struct private_agent_private_key_t { + /** + * Public interface for this signer. + */ + agent_private_key_t public; + + /** + * ssh-agent unix socket connection + */ + int socket; + + /** + * key identity blob in ssh format + */ + chunk_t key; + + /** + * keysize in bytes + */ + size_t key_size; + + /** + * Keyid formed as a SHA-1 hash of a publicKey object + */ + identification_t* keyid; + + /** + * Keyid formed as a SHA-1 hash of a publicKeyInfo object + */ + identification_t* keyid_info; + + /** + * reference count + */ + refcount_t ref; +}; + +/** + * Message types for ssh-agent protocol + */ +enum agent_msg_type_t { + SSH_AGENT_FAILURE = 5, + SSH_AGENT_SUCCESS = 6, + SSH_AGENT_ID_REQUEST = 11, + SSH_AGENT_ID_RESPONSE = 12, + SSH_AGENT_SIGN_REQUEST = 13, + SSH_AGENT_SIGN_RESPONSE = 14, +}; + +/** + * read a byte from a blob + */ +static u_char read_byte(chunk_t *blob) +{ + u_char val; + + if (blob->len < sizeof(u_char)) + { + return 0; + } + val = *(blob->ptr); + *blob = chunk_skip(*blob, sizeof(u_char)); + return val; +} + +/** + * read a u_int32_t from a blob + */ +static u_int32_t read_uint32(chunk_t *blob) +{ + u_int32_t val; + + if (blob->len < sizeof(u_int32_t)) + { + return 0; + } + val = ntohl(*(u_int32_t*)blob->ptr); + *blob = chunk_skip(*blob, sizeof(u_int32_t)); + return val; +} + +/** + * read a ssh-agent "string" length/value from a blob + */ +static chunk_t read_string(chunk_t *blob) +{ + int len; + chunk_t str; + + len = read_uint32(blob); + if (len > blob->len) + { + return chunk_empty; + } + str = chunk_create(blob->ptr, len); + *blob = chunk_skip(*blob, + len); + return str; +} + +/** + * open socket connection to the ssh-agent + */ +static int open_connection(char *path) +{ + struct sockaddr_un addr; + int s; + + s = socket(AF_UNIX, SOCK_STREAM, 0); + if (s == -1) + { + DBG1("opening ssh-agent socket %s failed: %s:", path, strerror(errno)); + return -1; + } + + addr.sun_family = AF_UNIX; + addr.sun_path[UNIX_PATH_MAX - 1] = '\0'; + strncpy(addr.sun_path, path, UNIX_PATH_MAX - 1); + + if (connect(s, (struct sockaddr*)&addr, SUN_LEN(&addr)) != 0) + { + DBG1("connecting to ssh-agent socket failed: %s", strerror(errno)); + close(s); + return -1; + } + return s; +} + +/** + * check if the ssh agent key blob matches to our public key + */ +static bool matches_pubkey(chunk_t key, public_key_t *pubkey) +{ + chunk_t pubkeydata, hash, n, e; + hasher_t *hasher; + identification_t *id; + bool match; + + if (!pubkey) + { + return TRUE; + } + read_string(&key); + e = read_string(&key); + n = read_string(&key); + hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1); + if (hasher == NULL) + { + return FALSE; + } + pubkeydata = asn1_wrap(ASN1_SEQUENCE, "mm", + asn1_wrap(ASN1_INTEGER, "c", n), + asn1_wrap(ASN1_INTEGER, "c", e)); + hasher->allocate_hash(hasher, pubkeydata, &hash); + free(pubkeydata.ptr); + id = pubkey->get_id(pubkey, ID_PUBKEY_SHA1); + if (!id) + { + return FALSE; + } + match = chunk_equals(id->get_encoding(id), hash); + free(hash.ptr); + return match; +} + +/** + * Get the first usable key from the agent + */ +static bool read_key(private_agent_private_key_t *this, public_key_t *pubkey) +{ + int len, count; + char buf[2048]; + chunk_t blob = chunk_from_buf(buf), key, type, tmp; + + len = htonl(1); + write(this->socket, &len, sizeof(len)); + buf[0] = SSH_AGENT_ID_REQUEST; + write(this->socket, &buf, 1); + + blob.len = read(this->socket, blob.ptr, blob.len); + + if (blob.len < sizeof(u_int32_t) + sizeof(u_char) || + read_uint32(&blob) != blob.len || + read_byte(&blob) != SSH_AGENT_ID_RESPONSE) + { + DBG1("received invalid ssh-agent identity response"); + return FALSE; + } + count = read_uint32(&blob); + + while (blob.len) + { + key = read_string(&blob); + if (key.len) + { + tmp = key; + type = read_string(&tmp); + read_string(&tmp); + tmp = read_string(&tmp); + if (type.len && strneq("ssh-rsa", type.ptr, type.len) && + tmp.len >= 512/8 && matches_pubkey(key, pubkey)) + { + this->key = chunk_clone(key); + this->key_size = tmp.len; + if (tmp.ptr[0] == 0) + { + this->key_size--; + } + return TRUE; + } + continue; + } + break; + } + return FALSE; +} + +/** + * Implementation of agent_private_key.destroy. + */ +static bool sign(private_agent_private_key_t *this, signature_scheme_t scheme, + chunk_t data, chunk_t *signature) +{ + u_int32_t len, flags; + char buf[2048]; + chunk_t blob = chunk_from_buf(buf); + + if (scheme != SIGN_DEFAULT && scheme != SIGN_RSA_EMSA_PKCS1_SHA1) + { + DBG1("signature scheme %N not supported by ssh-agent", + signature_scheme_names, scheme); + return FALSE; + } + + len = htonl(1 + sizeof(u_int32_t) * 3 + this->key.len + data.len); + write(this->socket, &len, sizeof(len)); + buf[0] = SSH_AGENT_SIGN_REQUEST; + write(this->socket, &buf, 1); + + len = htonl(this->key.len); + write(this->socket, &len, sizeof(len)); + write(this->socket, this->key.ptr, this->key.len); + + len = htonl(data.len); + write(this->socket, &len, sizeof(len)); + write(this->socket, data.ptr, data.len); + + flags = htonl(0); + write(this->socket, &flags, sizeof(flags)); + + blob.len = read(this->socket, blob.ptr, blob.len); + if (blob.len < sizeof(u_int32_t) + sizeof(u_char) || + read_uint32(&blob) != blob.len || + read_byte(&blob) != SSH_AGENT_SIGN_RESPONSE) + { + DBG1("received invalid ssh-agent signature response"); + return FALSE; + } + /* parse length */ + blob = read_string(&blob); + /* skip sig type */ + read_string(&blob); + /* parse length */ + blob = read_string(&blob); + if (!blob.len) + { + DBG1("received invalid ssh-agent signature response"); + return FALSE; + } + *signature = chunk_clone(blob); + return TRUE; +} + +/** + * Implementation of agent_private_key.destroy. + */ +static key_type_t get_type(private_agent_private_key_t *this) +{ + return KEY_RSA; +} + +/** + * Implementation of agent_private_key.destroy. + */ +static bool decrypt(private_agent_private_key_t *this, + chunk_t crypto, chunk_t *plain) +{ + DBG1("private key decryption not supported by ssh-agent"); + return FALSE; +} + +/** + * Implementation of agent_private_key.destroy. + */ +static size_t get_keysize(private_agent_private_key_t *this) +{ + return this->key_size; +} + +/** + * Implementation of agent_private_key.destroy. + */ +static identification_t* get_id(private_agent_private_key_t *this, + id_type_t type) +{ + switch (type) + { + case ID_PUBKEY_INFO_SHA1: + return this->keyid_info; + case ID_PUBKEY_SHA1: + return this->keyid; + default: + return NULL; + } +} + +/** + * Implementation of agent_private_key.get_public_key. + */ +static public_key_t* get_public_key(private_agent_private_key_t *this) +{ + chunk_t key, n, e, encoded; + public_key_t *public; + + key = this->key; + read_string(&key); + e = read_string(&key); + n = read_string(&key); + encoded = asn1_wrap(ASN1_SEQUENCE, "mm", + asn1_wrap(ASN1_INTEGER, "c", n), + asn1_wrap(ASN1_INTEGER, "c", e)); + + public = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, KEY_RSA, + BUILD_BLOB_ASN1_DER, encoded, BUILD_END); + free(encoded.ptr); + return public; +} + +/** + * Implementation of agent_private_key.belongs_to. + */ +static bool belongs_to(private_agent_private_key_t *this, public_key_t *public) +{ + identification_t *keyid; + + if (public->get_type(public) != KEY_RSA) + { + return FALSE; + } + keyid = public->get_id(public, ID_PUBKEY_SHA1); + if (keyid && keyid->equals(keyid, this->keyid)) + { + return TRUE; + } + keyid = public->get_id(public, ID_PUBKEY_INFO_SHA1); + if (keyid && keyid->equals(keyid, this->keyid_info)) + { + return TRUE; + } + return FALSE; +} + +/** + * Build the RSA key identifier from n and e using SHA1 hashed publicKey(Info). + */ +static bool build_ids(private_agent_private_key_t *this) +{ + chunk_t publicKeyInfo, publicKey, hash, key, n, e; + hasher_t *hasher; + + key = this->key; + read_string(&key); + e = read_string(&key); + n = read_string(&key); + + hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1); + if (hasher == NULL) + { + DBG1("SHA1 hash algorithm not supported, unable to use RSA"); + return FALSE; + } + publicKey = asn1_wrap(ASN1_SEQUENCE, "mm", + asn1_wrap(ASN1_INTEGER, "c", n), + asn1_wrap(ASN1_INTEGER, "c", e)); + hasher->allocate_hash(hasher, publicKey, &hash); + this->keyid = identification_create_from_encoding(ID_PUBKEY_SHA1, hash); + chunk_free(&hash); + + publicKeyInfo = asn1_wrap(ASN1_SEQUENCE, "cm", + asn1_algorithmIdentifier(OID_RSA_ENCRYPTION), + asn1_bitstring("m", publicKey)); + hasher->allocate_hash(hasher, publicKeyInfo, &hash); + this->keyid_info = identification_create_from_encoding(ID_PUBKEY_INFO_SHA1, hash); + chunk_free(&hash); + + hasher->destroy(hasher); + chunk_free(&publicKeyInfo); + return TRUE; +} + +/** + * Implementation of private_key_t.get_encoding. + */ +static chunk_t get_encoding(private_agent_private_key_t *this) +{ + return chunk_empty; +} + +/** + * Implementation of agent_private_key.get_ref. + */ +static private_agent_private_key_t* get_ref(private_agent_private_key_t *this) +{ + ref_get(&this->ref); + return this; +} + +/** + * Implementation of agent_private_key.destroy. + */ +static void destroy(private_agent_private_key_t *this) +{ + if (ref_put(&this->ref)) + { + close(this->socket); + DESTROY_IF(this->keyid); + DESTROY_IF(this->keyid_info); + free(this->key.ptr); + free(this); + } +} + +/** + * Internal constructor + */ +static agent_private_key_t *agent_private_key_create(char *path, + public_key_t *pubkey) +{ + private_agent_private_key_t *this = malloc_thing(private_agent_private_key_t); + + this->public.interface.get_type = (key_type_t (*)(private_key_t *this))get_type; + this->public.interface.sign = (bool (*)(private_key_t *this, signature_scheme_t scheme, chunk_t data, chunk_t *signature))sign; + this->public.interface.decrypt = (bool (*)(private_key_t *this, chunk_t crypto, chunk_t *plain))decrypt; + this->public.interface.get_keysize = (size_t (*) (private_key_t *this))get_keysize; + this->public.interface.get_id = (identification_t* (*) (private_key_t *this,id_type_t))get_id; + this->public.interface.get_public_key = (public_key_t* (*)(private_key_t *this))get_public_key; + this->public.interface.belongs_to = (bool (*) (private_key_t *this, public_key_t *public))belongs_to; + this->public.interface.get_encoding = (chunk_t(*)(private_key_t*))get_encoding; + this->public.interface.get_ref = (private_key_t* (*)(private_key_t *this))get_ref; + this->public.interface.destroy = (void (*)(private_key_t *this))destroy; + + this->socket = open_connection(path); + if (this->socket < 0) + { + free(this); + return NULL; + } + this->key = chunk_empty; + this->keyid = NULL; + this->keyid_info = NULL; + this->ref = 1; + if (!read_key(this, pubkey) || !build_ids(this)) + { + destroy(this); + return NULL; + } + return &this->public; +} + +typedef struct private_builder_t private_builder_t; +/** + * Builder implementation for key loading/generation + */ +struct private_builder_t { + /** implements the builder interface */ + builder_t public; + /** agent unix socket */ + char *socket; + /** matching public key */ + public_key_t *pubkey; +}; + +/** + * Implementation of builder_t.build + */ +static agent_private_key_t *build(private_builder_t *this) +{ + agent_private_key_t *key = NULL; + + if (this->socket) + { + key = agent_private_key_create(this->socket, this->pubkey); + } + free(this); + return key; +} + +/** + * Implementation of builder_t.add + */ +static void add(private_builder_t *this, builder_part_t part, ...) +{ + va_list args; + + switch (part) + { + case BUILD_AGENT_SOCKET: + { + va_start(args, part); + this->socket = va_arg(args, char*); + va_end(args); + return; + } + case BUILD_PUBLIC_KEY: + { + va_start(args, part); + this->pubkey = va_arg(args, public_key_t*); + va_end(args); + return; + } + default: + break; + } + builder_cancel(&this->public); +} + +/** + * Builder construction function + */ +builder_t *agent_private_key_builder(key_type_t type) +{ + private_builder_t *this; + + if (type != KEY_RSA) + { + return NULL; + } + + this = malloc_thing(private_builder_t); + + this->pubkey = NULL; + this->socket = NULL; + this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add; + this->public.build = (void*(*)(builder_t *this))build; + + return &this->public; +} + diff --git a/src/libstrongswan/plugins/agent/agent_private_key.h b/src/libstrongswan/plugins/agent/agent_private_key.h new file mode 100644 index 000000000..4d678dd08 --- /dev/null +++ b/src/libstrongswan/plugins/agent/agent_private_key.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2008 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 agent_private_key agent_private_key + * @{ @ingroup agent_p + */ + +#ifndef AGENT_PRIVATE_KEY_H_ +#define AGENT_PRIVATE_KEY_H_ + +#include <credentials/keys/private_key.h> + +typedef struct agent_private_key_t agent_private_key_t; + +/** + * private_key_t implementation using an ssh-agent. + */ +struct agent_private_key_t { + + /** + * Implements private_key_t interface + */ + private_key_t interface; +}; + +/** + * Create the builder for a private key. + * + * @param type type of the key + * @return builder instance + */ +builder_t *agent_private_key_builder(key_type_t type); + +#endif /*AGENT_PRIVATE_KEY_H_ @}*/ + diff --git a/src/libstrongswan/plugins/curl/Makefile.in b/src/libstrongswan/plugins/curl/Makefile.in index d3f7b443d..cb44a4ffe 100644 --- a/src/libstrongswan/plugins/curl/Makefile.in +++ b/src/libstrongswan/plugins/curl/Makefile.in @@ -187,6 +187,8 @@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ +nm_CFLAGS = @nm_CFLAGS@ +nm_LIBS = @nm_LIBS@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ piddir = @piddir@ diff --git a/src/libstrongswan/plugins/des/Makefile.in b/src/libstrongswan/plugins/des/Makefile.in index 5072a2cab..8824bd238 100644 --- a/src/libstrongswan/plugins/des/Makefile.in +++ b/src/libstrongswan/plugins/des/Makefile.in @@ -187,6 +187,8 @@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ +nm_CFLAGS = @nm_CFLAGS@ +nm_LIBS = @nm_LIBS@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ piddir = @piddir@ diff --git a/src/libstrongswan/plugins/des/des_plugin.c b/src/libstrongswan/plugins/des/des_plugin.c index c32096ad0..538138d8a 100644 --- a/src/libstrongswan/plugins/des/des_plugin.c +++ b/src/libstrongswan/plugins/des/des_plugin.c @@ -12,7 +12,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: des_plugin.c 3488 2008-02-21 15:10:02Z martin $ + * $Id: des_plugin.c 4309 2008-08-28 11:07:57Z martin $ */ #include "des_plugin.h" @@ -52,10 +52,10 @@ plugin_t *plugin_create() this->public.plugin.destroy = (void(*)(plugin_t*))destroy; - lib->crypto->add_crypter(lib->crypto, ENCR_DES, - (crypter_constructor_t)des_crypter_create); lib->crypto->add_crypter(lib->crypto, ENCR_3DES, (crypter_constructor_t)des_crypter_create); + lib->crypto->add_crypter(lib->crypto, ENCR_DES, + (crypter_constructor_t)des_crypter_create); return &this->public.plugin; } diff --git a/src/libstrongswan/plugins/fips_prf/Makefile.in b/src/libstrongswan/plugins/fips_prf/Makefile.in index fa51b0db5..48a6c9b28 100644 --- a/src/libstrongswan/plugins/fips_prf/Makefile.in +++ b/src/libstrongswan/plugins/fips_prf/Makefile.in @@ -189,6 +189,8 @@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ +nm_CFLAGS = @nm_CFLAGS@ +nm_LIBS = @nm_LIBS@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ piddir = @piddir@ diff --git a/src/libstrongswan/plugins/gmp/Makefile.in b/src/libstrongswan/plugins/gmp/Makefile.in index 1d9bfb88e..56642b7c9 100644 --- a/src/libstrongswan/plugins/gmp/Makefile.in +++ b/src/libstrongswan/plugins/gmp/Makefile.in @@ -188,6 +188,8 @@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ +nm_CFLAGS = @nm_CFLAGS@ +nm_LIBS = @nm_LIBS@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ piddir = @piddir@ diff --git a/src/libstrongswan/plugins/gmp/gmp_diffie_hellman.c b/src/libstrongswan/plugins/gmp/gmp_diffie_hellman.c index 3d9856b63..40e83fc4c 100644 --- a/src/libstrongswan/plugins/gmp/gmp_diffie_hellman.c +++ b/src/libstrongswan/plugins/gmp/gmp_diffie_hellman.c @@ -15,7 +15,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: gmp_diffie_hellman.c 3806 2008-04-15 05:56:35Z martin $ + * $Id: gmp_diffie_hellman.c 4346 2008-09-17 09:02:30Z martin $ */ #include <gmp.h> @@ -343,7 +343,7 @@ struct private_gmp_diffie_hellman_t { * Generator value. */ mpz_t g; - + /** * My private value. */ @@ -353,7 +353,7 @@ struct private_gmp_diffie_hellman_t { * My public value. */ mpz_t ya; - + /** * Other public value. */ @@ -373,7 +373,7 @@ struct private_gmp_diffie_hellman_t { * Modulus length. */ size_t p_len; - + /** * True if shared secret is computed and stored in my_public_value. */ @@ -395,7 +395,7 @@ static void set_other_public_value(private_gmp_diffie_hellman_t *this, chunk_t v /* check public value: * 1. 0 or 1 is invalid as 0^a = 0 and 1^a = 1 * 2. a public value larger or equal the modulus is invalid */ - if (mpz_cmp_ui(this->yb, 1) > 0 || + if (mpz_cmp_ui(this->yb, 1) > 0 && mpz_cmp(this->yb, p_min_1) < 0) { #ifdef EXTENDED_DH_TEST @@ -440,7 +440,11 @@ static status_t get_other_public_value(private_gmp_diffie_hellman_t *this, return FAILED; } value->len = this->p_len; - value->ptr = mpz_export(NULL, NULL, 1, value->len, 1, 0, this->yb); + value->ptr = mpz_export(NULL, NULL, 1, value->len, 1, 0, this->yb); + if (value->ptr == NULL) + { + return FAILED; + } return SUCCESS; } @@ -451,6 +455,10 @@ static void get_my_public_value(private_gmp_diffie_hellman_t *this,chunk_t *valu { value->len = this->p_len; value->ptr = mpz_export(NULL, NULL, 1, value->len, 1, 0, this->ya); + if (value->ptr == NULL) + { + value->len = 0; + } } /** @@ -463,7 +471,11 @@ static status_t get_shared_secret(private_gmp_diffie_hellman_t *this, chunk_t *s return FAILED; } secret->len = this->p_len; - secret->ptr = mpz_export(NULL, NULL, 1, secret->len, 1, 0, this->zz); + secret->ptr = mpz_export(NULL, NULL, 1, secret->len, 1, 0, this->zz); + if (secret->ptr == NULL) + { + return FAILED; + } return SUCCESS; } diff --git a/src/libstrongswan/plugins/gmp/gmp_plugin.c b/src/libstrongswan/plugins/gmp/gmp_plugin.c index 56fb0ddd8..7711b6d34 100644 --- a/src/libstrongswan/plugins/gmp/gmp_plugin.c +++ b/src/libstrongswan/plugins/gmp/gmp_plugin.c @@ -12,7 +12,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: gmp_plugin.c 3962 2008-05-15 12:39:35Z tobias $ + * $Id: gmp_plugin.c 4309 2008-08-28 11:07:57Z martin $ */ #include "gmp_plugin.h" @@ -58,14 +58,10 @@ plugin_t *plugin_create() this->public.plugin.destroy = (void(*)(plugin_t*))destroy; - lib->crypto->add_dh(lib->crypto, MODP_768_BIT, - (dh_constructor_t)gmp_diffie_hellman_create); - lib->crypto->add_dh(lib->crypto, MODP_1024_BIT, + lib->crypto->add_dh(lib->crypto, MODP_2048_BIT, (dh_constructor_t)gmp_diffie_hellman_create); lib->crypto->add_dh(lib->crypto, MODP_1536_BIT, (dh_constructor_t)gmp_diffie_hellman_create); - lib->crypto->add_dh(lib->crypto, MODP_2048_BIT, - (dh_constructor_t)gmp_diffie_hellman_create); lib->crypto->add_dh(lib->crypto, MODP_3072_BIT, (dh_constructor_t)gmp_diffie_hellman_create); lib->crypto->add_dh(lib->crypto, MODP_4096_BIT, @@ -74,6 +70,10 @@ plugin_t *plugin_create() (dh_constructor_t)gmp_diffie_hellman_create); lib->crypto->add_dh(lib->crypto, MODP_8192_BIT, (dh_constructor_t)gmp_diffie_hellman_create); + lib->crypto->add_dh(lib->crypto, MODP_1024_BIT, + (dh_constructor_t)gmp_diffie_hellman_create); + lib->crypto->add_dh(lib->crypto, MODP_768_BIT, + (dh_constructor_t)gmp_diffie_hellman_create); lib->creds->add_builder(lib->creds, CRED_PRIVATE_KEY, KEY_RSA, (builder_constructor_t)gmp_rsa_private_key_builder); diff --git a/src/libstrongswan/plugins/gmp/gmp_rsa_private_key.c b/src/libstrongswan/plugins/gmp/gmp_rsa_private_key.c index cd951f0e4..e445dd670 100644 --- a/src/libstrongswan/plugins/gmp/gmp_rsa_private_key.c +++ b/src/libstrongswan/plugins/gmp/gmp_rsa_private_key.c @@ -13,7 +13,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: gmp_rsa_private_key.c 4014 2008-05-23 19:23:04Z andreas $ + * $Id: gmp_rsa_private_key.c 4345 2008-09-17 08:10:48Z martin $ */ #include <gmp.h> @@ -191,6 +191,10 @@ static chunk_t rsadp(private_gmp_rsa_private_key_t *this, chunk_t data) decrypted.len = this->k; decrypted.ptr = mpz_export(NULL, NULL, 1, decrypted.len, 1, 0, t1); + if (decrypted.ptr == NULL) + { + decrypted.len = 0; + } mpz_clear_randomized(t1); mpz_clear_randomized(t2); @@ -789,34 +793,37 @@ static gmp_rsa_private_key_t *build(private_builder_t *this) */ static void add(private_builder_t *this, builder_part_t part, ...) { - va_list args; - - if (this->key) + if (!this->key) { - DBG1("ignoring surplus build part %N", builder_part_names, part); - return; - } + va_list args; + chunk_t chunk; - switch (part) - { - case BUILD_BLOB_ASN1_DER: + switch (part) { - va_start(args, part); - this->key = load(va_arg(args, chunk_t)); - va_end(args); - break; - } - case BUILD_KEY_SIZE: - { - va_start(args, part); - this->key = generate(va_arg(args, u_int)); - va_end(args); - break; + case BUILD_BLOB_ASN1_DER: + { + va_start(args, part); + chunk = va_arg(args, chunk_t); + this->key = load(chunk_clone(chunk)); + va_end(args); + return; + } + case BUILD_KEY_SIZE: + { + va_start(args, part); + this->key = generate(va_arg(args, u_int)); + va_end(args); + return; + } + default: + break; } - default: - DBG1("ignoring unsupported build part %N", builder_part_names, part); - break; } + if (this->key) + { + destroy((private_gmp_rsa_private_key_t*)this->key); + } + builder_cancel(&this->public); } /** diff --git a/src/libstrongswan/plugins/gmp/gmp_rsa_public_key.c b/src/libstrongswan/plugins/gmp/gmp_rsa_public_key.c index e4f898ecc..8a89849cd 100644 --- a/src/libstrongswan/plugins/gmp/gmp_rsa_public_key.c +++ b/src/libstrongswan/plugins/gmp/gmp_rsa_public_key.c @@ -13,7 +13,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: gmp_rsa_public_key.c 3988 2008-05-21 13:01:58Z martin $ + * $Id: gmp_rsa_public_key.c 4345 2008-09-17 08:10:48Z martin $ */ #include <gmp.h> @@ -93,11 +93,15 @@ static chunk_t rsaep(private_gmp_rsa_public_key_t *this, chunk_t data) mpz_powm(c, m, this->e, this->n); - encrypted.len = this->k; - encrypted.ptr = mpz_export(NULL, NULL, 1, encrypted.len, 1, 0, c); + encrypted.len = this->k; + encrypted.ptr = mpz_export(NULL, NULL, 1, encrypted.len, 1, 0, c); + if (encrypted.ptr == NULL) + { + encrypted.len = 0; + } mpz_clear(c); - mpz_clear(m); + mpz_clear(m); return encrypted; } @@ -541,27 +545,30 @@ static gmp_rsa_public_key_t *build(private_builder_t *this) */ static void add(private_builder_t *this, builder_part_t part, ...) { - va_list args; - - if (this->key) + if (!this->key) { - DBG1("ignoring surplus build part %N", builder_part_names, part); - return; - } + va_list args; + chunk_t chunk; - switch (part) - { - case BUILD_BLOB_ASN1_DER: + switch (part) { - va_start(args, part); - this->key = load(va_arg(args, chunk_t)); - va_end(args); - break; + case BUILD_BLOB_ASN1_DER: + { + va_start(args, part); + chunk = va_arg(args, chunk_t); + this->key = load(chunk_clone(chunk)); + va_end(args); + return; + } + default: + break; } - default: - DBG1("ignoring unsupported build part %N", builder_part_names, part); - break; } + if (this->key) + { + destroy((private_gmp_rsa_public_key_t*)this->key); + } + builder_cancel(&this->public); } /** diff --git a/src/libstrongswan/plugins/hmac/Makefile.in b/src/libstrongswan/plugins/hmac/Makefile.in index b6e851cd4..ded48fbf2 100644 --- a/src/libstrongswan/plugins/hmac/Makefile.in +++ b/src/libstrongswan/plugins/hmac/Makefile.in @@ -188,6 +188,8 @@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ +nm_CFLAGS = @nm_CFLAGS@ +nm_LIBS = @nm_LIBS@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ piddir = @piddir@ diff --git a/src/libstrongswan/plugins/hmac/hmac_plugin.c b/src/libstrongswan/plugins/hmac/hmac_plugin.c index bfa2df35f..a0afc2a85 100644 --- a/src/libstrongswan/plugins/hmac/hmac_plugin.c +++ b/src/libstrongswan/plugins/hmac/hmac_plugin.c @@ -12,7 +12,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: hmac_plugin.c 3488 2008-02-21 15:10:02Z martin $ + * $Id: hmac_plugin.c 4309 2008-08-28 11:07:57Z martin $ */ #include "hmac_plugin.h" @@ -55,25 +55,25 @@ plugin_t *plugin_create() this->public.plugin.destroy = (void(*)(plugin_t*))destroy; - lib->crypto->add_prf(lib->crypto, PRF_HMAC_MD5, + lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA2_256, (prf_constructor_t)hmac_prf_create); lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA1, (prf_constructor_t)hmac_prf_create); - lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA2_256, + lib->crypto->add_prf(lib->crypto, PRF_HMAC_MD5, (prf_constructor_t)hmac_prf_create); lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA2_384, (prf_constructor_t)hmac_prf_create); lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA2_512, (prf_constructor_t)hmac_prf_create); - lib->crypto->add_signer(lib->crypto, AUTH_HMAC_MD5_96, - (signer_constructor_t)hmac_signer_create); lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA1_96, (signer_constructor_t)hmac_signer_create); lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA1_128, (signer_constructor_t)hmac_signer_create); lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_256_128, (signer_constructor_t)hmac_signer_create); + lib->crypto->add_signer(lib->crypto, AUTH_HMAC_MD5_96, + (signer_constructor_t)hmac_signer_create); lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_384_192, (signer_constructor_t)hmac_signer_create); lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_512_256, diff --git a/src/libstrongswan/plugins/ldap/Makefile.in b/src/libstrongswan/plugins/ldap/Makefile.in index 8c28f1307..e828fbd44 100644 --- a/src/libstrongswan/plugins/ldap/Makefile.in +++ b/src/libstrongswan/plugins/ldap/Makefile.in @@ -187,6 +187,8 @@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ +nm_CFLAGS = @nm_CFLAGS@ +nm_LIBS = @nm_LIBS@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ piddir = @piddir@ diff --git a/src/libstrongswan/plugins/md5/Makefile.in b/src/libstrongswan/plugins/md5/Makefile.in index 6a4b2a78b..43b921e63 100644 --- a/src/libstrongswan/plugins/md5/Makefile.in +++ b/src/libstrongswan/plugins/md5/Makefile.in @@ -187,6 +187,8 @@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ +nm_CFLAGS = @nm_CFLAGS@ +nm_LIBS = @nm_LIBS@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ piddir = @piddir@ diff --git a/src/libstrongswan/plugins/mysql/Makefile.in b/src/libstrongswan/plugins/mysql/Makefile.in index 6de9dc13d..96dc33fe5 100644 --- a/src/libstrongswan/plugins/mysql/Makefile.in +++ b/src/libstrongswan/plugins/mysql/Makefile.in @@ -187,6 +187,8 @@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ +nm_CFLAGS = @nm_CFLAGS@ +nm_LIBS = @nm_LIBS@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ piddir = @piddir@ diff --git a/src/libstrongswan/plugins/mysql/mysql_database.c b/src/libstrongswan/plugins/mysql/mysql_database.c index 58202c5ae..01f604fef 100644 --- a/src/libstrongswan/plugins/mysql/mysql_database.c +++ b/src/libstrongswan/plugins/mysql/mysql_database.c @@ -12,7 +12,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: mysql_database.c 4111 2008-06-26 07:31:52Z martin $ + * $Id: mysql_database.c 4193 2008-07-21 11:13:06Z martin $ */ #define _GNU_SOURCE @@ -592,6 +592,14 @@ static int execute(private_mysql_database_t *this, int *rowid, char *sql, ...) conn_release(conn); return affected; } + +/** + * Implementation of database_t.get_driver + */ +static db_driver_t get_driver(private_mysql_database_t *this) +{ + return DB_MYSQL; +} /** * Implementation of database_t.destroy @@ -672,6 +680,7 @@ mysql_database_t *mysql_database_create(char *uri) this->public.db.query = (enumerator_t* (*)(database_t *this, char *sql, ...))query; this->public.db.execute = (int (*)(database_t *this, int *rowid, char *sql, ...))execute; + this->public.db.get_driver = (db_driver_t(*)(database_t*))get_driver; this->public.db.destroy = (void(*)(database_t*))destroy; if (!parse_uri(this, uri)) diff --git a/src/libstrongswan/plugins/openssl/Makefile.in b/src/libstrongswan/plugins/openssl/Makefile.in index f83b0ce38..746b5cf4b 100644 --- a/src/libstrongswan/plugins/openssl/Makefile.in +++ b/src/libstrongswan/plugins/openssl/Makefile.in @@ -192,6 +192,8 @@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ +nm_CFLAGS = @nm_CFLAGS@ +nm_LIBS = @nm_LIBS@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ piddir = @piddir@ diff --git a/src/libstrongswan/plugins/openssl/openssl_ec_private_key.c b/src/libstrongswan/plugins/openssl/openssl_ec_private_key.c index 9f7df4bca..aeab15f26 100644 --- a/src/libstrongswan/plugins/openssl/openssl_ec_private_key.c +++ b/src/libstrongswan/plugins/openssl/openssl_ec_private_key.c @@ -12,7 +12,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: openssl_ec_private_key.c 4051 2008-06-10 09:08:27Z tobias $ + * $Id: openssl_ec_private_key.c 4317 2008-09-02 11:00:13Z martin $ */ #include "openssl_ec_private_key.h" @@ -399,27 +399,30 @@ static openssl_ec_private_key_t *build(private_builder_t *this) */ static void add(private_builder_t *this, builder_part_t part, ...) { - va_list args; - - if (this->key) - { - DBG1("ignoring surplus build part %N", builder_part_names, part); - return; - } - - switch (part) + if (!this->key) { - case BUILD_BLOB_ASN1_DER: + va_list args; + chunk_t chunk; + + switch (part) { - va_start(args, part); - this->key = load(va_arg(args, chunk_t)); - va_end(args); - break; + case BUILD_BLOB_ASN1_DER: + { + va_start(args, part); + chunk = va_arg(args, chunk_t); + this->key = load(chunk_clone(chunk)); + va_end(args); + return; + } + default: + break; } - default: - DBG1("ignoring unsupported build part %N", builder_part_names, part); - break; } + if (this->key) + { + destroy((private_openssl_ec_private_key_t*)this->key); + } + builder_cancel(&this->public); } /** diff --git a/src/libstrongswan/plugins/openssl/openssl_ec_public_key.c b/src/libstrongswan/plugins/openssl/openssl_ec_public_key.c index 2056575ba..923df3938 100644 --- a/src/libstrongswan/plugins/openssl/openssl_ec_public_key.c +++ b/src/libstrongswan/plugins/openssl/openssl_ec_public_key.c @@ -12,7 +12,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: openssl_ec_public_key.c 4051 2008-06-10 09:08:27Z tobias $ + * $Id: openssl_ec_public_key.c 4317 2008-09-02 11:00:13Z martin $ */ #include "openssl_ec_public_key.h" @@ -401,27 +401,30 @@ static openssl_ec_public_key_t *build(private_builder_t *this) */ static void add(private_builder_t *this, builder_part_t part, ...) { - va_list args; - - if (this->key) + if (!this->key) { - DBG1("ignoring surplus build part %N", builder_part_names, part); - return; - } + va_list args; + chunk_t chunk; - switch (part) - { - case BUILD_BLOB_ASN1_DER: + switch (part) { - va_start(args, part); - this->key = load(va_arg(args, chunk_t)); - va_end(args); - break; + case BUILD_BLOB_ASN1_DER: + { + va_start(args, part); + chunk = va_arg(args, chunk_t); + this->key = load(chunk_clone(chunk)); + va_end(args); + return; + } + default: + break; } - default: - DBG1("ignoring unsupported build part %N", builder_part_names, part); - break; } + if (this->key) + { + destroy((private_openssl_ec_public_key_t*)this->key); + } + builder_cancel(&this->public); } /** diff --git a/src/libstrongswan/plugins/openssl/openssl_plugin.c b/src/libstrongswan/plugins/openssl/openssl_plugin.c index 7fdd7c224..82c54a95e 100644 --- a/src/libstrongswan/plugins/openssl/openssl_plugin.c +++ b/src/libstrongswan/plugins/openssl/openssl_plugin.c @@ -12,7 +12,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: openssl_plugin.c 4107 2008-06-25 12:39:32Z tobias $ + * $Id: openssl_plugin.c 4309 2008-08-28 11:07:57Z martin $ */ #include <openssl/evp.h> @@ -87,7 +87,7 @@ plugin_t *plugin_create() ENGINE_register_all_complete(); /* crypter */ - lib->crypto->add_crypter(lib->crypto, ENCR_DES, + lib->crypto->add_crypter(lib->crypto, ENCR_AES_CBC, (crypter_constructor_t)openssl_crypter_create); lib->crypto->add_crypter(lib->crypto, ENCR_3DES, (crypter_constructor_t)openssl_crypter_create); @@ -99,9 +99,9 @@ plugin_t *plugin_create() (crypter_constructor_t)openssl_crypter_create); lib->crypto->add_crypter(lib->crypto, ENCR_BLOWFISH, (crypter_constructor_t)openssl_crypter_create); - lib->crypto->add_crypter(lib->crypto, ENCR_NULL, + lib->crypto->add_crypter(lib->crypto, ENCR_DES, (crypter_constructor_t)openssl_crypter_create); - lib->crypto->add_crypter(lib->crypto, ENCR_AES_CBC, + lib->crypto->add_crypter(lib->crypto, ENCR_NULL, (crypter_constructor_t)openssl_crypter_create); /* hasher */ @@ -118,15 +118,23 @@ plugin_t *plugin_create() lib->crypto->add_hasher(lib->crypto, HASH_SHA512, (hasher_constructor_t)openssl_hasher_create); + /* ec diffie hellman */ + lib->crypto->add_dh(lib->crypto, ECP_192_BIT, + (dh_constructor_t)openssl_ec_diffie_hellman_create); + lib->crypto->add_dh(lib->crypto, ECP_224_BIT, + (dh_constructor_t)openssl_ec_diffie_hellman_create); + lib->crypto->add_dh(lib->crypto, ECP_256_BIT, + (dh_constructor_t)openssl_ec_diffie_hellman_create); + lib->crypto->add_dh(lib->crypto, ECP_384_BIT, + (dh_constructor_t)openssl_ec_diffie_hellman_create); + lib->crypto->add_dh(lib->crypto, ECP_521_BIT, + (dh_constructor_t)openssl_ec_diffie_hellman_create); + /* diffie hellman */ - lib->crypto->add_dh(lib->crypto, MODP_768_BIT, - (dh_constructor_t)openssl_diffie_hellman_create); - lib->crypto->add_dh(lib->crypto, MODP_1024_BIT, + lib->crypto->add_dh(lib->crypto, MODP_2048_BIT, (dh_constructor_t)openssl_diffie_hellman_create); lib->crypto->add_dh(lib->crypto, MODP_1536_BIT, (dh_constructor_t)openssl_diffie_hellman_create); - lib->crypto->add_dh(lib->crypto, MODP_2048_BIT, - (dh_constructor_t)openssl_diffie_hellman_create); lib->crypto->add_dh(lib->crypto, MODP_3072_BIT, (dh_constructor_t)openssl_diffie_hellman_create); lib->crypto->add_dh(lib->crypto, MODP_4096_BIT, @@ -135,18 +143,10 @@ plugin_t *plugin_create() (dh_constructor_t)openssl_diffie_hellman_create); lib->crypto->add_dh(lib->crypto, MODP_8192_BIT, (dh_constructor_t)openssl_diffie_hellman_create); - - /* ec diffie hellman */ - lib->crypto->add_dh(lib->crypto, ECP_192_BIT, - (dh_constructor_t)openssl_ec_diffie_hellman_create); - lib->crypto->add_dh(lib->crypto, ECP_224_BIT, - (dh_constructor_t)openssl_ec_diffie_hellman_create); - lib->crypto->add_dh(lib->crypto, ECP_256_BIT, - (dh_constructor_t)openssl_ec_diffie_hellman_create); - lib->crypto->add_dh(lib->crypto, ECP_384_BIT, - (dh_constructor_t)openssl_ec_diffie_hellman_create); - lib->crypto->add_dh(lib->crypto, ECP_521_BIT, - (dh_constructor_t)openssl_ec_diffie_hellman_create); + lib->crypto->add_dh(lib->crypto, MODP_1024_BIT, + (dh_constructor_t)openssl_diffie_hellman_create); + lib->crypto->add_dh(lib->crypto, MODP_768_BIT, + (dh_constructor_t)openssl_diffie_hellman_create); /* rsa */ lib->creds->add_builder(lib->creds, CRED_PRIVATE_KEY, KEY_RSA, diff --git a/src/libstrongswan/plugins/openssl/openssl_rsa_private_key.c b/src/libstrongswan/plugins/openssl/openssl_rsa_private_key.c index 7595eed3a..8ad75215a 100644 --- a/src/libstrongswan/plugins/openssl/openssl_rsa_private_key.c +++ b/src/libstrongswan/plugins/openssl/openssl_rsa_private_key.c @@ -12,7 +12,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: openssl_rsa_private_key.c 3963 2008-05-15 12:41:06Z tobias $ + * $Id: openssl_rsa_private_key.c 4317 2008-09-02 11:00:13Z martin $ */ #include "openssl_rsa_private_key.h" @@ -369,34 +369,37 @@ static openssl_rsa_private_key_t *build(private_builder_t *this) */ static void add(private_builder_t *this, builder_part_t part, ...) { - va_list args; - - if (this->key) + if (!this->key) { - DBG1("ignoring surplus build part %N", builder_part_names, part); - return; - } + va_list args; + chunk_t chunk; - switch (part) - { - case BUILD_BLOB_ASN1_DER: - { - va_start(args, part); - this->key = load(va_arg(args, chunk_t)); - va_end(args); - break; - } - case BUILD_KEY_SIZE: + switch (part) { - va_start(args, part); - this->key = generate(va_arg(args, u_int)); - va_end(args); - break; + case BUILD_BLOB_ASN1_DER: + { + va_start(args, part); + chunk = va_arg(args, chunk_t); + this->key = load(chunk_clone(chunk)); + va_end(args); + return; + } + case BUILD_KEY_SIZE: + { + va_start(args, part); + this->key = generate(va_arg(args, u_int)); + va_end(args); + return; + } + default: + break; } - default: - DBG1("ignoring unsupported build part %N", builder_part_names, part); - break; } + if (this->key) + { + destroy((private_openssl_rsa_private_key_t*)this->key); + } + builder_cancel(&this->public); } /** diff --git a/src/libstrongswan/plugins/openssl/openssl_rsa_public_key.c b/src/libstrongswan/plugins/openssl/openssl_rsa_public_key.c index 755b86e96..61b5b9b64 100644 --- a/src/libstrongswan/plugins/openssl/openssl_rsa_public_key.c +++ b/src/libstrongswan/plugins/openssl/openssl_rsa_public_key.c @@ -12,7 +12,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: openssl_rsa_public_key.c 3963 2008-05-15 12:41:06Z tobias $ + * $Id: openssl_rsa_public_key.c 4317 2008-09-02 11:00:13Z martin $ */ #include "openssl_rsa_public_key.h" @@ -387,27 +387,30 @@ static openssl_rsa_public_key_t *build(private_builder_t *this) */ static void add(private_builder_t *this, builder_part_t part, ...) { - va_list args; - - if (this->key) + if (!this->key) { - DBG1("ignoring surplus build part %N", builder_part_names, part); - return; - } + va_list args; + chunk_t chunk; - switch (part) - { - case BUILD_BLOB_ASN1_DER: + switch (part) { - va_start(args, part); - this->key = load(va_arg(args, chunk_t)); - va_end(args); - break; + case BUILD_BLOB_ASN1_DER: + { + va_start(args, part); + chunk = va_arg(args, chunk_t); + this->key = load(chunk_clone(chunk)); + va_end(args); + return; + } + default: + break; } - default: - DBG1("ignoring unsupported build part %N", builder_part_names, part); - break; } + if (this->key) + { + destroy((private_openssl_rsa_public_key_t*)this->key); + } + builder_cancel(&this->public); } /** diff --git a/src/libstrongswan/plugins/padlock/Makefile.in b/src/libstrongswan/plugins/padlock/Makefile.in index d96b2cf6d..1b032e3d4 100644 --- a/src/libstrongswan/plugins/padlock/Makefile.in +++ b/src/libstrongswan/plugins/padlock/Makefile.in @@ -189,6 +189,8 @@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ +nm_CFLAGS = @nm_CFLAGS@ +nm_LIBS = @nm_LIBS@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ piddir = @piddir@ diff --git a/src/libstrongswan/plugins/plugin_loader.c b/src/libstrongswan/plugins/plugin_loader.c index 4c5095e4a..6480a2760 100644 --- a/src/libstrongswan/plugins/plugin_loader.c +++ b/src/libstrongswan/plugins/plugin_loader.c @@ -12,7 +12,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: plugin_loader.c 4108 2008-06-25 14:53:49Z martin $ + * $Id: plugin_loader.c 4144 2008-07-02 08:19:43Z martin $ */ #define _GNU_SOURCE @@ -96,43 +96,22 @@ static plugin_t* load_plugin(private_plugin_loader_t *this, static int load(private_plugin_loader_t *this, char *path, char *list) { plugin_t *plugin; - char *pos; + enumerator_t *enumerator; + char *token; int count = 0; - list = strdupa(list); - while (TRUE) + enumerator = enumerator_create_token(list, " ", " "); + while (enumerator->enumerate(enumerator, &token)) { - /* eat any whitespace in front */ - while (*list == ' ') - { - list++; - } - /* have we reached the end of the list? */ - if (!*list) - { - break; - } - pos = strchr(list, ' '); - if (pos) - { - *pos++ = '\0'; - } - plugin = load_plugin(this, path, list); + plugin = load_plugin(this, path, token); if (plugin) { /* insert in front to destroy them in reverse order */ this->plugins->insert_last(this->plugins, plugin); - this->names->insert_last(this->names, strdup(list)); + this->names->insert_last(this->names, strdup(token)); count++; } - if (pos) - { - list = pos; - } - else - { - break; - } } + enumerator->destroy(enumerator); return count; } diff --git a/src/libstrongswan/plugins/pubkey/Makefile.in b/src/libstrongswan/plugins/pubkey/Makefile.in index ced339d15..ef1004672 100644 --- a/src/libstrongswan/plugins/pubkey/Makefile.in +++ b/src/libstrongswan/plugins/pubkey/Makefile.in @@ -189,6 +189,8 @@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ +nm_CFLAGS = @nm_CFLAGS@ +nm_LIBS = @nm_LIBS@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ piddir = @piddir@ diff --git a/src/libstrongswan/plugins/pubkey/pubkey_cert.c b/src/libstrongswan/plugins/pubkey/pubkey_cert.c index 63dffb47b..762557094 100644 --- a/src/libstrongswan/plugins/pubkey/pubkey_cert.c +++ b/src/libstrongswan/plugins/pubkey/pubkey_cert.c @@ -19,6 +19,11 @@ #include <debug.h> +/** + * defined in pubkey_public_key.c + */ +extern public_key_t *pubkey_public_key_load(chunk_t blob); + typedef struct private_pubkey_cert_t private_pubkey_cert_t; /** @@ -60,7 +65,7 @@ static certificate_type_t get_type(private_pubkey_cert_t *this) */ static identification_t* get_subject(private_pubkey_cert_t *this) { - return this->key->get_id(this->key, ID_PUBKEY_SHA1); + return this->key->get_id(this->key, ID_PUBKEY_INFO_SHA1); } /** @@ -109,7 +114,7 @@ static bool equals(private_pubkey_cert_t *this, certificate_t *other) { return FALSE; } - return other->has_subject(other, this->key->get_id(this->key, ID_PUBKEY_SHA1)); + return other->has_subject(other, this->key->get_id(this->key, ID_PUBKEY_INFO_SHA1)); } /** @@ -211,6 +216,13 @@ static pubkey_cert_t *pubkey_cert_create(public_key_t *key) return &this->public; } +static pubkey_cert_t *pubkey_cert_create_from_chunk(chunk_t blob) +{ + public_key_t *key = pubkey_public_key_load(chunk_clone(blob)); + + return (key)? pubkey_cert_create(key) : NULL; +} + typedef struct private_builder_t private_builder_t; /** * Builder implementation for key loading @@ -238,27 +250,35 @@ static pubkey_cert_t *build(private_builder_t *this) */ static void add(private_builder_t *this, builder_part_t part, ...) { - va_list args; - - if (this->key) + if (!this->key) { - DBG1("ignoring surplus build part %N", builder_part_names, part); - return; - } + va_list args; - switch (part) - { - case BUILD_PUBLIC_KEY: + switch (part) { - va_start(args, part); - this->key = pubkey_cert_create(va_arg(args, public_key_t*)); - va_end(args); - break; + case BUILD_BLOB_ASN1_DER: + { + va_start(args, part); + this->key = pubkey_cert_create_from_chunk(va_arg(args, chunk_t)); + va_end(args); + return; + } + case BUILD_PUBLIC_KEY: + { + va_start(args, part); + this->key = pubkey_cert_create(va_arg(args, public_key_t*)); + va_end(args); + return; + } + default: + break; } - default: - DBG1("ignoring unsupported build part %N", builder_part_names, part); - break; } + if (this->key) + { + destroy((private_pubkey_cert_t*)this->key); + } + builder_cancel(&this->public); } /** diff --git a/src/libstrongswan/plugins/pubkey/pubkey_public_key.c b/src/libstrongswan/plugins/pubkey/pubkey_public_key.c index 0527ed758..4b5f4aac2 100644 --- a/src/libstrongswan/plugins/pubkey/pubkey_public_key.c +++ b/src/libstrongswan/plugins/pubkey/pubkey_public_key.c @@ -14,7 +14,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: pubkey_public_key.c 4059 2008-06-11 14:10:02Z martin $ + * $Id: pubkey_public_key.c 4379 2008-10-08 01:19:26Z andreas $ */ #include "pubkey_public_key.h" @@ -39,9 +39,10 @@ static const asn1Object_t pkinfoObjects[] = { /** - * Load a public key from an ASN1 encoded blob + * Load a public key from an ASN.1 encoded blob + * Also used by pubkey_cert.c */ -static public_key_t *load(chunk_t blob) +public_key_t *pubkey_public_key_load(chunk_t blob) { asn1_parser_t *parser; chunk_t object; @@ -67,9 +68,8 @@ static public_key_t *load(chunk_t blob) else if (oid == OID_EC_PUBLICKEY) { /* we need the whole subjectPublicKeyInfo for EC public keys */ - key = lib->creds->create(lib->creds, - CRED_PUBLIC_KEY, KEY_ECDSA, BUILD_BLOB_ASN1_DER, - chunk_clone(blob), BUILD_END); + key = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, + KEY_ECDSA, BUILD_BLOB_ASN1_DER, blob, BUILD_END); goto end; } else @@ -86,8 +86,7 @@ static public_key_t *load(chunk_t blob) object = chunk_skip(object, 1); } key = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, type, - BUILD_BLOB_ASN1_DER, chunk_clone(object), - BUILD_END); + BUILD_BLOB_ASN1_DER, object, BUILD_END); break; } } @@ -125,41 +124,43 @@ static public_key_t *build(private_builder_t *this) */ static void add(private_builder_t *this, builder_part_t part, ...) { - va_list args; - - if (this->key) - { - DBG1("ignoring surplus build part %N", builder_part_names, part); - return; - } - va_start(args, part); - switch (part) + if (!this->key) { - case BUILD_BLOB_ASN1_DER: + va_list args; + chunk_t blob; + + switch (part) { - this->key = load(va_arg(args, chunk_t)); - break; - } - case BUILD_BLOB_ASN1_PEM: - { - bool pgp; - char *pem; - chunk_t blob; - - pem = va_arg(args, char *); - blob = chunk_clone(chunk_create(pem, strlen(pem))); - if (pem_to_bin(&blob, &chunk_empty, &pgp)) + case BUILD_BLOB_ASN1_DER: { - this->key = load(chunk_clone(blob)); + va_start(args, part); + blob = va_arg(args, chunk_t); + this->key = pubkey_public_key_load(chunk_clone(blob)); + va_end(args); + return; } - free(blob.ptr); - break; + case BUILD_BLOB_ASN1_PEM: + { + bool pgp; + char *pem; + + va_start(args, part); + pem = va_arg(args, char *); + blob = chunk_clone(chunk_create(pem, strlen(pem))); + if (pem_to_bin(&blob, &chunk_empty, &pgp)) + { + this->key = pubkey_public_key_load(chunk_clone(blob)); + } + free(blob.ptr); + va_end(args); + return; + } + default: + break; } - default: - DBG1("ignoring unsupported build part %N", builder_part_names, part); - break; } - va_end(args); + DESTROY_IF(this->key); + builder_cancel(&this->public); } /** diff --git a/src/libstrongswan/plugins/random/Makefile.in b/src/libstrongswan/plugins/random/Makefile.in index c4baa04b3..90b319520 100644 --- a/src/libstrongswan/plugins/random/Makefile.in +++ b/src/libstrongswan/plugins/random/Makefile.in @@ -188,6 +188,8 @@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ +nm_CFLAGS = @nm_CFLAGS@ +nm_LIBS = @nm_LIBS@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ piddir = @piddir@ diff --git a/src/libstrongswan/plugins/random/random_rng.c b/src/libstrongswan/plugins/random/random_rng.c index 1aadc88bd..45a1b5138 100644 --- a/src/libstrongswan/plugins/random/random_rng.c +++ b/src/libstrongswan/plugins/random/random_rng.c @@ -63,7 +63,8 @@ struct private_random_rng_t { static void get_bytes(private_random_rng_t *this, size_t bytes, u_int8_t *buffer) { - size_t done, got; + size_t done; + ssize_t got; done = 0; diff --git a/src/libstrongswan/plugins/sha1/Makefile.am b/src/libstrongswan/plugins/sha1/Makefile.am index 299e85083..5de45e4e8 100644 --- a/src/libstrongswan/plugins/sha1/Makefile.am +++ b/src/libstrongswan/plugins/sha1/Makefile.am @@ -5,6 +5,7 @@ AM_CFLAGS = -rdynamic plugin_LTLIBRARIES = libstrongswan-sha1.la -libstrongswan_sha1_la_SOURCES = sha1_plugin.h sha1_plugin.c sha1_hasher.c sha1_hasher.h +libstrongswan_sha1_la_SOURCES = sha1_plugin.h sha1_plugin.c \ + sha1_hasher.c sha1_hasher.h sha1_prf.c sha1_prf.h libstrongswan_sha1_la_LDFLAGS = -module diff --git a/src/libstrongswan/plugins/sha1/Makefile.in b/src/libstrongswan/plugins/sha1/Makefile.in index b57c46aee..df6845b43 100644 --- a/src/libstrongswan/plugins/sha1/Makefile.in +++ b/src/libstrongswan/plugins/sha1/Makefile.in @@ -50,7 +50,8 @@ am__installdirs = "$(DESTDIR)$(plugindir)" pluginLTLIBRARIES_INSTALL = $(INSTALL) LTLIBRARIES = $(plugin_LTLIBRARIES) libstrongswan_sha1_la_LIBADD = -am_libstrongswan_sha1_la_OBJECTS = sha1_plugin.lo sha1_hasher.lo +am_libstrongswan_sha1_la_OBJECTS = sha1_plugin.lo sha1_hasher.lo \ + sha1_prf.lo libstrongswan_sha1_la_OBJECTS = $(am_libstrongswan_sha1_la_OBJECTS) libstrongswan_sha1_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ @@ -187,6 +188,8 @@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ +nm_CFLAGS = @nm_CFLAGS@ +nm_LIBS = @nm_LIBS@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ piddir = @piddir@ @@ -209,7 +212,9 @@ xml_LIBS = @xml_LIBS@ INCLUDES = -I$(top_srcdir)/src/libstrongswan AM_CFLAGS = -rdynamic plugin_LTLIBRARIES = libstrongswan-sha1.la -libstrongswan_sha1_la_SOURCES = sha1_plugin.h sha1_plugin.c sha1_hasher.c sha1_hasher.h +libstrongswan_sha1_la_SOURCES = sha1_plugin.h sha1_plugin.c \ + sha1_hasher.c sha1_hasher.h sha1_prf.c sha1_prf.h + libstrongswan_sha1_la_LDFLAGS = -module all: all-am @@ -282,6 +287,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sha1_hasher.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sha1_plugin.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sha1_prf.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< diff --git a/src/libstrongswan/plugins/sha1/sha1_hasher.c b/src/libstrongswan/plugins/sha1/sha1_hasher.c index c496be8f4..ea0882cb5 100644 --- a/src/libstrongswan/plugins/sha1/sha1_hasher.c +++ b/src/libstrongswan/plugins/sha1/sha1_hasher.c @@ -16,7 +16,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: sha1_hasher.c 3619 2008-03-19 14:02:52Z martin $ + * $Id: sha1_hasher.c 4308 2008-08-28 10:57:24Z martin $ */ #include <string.h> @@ -47,7 +47,6 @@ typedef struct private_sha1_hasher_t private_sha1_hasher_t; -typedef struct private_sha1_keyed_prf_t private_sha1_keyed_prf_t; /** * Private data structure with hasing context. @@ -59,28 +58,13 @@ struct private_sha1_hasher_t { sha1_hasher_t public; /* - * State of the hasher. + * State of the hasher. Shared with sha1_prf.c, do not change it!!! */ u_int32_t state[5]; u_int32_t count[2]; u_int8_t buffer[64]; }; -/** - * Private data structure with keyed prf context. - */ -struct private_sha1_keyed_prf_t { - /** - * public prf interface - */ - sha1_keyed_prf_t public; - - /** - * internal used hasher - */ - private_sha1_hasher_t *hasher; -}; - /* * Hash a single 512-bit block. This is the core of the algorithm. * */ @@ -132,10 +116,10 @@ static void SHA1Transform(u_int32_t state[5], const unsigned char buffer[64]) memset(block, '\0', sizeof(block)); } -/* - * Run your data through this. +/** + * Run your data through this. Also used in sha1_prf. */ -static void SHA1Update(private_sha1_hasher_t* this, u_int8_t *data, u_int32_t len) +void SHA1Update(private_sha1_hasher_t* this, u_int8_t *data, u_int32_t len) { u_int32_t i; u_int32_t j; @@ -275,92 +259,3 @@ sha1_hasher_t *sha1_hasher_create(hash_algorithm_t algo) return &(this->public); } -/** - * Implementation of prf_t.get_bytes. - */ -static void get_bytes(private_sha1_keyed_prf_t *this, chunk_t seed, u_int8_t *bytes) -{ - u_int32_t *hash = (u_int32_t*)bytes; - - SHA1Update(this->hasher, seed.ptr, seed.len); - - hash[0] = htonl(this->hasher->state[0]); - hash[1] = htonl(this->hasher->state[1]); - hash[2] = htonl(this->hasher->state[2]); - hash[3] = htonl(this->hasher->state[3]); - hash[4] = htonl(this->hasher->state[4]); -} - -/** - * Implementation of prf_t.get_block_size. - */ -static size_t get_block_size(private_sha1_keyed_prf_t *this) -{ - return HASH_SIZE_SHA1; -} - -/** - * Implementation of prf_t.allocate_bytes. - */ -static void allocate_bytes(private_sha1_keyed_prf_t *this, chunk_t seed, chunk_t *chunk) -{ - *chunk = chunk_alloc(HASH_SIZE_SHA1); - get_bytes(this, seed, chunk->ptr); -} - -/** - * Implementation of prf_t.get_key_size. - */ -static size_t get_key_size(private_sha1_keyed_prf_t *this) -{ - return sizeof(this->hasher->state); -} - -/** - * Implementation of prf_t.set_key. - */ -static void set_key(private_sha1_keyed_prf_t *this, chunk_t key) -{ - int i, rounds; - u_int32_t *iv = (u_int32_t*)key.ptr; - - reset(this->hasher); - rounds = min(key.len/sizeof(u_int32_t), sizeof(this->hasher->state)); - for (i = 0; i < rounds; i++) - { - this->hasher->state[i] ^= htonl(iv[i]); - } -} - -/** - * Implementation of prf_t.destroy. - */ -static void destroy_p(private_sha1_keyed_prf_t *this) -{ - destroy(this->hasher); - free(this); -} - -/** - * see header - */ -sha1_keyed_prf_t *sha1_keyed_prf_create(pseudo_random_function_t algo) -{ - private_sha1_keyed_prf_t *this; - if (algo != PRF_KEYED_SHA1) - { - return NULL; - } - this = malloc_thing(private_sha1_keyed_prf_t); - this->public.prf_interface.get_bytes = (void (*) (prf_t *,chunk_t,u_int8_t*))get_bytes; - this->public.prf_interface.allocate_bytes = (void (*) (prf_t*,chunk_t,chunk_t*))allocate_bytes; - this->public.prf_interface.get_block_size = (size_t (*) (prf_t*))get_block_size; - this->public.prf_interface.get_key_size = (size_t (*) (prf_t*))get_key_size; - this->public.prf_interface.set_key = (void (*) (prf_t *,chunk_t))set_key; - this->public.prf_interface.destroy = (void (*) (prf_t *))destroy_p; - - this->hasher = (private_sha1_hasher_t*)sha1_hasher_create(HASH_SHA1); - - return &(this->public); -} - diff --git a/src/libstrongswan/plugins/sha1/sha1_hasher.h b/src/libstrongswan/plugins/sha1/sha1_hasher.h index 2e44797d8..7dcb0b8b3 100644 --- a/src/libstrongswan/plugins/sha1/sha1_hasher.h +++ b/src/libstrongswan/plugins/sha1/sha1_hasher.h @@ -23,10 +23,8 @@ #define SHA1_HASHER_H_ typedef struct sha1_hasher_t sha1_hasher_t; -typedef struct sha1_keyed_prf_t sha1_keyed_prf_t; #include <crypto/hashers/hasher.h> -#include <crypto/prfs/prf.h> /** * Implementation of hasher_t interface using the SHA1 algorithm. @@ -40,17 +38,6 @@ struct sha1_hasher_t { }; /** - * Implementation of prf_t interface using keyed SHA1 algorithm (used for EAP-AKA). - */ -struct sha1_keyed_prf_t { - - /** - * Implements prf_t interface. - */ - prf_t prf_interface; -}; - -/** * Creates a new sha1_hasher_t. * * @param algo algorithm, must be HASH_SHA1 @@ -58,12 +45,4 @@ struct sha1_keyed_prf_t { */ sha1_hasher_t *sha1_hasher_create(hash_algorithm_t algo); -/** - * Creates a new sha1_keyed_prf_t. - * - * @param algo algorithm, must be PRF_KEYED_SHA1 - * @return sha1_keyed_prf_tobject - */ -sha1_keyed_prf_t *sha1_keyed_prf_create(pseudo_random_function_t algo); - #endif /*SHA1_HASHER_H_ @}*/ diff --git a/src/libstrongswan/plugins/sha1/sha1_plugin.c b/src/libstrongswan/plugins/sha1/sha1_plugin.c index e8da99e6c..58f0faf56 100644 --- a/src/libstrongswan/plugins/sha1/sha1_plugin.c +++ b/src/libstrongswan/plugins/sha1/sha1_plugin.c @@ -12,13 +12,14 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: sha1_plugin.c 3619 2008-03-19 14:02:52Z martin $ + * $Id: sha1_plugin.c 4308 2008-08-28 10:57:24Z martin $ */ #include "sha1_plugin.h" #include <library.h> #include "sha1_hasher.h" +#include "sha1_prf.h" typedef struct private_sha1_plugin_t private_sha1_plugin_t; @@ -41,7 +42,7 @@ static void destroy(private_sha1_plugin_t *this) lib->crypto->remove_hasher(lib->crypto, (hasher_constructor_t)sha1_hasher_create); lib->crypto->remove_prf(lib->crypto, - (prf_constructor_t)sha1_keyed_prf_create); + (prf_constructor_t)sha1_prf_create); free(this); } @@ -57,7 +58,7 @@ plugin_t *plugin_create() lib->crypto->add_hasher(lib->crypto, HASH_SHA1, (hasher_constructor_t)sha1_hasher_create); lib->crypto->add_prf(lib->crypto, PRF_KEYED_SHA1, - (prf_constructor_t)sha1_keyed_prf_create); + (prf_constructor_t)sha1_prf_create); return &this->public.plugin; } diff --git a/src/libstrongswan/plugins/sha1/sha1_prf.c b/src/libstrongswan/plugins/sha1/sha1_prf.c new file mode 100644 index 000000000..668801caf --- /dev/null +++ b/src/libstrongswan/plugins/sha1/sha1_prf.c @@ -0,0 +1,152 @@ +/* + * Copyright (C) 2008 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. + * + * $Id$ + */ + +#include "sha1_prf.h" +#include "sha1_hasher.h" + +#include <arpa/inet.h> + +typedef struct private_sha1_prf_t private_sha1_prf_t; +typedef struct private_sha1_hasher_t private_sha1_hasher_t; + +/** + * Private data structure with hasing context. + */ +struct private_sha1_hasher_t { + /** + * Public interface for this hasher. + */ + sha1_hasher_t public; + + /* + * State of the hasher. From sha1_hasher.c, do not change it! + */ + u_int32_t state[5]; + u_int32_t count[2]; + u_int8_t buffer[64]; +}; + +/** + * Private data structure with keyed prf context. + */ +struct private_sha1_prf_t { + + /** + * public prf interface + */ + sha1_prf_t public; + + /** + * internal used hasher + */ + private_sha1_hasher_t *hasher; +}; + +/** + * From sha1_hasher.c + */ +extern void SHA1Update(private_sha1_hasher_t* this, u_int8_t *data, u_int32_t len); + +/** + * Implementation of prf_t.get_bytes. + */ +static void get_bytes(private_sha1_prf_t *this, chunk_t seed, u_int8_t *bytes) +{ + u_int32_t *hash = (u_int32_t*)bytes; + + SHA1Update(this->hasher, seed.ptr, seed.len); + + hash[0] = htonl(this->hasher->state[0]); + hash[1] = htonl(this->hasher->state[1]); + hash[2] = htonl(this->hasher->state[2]); + hash[3] = htonl(this->hasher->state[3]); + hash[4] = htonl(this->hasher->state[4]); +} + +/** + * Implementation of prf_t.get_block_size. + */ +static size_t get_block_size(private_sha1_prf_t *this) +{ + return HASH_SIZE_SHA1; +} + +/** + * Implementation of prf_t.allocate_bytes. + */ +static void allocate_bytes(private_sha1_prf_t *this, chunk_t seed, chunk_t *chunk) +{ + *chunk = chunk_alloc(HASH_SIZE_SHA1); + get_bytes(this, seed, chunk->ptr); +} + +/** + * Implementation of prf_t.get_key_size. + */ +static size_t get_key_size(private_sha1_prf_t *this) +{ + return sizeof(this->hasher->state); +} + +/** + * Implementation of prf_t.set_key. + */ +static void set_key(private_sha1_prf_t *this, chunk_t key) +{ + int i, rounds; + u_int32_t *iv = (u_int32_t*)key.ptr; + + this->hasher->public.hasher_interface.reset(&this->hasher->public.hasher_interface); + rounds = min(key.len/sizeof(u_int32_t), sizeof(this->hasher->state)); + for (i = 0; i < rounds; i++) + { + this->hasher->state[i] ^= htonl(iv[i]); + } +} + +/** + * Implementation of prf_t.destroy. + */ +static void destroy(private_sha1_prf_t *this) +{ + this->hasher->public.hasher_interface.destroy(&this->hasher->public.hasher_interface); + free(this); +} + +/** + * see header + */ +sha1_prf_t *sha1_prf_create(pseudo_random_function_t algo) +{ + private_sha1_prf_t *this; + if (algo != PRF_KEYED_SHA1) + { + return NULL; + } + this = malloc_thing(private_sha1_prf_t); + this->public.prf_interface.get_bytes = (void (*) (prf_t *,chunk_t,u_int8_t*))get_bytes; + this->public.prf_interface.allocate_bytes = (void (*) (prf_t*,chunk_t,chunk_t*))allocate_bytes; + this->public.prf_interface.get_block_size = (size_t (*) (prf_t*))get_block_size; + this->public.prf_interface.get_key_size = (size_t (*) (prf_t*))get_key_size; + this->public.prf_interface.set_key = (void (*) (prf_t *,chunk_t))set_key; + this->public.prf_interface.destroy = (void (*) (prf_t *))destroy; + + this->hasher = (private_sha1_hasher_t*)sha1_hasher_create(HASH_SHA1); + + return &this->public; +} + diff --git a/src/libstrongswan/plugins/sha1/sha1_prf.h b/src/libstrongswan/plugins/sha1/sha1_prf.h new file mode 100644 index 000000000..a0f56b681 --- /dev/null +++ b/src/libstrongswan/plugins/sha1/sha1_prf.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2008 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 sha1_prf sha1_prf + * @{ @ingroup sha1_p + */ + +#ifndef SHA1_PRF_H_ +#define SHA1_PRF_H_ + +typedef struct sha1_prf_t sha1_prf_t; + +#include <crypto/prfs/prf.h> + +/** + * Implementation of prf_t interface using keyed SHA1 algorithm (used for EAP-AKA). + */ +struct sha1_prf_t { + + /** + * Implements prf_t interface. + */ + prf_t prf_interface; +}; + +/** + * Creates a new sha1_prf_t. + * + * @param algo algorithm, must be PRF_KEYED_SHA1 + * @return sha1_keyed_prf_tobject + */ +sha1_prf_t *sha1_prf_create(pseudo_random_function_t algo); + +#endif /*SHA1_PRF_H_ @}*/ diff --git a/src/libstrongswan/plugins/sha2/Makefile.in b/src/libstrongswan/plugins/sha2/Makefile.in index ec0e45248..ea5610671 100644 --- a/src/libstrongswan/plugins/sha2/Makefile.in +++ b/src/libstrongswan/plugins/sha2/Makefile.in @@ -187,6 +187,8 @@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ +nm_CFLAGS = @nm_CFLAGS@ +nm_LIBS = @nm_LIBS@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ piddir = @piddir@ diff --git a/src/libstrongswan/plugins/sqlite/Makefile.in b/src/libstrongswan/plugins/sqlite/Makefile.in index 3a73829dc..21773de32 100644 --- a/src/libstrongswan/plugins/sqlite/Makefile.in +++ b/src/libstrongswan/plugins/sqlite/Makefile.in @@ -189,6 +189,8 @@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ +nm_CFLAGS = @nm_CFLAGS@ +nm_LIBS = @nm_LIBS@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ piddir = @piddir@ diff --git a/src/libstrongswan/plugins/sqlite/sqlite_database.c b/src/libstrongswan/plugins/sqlite/sqlite_database.c index d5a03894d..c8d9e5beb 100644 --- a/src/libstrongswan/plugins/sqlite/sqlite_database.c +++ b/src/libstrongswan/plugins/sqlite/sqlite_database.c @@ -12,12 +12,13 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: sqlite_database.c 3911 2008-05-07 14:41:13Z martin $ + * $Id: sqlite_database.c 4268 2008-08-21 11:58:58Z andreas $ */ #include "sqlite_database.h" #include <sqlite3.h> +#include <unistd.h> #include <library.h> #include <debug.h> #include <utils/mutex.h> @@ -131,8 +132,8 @@ typedef struct { int count; /** column types */ db_type_t *columns; - /** reference to db connection */ - sqlite3 *db; + /** back reference to parent */ + private_sqlite_database_t *database; } sqlite_enumerator_t; /** @@ -141,6 +142,9 @@ typedef struct { static void sqlite_enumerator_destroy(sqlite_enumerator_t *this) { sqlite3_finalize(this->stmt); +#if SQLITE_VERSION_NUMBER < 3005000 + this->database->mutex->unlock(this->database->mutex); +#endif free(this->columns); free(this); } @@ -158,7 +162,8 @@ static bool sqlite_enumerator_enumerate(sqlite_enumerator_t *this, ...) case SQLITE_ROW: break; default: - DBG1("stepping sqlite statement failed: %s", sqlite3_errmsg(this->db)); + DBG1("stepping sqlite statement failed: %s", + sqlite3_errmsg(this->database->db)); /* fall */ case SQLITE_DONE: return FALSE; @@ -218,6 +223,10 @@ static enumerator_t* query(private_sqlite_database_t *this, char *sql, ...) sqlite_enumerator_t *enumerator = NULL; int i; +#if SQLITE_VERSION_NUMBER < 3005000 + /* sqlite connections prior to 3.5 may be used by a single thread only, */ + this->mutex->lock(this->mutex); +#endif va_start(args, sql); stmt = run(this, sql, &args); @@ -229,7 +238,7 @@ static enumerator_t* query(private_sqlite_database_t *this, char *sql, ...) enumerator->stmt = stmt; enumerator->count = sqlite3_column_count(stmt); enumerator->columns = malloc(sizeof(db_type_t) * enumerator->count); - enumerator->db = this->db; + enumerator->database = this; for (i = 0; i < enumerator->count; i++) { enumerator->columns[i] = va_arg(args, db_type_t); @@ -274,6 +283,25 @@ static int execute(private_sqlite_database_t *this, int *rowid, char *sql, ...) } /** + * Implementation of database_t.get_driver + */ +static db_driver_t get_driver(private_sqlite_database_t *this) +{ + return DB_SQLITE; +} + +/** + * Busy handler implementation + */ +static int busy_handler(private_sqlite_database_t *this, int count) +{ + /* add a backoff time, quadratically increasing with every try */ + usleep(count * count * 1000); + /* always retry */ + return 1; +} + +/** * Implementation of database_t.destroy */ static void destroy(private_sqlite_database_t *this) @@ -304,9 +332,10 @@ sqlite_database_t *sqlite_database_create(char *uri) this->public.db.query = (enumerator_t* (*)(database_t *this, char *sql, ...))query; this->public.db.execute = (int (*)(database_t *this, int *rowid, char *sql, ...))execute; + this->public.db.get_driver = (db_driver_t(*)(database_t*))get_driver; this->public.db.destroy = (void(*)(database_t*))destroy; - this->mutex = mutex_create(MUTEX_DEFAULT); + this->mutex = mutex_create(MUTEX_RECURSIVE); if (sqlite3_open(file, &this->db) != SQLITE_OK) { @@ -316,6 +345,8 @@ sqlite_database_t *sqlite_database_create(char *uri) return NULL; } + sqlite3_busy_handler(this->db, (void*)busy_handler, this); + return &this->public; } diff --git a/src/libstrongswan/plugins/x509/Makefile.in b/src/libstrongswan/plugins/x509/Makefile.in index 9178d6c8c..01093e862 100644 --- a/src/libstrongswan/plugins/x509/Makefile.in +++ b/src/libstrongswan/plugins/x509/Makefile.in @@ -189,6 +189,8 @@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ +nm_CFLAGS = @nm_CFLAGS@ +nm_LIBS = @nm_LIBS@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ piddir = @piddir@ diff --git a/src/libstrongswan/plugins/x509/x509_ac.c b/src/libstrongswan/plugins/x509/x509_ac.c index cfa38c66b..caae5e08d 100644 --- a/src/libstrongswan/plugins/x509/x509_ac.c +++ b/src/libstrongswan/plugins/x509/x509_ac.c @@ -1054,6 +1054,7 @@ static void add(private_builder_t *this, builder_part_t part, ...) { va_list args; certificate_t *cert; + chunk_t chunk; va_start(args, part); switch (part) @@ -1070,7 +1071,8 @@ static void add(private_builder_t *this, builder_part_t part, ...) { destroy(this->ac); } - this->ac = create_from_chunk(va_arg(args, chunk_t)); + chunk = va_arg(args, chunk_t); + this->ac = create_from_chunk(chunk_clone(chunk)); break; case BUILD_NOT_BEFORE_TIME: this->ac->notBefore = va_arg(args, time_t); @@ -1079,7 +1081,8 @@ static void add(private_builder_t *this, builder_part_t part, ...) this->ac->notAfter = va_arg(args, time_t); break; case BUILD_SERIAL: - this->ac->serialNumber = va_arg(args, chunk_t); + chunk = va_arg(args, chunk_t); + this->ac->serialNumber = chunk_clone(chunk); break; case BUILD_IETF_GROUP_ATTR: ietfAttr_list_create_from_string(va_arg(args, char*), @@ -1089,29 +1092,27 @@ static void add(private_builder_t *this, builder_part_t part, ...) cert = va_arg(args, certificate_t*); if (cert->get_type(cert) == CERT_X509) { - this->ac->holderCert = cert; - } - else - { - cert->destroy(cert); + this->ac->holderCert = cert->get_ref(cert); } break; case BUILD_SIGNING_CERT: cert = va_arg(args, certificate_t*); if (cert->get_type(cert) == CERT_X509) { - this->ac->signerCert = cert; - } - else - { - cert->destroy(cert); + this->ac->signerCert = cert->get_ref(cert); } break; case BUILD_SIGNING_KEY: this->ac->signerKey = va_arg(args, private_key_t*); + this->ac->signerKey->get_ref(this->ac->signerKey); break; default: - DBG1("ignoring unsupported build part %N", builder_part_names, part); + /* abort if unsupported option */ + if (this->ac) + { + destroy(this->ac); + } + builder_cancel(&this->public); break; } va_end(args); diff --git a/src/libstrongswan/plugins/x509/x509_cert.c b/src/libstrongswan/plugins/x509/x509_cert.c index 714258865..c82d14a17 100644 --- a/src/libstrongswan/plugins/x509/x509_cert.c +++ b/src/libstrongswan/plugins/x509/x509_cert.c @@ -17,7 +17,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: x509_cert.c 4051 2008-06-10 09:08:27Z tobias $ + * $Id: x509_cert.c 4317 2008-09-02 11:00:13Z martin $ */ #define _GNU_SOURCE @@ -722,7 +722,7 @@ static bool parse_certificate(private_x509_cert_t *this) break; case X509_OBJ_SUBJECT_PUBLIC_KEY_INFO: this->public_key = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, - KEY_ANY, BUILD_BLOB_ASN1_DER, chunk_clone(object), BUILD_END); + KEY_ANY, BUILD_BLOB_ASN1_DER, object, BUILD_END); if (this->public_key == NULL) { DBG1("could not create public key"); @@ -1251,6 +1251,7 @@ static private_x509_cert_t *build(private_builder_t *this) static void add(private_builder_t *this, builder_part_t part, ...) { va_list args; + chunk_t chunk; va_start(args, part); switch (part) @@ -1259,13 +1260,19 @@ static void add(private_builder_t *this, builder_part_t part, ...) this->cert = create_from_file(va_arg(args, char*)); break; case BUILD_BLOB_ASN1_DER: - this->cert = create_from_chunk(va_arg(args, chunk_t)); + chunk = va_arg(args, chunk_t); + this->cert = create_from_chunk(chunk_clone(chunk)); break; case BUILD_X509_FLAG: this->flags = va_arg(args, x509_flag_t); break; default: - DBG1("ignoring unsupported build part %N", builder_part_names, part); + /* abort if unsupported option */ + if (this->cert) + { + destroy(this->cert); + } + builder_cancel(&this->public); break; } va_end(args); diff --git a/src/libstrongswan/plugins/x509/x509_crl.c b/src/libstrongswan/plugins/x509/x509_crl.c index 3bdda1701..eb9bfe903 100644 --- a/src/libstrongswan/plugins/x509/x509_crl.c +++ b/src/libstrongswan/plugins/x509/x509_crl.c @@ -12,7 +12,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: x509_crl.c 4091 2008-06-22 17:41:07Z andreas $ + * $Id: x509_crl.c 4317 2008-09-02 11:00:13Z martin $ */ #include "x509_crl.h" @@ -693,30 +693,37 @@ static private_x509_crl_t *build(private_builder_t *this) */ static void add(private_builder_t *this, builder_part_t part, ...) { - va_list args; - - if (this->crl) + if (!this->crl) { - DBG1("ignoring surplus build part %N", builder_part_names, part); - return; - } + va_list args; + chunk_t chunk; - va_start(args, part); - switch (part) - { - case BUILD_FROM_FILE: - this->crl = create_from_file(va_arg(args, char*)); - break; - case BUILD_BLOB_ASN1_DER: + switch (part) { - this->crl = create_from_chunk(va_arg(args, chunk_t)); - break; + case BUILD_FROM_FILE: + { + va_start(args, part); + this->crl = create_from_file(va_arg(args, char*)); + va_end(args); + return; + } + case BUILD_BLOB_ASN1_DER: + { + va_start(args, part); + chunk = va_arg(args, chunk_t); + this->crl = create_from_chunk(chunk_clone(chunk)); + va_end(args); + return; + } + default: + break; } - default: - DBG1("ignoring unsupported build part %N", builder_part_names, part); - break; } - va_end(args); + if (this->crl) + { + destroy(this->crl); + } + builder_cancel(&this->public); } /** diff --git a/src/libstrongswan/plugins/x509/x509_ocsp_request.c b/src/libstrongswan/plugins/x509/x509_ocsp_request.c index 590a974f7..7b97b990d 100644 --- a/src/libstrongswan/plugins/x509/x509_ocsp_request.c +++ b/src/libstrongswan/plugins/x509/x509_ocsp_request.c @@ -14,7 +14,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: x509_ocsp_request.c 4091 2008-06-22 17:41:07Z andreas $ + * $Id: x509_ocsp_request.c 4317 2008-09-02 11:00:13Z martin $ */ #include "x509_ocsp_request.h" @@ -547,6 +547,8 @@ static void add(private_builder_t *this, builder_part_t part, ...) { va_list args; certificate_t *cert; + identification_t *subject; + private_key_t *private; va_start(args, part); switch (part) @@ -555,35 +557,36 @@ static void add(private_builder_t *this, builder_part_t part, ...) cert = va_arg(args, certificate_t*); if (cert->get_type(cert) == CERT_X509) { - this->req->ca = (x509_t*)cert; - } - else - { - cert->destroy(cert); + this->req->ca = (x509_t*)cert->get_ref(cert); } break; case BUILD_CERT: cert = va_arg(args, certificate_t*); if (cert->get_type(cert) == CERT_X509) { - this->req->candidates->insert_last(this->req->candidates, cert); - } - else - { - cert->destroy(cert); + this->req->candidates->insert_last(this->req->candidates, + cert->get_ref(cert)); } break; case BUILD_SIGNING_CERT: - this->req->cert = va_arg(args, certificate_t*); + cert = va_arg(args, certificate_t*); + this->req->cert = cert->get_ref(cert); break; case BUILD_SIGNING_KEY: - this->req->key = va_arg(args, private_key_t*); + private = va_arg(args, private_key_t*); + this->req->key = private->get_ref(private); break; case BUILD_SUBJECT: - this->req->requestor = va_arg(args, identification_t*); + subject = va_arg(args, identification_t*); + this->req->requestor = subject->clone(subject); break; default: - DBG1("ignoring unsupported build part %N", builder_part_names, part); + /* cancel if option not supported */ + if (this->req) + { + destroy(this->req); + } + builder_cancel(&this->public); break; } va_end(args); diff --git a/src/libstrongswan/plugins/x509/x509_ocsp_response.c b/src/libstrongswan/plugins/x509/x509_ocsp_response.c index 33cf73cd2..01f35864d 100644 --- a/src/libstrongswan/plugins/x509/x509_ocsp_response.c +++ b/src/libstrongswan/plugins/x509/x509_ocsp_response.c @@ -14,7 +14,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: x509_ocsp_response.c 4091 2008-06-22 17:41:07Z andreas $ + * $Id: x509_ocsp_response.c 4317 2008-09-02 11:00:13Z martin $ */ #include "x509_ocsp_response.h" @@ -560,8 +560,7 @@ static bool parse_basicOCSPResponse(private_x509_ocsp_response_t *this, case BASIC_RESPONSE_CERTIFICATE: { cert = lib->creds->create(lib->creds, CRED_CERTIFICATE,CERT_X509, - BUILD_BLOB_ASN1_DER, - chunk_clone(object), + BUILD_BLOB_ASN1_DER, object, BUILD_END); if (cert) { @@ -944,27 +943,30 @@ static x509_ocsp_response_t *build(private_builder_t *this) */ static void add(private_builder_t *this, builder_part_t part, ...) { - va_list args; - - if (this->res) - { - DBG1("ignoring surplus build part %N", builder_part_names, part); - return; - } - - switch (part) + if (!this->res) { - case BUILD_BLOB_ASN1_DER: + va_list args; + chunk_t chunk; + + switch (part) { - va_start(args, part); - this->res = load(va_arg(args, chunk_t)); - va_end(args); - break; + case BUILD_BLOB_ASN1_DER: + { + va_start(args, part); + chunk = va_arg(args, chunk_t); + this->res = load(chunk_clone(chunk)); + va_end(args); + return; + } + default: + break; } - default: - DBG1("ignoring unsupported build part %N", builder_part_names, part); - break; } + if (this->res) + { + destroy((private_x509_ocsp_response_t*)this->res); + } + builder_cancel(&this->public); } /** diff --git a/src/libstrongswan/plugins/xcbc/Makefile.in b/src/libstrongswan/plugins/xcbc/Makefile.in index 3fdf46955..898142582 100644 --- a/src/libstrongswan/plugins/xcbc/Makefile.in +++ b/src/libstrongswan/plugins/xcbc/Makefile.in @@ -188,6 +188,8 @@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ +nm_CFLAGS = @nm_CFLAGS@ +nm_LIBS = @nm_LIBS@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ piddir = @piddir@ |