~ubuntu-branches/ubuntu/lucid/openssl/lucid-proposed

« back to all changes in this revision

Viewing changes to Netware/do_tests.pl

  • Committer: Bazaar Package Importer
  • Author(s): Kurt Roeckx
  • Date: 2009-06-13 18:15:46 UTC
  • mto: (11.1.5 squeeze)
  • mto: This revision was merged to the branch mainline in revision 34.
  • Revision ID: james.westby@ubuntu.com-20090613181546-vbfntai3b009dl1u
Tags: upstream-0.9.8k
ImportĀ upstreamĀ versionĀ 0.9.8k

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
   # delete all the output files in the output directory
35
35
   unlink <$output_path\\*.*>;
36
36
 
37
 
   # open the main log file 
 
37
   # open the main log file
38
38
   open(OUT, ">$log_file") || die "unable to open $log_file\n";
39
39
 
40
 
   
 
40
   print( OUT "========================================================\n");
 
41
   my $outFile = "$output_path\\version.out";
 
42
   system("openssl2 version (CLIB_OPT)/>$outFile");
 
43
   log_output("CHECKING FOR OPENSSL VERSION:", $outFile);
 
44
 
41
45
   algorithm_tests();
42
46
   encryption_tests();
 
47
   evp_tests();
43
48
   pem_tests();
44
49
   verify_tests();
45
50
   ca_tests();
56
61
{
57
62
   my $i;
58
63
   my $outFile;
59
 
   my @tests = ( rsa_test, destest, ideatest, bftest, shatest, sha1test,
60
 
                 md5test, dsatest, md2test, mdc2test, rc2test, rc4test, randtest,
61
 
                 dhtest, exptest );
 
64
   my @tests = ( rsa_test, destest, ideatest, bftest, bntest, shatest, sha1test,
 
65
                 sha256t, sha512t, dsatest, md2test, md4test, md5test, mdc2test,
 
66
                 rc2test, rc4test, rc5test, randtest, rmdtest, dhtest, ecdhtest,
 
67
                 ecdsatest, ectest, exptest, casttest, hmactest );
62
68
 
63
69
   print( "\nRUNNING CRYPTO ALGORITHM TESTS:\n\n");
64
70
 
68
74
   foreach $i (@tests)
69
75
   {
70
76
      if (-e "$base_path\\$i.nlm")
71
 
          {
 
77
      {
72
78
         $outFile = "$output_path\\$i.out";
73
 
         system("$i > $outFile");
 
79
         system("$i (CLIB_OPT)/>$outFile");
74
80
         log_desc("Test: $i\.nlm:");
75
81
         log_output("", $outFile );
76
 
          }
77
 
          else
78
 
          {
 
82
      }
 
83
      else
 
84
      {
79
85
         log_desc("Test: $i\.nlm: file not found");
80
 
          }
 
86
      }
81
87
   }
82
88
}
83
89
 
109
115
 
110
116
      # do encryption
111
117
      $outFile = "$output_path\\enc.out";
112
 
      system("openssl2 $i -e -bufsize 113 -k test -in $input -out $cipher > $outFile" );
 
118
      system("openssl2 $i -e -bufsize 113 -k test -in $input -out $cipher (CLIB_OPT)/>$outFile" );
113
119
      log_output("Encrypting: $input --> $cipher", $outFile);
114
120
 
115
121
      # do decryption
116
122
      $outFile = "$output_path\\dec.out";
117
 
      system("openssl2 $i -d -bufsize 157 -k test -in $cipher -out $clear > $outFile");
 
123
      system("openssl2 $i -d -bufsize 157 -k test -in $cipher -out $clear (CLIB_OPT)/>$outFile");
118
124
      log_output("Decrypting: $cipher --> $clear", $outFile);
119
125
 
120
126
      # compare files
121
127
      $x = compare_files( $input, $clear, 1);
122
128
      if ( $x == 0 )
123
129
      {
124
 
         print( "SUCCESS - files match: $input, $clear\n");
 
130
         print( "\rSUCCESS - files match: $input, $clear\n");
125
131
         print( OUT "SUCCESS - files match: $input, $clear\n");
126
132
      }
127
133
      else
