5b410ee854ff29987a574d98b3fb8f3625815fdb
[openssl.git] / test / recipes / 80-test_ssl.t
1 #! /usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use POSIX;
7 use File::Spec;
8 use File::Copy;
9 use OpenSSL::Test qw/:DEFAULT with top_file cmdstr/;
10
11 setup("test_ssl");
12
13 my $digest = "-sha1";
14 my @reqcmd = ("openssl", "req");
15 my @x509cmd = ("openssl", "x509", $digest);
16 my @verifycmd = ("openssl", "verify");
17 my $dummycnf = top_file("apps", "openssl.cnf");
18
19 my $CAkey = "keyCA.ss";
20 my $CAcert="certCA.ss";
21 my $CAserial="certCA.srl";
22 my $CAreq="reqCA.ss";
23 my $CAconf=top_file("test","CAss.cnf");
24 my $CAreq2="req2CA.ss"; # temp
25
26 my $Uconf=top_file("test","Uss.cnf");
27 my $Ukey="keyU.ss";
28 my $Ureq="reqU.ss";
29 my $Ucert="certU.ss";
30
31 my $Dkey="keyD.ss";
32 my $Dreq="reqD.ss";
33 my $Dcert="certD.ss";
34
35 my $Ekey="keyE.ss";
36 my $Ereq="reqE.ss";
37 my $Ecert="certE.ss";
38
39 my $P1conf=top_file("test","P1ss.cnf");
40 my $P1key="keyP1.ss";
41 my $P1req="reqP1.ss";
42 my $P1cert="certP1.ss";
43 my $P1intermediate="tmp_intP1.ss";
44
45 my $P2conf=top_file("test","P2ss.cnf");
46 my $P2key="keyP2.ss";
47 my $P2req="reqP2.ss";
48 my $P2cert="certP2.ss";
49 my $P2intermediate="tmp_intP2.ss";
50
51 plan tests =>
52     1                           # For testss
53     + 1                         # For ssltest -test_cipherlist
54     + 8                         # For the first testssl
55     + 8 * 4 * 4                 # For the first testsslproxy (16 times testssl)
56     + 8 * 4 * 4                 # For the second testsslproxy (16 times testssl)
57     ;
58
59 subtest 'test_ss' => sub {
60     if (testss()) {
61         open OUT, ">", "intP1.ss";
62         copy($CAcert, \*OUT); copy($Ucert, \*OUT);
63         close OUT;
64
65         open OUT, ">", "intP2.ss";
66         copy($CAcert, \*OUT); copy($Ucert, \*OUT); copy($P1cert, \*OUT);
67         close OUT;
68     }
69 };
70
71 my $check = ok(run(test(["ssltest","-test_cipherlist"])), "running ssltest");
72
73   SKIP: {
74       skip "ssltest ended with error, skipping the rest", 3
75           if !$check;
76
77       note('test_ssl -- key U');
78       testssl("keyU.ss", $Ucert, $CAcert);
79
80       note('test_ssl -- key P1');
81       testsslproxy("keyP1.ss", "certP1.ss", "intP1.ss");
82
83       note('test_ssl -- key P2');
84       testsslproxy("keyP2.ss", "certP2.ss", "intP2.ss");
85     }
86
87 # -----------
88 # subtest functions
89 sub testss {
90     open RND, ">>", ".rnd";
91     print RND "string to make the random number generator think it has entropy";
92     close RND;
93
94     my @req_dsa = ("-newkey",
95                    "dsa:".File::Spec->catfile("..", "apps", "dsa1024.pem"));;
96     my @req_new;
97     if (run(app(["openssl", "no-rsa"], stdout => undef))) {
98         @req_new = @req_dsa;
99     } else {
100         @req_new = ("-new");
101     }
102
103     plan tests => 17;
104
105   SKIP: {
106       skip 'failure', 16 unless
107           ok(run(app([@reqcmd, "-config", $CAconf,
108                       "-out", $CAreq, "-keyout", $CAkey,
109                       @req_new])),
110              'make cert request');
111
112       skip 'failure', 15 unless
113           ok(run(app([@x509cmd, "-CAcreateserial", "-in", $CAreq, "-days", "30",
114                       "-req", "-out", $CAcert, "-signkey", $CAkey,
115                       "-extfile", $CAconf, "-extensions", "v3_ca"],
116                      stdout => "err.ss")),
117              'convert request into self-signed cert');
118
119       skip 'failure', 14 unless
120           ok(run(app([@x509cmd, "-in", $CAcert,
121                       "-x509toreq", "-signkey", $CAkey, "-out", $CAreq2],
122                      stdout => "err.ss")),
123              'convert cert into a cert request');
124
125       skip 'failure', 13 unless
126           ok(run(app([@reqcmd, "-config", $dummycnf,
127                       "-verify", "-in", $CAreq, "-noout"])),
128              'verify request 1');
129
130
131       skip 'failure', 12 unless
132           ok(run(app([@reqcmd, "-config", $dummycnf,
133                       "-verify", "-in", $CAreq2, "-noout"])),
134              'verify request 2');
135
136       skip 'failure', 11 unless
137           ok(run(app([@verifycmd, "-CAfile", $CAcert, $CAcert])),
138              'verify signature');
139
140       skip 'failure', 10 unless
141           ok(run(app([@reqcmd, "-config", $Uconf,
142                       "-out", $Ureq, "-keyout", $Ukey, @req_new],
143                      stdout => "err.ss")),
144              'make a user cert request');
145
146       skip 'failure', 9 unless
147           ok(run(app([@x509cmd, "-CAcreateserial", "-in", $Ureq, "-days", "30",
148                       "-req", "-out", $Ucert,
149                       "-CA", $CAcert, "-CAkey", $CAkey, "-CAserial", $CAserial,
150                       "-extfile", $Uconf, "-extensions", "v3_ee"],
151                      stdout => "err.ss"))
152              && run(app([@verifycmd, "-CAfile", $CAcert, $Ucert])),
153              'sign user cert request');
154
155       skip 'failure', 8 unless
156           ok(run(app([@x509cmd,
157                       "-subject", "-issuer", "-startdate", "-enddate",
158                       "-noout", "-in", $Ucert])),
159              'Certificate details');
160
161       skip 'failure', 7 unless
162           subtest 'DSA certificate creation' => sub {
163               plan skip_all => "skipping DSA certificate creation"
164                   if run(app(["openssl", "no-dsa"], stdout => undef));
165
166               plan tests => 4;
167
168             SKIP: {
169                 $ENV{CN2} = "DSA Certificate";
170                 skip 'failure', 3 unless
171                     ok(run(app([@reqcmd, "-config", $Uconf,
172                                 "-out", $Dreq, "-keyout", $Dkey,
173                                 @req_dsa],
174                                stdout => "err.ss")),
175                        "make a DSA user cert request");
176                 skip 'failure', 2 unless
177                     ok(run(app([@x509cmd, "-CAcreateserial",
178                                 "-in", $Dreq,
179                                 "-days", "30",
180                                 "-req",
181                                 "-out", $Dcert,
182                                 "-CA", $CAcert, "-CAkey", $CAkey,
183                                 "-CAserial", $CAserial,
184                                 "-extfile", $Uconf,
185                                 "-extensions", "v3_ee_dsa"],
186                                stdout => "err.ss")),
187                        "sign DSA user cert request");
188                 skip 'failure', 1 unless
189                     ok(run(app([@verifycmd, "-CAfile", $CAcert, $Dcert])),
190                        "verify DSA user cert");
191                 skip 'failure', 0 unless
192                     ok(run(app([@x509cmd,
193                                 "-subject", "-issuer",
194                                 "-startdate", "-enddate", "-noout",
195                                 "-in", $Dcert])),
196                        "DSA Certificate details");
197               }
198       };
199
200       skip 'failure', 6 unless
201           subtest 'ECDSA/ECDH certificate creation' => sub {
202               plan skip_all => "skipping ECDSA/ECDH certificate creation"
203                   if run(app(["openssl", "no-ec"], stdout => undef));
204
205               plan tests => 5;
206
207             SKIP: {
208                 $ENV{CN2} = "ECDSA Certificate";
209                 skip 'failure', 4 unless
210                     ok(run(app(["openssl", "ecparam", "-name", "P-256",
211                                 "-out", "ecp.ss"])),
212                        "make EC parameters");
213                 skip 'failure', 3 unless
214                     ok(run(app([@reqcmd, "-config", $Uconf,
215                                 "-out", $Ereq, "-keyout", $Ekey,
216                                 "-newkey", "ec:ecp.ss"],
217                                stdout => "err.ss")),
218                        "make a ECDSA/ECDH user cert request");
219                 skip 'failure', 2 unless
220                     ok(run(app([@x509cmd, "-CAcreateserial",
221                                 "-in", $Ereq,
222                                 "-days", "30",
223                                 "-req",
224                                 "-out", $Ecert,
225                                 "-CA", $CAcert, "-CAkey", $CAkey,
226                                 "-CAserial", $CAserial,
227                                 "-extfile", $Uconf,
228                                 "-extensions", "v3_ee_ec"],
229                                stdout => "err.ss")),
230                        "sign ECDSA/ECDH user cert request");
231                 skip 'failure', 1 unless
232                     ok(run(app([@verifycmd, "-CAfile", $CAcert, $Ecert])),
233                        "verify ECDSA/ECDH user cert");
234                 skip 'failure', 0 unless
235                     ok(run(app([@x509cmd,
236                                 "-subject", "-issuer",
237                                 "-startdate", "-enddate", "-noout",
238                                 "-in", $Ecert])),
239                        "ECDSA Certificate details");
240               }
241       };
242
243       skip 'failure', 5 unless
244           ok(run(app([@reqcmd, "-config", $P1conf,
245                       "-out", $P1req, "-keyout", $P1key, @req_new],
246                      stdout => "err.ss")),
247              'make a proxy cert request');
248
249
250       skip 'failure', 4 unless
251           ok(run(app([@x509cmd, "-CAcreateserial", "-in", $P1req, "-days", "30",
252                       "-req", "-out", $P1cert,
253                       "-CA", $Ucert, "-CAkey", $Ukey,
254                       "-extfile", $P1conf, "-extensions", "v3_proxy"],
255                      stdout => "err.ss")),
256              'sign proxy with user cert');
257
258       copy($Ucert, $P1intermediate);
259       run(app([@verifycmd, "-CAfile", $CAcert,
260                "-untrusted", $P1intermediate, $P1cert]));
261       ok(run(app([@x509cmd,
262                   "-subject", "-issuer", "-startdate", "-enddate",
263                   "-noout", "-in", $P1cert])),
264          'Certificate details');
265
266       skip 'failure', 2 unless
267           ok(run(app([@reqcmd, "-config", $P2conf,
268                       "-out", $P2req, "-keyout", $P2key,
269                       @req_new],
270                      stdout => "err.ss")),
271              'make another proxy cert request');
272
273
274       skip 'failure', 1 unless
275           ok(run(app([@x509cmd, "-CAcreateserial", "-in", $P2req, "-days", "30",
276                       "-req", "-out", $P2cert,
277                       "-CA", $P1cert, "-CAkey", $P1key,
278                       "-extfile", $P2conf, "-extensions", "v3_proxy"],
279                      stdout => "err.ss")),
280              'sign second proxy cert request with the first proxy cert');
281
282
283       open OUT, ">", $P2intermediate;
284       copy($Ucert, \*OUT); copy($P1cert, \*OUT);
285       close OUT;
286       run(app([@verifycmd, "-CAfile", $CAcert,
287                "-untrusted", $P2intermediate, $P2cert]));
288       ok(run(app([@x509cmd,
289                   "-subject", "-issuer", "-startdate", "-enddate",
290                   "-noout", "-in", $P2cert])),
291          'Certificate details');
292     }
293 }
294
295 sub testssl {
296     my $key = shift || top_file("apps","server.pem");
297     my $cert = shift || top_file("apps","server.pem");
298     my $CAtmp = shift;
299     my @CA = $CAtmp ? ("-CAfile", $CAtmp) : ("-CApath", top_dir("certs"));
300     my @extra = @_;
301
302     my @ssltest = ("ssltest",
303                    "-s_key", $key, "-s_cert", $cert,
304                    "-c_key", $key, "-c_cert", $cert);
305
306     my $serverinfo = top_file("test","serverinfo.pem");
307
308     my $dsa_cert = 0;
309     if (grep /DSA Public Key/, run(app(["openssl", "x509", "-in", $cert,
310                                         "-text", "-noout"]), capture => 1)) {
311         $dsa_cert = 1;
312     }
313
314
315     # plan tests => 7;
316
317     subtest 'standard SSL tests' => sub {
318         ######################################################################
319         plan tests => 27;
320
321         ok(run(test([@ssltest, "-ssl3", @extra])),
322            'test sslv3');
323         ok(run(test([@ssltest, "-ssl3", "-server_auth", @CA, @extra])),
324            'test sslv3 with server authentication');
325         ok(run(test([@ssltest, "-ssl3", "-client_auth", @CA, @extra])),
326            'test sslv3 with client authentication');
327         ok(run(test([@ssltest, "-ssl3", "-server_auth", "-client_auth", @CA, @extra])),
328            'test sslv3 with both server and client authentication');
329         ok(run(test([@ssltest, @extra])),
330            'test sslv2/sslv3');
331         ok(run(test([@ssltest, "-server_auth", @CA, @extra])),
332            'test sslv2/sslv3 with server authentication');
333         ok(run(test([@ssltest, "-client_auth", @CA, @extra])),
334            'test sslv2/sslv3 with client authentication');
335         ok(run(test([@ssltest, "-server_auth", "-client_auth", @CA, @extra])),
336            'test sslv2/sslv3 with both server and client authentication');
337         ok(run(test([@ssltest, "-bio_pair", "-ssl3", @extra])),
338            'test sslv3 via BIO pair');
339         ok(run(test([@ssltest, "-bio_pair", "-ssl3", "-server_auth", @CA, @extra])),
340            'test sslv3 with server authentication via BIO pair');
341         ok(run(test([@ssltest, "-bio_pair", "-ssl3", "-client_auth", @CA, @extra])),
342            'test sslv3 with client authentication via BIO pair');
343         ok(run(test([@ssltest, "-bio_pair", "-ssl3", "-server_auth", "-client_auth", @CA, @extra])),
344            'test sslv3 with both server and client authentication via BIO pair');
345         ok(run(test([@ssltest, "-bio_pair", @extra])),
346            'test sslv2/sslv3 via BIO pair');
347         ok(run(test([@ssltest, "-dtls1", @extra])),
348            'test dtlsv1');
349         ok(run(test([@ssltest, "-dtls1", "-server_auth", @CA, @extra])),
350            'test dtlsv1 with server authentication');
351         ok(run(test([@ssltest, "-dtls1", "-client_auth", @CA, @extra])),
352            'test dtlsv1 with client authentication');
353         ok(run(test([@ssltest, "-dtls1", "-server_auth", "-client_auth", @CA, @extra])),
354            'test dtlsv1 with both server and client authentication');
355         ok(run(test([@ssltest, "-dtls12", @extra])),
356            'test dtlsv1.2');
357         ok(run(test([@ssltest, "-dtls12", "-server_auth", @CA, @extra])),
358            'test dtlsv1.2 with server authentication');
359         ok(run(test([@ssltest, "-dtls12", "-client_auth", @CA, @extra])),
360            'test dtlsv1.2 with client authentication');
361         ok(run(test([@ssltest, "-dtls12", "-server_auth", "-client_auth", @CA, @extra])),
362            'test dtlsv1.2 with both server and client authentication');
363         {
364           SKIP: {
365               skip "skipping test of sslv2/sslv3 w/o (EC)DHE test", 1 if $dsa_cert;
366
367               ok(run(test([@ssltest, "-bio_pair", "-no_dhe", "-no_ecdhe", @extra])),
368                  'test sslv2/sslv3 w/o (EC)DHE via BIO pair');
369             }
370         }
371         ok(run(test([@ssltest, "-bio_pair", "-dhe1024dsa", "-v", @extra])),
372            'test sslv2/sslv3 with 1024bit DHE via BIO pair');
373         ok(run(test([@ssltest, "-bio_pair", "-server_auth", @CA, @extra])),
374            'test sslv2/sslv3 with server authentication');
375         ok(run(test([@ssltest, "-bio_pair", "-client_auth", @CA, @extra])),
376            'test sslv2/sslv3 with client authentication via BIO pair');
377         ok(run(test([@ssltest, "-bio_pair", "-server_auth", "-client_auth", @CA, @extra])),
378            'test sslv2/sslv3 with both client and server authentication via BIO pair');
379         ok(run(test([@ssltest, "-bio_pair", "-server_auth", "-client_auth", "-app_verify", @CA, @extra])),
380            'test sslv2/sslv3 with both client and server authentication via BIO pair and app verify');
381     };
382
383     subtest "Testing ciphersuites" => sub {
384
385         my @exkeys = ();
386         my $ciphers = "-EXP:-PSK:-SRP:-kDH:-kECDHe";
387
388         if (run(app(["openssl", "no-dhparam"], stdout => undef))) {
389             note "skipping DHE tests\n";
390             $ciphers .= ":-kDHE";
391         }
392         if (run(app(["openssl", "no-dsa"], stdout => undef))) {
393             note "skipping DSA tests\n";
394             $ciphers .= ":-aDSA";
395         } else {
396             push @exkeys, "-s_cert", "certD.ss", "-s_key", "keyD.ss";
397         }
398
399         if (run(app(["openssl", "no-ec"], stdout => undef))) {
400             note "skipping EC tests\n";
401             $ciphers .= ":!aECDSA:!kECDH";
402         } else {
403             push @exkeys, "-s_cert", "certE.ss", "-s_key", "keyE.ss";
404         }
405
406         my @protocols = ("TLSv1.2", "SSLv3");
407         my $protocolciphersuitcount = 0;
408         my %ciphersuites =
409             map { my @c =
410                       map { split(/:/, $_) }
411                       run(app(["openssl", "ciphers", "${_}:$ciphers"]),
412                           capture => 1);
413                   chomp @c;
414                   $protocolciphersuitcount += scalar @c;
415                   $_ => [ @c ] } @protocols;
416
417         # The count of protocols is because in addition to the ciphersuits
418         # we got above, we're running a weak DH test for each protocol
419         plan tests => $protocolciphersuitcount + scalar(@protocols);
420
421         foreach my $protocol (@protocols) {
422             note "Testing ciphersuites for $protocol";
423             foreach my $cipher (@{$ciphersuites{$protocol}}) {
424                 ok(run(test([@ssltest, @exkeys, "-cipher", $cipher,
425                              $protocol eq "SSLv3" ? ("-ssl3") : ()])),
426                    "Testing $cipher");
427             }
428             is(run(test([@ssltest,
429                          "-s_cipher", "EDH",
430                          "-c_cipher", 'EDH:@SECLEVEL=1',
431                          "-dhe512",
432                          $protocol eq "SSLv3" ? ("-ssl3") : ()])), 0,
433                "testing connection with weak DH, expecting failure");
434         }
435     };
436
437     subtest 'RSA/(EC)DHE/PSK tests' => sub {
438         ######################################################################
439
440         plan tests => 5;
441
442         {
443           SKIP: {
444               skip "skipping anonymous DH tests", 1
445                   if (run(app(["openssl", "no-dhparam"], stdout => undef)));
446
447               ok(run(test([@ssltest, "-v", "-bio_pair", "-tls1", "-cipher", "ADH", "-dhe1024dsa", "-num", "10", "-f", "-time", @extra])),
448                  'test tlsv1 with 1024bit anonymous DH, multiple handshakes');
449             }
450         }
451
452         {
453           SKIP: {
454               skip "skipping RSA tests", 2
455                   if (run(app(["openssl", "no-rsa"], stdout => undef)));
456
457               ok(run(test(["ssltest", "-v", "-bio_pair", "-tls1", "-s_cert", top_file("apps","server2.pem"), "-no_dhe", "-no_ecdhe", "-num", "10", "-f", "-time", @extra])),
458                  'test tlsv1 with 1024bit RSA, no (EC)DHE, multiple handshakes');
459
460               skip "skipping RSA+DHE tests", 1
461                   if (run(app(["openssl", "no-dhparam"], stdout => undef)));
462
463               ok(run(test(["ssltest", "-v", "-bio_pair", "-tls1", "-s_cert", top_file("apps","server2.pem"), "-dhe1024dsa", "-num", "10", "-f", "-time", @extra])),
464                  'test tlsv1 with 1024bit RSA, 1024bit DHE, multiple handshakes');
465             }
466         }
467         ok(run(test([@ssltest, "-tls1", "-cipher", "PSK", "-psk", "abc123", @extra])),
468            'test tls1 with PSK');
469
470         ok(run(test([@ssltest, "-bio_pair", "-tls1", "-cipher", "PSK", "-psk", "abc123", @extra])),
471            'test tls1 with PSK via BIO pair');
472     };
473
474     subtest 'Next Protocol Negotiation Tests' => sub {
475         ######################################################################
476
477         plan tests => 7;
478
479         ok(run(test([@ssltest, "-bio_pair", "-tls1", "-npn_client"])));
480         ok(run(test([@ssltest, "-bio_pair", "-tls1", "-npn_server"])));
481         ok(run(test([@ssltest, "-bio_pair", "-tls1", "-npn_server_reject"])));
482         ok(run(test([@ssltest, "-bio_pair", "-tls1", "-npn_client", "-npn_server_reject"])));
483         ok(run(test([@ssltest, "-bio_pair", "-tls1", "-npn_client", "-npn_server"])));
484         ok(run(test([@ssltest, "-bio_pair", "-tls1", "-npn_client", "-npn_server", "-num", "2"])));
485         ok(run(test([@ssltest, "-bio_pair", "-tls1", "-npn_client", "-npn_server", "-num", "2", "-reuse"])));
486     };
487
488     subtest 'Custom Extension tests' => sub {
489         ######################################################################
490
491         plan tests => 1;
492
493         ok(run(test([@ssltest, "-bio_pair", "-tls1", "-custom_ext"])),
494            'test tls1 with custom extensions');
495     };
496
497     subtest 'Serverinfo tests' => sub {
498         ######################################################################
499
500         plan tests => 5;
501
502         note('echo test tls1 with serverinfo');
503         ok(run(test([@ssltest, "-bio_pair", "-tls1", "-serverinfo_file", $serverinfo])));
504         ok(run(test([@ssltest, "-bio_pair", "-tls1", "-serverinfo_file", $serverinfo, "-serverinfo_sct"])));
505         ok(run(test([@ssltest, "-bio_pair", "-tls1", "-serverinfo_file", $serverinfo, "-serverinfo_tack"])));
506         ok(run(test([@ssltest, "-bio_pair", "-tls1", "-serverinfo_file", $serverinfo, "-serverinfo_sct", "-serverinfo_tack"])));
507         ok(run(test([@ssltest, "-bio_pair", "-tls1", "-custom_ext", "-serverinfo_file", $serverinfo, "-serverinfo_sct", "-serverinfo_tack"])));
508     };
509
510     subtest 'ALPN tests' => sub {
511         ######################################################################
512
513         plan tests => 12;
514
515         ok(run(test([@ssltest, "-bio_pair", "-tls1", "-alpn_client", "foo", "-alpn_server", "bar"])));
516         ok(run(test([@ssltest, "-bio_pair", "-tls1", "-alpn_client", "foo", "-alpn_server", "foo", "-alpn_expected", "foo"])));
517         ok(run(test([@ssltest, "-bio_pair", "-tls1", "-alpn_client", "foo,bar", "-alpn_server", "foo", "-alpn_expected", "foo"])));
518         ok(run(test([@ssltest, "-bio_pair", "-tls1", "-alpn_client", "bar,foo", "-alpn_server", "foo", "-alpn_expected", "foo"])));
519         ok(run(test([@ssltest, "-bio_pair", "-tls1", "-alpn_client", "bar,foo", "-alpn_server", "foo,bar", "-alpn_expected", "foo"])));
520         ok(run(test([@ssltest, "-bio_pair", "-tls1", "-alpn_client", "bar,foo", "-alpn_server", "bar,foo", "-alpn_expected", "bar"])));
521         ok(run(test([@ssltest, "-bio_pair", "-tls1", "-alpn_client", "foo,bar", "-alpn_server", "bar,foo", "-alpn_expected", "bar"])));
522         ok(run(test([@ssltest, "-bio_pair", "-tls1", "-alpn_client", "baz", "-alpn_server", "bar,foo"])));
523
524         {
525           SKIP: {
526               skip "skipping SRP tests", 4
527                   if run(app(["openssl", "no-srp"], stdout => undef));
528
529               ok(run(test([@ssltest, "-tls1", "-cipher", "SRP", "-srpuser", "test", "-srppass", "abc123"])),
530                  'test tls1 with SRP');
531
532               ok(run(test([@ssltest, "-bio_pair", "-tls1", "-cipher", "SRP", "-srpuser", "test", "-srppass", "abc123"])),
533                  'test tls1 with SRP via BIO pair');
534
535               ok(run(test([@ssltest, "-tls1", "-cipher", "aSRP", "-srpuser", "test", "-srppass", "abc123"])),
536                  'test tls1 with SRP auth');
537
538               ok(run(test([@ssltest, "-bio_pair", "-tls1", "-cipher", "aSRP", "-srpuser", "test", "-srppass", "abc123"])),
539                  'test tls1 with SRP auth via BIO pair');
540             }
541         }
542     };
543
544     subtest 'Multi-buffer tests' => sub {
545         ######################################################################
546
547         plan tests => 2;
548
549         {
550           SKIP: {
551               skip "skipping multi-buffer tests", 2
552                   if @extra || (POSIX::uname())[4] ne "x86_64";
553               ok(run(test([@ssltest, "-cipher", "AES128-SHA",    "-bytes", "8m"])));
554               ok(run(test([@ssltest, "-cipher", "AES128-SHA256", "-bytes", "8m"])));
555             }
556         }
557     };
558 }
559
560 sub testsslproxy {
561     my ($a1, $a2, $a3, @rest) = @_;
562
563     # plan tests => 16;
564
565     note('Testing a lot of proxy conditions.');
566     note('Some of them may turn out being invalid, which is fine.');
567     foreach my $auth (('A', 'B', 'C', 'BC')) {
568         foreach my $cond (('A', 'B', 'C', 'A|B&!C')) {
569             # Exit code 3 is when ssltest couldn't parse the condition
570             with({ exit_checker => sub { my $x = shift;
571                                          return
572                                              ($x == 1 || $x == 3) ? 0 : 1; } },
573                  sub {
574                      testssl($a1, $a2, $a3,
575                              "-proxy", "-proxy_auth", $auth,
576                              "-proxy_cond", $cond);
577                  });
578         }
579     }
580 }