⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 do_tests.pl

📁 mediastreamer2是开源的网络传输媒体流的库
💻 PL
📖 第 1 页 / 共 2 页
字号:
# perl script to run OpenSSL testsmy $base_path      = "\\openssl";my $output_path    = "$base_path\\test_out";my $cert_path      = "$base_path\\certs";my $test_path      = "$base_path\\test";my $app_path       = "$base_path\\apps";my $tmp_cert       = "$output_path\\cert.tmp";my $OpenSSL_config = "$app_path\\openssl.cnf";my $log_file       = "$output_path\\tests.log";my $pause = 0;#  process the command line args to see if they wanted us to pause#  between executing each commandforeach $i (@ARGV){   if ($i =~ /^-p$/)   { $pause=1; }}main();############################################################################sub main(){   # delete all the output files in the output directory   unlink <$output_path\\*.*>;   # open the main log file    open(OUT, ">$log_file") || die "unable to open $log_file\n";      algorithm_tests();   encryption_tests();   pem_tests();   verify_tests();   ca_tests();   ssl_tests();   close(OUT);   print("\nCompleted running tests.\n\n");   print("Check log file for errors: $log_file\n");}############################################################################sub algorithm_tests{   my $i;   my $outFile;   my @tests = ( rsa_test, destest, ideatest, bftest, shatest, sha1test,                 md5test, dsatest, md2test, mdc2test, rc2test, rc4test, randtest,                 dhtest, exptest );   print( "\nRUNNING CRYPTO ALGORITHM TESTS:\n\n");   print( OUT "\n========================================================\n");   print( OUT "CRYPTO ALGORITHM TESTS:\n\n");   foreach $i (@tests)   {      if (-e "$base_path\\$i.nlm")	  {         $outFile = "$output_path\\$i.out";         system("$i > $outFile");         log_desc("Test: $i\.nlm:");         log_output("", $outFile );	  }	  else	  {         log_desc("Test: $i\.nlm: file not found");	  }   }}############################################################################sub encryption_tests{   my $i;   my $outFile;   my @enc_tests = ( "enc", "rc4", "des-cfb", "des-ede-cfb", "des-ede3-cfb",                     "des-ofb", "des-ede-ofb", "des-ede3-ofb",                     "des-ecb", "des-ede", "des-ede3", "des-cbc",                     "des-ede-cbc", "des-ede3-cbc", "idea-ecb", "idea-cfb",                     "idea-ofb", "idea-cbc", "rc2-ecb", "rc2-cfb",                     "rc2-ofb", "rc2-cbc", "bf-ecb", "bf-cfb",                     "bf-ofb", "bf-cbc" );   my $input = "$base_path\\do_tests.pl";   my $cipher = "$output_path\\cipher.out";   my $clear = "$output_path\\clear.out";   print( "\nRUNNING ENCRYPTION & DECRYPTION TESTS:\n\n");   print( OUT "\n========================================================\n");   print( OUT "FILE ENCRYPTION & DECRYPTION TESTS:\n\n");   foreach $i (@enc_tests)   {      log_desc("Testing: $i");      # do encryption      $outFile = "$output_path\\enc.out";      system("openssl2 $i -e -bufsize 113 -k test -in $input -out $cipher > $outFile" );      log_output("Encrypting: $input --> $cipher", $outFile);      # do decryption      $outFile = "$output_path\\dec.out";      system("openssl2 $i -d -bufsize 157 -k test -in $cipher -out $clear > $outFile");      log_output("Decrypting: $cipher --> $clear", $outFile);      # compare files      $x = compare_files( $input, $clear, 1);      if ( $x == 0 )      {         print( "SUCCESS - files match: $input, $clear\n");         print( OUT "SUCCESS - files match: $input, $clear\n");      }      else      {         print( "ERROR: files don't match\n");         print( OUT "ERROR: files don't match\n");      }      do_wait();      # Now do the same encryption but use Base64      # do encryption B64      $outFile = "$output_path\\B64enc.out";      system("openssl2 $i -a -e -bufsize 113 -k test -in $input -out $cipher > $outFile");      log_output("Encrypting(B64): $cipher --> $clear", $outFile);      # do decryption B64      $outFile = "$output_path\\B64dec.out";      system("openssl2 $i -a -d -bufsize 157 -k test -in $cipher -out $clear > $outFile");      log_output("Decrypting(B64): $cipher --> $clear", $outFile);      # compare files      $x = compare_files( $input, $clear, 1);      if ( $x == 0 )      {         print( "SUCCESS - files match: $input, $clear\n");         print( OUT "SUCCESS - files match: $input, $clear\n");      }      else      {         print( "ERROR: files don't match\n");         print( OUT "ERROR: files don't match\n");      }      do_wait();   } # end foreach   # delete the temporary files   unlink($cipher);   unlink($clear);}############################################################################sub pem_tests{   my $i;   my $tmp_out;   my $outFile = "$output_path\\pem.out";   my %pem_tests = (         "crl"      => "testcrl.pem",          "pkcs7"   => "testp7.pem",          "req"     => "testreq2.pem",          "rsa"     => "testrsa.pem",          "x509"    => "testx509.pem",          "x509"    => "v3-cert1.pem",          "sess_id" => "testsid.pem"  );   print( "\nRUNNING PEM TESTS:\n\n");   print( OUT "\n========================================================\n");   print( OUT "PEM TESTS:\n\n");   foreach $i (keys(%pem_tests))   {      log_desc( "Testing: $i");      my $input = "$test_path\\$pem_tests{$i}";      $tmp_out = "$output_path\\$pem_tests{$i}";      if ($i ne "req" )      {         system("openssl2 $i -in $input -out $tmp_out > $outFile");         log_output( "openssl2 $i -in $input -out $tmp_out", $outFile);      }      else      {         system("openssl2 $i -in $input -out $tmp_out -config $OpenSSL_config > $outFile");         log_output( "openssl2 $i -in $input -out $tmp_out -config $OpenSSL_config", $outFile );      }      $x = compare_files( $input, $tmp_out);      if ( $x == 0 )      {         print( "SUCCESS - files match: $input, $tmp_out\n");         print( OUT "SUCCESS - files match: $input, $tmp_out\n");      }      else      {         print( "ERROR: files don't match\n");         print( OUT "ERROR: files don't match\n");      }      do_wait();   } # end foreach}############################################################################sub verify_tests{   my $i;   my $outFile = "$output_path\\verify.out";   my @cert_files = <$cert_path\\*.pem>;   print( "\nRUNNING VERIFY TESTS:\n\n");   print( OUT "\n========================================================\n");   print( OUT "VERIFY TESTS:\n\n");   make_tmp_cert_file();   foreach $i (@cert_files)   {      system("openssl2 verify -CAfile $tmp_cert $i >$outFile");      log_desc("Verifying cert: $i");      log_output("openssl2 verify -CAfile $tmp_cert $i", $outFile);   }}############################################################################sub ssl_tests{   my $outFile = "$output_path\\ssl_tst.out";   my($CAcert) = "$output_path\\certCA.ss";   my($Ukey)   = "$output_path\\keyU.ss";   my($Ucert)  = "$output_path\\certU.ss";   my($ssltest)= "ssltest -key $Ukey -cert $Ucert -c_key $Ukey -c_cert $Ucert -CAfile $CAcert";   print( "\nRUNNING SSL TESTS:\n\n");   print( OUT "\n========================================================\n");   print( OUT "SSL TESTS:\n\n");   system("ssltest -ssl2 >$outFile");   log_desc("Testing sslv2:");   log_output("ssltest -ssl2", $outFile);   system("$ssltest -ssl2 -server_auth >$outFile");   log_desc("Testing sslv2 with server authentication:");   log_output("$ssltest -ssl2 -server_auth", $outFile);   system("$ssltest -ssl2 -client_auth >$outFile");   log_desc("Testing sslv2 with client authentication:");   log_output("$ssltest -ssl2 -client_auth", $outFile);   system("$ssltest -ssl2 -server_auth -client_auth >$outFile");   log_desc("Testing sslv2 with both client and server authentication:");   log_output("$ssltest -ssl2 -server_auth -client_auth", $outFile);   system("ssltest -ssl3 >$outFile");   log_desc("Testing sslv3:");   log_output("ssltest -ssl3", $outFile);   system("$ssltest -ssl3 -server_auth >$outFile");   log_desc("Testing sslv3 with server authentication:");   log_output("$ssltest -ssl3 -server_auth", $outFile);   system("$ssltest -ssl3 -client_auth >$outFile");   log_desc("Testing sslv3 with client authentication:");   log_output("$ssltest -ssl3 -client_auth", $outFile);   system("$ssltest -ssl3 -server_auth -client_auth >$outFile");   log_desc("Testing sslv3 with both client and server authentication:");   log_output("$ssltest -ssl3 -server_auth -client_auth", $outFile);   system("ssltest >$outFile");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -