diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libssl/man/Makefile | 4 | ||||
| -rw-r--r-- | src/lib/libssl/man/SSL_CTX_set_tlsext_status_cb.3 | 166 | ||||
| -rw-r--r-- | src/lib/libssl/man/SSL_CTX_set_tlsext_ticket_key_cb.3 | 295 |
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 | ||
| 90 | A client application may request that a server send back an OCSP status | ||
| 91 | response (also known as OCSP stapling). | ||
| 92 | To do so the client should call the | ||
| 93 | .Fn SSL_set_tlsext_status_type | ||
| 94 | function on an individual | ||
| 95 | .Vt SSL | ||
| 96 | object prior to the start of the handshake. | ||
| 97 | Currently the only supported type is | ||
| 98 | .Dv TLSEXT_STATUSTYPE_ocsp . | ||
| 99 | This value should be passed in the | ||
| 100 | .Fa type | ||
| 101 | argument. | ||
| 102 | .Pp | ||
| 103 | The client should additionally provide a callback function to decide | ||
| 104 | what to do with the returned OCSP response by calling | ||
| 105 | .Fn SSL_CTX_set_tlsext_status_cb . | ||
| 106 | The callback function should determine whether the returned OCSP | ||
| 107 | response is acceptable or not. | ||
| 108 | The callback will be passed as an argument the value previously set via | ||
| 109 | a call to | ||
| 110 | .Fn SSL_CTX_set_tlsext_status_arg . | ||
| 111 | Note that the callback will not be called in the event of a handshake | ||
| 112 | where session resumption occurs (because there are no Certificates | ||
| 113 | exchanged in such a handshake). | ||
| 114 | .Pp | ||
| 115 | The response returned by the server can be obtained via a call to | ||
| 116 | .Fn SSL_get_tlsext_status_ocsp_resp . | ||
| 117 | The value | ||
| 118 | .Pf * Fa resp | ||
| 119 | will be updated to point to the OCSP response data and the return value | ||
| 120 | will be the length of that data. | ||
| 121 | If the server has not provided any response data, then | ||
| 122 | .Pf * Fa resp | ||
| 123 | will be | ||
| 124 | .Dv NULL | ||
| 125 | and the return value from | ||
| 126 | .Fn SSL_get_tlsext_status_ocsp_resp | ||
| 127 | will be -1. | ||
| 128 | .Pp | ||
| 129 | A server application must also call the | ||
| 130 | .Fn SSL_CTX_set_tlsext_status_cb | ||
| 131 | function if it wants to be able to provide clients with OCSP Certificate | ||
| 132 | Status responses. | ||
| 133 | Typically the server callback would obtain the server certificate that | ||
| 134 | is being sent back to the client via a call to | ||
| 135 | .Xr SSL_get_certificate 3 , | ||
| 136 | obtain the OCSP response to be sent back, and then set that response | ||
| 137 | data by calling | ||
| 138 | .Fn SSL_set_tlsext_status_ocsp_resp . | ||
| 139 | A pointer to the response data should be provided in the | ||
| 140 | .Fa resp | ||
| 141 | argument, and the length of that data should be in the | ||
| 142 | .Fa len | ||
| 143 | argument. | ||
| 144 | .Sh RETURN VALUES | ||
| 145 | The callback when used on the client side should return a negative | ||
| 146 | value on error, 0 if the response is not acceptable (in which case | ||
| 147 | the handshake will fail), or a positive value if it is acceptable. | ||
| 148 | .Pp | ||
| 149 | The 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 , | ||
| 160 | and | ||
| 161 | .Fn SSL_set_tlsext_status_ocsp_resp | ||
| 162 | return 0 on error or 1 on success. | ||
| 163 | .Pp | ||
| 164 | .Fn SSL_get_tlsext_status_ocsp_resp | ||
| 165 | returns the length of the OCSP response data or -1 if there is no OCSP | ||
| 166 | response 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 | ||
| 68 | sets a callback function | ||
| 69 | .Fa cb | ||
| 70 | for handling session tickets for the ssl context | ||
| 71 | .Fa sslctx . | ||
| 72 | Session tickets, defined in RFC5077, provide an enhanced session | ||
| 73 | resumption capability where the server implementation is not required to | ||
| 74 | maintain per session state. | ||
| 75 | .Pp | ||
| 76 | The callback function | ||
| 77 | .Fa cb | ||
| 78 | will be called for every client instigated TLS session when session | ||
| 79 | ticket extension is presented in the TLS hello message. | ||
| 80 | It is the responsibility of this function to create or retrieve the | ||
| 81 | cryptographic parameters and to maintain their state. | ||
| 82 | .Pp | ||
| 83 | The OpenSSL library uses the callback function to help implement a | ||
| 84 | common TLS ticket construction state according to RFC5077 Section 4 such | ||
| 85 | that per session state is unnecessary and a small set of cryptographic | ||
| 86 | variables needs to be maintained by the callback function | ||
| 87 | implementation. | ||
| 88 | .Pp | ||
| 89 | In order to reuse a session, a TLS client must send the a session ticket | ||
| 90 | extension to the server. | ||
| 91 | The client can only send exactly one session ticket. | ||
| 92 | The server, through the callback function, either agrees to reuse the | ||
| 93 | session ticket information or it starts a full TLS handshake to create a | ||
| 94 | new session ticket. | ||
| 95 | .Pp | ||
| 96 | Before the callback function is started, | ||
| 97 | .Fa ctx | ||
| 98 | and | ||
| 99 | .Fa hctx | ||
| 100 | have been initialised with | ||
| 101 | .Xr EVP_CIPHER_CTX_init 3 | ||
| 102 | and | ||
| 103 | .Xr HMAC_CTX_init 3 , | ||
| 104 | respectively. | ||
| 105 | .Pp | ||
| 106 | For new sessions tickets, when the client doesn't present a session | ||
| 107 | ticket, or an attempted retrieval of the ticket failed, or a renew | ||
| 108 | option was indicated, the callback function will be called with | ||
| 109 | .Fa enc | ||
| 110 | equal to 1. | ||
| 111 | The OpenSSL library expects that the function will set an arbitrary | ||
| 112 | .Fa key_name , | ||
| 113 | initialize | ||
| 114 | .Fa iv , | ||
| 115 | and set the cipher context | ||
| 116 | .Fa ctx | ||
| 117 | and the hash context | ||
| 118 | .Fa hctx . | ||
| 119 | .Pp | ||
| 120 | The | ||
| 121 | .Fa key_name | ||
| 122 | is 16 characters long and is used as a key identifier. | ||
| 123 | .Pp | ||
| 124 | The | ||
| 125 | .Fa iv | ||
| 126 | length is the length of the IV of the corresponding cipher. | ||
| 127 | The maximum IV length is | ||
| 128 | .Dv EVP_MAX_IV_LENGTH | ||
| 129 | bytes defined in | ||
| 130 | .In opsenssl/evp.h . | ||
| 131 | .Pp | ||
| 132 | The initialization vector | ||
| 133 | .Fa iv | ||
| 134 | should be a random value. | ||
| 135 | The cipher context | ||
| 136 | .Fa ctx | ||
| 137 | should use the initialisation vector | ||
| 138 | .Fa iv . | ||
| 139 | The cipher context can be set using | ||
| 140 | .Xr EVP_EncryptInit_ex 3 . | ||
| 141 | The hmac context can be set using | ||
| 142 | .Xr HMAC_Init_ex 3 . | ||
| 143 | .Pp | ||
| 144 | When the client presents a session ticket, the callback function | ||
| 145 | with be called with | ||
| 146 | .Fa enc | ||
| 147 | set to 0 indicating that the | ||
| 148 | .Fa cb | ||
| 149 | function should retrieve a set of parameters. | ||
| 150 | In this case | ||
| 151 | .Fa key_name | ||
| 152 | and | ||
| 153 | .Fa iv | ||
| 154 | have already been parsed out of the session ticket. | ||
| 155 | The OpenSSL library expects that the | ||
| 156 | .Em key_name | ||
| 157 | will be used to retrieve a cryptographic parameters and that the | ||
| 158 | cryptographic context | ||
| 159 | .Fa ctx | ||
| 160 | will be set with the retrieved parameters and the initialization vector | ||
| 161 | .Fa iv | ||
| 162 | using a function like | ||
| 163 | .Xr EVP_DecryptInit_ex 3 . | ||
| 164 | The | ||
| 165 | .Fa hctx | ||
| 166 | needs to be set using | ||
| 167 | .Xr HMAC_Init_ex 3 . | ||
| 168 | .Pp | ||
| 169 | If the | ||
| 170 | .Fa key_name | ||
| 171 | is still valid but a renewal of the ticket is required, the callback | ||
| 172 | function should return 2. | ||
| 173 | The library will call the callback again with an argument of | ||
| 174 | .Fa enc | ||
| 175 | equal to 1 to set the new ticket. | ||
| 176 | .Pp | ||
| 177 | The return value of the | ||
| 178 | .Fa cb | ||
| 179 | function is used by OpenSSL to determine what further processing will | ||
| 180 | occur. | ||
| 181 | The following return values have meaning: | ||
| 182 | .Bl -tag -width Ds | ||
| 183 | .It 2 | ||
| 184 | This indicates that the | ||
| 185 | .Fa ctx | ||
| 186 | and | ||
| 187 | .Fa hctx | ||
| 188 | have been set and the session can continue on those parameters. | ||
| 189 | Additionally it indicates that the session ticket is in a renewal period | ||
| 190 | and should be replaced. | ||
| 191 | The OpenSSL library will call | ||
| 192 | .Fa cb | ||
| 193 | again with an | ||
| 194 | .Fa enc | ||
| 195 | argument of 1 to set the new ticket (see RFC5077 3.3 paragraph 2). | ||
| 196 | .It 1 | ||
| 197 | This indicates that the | ||
| 198 | .Fa ctx | ||
| 199 | and | ||
| 200 | .Fa hctx | ||
| 201 | have been set and the session can continue on those parameters. | ||
| 202 | .It 0 | ||
| 203 | This indicates that it was not possible to set/retrieve a session ticket | ||
| 204 | and the SSL/TLS session will continue by negotiating a set of | ||
| 205 | cryptographic parameters or using the alternate SSL/TLS resumption | ||
| 206 | mechanism, session ids. | ||
| 207 | .Pp | ||
| 208 | If called with | ||
| 209 | .Fa enc | ||
| 210 | equal to 0, the library will call the | ||
| 211 | .Fa cb | ||
| 212 | again to get a new set of parameters. | ||
| 213 | .It less than 0 | ||
| 214 | This indicates an error. | ||
| 215 | .El | ||
| 216 | .Pp | ||
| 217 | Session resumption shortcuts the TLS so that the client certificate | ||
| 218 | negotiation don't occur. | ||
| 219 | It makes up for this by storing client certificate and all other | ||
| 220 | negotiated state information encrypted within the ticket. | ||
| 221 | In a resumed session the applications will have all this state | ||
| 222 | information available exactly as if a full negotiation had occurred. | ||
| 223 | .Pp | ||
| 224 | If an attacker can obtain the key used to encrypt a session ticket, they | ||
| 225 | can obtain the master secret for any ticket using that key and decrypt | ||
| 226 | any traffic using that session: even if the ciphersuite supports forward | ||
| 227 | secrecy. | ||
| 228 | As a result applications may wish to use multiple keys and avoid using | ||
| 229 | long term keys stored in files. | ||
| 230 | .Pp | ||
| 231 | Applications can use longer keys to maintain a consistent level of | ||
| 232 | security. | ||
| 233 | For example if a ciphersuite uses 256 bit ciphers but only a 128 bit | ||
| 234 | ticket key the overall security is only 128 bits because breaking the | ||
| 235 | ticket key will enable an attacker to obtain the session keys. | ||
| 236 | .Sh RETURN VALUES | ||
| 237 | This function returns 0 to indicate that the callback function was set. | ||
| 238 | .Sh EXAMPLES | ||
| 239 | Reference Implementation: | ||
| 240 | .Bd -literal | ||
| 241 | SSL_CTX_set_tlsext_ticket_key_cb(SSL, ssl_tlsext_ticket_key_cb); | ||
| 242 | \&.... | ||
| 243 | static 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 | ||