128
134
      {
129
 
         print( "ERROR: files don't match\n");
 
135
         print( "\rERROR: files don't match\n");
130
136
         print( OUT "ERROR: files don't match\n");
131
137
      }
132
138
 
136
142
 
137
143
      # do encryption B64
138
144
      $outFile = "$output_path\\B64enc.out";
139
 
      system("openssl2 $i -a -e -bufsize 113 -k test -in $input -out $cipher > $outFile");
 
145
      system("openssl2 $i -a -e -bufsize 113 -k test -in $input -out $cipher (CLIB_OPT)/>$outFile");
140
146
      log_output("Encrypting(B64): $cipher --> $clear", $outFile);
141
147
 
142
148
      # do decryption B64
143
149
      $outFile = "$output_path\\B64dec.out";
144
 
      system("openssl2 $i -a -d -bufsize 157 -k test -in $cipher -out $clear > $outFile");
 
150
      system("openssl2 $i -a -d -bufsize 157 -k test -in $cipher -out $clear (CLIB_OPT)/>$outFile");
145
151
      log_output("Decrypting(B64): $cipher --> $clear", $outFile);
146
152
 
147
153
      # compare files
148
154
      $x = compare_files( $input, $clear, 1);
149
155
      if ( $x == 0 )
150
156
      {
151
 
         print( "SUCCESS - files match: $input, $clear\n");
 
157
         print( "\rSUCCESS - files match: $input, $clear\n");
152
158
         print( OUT "SUCCESS - files match: $input, $clear\n");
153
159
      }
154
160
      else
155
161
      {
156
 
         print( "ERROR: files don't match\n");
 
162
         print( "\rERROR: files don't match\n");
157
163
         print( OUT "ERROR: files don't match\n");
158
164
      }
159
165
 
199
205
 
200
206
      if ($i ne "req" )
201
207
      {
202
 
         system("openssl2 $i -in $input -out $tmp_out > $outFile");
 
208
         system("openssl2 $i -in $input -out $tmp_out (CLIB_OPT)/>$outFile");
203
209
         log_output( "openssl2 $i -in $input -out $tmp_out", $outFile);
204
210
      }
205
211
      else
206
212
      {
207
 
         system("openssl2 $i -in $input -out $tmp_out -config $OpenSSL_config > $outFile");
 
213
         system("openssl2 $i -in $input -out $tmp_out -config $OpenSSL_config (CLIB_OPT)/>$outFile");
208
214
         log_output( "openssl2 $i -in $input -out $tmp_out -config $OpenSSL_config", $outFile );
209
215
      }
210
216
 
211
217
      $x = compare_files( $input, $tmp_out);
212
218
      if ( $x == 0 )
213
219
      {
214
 
         print( "SUCCESS - files match: $input, $tmp_out\n");
 
220
         print( "\rSUCCESS - files match: $input, $tmp_out\n");
215
221
         print( OUT "SUCCESS - files match: $input, $tmp_out\n");
216
222
      }
217
223
      else
218
224
      {
219
 
         print( "ERROR: files don't match\n");
 
225
         print( "\rERROR: files don't match\n");
220
226
         print( OUT "ERROR: files don't match\n");
221
227
      }
222
228
      do_wait();
231
237
   my $i;
232
238
   my $outFile = "$output_path\\verify.out";
233
239
 
234
 
   my @cert_files = <$cert_path\\*.pem>;
 
240
   $cert_path =~ s/\\/\//g;
 
