head 1.2; access; symbols perseant-exfatfs-base-20250801:1.2 perseant-exfatfs-base-20240630:1.2 perseant-exfatfs:1.2.0.22 perseant-exfatfs-base:1.2 cjep_sun2x:1.2.0.20 cjep_sun2x-base:1.2 cjep_staticlib_x-base1:1.2 cjep_staticlib_x:1.2.0.18 cjep_staticlib_x-base:1.2 phil-wifi-20200421:1.2 phil-wifi-20200411:1.2 phil-wifi-20200406:1.2 pgoyette-compat-merge-20190127:1.2 pgoyette-compat-20190127:1.2 pgoyette-compat-20190118:1.2 pgoyette-compat-1226:1.2 pgoyette-compat-1126:1.2 pgoyette-compat-1020:1.2 pgoyette-compat-0930:1.2 pgoyette-compat-0906:1.2 pgoyette-compat-0728:1.2 pgoyette-compat-0625:1.2 pgoyette-compat-0521:1.2 pgoyette-compat-0502:1.2 pgoyette-compat-0422:1.2 pgoyette-compat-0415:1.2 pgoyette-compat-0407:1.2 pgoyette-compat-0330:1.2 pgoyette-compat-0322:1.2 pgoyette-compat-0315:1.2 pgoyette-compat:1.2.0.16 pgoyette-compat-base:1.2 prg-localcount2-base3:1.2 prg-localcount2-base2:1.2 prg-localcount2-base1:1.2 prg-localcount2:1.2.0.14 prg-localcount2-base:1.2 pgoyette-localcount-20170426:1.2 bouyer-socketcan-base1:1.2 pgoyette-localcount-20170320:1.2 bouyer-socketcan:1.2.0.12 bouyer-socketcan-base:1.2 pgoyette-localcount-20170107:1.2 pgoyette-localcount-20161104:1.2 localcount-20160914:1.2 pgoyette-localcount-20160806:1.2 pgoyette-localcount-20160726:1.2 pgoyette-localcount:1.2.0.10 pgoyette-localcount-base:1.2 netbsd-5-2-3-RELEASE:1.1.1.2 netbsd-5-1-5-RELEASE:1.1.1.2 yamt-pagecache-base9:1.2 yamt-pagecache-tag8:1.2 tls-earlyentropy:1.2.0.6 tls-earlyentropy-base:1.2 riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.2 riastradh-drm2-base3:1.2 netbsd-5-2-2-RELEASE:1.1.1.2 netbsd-5-1-4-RELEASE:1.1.1.2 netbsd-5-2-1-RELEASE:1.1.1.2 netbsd-5-1-3-RELEASE:1.1.1.2 agc-symver:1.2.0.8 agc-symver-base:1.2 tls-maxphys-base:1.2 yamt-pagecache-base8:1.2 netbsd-5-2:1.1.1.2.0.2 yamt-pagecache-base7:1.2 netbsd-5-2-RELEASE:1.1.1.2 netbsd-5-2-RC1:1.1.1.2 yamt-pagecache-base6:1.2 yamt-pagecache-base5:1.2 yamt-pagecache-base4:1.2 netbsd-5-1-2-RELEASE:1.1.1.2 netbsd-5-1-1-RELEASE:1.1.1.2 yamt-pagecache-base3:1.2 yamt-pagecache-base2:1.2 yamt-pagecache:1.2.0.4 yamt-pagecache-base:1.2 bouyer-quota2-nbase:1.2 bouyer-quota2:1.2.0.2 bouyer-quota2-base:1.2 matt-nb5-mips64-premerge-20101231:1.1.1.2 matt-nb5-pq3:1.1.1.2.0.14 matt-nb5-pq3-base:1.1.1.2 netbsd-5-1:1.1.1.2.0.12 netbsd-5-1-RELEASE:1.1.1.2 netbsd-5-1-RC4:1.1.1.2 matt-nb5-mips64-k15:1.1.1.2 netbsd-5-1-RC3:1.1.1.2 netbsd-5-1-RC2:1.1.1.2 netbsd-5-1-RC1:1.1.1.2 netbsd-5-0-2-RELEASE:1.1.1.2 matt-nb5-mips64-premerge-20091211:1.1.1.2 matt-premerge-20091211:1.1.1.2 matt-nb5-mips64-u2-k2-k4-k7-k8-k9:1.1.1.2 matt-nb4-mips64-k7-u2a-k9b:1.1.1.2 matt-nb5-mips64-u1-k1-k5:1.1.1.2 matt-nb5-mips64:1.1.1.2.0.10 netbsd-5-0-1-RELEASE:1.1.1.2 jym-xensuspend-nbase:1.1.1.2 netbsd-5-0:1.1.1.2.0.8 netbsd-5-0-RELEASE:1.1.1.2 netbsd-5-0-RC4:1.1.1.2 netbsd-5-0-RC3:1.1.1.2 netbsd-5-0-RC2:1.1.1.2 jym-xensuspend:1.1.1.2.0.6 jym-xensuspend-base:1.1.1.2 netbsd-5-0-RC1:1.1.1.2 netbsd-5:1.1.1.2.0.4 netbsd-5-base:1.1.1.2 matt-mips64-base2:1.1.1.2 wrstuden-revivesa-base-3:1.1.1.2 wrstuden-revivesa-base-2:1.1.1.2 v0_6_4:1.1.1.2 wrstuden-revivesa-base-1:1.1.1.1 yamt-pf42-base4:1.1.1.1 yamt-pf42-base3:1.1.1.1 hpcarm-cleanup-nbase:1.1.1.1 hpcarm-cleanup-base:1.1.1.1 yamt-pf42-baseX:1.1.1.1 yamt-pf42-base2:1.1.1.1 wrstuden-revivesa:1.1.1.1.0.8 wrstuden-revivesa-base:1.1.1.1 yamt-pf42:1.1.1.1.0.6 yamt-pf42-base:1.1.1.1 matt-armv6:1.1.1.1.0.4 matt-armv6-nbase:1.1.1.1 keiichi-mipv6:1.1.1.1.0.2 keiichi-mipv6-base:1.1.1.1 v0_6_2:1.1.1.1 MALINEN:1.1.1; locks; strict; comment @# @; 1.2 date 2010.08.26.14.59.05; author christos; state dead; branches; next 1.1; 1.1 date 2008.01.26.21.38.35; author christos; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2008.01.26.21.38.35; author christos; state Exp; branches 1.1.1.1.4.1 1.1.1.1.8.1; next 1.1.1.2; 1.1.1.2 date 2008.08.30.07.23.44; author christos; state Exp; branches; next ; 1.1.1.1.4.1 date 2008.01.26.21.38.35; author matt; state dead; branches; next 1.1.1.1.4.2; 1.1.1.1.4.2 date 2008.03.23.00.17.14; author matt; state Exp; branches; next ; 1.1.1.1.8.1 date 2008.09.18.04.44.50; author wrstuden; state Exp; branches; next ; desc @@ 1.2 log @bye old wpa @ text @This patch adds support for TLS SessionTicket extension (RFC 4507) for the parts used by EAP-FAST (RFC 4851). This is based on the patch from Alexey Kobozev (sent to openssl-dev mailing list on Tue, 07 Jun 2005 15:40:58 +0300). diff -upr openssl-SNAP-20071101.orig/ssl/s3_clnt.c openssl-SNAP-20071101/ssl/s3_clnt.c --- openssl-SNAP-20071101.orig/ssl/s3_clnt.c 2007-10-26 06:00:28.000000000 -0700 +++ openssl-SNAP-20071101/ssl/s3_clnt.c 2007-11-01 19:19:43.000000000 -0700 @@@@ -715,7 +715,7 @@@@ int ssl3_get_server_hello(SSL *s) STACK_OF(SSL_CIPHER) *sk; SSL_CIPHER *c; unsigned char *p,*d; - int i,al,ok; + int i,al,ok,pre_shared; unsigned int j; long n; #ifndef OPENSSL_NO_COMP @@@@ -782,7 +782,26 @@@@ int ssl3_get_server_hello(SSL *s) goto f_err; } - if (j != 0 && j == s->session->session_id_length + /* check if we want to resume the session based on external pre-shared secret */ + pre_shared = 0; +#ifndef OPENSSL_NO_TLSEXT + if (s->version >= TLS1_VERSION && s->tls_session_secret_cb) + { + SSL_CIPHER *pref_cipher=NULL; + s->session->master_key_length=sizeof(s->session->master_key); + if (s->tls_session_secret_cb(s, s->session->master_key, &s->session->master_key_length, + NULL, &pref_cipher, s->tls_session_secret_cb_arg)) + { + s->hit=1; + s->session->cipher=pref_cipher ? pref_cipher : ssl_get_cipher_by_char(s,p+j); + s->session->session_id_length = j; + memcpy(s->session->session_id, p, j); + pre_shared = 1; + } + } +#endif /* OPENSSL_NO_TLSEXT */ + + if ((pre_shared || j != 0) && j == s->session->session_id_length && memcmp(p,s->session->session_id,j) == 0) { if(s->sid_ctx_length != s->session->sid_ctx_length diff -upr openssl-SNAP-20071101.orig/ssl/s3_srvr.c openssl-SNAP-20071101/ssl/s3_srvr.c --- openssl-SNAP-20071101.orig/ssl/s3_srvr.c 2007-10-26 06:00:29.000000000 -0700 +++ openssl-SNAP-20071101/ssl/s3_srvr.c 2007-11-01 19:19:43.000000000 -0700 @@@@ -992,6 +992,59 @@@@ int ssl3_get_client_hello(SSL *s) SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_CLIENTHELLO_TLSEXT); goto err; } + + /* Check if we want to use external pre-shared secret for this + * handshake for not reused session only. We need to generate + * server_random before calling tls_session_secret_cb in order to allow + * SessionTicket processing to use it in key derivation. */ + { + unsigned long Time; + unsigned char *pos; + Time=(unsigned long)time(NULL); /* Time */ + pos=s->s3->server_random; + l2n(Time,pos); + if (RAND_pseudo_bytes(pos,SSL3_RANDOM_SIZE-4) <= 0) + { + al=SSL_AD_INTERNAL_ERROR; + goto f_err; + } + } + + if (!s->hit && s->version >= TLS1_VERSION && s->tls_session_secret_cb) + { + SSL_CIPHER *pref_cipher=NULL; + + s->session->master_key_length=sizeof(s->session->master_key); + if(s->tls_session_secret_cb(s, s->session->master_key, &s->session->master_key_length, + ciphers, &pref_cipher, s->tls_session_secret_cb_arg)) + { + s->hit=1; + s->session->ciphers=ciphers; + s->session->verify_result=X509_V_OK; + + ciphers=NULL; + + /* check if some cipher was preferred by call back */ + pref_cipher=pref_cipher ? pref_cipher : ssl3_choose_cipher(s, s->session->ciphers, SSL_get_ciphers(s)); + if (pref_cipher == NULL) + { + al=SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_NO_SHARED_CIPHER); + goto f_err; + } + + s->session->cipher=pref_cipher; + + if (s->cipher_list) + sk_SSL_CIPHER_free(s->cipher_list); + + if (s->cipher_list_by_id) + sk_SSL_CIPHER_free(s->cipher_list_by_id); + + s->cipher_list = sk_SSL_CIPHER_dup(s->session->ciphers); + s->cipher_list_by_id = sk_SSL_CIPHER_dup(s->session->ciphers); + } + } #endif /* Worst case, we will use the NULL compression, but if we have other @@@@ -1118,16 +1171,22 @@@@ int ssl3_send_server_hello(SSL *s) unsigned char *buf; unsigned char *p,*d; int i,sl; - unsigned long l,Time; + unsigned long l; +#ifdef OPENSSL_NO_TLSEXT + unsigned long Time; +#endif if (s->state == SSL3_ST_SW_SRVR_HELLO_A) { buf=(unsigned char *)s->init_buf->data; +#ifdef OPENSSL_NO_TLSEXT p=s->s3->server_random; + /* Generate server_random if it was not needed previously */ Time=(unsigned long)time(NULL); /* Time */ l2n(Time,p); if (RAND_pseudo_bytes(p,SSL3_RANDOM_SIZE-4) <= 0) return -1; +#endif /* Do the message type and length last */ d=p= &(buf[4]); diff -upr openssl-SNAP-20071101.orig/ssl/ssl.h openssl-SNAP-20071101/ssl/ssl.h --- openssl-SNAP-20071101.orig/ssl/ssl.h 2007-10-26 17:01:28.000000000 -0700 +++ openssl-SNAP-20071101/ssl/ssl.h 2007-11-01 19:20:47.000000000 -0700 @@@@ -353,6 +353,7 @@@@ extern "C" { * 'struct ssl_st *' function parameters used to prototype callbacks * in SSL_CTX. */ typedef struct ssl_st *ssl_crock_st; +typedef struct tls_extension_st TLS_EXTENSION; /* used to hold info on the particular ciphers used */ typedef struct ssl_cipher_st @@@@ -379,6 +380,8 @@@@ DECLARE_STACK_OF(SSL_CIPHER) typedef struct ssl_st SSL; typedef struct ssl_ctx_st SSL_CTX; +typedef int (*tls_session_secret_cb_fn)(SSL *s, void *secret, int *secret_len, STACK_OF(SSL_CIPHER) *peer_ciphers, SSL_CIPHER **cipher, void *arg); + /* Used to hold functions for SSLv2 or SSLv3/TLSv1 functions */ typedef struct ssl_method_st { @@@@ -1121,6 +1124,13 @@@@ struct ssl_st void *tlsext_opaque_prf_input; size_t tlsext_opaque_prf_input_len; + /* TLS extensions */ + TLS_EXTENSION *tls_extension; + + /* TLS pre-shared secret session resumption */ + tls_session_secret_cb_fn tls_session_secret_cb; + void *tls_session_secret_cb_arg; + SSL_CTX * initial_ctx; /* initial ctx, used to store sessions */ #define session_ctx initial_ctx #else @@@@ -1721,6 +1731,12 @@@@ void *SSL_COMP_get_compression_methods(v int SSL_COMP_add_compression_method(int id,void *cm); #endif +/* TLS extensions functions */ +int SSL_set_hello_extension(SSL *s, int ext_type, void *ext_data, int ext_len); + +/* Pre-shared secret session resumption functions */ +int SSL_set_session_secret_cb(SSL *s, tls_session_secret_cb_fn tls_session_secret_cb, void *arg); + /* BEGIN ERROR CODES */ /* The following lines are auto generated by the script mkerr.pl. Any changes * made after this point may be overwritten when the script is next run. @@@@ -1920,6 +1936,7 @@@@ void ERR_load_SSL_strings(void); #define SSL_F_TLS1_PRF 284 #define SSL_F_TLS1_SETUP_KEY_BLOCK 211 #define SSL_F_WRITE_PENDING 212 +#define SSL_F_SSL_SET_HELLO_EXTENSION 213 /* Reason codes. */ #define SSL_R_APP_DATA_IN_HANDSHAKE 100 diff -upr openssl-SNAP-20071101.orig/ssl/ssl_err.c openssl-SNAP-20071101/ssl/ssl_err.c --- openssl-SNAP-20071101.orig/ssl/ssl_err.c 2007-10-26 17:01:29.000000000 -0700 +++ openssl-SNAP-20071101/ssl/ssl_err.c 2007-11-01 19:19:43.000000000 -0700 @@@@ -260,6 +260,7 @@@@ static ERR_STRING_DATA SSL_str_functs[]= {ERR_FUNC(SSL_F_TLS1_PRF), "tls1_prf"}, {ERR_FUNC(SSL_F_TLS1_SETUP_KEY_BLOCK), "TLS1_SETUP_KEY_BLOCK"}, {ERR_FUNC(SSL_F_WRITE_PENDING), "WRITE_PENDING"}, +{ERR_FUNC(SSL_F_SSL_SET_HELLO_EXTENSION), "SSL_set_hello_extension"}, {0,NULL} }; diff -upr openssl-SNAP-20071101.orig/ssl/ssl_sess.c openssl-SNAP-20071101/ssl/ssl_sess.c --- openssl-SNAP-20071101.orig/ssl/ssl_sess.c 2007-10-17 11:00:45.000000000 -0700 +++ openssl-SNAP-20071101/ssl/ssl_sess.c 2007-11-01 19:19:43.000000000 -0700 @@@@ -831,6 +831,52 @@@@ long SSL_CTX_get_timeout(const SSL_CTX * return(s->session_timeout); } +#ifndef OPENSSL_NO_TLSEXT +int SSL_set_session_secret_cb(SSL *s, int (*tls_session_secret_cb)(SSL *s, void *secret, int *secret_len, + STACK_OF(SSL_CIPHER) *peer_ciphers, SSL_CIPHER **cipher, void *arg), void *arg) +{ + if (s == NULL) return(0); + s->tls_session_secret_cb = tls_session_secret_cb; + s->tls_session_secret_cb_arg = arg; + return(1); +} + +int SSL_set_hello_extension(SSL *s, int ext_type, void *ext_data, int ext_len) +{ + if(s->version >= TLS1_VERSION) + { + if(s->tls_extension) + { + OPENSSL_free(s->tls_extension); + s->tls_extension = NULL; + } + + s->tls_extension = OPENSSL_malloc(sizeof(TLS_EXTENSION) + ext_len); + if(!s->tls_extension) + { + SSLerr(SSL_F_SSL_SET_HELLO_EXTENSION, ERR_R_MALLOC_FAILURE); + return 0; + } + + s->tls_extension->type = ext_type; + + if(ext_data) + { + s->tls_extension->length = ext_len; + s->tls_extension->data = s->tls_extension + 1; + memcpy(s->tls_extension->data, ext_data, ext_len); + } else { + s->tls_extension->length = 0; + s->tls_extension->data = NULL; + } + + return 1; + } + + return 0; +} +#endif /* OPENSSL_NO_TLSEXT */ + typedef struct timeout_param_st { SSL_CTX *ctx; diff -upr openssl-SNAP-20071101.orig/ssl/t1_lib.c openssl-SNAP-20071101/ssl/t1_lib.c --- openssl-SNAP-20071101.orig/ssl/t1_lib.c 2007-10-26 06:00:29.000000000 -0700 +++ openssl-SNAP-20071101/ssl/t1_lib.c 2007-11-01 19:19:43.000000000 -0700 @@@@ -154,6 +154,12 @@@@ int tls1_new(SSL *s) void tls1_free(SSL *s) { +#ifndef OPENSSL_NO_TLSEXT + if(s->tls_extension) + { + OPENSSL_free(s->tls_extension); + } +#endif ssl3_free(s); } @@@@ -355,8 +361,24 @@@@ unsigned char *ssl_add_clienthello_tlsex int ticklen; if (s->session && s->session->tlsext_tick) ticklen = s->session->tlsext_ticklen; + else if (s->session && s->tls_extension && + s->tls_extension->type == TLSEXT_TYPE_session_ticket && + s->tls_extension->data) + { + ticklen = s->tls_extension->length; + s->session->tlsext_tick = OPENSSL_malloc(ticklen); + if (!s->session->tlsext_tick) + return NULL; + memcpy(s->session->tlsext_tick, s->tls_extension->data, + ticklen); + s->session->tlsext_ticklen = ticklen; + } else ticklen = 0; + if (ticklen == 0 && s->tls_extension && + s->tls_extension->type == TLSEXT_TYPE_session_ticket && + s->tls_extension->data == NULL) + goto skip_ext; /* Check for enough room 2 for extension type, 2 for len * rest for ticket */ @@@@ -369,6 +391,7 @@@@ unsigned char *ssl_add_clienthello_tlsex ret += ticklen; } } + skip_ext: #ifdef TLSEXT_TYPE_opaque_prf_input if (s->s3->client_opaque_prf_input != NULL) @@@@ -1422,6 +1445,8 @@@@ int tls1_process_ticket(SSL *s, unsigned s->tlsext_ticket_expected = 1; return 0; /* Cache miss */ } + if (s->tls_session_secret_cb) + return 0; return tls_decrypt_ticket(s, p, size, session_id, len, ret); } diff -upr openssl-SNAP-20071101.orig/ssl/tls1.h openssl-SNAP-20071101/ssl/tls1.h --- openssl-SNAP-20071101.orig/ssl/tls1.h 2007-09-26 15:01:39.000000000 -0700 +++ openssl-SNAP-20071101/ssl/tls1.h 2007-11-01 19:19:43.000000000 -0700 @@@@ -509,6 +509,14 @@@@ SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TLSEXT_OPA #define TLS_MD_MASTER_SECRET_CONST "\x6d\x61\x73\x74\x65\x72\x20\x73\x65\x63\x72\x65\x74" /*master secret*/ #endif +/* TLS extension struct */ +struct tls_extension_st +{ + unsigned short type; + unsigned short length; + void *data; +}; + #ifdef __cplusplus } #endif diff -upr openssl-SNAP-20071101.orig/util/ssleay.num openssl-SNAP-20071101/util/ssleay.num --- openssl-SNAP-20071101.orig/util/ssleay.num 2007-08-31 06:03:14.000000000 -0700 +++ openssl-SNAP-20071101/util/ssleay.num 2007-11-01 19:19:43.000000000 -0700 @@@@ -253,3 +253,5 @@@@ PEM_write_bio_SSL_SESSION PEM_read_SSL_SESSION 302 EXIST:!WIN16:FUNCTION: PEM_read_bio_SSL_SESSION 303 EXIST::FUNCTION: PEM_write_SSL_SESSION 304 EXIST:!WIN16:FUNCTION: +SSL_set_hello_extension 305 EXIST::FUNCTION:TLSEXT +SSL_set_session_secret_cb 306 EXIST::FUNCTION:TLSEXT @ 1.1 log @Initial revision @ text @@ 1.1.1.1 log @Import new wpa_supplicant code @ text @@ 1.1.1.1.8.1 log @Sync with wrstuden-revivesa-base-2. @ text @d1 1 a1 1 This patch adds support for TLS SessionTicket extension (RFC 5077) for d9 13 a21 4 diff -upr openssl-SNAP-20080528.orig/ssl/s3_clnt.c openssl-SNAP-20080528/ssl/s3_clnt.c --- openssl-SNAP-20080528.orig/ssl/s3_clnt.c 2008-04-29 21:00:17.000000000 +0300 +++ openssl-SNAP-20080528/ssl/s3_clnt.c 2008-05-29 10:55:43.000000000 +0300 @@@@ -785,6 +785,20 @@@@ int ssl3_get_server_hello(SSL *s) d25 3 a28 1 + /* check if we want to resume the session based on external pre-shared secret */ d36 1 d38 3 d45 1 a45 1 if (j != 0 && j == s->session->session_id_length d48 5 a52 18 @@@@ -2918,11 +2932,8 @@@@ static int ssl3_check_finished(SSL *s) { int ok; long n; - /* If we have no ticket or session ID is non-zero length (a match of - * a non-zero session length would never reach here) it cannot be a - * resumed session. - */ - if (!s->session->tlsext_tick || s->session->session_id_length) + /* If we have no ticket it cannot be a resumed session. */ + if (!s->session->tlsext_tick) return 1; /* this function is called when we really expect a Certificate * message, so permit appropriate message length */ diff -upr openssl-SNAP-20080528.orig/ssl/s3_srvr.c openssl-SNAP-20080528/ssl/s3_srvr.c --- openssl-SNAP-20080528.orig/ssl/s3_srvr.c 2008-04-30 20:00:38.000000000 +0300 +++ openssl-SNAP-20080528/ssl/s3_srvr.c 2008-05-29 10:49:25.000000000 +0300 @@@@ -1004,6 +1004,59 @@@@ int ssl3_get_client_hello(SSL *s) d112 1 a112 1 @@@@ -1130,16 +1183,22 @@@@ int ssl3_send_server_hello(SSL *s) d136 4 a139 4 diff -upr openssl-SNAP-20080528.orig/ssl/ssl.h openssl-SNAP-20080528/ssl/ssl.h --- openssl-SNAP-20080528.orig/ssl/ssl.h 2008-05-26 15:00:37.000000000 +0300 +++ openssl-SNAP-20080528/ssl/ssl.h 2008-05-29 10:49:25.000000000 +0300 @@@@ -354,6 +354,7 @@@@ extern "C" { d147 1 a147 1 @@@@ -380,6 +381,8 @@@@ DECLARE_STACK_OF(SSL_CIPHER) d156 1 a156 1 @@@@ -1128,6 +1131,13 @@@@ struct ssl_st d170 1 a170 1 @@@@ -1729,6 +1739,12 @@@@ void *SSL_COMP_get_compression_methods(v d183 1 a183 1 @@@@ -1928,6 +1944,7 @@@@ void ERR_load_SSL_strings(void); d191 3 a193 3 diff -upr openssl-SNAP-20080528.orig/ssl/ssl_err.c openssl-SNAP-20080528/ssl/ssl_err.c --- openssl-SNAP-20080528.orig/ssl/ssl_err.c 2007-10-27 03:01:29.000000000 +0300 +++ openssl-SNAP-20080528/ssl/ssl_err.c 2008-05-29 10:49:25.000000000 +0300 d202 3 a204 3 diff -upr openssl-SNAP-20080528.orig/ssl/ssl_sess.c openssl-SNAP-20080528/ssl/ssl_sess.c --- openssl-SNAP-20080528.orig/ssl/ssl_sess.c 2008-05-26 15:00:37.000000000 +0300 +++ openssl-SNAP-20080528/ssl/ssl_sess.c 2008-05-29 10:49:25.000000000 +0300 d258 3 a260 3 diff -upr openssl-SNAP-20080528.orig/ssl/t1_lib.c openssl-SNAP-20080528/ssl/t1_lib.c --- openssl-SNAP-20080528.orig/ssl/t1_lib.c 2008-04-30 20:00:39.000000000 +0300 +++ openssl-SNAP-20080528/ssl/t1_lib.c 2008-05-29 10:49:25.000000000 +0300 d274 1 a274 1 @@@@ -357,8 +363,24 @@@@ unsigned char *ssl_add_clienthello_tlsex d299 1 a299 1 @@@@ -371,6 +393,7 @@@@ unsigned char *ssl_add_clienthello_tlsex d307 1 a307 1 @@@@ -1427,6 +1450,8 @@@@ int tls1_process_ticket(SSL *s, unsigned d316 4 a319 4 diff -upr openssl-SNAP-20080528.orig/ssl/tls1.h openssl-SNAP-20080528/ssl/tls1.h --- openssl-SNAP-20080528.orig/ssl/tls1.h 2008-04-30 20:00:39.000000000 +0300 +++ openssl-SNAP-20080528/ssl/tls1.h 2008-05-29 10:49:25.000000000 +0300 @@@@ -512,6 +512,14 @@@@ SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_T d334 3 a336 3 diff -upr openssl-SNAP-20080528.orig/util/ssleay.num openssl-SNAP-20080528/util/ssleay.num --- openssl-SNAP-20080528.orig/util/ssleay.num 2007-08-31 16:03:14.000000000 +0300 +++ openssl-SNAP-20080528/util/ssleay.num 2008-05-29 10:49:25.000000000 +0300 @ 1.1.1.2 log @Import wpa_supplicant and hostapd @ text @d1 1 a1 1 This patch adds support for TLS SessionTicket extension (RFC 5077) for d9 13 a21 4 diff -upr openssl-SNAP-20080528.orig/ssl/s3_clnt.c openssl-SNAP-20080528/ssl/s3_clnt.c --- openssl-SNAP-20080528.orig/ssl/s3_clnt.c 2008-04-29 21:00:17.000000000 +0300 +++ openssl-SNAP-20080528/ssl/s3_clnt.c 2008-05-29 10:55:43.000000000 +0300 @@@@ -785,6 +785,20 @@@@ int ssl3_get_server_hello(SSL *s) d25 3 a28 1 + /* check if we want to resume the session based on external pre-shared secret */ d36 1 d38 3 d45 1 a45 1 if (j != 0 && j == s->session->session_id_length d48 5 a52 18 @@@@ -2918,11 +2932,8 @@@@ static int ssl3_check_finished(SSL *s) { int ok; long n; - /* If we have no ticket or session ID is non-zero length (a match of - * a non-zero session length would never reach here) it cannot be a - * resumed session. - */ - if (!s->session->tlsext_tick || s->session->session_id_length) + /* If we have no ticket it cannot be a resumed session. */ + if (!s->session->tlsext_tick) return 1; /* this function is called when we really expect a Certificate * message, so permit appropriate message length */ diff -upr openssl-SNAP-20080528.orig/ssl/s3_srvr.c openssl-SNAP-20080528/ssl/s3_srvr.c --- openssl-SNAP-20080528.orig/ssl/s3_srvr.c 2008-04-30 20:00:38.000000000 +0300 +++ openssl-SNAP-20080528/ssl/s3_srvr.c 2008-05-29 10:49:25.000000000 +0300 @@@@ -1004,6 +1004,59 @@@@ int ssl3_get_client_hello(SSL *s) d112 1 a112 1 @@@@ -1130,16 +1183,22 @@@@ int ssl3_send_server_hello(SSL *s) d136 4 a139 4 diff -upr openssl-SNAP-20080528.orig/ssl/ssl.h openssl-SNAP-20080528/ssl/ssl.h --- openssl-SNAP-20080528.orig/ssl/ssl.h 2008-05-26 15:00:37.000000000 +0300 +++ openssl-SNAP-20080528/ssl/ssl.h 2008-05-29 10:49:25.000000000 +0300 @@@@ -354,6 +354,7 @@@@ extern "C" { d147 1 a147 1 @@@@ -380,6 +381,8 @@@@ DECLARE_STACK_OF(SSL_CIPHER) d156 1 a156 1 @@@@ -1128,6 +1131,13 @@@@ struct ssl_st d170 1 a170 1 @@@@ -1729,6 +1739,12 @@@@ void *SSL_COMP_get_compression_methods(v d183 1 a183 1 @@@@ -1928,6 +1944,7 @@@@ void ERR_load_SSL_strings(void); d191 3 a193 3 diff -upr openssl-SNAP-20080528.orig/ssl/ssl_err.c openssl-SNAP-20080528/ssl/ssl_err.c --- openssl-SNAP-20080528.orig/ssl/ssl_err.c 2007-10-27 03:01:29.000000000 +0300 +++ openssl-SNAP-20080528/ssl/ssl_err.c 2008-05-29 10:49:25.000000000 +0300 d202 3 a204 3 diff -upr openssl-SNAP-20080528.orig/ssl/ssl_sess.c openssl-SNAP-20080528/ssl/ssl_sess.c --- openssl-SNAP-20080528.orig/ssl/ssl_sess.c 2008-05-26 15:00:37.000000000 +0300 +++ openssl-SNAP-20080528/ssl/ssl_sess.c 2008-05-29 10:49:25.000000000 +0300 d258 3 a260 3 diff -upr openssl-SNAP-20080528.orig/ssl/t1_lib.c openssl-SNAP-20080528/ssl/t1_lib.c --- openssl-SNAP-20080528.orig/ssl/t1_lib.c 2008-04-30 20:00:39.000000000 +0300 +++ openssl-SNAP-20080528/ssl/t1_lib.c 2008-05-29 10:49:25.000000000 +0300 d274 1 a274 1 @@@@ -357,8 +363,24 @@@@ unsigned char *ssl_add_clienthello_tlsex d299 1 a299 1 @@@@ -371,6 +393,7 @@@@ unsigned char *ssl_add_clienthello_tlsex d307 1 a307 1 @@@@ -1427,6 +1450,8 @@@@ int tls1_process_ticket(SSL *s, unsigned d316 4 a319 4 diff -upr openssl-SNAP-20080528.orig/ssl/tls1.h openssl-SNAP-20080528/ssl/tls1.h --- openssl-SNAP-20080528.orig/ssl/tls1.h 2008-04-30 20:00:39.000000000 +0300 +++ openssl-SNAP-20080528/ssl/tls1.h 2008-05-29 10:49:25.000000000 +0300 @@@@ -512,6 +512,14 @@@@ SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_T d334 3 a336 3 diff -upr openssl-SNAP-20080528.orig/util/ssleay.num openssl-SNAP-20080528/util/ssleay.num --- openssl-SNAP-20080528.orig/util/ssleay.num 2007-08-31 16:03:14.000000000 +0300 +++ openssl-SNAP-20080528/util/ssleay.num 2008-05-29 10:49:25.000000000 +0300 @ 1.1.1.1.4.1 log @file openssl-0.9.9-session-ticket.patch was added on branch matt-armv6 on 2008-03-23 00:17:14 +0000 @ text @d1 342 @ 1.1.1.1.4.2 log @sync with HEAD @ text @a0 342 This patch adds support for TLS SessionTicket extension (RFC 4507) for the parts used by EAP-FAST (RFC 4851). This is based on the patch from Alexey Kobozev (sent to openssl-dev mailing list on Tue, 07 Jun 2005 15:40:58 +0300). diff -upr openssl-SNAP-20071101.orig/ssl/s3_clnt.c openssl-SNAP-20071101/ssl/s3_clnt.c --- openssl-SNAP-20071101.orig/ssl/s3_clnt.c 2007-10-26 06:00:28.000000000 -0700 +++ openssl-SNAP-20071101/ssl/s3_clnt.c 2007-11-01 19:19:43.000000000 -0700 @@@@ -715,7 +715,7 @@@@ int ssl3_get_server_hello(SSL *s) STACK_OF(SSL_CIPHER) *sk; SSL_CIPHER *c; unsigned char *p,*d; - int i,al,ok; + int i,al,ok,pre_shared; unsigned int j; long n; #ifndef OPENSSL_NO_COMP @@@@ -782,7 +782,26 @@@@ int ssl3_get_server_hello(SSL *s) goto f_err; } - if (j != 0 && j == s->session->session_id_length + /* check if we want to resume the session based on external pre-shared secret */ + pre_shared = 0; +#ifndef OPENSSL_NO_TLSEXT + if (s->version >= TLS1_VERSION && s->tls_session_secret_cb) + { + SSL_CIPHER *pref_cipher=NULL; + s->session->master_key_length=sizeof(s->session->master_key); + if (s->tls_session_secret_cb(s, s->session->master_key, &s->session->master_key_length, + NULL, &pref_cipher, s->tls_session_secret_cb_arg)) + { + s->hit=1; + s->session->cipher=pref_cipher ? pref_cipher : ssl_get_cipher_by_char(s,p+j); + s->session->session_id_length = j; + memcpy(s->session->session_id, p, j); + pre_shared = 1; + } + } +#endif /* OPENSSL_NO_TLSEXT */ + + if ((pre_shared || j != 0) && j == s->session->session_id_length && memcmp(p,s->session->session_id,j) == 0) { if(s->sid_ctx_length != s->session->sid_ctx_length diff -upr openssl-SNAP-20071101.orig/ssl/s3_srvr.c openssl-SNAP-20071101/ssl/s3_srvr.c --- openssl-SNAP-20071101.orig/ssl/s3_srvr.c 2007-10-26 06:00:29.000000000 -0700 +++ openssl-SNAP-20071101/ssl/s3_srvr.c 2007-11-01 19:19:43.000000000 -0700 @@@@ -992,6 +992,59 @@@@ int ssl3_get_client_hello(SSL *s) SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_CLIENTHELLO_TLSEXT); goto err; } + + /* Check if we want to use external pre-shared secret for this + * handshake for not reused session only. We need to generate + * server_random before calling tls_session_secret_cb in order to allow + * SessionTicket processing to use it in key derivation. */ + { + unsigned long Time; + unsigned char *pos; + Time=(unsigned long)time(NULL); /* Time */ + pos=s->s3->server_random; + l2n(Time,pos); + if (RAND_pseudo_bytes(pos,SSL3_RANDOM_SIZE-4) <= 0) + { + al=SSL_AD_INTERNAL_ERROR; + goto f_err; + } + } + + if (!s->hit && s->version >= TLS1_VERSION && s->tls_session_secret_cb) + { + SSL_CIPHER *pref_cipher=NULL; + + s->session->master_key_length=sizeof(s->session->master_key); + if(s->tls_session_secret_cb(s, s->session->master_key, &s->session->master_key_length, + ciphers, &pref_cipher, s->tls_session_secret_cb_arg)) + { + s->hit=1; + s->session->ciphers=ciphers; + s->session->verify_result=X509_V_OK; + + ciphers=NULL; + + /* check if some cipher was preferred by call back */ + pref_cipher=pref_cipher ? pref_cipher : ssl3_choose_cipher(s, s->session->ciphers, SSL_get_ciphers(s)); + if (pref_cipher == NULL) + { + al=SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_NO_SHARED_CIPHER); + goto f_err; + } + + s->session->cipher=pref_cipher; + + if (s->cipher_list) + sk_SSL_CIPHER_free(s->cipher_list); + + if (s->cipher_list_by_id) + sk_SSL_CIPHER_free(s->cipher_list_by_id); + + s->cipher_list = sk_SSL_CIPHER_dup(s->session->ciphers); + s->cipher_list_by_id = sk_SSL_CIPHER_dup(s->session->ciphers); + } + } #endif /* Worst case, we will use the NULL compression, but if we have other @@@@ -1118,16 +1171,22 @@@@ int ssl3_send_server_hello(SSL *s) unsigned char *buf; unsigned char *p,*d; int i,sl; - unsigned long l,Time; + unsigned long l; +#ifdef OPENSSL_NO_TLSEXT + unsigned long Time; +#endif if (s->state == SSL3_ST_SW_SRVR_HELLO_A) { buf=(unsigned char *)s->init_buf->data; +#ifdef OPENSSL_NO_TLSEXT p=s->s3->server_random; + /* Generate server_random if it was not needed previously */ Time=(unsigned long)time(NULL); /* Time */ l2n(Time,p); if (RAND_pseudo_bytes(p,SSL3_RANDOM_SIZE-4) <= 0) return -1; +#endif /* Do the message type and length last */ d=p= &(buf[4]); diff -upr openssl-SNAP-20071101.orig/ssl/ssl.h openssl-SNAP-20071101/ssl/ssl.h --- openssl-SNAP-20071101.orig/ssl/ssl.h 2007-10-26 17:01:28.000000000 -0700 +++ openssl-SNAP-20071101/ssl/ssl.h 2007-11-01 19:20:47.000000000 -0700 @@@@ -353,6 +353,7 @@@@ extern "C" { * 'struct ssl_st *' function parameters used to prototype callbacks * in SSL_CTX. */ typedef struct ssl_st *ssl_crock_st; +typedef struct tls_extension_st TLS_EXTENSION; /* used to hold info on the particular ciphers used */ typedef struct ssl_cipher_st @@@@ -379,6 +380,8 @@@@ DECLARE_STACK_OF(SSL_CIPHER) typedef struct ssl_st SSL; typedef struct ssl_ctx_st SSL_CTX; +typedef int (*tls_session_secret_cb_fn)(SSL *s, void *secret, int *secret_len, STACK_OF(SSL_CIPHER) *peer_ciphers, SSL_CIPHER **cipher, void *arg); + /* Used to hold functions for SSLv2 or SSLv3/TLSv1 functions */ typedef struct ssl_method_st { @@@@ -1121,6 +1124,13 @@@@ struct ssl_st void *tlsext_opaque_prf_input; size_t tlsext_opaque_prf_input_len; + /* TLS extensions */ + TLS_EXTENSION *tls_extension; + + /* TLS pre-shared secret session resumption */ + tls_session_secret_cb_fn tls_session_secret_cb; + void *tls_session_secret_cb_arg; + SSL_CTX * initial_ctx; /* initial ctx, used to store sessions */ #define session_ctx initial_ctx #else @@@@ -1721,6 +1731,12 @@@@ void *SSL_COMP_get_compression_methods(v int SSL_COMP_add_compression_method(int id,void *cm); #endif +/* TLS extensions functions */ +int SSL_set_hello_extension(SSL *s, int ext_type, void *ext_data, int ext_len); + +/* Pre-shared secret session resumption functions */ +int SSL_set_session_secret_cb(SSL *s, tls_session_secret_cb_fn tls_session_secret_cb, void *arg); + /* BEGIN ERROR CODES */ /* The following lines are auto generated by the script mkerr.pl. Any changes * made after this point may be overwritten when the script is next run. @@@@ -1920,6 +1936,7 @@@@ void ERR_load_SSL_strings(void); #define SSL_F_TLS1_PRF 284 #define SSL_F_TLS1_SETUP_KEY_BLOCK 211 #define SSL_F_WRITE_PENDING 212 +#define SSL_F_SSL_SET_HELLO_EXTENSION 213 /* Reason codes. */ #define SSL_R_APP_DATA_IN_HANDSHAKE 100 diff -upr openssl-SNAP-20071101.orig/ssl/ssl_err.c openssl-SNAP-20071101/ssl/ssl_err.c --- openssl-SNAP-20071101.orig/ssl/ssl_err.c 2007-10-26 17:01:29.000000000 -0700 +++ openssl-SNAP-20071101/ssl/ssl_err.c 2007-11-01 19:19:43.000000000 -0700 @@@@ -260,6 +260,7 @@@@ static ERR_STRING_DATA SSL_str_functs[]= {ERR_FUNC(SSL_F_TLS1_PRF), "tls1_prf"}, {ERR_FUNC(SSL_F_TLS1_SETUP_KEY_BLOCK), "TLS1_SETUP_KEY_BLOCK"}, {ERR_FUNC(SSL_F_WRITE_PENDING), "WRITE_PENDING"}, +{ERR_FUNC(SSL_F_SSL_SET_HELLO_EXTENSION), "SSL_set_hello_extension"}, {0,NULL} }; diff -upr openssl-SNAP-20071101.orig/ssl/ssl_sess.c openssl-SNAP-20071101/ssl/ssl_sess.c --- openssl-SNAP-20071101.orig/ssl/ssl_sess.c 2007-10-17 11:00:45.000000000 -0700 +++ openssl-SNAP-20071101/ssl/ssl_sess.c 2007-11-01 19:19:43.000000000 -0700 @@@@ -831,6 +831,52 @@@@ long SSL_CTX_get_timeout(const SSL_CTX * return(s->session_timeout); } +#ifndef OPENSSL_NO_TLSEXT +int SSL_set_session_secret_cb(SSL *s, int (*tls_session_secret_cb)(SSL *s, void *secret, int *secret_len, + STACK_OF(SSL_CIPHER) *peer_ciphers, SSL_CIPHER **cipher, void *arg), void *arg) +{ + if (s == NULL) return(0); + s->tls_session_secret_cb = tls_session_secret_cb; + s->tls_session_secret_cb_arg = arg; + return(1); +} + +int SSL_set_hello_extension(SSL *s, int ext_type, void *ext_data, int ext_len) +{ + if(s->version >= TLS1_VERSION) + { + if(s->tls_extension) + { + OPENSSL_free(s->tls_extension); + s->tls_extension = NULL; + } + + s->tls_extension = OPENSSL_malloc(sizeof(TLS_EXTENSION) + ext_len); + if(!s->tls_extension) + { + SSLerr(SSL_F_SSL_SET_HELLO_EXTENSION, ERR_R_MALLOC_FAILURE); + return 0; + } + + s->tls_extension->type = ext_type; + + if(ext_data) + { + s->tls_extension->length = ext_len; + s->tls_extension->data = s->tls_extension + 1; + memcpy(s->tls_extension->data, ext_data, ext_len); + } else { + s->tls_extension->length = 0; + s->tls_extension->data = NULL; + } + + return 1; + } + + return 0; +} +#endif /* OPENSSL_NO_TLSEXT */ + typedef struct timeout_param_st { SSL_CTX *ctx; diff -upr openssl-SNAP-20071101.orig/ssl/t1_lib.c openssl-SNAP-20071101/ssl/t1_lib.c --- openssl-SNAP-20071101.orig/ssl/t1_lib.c 2007-10-26 06:00:29.000000000 -0700 +++ openssl-SNAP-20071101/ssl/t1_lib.c 2007-11-01 19:19:43.000000000 -0700 @@@@ -154,6 +154,12 @@@@ int tls1_new(SSL *s) void tls1_free(SSL *s) { +#ifndef OPENSSL_NO_TLSEXT + if(s->tls_extension) + { + OPENSSL_free(s->tls_extension); + } +#endif ssl3_free(s); } @@@@ -355,8 +361,24 @@@@ unsigned char *ssl_add_clienthello_tlsex int ticklen; if (s->session && s->session->tlsext_tick) ticklen = s->session->tlsext_ticklen; + else if (s->session && s->tls_extension && + s->tls_extension->type == TLSEXT_TYPE_session_ticket && + s->tls_extension->data) + { + ticklen = s->tls_extension->length; + s->session->tlsext_tick = OPENSSL_malloc(ticklen); + if (!s->session->tlsext_tick) + return NULL; + memcpy(s->session->tlsext_tick, s->tls_extension->data, + ticklen); + s->session->tlsext_ticklen = ticklen; + } else ticklen = 0; + if (ticklen == 0 && s->tls_extension && + s->tls_extension->type == TLSEXT_TYPE_session_ticket && + s->tls_extension->data == NULL) + goto skip_ext; /* Check for enough room 2 for extension type, 2 for len * rest for ticket */ @@@@ -369,6 +391,7 @@@@ unsigned char *ssl_add_clienthello_tlsex ret += ticklen; } } + skip_ext: #ifdef TLSEXT_TYPE_opaque_prf_input if (s->s3->client_opaque_prf_input != NULL) @@@@ -1422,6 +1445,8 @@@@ int tls1_process_ticket(SSL *s, unsigned s->tlsext_ticket_expected = 1; return 0; /* Cache miss */ } + if (s->tls_session_secret_cb) + return 0; return tls_decrypt_ticket(s, p, size, session_id, len, ret); } diff -upr openssl-SNAP-20071101.orig/ssl/tls1.h openssl-SNAP-20071101/ssl/tls1.h --- openssl-SNAP-20071101.orig/ssl/tls1.h 2007-09-26 15:01:39.000000000 -0700 +++ openssl-SNAP-20071101/ssl/tls1.h 2007-11-01 19:19:43.000000000 -0700 @@@@ -509,6 +509,14 @@@@ SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TLSEXT_OPA #define TLS_MD_MASTER_SECRET_CONST "\x6d\x61\x73\x74\x65\x72\x20\x73\x65\x63\x72\x65\x74" /*master secret*/ #endif +/* TLS extension struct */ +struct tls_extension_st +{ + unsigned short type; + unsigned short length; + void *data; +}; + #ifdef __cplusplus } #endif diff -upr openssl-SNAP-20071101.orig/util/ssleay.num openssl-SNAP-20071101/util/ssleay.num --- openssl-SNAP-20071101.orig/util/ssleay.num 2007-08-31 06:03:14.000000000 -0700 +++ openssl-SNAP-20071101/util/ssleay.num 2007-11-01 19:19:43.000000000 -0700 @@@@ -253,3 +253,5 @@@@ PEM_write_bio_SSL_SESSION PEM_read_SSL_SESSION 302 EXIST:!WIN16:FUNCTION: PEM_read_bio_SSL_SESSION 303 EXIST::FUNCTION: PEM_write_SSL_SESSION 304 EXIST:!WIN16:FUNCTION: +SSL_set_hello_extension 305 EXIST::FUNCTION:TLSEXT +SSL_set_session_secret_cb 306 EXIST::FUNCTION:TLSEXT @