]> wagner.pp.ru Git - openssl-gost/engine.git/commitdiff
Started test suite. Added .gitignore file
authorVictor Wagner <wagner@atlas-kard.ru>
Fri, 18 Sep 2015 10:47:09 +0000 (13:47 +0300)
committerVictor Wagner <wagner@atlas-kard.ru>
Fri, 18 Sep 2015 10:47:09 +0000 (13:47 +0300)
.gitignore [new file with mode: 0644]
Makefile.am
configure.ac
test/00-engine.t [new file with mode: 0644]
test/01-digest.t [new file with mode: 0644]
test/02-mac.t [new file with mode: 0644]
test/Makefile.am [new file with mode: 0644]
test/run_tests [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..744c2f9
--- /dev/null
@@ -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
+
index 8e247b746970cb1c991c8a2c40dd4a933c476423..42564c041ed9f57fe9926e24f2aa5cee4c0ef08c 100644 (file)
@@ -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
index 35ceec5824c4e2afcd01a85556643f1c9cbb383b..d1626f4c3c4d9f07a40eef55192b4871fe2a7556 100644 (file)
@@ -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 (file)
index 0000000..9fe06a5
--- /dev/null
@@ -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= <<EOINF;
+(gost) Reference implementation of GOST engine
+ [gost89, gost89-cnt, gost89-cnt-12, gost89-cbc, md_gost94, gost-mac, md_gost12_256, md_gost12_512, gost-mac-12, gost2001, gost-mac, gost2012_256, gost2012_512, UNDEF]
+EOINF
+}
+
+$ENV{'OPENSSL_CONF'}=abs_path("no_such_file.cfg");
+is(`openssl engine -c $engine`,
+$engine_info,
+"load engine without any config");
+
+is(`openssl dgst -engine $engine -md_gost94 testdata.dat`,
+"md_gost94(testdata.dat)= f7fc6d16a6a5c12ac4f7d320e0fd0d8354908699125e09727a4ef929122b1cae\n",
+"compute digest without config");
+
+
+open F,">","test.cnf";
+print F <<EOCFG;
+openssl_conf = openssl_def
+[openssl_def]
+engines = engines
+[engines]
+${engine}=gost_conf
+[gost_conf]
+default_algorithms = ALL
+
+EOCFG
+close F;
+$ENV{'OPENSSL_CONF'}=abs_path('test.cnf');
+
+is(`openssl engine -c $engine`,
+$engine_info,
+"load engine with config");
+
+is(`openssl dgst -md_gost94 testdata.dat`,
+"md_gost94(testdata.dat)= f7fc6d16a6a5c12ac4f7d320e0fd0d8354908699125e09727a4ef929122b1cae\n",
+"compute digest with config without explicit engine param");
+
+is(`openssl dgst -engine $engine -md_gost94 testdata.dat`,
+"md_gost94(testdata.dat)= f7fc6d16a6a5c12ac4f7d320e0fd0d8354908699125e09727a4ef929122b1cae\n",
+"compute digest with both config and explicit engine param");
+
+unlink('testdata.dat');
+unlink('test.cnf');
diff --git a/test/01-digest.t b/test/01-digest.t
new file mode 100644 (file)
index 0000000..40734fe
--- /dev/null
@@ -0,0 +1,30 @@
+#!/usr/bin/perl 
+use Test::More tests => 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 (file)
index 0000000..b11bf7b
--- /dev/null
@@ -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 (file)
index 0000000..2a00f54
--- /dev/null
@@ -0,0 +1,4 @@
+PERL=@PERL@
+
+test: 
+       $(PERL) ./run_tests
diff --git a/test/run_tests b/test/run_tests
new file mode 100644 (file)
index 0000000..ad93e3f
--- /dev/null
@@ -0,0 +1,5 @@
+#!/usr/bin/perl
+use TAP::Harness;
+
+my $harness = TAP::Harness->new();
+$harness->runtests(glob("*.t"));