]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - secure/lib/libcrypto/man/man3/SSL_extension_supported.3
Merge OpenSSL 1.1.1f.
[FreeBSD/FreeBSD.git] / secure / lib / libcrypto / man / man3 / SSL_extension_supported.3
1 .\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.40)
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sp \" Vertical space (when we can't use .PP)
6 .if t .sp .5v
7 .if n .sp
8 ..
9 .de Vb \" Begin verbatim text
10 .ft CW
11 .nf
12 .ne \\$1
13 ..
14 .de Ve \" End verbatim text
15 .ft R
16 .fi
17 ..
18 .\" Set up some character translations and predefined strings.  \*(-- will
19 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
20 .\" double quote, and \*(R" will give a right double quote.  \*(C+ will
21 .\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
22 .\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
23 .\" nothing in troff, for use with C<>.
24 .tr \(*W-
25 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
26 .ie n \{\
27 .    ds -- \(*W-
28 .    ds PI pi
29 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
30 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
31 .    ds L" ""
32 .    ds R" ""
33 .    ds C` ""
34 .    ds C' ""
35 'br\}
36 .el\{\
37 .    ds -- \|\(em\|
38 .    ds PI \(*p
39 .    ds L" ``
40 .    ds R" ''
41 .    ds C`
42 .    ds C'
43 'br\}
44 .\"
45 .\" Escape single quotes in literal strings from groff's Unicode transform.
46 .ie \n(.g .ds Aq \(aq
47 .el       .ds Aq '
48 .\"
49 .\" If the F register is >0, we'll generate index entries on stderr for
50 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
51 .\" entries marked with X<> in POD.  Of course, you'll have to process the
52 .\" output yourself in some meaningful fashion.
53 .\"
54 .\" Avoid warning from groff about undefined register 'F'.
55 .de IX
56 ..
57 .nr rF 0
58 .if \n(.g .if rF .nr rF 1
59 .if (\n(rF:(\n(.g==0)) \{\
60 .    if \nF \{\
61 .        de IX
62 .        tm Index:\\$1\t\\n%\t"\\$2"
63 ..
64 .        if !\nF==2 \{\
65 .            nr % 0
66 .            nr F 2
67 .        \}
68 .    \}
69 .\}
70 .rr rF
71 .\"
72 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
73 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
74 .    \" fudge factors for nroff and troff
75 .if n \{\
76 .    ds #H 0
77 .    ds #V .8m
78 .    ds #F .3m
79 .    ds #[ \f1
80 .    ds #] \fP
81 .\}
82 .if t \{\
83 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
84 .    ds #V .6m
85 .    ds #F 0
86 .    ds #[ \&
87 .    ds #] \&
88 .\}
89 .    \" simple accents for nroff and troff
90 .if n \{\
91 .    ds ' \&
92 .    ds ` \&
93 .    ds ^ \&
94 .    ds , \&
95 .    ds ~ ~
96 .    ds /
97 .\}
98 .if t \{\
99 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
100 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
101 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
102 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
103 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
104 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
105 .\}
106 .    \" troff and (daisy-wheel) nroff accents
107 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
108 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
109 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
110 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
111 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
112 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
113 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
114 .ds ae a\h'-(\w'a'u*4/10)'e
115 .ds Ae A\h'-(\w'A'u*4/10)'E
116 .    \" corrections for vroff
117 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
118 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
119 .    \" for low resolution devices (crt and lpr)
120 .if \n(.H>23 .if \n(.V>19 \
121 \{\
122 .    ds : e
123 .    ds 8 ss
124 .    ds o a
125 .    ds d- d\h'-1'\(ga
126 .    ds D- D\h'-1'\(hy
127 .    ds th \o'bp'
128 .    ds Th \o'LP'
129 .    ds ae ae
130 .    ds Ae AE
131 .\}
132 .rm #[ #] #H #V #F C
133 .\" ========================================================================
134 .\"
135 .IX Title "SSL_EXTENSION_SUPPORTED 3"
136 .TH SSL_EXTENSION_SUPPORTED 3 "2020-03-31" "1.1.1f" "OpenSSL"
137 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
138 .\" way too many mistakes in technical documents.
139 .if n .ad l
140 .nh
141 .SH "NAME"
142 SSL_extension_supported, SSL_CTX_add_custom_ext, SSL_CTX_add_client_custom_ext, SSL_CTX_add_server_custom_ext, custom_ext_add_cb, custom_ext_free_cb, custom_ext_parse_cb \&\- custom TLS extension handling
143 .SH "SYNOPSIS"
144 .IX Header "SYNOPSIS"
145 .Vb 1
146 \& #include <openssl/ssl.h>
147 \&
148 \& typedef int (*SSL_custom_ext_add_cb_ex) (SSL *s, unsigned int ext_type,
149 \&                                          unsigned int context,
150 \&                                          const unsigned char **out,
151 \&                                          size_t *outlen, X509 *x,
152 \&                                          size_t chainidx, int *al,
153 \&                                          void *add_arg);
154 \&
155 \& typedef void (*SSL_custom_ext_free_cb_ex) (SSL *s, unsigned int ext_type,
156 \&                                            unsigned int context,
157 \&                                            const unsigned char *out,
158 \&                                            void *add_arg);
159 \&
160 \& typedef int (*SSL_custom_ext_parse_cb_ex) (SSL *s, unsigned int ext_type,
161 \&                                            unsigned int context,
162 \&                                            const unsigned char *in,
163 \&                                            size_t inlen, X509 *x,
164 \&                                            size_t chainidx, int *al,
165 \&                                            void *parse_arg);
166 \&
167 \& int SSL_CTX_add_custom_ext(SSL_CTX *ctx, unsigned int ext_type,
168 \&                            unsigned int context,
169 \&                            SSL_custom_ext_add_cb_ex add_cb,
170 \&                            SSL_custom_ext_free_cb_ex free_cb,
171 \&                            void *add_arg,
172 \&                            SSL_custom_ext_parse_cb_ex parse_cb,
173 \&                            void *parse_arg);
174 \&
175 \& typedef int (*custom_ext_add_cb)(SSL *s, unsigned int ext_type,
176 \&                                  const unsigned char **out,
177 \&                                  size_t *outlen, int *al,
178 \&                                  void *add_arg);
179 \&
180 \& typedef void (*custom_ext_free_cb)(SSL *s, unsigned int ext_type,
181 \&                                    const unsigned char *out,
182 \&                                    void *add_arg);
183 \&
184 \& typedef int (*custom_ext_parse_cb)(SSL *s, unsigned int ext_type,
185 \&                                    const unsigned char *in,
186 \&                                    size_t inlen, int *al,
187 \&                                    void *parse_arg);
188 \&
189 \& int SSL_CTX_add_client_custom_ext(SSL_CTX *ctx, unsigned int ext_type,
190 \&                                   custom_ext_add_cb add_cb,
191 \&                                   custom_ext_free_cb free_cb, void *add_arg,
192 \&                                   custom_ext_parse_cb parse_cb,
193 \&                                   void *parse_arg);
194 \&
195 \& int SSL_CTX_add_server_custom_ext(SSL_CTX *ctx, unsigned int ext_type,
196 \&                                   custom_ext_add_cb add_cb,
197 \&                                   custom_ext_free_cb free_cb, void *add_arg,
198 \&                                   custom_ext_parse_cb parse_cb,
199 \&                                   void *parse_arg);
200 \&
201 \& int SSL_extension_supported(unsigned int ext_type);
202 .Ve
203 .SH "DESCRIPTION"
204 .IX Header "DESCRIPTION"
205 \&\fBSSL_CTX_add_custom_ext()\fR adds a custom extension for a \s-1TLS/DTLS\s0 client or server
206 for all supported protocol versions with extension type \fBext_type\fR and
207 callbacks \fBadd_cb\fR, \fBfree_cb\fR and \fBparse_cb\fR (see the
208 \&\*(L"\s-1EXTENSION CALLBACKS\*(R"\s0 section below). The \fBcontext\fR value determines
209 which messages and under what conditions the extension will be added/parsed (see
210 the \*(L"\s-1EXTENSION CONTEXTS\*(R"\s0 section below).
211 .PP
212 \&\fBSSL_CTX_add_client_custom_ext()\fR adds a custom extension for a \s-1TLS/DTLS\s0 client
213 with extension type \fBext_type\fR and callbacks \fBadd_cb\fR, \fBfree_cb\fR and
214 \&\fBparse_cb\fR. This function is similar to \fBSSL_CTX_add_custom_ext()\fR except it only
215 applies to clients, uses the older style of callbacks, and implicitly sets the
216 \&\fBcontext\fR value to:
217 .PP
218 .Vb 2
219 \& SSL_EXT_TLS1_2_AND_BELOW_ONLY | SSL_EXT_CLIENT_HELLO
220 \& | SSL_EXT_TLS1_2_SERVER_HELLO | SSL_EXT_IGNORE_ON_RESUMPTION
221 .Ve
222 .PP
223 \&\fBSSL_CTX_add_server_custom_ext()\fR adds a custom extension for a \s-1TLS/DTLS\s0 server
224 with extension type \fBext_type\fR and callbacks \fBadd_cb\fR, \fBfree_cb\fR and
225 \&\fBparse_cb\fR. This function is similar to \fBSSL_CTX_add_custom_ext()\fR except it
226 only applies to servers, uses the older style of callbacks, and implicitly sets
227 the \fBcontext\fR value to the same as for \fBSSL_CTX_add_client_custom_ext()\fR above.
228 .PP
229 The \fBext_type\fR parameter corresponds to the \fBextension_type\fR field of
230 \&\s-1RFC5246\s0 et al. It is \fBnot\fR a \s-1NID.\s0 In all cases the extension type must not be
231 handled by OpenSSL internally or an error occurs.
232 .PP
233 \&\fBSSL_extension_supported()\fR returns 1 if the extension \fBext_type\fR is handled
234 internally by OpenSSL and 0 otherwise.
235 .SH "EXTENSION CALLBACKS"
236 .IX Header "EXTENSION CALLBACKS"
237 The callback \fBadd_cb\fR is called to send custom extension data to be
238 included in various \s-1TLS\s0 messages. The \fBext_type\fR parameter is set to the
239 extension type which will be added and \fBadd_arg\fR to the value set when the
240 extension handler was added. When using the new style callbacks the \fBcontext\fR
241 parameter will indicate which message is currently being constructed e.g. for
242 the ClientHello it will be set to \fB\s-1SSL_EXT_CLIENT_HELLO\s0\fR.
243 .PP
244 If the application wishes to include the extension \fBext_type\fR it should
245 set \fB*out\fR to the extension data, set \fB*outlen\fR to the length of the
246 extension data and return 1.
247 .PP
248 If the \fBadd_cb\fR does not wish to include the extension it must return 0.
249 .PP
250 If \fBadd_cb\fR returns \-1 a fatal handshake error occurs using the \s-1TLS\s0
251 alert value specified in \fB*al\fR.
252 .PP
253 When constructing the ClientHello, if \fBadd_cb\fR is set to \s-1NULL\s0 a zero length
254 extension is added for \fBext_type\fR. For all other messages if \fBadd_cb\fR is set
255 to \s-1NULL\s0 then no extension is added.
256 .PP
257 When constructing a Certificate message the callback will be called for each
258 certificate in the message. The \fBx\fR parameter will indicate the
259 current certificate and the \fBchainidx\fR parameter will indicate the position
260 of the certificate in the message. The first certificate is always the end
261 entity certificate and has a \fBchainidx\fR value of 0. The certificates are in the
262 order that they were received in the Certificate message.
263 .PP
264 For all messages except the ServerHello and EncryptedExtensions every
265 registered \fBadd_cb\fR is always called to see if the application wishes to add an
266 extension (as long as all requirements of the specified \fBcontext\fR are met).
267 .PP
268 For the ServerHello and EncryptedExtension messages every registered \fBadd_cb\fR
269 is called once if and only if the requirements of the specified \fBcontext\fR are
270 met and the corresponding extension was received in the ClientHello. That is, if
271 no corresponding extension was received in the ClientHello then \fBadd_cb\fR will
272 not be called.
273 .PP
274 If an extension is added (that is \fBadd_cb\fR returns 1) \fBfree_cb\fR is called
275 (if it is set) with the value of \fBout\fR set by the add callback. It can be
276 used to free up any dynamic extension data set by \fBadd_cb\fR. Since \fBout\fR is
277 constant (to permit use of constant data in \fBadd_cb\fR) applications may need to
278 cast away const to free the data.
279 .PP
280 The callback \fBparse_cb\fR receives data for \s-1TLS\s0 extensions. The callback is only
281 called if the extension is present and relevant for the context (see
282 \&\*(L"\s-1EXTENSION CONTEXTS\*(R"\s0 below).
283 .PP
284 The extension data consists of \fBinlen\fR bytes in the buffer \fBin\fR for the
285 extension \fBext_type\fR.
286 .PP
287 If the message being parsed is a TLSv1.3 compatible Certificate message then
288 \&\fBparse_cb\fR will be called for each certificate contained within the message.
289 The \fBx\fR parameter will indicate the current certificate and the \fBchainidx\fR
290 parameter will indicate the position of the certificate in the message. The
291 first certificate is always the end entity certificate and has a \fBchainidx\fR
292 value of 0.
293 .PP
294 If the \fBparse_cb\fR considers the extension data acceptable it must return
295 1. If it returns 0 or a negative value a fatal handshake error occurs
296 using the \s-1TLS\s0 alert value specified in \fB*al\fR.
297 .PP
298 The buffer \fBin\fR is a temporary internal buffer which will not be valid after
299 the callback returns.
300 .SH "EXTENSION CONTEXTS"
301 .IX Header "EXTENSION CONTEXTS"
302 An extension context defines which messages and under which conditions an
303 extension should be added or expected. The context is built up by performing
304 a bitwise \s-1OR\s0 of multiple pre-defined values together. The valid context values
305 are:
306 .IP "\s-1SSL_EXT_TLS_ONLY\s0" 4
307 .IX Item "SSL_EXT_TLS_ONLY"
308 The extension is only allowed in \s-1TLS\s0
309 .IP "\s-1SSL_EXT_DTLS_ONLY\s0" 4
310 .IX Item "SSL_EXT_DTLS_ONLY"
311 The extension is only allowed in \s-1DTLS\s0
312 .IP "\s-1SSL_EXT_TLS_IMPLEMENTATION_ONLY\s0" 4
313 .IX Item "SSL_EXT_TLS_IMPLEMENTATION_ONLY"
314 The extension is allowed in \s-1DTLS,\s0 but there is only a \s-1TLS\s0 implementation
315 available (so it is ignored in \s-1DTLS\s0).
316 .IP "\s-1SSL_EXT_SSL3_ALLOWED\s0" 4
317 .IX Item "SSL_EXT_SSL3_ALLOWED"
318 Extensions are not typically defined for SSLv3. Setting this value will allow
319 the extension in SSLv3. Applications will not typically need to use this.
320 .IP "\s-1SSL_EXT_TLS1_2_AND_BELOW_ONLY\s0" 4
321 .IX Item "SSL_EXT_TLS1_2_AND_BELOW_ONLY"
322 The extension is only defined for TLSv1.2/DTLSv1.2 and below. Servers will
323 ignore this extension if it is present in the ClientHello and TLSv1.3 is
324 negotiated.
325 .IP "\s-1SSL_EXT_TLS1_3_ONLY\s0" 4
326 .IX Item "SSL_EXT_TLS1_3_ONLY"
327 The extension is only defined for \s-1TLS1.3\s0 and above. Servers will ignore this
328 extension if it is present in the ClientHello and TLSv1.2 or below is
329 negotiated.
330 .IP "\s-1SSL_EXT_IGNORE_ON_RESUMPTION\s0" 4
331 .IX Item "SSL_EXT_IGNORE_ON_RESUMPTION"
332 The extension will be ignored during parsing if a previous session is being
333 successfully resumed.
334 .IP "\s-1SSL_EXT_CLIENT_HELLO\s0" 4
335 .IX Item "SSL_EXT_CLIENT_HELLO"
336 The extension may be present in the ClientHello message.
337 .IP "\s-1SSL_EXT_TLS1_2_SERVER_HELLO\s0" 4
338 .IX Item "SSL_EXT_TLS1_2_SERVER_HELLO"
339 The extension may be present in a TLSv1.2 or below compatible ServerHello
340 message.
341 .IP "\s-1SSL_EXT_TLS1_3_SERVER_HELLO\s0" 4
342 .IX Item "SSL_EXT_TLS1_3_SERVER_HELLO"
343 The extension may be present in a TLSv1.3 compatible ServerHello message.
344 .IP "\s-1SSL_EXT_TLS1_3_ENCRYPTED_EXTENSIONS\s0" 4
345 .IX Item "SSL_EXT_TLS1_3_ENCRYPTED_EXTENSIONS"
346 The extension may be present in an EncryptedExtensions message.
347 .IP "\s-1SSL_EXT_TLS1_3_HELLO_RETRY_REQUEST\s0" 4
348 .IX Item "SSL_EXT_TLS1_3_HELLO_RETRY_REQUEST"
349 The extension may be present in a HelloRetryRequest message.
350 .IP "\s-1SSL_EXT_TLS1_3_CERTIFICATE\s0" 4
351 .IX Item "SSL_EXT_TLS1_3_CERTIFICATE"
352 The extension may be present in a TLSv1.3 compatible Certificate message.
353 .IP "\s-1SSL_EXT_TLS1_3_NEW_SESSION_TICKET\s0" 4
354 .IX Item "SSL_EXT_TLS1_3_NEW_SESSION_TICKET"
355 The extension may be present in a TLSv1.3 compatible NewSessionTicket message.
356 .IP "\s-1SSL_EXT_TLS1_3_CERTIFICATE_REQUEST\s0" 4
357 .IX Item "SSL_EXT_TLS1_3_CERTIFICATE_REQUEST"
358 The extension may be present in a TLSv1.3 compatible CertificateRequest message.
359 .PP
360 The context must include at least one message value (otherwise the extension
361 will never be used).
362 .SH "NOTES"
363 .IX Header "NOTES"
364 The \fBadd_arg\fR and \fBparse_arg\fR parameters can be set to arbitrary values
365 which will be passed to the corresponding callbacks. They can, for example,
366 be used to store the extension data received in a convenient structure or
367 pass the extension data to be added or freed when adding extensions.
368 .PP
369 If the same custom extension type is received multiple times a fatal
370 \&\fBdecode_error\fR alert is sent and the handshake aborts. If a custom extension
371 is received in a ServerHello/EncryptedExtensions message which was not sent in
372 the ClientHello a fatal \fBunsupported_extension\fR alert is sent and the
373 handshake is aborted. The ServerHello/EncryptedExtensions \fBadd_cb\fR callback is
374 only called if the corresponding extension was received in the ClientHello. This
375 is compliant with the \s-1TLS\s0 specifications. This behaviour ensures that each
376 callback is called at most once and that an application can never send
377 unsolicited extensions.
378 .SH "RETURN VALUES"
379 .IX Header "RETURN VALUES"
380 \&\fBSSL_CTX_add_custom_ext()\fR, \fBSSL_CTX_add_client_custom_ext()\fR and
381 \&\fBSSL_CTX_add_server_custom_ext()\fR return 1 for success and 0 for failure. A
382 failure can occur if an attempt is made to add the same \fBext_type\fR more than
383 once, if an attempt is made to use an extension type handled internally by
384 OpenSSL or if an internal error occurs (for example a memory allocation
385 failure).
386 .PP
387 \&\fBSSL_extension_supported()\fR returns 1 if the extension \fBext_type\fR is handled
388 internally by OpenSSL and 0 otherwise.
389 .SH "HISTORY"
390 .IX Header "HISTORY"
391 The \fBSSL_CTX_add_custom_ext()\fR function was added in OpenSSL 1.1.1.
392 .SH "COPYRIGHT"
393 .IX Header "COPYRIGHT"
394 Copyright 2014\-2017 The OpenSSL Project Authors. All Rights Reserved.
395 .PP
396 Licensed under the OpenSSL license (the \*(L"License\*(R").  You may not use
397 this file except in compliance with the License.  You can obtain a copy
398 in the file \s-1LICENSE\s0 in the source distribution or at
399 <https://www.openssl.org/source/license.html>.