2 use Test::More tests => 7;
7 open F,">","testdata.dat";
8 print F "12345670" x 128;
11 # Set OPENSSL_ENGINES environment variable to just built engine
12 if(!defined $ENV{'OPENSSL_ENGINES'}){
13 $ENV{'OPENSSL_ENGINES'} = abs_path("../.libs");
16 $key='0123456789abcdef' x 2;
19 # You can redefine engine to use using ENGINE_NAME environment variable
21 $engine=$ENV{'ENGINE_NAME'}||"gost";
23 # Reopen STDERR to eliminate extra output
24 open STDERR, ">>","tests.err";
26 if (exists $ENV{'OPENSSL_CONF'}) {
27 delete $ENV{'OPENSSL_CONF'}
30 # This test needs output of openssl engine -c command.
31 # Default one is hardcoded below, but you can place file
32 # ${ENGINE_NAME}.info into this directory if you use this test suite
33 # to test other engine implementing GOST cryptography.
35 if ( -f $engine . ".info") {
36 diag("Reading $engine.info");
37 open F, "<", $engine . ".info";
38 read F,$engine_info,1024;
41 $engine_info= <<EOINF;
42 (gost) Reference implementation of GOST engine
43 [gost89, gost89-cnt, gost89-cnt-12, gost89-cbc, grasshopper-ecb, grasshopper-cbc, grasshopper-cfb, grasshopper-ofb, grasshopper-ctr, magma-cbc, magma-ctr, id-tc26-cipher-gostr3412-2015-kuznyechik-ctracpkm, md_gost94, gost-mac, md_gost12_256, md_gost12_512, gost-mac-12, magma-mac, grasshopper-mac, id-tc26-cipher-gostr3412-2015-kuznyechik-ctracpkm-omac, gost2001, gost-mac, gost2012_256, gost2012_512, gost-mac-12, magma-mac, grasshopper-mac, id-tc26-cipher-gostr3412-2015-magma-ctracpkm-omac, id-tc26-cipher-gostr3412-2015-kuznyechik-ctracpkm-omac]
47 $ENV{'OPENSSL_CONF'}=abs_path("no_such_file.cfg");
48 is(`openssl engine -c $engine`,
50 "load engine without any config");
52 is(`openssl dgst -engine $engine -md_gost94 testdata.dat`,
53 "md_gost94(testdata.dat)= f7fc6d16a6a5c12ac4f7d320e0fd0d8354908699125e09727a4ef929122b1cae\n",
54 "compute digest without config");
57 open F,">","test.cnf";
59 openssl_conf = openssl_def
65 default_algorithms = ALL
69 $ENV{'OPENSSL_CONF'}=abs_path('test.cnf');
71 is(`openssl engine -c $engine`,
73 "load engine with config");
75 is(`openssl dgst -md_gost94 testdata.dat`,
76 "md_gost94(testdata.dat)= f7fc6d16a6a5c12ac4f7d320e0fd0d8354908699125e09727a4ef929122b1cae\n",
77 "compute digest with config without explicit engine param");
79 is(`openssl dgst -engine $engine -md_gost94 testdata.dat`,
80 "md_gost94(testdata.dat)= f7fc6d16a6a5c12ac4f7d320e0fd0d8354908699125e09727a4ef929122b1cae\n",
81 "compute digest with both config and explicit engine param");
83 like(`openssl ciphers`, qr|GOST2001-GOST89-GOST89|, 'display GOST2001-GOST89-GOST89 cipher');
85 like(`openssl ciphers`, qr|GOST2012-GOST8912-GOST8912|, 'display GOST2012-GOST8912-GOST8912 cipher');
87 unlink('testdata.dat');