1 /* $OpenBSD: ssl_tlsext.h,v 1.25 2020/07/03 04:51:59 tb Exp $ */ 2 /* 3 * Copyright (c) 2016, 2017 Joel Sing <jsing@openbsd.org> 4 * Copyright (c) 2017 Doug Hogan <doug@openbsd.org> 5 * Copyright (c) 2019 Bob Beck <beck@openbsd.org> 6 * 7 * Permission to use, copy, modify, and distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above 9 * copyright notice and this permission notice appear in all copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 #ifndef HEADER_SSL_TLSEXT_H 21 #define HEADER_SSL_TLSEXT_H 22 23 /* TLSv1.3 - RFC 8446 Section 4.2. */ 24 #define SSL_TLSEXT_MSG_CH 0x0001 /* ClientHello */ 25 #define SSL_TLSEXT_MSG_SH 0x0002 /* ServerHello */ 26 #define SSL_TLSEXT_MSG_EE 0x0004 /* EncryptedExtension */ 27 #define SSL_TLSEXT_MSG_CT 0x0008 /* Certificate */ 28 #define SSL_TLSEXT_MSG_CR 0x0010 /* CertificateRequest */ 29 #define SSL_TLSEXT_MSG_NST 0x0020 /* NewSessionTicket */ 30 #define SSL_TLSEXT_MSG_HRR 0x0040 /* HelloRetryRequest */ 31 32 __BEGIN_HIDDEN_DECLS 33 34 int tlsext_alpn_client_needs(SSL *s, uint16_t msg_type); 35 int tlsext_alpn_client_build(SSL *s, uint16_t msg_type, CBB *cbb); 36 int tlsext_alpn_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); 37 int tlsext_alpn_server_needs(SSL *s, uint16_t msg_type); 38 int tlsext_alpn_server_build(SSL *s, uint16_t msg_type, CBB *cbb); 39 int tlsext_alpn_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); 40 41 int tlsext_ri_client_needs(SSL *s, uint16_t msg_type); 42 int tlsext_ri_client_build(SSL *s, uint16_t msg_type, CBB *cbb); 43 int tlsext_ri_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); 44 int tlsext_ri_server_needs(SSL *s, uint16_t msg_type); 45 int tlsext_ri_server_build(SSL *s, uint16_t msg_type, CBB *cbb); 46 int tlsext_ri_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); 47 48 int tlsext_sigalgs_client_needs(SSL *s, uint16_t msg_type); 49 int tlsext_sigalgs_client_build(SSL *s, uint16_t msg_type, CBB *cbb); 50 int tlsext_sigalgs_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, 51 int *alert); 52 int tlsext_sigalgs_server_needs(SSL *s, uint16_t msg_type); 53 int tlsext_sigalgs_server_build(SSL *s, uint16_t msg_type, CBB *cbb); 54 int tlsext_sigalgs_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, 55 int *alert); 56 57 int tlsext_sni_client_needs(SSL *s, uint16_t msg_type); 58 int tlsext_sni_client_build(SSL *s, uint16_t msg_type, CBB *cbb); 59 int tlsext_sni_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); 60 int tlsext_sni_server_needs(SSL *s, uint16_t msg_type); 61 int tlsext_sni_server_build(SSL *s, uint16_t msg_type, CBB *cbb); 62 int tlsext_sni_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); 63 int tlsext_sni_is_valid_hostname(CBS *cbs); 64 65 int tlsext_supportedgroups_client_needs(SSL *s, uint16_t msg_type); 66 int tlsext_supportedgroups_client_build(SSL *s, uint16_t msg_type, CBB *cbb); 67 int tlsext_supportedgroups_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, 68 int *alert); 69 int tlsext_supportedgroups_server_needs(SSL *s, uint16_t msg_type); 70 int tlsext_supportedgroups_server_build(SSL *s, uint16_t msg_type, CBB *cbb); 71 int tlsext_supportedgroups_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, 72 int *alert); 73 74 int tlsext_ecpf_client_needs(SSL *s, uint16_t msg_type); 75 int tlsext_ecpf_client_build(SSL *s, uint16_t msg_type, CBB *cbb); 76 int tlsext_ecpf_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); 77 int tlsext_ecpf_server_needs(SSL *s, uint16_t msg_type); 78 int tlsext_ecpf_server_build(SSL *s, uint16_t msg_type, CBB *cbb); 79 int tlsext_ecpf_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); 80 81 int tlsext_ocsp_client_needs(SSL *s, uint16_t msg_type); 82 int tlsext_ocsp_client_build(SSL *s, uint16_t msg_type, CBB *cbb); 83 int tlsext_ocsp_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); 84 int tlsext_ocsp_server_needs(SSL *s, uint16_t msg_type); 85 int tlsext_ocsp_server_build(SSL *s, uint16_t msg_type, CBB *cbb); 86 int tlsext_ocsp_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); 87 88 int tlsext_sessionticket_client_needs(SSL *s, uint16_t msg_type); 89 int tlsext_sessionticket_client_build(SSL *s, uint16_t msg_type, CBB *cbb); 90 int tlsext_sessionticket_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, 91 int *alert); 92 int tlsext_sessionticket_server_needs(SSL *s, uint16_t msg_type); 93 int tlsext_sessionticket_server_build(SSL *s, uint16_t msg_type, CBB *cbb); 94 int tlsext_sessionticket_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, 95 int *alert); 96 97 int tlsext_versions_client_needs(SSL *s, uint16_t msg_type); 98 int tlsext_versions_client_build(SSL *s, uint16_t msg_type, CBB *cbb); 99 int tlsext_versions_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, 100 int *alert); 101 int tlsext_versions_server_needs(SSL *s, uint16_t msg_type); 102 int tlsext_versions_server_build(SSL *s, uint16_t msg_type, CBB *cbb); 103 int tlsext_versions_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, 104 int *alert); 105 106 int tlsext_keyshare_client_needs(SSL *s, uint16_t msg_type); 107 int tlsext_keyshare_client_build(SSL *s, uint16_t msg_type, CBB *cbb); 108 int tlsext_keyshare_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, 109 int *alert); 110 int tlsext_keyshare_server_needs(SSL *s, uint16_t msg_type); 111 int tlsext_keyshare_server_build(SSL *s, uint16_t msg_type, CBB *cbb); 112 int tlsext_keyshare_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, 113 int *alert); 114 115 int tlsext_cookie_client_needs(SSL *s, uint16_t msg_type); 116 int tlsext_cookie_client_build(SSL *s, uint16_t msg_type, CBB *cbb); 117 int tlsext_cookie_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); 118 int tlsext_cookie_server_needs(SSL *s, uint16_t msg_type); 119 int tlsext_cookie_server_build(SSL *s, uint16_t msg_type, CBB *cbb); 120 int tlsext_cookie_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); 121 122 #ifndef OPENSSL_NO_SRTP 123 int tlsext_srtp_client_needs(SSL *s, uint16_t msg_type); 124 int tlsext_srtp_client_build(SSL *s, uint16_t msg_type, CBB *cbb); 125 int tlsext_srtp_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); 126 int tlsext_srtp_server_needs(SSL *s, uint16_t msg_type); 127 int tlsext_srtp_server_build(SSL *s, uint16_t msg_type, CBB *cbb); 128 int tlsext_srtp_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); 129 #endif 130 131 int tlsext_client_build(SSL *s, uint16_t msg_type, CBB *cbb); 132 int tlsext_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); 133 134 int tlsext_server_build(SSL *s, uint16_t msg_type, CBB *cbb); 135 int tlsext_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert); 136 137 struct tls_extension *tls_extension_find(uint16_t, size_t *); 138 int tlsext_extension_seen(SSL *s, uint16_t); 139 __END_HIDDEN_DECLS 140 141 #endif 142