From: Victor Wagner Date: Sat, 19 Sep 2015 11:25:09 +0000 (+0300) Subject: Added option to load engine via configuration file to allow tecting with X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=d9a37e677239c4a9be7ac62b497272480c37d490;p=openssl-gost%2Fengine.git Added option to load engine via configuration file to allow tecting with unpatched openssl 1.0.1 and 1.0.2 series. --- diff --git a/test/03-encrypt.t b/test/03-encrypt.t index 5ed6b55..6cb8b9b 100644 --- a/test/03-encrypt.t +++ b/test/03-encrypt.t @@ -2,6 +2,12 @@ use Test::More tests => 48; use Cwd 'abs_path'; +# +# If this variable is set, engine would be loaded via configuration +# file. Otherwise - via command line +# +$use_config = 1; + # prepare data for @@ -28,20 +34,41 @@ our $count=0; # -iv - IV (hex-encoded) # +open F,">","test.cnf"; +if (defined($use_config) && $use_config) { + $eng_param = ""; + open F,">","test.cnf"; + print F <", "test$count.clear"; print $f $p{-cleartext}; close $f; + $ENV{'CRYPT_PARAMS'} = $p{-paramset} if exists $p{-paramset}; - my $ctext = `openssl enc -engine ${engine} -e -$p{-alg} -K $p{-key} -iv $p{-iv} -in test$count.clear`; + my $ctext = `openssl enc ${eng_param} -e -$p{-alg} -K $p{-key} -iv $p{-iv} -in test$count.clear`; is($?,0,"$p{-name} - encrypt successful"); is(unpack("H*",$ctext),$p{-ciphertext},"$p{-name} - ciphertext expected"); open my $f, ">", "test$count.enc"; print $f $ctext; close $f; - my $otext = `openssl enc -engine ${engine} -d -$p{-alg} -K $p{-key} -iv $p{-iv} -in test$count.enc`; + my $otext = `openssl enc ${eng_param} -d -$p{-alg} -K $p{-key} -iv $p{-iv} -in test$count.enc`; is($?,0,"$p{-name} - decrypt successful"); is($otext,$p{-cleartext},"$p{-name} - decrypted correctly"); unlink "test$count.enc"; @@ -129,3 +156,4 @@ crypt_test(-paramset=> "1.2.643.2.2.31.4", -key => $key, -iv => $iv, -alg => 'gost89-cbc', -name=> 'CBC short text, paramset D'); +unlink test.cnf;