241
   my @cert_files = <$cert_path/*.pem>;
235
242
 
236
243
   print( "\nRUNNING VERIFY TESTS:\n\n");
237
244
 
242
249
 
243
250
   foreach $i (@cert_files)
244
251
   {
245
 
      system("openssl2 verify -CAfile $tmp_cert $i >$outFile");
 
252
      system("openssl2 verify -CAfile $tmp_cert $i (CLIB_OPT)/>$outFile");
246
253
      log_desc("Verifying cert: $i");
247
254
      log_output("openssl2 verify -CAfile $tmp_cert $i", $outFile);
248
255
   }
263
270
   print( OUT "\n========================================================\n");
264
271
   print( OUT "SSL TESTS:\n\n");
265
272
 
266
 
   system("ssltest -ssl2 >$outFile");
 
273
   system("ssltest -ssl2 (CLIB_OPT)/>$outFile");
267
274
   log_desc("Testing sslv2:");
268
275
   log_output("ssltest -ssl2", $outFile);
269
276
 
270
 
   system("$ssltest -ssl2 -server_auth >$outFile");
 
277
   system("$ssltest -ssl2 -server_auth (CLIB_OPT)/>$outFile");
271
278
   log_desc("Testing sslv2 with server authentication:");
272
279
   log_output("$ssltest -ssl2 -server_auth", $outFile);
273
280
 
274
 
   system("$ssltest -ssl2 -client_auth >$outFile");
 
281
   system("$ssltest -ssl2 -client_auth (CLIB_OPT)/>$outFile");
275
282
   log_desc("Testing sslv2 with client authentication:");
276
283
   log_output("$ssltest -ssl2 -client_auth", $outFile);
277
284
 
278
 
   system("$ssltest -ssl2 -server_auth -client_auth >$outFile");
 
285
   system("$ssltest -ssl2 -server_auth -client_auth (CLIB_OPT)/>$outFile");
279
286
   log_desc("Testing sslv2 with both client and server authentication:");
280
287
   log_output("$ssltest -ssl2 -server_auth -client_auth", $outFile);
281
288
 
282
 
   system("ssltest -ssl3 >$outFile");
 
289
   system("ssltest -ssl3 (CLIB_OPT)/>$outFile");
283
290
   log_desc("Testing sslv3:");
284
291
   log_output("ssltest -ssl3", $outFile);
285
292
 
286
 
   system("$ssltest -ssl3 -server_auth >$outFile");
 
293
   system("$ssltest -ssl3 -server_auth (CLIB_OPT)/>$outFile");
287
294
   log_desc("Testing sslv3 with server authentication:");
288
295
   log_output("$ssltest -ssl3 -server_auth", $outFile);
289
296
 
290
 
   system("$ssltest -ssl3 -client_auth >$outFile");
 
297
   system("$ssltest -ssl3 -client_auth (CLIB_OPT)/>$outFile");
291
298
   log_desc("Testing sslv3 with client authentication:");
292
299
   log_output("$ssltest -ssl3 -client_auth", $outFile);
293
300
 
294
 
   system("$ssltest -ssl3 -server_auth -client_auth >$outFile");
 
301
   system("$ssltest -ssl3 -server_auth -client_auth (CLIB_OPT)/>$outFile");
295
302
   log_desc("Testing sslv3 with both client and server authentication:");
296
303
   log_output("$ssltest -ssl3 -server_auth -client_auth", $outFile);
297
304
 
298
 
   system("ssltest >$outFile");
 
305
   system("ssltest (CLIB_OPT)/>$outFile");
299
306
   log_desc("Testing sslv2/sslv3:");
300
307
   log_output("ssltest", $outFile);
301
308
 
302
 
   system("$ssltest -server_auth >$outFile");
 
309
   system("$ssltest -server_auth (CLIB_OPT)/>$outFile");
303
310
   log_desc("Testing sslv2/sslv3 with server authentication:");
304
311
   log_output("$ssltest -server_auth", $outFile);
305
312
 
306
 
   system("$ssltest -client_auth >$outFile");
 
313
   system("$ssltest -client_auth (CLIB_OPT)/>$outFile");
307
314
   log_desc("Testing sslv2/sslv3 with client authentication:");
308
315
   log_output("$ssltest -client_auth ", $outFile);
309
316
 
310
 
   system("$ssltest -server_auth -client_auth >$outFile");
 
317
   system("$ssltest -server_auth -client_auth (CLIB_OPT)/>$outFile");
311
318
   log_desc("Testing sslv2/sslv3 with both client and server authentication:");
312
319
   log_output("$ssltest -server_auth -client_auth", $outFile);
313
320
 
314
 
   system("ssltest -bio_pair -ssl2 >$outFile");
 
321
   system("ssltest -bio_pair -ssl2 (CLIB_OPT)/>$outFile");
315
322
   log_desc("Testing sslv2 via BIO pair:");
316
323
   log_output("ssltest -bio_pair -ssl2", $outFile);
317
324
 
318
 
   system("ssltest -bio_pair -dhe1024dsa -v >$outFile");
 
325
   system("ssltest -bio_pair -dhe1024dsa -v (CLIB_OPT)/>$outFile");
319
326
   log_desc("Testing sslv2/sslv3 with 1024 bit DHE via BIO pair:");
320
327
   log_output("ssltest -bio_pair -dhe1024dsa -v", $outFile);
321
328
 
322
 
   system("$ssltest -bio_pair -ssl2 -server_auth >$outFile");
 
329
   system("$ssltest -bio_pair -ssl2 -server_auth (CLIB_OPT)/>$outFile");
323
330
   log_desc("Testing sslv2 with server authentication via BIO pair:");
324
331
   log_output("$ssltest -bio_pair -ssl2 -server_auth", $outFile);
325
332
 
326
 
   system("$ssltest -bio_pair -ssl2 -client_auth >$outFile");
 
333
   system("$ssltest -bio_pair -ssl2 -client_auth (CLIB_OPT)/>$outFile");
327
334
   log_desc("Testing sslv2 with client authentication via BIO pair:");
328
335
   log_output("$ssltest -bio_pair -ssl2 -client_auth", $outFile);
329
336
 
330
 
   system("$ssltest -bio_pair -ssl2 -server_auth -client_auth >$outFile");
 
337
   system("$ssltest -bio_pair -ssl2 -server_auth -client_auth (CLIB_OPT)/>$outFile");
331
338
   log_desc("Testing sslv2 with both client and server authentication via BIO pair:");
332
339
   log_output("$ssltest -bio_pair -ssl2 -server_auth -client_auth", $outFile);
333
340
 
334
 
   system("ssltest -bio_pair -ssl3 >$outFile");
 
341
   system("ssltest -bio_pair -ssl3 (CLIB_OPT)/>$outFile");
335
342
   log_desc("Testing sslv3 via BIO pair:");
336
343
   log_output("ssltest -bio_pair -ssl3", $outFile);
337
344
 
338
 
   system("$ssltest -bio_pair -ssl3 -server_auth >$outFile");
 
345
   system("$ssltest -bio_pair -ssl3 -server_auth (CLIB_OPT)/>$outFile");
339
346
   log_desc("Testing sslv3 with server authentication via BIO pair:");
340
347
   log_output("$ssltest -bio_pair -ssl3 -server_auth", $outFile);
341
348
 
342
 
   system("$ssltest -bio_pair -ssl3 -client_auth >$outFile");
 
349
   system("$ssltest -bio_pair -ssl3 -client_auth (CLIB_OPT)/>$outFile");
343
350
   log_desc("Testing sslv3 with client authentication  via BIO pair:");
344
351
   log_output("$ssltest -bio_pair -ssl3 -client_auth", $outFile);
345
352
 
346
 
   system("$ssltest -bio_pair -ssl3 -server_auth -client_auth >$outFile");
 
353
   system("$ssltest -bio_pair -ssl3 -server_auth -client_auth (CLIB_OPT)/>$outFile");
347
354
   log_desc("Testing sslv3 with both client and server authentication via BIO pair:");
348
355
   log_output("$ssltest -bio_pair -ssl3 -server_auth -client_auth", $outFile);
349
356
 
350
 
   system("ssltest -bio_pair >$outFile");
 
357
   system("ssltest -bio_pair (CLIB_OPT)/>$outFile");
351
358
   log_desc("Testing sslv2/sslv3 via BIO pair:");
352
359
   log_output("ssltest -bio_pair", $outFile);
353
360
 
354
 
   system("$ssltest -bio_pair -server_auth >$outFile");
 
361
   system("$ssltest -bio_pair -server_auth (CLIB_OPT)/>$outFile");
355
362
   log_desc("Testing sslv2/sslv3 with server authentication via BIO pair:");
356
363
   log_output("$ssltest -bio_pair -server_auth", $outFile);
357
364
 
358
 
   system("$ssltest -bio_pair -client_auth >$outFile");
 
365
   system("$ssltest -bio_pair -client_auth (CLIB_OPT)/>$outFile");
359
366
   log_desc("Testing sslv2/sslv3 with client authentication via BIO pair:");
360
367
   log_output("$ssltest -bio_pair -client_auth", $outFile);
361
368
 
362
 
   system("$ssltest -bio_pair -server_auth -client_auth >$outFile");
 
369
   system("$ssltest -bio_pair -server_auth -client_auth (CLIB_OPT)/>$outFile");
363
370
   log_desc("Testing sslv2/sslv3 with both client and server authentication via BIO pair:");
364
371
   log_output("$ssltest -bio_pair -server_auth -client_auth", $outFile);
365
372
}
389
396
   print( OUT "\n========================================================\n");
390
397
   print( OUT "CA TESTS:\n");
391
398
 
392
 
   system("openssl2 req -config $CAconf -out $CAreq -keyout $CAkey -new >$outFile");
 
399
   system("openssl2 req -config $CAconf -out $CAreq -keyout $CAkey -new (CLIB_OPT)/>$outFile");
393
400
   log_desc("Make a certificate request using req:");
394
401
   log_output("openssl2 req -config $CAconf -out $CAreq -keyout $CAkey -new", $outFile);
395
402
 
396
 
   system("openssl2 x509 -CAcreateserial -in $CAreq -days 30 -req -out $CAcert -signkey $CAkey >$outFile");
 
403
   system("openssl2 x509 -CAcreateserial -in $CAreq -days 30 -req -out $CAcert -signkey $CAkey (CLIB_OPT)/>$outFile");
397
404
   log_desc("Convert the certificate request into a self signed certificate using x509:");
398
405
   log_output("openssl2 x509 -CAcreateserial -in $CAreq -days 30 -req -out $CAcert -signkey $CAkey", $outFile);
399
406
 
400
 
   system("openssl2 x509 -in $CAcert -x509toreq -signkey $CAkey -out $CAreq2 >$outFile");
 
407
   system("openssl2 x509 -in $CAcert -x509toreq -signkey $CAkey -out $CAreq2 (CLIB_OPT)/>$outFile");
401
408
   log_desc("Convert a certificate into a certificate request using 'x509':");
402
409
   log_output("openssl2 x509 -in $CAcert -x509toreq -signkey $CAkey -out $CAreq2", $outFile);
403
410
 
404
 
   system("openssl2 req -config $OpenSSL_config -verify -in $CAreq -noout >$outFile");
 
411
   system("openssl2 req -config $OpenSSL_config -verify -in $CAreq -noout (CLIB_OPT)/>$outFile");
405
412
   log_output("openssl2 req -config $OpenSSL_config -verify -in $CAreq -noout", $outFile);
406
413
 
407
 
   system("openssl2 req -config $OpenSSL_config -verify -in $CAreq2 -noout >$outFile");
 
414
   system("openssl2 req -config $OpenSSL_config -verify -in $CAreq2 -noout (CLIB_OPT)/>$outFile");
408
415
   log_output( "openssl2 req -config $OpenSSL_config -verify -in $CAreq2 -noout", $outFile);
409
416
 
410
 
   system("openssl2 verify -CAfile $CAcert $CAcert >$outFile");
 
417
   system("openssl2 verify -CAfile $CAcert $CAcert (CLIB_OPT)/>$outFile");
411
418
   log_output("openssl2 verify -CAfile $CAcert $CAcert", $outFile);
412
419
 
413
 
   system("openssl2 req -config $Uconf -out $Ureq -keyout $Ukey -new >$outFile");
 
420
   system("openssl2 req -config $Uconf -out $Ureq -keyout $Ukey -new (CLIB_OPT)/>$outFile");
414
421
   log_desc("Make another certificate request using req:");
415
422
   log_output("openssl2 req -config $Uconf -out $Ureq -keyout $Ukey -new", $outFile);
416
423
 
417
 
   system("openssl2 x509 -CAcreateserial -in $Ureq -days 30 -req -out $Ucert -CA $CAcert -CAkey $CAkey -CAserial $CAserial >$outFile");
 
424
   system("openssl2 x509 -CAcreateserial -in $Ureq -days 30 -req -out $Ucert -CA $CAcert -CAkey $CAkey -CAserial $CAserial (CLIB_OPT)/>$outFile");
418
425
   log_desc("Sign certificate request with the just created CA via x509:");
419
426
   log_output("openssl2 x509 -CAcreateserial -in $Ureq -days 30 -req -out $Ucert -CA $CAcert -CAkey $CAkey -CAserial $CAserial", $outFile);
420
427
 
421
 
   system("openssl2 verify -CAfile $CAcert $Ucert >$outFile");
 
428
   system("openssl2 verify -CAfile $CAcert $Ucert (CLIB_OPT)/>$outFile");
422
429
   log_output("openssl2 verify -CAfile $CAcert $Ucert", $outFile);
423
430
 
424
 
   system("openssl2 x509 -subject -issuer -startdate -enddate -noout -in $Ucert >$outFile");
 
431
   system("openssl2 x509 -subject -issuer -startdate -enddate -noout -in $Ucert (CLIB_OPT)/>$outFile");
425
432
   log_desc("Certificate details");
426
433
   log_output("openssl2 x509 -subject -issuer -startdate -enddate -noout -in $Ucert", $outFile);
427
434
 
428
 
   print(OUT "-- \n");
 
435
   print(OUT "--\n");
429
436
   print(OUT "The generated CA certificate is $CAcert\n");
430
437
   print(OUT "The generated CA private key is $CAkey\n");
431
438
   print(OUT "The current CA signing serial number is in $CAserial\n");
436
443
}
437
444
 
438
445
############################################################################
 
446
sub evp_tests
 
447
{
 
448
   my $i = 'evp_test';
 
449
 
 
450
   print( "\nRUNNING EVP TESTS:\n\n");
 
451
 
 
452
   print( OUT "\n========================================================\n");
 
453
   print( OUT "EVP TESTS:\n\n");
 
454
 
 
455
   if (-e "$base_path\\$i.nlm")
 
456
   {
 
457
       my $outFile = "$output_path\\$i.out";
 
458
       system("$i $test_path\\evptests.txt (CLIB_OPT)/>$outFile");
 
459
       log_desc("Test: $i\.nlm:");
 
460
       log_output("", $outFile );
 
461
   }
 
462
   else
 
463
   {
 
464
       log_desc("Test: $i\.nlm: file not found");
 
465
   }
 
466
}
 
467
 
 
468
############################################################################
439
469
sub log_output( $ $ )
440
470
{
441
471
   my( $desc, $file ) = @_;
445
475
 
446
476
   if ($desc)
447
477
   {
448
 
      print("$desc\n");
 
478
      print("\r$desc\n");
449
479
      print(OUT "$desc\n");
450
480
   }
451
481
 
457
487
      # copy test output to log file
458
488
   open(IN, "<$file");
459
489
   while (<IN>)
460
 
   { 
461
 
      print(OUT $_); 
 
490
   {
 
491
      print(OUT $_);
462
492
      if ( $_ =~ /ERROR/ )
463
493
      {
464
494
         $error = 1;
485
515
      $key = getc;
486
516
      print("\n");
487
517
   }
488
 
      
489
 
      # Several of the testing scripts run a loop loading the 
 
518
 
 
519
      # Several of the testing scripts run a loop loading the
490
520
      # same NLM with different options.
491
 
      # On slow NetWare machines there appears to be some delay in the 
 
521
      # On slow NetWare machines there appears to be some delay in the
492
522
      # OS actually unloading the test nlms and the OS complains about.
493
 
      # the NLM already being loaded.  This additional pause is to 
494
 
      # to help provide a little more time for unloading before trying to 
 
523
      # the NLM already being loaded.  This additional pause is to
 
524
      # to help provide a little more time for unloading before trying to
495
525
      # load again.
496
526
   sleep(1);
497
527
}
562
592
############################################################################
563
593
sub make_tmp_cert_file()
564
594
{
565
 
   my @cert_files = <$cert_path\\*.pem>;
 
595
   my @cert_files = <$cert_path/*.pem>;
566
596
 
567
597
      # delete the file if it already exists
568
598
   unlink($tmp_cert);
570
600
   open( TMP_CERT, ">$tmp_cert") || die "\nunable to open $tmp_cert\n";
571
601
 
572
602
   print("building temporary cert file\n");
573
 
   
 
603
 
574
604
   # create a temporary cert file that contains all the certs
575
605
   foreach $i (@cert_files)
576
606
   {