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 = (
["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";
{
run_digest_test($exdir, $tlist, $file);
}
+ if ($tlist =~ /encrypted/)
+ {
+ run_encrypted_test($exdir, $tlist, $file, $secretkey);
+ }
}
}
}
+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) = @_;