Delete temp files.
[openssl.git] / test / runex.pl
index 1d77c88d12fd85d8531359f2e23486be35687841..ed16ad4399c3c31e420be2cfc60f21103bde8c9c 100644 (file)
@@ -56,8 +56,8 @@
 my $badttest = 0;
 my $verbose = 1;
 
-my $cmscmd = "../apps/openssl cms";
-my $convcmd = "../apps/openssl x509 -inform DER";
+my $cmscmd = "../util/shlib_wrap.sh ../apps/openssl cms";
+my $convcmd = "../util/shlib_wrap.sh ../apps/openssl x509 -inform DER";
 my $exdir = "examples";
 
 my @test_list = (
@@ -77,10 +77,12 @@ my @test_list = (
 ["5.1.bin"     => "encode"],
 ["5.2.bin"     => "encode"],
 ["6.0.bin"     => "encode, digest, cont"],
-["7.1.bin"     => "encode"],
-["7.2.bin"     => "encode"]
+["7.1.bin"     => "encode, encrypted, cont"],
+["7.2.bin"     => "encode, encrypted, cont"]
 );
 
+my $secretkey = "73:7c:79:1f:25:ea:d0:e0:46:29:25:43:52:f7:dc:62:91:e5:cb:26:91:7a:da:32";
+
        if (!-d $exdir)
                {
                print STDERR "FATAL ERROR: examples directory missing!!\n";
@@ -111,6 +113,10 @@ foreach (@test_list) {
                {
                run_digest_test($exdir, $tlist, $file);
                }
+       if ($tlist =~ /encrypted/)
+               {
+               run_encrypted_test($exdir, $tlist, $file, $secretkey);
+               }
 
 }
 
@@ -234,6 +240,32 @@ sub run_digest_test
                }
        }
 
+sub run_encrypted_test
+       {
+       my ($cmsdir, $tlist, $tfile, $key) = @_;
+       unlink "tmp.txt";
+
+       system ("$cmscmd -EncryptedData_decrypt -inform DER" .
+               " -secretkey $key" .
+               " -in $cmsdir/$tfile -out tmp.txt");
+
+       if ($?)
+               {
+               print "\tEncrypted Data command FAILED!!\n";
+               $badtest++;
+               }
+       elsif ($tlist =~ /cont/ &&
+               !cmp_files("$cmsdir/ExContent.bin", "tmp.txt"))
+               {
+               print "\tEncrypted Data content compare FAILED!!\n";
+               $badtest++;
+               }
+       else
+               {
+               print "\tEncryptedData verify passed\n" if $verbose;
+               }
+       }
+
 sub cmp_files
        {
        my ($f1, $f2) = @_;