summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorschwarze <>2016-12-01 21:12:49 +0000
committerschwarze <>2016-12-01 21:12:49 +0000
commite53fcf2ef6fbb38de4669f45977b6eff4ef3b901 (patch)
tree469d04aa8e29969dd419aa4353f107b81a8d4192 /src
parent62bf07b97b085243d121193f754f99572c04fee4 (diff)
downloadopenbsd-e53fcf2ef6fbb38de4669f45977b6eff4ef3b901.tar.gz
openbsd-e53fcf2ef6fbb38de4669f45977b6eff4ef3b901.tar.bz2
openbsd-e53fcf2ef6fbb38de4669f45977b6eff4ef3b901.zip
import tlsext documentation from OpenSSL
Diffstat (limited to 'src')
-rw-r--r--src/lib/libssl/man/Makefile4
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_tlsext_status_cb.3166
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_tlsext_ticket_key_cb.3295
3 files changed, 464 insertions, 1 deletions
diff --git a/src/lib/libssl/man/Makefile b/src/lib/libssl/man/Makefile
index 57332ab32f..c2176f1022 100644
--- a/src/lib/libssl/man/Makefile
+++ b/src/lib/libssl/man/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.43 2016/12/01 19:40:05 schwarze Exp $ 1# $OpenBSD: Makefile,v 1.44 2016/12/01 21:12:49 schwarze Exp $
2 2
3.include <bsd.own.mk> 3.include <bsd.own.mk>
4 4
@@ -39,6 +39,8 @@ MAN = BIO_f_ssl.3 \
39 SSL_CTX_set_session_id_context.3 \ 39 SSL_CTX_set_session_id_context.3 \
40 SSL_CTX_set_ssl_version.3 \ 40 SSL_CTX_set_ssl_version.3 \
41 SSL_CTX_set_timeout.3 \ 41 SSL_CTX_set_timeout.3 \
42 SSL_CTX_set_tlsext_status_cb.3 \
43 SSL_CTX_set_tlsext_ticket_key_cb.3 \
42 SSL_CTX_set_tmp_dh_callback.3 \ 44 SSL_CTX_set_tmp_dh_callback.3 \
43 SSL_CTX_set_tmp_rsa_callback.3 \ 45 SSL_CTX_set_tmp_rsa_callback.3 \
44 SSL_CTX_set_verify.3 \ 46 SSL_CTX_set_verify.3 \
diff --git a/src/lib/libssl/man/SSL_CTX_set_tlsext_status_cb.3 b/src/lib/libssl/man/SSL_CTX_set_tlsext_status_cb.3
new file mode 100644
index 0000000000..7fdd816cc3
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_set_tlsext_status_cb.3
@@ -0,0 +1,166 @@
1.\" $OpenBSD: SSL_CTX_set_tlsext_status_cb.3,v 1.1 2016/12/01 21:12:49 schwarze Exp $
2.\" OpenSSL 43c34894 Nov 30 16:04:51 2015 +0000
3.\"
4.\" This file was written by Matt Caswell <matt@openssl.org>.
5.\" Copyright (c) 2015 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: December 1 2016 $
52.Dt SSL_CTX_SET_TLSEXT_STATUS_CB 3
53.Os
54.Sh NAME
55.Nm SSL_CTX_set_tlsext_status_cb ,
56.Nm SSL_CTX_set_tlsext_status_arg ,
57.Nm SSL_set_tlsext_status_type ,
58.Nm SSL_get_tlsext_status_ocsp_resp ,
59.Nm SSL_set_tlsext_status_ocsp_resp
60.Nd OCSP Certificate Status Request functions
61.Sh SYNOPSIS
62.In openssl/tls1.h
63.Ft long
64.Fo SSL_CTX_set_tlsext_status_cb
65.Fa "SSL_CTX *ctx"
66.Fa "int (*callback)(SSL *, void *)"
67.Fc
68.Ft long
69.Fo SSL_CTX_set_tlsext_status_arg
70.Fa "SSL_CTX *ctx"
71.Fa "void *arg"
72.Fc
73.Ft long
74.Fo SSL_set_tlsext_status_type
75.Fa "SSL *s"
76.Fa "int type"
77.Fc
78.Ft long
79.Fo SSL_get_tlsext_status_ocsp_resp
80.Fa ssl
81.Fa "unsigned char **resp"
82.Fc
83.Ft long
84.Fo SSL_set_tlsext_status_ocsp_resp
85.Fa ssl
86.Fa "unsigned char *resp"
87.Fa "int len"
88.Fc
89.Sh DESCRIPTION
90A client application may request that a server send back an OCSP status
91response (also known as OCSP stapling).
92To do so the client should call the
93.Fn SSL_set_tlsext_status_type
94function on an individual
95.Vt SSL
96object prior to the start of the handshake.
97Currently the only supported type is
98.Dv TLSEXT_STATUSTYPE_ocsp .
99This value should be passed in the
100.Fa type
101argument.
102.Pp
103The client should additionally provide a callback function to decide
104what to do with the returned OCSP response by calling
105.Fn SSL_CTX_set_tlsext_status_cb .
106The callback function should determine whether the returned OCSP
107response is acceptable or not.
108The callback will be passed as an argument the value previously set via
109a call to
110.Fn SSL_CTX_set_tlsext_status_arg .
111Note that the callback will not be called in the event of a handshake
112where session resumption occurs (because there are no Certificates
113exchanged in such a handshake).
114.Pp
115The response returned by the server can be obtained via a call to
116.Fn SSL_get_tlsext_status_ocsp_resp .
117The value
118.Pf * Fa resp
119will be updated to point to the OCSP response data and the return value
120will be the length of that data.
121If the server has not provided any response data, then
122.Pf * Fa resp
123will be
124.Dv NULL
125and the return value from
126.Fn SSL_get_tlsext_status_ocsp_resp
127will be -1.
128.Pp
129A server application must also call the
130.Fn SSL_CTX_set_tlsext_status_cb
131function if it wants to be able to provide clients with OCSP Certificate
132Status responses.
133Typically the server callback would obtain the server certificate that
134is being sent back to the client via a call to
135.Xr SSL_get_certificate 3 ,
136obtain the OCSP response to be sent back, and then set that response
137data by calling
138.Fn SSL_set_tlsext_status_ocsp_resp .
139A pointer to the response data should be provided in the
140.Fa resp
141argument, and the length of that data should be in the
142.Fa len
143argument.
144.Sh RETURN VALUES
145The callback when used on the client side should return a negative
146value on error, 0 if the response is not acceptable (in which case
147the handshake will fail), or a positive value if it is acceptable.
148.Pp
149The callback when used on the server side should return with either
150.Dv SSL_TLSEXT_ERR_OK
151(meaning that the OCSP response that has been set should be returned),
152.Dv SSL_TLSEXT_ERR_NOACK
153(meaning that an OCSP response should not be returned), or
154.Dv SSL_TLSEXT_ERR_ALERT_FATAL
155(meaning that a fatal error has occurred).
156.Pp
157.Fn SSL_CTX_set_tlsext_status_cb ,
158.Fn SSL_CTX_set_tlsext_status_arg ,
159.Fn SSL_set_tlsext_status_type ,
160and
161.Fn SSL_set_tlsext_status_ocsp_resp
162return 0 on error or 1 on success.
163.Pp
164.Fn SSL_get_tlsext_status_ocsp_resp
165returns the length of the OCSP response data or -1 if there is no OCSP
166response data.
diff --git a/src/lib/libssl/man/SSL_CTX_set_tlsext_ticket_key_cb.3 b/src/lib/libssl/man/SSL_CTX_set_tlsext_ticket_key_cb.3
new file mode 100644
index 0000000000..5009f29858
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_set_tlsext_ticket_key_cb.3
@@ -0,0 +1,295 @@
1.\" $OpenBSD: SSL_CTX_set_tlsext_ticket_key_cb.3,v 1.1 2016/12/01 21:12:49 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Rich Salz <rsalz@akamai.com>
5.\" Copyright (c) 2014, 2015, 2016 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: December 1 2016 $
52.Dt SSL_CTX_SET_TLSEXT_TICKET_KEY_CB 3
53.Os
54.Sh NAME
55.Nm SSL_CTX_set_tlsext_ticket_key_cb
56.Nd set a callback for session ticket processing
57.Sh SYNOPSIS
58.In openssl/tls1.h
59.Ft long
60.Fo SSL_CTX_set_tlsext_ticket_key_cb
61.Fa "SSL_CTX sslctx"
62.Fa "int (*cb)(SSL *s, unsigned char key_name[16],\
63 unsigned char iv[EVP_MAX_IV_LENGTH],\
64 EVP_CIPHER_CTX *ctx, HMAC_CTX *hctx, int enc)"
65.Fc
66.Sh DESCRIPTION
67.Fn SSL_CTX_set_tlsext_ticket_key_cb
68sets a callback function
69.Fa cb
70for handling session tickets for the ssl context
71.Fa sslctx .
72Session tickets, defined in RFC5077, provide an enhanced session
73resumption capability where the server implementation is not required to
74maintain per session state.
75.Pp
76The callback function
77.Fa cb
78will be called for every client instigated TLS session when session
79ticket extension is presented in the TLS hello message.
80It is the responsibility of this function to create or retrieve the
81cryptographic parameters and to maintain their state.
82.Pp
83The OpenSSL library uses the callback function to help implement a
84common TLS ticket construction state according to RFC5077 Section 4 such
85that per session state is unnecessary and a small set of cryptographic
86variables needs to be maintained by the callback function
87implementation.
88.Pp
89In order to reuse a session, a TLS client must send the a session ticket
90extension to the server.
91The client can only send exactly one session ticket.
92The server, through the callback function, either agrees to reuse the
93session ticket information or it starts a full TLS handshake to create a
94new session ticket.
95.Pp
96Before the callback function is started,
97.Fa ctx
98and
99.Fa hctx
100have been initialised with
101.Xr EVP_CIPHER_CTX_init 3
102and
103.Xr HMAC_CTX_init 3 ,
104respectively.
105.Pp
106For new sessions tickets, when the client doesn't present a session
107ticket, or an attempted retrieval of the ticket failed, or a renew
108option was indicated, the callback function will be called with
109.Fa enc
110equal to 1.
111The OpenSSL library expects that the function will set an arbitrary
112.Fa key_name ,
113initialize
114.Fa iv ,
115and set the cipher context
116.Fa ctx
117and the hash context
118.Fa hctx .
119.Pp
120The
121.Fa key_name
122is 16 characters long and is used as a key identifier.
123.Pp
124The
125.Fa iv
126length is the length of the IV of the corresponding cipher.
127The maximum IV length is
128.Dv EVP_MAX_IV_LENGTH
129bytes defined in
130.In opsenssl/evp.h .
131.Pp
132The initialization vector
133.Fa iv
134should be a random value.
135The cipher context
136.Fa ctx
137should use the initialisation vector
138.Fa iv .
139The cipher context can be set using
140.Xr EVP_EncryptInit_ex 3 .
141The hmac context can be set using
142.Xr HMAC_Init_ex 3 .
143.Pp
144When the client presents a session ticket, the callback function
145with be called with
146.Fa enc
147set to 0 indicating that the
148.Fa cb
149function should retrieve a set of parameters.
150In this case
151.Fa key_name
152and
153.Fa iv
154have already been parsed out of the session ticket.
155The OpenSSL library expects that the
156.Em key_name
157will be used to retrieve a cryptographic parameters and that the
158cryptographic context
159.Fa ctx
160will be set with the retrieved parameters and the initialization vector
161.Fa iv
162using a function like
163.Xr EVP_DecryptInit_ex 3 .
164The
165.Fa hctx
166needs to be set using
167.Xr HMAC_Init_ex 3 .
168.Pp
169If the
170.Fa key_name
171is still valid but a renewal of the ticket is required, the callback
172function should return 2.
173The library will call the callback again with an argument of
174.Fa enc
175equal to 1 to set the new ticket.
176.Pp
177The return value of the
178.Fa cb
179function is used by OpenSSL to determine what further processing will
180occur.
181The following return values have meaning:
182.Bl -tag -width Ds
183.It 2
184This indicates that the
185.Fa ctx
186and
187.Fa hctx
188have been set and the session can continue on those parameters.
189Additionally it indicates that the session ticket is in a renewal period
190and should be replaced.
191The OpenSSL library will call
192.Fa cb
193again with an
194.Fa enc
195argument of 1 to set the new ticket (see RFC5077 3.3 paragraph 2).
196.It 1
197This indicates that the
198.Fa ctx
199and
200.Fa hctx
201have been set and the session can continue on those parameters.
202.It 0
203This indicates that it was not possible to set/retrieve a session ticket
204and the SSL/TLS session will continue by negotiating a set of
205cryptographic parameters or using the alternate SSL/TLS resumption
206mechanism, session ids.
207.Pp
208If called with
209.Fa enc
210equal to 0, the library will call the
211.Fa cb
212again to get a new set of parameters.
213.It less than 0
214This indicates an error.
215.El
216.Pp
217Session resumption shortcuts the TLS so that the client certificate
218negotiation don't occur.
219It makes up for this by storing client certificate and all other
220negotiated state information encrypted within the ticket.
221In a resumed session the applications will have all this state
222information available exactly as if a full negotiation had occurred.
223.Pp
224If an attacker can obtain the key used to encrypt a session ticket, they
225can obtain the master secret for any ticket using that key and decrypt
226any traffic using that session: even if the ciphersuite supports forward
227secrecy.
228As a result applications may wish to use multiple keys and avoid using
229long term keys stored in files.
230.Pp
231Applications can use longer keys to maintain a consistent level of
232security.
233For example if a ciphersuite uses 256 bit ciphers but only a 128 bit
234ticket key the overall security is only 128 bits because breaking the
235ticket key will enable an attacker to obtain the session keys.
236.Sh RETURN VALUES
237This function returns 0 to indicate that the callback function was set.
238.Sh EXAMPLES
239Reference Implementation:
240.Bd -literal
241SSL_CTX_set_tlsext_ticket_key_cb(SSL, ssl_tlsext_ticket_key_cb);
242\&....
243static int ssl_tlsext_ticket_key_cb(SSL *s, unsigned char key_name[16],
244 unsigned char *iv, EVP_CIPHER_CTX *ctx, HMAC_CTX *hctx, int enc)
245{
246 if (enc) { /* create new session */
247 if (RAND_bytes(iv, EVP_MAX_IV_LENGTH))
248 return -1; /* insufficient random */
249
250 key = currentkey(); /* something you need to implement */
251 if (!key) {
252 /* current key doesn't exist or isn't valid */
253 key = createkey();
254 /* something that you need to implement.
255 * createkey needs to initialise a name,
256 * an aes_key, a hmac_key, and optionally
257 * an expire time. */
258 if (!key) /* key couldn't be created */
259 return 0;
260 }
261 memcpy(key_name, key->name, 16);
262
263 EVP_EncryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL,
264 key->aes_key, iv);
265 HMAC_Init_ex(&hctx, key->hmac_key, 16, EVP_sha256(), NULL);
266
267 return 1;
268
269 } else { /* retrieve session */
270 key = findkey(name);
271
272 if (!key || key->expire < now())
273 return 0;
274
275 HMAC_Init_ex(&hctx, key->hmac_key, 16, EVP_sha256(), NULL);
276 EVP_DecryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL,
277 key->aes_key, iv );
278
279 if (key->expire < (now() - RENEW_TIME))
280 /* this session will get a new ticket
281 * even though the current is still valid */
282 return 2;
283
284 return 1;
285 }
286}
287.Ed
288.Sh SEE ALSO
289.Xr ssl 3 ,
290.Xr SSL_CTX_add_session 3 ,
291.Xr SSL_CTX_sess_number 3 ,
292.Xr SSL_CTX_sess_set_get_cb 3 ,
293.Xr SSL_CTX_set_session_id_context 3 ,
294.Xr SSL_session_reused 3 ,
295.Xr SSL_set_session 3