diff options
author | tb <> | 2022-08-04 09:27:36 +0000 |
---|---|---|
committer | tb <> | 2022-08-04 09:27:36 +0000 |
commit | a65f4608fab82ca1a01fdae059ee762cb1626d69 (patch) | |
tree | 49cf56f0876a731f8625f44fad25bc2952a561ae /src | |
parent | 28e3b1222b3ca2332b57eabdb44e9133d6907f97 (diff) | |
download | openbsd-a65f4608fab82ca1a01fdae059ee762cb1626d69.tar.gz openbsd-a65f4608fab82ca1a01fdae059ee762cb1626d69.tar.bz2 openbsd-a65f4608fab82ca1a01fdae059ee762cb1626d69.zip |
Make tlsext_*_{build,needs,parse}() functions static
None of these functions are used outside of ssl_tlsext.c. The only reason
they are prototyped in the header is for the use of tlsexttest.c. Rather
than having a big pile of useless copy-paste in the header, we can adapt
the test to avoid using these functions directly.
ok jsing
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libssl/ssl_tlsext.c | 185 | ||||
-rw-r--r-- | src/lib/libssl/ssl_tlsext.h | 126 |
2 files changed, 94 insertions, 217 deletions
diff --git a/src/lib/libssl/ssl_tlsext.c b/src/lib/libssl/ssl_tlsext.c index 033608e03e..f417f59b8e 100644 --- a/src/lib/libssl/ssl_tlsext.c +++ b/src/lib/libssl/ssl_tlsext.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_tlsext.c,v 1.127 2022/07/24 10:52:51 tb Exp $ */ | 1 | /* $OpenBSD: ssl_tlsext.c,v 1.128 2022/08/04 09:27:36 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2016, 2017, 2019 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2016, 2017, 2019 Joel Sing <jsing@openbsd.org> |
4 | * Copyright (c) 2017 Doug Hogan <doug@openbsd.org> | 4 | * Copyright (c) 2017 Doug Hogan <doug@openbsd.org> |
@@ -36,7 +36,7 @@ | |||
36 | * Supported Application-Layer Protocol Negotiation - RFC 7301 | 36 | * Supported Application-Layer Protocol Negotiation - RFC 7301 |
37 | */ | 37 | */ |
38 | 38 | ||
39 | int | 39 | static int |
40 | tlsext_alpn_client_needs(SSL *s, uint16_t msg_type) | 40 | tlsext_alpn_client_needs(SSL *s, uint16_t msg_type) |
41 | { | 41 | { |
42 | /* ALPN protos have been specified and this is the initial handshake */ | 42 | /* ALPN protos have been specified and this is the initial handshake */ |
@@ -44,7 +44,7 @@ tlsext_alpn_client_needs(SSL *s, uint16_t msg_type) | |||
44 | s->s3->hs.finished_len == 0; | 44 | s->s3->hs.finished_len == 0; |
45 | } | 45 | } |
46 | 46 | ||
47 | int | 47 | static int |
48 | tlsext_alpn_client_build(SSL *s, uint16_t msg_type, CBB *cbb) | 48 | tlsext_alpn_client_build(SSL *s, uint16_t msg_type, CBB *cbb) |
49 | { | 49 | { |
50 | CBB protolist; | 50 | CBB protolist; |
@@ -83,7 +83,7 @@ tlsext_alpn_check_format(CBS *cbs) | |||
83 | return 1; | 83 | return 1; |
84 | } | 84 | } |
85 | 85 | ||
86 | int | 86 | static int |
87 | tlsext_alpn_server_parse(SSL *s, uint16_t msg_types, CBS *cbs, int *alert) | 87 | tlsext_alpn_server_parse(SSL *s, uint16_t msg_types, CBS *cbs, int *alert) |
88 | { | 88 | { |
89 | CBS alpn; | 89 | CBS alpn; |
@@ -134,13 +134,13 @@ tlsext_alpn_server_parse(SSL *s, uint16_t msg_types, CBS *cbs, int *alert) | |||
134 | return 0; | 134 | return 0; |
135 | } | 135 | } |
136 | 136 | ||
137 | int | 137 | static int |
138 | tlsext_alpn_server_needs(SSL *s, uint16_t msg_type) | 138 | tlsext_alpn_server_needs(SSL *s, uint16_t msg_type) |
139 | { | 139 | { |
140 | return s->s3->alpn_selected != NULL; | 140 | return s->s3->alpn_selected != NULL; |
141 | } | 141 | } |
142 | 142 | ||
143 | int | 143 | static int |
144 | tlsext_alpn_server_build(SSL *s, uint16_t msg_type, CBB *cbb) | 144 | tlsext_alpn_server_build(SSL *s, uint16_t msg_type, CBB *cbb) |
145 | { | 145 | { |
146 | CBB list, selected; | 146 | CBB list, selected; |
@@ -161,7 +161,7 @@ tlsext_alpn_server_build(SSL *s, uint16_t msg_type, CBB *cbb) | |||
161 | return 1; | 161 | return 1; |
162 | } | 162 | } |
163 | 163 | ||
164 | int | 164 | static int |
165 | tlsext_alpn_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | 165 | tlsext_alpn_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) |
166 | { | 166 | { |
167 | CBS list, proto; | 167 | CBS list, proto; |
@@ -191,14 +191,14 @@ tlsext_alpn_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
191 | /* | 191 | /* |
192 | * Supported Groups - RFC 7919 section 2 | 192 | * Supported Groups - RFC 7919 section 2 |
193 | */ | 193 | */ |
194 | int | 194 | static int |
195 | tlsext_supportedgroups_client_needs(SSL *s, uint16_t msg_type) | 195 | tlsext_supportedgroups_client_needs(SSL *s, uint16_t msg_type) |
196 | { | 196 | { |
197 | return ssl_has_ecc_ciphers(s) || | 197 | return ssl_has_ecc_ciphers(s) || |
198 | (s->s3->hs.our_max_tls_version >= TLS1_3_VERSION); | 198 | (s->s3->hs.our_max_tls_version >= TLS1_3_VERSION); |
199 | } | 199 | } |
200 | 200 | ||
201 | int | 201 | static int |
202 | tlsext_supportedgroups_client_build(SSL *s, uint16_t msg_type, CBB *cbb) | 202 | tlsext_supportedgroups_client_build(SSL *s, uint16_t msg_type, CBB *cbb) |
203 | { | 203 | { |
204 | const uint16_t *groups; | 204 | const uint16_t *groups; |
@@ -228,7 +228,7 @@ tlsext_supportedgroups_client_build(SSL *s, uint16_t msg_type, CBB *cbb) | |||
228 | return 1; | 228 | return 1; |
229 | } | 229 | } |
230 | 230 | ||
231 | int | 231 | static int |
232 | tlsext_supportedgroups_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, | 232 | tlsext_supportedgroups_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, |
233 | int *alert) | 233 | int *alert) |
234 | { | 234 | { |
@@ -289,19 +289,19 @@ tlsext_supportedgroups_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, | |||
289 | } | 289 | } |
290 | 290 | ||
291 | /* This extension is never used by the server. */ | 291 | /* This extension is never used by the server. */ |
292 | int | 292 | static int |
293 | tlsext_supportedgroups_server_needs(SSL *s, uint16_t msg_type) | 293 | tlsext_supportedgroups_server_needs(SSL *s, uint16_t msg_type) |
294 | { | 294 | { |
295 | return 0; | 295 | return 0; |
296 | } | 296 | } |
297 | 297 | ||
298 | int | 298 | static int |
299 | tlsext_supportedgroups_server_build(SSL *s, uint16_t msg_type, CBB *cbb) | 299 | tlsext_supportedgroups_server_build(SSL *s, uint16_t msg_type, CBB *cbb) |
300 | { | 300 | { |
301 | return 0; | 301 | return 0; |
302 | } | 302 | } |
303 | 303 | ||
304 | int | 304 | static int |
305 | tlsext_supportedgroups_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, | 305 | tlsext_supportedgroups_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, |
306 | int *alert) | 306 | int *alert) |
307 | { | 307 | { |
@@ -378,37 +378,37 @@ tlsext_ecpf_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
378 | return 1; | 378 | return 1; |
379 | } | 379 | } |
380 | 380 | ||
381 | int | 381 | static int |
382 | tlsext_ecpf_client_needs(SSL *s, uint16_t msg_type) | 382 | tlsext_ecpf_client_needs(SSL *s, uint16_t msg_type) |
383 | { | 383 | { |
384 | return ssl_has_ecc_ciphers(s); | 384 | return ssl_has_ecc_ciphers(s); |
385 | } | 385 | } |
386 | 386 | ||
387 | int | 387 | static int |
388 | tlsext_ecpf_client_build(SSL *s, uint16_t msg_type, CBB *cbb) | 388 | tlsext_ecpf_client_build(SSL *s, uint16_t msg_type, CBB *cbb) |
389 | { | 389 | { |
390 | return tlsext_ecpf_build(s, msg_type, cbb); | 390 | return tlsext_ecpf_build(s, msg_type, cbb); |
391 | } | 391 | } |
392 | 392 | ||
393 | int | 393 | static int |
394 | tlsext_ecpf_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | 394 | tlsext_ecpf_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) |
395 | { | 395 | { |
396 | return tlsext_ecpf_parse(s, msg_type, cbs, alert); | 396 | return tlsext_ecpf_parse(s, msg_type, cbs, alert); |
397 | } | 397 | } |
398 | 398 | ||
399 | int | 399 | static int |
400 | tlsext_ecpf_server_needs(SSL *s, uint16_t msg_type) | 400 | tlsext_ecpf_server_needs(SSL *s, uint16_t msg_type) |
401 | { | 401 | { |
402 | return ssl_using_ecc_cipher(s); | 402 | return ssl_using_ecc_cipher(s); |
403 | } | 403 | } |
404 | 404 | ||
405 | int | 405 | static int |
406 | tlsext_ecpf_server_build(SSL *s, uint16_t msg_type, CBB *cbb) | 406 | tlsext_ecpf_server_build(SSL *s, uint16_t msg_type, CBB *cbb) |
407 | { | 407 | { |
408 | return tlsext_ecpf_build(s, msg_type, cbb); | 408 | return tlsext_ecpf_build(s, msg_type, cbb); |
409 | } | 409 | } |
410 | 410 | ||
411 | int | 411 | static int |
412 | tlsext_ecpf_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | 412 | tlsext_ecpf_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) |
413 | { | 413 | { |
414 | return tlsext_ecpf_parse(s, msg_type, cbs, alert); | 414 | return tlsext_ecpf_parse(s, msg_type, cbs, alert); |
@@ -417,13 +417,13 @@ tlsext_ecpf_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
417 | /* | 417 | /* |
418 | * Renegotiation Indication - RFC 5746. | 418 | * Renegotiation Indication - RFC 5746. |
419 | */ | 419 | */ |
420 | int | 420 | static int |
421 | tlsext_ri_client_needs(SSL *s, uint16_t msg_type) | 421 | tlsext_ri_client_needs(SSL *s, uint16_t msg_type) |
422 | { | 422 | { |
423 | return (s->internal->renegotiate); | 423 | return (s->internal->renegotiate); |
424 | } | 424 | } |
425 | 425 | ||
426 | int | 426 | static int |
427 | tlsext_ri_client_build(SSL *s, uint16_t msg_type, CBB *cbb) | 427 | tlsext_ri_client_build(SSL *s, uint16_t msg_type, CBB *cbb) |
428 | { | 428 | { |
429 | CBB reneg; | 429 | CBB reneg; |
@@ -439,7 +439,7 @@ tlsext_ri_client_build(SSL *s, uint16_t msg_type, CBB *cbb) | |||
439 | return 1; | 439 | return 1; |
440 | } | 440 | } |
441 | 441 | ||
442 | int | 442 | static int |
443 | tlsext_ri_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | 443 | tlsext_ri_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) |
444 | { | 444 | { |
445 | CBS reneg; | 445 | CBS reneg; |
@@ -462,14 +462,14 @@ tlsext_ri_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
462 | return 1; | 462 | return 1; |
463 | } | 463 | } |
464 | 464 | ||
465 | int | 465 | static int |
466 | tlsext_ri_server_needs(SSL *s, uint16_t msg_type) | 466 | tlsext_ri_server_needs(SSL *s, uint16_t msg_type) |
467 | { | 467 | { |
468 | return (s->s3->hs.negotiated_tls_version < TLS1_3_VERSION && | 468 | return (s->s3->hs.negotiated_tls_version < TLS1_3_VERSION && |
469 | s->s3->send_connection_binding); | 469 | s->s3->send_connection_binding); |
470 | } | 470 | } |
471 | 471 | ||
472 | int | 472 | static int |
473 | tlsext_ri_server_build(SSL *s, uint16_t msg_type, CBB *cbb) | 473 | tlsext_ri_server_build(SSL *s, uint16_t msg_type, CBB *cbb) |
474 | { | 474 | { |
475 | CBB reneg; | 475 | CBB reneg; |
@@ -488,7 +488,7 @@ tlsext_ri_server_build(SSL *s, uint16_t msg_type, CBB *cbb) | |||
488 | return 1; | 488 | return 1; |
489 | } | 489 | } |
490 | 490 | ||
491 | int | 491 | static int |
492 | tlsext_ri_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | 492 | tlsext_ri_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) |
493 | { | 493 | { |
494 | CBS reneg, prev_client, prev_server; | 494 | CBS reneg, prev_client, prev_server; |
@@ -546,13 +546,13 @@ tlsext_ri_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
546 | /* | 546 | /* |
547 | * Signature Algorithms - RFC 5246 section 7.4.1.4.1. | 547 | * Signature Algorithms - RFC 5246 section 7.4.1.4.1. |
548 | */ | 548 | */ |
549 | int | 549 | static int |
550 | tlsext_sigalgs_client_needs(SSL *s, uint16_t msg_type) | 550 | tlsext_sigalgs_client_needs(SSL *s, uint16_t msg_type) |
551 | { | 551 | { |
552 | return (s->s3->hs.our_max_tls_version >= TLS1_2_VERSION); | 552 | return (s->s3->hs.our_max_tls_version >= TLS1_2_VERSION); |
553 | } | 553 | } |
554 | 554 | ||
555 | int | 555 | static int |
556 | tlsext_sigalgs_client_build(SSL *s, uint16_t msg_type, CBB *cbb) | 556 | tlsext_sigalgs_client_build(SSL *s, uint16_t msg_type, CBB *cbb) |
557 | { | 557 | { |
558 | uint16_t tls_version = s->s3->hs.negotiated_tls_version; | 558 | uint16_t tls_version = s->s3->hs.negotiated_tls_version; |
@@ -571,7 +571,7 @@ tlsext_sigalgs_client_build(SSL *s, uint16_t msg_type, CBB *cbb) | |||
571 | return 1; | 571 | return 1; |
572 | } | 572 | } |
573 | 573 | ||
574 | int | 574 | static int |
575 | tlsext_sigalgs_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | 575 | tlsext_sigalgs_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) |
576 | { | 576 | { |
577 | CBS sigalgs; | 577 | CBS sigalgs; |
@@ -586,13 +586,13 @@ tlsext_sigalgs_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
586 | return 1; | 586 | return 1; |
587 | } | 587 | } |
588 | 588 | ||
589 | int | 589 | static int |
590 | tlsext_sigalgs_server_needs(SSL *s, uint16_t msg_type) | 590 | tlsext_sigalgs_server_needs(SSL *s, uint16_t msg_type) |
591 | { | 591 | { |
592 | return (s->s3->hs.negotiated_tls_version >= TLS1_3_VERSION); | 592 | return (s->s3->hs.negotiated_tls_version >= TLS1_3_VERSION); |
593 | } | 593 | } |
594 | 594 | ||
595 | int | 595 | static int |
596 | tlsext_sigalgs_server_build(SSL *s, uint16_t msg_type, CBB *cbb) | 596 | tlsext_sigalgs_server_build(SSL *s, uint16_t msg_type, CBB *cbb) |
597 | { | 597 | { |
598 | CBB sigalgs; | 598 | CBB sigalgs; |
@@ -608,7 +608,7 @@ tlsext_sigalgs_server_build(SSL *s, uint16_t msg_type, CBB *cbb) | |||
608 | return 1; | 608 | return 1; |
609 | } | 609 | } |
610 | 610 | ||
611 | int | 611 | static int |
612 | tlsext_sigalgs_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | 612 | tlsext_sigalgs_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) |
613 | { | 613 | { |
614 | CBS sigalgs; | 614 | CBS sigalgs; |
@@ -629,13 +629,13 @@ tlsext_sigalgs_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
629 | /* | 629 | /* |
630 | * Server Name Indication - RFC 6066, section 3. | 630 | * Server Name Indication - RFC 6066, section 3. |
631 | */ | 631 | */ |
632 | int | 632 | static int |
633 | tlsext_sni_client_needs(SSL *s, uint16_t msg_type) | 633 | tlsext_sni_client_needs(SSL *s, uint16_t msg_type) |
634 | { | 634 | { |
635 | return (s->tlsext_hostname != NULL); | 635 | return (s->tlsext_hostname != NULL); |
636 | } | 636 | } |
637 | 637 | ||
638 | int | 638 | static int |
639 | tlsext_sni_client_build(SSL *s, uint16_t msg_type, CBB *cbb) | 639 | tlsext_sni_client_build(SSL *s, uint16_t msg_type, CBB *cbb) |
640 | { | 640 | { |
641 | CBB server_name_list, host_name; | 641 | CBB server_name_list, host_name; |
@@ -735,7 +735,7 @@ tlsext_sni_is_valid_hostname(CBS *cbs, int *is_ip) | |||
735 | return 1; | 735 | return 1; |
736 | } | 736 | } |
737 | 737 | ||
738 | int | 738 | static int |
739 | tlsext_sni_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | 739 | tlsext_sni_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) |
740 | { | 740 | { |
741 | CBS server_name_list, host_name; | 741 | CBS server_name_list, host_name; |
@@ -816,7 +816,7 @@ tlsext_sni_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
816 | return 0; | 816 | return 0; |
817 | } | 817 | } |
818 | 818 | ||
819 | int | 819 | static int |
820 | tlsext_sni_server_needs(SSL *s, uint16_t msg_type) | 820 | tlsext_sni_server_needs(SSL *s, uint16_t msg_type) |
821 | { | 821 | { |
822 | if (s->internal->hit) | 822 | if (s->internal->hit) |
@@ -825,13 +825,13 @@ tlsext_sni_server_needs(SSL *s, uint16_t msg_type) | |||
825 | return (s->session->tlsext_hostname != NULL); | 825 | return (s->session->tlsext_hostname != NULL); |
826 | } | 826 | } |
827 | 827 | ||
828 | int | 828 | static int |
829 | tlsext_sni_server_build(SSL *s, uint16_t msg_type, CBB *cbb) | 829 | tlsext_sni_server_build(SSL *s, uint16_t msg_type, CBB *cbb) |
830 | { | 830 | { |
831 | return 1; | 831 | return 1; |
832 | } | 832 | } |
833 | 833 | ||
834 | int | 834 | static int |
835 | tlsext_sni_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | 835 | tlsext_sni_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) |
836 | { | 836 | { |
837 | if (s->tlsext_hostname == NULL || CBS_len(cbs) != 0) { | 837 | if (s->tlsext_hostname == NULL || CBS_len(cbs) != 0) { |
@@ -862,12 +862,11 @@ tlsext_sni_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
862 | return 1; | 862 | return 1; |
863 | } | 863 | } |
864 | 864 | ||
865 | |||
866 | /* | 865 | /* |
867 | * Certificate Status Request - RFC 6066 section 8. | 866 | * Certificate Status Request - RFC 6066 section 8. |
868 | */ | 867 | */ |
869 | 868 | ||
870 | int | 869 | static int |
871 | tlsext_ocsp_client_needs(SSL *s, uint16_t msg_type) | 870 | tlsext_ocsp_client_needs(SSL *s, uint16_t msg_type) |
872 | { | 871 | { |
873 | if (msg_type != SSL_TLSEXT_MSG_CH) | 872 | if (msg_type != SSL_TLSEXT_MSG_CH) |
@@ -876,7 +875,7 @@ tlsext_ocsp_client_needs(SSL *s, uint16_t msg_type) | |||
876 | return (s->tlsext_status_type == TLSEXT_STATUSTYPE_ocsp); | 875 | return (s->tlsext_status_type == TLSEXT_STATUSTYPE_ocsp); |
877 | } | 876 | } |
878 | 877 | ||
879 | int | 878 | static int |
880 | tlsext_ocsp_client_build(SSL *s, uint16_t msg_type, CBB *cbb) | 879 | tlsext_ocsp_client_build(SSL *s, uint16_t msg_type, CBB *cbb) |
881 | { | 880 | { |
882 | CBB respid_list, respid, exts; | 881 | CBB respid_list, respid, exts; |
@@ -920,7 +919,7 @@ tlsext_ocsp_client_build(SSL *s, uint16_t msg_type, CBB *cbb) | |||
920 | return 1; | 919 | return 1; |
921 | } | 920 | } |
922 | 921 | ||
923 | int | 922 | static int |
924 | tlsext_ocsp_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | 923 | tlsext_ocsp_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) |
925 | { | 924 | { |
926 | int alert_desc = SSL_AD_DECODE_ERROR; | 925 | int alert_desc = SSL_AD_DECODE_ERROR; |
@@ -993,7 +992,7 @@ tlsext_ocsp_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
993 | return ret; | 992 | return ret; |
994 | } | 993 | } |
995 | 994 | ||
996 | int | 995 | static int |
997 | tlsext_ocsp_server_needs(SSL *s, uint16_t msg_type) | 996 | tlsext_ocsp_server_needs(SSL *s, uint16_t msg_type) |
998 | { | 997 | { |
999 | if (s->s3->hs.negotiated_tls_version >= TLS1_3_VERSION && | 998 | if (s->s3->hs.negotiated_tls_version >= TLS1_3_VERSION && |
@@ -1008,7 +1007,7 @@ tlsext_ocsp_server_needs(SSL *s, uint16_t msg_type) | |||
1008 | return s->internal->tlsext_status_expected; | 1007 | return s->internal->tlsext_status_expected; |
1009 | } | 1008 | } |
1010 | 1009 | ||
1011 | int | 1010 | static int |
1012 | tlsext_ocsp_server_build(SSL *s, uint16_t msg_type, CBB *cbb) | 1011 | tlsext_ocsp_server_build(SSL *s, uint16_t msg_type, CBB *cbb) |
1013 | { | 1012 | { |
1014 | CBB ocsp_response; | 1013 | CBB ocsp_response; |
@@ -1028,7 +1027,7 @@ tlsext_ocsp_server_build(SSL *s, uint16_t msg_type, CBB *cbb) | |||
1028 | return 1; | 1027 | return 1; |
1029 | } | 1028 | } |
1030 | 1029 | ||
1031 | int | 1030 | static int |
1032 | tlsext_ocsp_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | 1031 | tlsext_ocsp_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) |
1033 | { | 1032 | { |
1034 | uint8_t status_type; | 1033 | uint8_t status_type; |
@@ -1081,7 +1080,7 @@ tlsext_ocsp_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
1081 | /* | 1080 | /* |
1082 | * SessionTicket extension - RFC 5077 section 3.2 | 1081 | * SessionTicket extension - RFC 5077 section 3.2 |
1083 | */ | 1082 | */ |
1084 | int | 1083 | static int |
1085 | tlsext_sessionticket_client_needs(SSL *s, uint16_t msg_type) | 1084 | tlsext_sessionticket_client_needs(SSL *s, uint16_t msg_type) |
1086 | { | 1085 | { |
1087 | /* | 1086 | /* |
@@ -1105,7 +1104,7 @@ tlsext_sessionticket_client_needs(SSL *s, uint16_t msg_type) | |||
1105 | return 1; | 1104 | return 1; |
1106 | } | 1105 | } |
1107 | 1106 | ||
1108 | int | 1107 | static int |
1109 | tlsext_sessionticket_client_build(SSL *s, uint16_t msg_type, CBB *cbb) | 1108 | tlsext_sessionticket_client_build(SSL *s, uint16_t msg_type, CBB *cbb) |
1110 | { | 1109 | { |
1111 | /* | 1110 | /* |
@@ -1148,7 +1147,7 @@ tlsext_sessionticket_client_build(SSL *s, uint16_t msg_type, CBB *cbb) | |||
1148 | return 1; | 1147 | return 1; |
1149 | } | 1148 | } |
1150 | 1149 | ||
1151 | int | 1150 | static int |
1152 | tlsext_sessionticket_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, | 1151 | tlsext_sessionticket_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, |
1153 | int *alert) | 1152 | int *alert) |
1154 | { | 1153 | { |
@@ -1170,7 +1169,7 @@ tlsext_sessionticket_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, | |||
1170 | return 1; | 1169 | return 1; |
1171 | } | 1170 | } |
1172 | 1171 | ||
1173 | int | 1172 | static int |
1174 | tlsext_sessionticket_server_needs(SSL *s, uint16_t msg_type) | 1173 | tlsext_sessionticket_server_needs(SSL *s, uint16_t msg_type) |
1175 | { | 1174 | { |
1176 | return (s->internal->tlsext_ticket_expected && | 1175 | return (s->internal->tlsext_ticket_expected && |
@@ -1178,14 +1177,14 @@ tlsext_sessionticket_server_needs(SSL *s, uint16_t msg_type) | |||
1178 | ssl_security_tickets(s)); | 1177 | ssl_security_tickets(s)); |
1179 | } | 1178 | } |
1180 | 1179 | ||
1181 | int | 1180 | static int |
1182 | tlsext_sessionticket_server_build(SSL *s, uint16_t msg_type, CBB *cbb) | 1181 | tlsext_sessionticket_server_build(SSL *s, uint16_t msg_type, CBB *cbb) |
1183 | { | 1182 | { |
1184 | /* Empty ticket */ | 1183 | /* Empty ticket */ |
1185 | return 1; | 1184 | return 1; |
1186 | } | 1185 | } |
1187 | 1186 | ||
1188 | int | 1187 | static int |
1189 | tlsext_sessionticket_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, | 1188 | tlsext_sessionticket_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, |
1190 | int *alert) | 1189 | int *alert) |
1191 | { | 1190 | { |
@@ -1214,13 +1213,13 @@ tlsext_sessionticket_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, | |||
1214 | 1213 | ||
1215 | #ifndef OPENSSL_NO_SRTP | 1214 | #ifndef OPENSSL_NO_SRTP |
1216 | 1215 | ||
1217 | int | 1216 | static int |
1218 | tlsext_srtp_client_needs(SSL *s, uint16_t msg_type) | 1217 | tlsext_srtp_client_needs(SSL *s, uint16_t msg_type) |
1219 | { | 1218 | { |
1220 | return SSL_is_dtls(s) && SSL_get_srtp_profiles(s) != NULL; | 1219 | return SSL_is_dtls(s) && SSL_get_srtp_profiles(s) != NULL; |
1221 | } | 1220 | } |
1222 | 1221 | ||
1223 | int | 1222 | static int |
1224 | tlsext_srtp_client_build(SSL *s, uint16_t msg_type, CBB *cbb) | 1223 | tlsext_srtp_client_build(SSL *s, uint16_t msg_type, CBB *cbb) |
1225 | { | 1224 | { |
1226 | CBB profiles, mki; | 1225 | CBB profiles, mki; |
@@ -1257,7 +1256,7 @@ tlsext_srtp_client_build(SSL *s, uint16_t msg_type, CBB *cbb) | |||
1257 | return 1; | 1256 | return 1; |
1258 | } | 1257 | } |
1259 | 1258 | ||
1260 | int | 1259 | static int |
1261 | tlsext_srtp_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | 1260 | tlsext_srtp_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) |
1262 | { | 1261 | { |
1263 | const SRTP_PROTECTION_PROFILE *cprof, *sprof; | 1262 | const SRTP_PROTECTION_PROFILE *cprof, *sprof; |
@@ -1332,13 +1331,13 @@ tlsext_srtp_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
1332 | return ret; | 1331 | return ret; |
1333 | } | 1332 | } |
1334 | 1333 | ||
1335 | int | 1334 | static int |
1336 | tlsext_srtp_server_needs(SSL *s, uint16_t msg_type) | 1335 | tlsext_srtp_server_needs(SSL *s, uint16_t msg_type) |
1337 | { | 1336 | { |
1338 | return SSL_is_dtls(s) && SSL_get_selected_srtp_profile(s) != NULL; | 1337 | return SSL_is_dtls(s) && SSL_get_selected_srtp_profile(s) != NULL; |
1339 | } | 1338 | } |
1340 | 1339 | ||
1341 | int | 1340 | static int |
1342 | tlsext_srtp_server_build(SSL *s, uint16_t msg_type, CBB *cbb) | 1341 | tlsext_srtp_server_build(SSL *s, uint16_t msg_type, CBB *cbb) |
1343 | { | 1342 | { |
1344 | SRTP_PROTECTION_PROFILE *profile; | 1343 | SRTP_PROTECTION_PROFILE *profile; |
@@ -1362,7 +1361,7 @@ tlsext_srtp_server_build(SSL *s, uint16_t msg_type, CBB *cbb) | |||
1362 | return 1; | 1361 | return 1; |
1363 | } | 1362 | } |
1364 | 1363 | ||
1365 | int | 1364 | static int |
1366 | tlsext_srtp_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | 1365 | tlsext_srtp_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) |
1367 | { | 1366 | { |
1368 | STACK_OF(SRTP_PROTECTION_PROFILE) *clnt; | 1367 | STACK_OF(SRTP_PROTECTION_PROFILE) *clnt; |
@@ -1415,13 +1414,13 @@ tlsext_srtp_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
1415 | /* | 1414 | /* |
1416 | * TLSv1.3 Key Share - RFC 8446 section 4.2.8. | 1415 | * TLSv1.3 Key Share - RFC 8446 section 4.2.8. |
1417 | */ | 1416 | */ |
1418 | int | 1417 | static int |
1419 | tlsext_keyshare_client_needs(SSL *s, uint16_t msg_type) | 1418 | tlsext_keyshare_client_needs(SSL *s, uint16_t msg_type) |
1420 | { | 1419 | { |
1421 | return (s->s3->hs.our_max_tls_version >= TLS1_3_VERSION); | 1420 | return (s->s3->hs.our_max_tls_version >= TLS1_3_VERSION); |
1422 | } | 1421 | } |
1423 | 1422 | ||
1424 | int | 1423 | static int |
1425 | tlsext_keyshare_client_build(SSL *s, uint16_t msg_type, CBB *cbb) | 1424 | tlsext_keyshare_client_build(SSL *s, uint16_t msg_type, CBB *cbb) |
1426 | { | 1425 | { |
1427 | CBB client_shares, key_exchange; | 1426 | CBB client_shares, key_exchange; |
@@ -1443,7 +1442,7 @@ tlsext_keyshare_client_build(SSL *s, uint16_t msg_type, CBB *cbb) | |||
1443 | return 1; | 1442 | return 1; |
1444 | } | 1443 | } |
1445 | 1444 | ||
1446 | int | 1445 | static int |
1447 | tlsext_keyshare_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | 1446 | tlsext_keyshare_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) |
1448 | { | 1447 | { |
1449 | CBS client_shares, key_exchange; | 1448 | CBS client_shares, key_exchange; |
@@ -1495,14 +1494,14 @@ tlsext_keyshare_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
1495 | return 1; | 1494 | return 1; |
1496 | } | 1495 | } |
1497 | 1496 | ||
1498 | int | 1497 | static int |
1499 | tlsext_keyshare_server_needs(SSL *s, uint16_t msg_type) | 1498 | tlsext_keyshare_server_needs(SSL *s, uint16_t msg_type) |
1500 | { | 1499 | { |
1501 | return (s->s3->hs.negotiated_tls_version >= TLS1_3_VERSION && | 1500 | return (s->s3->hs.negotiated_tls_version >= TLS1_3_VERSION && |
1502 | tlsext_extension_seen(s, TLSEXT_TYPE_key_share)); | 1501 | tlsext_extension_seen(s, TLSEXT_TYPE_key_share)); |
1503 | } | 1502 | } |
1504 | 1503 | ||
1505 | int | 1504 | static int |
1506 | tlsext_keyshare_server_build(SSL *s, uint16_t msg_type, CBB *cbb) | 1505 | tlsext_keyshare_server_build(SSL *s, uint16_t msg_type, CBB *cbb) |
1507 | { | 1506 | { |
1508 | CBB key_exchange; | 1507 | CBB key_exchange; |
@@ -1530,7 +1529,7 @@ tlsext_keyshare_server_build(SSL *s, uint16_t msg_type, CBB *cbb) | |||
1530 | return 1; | 1529 | return 1; |
1531 | } | 1530 | } |
1532 | 1531 | ||
1533 | int | 1532 | static int |
1534 | tlsext_keyshare_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | 1533 | tlsext_keyshare_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) |
1535 | { | 1534 | { |
1536 | CBS key_exchange; | 1535 | CBS key_exchange; |
@@ -1574,13 +1573,13 @@ tlsext_keyshare_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
1574 | /* | 1573 | /* |
1575 | * Supported Versions - RFC 8446 section 4.2.1. | 1574 | * Supported Versions - RFC 8446 section 4.2.1. |
1576 | */ | 1575 | */ |
1577 | int | 1576 | static int |
1578 | tlsext_versions_client_needs(SSL *s, uint16_t msg_type) | 1577 | tlsext_versions_client_needs(SSL *s, uint16_t msg_type) |
1579 | { | 1578 | { |
1580 | return (s->s3->hs.our_max_tls_version >= TLS1_3_VERSION); | 1579 | return (s->s3->hs.our_max_tls_version >= TLS1_3_VERSION); |
1581 | } | 1580 | } |
1582 | 1581 | ||
1583 | int | 1582 | static int |
1584 | tlsext_versions_client_build(SSL *s, uint16_t msg_type, CBB *cbb) | 1583 | tlsext_versions_client_build(SSL *s, uint16_t msg_type, CBB *cbb) |
1585 | { | 1584 | { |
1586 | uint16_t max, min; | 1585 | uint16_t max, min; |
@@ -1605,7 +1604,7 @@ tlsext_versions_client_build(SSL *s, uint16_t msg_type, CBB *cbb) | |||
1605 | return 1; | 1604 | return 1; |
1606 | } | 1605 | } |
1607 | 1606 | ||
1608 | int | 1607 | static int |
1609 | tlsext_versions_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | 1608 | tlsext_versions_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) |
1610 | { | 1609 | { |
1611 | CBS versions; | 1610 | CBS versions; |
@@ -1640,19 +1639,19 @@ tlsext_versions_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
1640 | return 0; | 1639 | return 0; |
1641 | } | 1640 | } |
1642 | 1641 | ||
1643 | int | 1642 | static int |
1644 | tlsext_versions_server_needs(SSL *s, uint16_t msg_type) | 1643 | tlsext_versions_server_needs(SSL *s, uint16_t msg_type) |
1645 | { | 1644 | { |
1646 | return (s->s3->hs.negotiated_tls_version >= TLS1_3_VERSION); | 1645 | return (s->s3->hs.negotiated_tls_version >= TLS1_3_VERSION); |
1647 | } | 1646 | } |
1648 | 1647 | ||
1649 | int | 1648 | static int |
1650 | tlsext_versions_server_build(SSL *s, uint16_t msg_type, CBB *cbb) | 1649 | tlsext_versions_server_build(SSL *s, uint16_t msg_type, CBB *cbb) |
1651 | { | 1650 | { |
1652 | return CBB_add_u16(cbb, TLS1_3_VERSION); | 1651 | return CBB_add_u16(cbb, TLS1_3_VERSION); |
1653 | } | 1652 | } |
1654 | 1653 | ||
1655 | int | 1654 | static int |
1656 | tlsext_versions_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | 1655 | tlsext_versions_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) |
1657 | { | 1656 | { |
1658 | uint16_t selected_version; | 1657 | uint16_t selected_version; |
@@ -1677,14 +1676,14 @@ tlsext_versions_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
1677 | * Cookie - RFC 8446 section 4.2.2. | 1676 | * Cookie - RFC 8446 section 4.2.2. |
1678 | */ | 1677 | */ |
1679 | 1678 | ||
1680 | int | 1679 | static int |
1681 | tlsext_cookie_client_needs(SSL *s, uint16_t msg_type) | 1680 | tlsext_cookie_client_needs(SSL *s, uint16_t msg_type) |
1682 | { | 1681 | { |
1683 | return (s->s3->hs.our_max_tls_version >= TLS1_3_VERSION && | 1682 | return (s->s3->hs.our_max_tls_version >= TLS1_3_VERSION && |
1684 | s->s3->hs.tls13.cookie_len > 0 && s->s3->hs.tls13.cookie != NULL); | 1683 | s->s3->hs.tls13.cookie_len > 0 && s->s3->hs.tls13.cookie != NULL); |
1685 | } | 1684 | } |
1686 | 1685 | ||
1687 | int | 1686 | static int |
1688 | tlsext_cookie_client_build(SSL *s, uint16_t msg_type, CBB *cbb) | 1687 | tlsext_cookie_client_build(SSL *s, uint16_t msg_type, CBB *cbb) |
1689 | { | 1688 | { |
1690 | CBB cookie; | 1689 | CBB cookie; |
@@ -1702,7 +1701,7 @@ tlsext_cookie_client_build(SSL *s, uint16_t msg_type, CBB *cbb) | |||
1702 | return 1; | 1701 | return 1; |
1703 | } | 1702 | } |
1704 | 1703 | ||
1705 | int | 1704 | static int |
1706 | tlsext_cookie_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | 1705 | tlsext_cookie_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) |
1707 | { | 1706 | { |
1708 | CBS cookie; | 1707 | CBS cookie; |
@@ -1728,7 +1727,7 @@ tlsext_cookie_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
1728 | return 1; | 1727 | return 1; |
1729 | } | 1728 | } |
1730 | 1729 | ||
1731 | int | 1730 | static int |
1732 | tlsext_cookie_server_needs(SSL *s, uint16_t msg_type) | 1731 | tlsext_cookie_server_needs(SSL *s, uint16_t msg_type) |
1733 | { | 1732 | { |
1734 | /* | 1733 | /* |
@@ -1739,7 +1738,7 @@ tlsext_cookie_server_needs(SSL *s, uint16_t msg_type) | |||
1739 | s->s3->hs.tls13.cookie_len > 0 && s->s3->hs.tls13.cookie != NULL); | 1738 | s->s3->hs.tls13.cookie_len > 0 && s->s3->hs.tls13.cookie != NULL); |
1740 | } | 1739 | } |
1741 | 1740 | ||
1742 | int | 1741 | static int |
1743 | tlsext_cookie_server_build(SSL *s, uint16_t msg_type, CBB *cbb) | 1742 | tlsext_cookie_server_build(SSL *s, uint16_t msg_type, CBB *cbb) |
1744 | { | 1743 | { |
1745 | CBB cookie; | 1744 | CBB cookie; |
@@ -1759,7 +1758,7 @@ tlsext_cookie_server_build(SSL *s, uint16_t msg_type, CBB *cbb) | |||
1759 | return 1; | 1758 | return 1; |
1760 | } | 1759 | } |
1761 | 1760 | ||
1762 | int | 1761 | static int |
1763 | tlsext_cookie_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | 1762 | tlsext_cookie_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) |
1764 | { | 1763 | { |
1765 | CBS cookie; | 1764 | CBS cookie; |
@@ -1789,14 +1788,14 @@ tlsext_cookie_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
1789 | * Pre-Shared Key Exchange Modes - RFC 8446, 4.2.9. | 1788 | * Pre-Shared Key Exchange Modes - RFC 8446, 4.2.9. |
1790 | */ | 1789 | */ |
1791 | 1790 | ||
1792 | int | 1791 | static int |
1793 | tlsext_psk_kex_modes_client_needs(SSL *s, uint16_t msg_type) | 1792 | tlsext_psk_kex_modes_client_needs(SSL *s, uint16_t msg_type) |
1794 | { | 1793 | { |
1795 | return (s->s3->hs.tls13.use_psk_dhe_ke && | 1794 | return (s->s3->hs.tls13.use_psk_dhe_ke && |
1796 | s->s3->hs.our_max_tls_version >= TLS1_3_VERSION); | 1795 | s->s3->hs.our_max_tls_version >= TLS1_3_VERSION); |
1797 | } | 1796 | } |
1798 | 1797 | ||
1799 | int | 1798 | static int |
1800 | tlsext_psk_kex_modes_client_build(SSL *s, uint16_t msg_type, CBB *cbb) | 1799 | tlsext_psk_kex_modes_client_build(SSL *s, uint16_t msg_type, CBB *cbb) |
1801 | { | 1800 | { |
1802 | CBB ke_modes; | 1801 | CBB ke_modes; |
@@ -1814,7 +1813,7 @@ tlsext_psk_kex_modes_client_build(SSL *s, uint16_t msg_type, CBB *cbb) | |||
1814 | return 1; | 1813 | return 1; |
1815 | } | 1814 | } |
1816 | 1815 | ||
1817 | int | 1816 | static int |
1818 | tlsext_psk_kex_modes_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, | 1817 | tlsext_psk_kex_modes_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, |
1819 | int *alert) | 1818 | int *alert) |
1820 | { | 1819 | { |
@@ -1835,20 +1834,20 @@ tlsext_psk_kex_modes_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, | |||
1835 | return 1; | 1834 | return 1; |
1836 | } | 1835 | } |
1837 | 1836 | ||
1838 | int | 1837 | static int |
1839 | tlsext_psk_kex_modes_server_needs(SSL *s, uint16_t msg_type) | 1838 | tlsext_psk_kex_modes_server_needs(SSL *s, uint16_t msg_type) |
1840 | { | 1839 | { |
1841 | /* Servers MUST NOT send this extension. */ | 1840 | /* Servers MUST NOT send this extension. */ |
1842 | return 0; | 1841 | return 0; |
1843 | } | 1842 | } |
1844 | 1843 | ||
1845 | int | 1844 | static int |
1846 | tlsext_psk_kex_modes_server_build(SSL *s, uint16_t msg_type, CBB *cbb) | 1845 | tlsext_psk_kex_modes_server_build(SSL *s, uint16_t msg_type, CBB *cbb) |
1847 | { | 1846 | { |
1848 | return 0; | 1847 | return 0; |
1849 | } | 1848 | } |
1850 | 1849 | ||
1851 | int | 1850 | static int |
1852 | tlsext_psk_kex_modes_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, | 1851 | tlsext_psk_kex_modes_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, |
1853 | int *alert) | 1852 | int *alert) |
1854 | { | 1853 | { |
@@ -1859,37 +1858,37 @@ tlsext_psk_kex_modes_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, | |||
1859 | * Pre-Shared Key Extension - RFC 8446, 4.2.11 | 1858 | * Pre-Shared Key Extension - RFC 8446, 4.2.11 |
1860 | */ | 1859 | */ |
1861 | 1860 | ||
1862 | int | 1861 | static int |
1863 | tlsext_psk_client_needs(SSL *s, uint16_t msg_type) | 1862 | tlsext_psk_client_needs(SSL *s, uint16_t msg_type) |
1864 | { | 1863 | { |
1865 | return 0; | 1864 | return 0; |
1866 | } | 1865 | } |
1867 | 1866 | ||
1868 | int | 1867 | static int |
1869 | tlsext_psk_client_build(SSL *s, uint16_t msg_type, CBB *cbb) | 1868 | tlsext_psk_client_build(SSL *s, uint16_t msg_type, CBB *cbb) |
1870 | { | 1869 | { |
1871 | return 0; | 1870 | return 0; |
1872 | } | 1871 | } |
1873 | 1872 | ||
1874 | int | 1873 | static int |
1875 | tlsext_psk_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | 1874 | tlsext_psk_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) |
1876 | { | 1875 | { |
1877 | return CBS_skip(cbs, CBS_len(cbs)); | 1876 | return CBS_skip(cbs, CBS_len(cbs)); |
1878 | } | 1877 | } |
1879 | 1878 | ||
1880 | int | 1879 | static int |
1881 | tlsext_psk_server_needs(SSL *s, uint16_t msg_type) | 1880 | tlsext_psk_server_needs(SSL *s, uint16_t msg_type) |
1882 | { | 1881 | { |
1883 | return 0; | 1882 | return 0; |
1884 | } | 1883 | } |
1885 | 1884 | ||
1886 | int | 1885 | static int |
1887 | tlsext_psk_server_build(SSL *s, uint16_t msg_type, CBB *cbb) | 1886 | tlsext_psk_server_build(SSL *s, uint16_t msg_type, CBB *cbb) |
1888 | { | 1887 | { |
1889 | return 0; | 1888 | return 0; |
1890 | } | 1889 | } |
1891 | 1890 | ||
1892 | int | 1891 | static int |
1893 | tlsext_psk_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | 1892 | tlsext_psk_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) |
1894 | { | 1893 | { |
1895 | return CBS_skip(cbs, CBS_len(cbs)); | 1894 | return CBS_skip(cbs, CBS_len(cbs)); |
@@ -1899,13 +1898,13 @@ tlsext_psk_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
1899 | * QUIC transport parameters extension - RFC 9001 section 8.2. | 1898 | * QUIC transport parameters extension - RFC 9001 section 8.2. |
1900 | */ | 1899 | */ |
1901 | 1900 | ||
1902 | int | 1901 | static int |
1903 | tlsext_quic_transport_parameters_client_needs(SSL *s, uint16_t msg_type) | 1902 | tlsext_quic_transport_parameters_client_needs(SSL *s, uint16_t msg_type) |
1904 | { | 1903 | { |
1905 | return SSL_is_quic(s) && s->internal->quic_transport_params_len > 0; | 1904 | return SSL_is_quic(s) && s->internal->quic_transport_params_len > 0; |
1906 | } | 1905 | } |
1907 | 1906 | ||
1908 | int | 1907 | static int |
1909 | tlsext_quic_transport_parameters_client_build(SSL *s, uint16_t msg_type, | 1908 | tlsext_quic_transport_parameters_client_build(SSL *s, uint16_t msg_type, |
1910 | CBB *cbb) | 1909 | CBB *cbb) |
1911 | { | 1910 | { |
@@ -1916,7 +1915,7 @@ tlsext_quic_transport_parameters_client_build(SSL *s, uint16_t msg_type, | |||
1916 | return 1; | 1915 | return 1; |
1917 | } | 1916 | } |
1918 | 1917 | ||
1919 | int | 1918 | static int |
1920 | tlsext_quic_transport_parameters_client_parse(SSL *s, uint16_t msg_type, | 1919 | tlsext_quic_transport_parameters_client_parse(SSL *s, uint16_t msg_type, |
1921 | CBS *cbs, int *alert) | 1920 | CBS *cbs, int *alert) |
1922 | { | 1921 | { |
@@ -1934,13 +1933,13 @@ tlsext_quic_transport_parameters_client_parse(SSL *s, uint16_t msg_type, | |||
1934 | return 1; | 1933 | return 1; |
1935 | } | 1934 | } |
1936 | 1935 | ||
1937 | int | 1936 | static int |
1938 | tlsext_quic_transport_parameters_server_needs(SSL *s, uint16_t msg_type) | 1937 | tlsext_quic_transport_parameters_server_needs(SSL *s, uint16_t msg_type) |
1939 | { | 1938 | { |
1940 | return SSL_is_quic(s) && s->internal->quic_transport_params_len > 0; | 1939 | return SSL_is_quic(s) && s->internal->quic_transport_params_len > 0; |
1941 | } | 1940 | } |
1942 | 1941 | ||
1943 | int | 1942 | static int |
1944 | tlsext_quic_transport_parameters_server_build(SSL *s, uint16_t msg_type, | 1943 | tlsext_quic_transport_parameters_server_build(SSL *s, uint16_t msg_type, |
1945 | CBB *cbb) | 1944 | CBB *cbb) |
1946 | { | 1945 | { |
@@ -1951,7 +1950,7 @@ tlsext_quic_transport_parameters_server_build(SSL *s, uint16_t msg_type, | |||
1951 | return 1; | 1950 | return 1; |
1952 | } | 1951 | } |
1953 | 1952 | ||
1954 | int | 1953 | static int |
1955 | tlsext_quic_transport_parameters_server_parse(SSL *s, uint16_t msg_type, | 1954 | tlsext_quic_transport_parameters_server_parse(SSL *s, uint16_t msg_type, |
1956 | CBS *cbs, int *alert) | 1955 | CBS *cbs, int *alert) |
1957 | { | 1956 | { |
@@ -2233,7 +2232,7 @@ tlsext_extension_seen(SSL *s, uint16_t type) | |||
2233 | return ((s->s3->hs.extensions_seen & (1 << idx)) != 0); | 2232 | return ((s->s3->hs.extensions_seen & (1 << idx)) != 0); |
2234 | } | 2233 | } |
2235 | 2234 | ||
2236 | static const struct tls_extension_funcs * | 2235 | const struct tls_extension_funcs * |
2237 | tlsext_funcs(const struct tls_extension *tlsext, int is_server) | 2236 | tlsext_funcs(const struct tls_extension *tlsext, int is_server) |
2238 | { | 2237 | { |
2239 | if (is_server) | 2238 | if (is_server) |
diff --git a/src/lib/libssl/ssl_tlsext.h b/src/lib/libssl/ssl_tlsext.h index 393ee5d90d..7a41c8095d 100644 --- a/src/lib/libssl/ssl_tlsext.h +++ b/src/lib/libssl/ssl_tlsext.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_tlsext.h,v 1.31 2022/07/20 13:35:05 tb Exp $ */ | 1 | /* $OpenBSD: ssl_tlsext.h,v 1.32 2022/08/04 09:27:36 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2016, 2017 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2016, 2017 Joel Sing <jsing@openbsd.org> |
4 | * Copyright (c) 2017 Doug Hogan <doug@openbsd.org> | 4 | * Copyright (c) 2017 Doug Hogan <doug@openbsd.org> |
@@ -32,138 +32,16 @@ | |||
32 | __BEGIN_HIDDEN_DECLS | 32 | __BEGIN_HIDDEN_DECLS |
33 | 33 | ||
34 | int tlsext_alpn_check_format(CBS *cbs); | 34 | int tlsext_alpn_check_format(CBS *cbs); |
35 | int tlsext_alpn_client_needs(SSL *s, uint16_t msg_type); | ||
36 | int tlsext_alpn_client_build(SSL *s, uint16_t msg_type, CBB *cbb); | ||
37 | int tlsext_alpn_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); | ||
38 | int tlsext_alpn_server_needs(SSL *s, uint16_t msg_type); | ||
39 | int tlsext_alpn_server_build(SSL *s, uint16_t msg_type, CBB *cbb); | ||
40 | int tlsext_alpn_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); | ||
41 | |||
42 | int tlsext_ri_client_needs(SSL *s, uint16_t msg_type); | ||
43 | int tlsext_ri_client_build(SSL *s, uint16_t msg_type, CBB *cbb); | ||
44 | int tlsext_ri_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); | ||
45 | int tlsext_ri_server_needs(SSL *s, uint16_t msg_type); | ||
46 | int tlsext_ri_server_build(SSL *s, uint16_t msg_type, CBB *cbb); | ||
47 | int tlsext_ri_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); | ||
48 | |||
49 | int tlsext_sigalgs_client_needs(SSL *s, uint16_t msg_type); | ||
50 | int tlsext_sigalgs_client_build(SSL *s, uint16_t msg_type, CBB *cbb); | ||
51 | int tlsext_sigalgs_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, | ||
52 | int *alert); | ||
53 | int tlsext_sigalgs_server_needs(SSL *s, uint16_t msg_type); | ||
54 | int tlsext_sigalgs_server_build(SSL *s, uint16_t msg_type, CBB *cbb); | ||
55 | int tlsext_sigalgs_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, | ||
56 | int *alert); | ||
57 | |||
58 | int tlsext_sni_client_needs(SSL *s, uint16_t msg_type); | ||
59 | int tlsext_sni_client_build(SSL *s, uint16_t msg_type, CBB *cbb); | ||
60 | int tlsext_sni_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); | ||
61 | int tlsext_sni_server_needs(SSL *s, uint16_t msg_type); | ||
62 | int tlsext_sni_server_build(SSL *s, uint16_t msg_type, CBB *cbb); | ||
63 | int tlsext_sni_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); | ||
64 | int tlsext_sni_is_valid_hostname(CBS *cbs, int *is_ip); | 35 | int tlsext_sni_is_valid_hostname(CBS *cbs, int *is_ip); |
65 | 36 | ||
66 | int tlsext_supportedgroups_client_needs(SSL *s, uint16_t msg_type); | ||
67 | int tlsext_supportedgroups_client_build(SSL *s, uint16_t msg_type, CBB *cbb); | ||
68 | int tlsext_supportedgroups_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, | ||
69 | int *alert); | ||
70 | int tlsext_supportedgroups_server_needs(SSL *s, uint16_t msg_type); | ||
71 | int tlsext_supportedgroups_server_build(SSL *s, uint16_t msg_type, CBB *cbb); | ||
72 | int tlsext_supportedgroups_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, | ||
73 | int *alert); | ||
74 | |||
75 | int tlsext_ecpf_client_needs(SSL *s, uint16_t msg_type); | ||
76 | int tlsext_ecpf_client_build(SSL *s, uint16_t msg_type, CBB *cbb); | ||
77 | int tlsext_ecpf_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); | ||
78 | int tlsext_ecpf_server_needs(SSL *s, uint16_t msg_type); | ||
79 | int tlsext_ecpf_server_build(SSL *s, uint16_t msg_type, CBB *cbb); | ||
80 | int tlsext_ecpf_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); | ||
81 | |||
82 | int tlsext_ocsp_client_needs(SSL *s, uint16_t msg_type); | ||
83 | int tlsext_ocsp_client_build(SSL *s, uint16_t msg_type, CBB *cbb); | ||
84 | int tlsext_ocsp_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); | ||
85 | int tlsext_ocsp_server_needs(SSL *s, uint16_t msg_type); | ||
86 | int tlsext_ocsp_server_build(SSL *s, uint16_t msg_type, CBB *cbb); | ||
87 | int tlsext_ocsp_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); | ||
88 | |||
89 | int tlsext_sessionticket_client_needs(SSL *s, uint16_t msg_type); | ||
90 | int tlsext_sessionticket_client_build(SSL *s, uint16_t msg_type, CBB *cbb); | ||
91 | int tlsext_sessionticket_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, | ||
92 | int *alert); | ||
93 | int tlsext_sessionticket_server_needs(SSL *s, uint16_t msg_type); | ||
94 | int tlsext_sessionticket_server_build(SSL *s, uint16_t msg_type, CBB *cbb); | ||
95 | int tlsext_sessionticket_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, | ||
96 | int *alert); | ||
97 | |||
98 | int tlsext_versions_client_needs(SSL *s, uint16_t msg_type); | ||
99 | int tlsext_versions_client_build(SSL *s, uint16_t msg_type, CBB *cbb); | ||
100 | int tlsext_versions_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, | ||
101 | int *alert); | ||
102 | int tlsext_versions_server_needs(SSL *s, uint16_t msg_type); | ||
103 | int tlsext_versions_server_build(SSL *s, uint16_t msg_type, CBB *cbb); | ||
104 | int tlsext_versions_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, | ||
105 | int *alert); | ||
106 | |||
107 | int tlsext_keyshare_client_needs(SSL *s, uint16_t msg_type); | ||
108 | int tlsext_keyshare_client_build(SSL *s, uint16_t msg_type, CBB *cbb); | ||
109 | int tlsext_keyshare_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, | ||
110 | int *alert); | ||
111 | int tlsext_keyshare_server_needs(SSL *s, uint16_t msg_type); | ||
112 | int tlsext_keyshare_server_build(SSL *s, uint16_t msg_type, CBB *cbb); | ||
113 | int tlsext_keyshare_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, | ||
114 | int *alert); | ||
115 | |||
116 | int tlsext_cookie_client_needs(SSL *s, uint16_t msg_type); | ||
117 | int tlsext_cookie_client_build(SSL *s, uint16_t msg_type, CBB *cbb); | ||
118 | int tlsext_cookie_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); | ||
119 | int tlsext_cookie_server_needs(SSL *s, uint16_t msg_type); | ||
120 | int tlsext_cookie_server_build(SSL *s, uint16_t msg_type, CBB *cbb); | ||
121 | int tlsext_cookie_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); | ||
122 | |||
123 | int tlsext_psk_kex_modes_client_needs(SSL *s, uint16_t msg_type); | ||
124 | int tlsext_psk_kex_modes_client_build(SSL *s, uint16_t msg_type, CBB *cbb); | ||
125 | int tlsext_psk_kex_modes_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, | ||
126 | int *alert); | ||
127 | int tlsext_psk_kex_modes_server_needs(SSL *s, uint16_t msg_type); | ||
128 | int tlsext_psk_kex_modes_server_build(SSL *s, uint16_t msg_type, CBB *cbb); | ||
129 | int tlsext_psk_kex_modes_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, | ||
130 | int *alert); | ||
131 | |||
132 | int tlsext_psk_client_needs(SSL *s, uint16_t msg_type); | ||
133 | int tlsext_psk_client_build(SSL *s, uint16_t msg_type, CBB *cbb); | ||
134 | int tlsext_psk_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); | ||
135 | int tlsext_psk_server_needs(SSL *s, uint16_t msg_type); | ||
136 | int tlsext_psk_server_build(SSL *s, uint16_t msg_type, CBB *cbb); | ||
137 | int tlsext_psk_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); | ||
138 | |||
139 | #ifndef OPENSSL_NO_SRTP | ||
140 | int tlsext_srtp_client_needs(SSL *s, uint16_t msg_type); | ||
141 | int tlsext_srtp_client_build(SSL *s, uint16_t msg_type, CBB *cbb); | ||
142 | int tlsext_srtp_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); | ||
143 | int tlsext_srtp_server_needs(SSL *s, uint16_t msg_type); | ||
144 | int tlsext_srtp_server_build(SSL *s, uint16_t msg_type, CBB *cbb); | ||
145 | int tlsext_srtp_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); | ||
146 | #endif | ||
147 | |||
148 | int tlsext_quic_transport_parameters_client_needs(SSL *s, uint16_t msg_type); | ||
149 | int tlsext_quic_transport_parameters_client_build(SSL *s, uint16_t msg_type, | ||
150 | CBB *cbb); | ||
151 | int tlsext_quic_transport_parameters_client_parse(SSL *s, uint16_t msg_type, | ||
152 | CBS *cbs, int *alert); | ||
153 | int tlsext_quic_transport_parameters_server_needs(SSL *s, uint16_t msg_type); | ||
154 | int tlsext_quic_transport_parameters_server_build(SSL *s, uint16_t msg_type, | ||
155 | CBB *cbb); | ||
156 | int tlsext_quic_transport_parameters_server_parse(SSL *s, uint16_t msg_type, | ||
157 | CBS *cbs, int *alert); | ||
158 | |||
159 | int tlsext_client_build(SSL *s, uint16_t msg_type, CBB *cbb); | 37 | int tlsext_client_build(SSL *s, uint16_t msg_type, CBB *cbb); |
160 | int tlsext_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); | 38 | int tlsext_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); |
161 | 39 | ||
162 | int tlsext_server_build(SSL *s, uint16_t msg_type, CBB *cbb); | 40 | int tlsext_server_build(SSL *s, uint16_t msg_type, CBB *cbb); |
163 | int tlsext_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); | 41 | int tlsext_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); |
164 | 42 | ||
165 | const struct tls_extension *tls_extension_find(uint16_t, size_t *); | ||
166 | int tlsext_extension_seen(SSL *s, uint16_t); | 43 | int tlsext_extension_seen(SSL *s, uint16_t); |
44 | |||
167 | __END_HIDDEN_DECLS | 45 | __END_HIDDEN_DECLS |
168 | 46 | ||
169 | #endif | 47 | #endif |