]> wagner.pp.ru Git - openssl-gost/engine.git/blobdiff - test/02-mac.t
Started test suite. Added .gitignore file
[openssl-gost/engine.git] / test / 02-mac.t
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');