From: Victor Wagner Date: Fri, 18 Sep 2015 10:47:09 +0000 (+0300) Subject: Started test suite. Added .gitignore file X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=75f3eb6abae28f834b65ab0d6fca64b09ee0382d;p=openssl-gost%2Fengine.git Started test suite. Added .gitignore file --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..744c2f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +newnids.* +Makefile +Makefile.in +test/Makefile.in +test/Makefile +test/tests.err +*.o +*.lo +*.la +.deps +.libs +aclocal.m4 +autom4te.cache/ +config.guess +config.h +config.log +config.status +config.sub +configure +depcomp +install-sh +libtool +ltmain.sh +missing +stamp-h1 + diff --git a/Makefile.am b/Makefile.am index 8e247b7..42564c0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,5 @@ enginedir=@ENGINEDIR@ +PERL=@PERL@ srcdir=. lib_LTLIBRARIES=libgost.la libgost_enginedir=$(enginedir) @@ -6,8 +7,13 @@ libgost_la_includedir=$(includedir)/openssl libgost_la_include_HEADERS=e_gost_err.h gost89.h gosthash2012_const.h gosthash2012.h gosthash2012_precalc.h gosthash2012_ref.h gosthash2012_sse2.h gosthash.h gost_keywrap.h gost_lcl.h newnids.h libgost_la_SOURCES=e_gost_err.c gost89.c gost_ameth.c gost_asn1.c gost_crypt.c gost_ctl.c gost_ec_keyx.c gost_ec_sign.c gost_eng.c gosthash2012.c gosthash.c gost_keywrap.c gost_md2012.c gost_md.c gost_params.c gost_pmeth.c newnids.c obj_create.c +.PHONY: test + install-data-hook: rm -f $(DESTDIR)$(enginedir)/*.a $(DESTDIR)$(enginedir)/*.la newnids.c newnids.h: mkobj.pl gost_obj.txt $(PERL) mkobj.pl + +test: + $(MAKE) -C test test diff --git a/configure.ac b/configure.ac index 35ceec5..d1626f4 100644 --- a/configure.ac +++ b/configure.ac @@ -18,5 +18,5 @@ AC_PROG_LIBTOOL AC_CHECK_PROG([PERL],[perl],[perl],[AC_MSG_ERROR([*** perl not found])]) # Checks for libraries. AC_CHECK_LIB([crypto], [ENGINE_new], [], [AC_MSG_ERROR([*** libcrypto not found])]) -AC_CONFIG_FILES([Makefile]) +AC_CONFIG_FILES([Makefile test/Makefile]) AC_OUTPUT diff --git a/test/00-engine.t b/test/00-engine.t new file mode 100644 index 0000000..9fe06a5 --- /dev/null +++ b/test/00-engine.t @@ -0,0 +1,82 @@ +#!/usr/bin/perl +use Test::More tests => 5; +use Cwd 'abs_path'; + +# prepare data for + +open F,">","testdata.dat"; +print F "12345670" x 128; +close F; + +# Set OPENSSL_ENGINES environment variable to just build engine +$ENV{'OPENSSL_ENGINES'} = abs_path("../.libs"); + +$key='0123456789abcdef' x 2; + +# +# You can redefine engine to use using ENGINE_NAME environment variable +# +$engine=$ENV{'ENGINE_NAME'}||"gost"; + +# Reopen STDERR to eliminate extra output +open STDERR, ">>","tests.err"; + +if (exists $ENV{'OPENSSL_CONF'}) { + delete $ENV{'OPENSSL_CONF'} +} +# +# This test needs output of openssl engine -c command. +# Default one is hardcoded below, but you can place file +# ${ENGINE_NAME}.info into this directory if you use this test suite +# to test other engine implementing GOST cryptography. +# +if ( -f $engine . ".info") { + diag("Reading $engine.info"); + open F, "<", $engine . ".info"; + read F,$engine_info,1024; +} else { + +$engine_info= <","test.cnf"; +print F < 3; +use Cwd 'abs_path'; + +# prepare data for + +open F,">","testdata.dat"; +print F "12345670" x 128; +close F; + +# Set OPENSSL_ENGINES environment variable to just build engine +$ENV{'OPENSSL_ENGINES'} = abs_path("../.libs"); +# Set engine name from environment to allow testing of different engines +$engine=$ENV{'ENGINE_NAME'}||"gost"; +# Reopen STDERR to eliminate extra output +open STDERR, ">>","tests.err"; + +is(`openssl dgst -engine ${engine} -md_gost94 testdata.dat`, +"md_gost94(testdata.dat)= f7fc6d16a6a5c12ac4f7d320e0fd0d8354908699125e09727a4ef929122b1cae\n", +"GOST R 34.11-94"); + +is(`openssl dgst -engine ${engine} -md_gost12_256 testdata.dat`, +"md_gost12_256(testdata.dat)= d38a79cb15db40651051ef6879881fe25d84cdbb23ecec9f56126f8803f5fc88\n", +"GOST R 34.11-2012 256bit"); + +is(`openssl dgst -engine ${engine} -md_gost12_512 testdata.dat`, +"md_gost12_512(testdata.dat)= ac48be903716d9b9701fd8cdd75417b9085b5b642191926afd92310e645c52d465e36bbd5ccb356c5b1b8020a868915d5d8cc18ed2c07c28d24ba914b867f144\n", +"GOST R 34.11-2012 512bit"); + +unlink("testdata.dat"); diff --git a/test/02-mac.t b/test/02-mac.t new file mode 100644 index 0000000..b11bf7b --- /dev/null +++ b/test/02-mac.t @@ -0,0 +1,41 @@ +#!/usr/bin/perl +use Test::More tests => 10; +use Cwd 'abs_path'; + +# prepare data for + +open F,">","testdata.dat"; +print F "12345670" x 128; +close F; + +open F,">","testbig.dat"; +print F "12345670" x 1024; +close F; +# Set OPENSSL_ENGINES environment variable to just build engine +$ENV{'OPENSSL_ENGINES'} = abs_path("../.libs"); + +$key='0123456789abcdef' x 2; + +$engine=$ENV{'ENGINE_NAME'}||"gost"; + +# Reopen STDERR to eliminate extra output +open STDERR, ">>","tests.err"; + +is(`openssl dgst -engine ${engine} -mac gost-mac -macopt key:${key} testdata.dat`, +"GOST-MAC-gost-mac(testdata.dat)= 2ee8d13d\n", +"GOST MAC - default size"); + +for ($i=1;$i<=8; $i++) { + is(`openssl dgst -engine ${engine} -mac gost-mac -macopt key:${key} -sigopt size:$i testdata.dat`, +"GOST-MAC-gost-mac(testdata.dat)= ".substr("2ee8d13dff7f037d",0,$i*2)."\n", +"GOST MAC - size $i bytes"); +} + + + +is(`openssl dgst -engine ${engine} -mac gost-mac -macopt key:${key} testbig.dat`, +"GOST-MAC-gost-mac(testbig.dat)= d3978b1a\n", +"GOST MAC - big data"); + +unlink('testdata.dat'); +unlink('testbig.dat'); diff --git a/test/Makefile.am b/test/Makefile.am new file mode 100644 index 0000000..2a00f54 --- /dev/null +++ b/test/Makefile.am @@ -0,0 +1,4 @@ +PERL=@PERL@ + +test: + $(PERL) ./run_tests diff --git a/test/run_tests b/test/run_tests new file mode 100644 index 0000000..ad93e3f --- /dev/null +++ b/test/run_tests @@ -0,0 +1,5 @@ +#!/usr/bin/perl +use TAP::Harness; + +my $harness = TAP::Harness->new(); +$harness->runtests(glob("*.t"));