8 open (my $F,">","testdata.dat");
9 print $F "12345670" x 128;
12 # Set OPENSSL_ENGINES environment variable to just built engine
13 if(!defined $ENV{'OPENSSL_ENGINES'}){
14 $ENV{'OPENSSL_ENGINES'} = abs_path("../.libs");
17 my $key='0123456789abcdef' x 2;
20 # You can redefine engine to use using ENGINE_NAME environment variable
22 my $engine=$ENV{'ENGINE_NAME'}||"gost";
24 # Reopen STDERR to eliminate extra output
25 open STDERR, ">>","tests.err";
27 if (exists $ENV{'OPENSSL_CONF'}) {
28 delete $ENV{'OPENSSL_CONF'}
31 # This test needs output of openssl engine -c command.
32 # Default one is hardcoded below, but you can place file
33 # ${ENGINE_NAME}.info into this directory if you use this test suite
34 # to test other engine implementing GOST cryptography.
38 if ( -f $engine . ".info") {
39 diag("Reading $engine.info");
40 open F, "<", $engine . ".info";
41 read F,$engine_info,1024;
44 $engine_info= <<EOINF;
45 (gost) Reference implementation of GOST engine
46 [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]
50 $ENV{'OPENSSL_CONF'}=abs_path("no_such_file.cfg");
51 is(`openssl engine -c $engine`,
53 "load engine without any config");
55 is(`openssl dgst -engine $engine -md_gost94 testdata.dat`,
56 "md_gost94(testdata.dat)= f7fc6d16a6a5c12ac4f7d320e0fd0d8354908699125e09727a4ef929122b1cae\n",
57 "compute digest without config");
60 open $F,">","test.cnf";
62 openssl_conf = openssl_def
68 default_algorithms = ALL
72 $ENV{'OPENSSL_CONF'}=abs_path('test.cnf');
74 is(`openssl engine -c $engine`,
76 "load engine with config");
78 is(`openssl dgst -md_gost94 testdata.dat`,
79 "md_gost94(testdata.dat)= f7fc6d16a6a5c12ac4f7d320e0fd0d8354908699125e09727a4ef929122b1cae\n",
80 "compute digest with config without explicit engine param");
82 is(`openssl dgst -engine $engine -md_gost94 testdata.dat`,
83 "md_gost94(testdata.dat)= f7fc6d16a6a5c12ac4f7d320e0fd0d8354908699125e09727a4ef929122b1cae\n",
84 "compute digest with both config and explicit engine param");
86 like(`openssl ciphers`, qr|GOST2001-GOST89-GOST89|, 'display GOST2001-GOST89-GOST89 cipher');
88 like(`openssl ciphers`, qr|GOST2012-GOST8912-GOST8912|, 'display GOST2012-GOST8912-GOST8912 cipher');
90 unlink('testdata.dat');