%PDF- %PDF-
Direktori : /opt/cpanel/ea-openssl/etc/pki/tls/man/man3/ |
Current File : //opt/cpanel/ea-openssl/etc/pki/tls/man/man3/SSL_CTX_set_tlsext_ticket_key_cb.3 |
.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_set_tlsext_ticket_key_cb 3" .TH SSL_CTX_set_tlsext_ticket_key_cb 3 "2019-12-20" "1.0.2u" "OpenSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_set_tlsext_ticket_key_cb \- set a callback for session ticket processing .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include <openssl/tls1.h> \& \& long SSL_CTX_set_tlsext_ticket_key_cb(SSL_CTX sslctx, \& int (*cb)(SSL *s, unsigned char key_name[16], \& unsigned char iv[EVP_MAX_IV_LENGTH], \& EVP_CIPHER_CTX *ctx, HMAC_CTX *hctx, int enc)); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fBSSL_CTX_set_tlsext_ticket_key_cb()\fR sets a callback fuction \fIcb\fR for handling session tickets for the ssl context \fIsslctx\fR. Session tickets, defined in \&\s-1RFC5077\s0 provide an enhanced session resumption capability where the server implementation is not required to maintain per session state. It only applies to \s-1TLS\s0 and there is no SSLv3 implementation. .PP The callback is available when the OpenSSL library was built without \&\fI\s-1OPENSSL_NO_TLSEXT\s0\fR being defined. .PP The callback function \fIcb\fR will be called for every client instigated \s-1TLS\s0 session when session ticket extension is presented in the \s-1TLS\s0 hello message. It is the responsibility of this function to create or retrieve the cryptographic parameters and to maintain their state. .PP The OpenSSL library uses your callback function to help implement a common \s-1TLS\s0 ticket construction state according to \s-1RFC5077\s0 Section 4 such that per session state is unnecessary and a small set of cryptographic variables needs to be maintained by the callback function implementation. .PP In order to reuse a session, a \s-1TLS\s0 client must send the a session ticket extension to the server. The client can only send exactly one session ticket. The server, through the callback function, either agrees to reuse the session ticket information or it starts a full \s-1TLS\s0 handshake to create a new session ticket. .PP Before the callback function is started \fIctx\fR and \fIhctx\fR have been initialised with EVP_CIPHER_CTX_init and HMAC_CTX_init respectively. .PP For new sessions tickets, when the client doesn't present a session ticket, or an attempted retreival of the ticket failed, or a renew option was indicated, the callback function will be called with \fIenc\fR equal to 1. The OpenSSL library expects that the function will set an arbitary \fIname\fR, initialize \&\fIiv\fR, and set the cipher context \fIctx\fR and the hash context \fIhctx\fR. .PP The \fIname\fR is 16 characters long and is used as a key identifier. .PP The \fIiv\fR length is the length of the \s-1IV\s0 of the corresponding cipher. The maximum \s-1IV\s0 length is \s-1EVP_MAX_IV_LENGTH\s0 bytes defined in \fBevp.h\fR. .PP The initialization vector \fIiv\fR should be a random value. The cipher context \&\fIctx\fR should use the initialisation vector \fIiv\fR. The cipher context can be set using EVP_EncryptInit_ex. The hmac context can be set using HMAC_Init_ex. .PP When the client presents a session ticket, the callback function with be called with \fIenc\fR set to 0 indicating that the \fIcb\fR function should retreive a set of parameters. In this case \fIname\fR and \fIiv\fR have already been parsed out of the session ticket. The OpenSSL library expects that the \fIname\fR will be used to retrieve a cryptographic parameters and that the cryptographic context \&\fIctx\fR will be set with the retreived parameters and the initialization vector \&\fIiv\fR. using a function like EVP_DecryptInit_ex. The \fIhctx\fR needs to be set using HMAC_Init_ex. .PP If the \fIname\fR is still valid but a renewal of the ticket is required the callback function should return 2. The library will call the callback again with an arguement of enc equal to 1 to set the new ticket. .PP The return value of the \fIcb\fR function is used by OpenSSL to determine what further processing will occur. The following return values have meaning: .IP "2" 4 .IX Item "2" This indicates that the \fIctx\fR and \fIhctx\fR have been set and the session can continue on those parameters. Additionally it indicates that the session ticket is in a renewal period and should be replaced. The OpenSSL library will call \fIcb\fR again with an enc argument of 1 to set the new ticket (see \s-1RFC5077 3.3\s0 paragraph 2). .IP "1" 4 .IX Item "1" This indicates that the \fIctx\fR and \fIhctx\fR have been set and the session can continue on those parameters. .IP "0" 4 This indicates that it was not possible to set/retrieve a session ticket and the \s-1SSL/TLS\s0 session will continue by by negiotationing a set of cryptographic parameters or using the alternate \s-1SSL/TLS\s0 resumption mechanism, session ids. .Sp If called with enc equal to 0 the library will call the \fIcb\fR again to get a new set of parameters. .IP "less than 0" 4 .IX Item "less than 0" This indicates an error. .SH "NOTES" .IX Header "NOTES" Session resumption shortcuts the \s-1TLS\s0 so that the client certificate negiotation don't occur. It makes up for this by storing client certificate an all other negotiated state information encrypted within the ticket. In a resumed session the applications will have all this state information available exactly as if a full negiotation had occured. .PP If an attacker can obtain the key used to encrypt a session ticket, they can obtain the master secret for any ticket using that key and decrypt any traffic using that session: even if the ciphersuite supports forward secrecy. As a result applications may wish to use multiple keys and avoid using long term keys stored in files. .PP Applications can use longer keys to maintain a consistent level of security. For example if a ciphersuite uses 256 bit ciphers but only a 128 bit ticket key the overall security is only 128 bits because breaking the ticket key will enable an attacker to obtain the session keys. .SH "EXAMPLES" .IX Header "EXAMPLES" Reference Implemention: SSL_CTX_set_tlsext_ticket_key_cb(\s-1SSL\s0,ssl_tlsext_ticket_key_cb); .... .PP .Vb 6 \& static int ssl_tlsext_ticket_key_cb(SSL *s, unsigned char key_name[16], unsigned char *iv, EVP_CIPHER_CTX *ctx, HMAC_CTX *hctx, int enc) \& { \& if (enc) { /* create new session */ \& if (RAND_bytes(iv, EVP_MAX_IV_LENGTH) ) { \& return \-1; /* insufficient random */ \& } \& \& key = currentkey(); /* something that you need to implement */ \& if ( !key ) { \& /* current key doesn\*(Aqt exist or isn\*(Aqt valid */ \& key = createkey(); /* something that you need to implement. \& * createkey needs to initialise, a name, \& * an aes_key, a hmac_key and optionally \& * an expire time. */ \& if ( !key ) { /* key couldn\*(Aqt be created */ \& return 0; \& } \& } \& memcpy(key_name, key\->name, 16); \& \& EVP_EncryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL, key\->aes_key, iv); \& HMAC_Init_ex(&hctx, key\->hmac_key, 16, EVP_sha256(), NULL); \& \& return 1; \& \& } else { /* retrieve session */ \& key = findkey(name); \& \& if (!key || key\->expire < now() ) { \& return 0; \& } \& \& HMAC_Init_ex(&hctx, key\->hmac_key, 16, EVP_sha256(), NULL); \& EVP_DecryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL, key\->aes_key, iv ); \& \& if (key\->expire < ( now() \- RENEW_TIME ) ) { \& /* return 2 \- this session will get a new ticket even though the current is still valid */ \& return 2; \& } \& return 1; \& \& } \& } .Ve .SH "RETURN VALUES" .IX Header "RETURN VALUES" returns 0 to indicate the callback function was set. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBssl\fR\|(3), \fBSSL_set_session\fR\|(3), \&\fBSSL_session_reused\fR\|(3), \&\fBSSL_CTX_add_session\fR\|(3), \&\fBSSL_CTX_sess_number\fR\|(3), \&\fBSSL_CTX_sess_set_get_cb\fR\|(3), \&\fBSSL_CTX_set_session_id_context\fR\|(3), .SH "HISTORY" .IX Header "HISTORY" This function was introduced in OpenSSL 0.9.8h