X-Git-Url: http://wagner.pp.ru/gitweb/?a=blobdiff_plain;f=test%2F03-encrypt.t;h=8ab3d4aa94af572f05211b3c668209b20e74e20b;hb=e1fd432c3fd595871e1821360995d7d09faa9ead;hp=5ed6b55dd4236edf8c999e3d6f2acc796575b9d1;hpb=c4e2a10ce56876b3cc5d593aa13d13f3ebe322d6;p=openssl-gost%2Fengine.git diff --git a/test/03-encrypt.t b/test/03-encrypt.t index 5ed6b55..8ab3d4a 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"; @@ -113,8 +140,8 @@ crypt_test(-paramset=> "1.2.643.2.2.31.1", -key => $key, -iv => $iv, crypt_test(-paramset=> "1.2.643.2.2.31.2", -key => $key, -iv => $iv, -cleartext => $clear1, - -ciphertext => '11465c1c9708033e784fbb5536f2719c38353cb488b01f195c20d4c027022e8300d98bb66c138afbe878c88b', - -alg => 'gost89', + -ciphertext => 'af2a2167b75852378af176ac9950e3c4bffc94d3d4355191707adbb16d6c8e3f3a07868c4702babef18393edfac60a6d', + -alg => 'gost89-cbc', -name=> 'CBC short text, paramset B'); crypt_test(-paramset=> "1.2.643.2.2.31.3", -key => $key, -iv => $iv, @@ -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;