xref: /freebsd/crypto/openssl/test/ssl-tests/20-cert-select.cnf.in (revision 4b15965daa99044daf184221b7c283bf7f2d7e66)
1# -*- mode: perl; -*-
2
3## SSL test configurations
4
5
6use strict;
7use warnings;
8
9package ssltests;
10use OpenSSL::Test::Utils;
11
12our $fips_mode;
13our $fips_3_4;
14our $fips_3_5;
15our $no_deflt_libctx;
16
17srand(20);
18sub randcase {
19    my ($names) = @_;
20    my @ret;
21    foreach my $name (split(/:/, $names)) {
22        my ($alg, $rest) = split(/(?=[+])/, $name, 2);
23        $alg =~ s{([a-zA-Z])}{chr(ord($1)^(int(rand(2.0)) * 32))}eg;
24        push @ret, $alg . ($rest // "");
25    }
26    return join(":", @ret);
27}
28
29my $server = {
30    "ECDSA.Certificate" => test_pem("server-ecdsa-cert.pem"),
31    "ECDSA.PrivateKey" => test_pem("server-ecdsa-key.pem"),
32    "Ed25519.Certificate" => test_pem("server-ed25519-cert.pem"),
33    "Ed25519.PrivateKey" => test_pem("server-ed25519-key.pem"),
34    "Ed448.Certificate" => test_pem("server-ed448-cert.pem"),
35    "Ed448.PrivateKey" => test_pem("server-ed448-key.pem"),
36    "MaxProtocol" => "TLSv1.2"
37};
38
39my $server_pss = {
40    "PSS.Certificate" => test_pem("server-pss-cert.pem"),
41    "PSS.PrivateKey" => test_pem("server-pss-key.pem"),
42    "ECDSA.Certificate" => test_pem("server-ecdsa-cert.pem"),
43    "ECDSA.PrivateKey" => test_pem("server-ecdsa-key.pem"),
44    "Ed25519.Certificate" => test_pem("server-ed25519-cert.pem"),
45    "Ed25519.PrivateKey" => test_pem("server-ed25519-key.pem"),
46    "Ed448.Certificate" => test_pem("server-ed448-cert.pem"),
47    "Ed448.PrivateKey" => test_pem("server-ed448-key.pem"),
48    "MaxProtocol" => "TLSv1.2"
49};
50
51my $server_pss_only = {
52    "Certificate" => test_pem("server-pss-cert.pem"),
53    "PrivateKey" => test_pem("server-pss-key.pem"),
54};
55
56my $server_pss_restrict_only = {
57    "Certificate" => test_pem("server-pss-restrict-cert.pem"),
58    "PrivateKey" => test_pem("server-pss-restrict-key.pem"),
59};
60
61my $server_rsa_all;
62
63if ($no_deflt_libctx) {
64    $server_rsa_all = {
65        "Certificate" => test_pem("servercert.pem"),
66        "PrivateKey" => test_pem("serverkey.pem"),
67    };
68} else {
69    $server_rsa_all = {
70        "PSS.Certificate" => test_pem("server-pss-cert.pem"),
71        "PSS.PrivateKey" => test_pem("server-pss-key.pem"),
72        "Certificate" => test_pem("servercert.pem"),
73        "PrivateKey" => test_pem("serverkey.pem"),
74    };
75}
76
77our @tests = (
78    {
79        name => "ECDSA CipherString Selection",
80        server => $server,
81        client => {
82            "CipherString" => "aECDSA",
83            "MaxProtocol" => "TLSv1.2",
84            "RequestCAFile" => test_pem("root-cert.pem"),
85        },
86        test   => {
87            "ExpectedServerCertType" =>, "P-256",
88            "ExpectedServerSignType" =>, "EC",
89            # Note: certificate_authorities not sent for TLS < 1.3
90            "ExpectedServerCANames" =>, "empty",
91            "ExpectedResult" => "Success"
92        },
93    },
94    {
95        name => "ECDSA CipherString Selection",
96        server => {
97            "ECDSA.Certificate" => test_pem("server-ecdsa-cert.pem"),
98            "ECDSA.PrivateKey" => test_pem("server-ecdsa-key.pem"),
99            "MaxProtocol" => "TLSv1.2",
100            #Deliberately set supported_groups to one not in the cert. This
101            #should be tolerated
102            "Groups" => "P-384"
103        },
104        client => {
105            "CipherString" => "aECDSA",
106            "MaxProtocol" => "TLSv1.2",
107            "Groups" => "P-256:P-384",
108            "RequestCAFile" => test_pem("root-cert.pem"),
109        },
110        test   => {
111            "ExpectedServerCertType" =>, "P-256",
112            "ExpectedServerSignType" =>, "EC",
113            # Note: certificate_authorities not sent for TLS < 1.3
114            "ExpectedServerCANames" =>, "empty",
115            "ExpectedResult" => "Success"
116        },
117    },
118    {
119        name => "ECDSA CipherString Selection",
120        server => {
121            "ECDSA.Certificate" => test_pem("server-ecdsa-cert.pem"),
122            "ECDSA.PrivateKey" => test_pem("server-ecdsa-key.pem"),
123            "MaxProtocol" => "TLSv1.2",
124            "Groups" => "P-256:P-384"
125        },
126        client => {
127            "CipherString" => "aECDSA",
128            "MaxProtocol" => "TLSv1.2",
129            #Deliberately set groups to not include the certificate group. This
130            #should fail
131            "Groups" => "P-384",
132            "RequestCAFile" => test_pem("root-cert.pem"),
133        },
134        test   => {
135            "ExpectedResult" => "ServerFail"
136        },
137    },
138    {
139        name => "RSA CipherString Selection",
140        server => $server,
141        client => {
142            "CipherString" => "aRSA",
143            "MaxProtocol" => "TLSv1.2",
144        },
145        test   => {
146            "ExpectedServerCertType" =>, "RSA",
147            "ExpectedServerSignType" =>, "RSA-PSS",
148            "ExpectedResult" => "Success"
149        },
150    },
151    {
152        name => "P-256 CipherString and Signature Algorithm Selection",
153        server => $server,
154        client => {
155            "CipherString" => "aECDSA",
156            "MaxProtocol" => "TLSv1.2",
157            "SignatureAlgorithms" => randcase("ECDSA+SHA256:ed25519"),
158        },
159        test   => {
160            "ExpectedServerCertType" => "P-256",
161            "ExpectedServerSignHash" => "SHA256",
162            "ExpectedServerSignType" => "EC",
163            "ExpectedResult" => "Success"
164        },
165    },
166    {
167        name => "ECDSA CipherString Selection, no ECDSA certificate",
168        server => {
169            "MaxProtocol" => "TLSv1.2"
170        },
171        client => {
172            "CipherString" => "aECDSA",
173            "MaxProtocol" => "TLSv1.2"
174        },
175        test   => {
176            "ExpectedResult" => "ServerFail"
177        },
178    },
179    {
180        name => "ECDSA Signature Algorithm Selection",
181        server => $server,
182        client => {
183            "SignatureAlgorithms" => randcase("ECDSA+SHA256"),
184        },
185        test   => {
186            "ExpectedServerCertType" => "P-256",
187            "ExpectedServerSignHash" => "SHA256",
188            "ExpectedServerSignType" => "EC",
189            "ExpectedResult" => "Success"
190        },
191    },
192    {
193        name => "ECDSA Signature Algorithm Selection SHA384",
194        server => $server,
195        client => {
196            "SignatureAlgorithms" => randcase("ECDSA+SHA384"),
197        },
198        test   => {
199            "ExpectedServerCertType" => "P-256",
200            "ExpectedServerSignHash" => "SHA384",
201            "ExpectedServerSignType" => "EC",
202            "ExpectedResult" => "Success"
203        },
204    },
205    {
206        name => "ECDSA Signature Algorithm Selection compressed point",
207        server => {
208            "ECDSA.Certificate" => test_pem("server-cecdsa-cert.pem"),
209            "ECDSA.PrivateKey" => test_pem("server-cecdsa-key.pem"),
210            "MaxProtocol" => "TLSv1.2"
211        },
212        client => {
213            "SignatureAlgorithms" => randcase("ECDSA+SHA256"),
214        },
215        test   => {
216            "ExpectedServerCertType" => "P-256",
217            "ExpectedServerSignHash" => "SHA256",
218            "ExpectedServerSignType" => "EC",
219            "ExpectedResult" => "Success"
220        },
221    },
222    {
223        name => "ECDSA Signature Algorithm Selection, no ECDSA certificate",
224        server => {
225             "MaxProtocol" => "TLSv1.2"
226        },
227        client => {
228            "SignatureAlgorithms" => randcase("ECDSA+SHA256"),
229        },
230        test   => {
231            "ExpectedResult" => "ServerFail"
232        },
233    },
234    {
235        name => "RSA Signature Algorithm Selection",
236        server => $server,
237        client => {
238            "SignatureAlgorithms" => randcase("RSA+SHA256"),
239        },
240        test   => {
241            "ExpectedServerCertType" => "RSA",
242            "ExpectedServerSignHash" => "SHA256",
243            "ExpectedServerSignType" => "RSA",
244            "ExpectedResult" => "Success"
245        },
246    },
247    {
248        name => "RSA-PSS Signature Algorithm Selection",
249        server => $server,
250        client => {
251            "SignatureAlgorithms" => randcase("RSA-PSS+SHA256"),
252        },
253        test   => {
254            "ExpectedServerCertType" => "RSA",
255            "ExpectedServerSignHash" => "SHA256",
256            "ExpectedServerSignType" => "RSA-PSS",
257            "ExpectedResult" => "Success"
258        },
259    },
260    {
261        name => "RSA key exchange with all RSA certificate types",
262        server => $server_rsa_all,
263        client => {
264            "CipherString" => "kRSA",
265            "MaxProtocol" => "TLSv1.2",
266        },
267        test   => {
268            "ExpectedServerCertType" =>, "RSA",
269            "ExpectedResult" => $fips_3_4 ? "ClientFail" : "Success"
270        },
271    },
272    {
273        name => "Suite B P-256 Hash Algorithm Selection",
274        server =>  {
275            "ECDSA.Certificate" => test_pem("p256-server-cert.pem"),
276            "ECDSA.PrivateKey" => test_pem("p256-server-key.pem"),
277            "MaxProtocol" => "TLSv1.2",
278            "CipherString" => "SUITEB128"
279        },
280        client => {
281            "VerifyCAFile" => test_pem("p384-root.pem"),
282            "SignatureAlgorithms" => randcase("ECDSA+SHA384:ECDSA+SHA256")
283        },
284        test   => {
285            "ExpectedServerCertType" => "P-256",
286            "ExpectedServerSignHash" => "SHA256",
287            "ExpectedServerSignType" => "EC",
288            "ExpectedResult" => "Success"
289        },
290    },
291    {
292        name => "Suite B P-384 Hash Algorithm Selection",
293        server =>  {
294            "ECDSA.Certificate" => test_pem("p384-server-cert.pem"),
295            "ECDSA.PrivateKey" => test_pem("p384-server-key.pem"),
296            "MaxProtocol" => "TLSv1.2",
297            "CipherString" => "SUITEB128"
298        },
299        client => {
300            "VerifyCAFile" => test_pem("p384-root.pem"),
301            "SignatureAlgorithms" => randcase("ECDSA+SHA256:ECDSA+SHA384")
302        },
303        test   => {
304            "ExpectedServerCertType" => "P-384",
305            "ExpectedServerSignHash" => "SHA384",
306            "ExpectedServerSignType" => "EC",
307            "ExpectedResult" => "Success"
308        },
309    },
310    {
311        name => "Ed25519 CipherString and Signature Algorithm Selection",
312        server => $server,
313        client => {
314            "CipherString" => "aECDSA",
315            "MaxProtocol" => "TLSv1.2",
316            "SignatureAlgorithms" => randcase("ed25519:ECDSA+SHA256"),
317            "RequestCAFile" => test_pem("root-cert.pem"),
318        },
319        test   => {
320            "ExpectedServerCertType" =>, "Ed25519",
321            "ExpectedServerSignType" =>, "Ed25519",
322            # Note: certificate_authorities not sent for TLS < 1.3
323            "ExpectedServerCANames" =>, "empty",
324            "ExpectedResult" => "Success"
325        },
326    },
327    {
328        name => "Ed448 CipherString and Signature Algorithm Selection",
329        server => $server,
330        client => {
331            "CipherString" => "aECDSA",
332            "MaxProtocol" => "TLSv1.2",
333            "SignatureAlgorithms" => randcase("ed448:ECDSA+SHA256"),
334            "RequestCAFile" => test_pem("root-ed448-cert.pem"),
335            "VerifyCAFile" => test_pem("root-ed448-cert.pem"),
336        },
337        test   => {
338            "ExpectedServerCertType" =>, "Ed448",
339            "ExpectedServerSignType" =>, "Ed448",
340            # Note: certificate_authorities not sent for TLS < 1.3
341            "ExpectedServerCANames" =>, "empty",
342            "ExpectedResult" => "Success"
343        },
344    },
345    {
346        name => "TLS 1.2 Ed25519 Client Auth",
347        server => {
348            "VerifyCAFile" => test_pem("root-cert.pem"),
349            "VerifyMode" => "Require"
350        },
351        client => {
352            "Ed25519.Certificate" => test_pem("client-ed25519-cert.pem"),
353            "Ed25519.PrivateKey" => test_pem("client-ed25519-key.pem"),
354            "MinProtocol" => "TLSv1.2",
355            "MaxProtocol" => "TLSv1.2"
356        },
357        test   => {
358            "ExpectedClientCertType" => "Ed25519",
359            "ExpectedClientSignType" => "Ed25519",
360            "ExpectedResult" => "Success"
361        },
362    },
363    {
364        name => "TLS 1.2 Ed448 Client Auth",
365        server => {
366            "VerifyCAFile" => test_pem("root-cert.pem"),
367            "VerifyMode" => "Require"
368        },
369        client => {
370            "Ed448.Certificate" => test_pem("client-ed448-cert.pem"),
371            "Ed448.PrivateKey" => test_pem("client-ed448-key.pem"),
372            "MinProtocol" => "TLSv1.2",
373            "MaxProtocol" => "TLSv1.2"
374        },
375        test   => {
376            "ExpectedClientCertType" => "Ed448",
377            "ExpectedClientSignType" => "Ed448",
378            "ExpectedResult" => "Success"
379        },
380    },
381);
382
383my @tests_non_fips = (
384    {
385        name => "ECDSA Signature Algorithm Selection SHA1",
386        server => {
387            "CipherString" => "DEFAULT:\@SECLEVEL=0",
388            "ECDSA.Certificate" => test_pem("server-ecdsa-cert.pem"),
389            "ECDSA.PrivateKey" => test_pem("server-ecdsa-key.pem"),
390            "Ed25519.Certificate" => test_pem("server-ed25519-cert.pem"),
391            "Ed25519.PrivateKey" => test_pem("server-ed25519-key.pem"),
392            "Ed448.Certificate" => test_pem("server-ed448-cert.pem"),
393            "Ed448.PrivateKey" => test_pem("server-ed448-key.pem"),
394            "MaxProtocol" => "TLSv1.2"
395        },
396        client => {
397            "CipherString" => "DEFAULT:\@SECLEVEL=0",
398            "SignatureAlgorithms" => randcase("ECDSA+SHA1"),
399        },
400        test   => {
401            "ExpectedServerCertType" => "P-256",
402            "ExpectedServerSignHash" => "SHA1",
403            "ExpectedServerSignType" => "EC",
404            "ExpectedResult" => "Success"
405        },
406    },
407    {
408        name => "ECDSA with brainpool",
409        server =>  {
410            "Certificate" => test_pem("server-ecdsa-brainpoolP256r1-cert.pem"),
411            "PrivateKey" => test_pem("server-ecdsa-brainpoolP256r1-key.pem"),
412            "Groups" => "brainpoolP256r1",
413        },
414        client => {
415            "MaxProtocol" => "TLSv1.2",
416            "CipherString" => "aECDSA",
417            "RequestCAFile" => test_pem("root-cert.pem"),
418            "Groups" => "brainpoolP256r1",
419        },
420        test   => {
421            "ExpectedServerCertType" =>, "brainpoolP256r1",
422            "ExpectedServerSignType" =>, "EC",
423            # Note: certificate_authorities not sent for TLS < 1.3
424            "ExpectedServerCANames" =>, "empty",
425            "ExpectedResult" => "Success"
426        },
427    },
428    {
429        name => "Ed25519 CipherString and Curves Selection",
430        server => $server,
431        client => {
432            "CipherString" => "aECDSA",
433            "MaxProtocol" => "TLSv1.2",
434            "SignatureAlgorithms" => randcase("ECDSA+SHA256:ed25519"),
435            # Excluding P-256 from the supported curves list means server
436            # certificate should be Ed25519 and not P-256
437            "Curves" => "X25519"
438        },
439        test   => {
440            "ExpectedServerCertType" =>, "Ed25519",
441            "ExpectedServerSignType" =>, "Ed25519",
442            "ExpectedResult" => "Success"
443        },
444    },
445    {
446        name => "Ed448 CipherString and Curves Selection",
447        server => $server,
448        client => {
449            "CipherString" => "aECDSA",
450            "MaxProtocol" => "TLSv1.2",
451            "SignatureAlgorithms" => randcase("ECDSA+SHA256:ed448"),
452            "VerifyCAFile" => test_pem("root-ed448-cert.pem"),
453            # Excluding P-256 from the supported curves list means server
454            # certificate should be Ed25519 and not P-256
455            "Curves" => "X448"
456        },
457        test   => {
458            "ExpectedServerCertType" =>, "Ed448",
459            "ExpectedServerSignType" =>, "Ed448",
460            "ExpectedResult" => "Success"
461        },
462    },
463);
464
465my @tests_pss = (
466    {
467        name => "RSA-PSS Certificate CipherString Selection",
468        server => $server_pss,
469        client => {
470            "CipherString" => "aRSA",
471            "MaxProtocol" => "TLSv1.2",
472        },
473        test   => {
474            "ExpectedServerCertType" =>, "RSA-PSS",
475            "ExpectedServerSignType" =>, "RSA-PSS",
476            "ExpectedResult" => "Success"
477        },
478    },
479    {
480        name => "RSA-PSS Certificate Legacy Signature Algorithm Selection",
481        server => $server_pss,
482        client => {
483            "SignatureAlgorithms" => randcase("RSA-PSS+SHA256"),
484        },
485        test   => {
486            "ExpectedServerCertType" => "RSA",
487            "ExpectedServerSignHash" => "SHA256",
488            "ExpectedServerSignType" => "RSA-PSS",
489            "ExpectedResult" => "Success"
490        },
491    },
492    {
493        name => "RSA-PSS Certificate Unified Signature Algorithm Selection",
494        server => $server_pss,
495        client => {
496            "SignatureAlgorithms" => randcase("rsa_pss_pss_sha256"),
497        },
498        test   => {
499            "ExpectedServerCertType" => "RSA-PSS",
500            "ExpectedServerSignHash" => "SHA256",
501            "ExpectedServerSignType" => "RSA-PSS",
502            "ExpectedResult" => "Success"
503        },
504    },
505    {
506        name => "Only RSA-PSS Certificate",
507        server => $server_pss_only,
508        client => {},
509        test   => {
510            "ExpectedServerCertType" => "RSA-PSS",
511            "ExpectedServerSignHash" => "SHA256",
512            "ExpectedServerSignType" => "RSA-PSS",
513            "ExpectedResult" => "Success"
514        },
515    },
516    {
517        name => "Only RSA-PSS Certificate Valid Signature Algorithms",
518        server => $server_pss_only,
519        client => {
520            "SignatureAlgorithms" => randcase("rsa_pss_pss_sha512"),
521        },
522        test   => {
523            "ExpectedServerCertType" => "RSA-PSS",
524            "ExpectedServerSignHash" => "SHA512",
525            "ExpectedServerSignType" => "RSA-PSS",
526            "ExpectedResult" => "Success"
527        },
528    },
529    {
530        name => "RSA-PSS Certificate, no PSS signature algorithms",
531        server => $server_pss_only,
532        client => {
533            "SignatureAlgorithms" => randcase("RSA+SHA256"),
534        },
535        test   => {
536            "ExpectedResult" => "ServerFail"
537        },
538    },
539    {
540        name => "Only RSA-PSS Restricted Certificate",
541        server => $server_pss_restrict_only,
542        client => {},
543        test   => {
544            "ExpectedServerCertType" => "RSA-PSS",
545            "ExpectedServerSignHash" => "SHA256",
546            "ExpectedServerSignType" => "RSA-PSS",
547            "ExpectedResult" => "Success"
548        },
549    },
550    {
551        name => "RSA-PSS Restricted Certificate Valid Signature Algorithms",
552        server => $server_pss_restrict_only,
553        client => {
554            "SignatureAlgorithms" => randcase("rsa_pss_pss_sha256:rsa_pss_pss_sha512"),
555        },
556        test   => {
557            "ExpectedServerCertType" => "RSA-PSS",
558            "ExpectedServerSignHash" => "SHA256",
559            "ExpectedServerSignType" => "RSA-PSS",
560            "ExpectedResult" => "Success"
561        },
562    },
563    {
564        name => "RSA-PSS Restricted Cert client prefers invalid Signature Algorithm",
565        server => $server_pss_restrict_only,
566        client => {
567            "SignatureAlgorithms" => randcase("rsa_pss_pss_sha512:rsa_pss_pss_sha256"),
568        },
569        test   => {
570            "ExpectedServerCertType" => "RSA-PSS",
571            "ExpectedServerSignHash" => "SHA256",
572            "ExpectedServerSignType" => "RSA-PSS",
573            "ExpectedResult" => "Success"
574        },
575    },
576    {
577        name => "RSA-PSS Restricted Certificate Invalid Signature Algorithms",
578        server => $server_pss_restrict_only,
579        client => {
580            "SignatureAlgorithms" => randcase("rsa_pss_pss_sha512"),
581        },
582        test   => {
583            "ExpectedResult" => "ServerFail"
584        },
585    },
586    {
587        name => "RSA key exchange with only RSA-PSS certificate",
588        server => $server_pss_only,
589        client => {
590            "CipherString" => "kRSA",
591            "MaxProtocol" => "TLSv1.2",
592        },
593        test   => {
594            "ExpectedResult" => "ServerFail"
595        },
596    },
597);
598
599my @tests_tls_1_1 = (
600    {
601        name => "Only RSA-PSS Certificate, TLS v1.1",
602        server => {
603            "CipherString" => "DEFAULT:\@SECLEVEL=0",
604            "Certificate" => test_pem("server-pss-cert.pem"),
605            "PrivateKey" => test_pem("server-pss-key.pem"),
606        },
607        client => {
608            "MaxProtocol" => "TLSv1.1",
609            "CipherString" => "DEFAULT:\@SECLEVEL=0",
610        },
611        test   => {
612            "ExpectedResult" => "ServerFail"
613        },
614    },
615);
616
617push @tests, @tests_non_fips unless $fips_mode;
618push @tests, @tests_pss;
619push @tests, @tests_tls_1_1 unless disabled("tls1_1") || $no_deflt_libctx;
620
621my $server_tls_1_3;
622
623if ($fips_mode) {
624    $server_tls_1_3 = {
625        "ECDSA.Certificate" => test_pem("server-ecdsa-cert.pem"),
626        "ECDSA.PrivateKey" => test_pem("server-ecdsa-key.pem"),
627        "MinProtocol" => "TLSv1.3",
628        "MaxProtocol" => "TLSv1.3"
629    };
630} else {
631    $server_tls_1_3 = {
632        "ECDSA.Certificate" => test_pem("server-ecdsa-cert.pem"),
633        "ECDSA.PrivateKey" => test_pem("server-ecdsa-key.pem"),
634        "Ed25519.Certificate" => test_pem("server-ed25519-cert.pem"),
635        "Ed25519.PrivateKey" => test_pem("server-ed25519-key.pem"),
636        "Ed448.Certificate" => test_pem("server-ed448-cert.pem"),
637        "Ed448.PrivateKey" => test_pem("server-ed448-key.pem"),
638        "MinProtocol" => "TLSv1.3",
639        "MaxProtocol" => "TLSv1.3"
640    };
641}
642
643my $client_tls_1_3 = {
644    "RSA.Certificate" => test_pem("ee-client-chain.pem"),
645    "RSA.PrivateKey" => test_pem("ee-key.pem"),
646    "ECDSA.Certificate" => test_pem("ee-ecdsa-client-chain.pem"),
647    "ECDSA.PrivateKey" => test_pem("ee-ecdsa-key.pem"),
648    "MinProtocol" => "TLSv1.3",
649    "MaxProtocol" => "TLSv1.3"
650};
651
652my @tests_tls_1_3 = (
653    {
654        name => "TLS 1.3 ECDSA Signature Algorithm Selection",
655        server => $server_tls_1_3,
656        client => {
657            "SignatureAlgorithms" => randcase("ECDSA+SHA256"),
658        },
659        test   => {
660            "ExpectedServerCertType" => "P-256",
661            "ExpectedServerSignHash" => "SHA256",
662            "ExpectedServerSignType" => "EC",
663            "ExpectedServerCANames" => "empty",
664            "ExpectedResult" => "Success"
665        },
666    },
667    {
668        name => "TLS 1.3 ECDSA Signature Algorithm Selection compressed point",
669        server => {
670            "ECDSA.Certificate" => test_pem("server-cecdsa-cert.pem"),
671            "ECDSA.PrivateKey" => test_pem("server-cecdsa-key.pem"),
672            "MinProtocol" => "TLSv1.3",
673            "MaxProtocol" => "TLSv1.3"
674        },
675        client => {
676            "SignatureAlgorithms" => randcase("ECDSA+SHA256"),
677        },
678        test   => {
679            "ExpectedServerCertType" => "P-256",
680            "ExpectedServerSignHash" => "SHA256",
681            "ExpectedServerSignType" => "EC",
682            "ExpectedServerCANames" => "empty",
683            "ExpectedResult" => "Success"
684        },
685    },
686    {
687        name => "TLS 1.3 ECDSA Signature Algorithm Selection SHA1",
688        server => {
689            "CipherString" => "DEFAULT:\@SECLEVEL=0",
690            "ECDSA.Certificate" => test_pem("server-ecdsa-cert.pem"),
691            "ECDSA.PrivateKey" => test_pem("server-ecdsa-key.pem"),
692            "Ed25519.Certificate" => test_pem("server-ed25519-cert.pem"),
693            "Ed25519.PrivateKey" => test_pem("server-ed25519-key.pem"),
694            "Ed448.Certificate" => test_pem("server-ed448-cert.pem"),
695            "Ed448.PrivateKey" => test_pem("server-ed448-key.pem"),
696            "MinProtocol" => "TLSv1.3",
697            "MaxProtocol" => "TLSv1.3"
698        },
699        client => {
700            "CipherString" => "DEFAULT:\@SECLEVEL=0",
701            "SignatureAlgorithms" => randcase("ECDSA+SHA1"),
702        },
703        test   => {
704            "ExpectedResult" => "ServerFail"
705        },
706    },
707    {
708        name => "TLS 1.3 ECDSA Signature Algorithm Selection with PSS",
709        server => $server_tls_1_3,
710        client => {
711            "SignatureAlgorithms" => randcase("ECDSA+SHA256:RSA-PSS+SHA256"),
712            "RequestCAFile" => test_pem("root-cert.pem"),
713        },
714        test   => {
715            "ExpectedServerCertType" => "P-256",
716            "ExpectedServerSignHash" => "SHA256",
717            "ExpectedServerSignType" => "EC",
718            "ExpectedServerCANames" => test_pem("root-cert.pem"),
719            "ExpectedResult" => "Success"
720        },
721    },
722    {
723        name => "TLS 1.3 RSA Signature Algorithm Selection SHA384 with PSS",
724        server => $server_tls_1_3,
725        client => {
726            "SignatureAlgorithms" => randcase("ECDSA+SHA384:RSA-PSS+SHA384"),
727        },
728        test   => {
729            "ExpectedServerCertType" => "RSA",
730            "ExpectedServerSignHash" => "SHA384",
731            "ExpectedServerSignType" => "RSA-PSS",
732            "ExpectedResult" => "Success"
733        },
734    },
735    {
736        name => "TLS 1.3 ECDSA Signature Algorithm Selection, no ECDSA certificate",
737        server => {
738            "MinProtocol" => "TLSv1.3",
739            "MaxProtocol" => "TLSv1.3"
740        },
741        client => {
742            "SignatureAlgorithms" => randcase("ECDSA+SHA256"),
743        },
744        test   => {
745            "ExpectedResult" => "ServerFail"
746        },
747    },
748    {
749        name => "TLS 1.3 RSA Signature Algorithm Selection, no PSS",
750        server => $server_tls_1_3,
751        client => {
752            "SignatureAlgorithms" => randcase("RSA+SHA256"),
753        },
754        test   => {
755            "ExpectedResult" => "ServerFail"
756        },
757    },
758    {
759        name => "TLS 1.3 RSA-PSS Signature Algorithm Selection",
760        server => $server_tls_1_3,
761        client => {
762            "SignatureAlgorithms" => randcase("RSA-PSS+SHA256"),
763        },
764        test   => {
765            "ExpectedServerCertType" => "RSA",
766            "ExpectedServerSignHash" => "SHA256",
767            "ExpectedServerSignType" => "RSA-PSS",
768            "ExpectedResult" => "Success"
769        },
770    },
771    {
772        name => "TLS 1.3 RSA Client Auth Signature Algorithm Selection",
773        server => {
774            "ClientSignatureAlgorithms" => randcase("PSS+SHA256"),
775            "VerifyCAFile" => test_pem("root-cert.pem"),
776            "VerifyMode" => "Require"
777        },
778        client => $client_tls_1_3,
779        test   => {
780            "ExpectedClientCertType" => "RSA",
781            "ExpectedClientSignHash" => "SHA256",
782            "ExpectedClientSignType" => "RSA-PSS",
783            "ExpectedClientCANames" => "empty",
784            "ExpectedResult" => "Success"
785        },
786    },
787    {
788        name => "TLS 1.3 RSA Client Auth Signature Algorithm Selection non-empty CA Names",
789        server => {
790            "ClientSignatureAlgorithms" => randcase("PSS+SHA256"),
791            "VerifyCAFile" => test_pem("root-cert.pem"),
792            "RequestCAFile" => test_pem("root-cert.pem"),
793            "VerifyMode" => "Require"
794        },
795        client => $client_tls_1_3,
796        test   => {
797            "ExpectedClientCertType" => "RSA",
798            "ExpectedClientSignHash" => "SHA256",
799            "ExpectedClientSignType" => "RSA-PSS",
800            "ExpectedClientCANames" => test_pem("root-cert.pem"),
801            "ExpectedResult" => "Success"
802        },
803    },
804    {
805        name => "TLS 1.3 ECDSA Client Auth Signature Algorithm Selection",
806        server => {
807            "ClientSignatureAlgorithms" => randcase("ECDSA+SHA256"),
808            "VerifyCAFile" => test_pem("root-cert.pem"),
809            "VerifyMode" => "Require"
810        },
811        client => $client_tls_1_3,
812        test   => {
813            "ExpectedClientCertType" => "P-256",
814            "ExpectedClientSignHash" => "SHA256",
815            "ExpectedClientSignType" => "EC",
816            "ExpectedResult" => "Success"
817        },
818    },
819);
820
821my @tests_tls_1_3_non_fips = (
822    {
823        name => "TLS 1.3 Ed25519 Signature Algorithm Selection",
824        server => $server_tls_1_3,
825        client => {
826            "SignatureAlgorithms" => randcase("ed25519"),
827        },
828        test   => {
829            "ExpectedServerCertType" => "Ed25519",
830            "ExpectedServerSignType" => "Ed25519",
831            "ExpectedResult" => "Success"
832        },
833    },
834    {
835        name => "TLS 1.3 Ed448 Signature Algorithm Selection",
836        server => $server_tls_1_3,
837        client => {
838            "SignatureAlgorithms" => randcase("ed448"),
839            "VerifyCAFile" => test_pem("root-ed448-cert.pem"),
840        },
841        test   => {
842            "ExpectedServerCertType" => "Ed448",
843            "ExpectedServerSignType" => "Ed448",
844            "ExpectedResult" => "Success"
845        },
846    },
847    {
848        name => "TLS 1.3 Ed25519 CipherString and Groups Selection",
849        server => $server_tls_1_3,
850        client => {
851            "SignatureAlgorithms" => randcase("ECDSA+SHA256:ed25519"),
852            # Excluding P-256 from the supported groups list should
853            # mean server still uses a P-256 certificate because supported
854            # groups is not used in signature selection for TLS 1.3
855            "Groups" => "X25519"
856        },
857        test   => {
858            "ExpectedServerCertType" =>, "P-256",
859            "ExpectedServerSignType" =>, "EC",
860            "ExpectedResult" => "Success"
861        },
862    },
863    {
864        name => "TLS 1.3 Ed448 CipherString and Groups Selection",
865        server => $server_tls_1_3,
866        client => {
867            "SignatureAlgorithms" => randcase("ECDSA+SHA256:ed448"),
868            # Excluding P-256 from the supported groups list should
869            # mean server still uses a P-256 certificate because supported
870            # groups is not used in signature selection for TLS 1.3
871            "Groups" => "X448"
872        },
873        test   => {
874            "ExpectedServerCertType" =>, "P-256",
875            "ExpectedServerSignType" =>, "EC",
876            "ExpectedResult" => "Success"
877        },
878    },
879    {
880        name => "TLS 1.3 Ed25519 Client Auth",
881        server => {
882            "VerifyCAFile" => test_pem("root-cert.pem"),
883            "VerifyMode" => "Require"
884        },
885        client => {
886            "EdDSA.Certificate" => test_pem("client-ed25519-cert.pem"),
887            "EdDSA.PrivateKey" => test_pem("client-ed25519-key.pem"),
888            "MinProtocol" => "TLSv1.3",
889            "MaxProtocol" => "TLSv1.3"
890        },
891        test   => {
892            "ExpectedClientCertType" => "Ed25519",
893            "ExpectedClientSignType" => "Ed25519",
894            "ExpectedResult" => "Success"
895        },
896    },
897    {
898        name => "TLS 1.3 Ed448 Client Auth",
899        server => {
900            "VerifyCAFile" => test_pem("root-cert.pem"),
901            "VerifyMode" => "Require"
902        },
903        client => {
904            "EdDSA.Certificate" => test_pem("client-ed448-cert.pem"),
905            "EdDSA.PrivateKey" => test_pem("client-ed448-key.pem"),
906            "MinProtocol" => "TLSv1.3",
907            "MaxProtocol" => "TLSv1.3"
908        },
909        test   => {
910            "ExpectedClientCertType" => "Ed448",
911            "ExpectedClientSignType" => "Ed448",
912            "ExpectedResult" => "Success"
913        },
914    },
915    {
916        name => "TLS 1.3 ECDSA with brainpool but no suitable groups",
917        server =>  {
918            "Certificate" => test_pem("server-ecdsa-brainpoolP256r1-cert.pem"),
919            "PrivateKey" => test_pem("server-ecdsa-brainpoolP256r1-key.pem"),
920            "Groups" => "brainpoolP256r1",
921        },
922        client => {
923            "CipherString" => "aECDSA",
924            "RequestCAFile" => test_pem("root-cert.pem"),
925            "Groups" => "brainpoolP256r1",
926        },
927        test   => {
928            #We only configured brainpoolP256r1 on the client side, but TLSv1.3
929            #is enabled and this group is not allowed in TLSv1.3. Therefore this
930            #should fail
931            "ExpectedResult" => "ClientFail"
932        },
933    },
934    {
935        name => "TLS 1.3 ECDSA with brainpool",
936        server =>  {
937            "Certificate" => test_pem("server-ecdsa-brainpoolP256r1-cert.pem"),
938            "PrivateKey" => test_pem("server-ecdsa-brainpoolP256r1-key.pem"),
939        },
940        client => {
941            "RequestCAFile" => test_pem("root-cert.pem"),
942            "MinProtocol" => "TLSv1.3",
943            "MaxProtocol" => "TLSv1.3"
944        },
945        test   => {
946            "ExpectedResult" => "Success"
947        },
948    },
949);
950
951push @tests, @tests_tls_1_3 unless disabled("tls1_3");
952push @tests, @tests_tls_1_3_non_fips unless disabled("tls1_3") || $fips_mode;
953
954my @tests_dsa_tls_1_2 = (
955    {
956        name => "TLS 1.2 DSA Certificate Test",
957        server => {
958            "DSA.Certificate" => test_pem("server-dsa-cert.pem"),
959            "DSA.PrivateKey" => test_pem("server-dsa-key.pem"),
960            "DHParameters" => test_pem("dhp2048.pem"),
961            "MinProtocol" => "TLSv1.2",
962            "MaxProtocol" => "TLSv1.2",
963            "CipherString" => "ALL",
964        },
965        client => {
966            "SignatureAlgorithms" => randcase("DSA+SHA256:DSA+SHA1"),
967            "CipherString" => "ALL",
968        },
969        test   => {
970            "ExpectedResult" => "Success"
971        },
972    },
973);
974
975my @tests_dsa_tls_1_3 = (
976    {
977        name => "TLS 1.3 Client Auth No TLS 1.3 Signature Algorithms",
978        server => {
979            "ClientSignatureAlgorithms" => randcase("ECDSA+SHA1:DSA+SHA256:RSA+SHA256"),
980            "VerifyCAFile" => test_pem("root-cert.pem"),
981            "VerifyMode" => "Request"
982        },
983        client => {},
984        test   => {
985            "ExpectedResult" => "ServerFail"
986        },
987    },
988    {
989        name => "TLS 1.3 DSA Certificate Test",
990        server => {
991            "DSA.Certificate" => test_pem("server-dsa-cert.pem"),
992            "DSA.PrivateKey" => test_pem("server-dsa-key.pem"),
993            "MinProtocol" => "TLSv1.3",
994            "MaxProtocol" => "TLSv1.3",
995            "CipherString" => "ALL",
996        },
997        client => {
998            "SignatureAlgorithms" => randcase("DSA+SHA1:DSA+SHA256:ECDSA+SHA256"),
999            "CipherString" => "ALL",
1000        },
1001        test   => {
1002            "ExpectedResult" => "ServerFail"
1003        },
1004    },
1005);
1006
1007if (!disabled("dsa")) {
1008    push @tests, @tests_dsa_tls_1_2 unless disabled("dh") || $fips_3_4;
1009    push @tests, @tests_dsa_tls_1_3 unless disabled("tls1_3");
1010}
1011
1012my @tests_mldsa_tls_1_3 = (
1013    {
1014        name => "TLS 1.3 ML-DSA Certificate Test",
1015        server => {
1016            "Certificate" => test_pem("server-ml-dsa-44-cert.pem"),
1017            "PrivateKey" => test_pem("server-ml-dsa-44-key.pem"),
1018            "MinProtocol" => "TLSv1.3",
1019            "MaxProtocol" => "TLSv1.3",
1020            "SignatureAlgorithms" => randcase("mldsa44"),
1021        },
1022        client => {
1023            "MinProtocol" => "TLSv1.3",
1024            "MaxProtocol" => "TLSv1.3",
1025            "SignatureAlgorithms" => randcase("mldsa44"),
1026            "VerifyCAFile" => test_pem("root-ml-dsa-44-cert.pem"),
1027            "VerifyMode" => "Peer",
1028        },
1029        test   => {
1030            "ExpectedResult" => "Success"
1031        },
1032    },
1033);
1034
1035if (!disabled("ml-dsa") && (!$fips_mode || $fips_3_5)) {
1036    push @tests, @tests_mldsa_tls_1_3 unless disabled("tls1_3");
1037}
1038