summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorYves-Alexis Perez <corsac@debian.org>2013-11-01 13:32:07 +0100
committerYves-Alexis Perez <corsac@debian.org>2013-11-01 13:32:07 +0100
commit5313d2d78ca150515f7f5eb39801c100690b6b29 (patch)
treec78e420367283bb1b16f14210b12687cdfbd26eb /scripts
parent6b99c8d9cff7b3e8ae8f3204b99e7ea40f791349 (diff)
downloadvyos-strongswan-5313d2d78ca150515f7f5eb39801c100690b6b29.tar.gz
vyos-strongswan-5313d2d78ca150515f7f5eb39801c100690b6b29.zip
Imported Upstream version 5.1.1
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.am9
-rw-r--r--scripts/Makefile.in265
-rw-r--r--scripts/aes-test.c657
-rw-r--r--scripts/pubkey_speed.c17
4 files changed, 856 insertions, 92 deletions
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 06d4609cf..ed5147a3d 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -5,7 +5,7 @@ AM_CPPFLAGS = \
noinst_PROGRAMS = bin2array bin2sql id2sql key2keyid keyid2sql oid2der \
thread_analysis dh_speed pubkey_speed crypt_burn hash_burn fetch \
- dnssec malloc_speed
+ dnssec malloc_speed aes-test
if USE_TLS
noinst_PROGRAMS += tls_test
@@ -32,13 +32,14 @@ id2sql_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
key2keyid_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
keyid2sql_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
oid2der_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
-dh_speed_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la -lrt
-pubkey_speed_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la -lrt
+dh_speed_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la $(RTLIB)
+pubkey_speed_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la $(RTLIB)
crypt_burn_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
hash_burn_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
-malloc_speed_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
+malloc_speed_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la $(RTLIB)
fetch_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
dnssec_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
+aes_test_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
key2keyid.o : $(top_builddir)/config.status
diff --git a/scripts/Makefile.in b/scripts/Makefile.in
index 6808d2436..08a726041 100644
--- a/scripts/Makefile.in
+++ b/scripts/Makefile.in
@@ -1,9 +1,8 @@
-# Makefile.in generated by automake 1.11.6 from Makefile.am.
+# Makefile.in generated by automake 1.13.3 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-# Foundation, Inc.
+# Copyright (C) 1994-2013 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.
@@ -16,23 +15,51 @@
@SET_MAKE@
VPATH = @srcdir@
-am__make_dryrun = \
- { \
- am__dry=no; \
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
- echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
- | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
- *) \
- for am__flg in $$MAKEFLAGS; do \
- case $$am__flg in \
- *=*|--*) ;; \
- *n*) am__dry=yes; break;; \
- esac; \
- done;; \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
esac; \
- test $$am__dry = yes; \
- }
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@@ -56,16 +83,18 @@ noinst_PROGRAMS = bin2array$(EXEEXT) bin2sql$(EXEEXT) id2sql$(EXEEXT) \
thread_analysis$(EXEEXT) dh_speed$(EXEEXT) \
pubkey_speed$(EXEEXT) crypt_burn$(EXEEXT) hash_burn$(EXEEXT) \
fetch$(EXEEXT) dnssec$(EXEEXT) malloc_speed$(EXEEXT) \
- $(am__EXEEXT_1)
+ aes-test$(EXEEXT) $(am__EXEEXT_1)
@USE_TLS_TRUE@am__append_1 = tls_test
subdir = scripts
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+ $(top_srcdir)/depcomp
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/config/libtool.m4 \
$(top_srcdir)/m4/config/ltoptions.m4 \
$(top_srcdir)/m4/config/ltsugar.m4 \
$(top_srcdir)/m4/config/ltversion.m4 \
$(top_srcdir)/m4/config/lt~obsolete.m4 \
+ $(top_srcdir)/m4/macros/split-package-version.m4 \
$(top_srcdir)/m4/macros/with.m4 \
$(top_srcdir)/m4/macros/enable-disable.m4 \
$(top_srcdir)/m4/macros/add-plugin.m4 \
@@ -78,12 +107,17 @@ CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
@USE_TLS_TRUE@am__EXEEXT_1 = tls_test$(EXEEXT)
PROGRAMS = $(noinst_PROGRAMS)
-am_bin2array_OBJECTS = bin2array.$(OBJEXT)
-bin2array_OBJECTS = $(am_bin2array_OBJECTS)
-bin2array_LDADD = $(LDADD)
+aes_test_SOURCES = aes-test.c
+aes_test_OBJECTS = aes-test.$(OBJEXT)
+aes_test_DEPENDENCIES = \
+ $(top_builddir)/src/libstrongswan/libstrongswan.la
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
+am__v_lt_1 =
+am_bin2array_OBJECTS = bin2array.$(OBJEXT)
+bin2array_OBJECTS = $(am_bin2array_OBJECTS)
+bin2array_LDADD = $(LDADD)
am_bin2sql_OBJECTS = bin2sql.$(OBJEXT)
bin2sql_OBJECTS = $(am_bin2sql_OBJECTS)
bin2sql_LDADD = $(LDADD)
@@ -93,8 +127,10 @@ crypt_burn_DEPENDENCIES = \
$(top_builddir)/src/libstrongswan/libstrongswan.la
am_dh_speed_OBJECTS = dh_speed.$(OBJEXT)
dh_speed_OBJECTS = $(am_dh_speed_OBJECTS)
+am__DEPENDENCIES_1 =
dh_speed_DEPENDENCIES = \
- $(top_builddir)/src/libstrongswan/libstrongswan.la
+ $(top_builddir)/src/libstrongswan/libstrongswan.la \
+ $(am__DEPENDENCIES_1)
am_dnssec_OBJECTS = dnssec.$(OBJEXT)
dnssec_OBJECTS = $(am_dnssec_OBJECTS)
dnssec_DEPENDENCIES = \
@@ -122,7 +158,8 @@ keyid2sql_DEPENDENCIES = \
am_malloc_speed_OBJECTS = malloc_speed.$(OBJEXT)
malloc_speed_OBJECTS = $(am_malloc_speed_OBJECTS)
malloc_speed_DEPENDENCIES = \
- $(top_builddir)/src/libstrongswan/libstrongswan.la
+ $(top_builddir)/src/libstrongswan/libstrongswan.la \
+ $(am__DEPENDENCIES_1)
am_oid2der_OBJECTS = oid2der.$(OBJEXT)
oid2der_OBJECTS = $(am_oid2der_OBJECTS)
oid2der_DEPENDENCIES = \
@@ -130,7 +167,8 @@ oid2der_DEPENDENCIES = \
am_pubkey_speed_OBJECTS = pubkey_speed.$(OBJEXT)
pubkey_speed_OBJECTS = $(am_pubkey_speed_OBJECTS)
pubkey_speed_DEPENDENCIES = \
- $(top_builddir)/src/libstrongswan/libstrongswan.la
+ $(top_builddir)/src/libstrongswan/libstrongswan.la \
+ $(am__DEPENDENCIES_1)
am_thread_analysis_OBJECTS = thread_analysis.$(OBJEXT)
thread_analysis_OBJECTS = $(am_thread_analysis_OBJECTS)
thread_analysis_LDADD = $(LDADD)
@@ -139,6 +177,18 @@ am__tls_test_SOURCES_DIST = tls_test.c
tls_test_OBJECTS = $(am_tls_test_OBJECTS)
@USE_TLS_TRUE@tls_test_DEPENDENCIES = $(top_builddir)/src/libstrongswan/libstrongswan.la \
@USE_TLS_TRUE@ $(top_builddir)/src/libtls/libtls.la
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
@@ -151,28 +201,24 @@ LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
-am__v_CC_0 = @echo " CC " $@;
-AM_V_at = $(am__v_at_@AM_V@)
-am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
-am__v_at_0 = @
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
-am__v_CCLD_0 = @echo " CCLD " $@;
-AM_V_GEN = $(am__v_GEN_@AM_V@)
-am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
-am__v_GEN_0 = @echo " GEN " $@;
-SOURCES = $(bin2array_SOURCES) $(bin2sql_SOURCES) \
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
+SOURCES = aes-test.c $(bin2array_SOURCES) $(bin2sql_SOURCES) \
$(crypt_burn_SOURCES) $(dh_speed_SOURCES) $(dnssec_SOURCES) \
$(fetch_SOURCES) $(hash_burn_SOURCES) $(id2sql_SOURCES) \
$(key2keyid_SOURCES) $(keyid2sql_SOURCES) \
$(malloc_speed_SOURCES) $(oid2der_SOURCES) \
$(pubkey_speed_SOURCES) $(thread_analysis_SOURCES) \
$(tls_test_SOURCES)
-DIST_SOURCES = $(bin2array_SOURCES) $(bin2sql_SOURCES) \
+DIST_SOURCES = aes-test.c $(bin2array_SOURCES) $(bin2sql_SOURCES) \
$(crypt_burn_SOURCES) $(dh_speed_SOURCES) $(dnssec_SOURCES) \
$(fetch_SOURCES) $(hash_burn_SOURCES) $(id2sql_SOURCES) \
$(key2keyid_SOURCES) $(keyid2sql_SOURCES) \
@@ -184,6 +230,23 @@ am__can_run_installinfo = \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -260,6 +323,10 @@ PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
+PACKAGE_VERSION_BUILD = @PACKAGE_VERSION_BUILD@
+PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@
+PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@
+PACKAGE_VERSION_REVIEW = @PACKAGE_VERSION_REVIEW@
PATH_SEPARATOR = @PATH_SEPARATOR@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -376,6 +443,7 @@ starter_plugins = @starter_plugins@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
systemdsystemunitdir = @systemdsystemunitdir@
+t_plugins = @t_plugins@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
@@ -410,13 +478,14 @@ id2sql_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
key2keyid_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
keyid2sql_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
oid2der_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
-dh_speed_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la -lrt
-pubkey_speed_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la -lrt
+dh_speed_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la $(RTLIB)
+pubkey_speed_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la $(RTLIB)
crypt_burn_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
hash_burn_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
-malloc_speed_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
+malloc_speed_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la $(RTLIB)
fetch_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
dnssec_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
+aes_test_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
all: all-am
.SUFFIXES:
@@ -460,48 +529,67 @@ clean-noinstPROGRAMS:
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
echo " rm -f" $$list; \
rm -f $$list
+
+aes-test$(EXEEXT): $(aes_test_OBJECTS) $(aes_test_DEPENDENCIES) $(EXTRA_aes_test_DEPENDENCIES)
+ @rm -f aes-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(aes_test_OBJECTS) $(aes_test_LDADD) $(LIBS)
+
bin2array$(EXEEXT): $(bin2array_OBJECTS) $(bin2array_DEPENDENCIES) $(EXTRA_bin2array_DEPENDENCIES)
@rm -f bin2array$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(bin2array_OBJECTS) $(bin2array_LDADD) $(LIBS)
+
bin2sql$(EXEEXT): $(bin2sql_OBJECTS) $(bin2sql_DEPENDENCIES) $(EXTRA_bin2sql_DEPENDENCIES)
@rm -f bin2sql$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(bin2sql_OBJECTS) $(bin2sql_LDADD) $(LIBS)
+
crypt_burn$(EXEEXT): $(crypt_burn_OBJECTS) $(crypt_burn_DEPENDENCIES) $(EXTRA_crypt_burn_DEPENDENCIES)
@rm -f crypt_burn$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(crypt_burn_OBJECTS) $(crypt_burn_LDADD) $(LIBS)
+
dh_speed$(EXEEXT): $(dh_speed_OBJECTS) $(dh_speed_DEPENDENCIES) $(EXTRA_dh_speed_DEPENDENCIES)
@rm -f dh_speed$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(dh_speed_OBJECTS) $(dh_speed_LDADD) $(LIBS)
+
dnssec$(EXEEXT): $(dnssec_OBJECTS) $(dnssec_DEPENDENCIES) $(EXTRA_dnssec_DEPENDENCIES)
@rm -f dnssec$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(dnssec_OBJECTS) $(dnssec_LDADD) $(LIBS)
+
fetch$(EXEEXT): $(fetch_OBJECTS) $(fetch_DEPENDENCIES) $(EXTRA_fetch_DEPENDENCIES)
@rm -f fetch$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(fetch_OBJECTS) $(fetch_LDADD) $(LIBS)
+
hash_burn$(EXEEXT): $(hash_burn_OBJECTS) $(hash_burn_DEPENDENCIES) $(EXTRA_hash_burn_DEPENDENCIES)
@rm -f hash_burn$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(hash_burn_OBJECTS) $(hash_burn_LDADD) $(LIBS)
+
id2sql$(EXEEXT): $(id2sql_OBJECTS) $(id2sql_DEPENDENCIES) $(EXTRA_id2sql_DEPENDENCIES)
@rm -f id2sql$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(id2sql_OBJECTS) $(id2sql_LDADD) $(LIBS)
+
key2keyid$(EXEEXT): $(key2keyid_OBJECTS) $(key2keyid_DEPENDENCIES) $(EXTRA_key2keyid_DEPENDENCIES)
@rm -f key2keyid$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(key2keyid_OBJECTS) $(key2keyid_LDADD) $(LIBS)
+
keyid2sql$(EXEEXT): $(keyid2sql_OBJECTS) $(keyid2sql_DEPENDENCIES) $(EXTRA_keyid2sql_DEPENDENCIES)
@rm -f keyid2sql$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(keyid2sql_OBJECTS) $(keyid2sql_LDADD) $(LIBS)
+
malloc_speed$(EXEEXT): $(malloc_speed_OBJECTS) $(malloc_speed_DEPENDENCIES) $(EXTRA_malloc_speed_DEPENDENCIES)
@rm -f malloc_speed$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(malloc_speed_OBJECTS) $(malloc_speed_LDADD) $(LIBS)
+
oid2der$(EXEEXT): $(oid2der_OBJECTS) $(oid2der_DEPENDENCIES) $(EXTRA_oid2der_DEPENDENCIES)
@rm -f oid2der$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(oid2der_OBJECTS) $(oid2der_LDADD) $(LIBS)
+
pubkey_speed$(EXEEXT): $(pubkey_speed_OBJECTS) $(pubkey_speed_DEPENDENCIES) $(EXTRA_pubkey_speed_DEPENDENCIES)
@rm -f pubkey_speed$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(pubkey_speed_OBJECTS) $(pubkey_speed_LDADD) $(LIBS)
+
thread_analysis$(EXEEXT): $(thread_analysis_OBJECTS) $(thread_analysis_DEPENDENCIES) $(EXTRA_thread_analysis_DEPENDENCIES)
@rm -f thread_analysis$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(thread_analysis_OBJECTS) $(thread_analysis_LDADD) $(LIBS)
+
tls_test$(EXEEXT): $(tls_test_OBJECTS) $(tls_test_DEPENDENCIES) $(EXTRA_tls_test_DEPENDENCIES)
@rm -f tls_test$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(tls_test_OBJECTS) $(tls_test_LDADD) $(LIBS)
@@ -512,6 +600,7 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aes-test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bin2array.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bin2sql.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crypt_burn.Po@am__quote@
@@ -529,22 +618,25 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls_test.Po@am__quote@
.c.o:
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $<
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
.c.obj:
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.c.lo:
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
@@ -555,26 +647,15 @@ mostlyclean-libtool:
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; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
- mkid -fID $$unique
-tags: TAGS
-
-TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
- $(TAGS_FILES) $(LISP)
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
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; }; }'`; \
+ $(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
@@ -586,15 +667,11 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$$unique; \
fi; \
fi
-ctags: CTAGS
-CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
- $(TAGS_FILES) $(LISP)
- 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; }; }'`; \
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
@@ -603,6 +680,21 @@ GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -744,18 +836,19 @@ uninstall-am:
.MAKE: install-am install-strip
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
- clean-libtool clean-noinstPROGRAMS 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-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
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstPROGRAMS cscopelist-am ctags \
+ ctags-am 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-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 tags-am uninstall uninstall-am
key2keyid.o : $(top_builddir)/config.status
diff --git a/scripts/aes-test.c b/scripts/aes-test.c
new file mode 100644
index 000000000..ddf4a5ded
--- /dev/null
+++ b/scripts/aes-test.c
@@ -0,0 +1,657 @@
+/*
+ * Copyright (C) 2013 Tobias Brunner
+ * Hochschule fuer Technik Rapperswil
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <errno.h>
+
+#include <library.h>
+
+/** plugins to load */
+#undef PLUGINS
+#define PLUGINS "openssl"
+
+/**
+ * Context
+ */
+static struct {
+ /** input file */
+ FILE *in;
+ /** output file */
+ FILE *out;
+ /** whether to use GCM or CBC */
+ bool use_gcm;
+ /** whether to run the Monte Carlo Test */
+ bool use_mct;
+ /** whether to test encryption or decryption */
+ bool decrypt;
+ /** IV length in bits in case of GCM */
+ int ivlen;
+ /** ICV length in bits in case of GCM */
+ int icvlen;
+} ctx;
+
+/**
+ * Types of parameters of a test vector
+ */
+typedef enum {
+ PARAM_UNKNOWN,
+ PARAM_COUNT,
+ PARAM_KEY,
+ PARAM_IV,
+ PARAM_PLAINTEXT,
+ PARAM_CIPHERTEXT,
+ PARAM_AAD,
+ PARAM_ICV,
+} param_t;
+
+static param_t parse_parameter(char *param)
+{
+ if (strcaseeq(param, "COUNT"))
+ {
+ return PARAM_COUNT;
+ }
+ if (strcaseeq(param, "KEY"))
+ {
+ return PARAM_KEY;
+ }
+ if (strcaseeq(param, "IV"))
+ {
+ return PARAM_IV;
+ }
+ if (strcaseeq(param, "PLAINTEXT") ||
+ strcaseeq(param, "PT"))
+ {
+ return PARAM_PLAINTEXT;
+ }
+ if (strcaseeq(param, "CIPHERTEXT") ||
+ strcaseeq(param, "CT"))
+ {
+ return PARAM_CIPHERTEXT;
+ }
+ if (strcaseeq(param, "AAD"))
+ {
+ return PARAM_AAD;
+ }
+ if (strcaseeq(param, "TAG"))
+ {
+ return PARAM_ICV;
+ }
+ return PARAM_UNKNOWN;
+}
+
+/**
+ * Test vector
+ */
+typedef struct {
+ /** encryption/decryption key */
+ chunk_t key;
+ /** initialization vector */
+ chunk_t iv;
+ /** plain text */
+ chunk_t plain;
+ /** cipher text */
+ chunk_t cipher;
+ /** associated data */
+ chunk_t aad;
+ /** ICV/tag */
+ chunk_t icv;
+ /** whether the IV was provided */
+ bool external_iv;
+ /** whether the decryption/verification in GCM mode was successful */
+ bool success;
+} test_vector_t;
+
+static void test_vector_free(test_vector_t *test)
+{
+ chunk_free(&test->key);
+ chunk_free(&test->iv);
+ chunk_free(&test->plain);
+ chunk_free(&test->cipher);
+ chunk_free(&test->aad);
+ chunk_free(&test->icv);
+}
+
+static void print_result(test_vector_t *test)
+{
+ if (ctx.use_gcm)
+ {
+ if (ctx.decrypt)
+ {
+ if (test->success)
+ {
+ fprintf(ctx.out, "PT = %+B\n", &test->plain);
+ }
+ else
+ {
+ fprintf(ctx.out, "FAIL\n");
+ }
+ return;
+ }
+ if (!test->external_iv)
+ {
+ fprintf(ctx.out, "IV = %+B\n", &test->iv);
+ }
+ fprintf(ctx.out, "CT = %+B\n", &test->cipher);
+ fprintf(ctx.out, "Tag = %+B\n", &test->icv);
+ }
+ else
+ {
+ fprintf(ctx.out, "%s = %+B\n", ctx.decrypt ? "PLAINTEXT" : "CIPHERTEXT",
+ ctx.decrypt ? &test->plain : &test->cipher);
+ }
+}
+
+static bool get_next_test_vector(test_vector_t *test)
+{
+ param_t param = PARAM_UNKNOWN;
+ char line[512];
+
+ memset(test, 0, sizeof(test_vector_t));
+
+ while (fgets(line, sizeof(line), ctx.in))
+ {
+ enumerator_t *enumerator;
+ chunk_t value;
+ char *token;
+ int i;
+
+ switch (line[0])
+ {
+ case '\n':
+ case '\r':
+ case '#':
+ case '\0':
+ /* copy comments, empty lines etc. directly to the output */
+ if (param != PARAM_UNKNOWN)
+ { /* seems we got a complete test vector */
+ return TRUE;
+ }
+ fputs(line, ctx.out);
+ continue;
+ case '[':
+ /* control directives */
+ fputs(line, ctx.out);
+ if (strpfx(line, "[ENCRYPT]"))
+ {
+ ctx.decrypt = FALSE;
+ }
+ else if (strpfx(line, "[DECRYPT]"))
+ {
+ ctx.decrypt = TRUE;
+ }
+ else if (strcasepfx(line, "[IVlen = "))
+ {
+ ctx.ivlen = atoi(line + strlen("[IVlen = "));
+ }
+ else if (strcasepfx(line, "[Taglen = "))
+ {
+ ctx.icvlen = atoi(line + strlen("[Taglen = "));
+ }
+ continue;
+ default:
+ /* we assume the rest of the lines are PARAM = VALUE pairs*/
+ fputs(line, ctx.out);
+ break;
+ }
+
+ i = 0;
+ enumerator = enumerator_create_token(line, "=", " \n\r");
+ while (enumerator->enumerate(enumerator, &token))
+ {
+ switch (i++)
+ {
+ case 0: /* PARAM */
+ param = parse_parameter(token);
+ continue;
+ case 1: /* VALUE */
+ if (param != PARAM_UNKNOWN && param != PARAM_COUNT)
+ {
+ value = chunk_from_hex(chunk_from_str(token), NULL);
+ }
+ else
+ {
+ value = chunk_empty;
+ }
+ continue;
+ default:
+ break;
+ }
+ break;
+ }
+ enumerator->destroy(enumerator);
+ if (i < 2)
+ {
+ value = chunk_empty;
+ }
+ switch (param)
+ {
+ case PARAM_KEY:
+ test->key = value;
+ break;
+ case PARAM_IV:
+ test->iv = value;
+ test->external_iv = TRUE;
+ break;
+ case PARAM_PLAINTEXT:
+ test->plain = value;
+ break;
+ case PARAM_CIPHERTEXT:
+ test->cipher = value;
+ break;
+ case PARAM_AAD:
+ test->aad = value;
+ break;
+ case PARAM_ICV:
+ test->icv = value;
+ break;
+ default:
+ chunk_free(&value);
+ break;
+ }
+ }
+ if (param != PARAM_UNKNOWN)
+ { /* could be that the file ended with a complete test vector */
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static bool verify_test_vector(test_vector_t *test)
+{
+ if (ctx.use_gcm)
+ {
+ if (ctx.decrypt)
+ {
+ return test->key.ptr && test->iv.ptr && test->cipher.ptr &&
+ test->icv.ptr;
+ }
+ return test->key.ptr && test->plain.ptr;
+ }
+ if (ctx.decrypt)
+ {
+ return test->key.ptr && test->iv.ptr && test->cipher.ptr;
+ }
+ return test->key.ptr && test->iv.ptr && test->plain.ptr;
+}
+
+static bool do_test_gcm(test_vector_t *test)
+{
+ encryption_algorithm_t alg;
+ chunk_t key, iv;
+ aead_t *aead;
+ size_t saltlen, ivlen;
+
+ switch (ctx.icvlen / 8)
+ {
+ case 8:
+ alg = ENCR_AES_GCM_ICV8;
+ break;
+ case 12:
+ alg = ENCR_AES_GCM_ICV12;
+ break;
+ case 16:
+ alg = ENCR_AES_GCM_ICV16;
+ break;
+ default:
+ DBG1(DBG_APP, "unsupported ICV length: %d", ctx.icvlen);
+ return FALSE;
+ }
+
+ aead = lib->crypto->create_aead(lib->crypto, alg, test->key.len);
+ if (!aead)
+ {
+ DBG1(DBG_APP, "algorithm %N or key length (%d bits) not supported",
+ encryption_algorithm_names, alg, test->key.len * 8);
+ return FALSE;
+ }
+ /* our API is quite RFC 4106 specific, that is, part of the IV is provided
+ * at the end of the key. */
+ saltlen = aead->get_key_size(aead) - test->key.len;
+ ivlen = aead->get_iv_size(aead);
+ if (ctx.ivlen / 8 != saltlen + ivlen)
+ {
+ DBG1(DBG_APP, "unsupported IV length: %d", ctx.ivlen);
+ aead->destroy(aead);
+ return FALSE;
+ }
+ if (!test->external_iv)
+ {
+ rng_t *rng;
+
+ /* the IV consists of saltlen random bytes (usually additional keymat)
+ * followed by a counter, zero here */
+ test->iv = chunk_alloc(saltlen + ivlen);
+ memset(test->iv.ptr, 0, test->iv.len);
+ rng = lib->crypto->create_rng(lib->crypto, RNG_STRONG);
+ if (!rng || !rng->get_bytes(rng, saltlen, test->iv.ptr))
+ {
+ DBG1(DBG_APP, "failed to generate IV");
+ DESTROY_IF(rng);
+ aead->destroy(aead);
+ return FALSE;
+ }
+ rng->destroy(rng);
+ }
+ key = chunk_alloca(test->key.len + saltlen);
+ memcpy(key.ptr, test->key.ptr, test->key.len);
+ memcpy(key.ptr + test->key.len, test->iv.ptr, saltlen);
+ iv = chunk_alloca(ivlen);
+ memcpy(iv.ptr, test->iv.ptr + saltlen, iv.len);
+ if (!aead->set_key(aead, key))
+ {
+ DBG1(DBG_APP, "failed to set key");
+ aead->destroy(aead);
+ return FALSE;
+ }
+ if (ctx.decrypt)
+ {
+ /* the ICV is expected to follow the cipher text */
+ chunk_t cipher = chunk_cata("cc", test->cipher, test->icv);
+ /* store if the verification of the ICV verification is successful */
+ test->success = aead->decrypt(aead, cipher, test->aad, iv,
+ &test->plain);
+ }
+ else
+ {
+ if (!aead->encrypt(aead, test->plain, test->aad, iv, &test->cipher))
+ {
+ DBG1(DBG_APP, "encryption failed");
+ aead->destroy(aead);
+ return FALSE;
+ }
+ /* copy ICV from the end of the cipher text */
+ test->icv = chunk_alloc(ctx.icvlen / 8);
+ test->cipher.len -= test->icv.len;
+ memcpy(test->icv.ptr, test->cipher.ptr + test->cipher.len,
+ test->icv.len);
+ }
+ aead->destroy(aead);
+ return TRUE;
+}
+
+static bool do_crypt(crypter_t *crypter, test_vector_t *test)
+{
+ if (ctx.decrypt)
+ {
+ if (!crypter->decrypt(crypter, test->cipher, test->iv, &test->plain))
+ {
+ DBG1(DBG_APP, "decryption failed");
+ return FALSE;
+ }
+ }
+ else
+ {
+ if (!crypter->encrypt(crypter, test->plain, test->iv, &test->cipher))
+ {
+ DBG1(DBG_APP, "encryption failed");
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+static bool do_test_cbc(test_vector_t *test)
+{
+ crypter_t *crypter;
+
+ crypter = lib->crypto->create_crypter(lib->crypto, ENCR_AES_CBC,
+ test->key.len);
+ if (!crypter)
+ {
+ DBG1(DBG_APP, "algorithm %N or key length (%d bits) not supported",
+ encryption_algorithm_names, ENCR_AES_CBC, test->key.len * 8);
+ return FALSE;
+ }
+ if (!crypter->set_key(crypter, test->key))
+ {
+ DBG1(DBG_APP, "failed to set key");
+ crypter->destroy(crypter);
+ return FALSE;
+ }
+ if (!do_crypt(crypter, test))
+ {
+ crypter->destroy(crypter);
+ return FALSE;
+ }
+ crypter->destroy(crypter);
+ return TRUE;
+}
+
+static bool do_test_mct(test_vector_t *test)
+{
+ crypter_t *crypter;
+ chunk_t prev, *input, *output;
+ int i, j;
+
+ crypter = lib->crypto->create_crypter(lib->crypto, ENCR_AES_CBC,
+ test->key.len);
+ if (!crypter)
+ {
+ DBG1(DBG_APP, "algorithm %N or key length (%d bits) not supported",
+ encryption_algorithm_names, ENCR_AES_CBC, test->key.len * 8);
+ return FALSE;
+ }
+ input = ctx.decrypt ? &test->cipher : &test->plain;
+ output = ctx.decrypt ? &test->plain : &test->cipher;
+ if (crypter->get_block_size(crypter) != input->len)
+ {
+ DBG1(DBG_APP, "MCT only works for input with a length of one block");
+ crypter->destroy(crypter);
+ return FALSE;
+ }
+ prev = chunk_alloca(input->len);
+ /* assume initial IV as previous output */
+ *output = chunk_clone(test->iv);
+ for (i = 0; i < 100; i++)
+ {
+ if (i > 0)
+ { /* we copied the original lines already */
+ fprintf(ctx.out, "COUNT = %d\n", i);
+ fprintf(ctx.out, "KEY = %+B\n", &test->key);
+ fprintf(ctx.out, "IV = %+B\n", &test->iv);
+ fprintf(ctx.out, "%s = %+B\n",
+ ctx.decrypt ? "CIPHERTEXT" : "PLAINTEXT", input);
+ }
+ if (!crypter->set_key(crypter, test->key))
+ {
+ DBG1(DBG_APP, "failed to set key");
+ return FALSE;
+ }
+ for (j = 0; j < 1000; j++)
+ {
+ /* store previous output as it is used as input after next */
+ memcpy(prev.ptr, output->ptr, prev.len);
+ chunk_free(output);
+ if (!do_crypt(crypter, test))
+ {
+ crypter->destroy(crypter);
+ return FALSE;
+ }
+ /* prepare the next IV (our API does not allow incremental calls) */
+ if (ctx.decrypt)
+ {
+ memcpy(test->iv.ptr, input->ptr, test->iv.len);
+ }
+ else
+ {
+ memcpy(test->iv.ptr, output->ptr, test->iv.len);
+ }
+ /* the previous output is the next input */
+ memcpy(input->ptr, prev.ptr, input->len);
+ }
+ fprintf(ctx.out, "%s = %+B\n\n",
+ ctx.decrypt ? "PLAINTEXT" : "CIPHERTEXT", output);
+ /* derive key for next round */
+ switch (test->key.len)
+ {
+ case 16:
+ memxor(test->key.ptr, output->ptr, output->len);
+ break;
+ case 24:
+ memxor(test->key.ptr, prev.ptr + 8, 8);
+ memxor(test->key.ptr + 8, output->ptr, output->len);
+ break;
+ case 32:
+ memxor(test->key.ptr, prev.ptr, prev.len);
+ memxor(test->key.ptr + prev.len, output->ptr, output->len);
+ break;
+ }
+ /* the current output is used as IV for the next round */
+ memcpy(test->iv.ptr, output->ptr, test->iv.len);
+ }
+ crypter->destroy(crypter);
+ /* we return FALSE as we print the output ourselves */
+ return FALSE;
+}
+
+static bool do_test(test_vector_t *test)
+{
+ if (ctx.use_gcm)
+ {
+ return do_test_gcm(test);
+ }
+ if (ctx.use_mct)
+ {
+ return do_test_mct(test);
+ }
+ return do_test_cbc(test);
+}
+
+static void usage(FILE *out, char *name)
+{
+ fprintf(out, "Test AES implementation according to the AES Algorithm Validation Suite (AESAVS)\n");
+ fprintf(out, "and the GCM Validation System (GCMVS)\n\n");
+ fprintf(out, "%s [OPTIONS]\n\n", name);
+ fprintf(out, "Options:\n");
+ fprintf(out, " -h, --help print this help.\n");
+ fprintf(out, " -d, --debug=LEVEL set debug level (default 1).\n");
+ fprintf(out, " -m, --mode=MODE mode to test, either CBC or GCM (default CBC).\n");
+ fprintf(out, " -t, --mct run Monte Carlo Test (MCT), only for CBC.\n");
+ fprintf(out, " -x, --decrypt test decryption (not needed for CBC as files contain control directives).\n");
+ fprintf(out, " -i, --in=FILE request file (default STDIN).\n");
+ fprintf(out, " -o, --out=FILE response file (default STDOUT).\n");
+ fprintf(out, "\n");
+}
+
+int main(int argc, char *argv[])
+{
+ test_vector_t test;
+
+ ctx.in = stdin;
+ ctx.out = stdout;
+
+ library_init(NULL);
+ atexit(library_deinit);
+
+ while (true)
+ {
+ struct option long_opts[] = {
+ {"help", no_argument, NULL, 'h' },
+ {"debug", required_argument, NULL, 'd' },
+ {"mode", required_argument, NULL, 'm' },
+ {"mct", no_argument, NULL, 't' },
+ {"decrypt", no_argument, NULL, 'x' },
+ {"in", required_argument, NULL, 'i' },
+ {"out", required_argument, NULL, 'o' },
+ {0,0,0,0 },
+ };
+ switch (getopt_long(argc, argv, "hd:m:txi:o:", long_opts, NULL))
+ {
+ case EOF:
+ break;
+ case 'h':
+ usage(stdout, argv[0]);
+ return 0;
+ case 'd':
+ dbg_default_set_level(atoi(optarg));
+ continue;
+ case 'm':
+ if (strcaseeq(optarg, "GCM"))
+ {
+ ctx.use_gcm = TRUE;
+ }
+ else if (!strcaseeq(optarg, "CBC"))
+ {
+ usage(stderr, argv[0]);
+ return 1;
+ }
+ continue;
+ case 't':
+ ctx.use_mct = TRUE;
+ continue;
+ case 'x':
+ ctx.decrypt = TRUE;
+ continue;
+ case 'i':
+ ctx.in = fopen(optarg, "r");
+ if (!ctx.in)
+ {
+ fprintf(stderr, "failed to open '%s': %s\n", optarg,
+ strerror(errno));
+ usage(stderr, argv[0]);
+ return 1;
+ }
+ continue;
+ case 'o':
+ ctx.out = fopen(optarg, "w");
+ if (!ctx.out)
+ {
+ fprintf(stderr, "failed to open '%s': %s\n", optarg,
+ strerror(errno));
+ usage(stderr, argv[0]);
+ return 1;
+ }
+ continue;
+ default:
+ usage(stderr, argv[0]);
+ return 1;
+ }
+ break;
+ }
+ /* TODO: maybe make plugins configurable */
+ lib->plugins->load(lib->plugins, PLUGINS);
+ lib->plugins->status(lib->plugins, LEVEL_CTRL);
+
+ while (get_next_test_vector(&test))
+ {
+ if (verify_test_vector(&test))
+ {
+ if (do_test(&test))
+ {
+ print_result(&test);
+ }
+ }
+ else
+ {
+ DBG1(DBG_APP, "test vector with missing data encountered");
+ }
+ fprintf(ctx.out, "\n");
+ test_vector_free(&test);
+ }
+
+ if (ctx.in != stdin)
+ {
+ fclose(ctx.in);
+ }
+ if (ctx.out != stdout)
+ {
+ fclose(ctx.out);
+ }
+ return 0;
+}
diff --git a/scripts/pubkey_speed.c b/scripts/pubkey_speed.c
index ba3ad1f5e..f7e75162a 100644
--- a/scripts/pubkey_speed.c
+++ b/scripts/pubkey_speed.c
@@ -1,3 +1,17 @@
+/*
+ * Copyright (C) 2009 Martin Willi
+ * Hochschule fuer Technik Rapperswil
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
#include <stdio.h>
#include <time.h>
@@ -21,7 +35,7 @@ double end_timing(struct timespec *start)
static void usage()
{
- printf("usage: pubkey_speed plugins rsa|ecdsa rounds\n");
+ printf("usage: pubkey_speed plugins rsa|ecdsa rounds < key\n");
exit(1);
}
@@ -138,4 +152,3 @@ int main(int argc, char *argv[])
free(sigs);
return 0;
}
-