|
@@ -6,10 +6,11 @@ This is based on the patch from Alexey Kobozev <akobozev@cisco.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-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)
|
|
|
|
|
|
+Index: openssl-SNAP-20080822/ssl/s3_clnt.c
|
|
|
|
+===================================================================
|
|
|
|
+--- openssl-SNAP-20080822.orig/ssl/s3_clnt.c
|
|
|
|
++++ openssl-SNAP-20080822/ssl/s3_clnt.c
|
|
|
|
+@@ -788,6 +788,20 @@ int ssl3_get_server_hello(SSL *s)
|
|
goto f_err;
|
|
goto f_err;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -30,7 +31,7 @@ diff -upr openssl-SNAP-20080528.orig/ssl/s3_clnt.c openssl-SNAP-20080528/ssl/s3_
|
|
if (j != 0 && j == s->session->session_id_length
|
|
if (j != 0 && j == s->session->session_id_length
|
|
&& memcmp(p,s->session->session_id,j) == 0)
|
|
&& memcmp(p,s->session->session_id,j) == 0)
|
|
{
|
|
{
|
|
-@@ -2918,11 +2932,8 @@ static int ssl3_check_finished(SSL *s)
|
|
|
|
|
|
+@@ -2927,11 +2941,8 @@ static int ssl3_check_finished(SSL *s)
|
|
{
|
|
{
|
|
int ok;
|
|
int ok;
|
|
long n;
|
|
long n;
|
|
@@ -44,10 +45,11 @@ diff -upr openssl-SNAP-20080528.orig/ssl/s3_clnt.c openssl-SNAP-20080528/ssl/s3_
|
|
return 1;
|
|
return 1;
|
|
/* this function is called when we really expect a Certificate
|
|
/* this function is called when we really expect a Certificate
|
|
* message, so permit appropriate message length */
|
|
* 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)
|
|
|
|
|
|
+Index: openssl-SNAP-20080822/ssl/s3_srvr.c
|
|
|
|
+===================================================================
|
|
|
|
+--- openssl-SNAP-20080822.orig/ssl/s3_srvr.c
|
|
|
|
++++ openssl-SNAP-20080822/ssl/s3_srvr.c
|
|
|
|
+@@ -1004,6 +1004,61 @@ int ssl3_get_client_hello(SSL *s)
|
|
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_CLIENTHELLO_TLSEXT);
|
|
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_CLIENTHELLO_TLSEXT);
|
|
goto err;
|
|
goto err;
|
|
}
|
|
}
|
|
@@ -74,15 +76,15 @@ diff -upr openssl-SNAP-20080528.orig/ssl/s3_srvr.c openssl-SNAP-20080528/ssl/s3_
|
|
+ SSL_CIPHER *pref_cipher=NULL;
|
|
+ SSL_CIPHER *pref_cipher=NULL;
|
|
+
|
|
+
|
|
+ s->session->master_key_length=sizeof(s->session->master_key);
|
|
+ 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,
|
|
|
|
|
|
++ 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))
|
|
+ ciphers, &pref_cipher, s->tls_session_secret_cb_arg))
|
|
+ {
|
|
+ {
|
|
+ s->hit=1;
|
|
+ s->hit=1;
|
|
+ s->session->ciphers=ciphers;
|
|
+ s->session->ciphers=ciphers;
|
|
+ s->session->verify_result=X509_V_OK;
|
|
+ s->session->verify_result=X509_V_OK;
|
|
-+
|
|
|
|
|
|
++
|
|
+ ciphers=NULL;
|
|
+ ciphers=NULL;
|
|
-+
|
|
|
|
|
|
++
|
|
+ /* check if some cipher was preferred by call back */
|
|
+ /* 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));
|
|
+ pref_cipher=pref_cipher ? pref_cipher : ssl3_choose_cipher(s, s->session->ciphers, SSL_get_ciphers(s));
|
|
+ if (pref_cipher == NULL)
|
|
+ if (pref_cipher == NULL)
|
|
@@ -102,12 +104,14 @@ diff -upr openssl-SNAP-20080528.orig/ssl/s3_srvr.c openssl-SNAP-20080528/ssl/s3_
|
|
+
|
|
+
|
|
+ s->cipher_list = sk_SSL_CIPHER_dup(s->session->ciphers);
|
|
+ s->cipher_list = sk_SSL_CIPHER_dup(s->session->ciphers);
|
|
+ s->cipher_list_by_id = sk_SSL_CIPHER_dup(s->session->ciphers);
|
|
+ s->cipher_list_by_id = sk_SSL_CIPHER_dup(s->session->ciphers);
|
|
|
|
++ s->s3->tmp.new_cipher = pref_cipher;
|
|
|
|
++ ssl3_digest_cached_records(s);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ }
|
|
#endif
|
|
#endif
|
|
|
|
|
|
/* Worst case, we will use the NULL compression, but if we have other
|
|
/* Worst case, we will use the NULL compression, but if we have other
|
|
-@@ -1130,16 +1183,22 @@ int ssl3_send_server_hello(SSL *s)
|
|
|
|
|
|
+@@ -1130,16 +1185,22 @@ int ssl3_send_server_hello(SSL *s)
|
|
unsigned char *buf;
|
|
unsigned char *buf;
|
|
unsigned char *p,*d;
|
|
unsigned char *p,*d;
|
|
int i,sl;
|
|
int i,sl;
|
|
@@ -131,9 +135,22 @@ diff -upr openssl-SNAP-20080528.orig/ssl/s3_srvr.c openssl-SNAP-20080528/ssl/s3_
|
|
/* Do the message type and length last */
|
|
/* Do the message type and length last */
|
|
d=p= &(buf[4]);
|
|
d=p= &(buf[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
|
|
|
|
|
|
+Index: openssl-SNAP-20080822/ssl/ssl_err.c
|
|
|
|
+===================================================================
|
|
|
|
+--- openssl-SNAP-20080822.orig/ssl/ssl_err.c
|
|
|
|
++++ openssl-SNAP-20080822/ssl/ssl_err.c
|
|
|
|
+@@ -263,6 +263,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}
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+Index: openssl-SNAP-20080822/ssl/ssl.h
|
|
|
|
+===================================================================
|
|
|
|
+--- openssl-SNAP-20080822.orig/ssl/ssl.h
|
|
|
|
++++ openssl-SNAP-20080822/ssl/ssl.h
|
|
@@ -354,6 +354,7 @@ extern "C" {
|
|
@@ -354,6 +354,7 @@ extern "C" {
|
|
* 'struct ssl_st *' function parameters used to prototype callbacks
|
|
* 'struct ssl_st *' function parameters used to prototype callbacks
|
|
* in SSL_CTX. */
|
|
* in SSL_CTX. */
|
|
@@ -142,16 +159,16 @@ diff -upr openssl-SNAP-20080528.orig/ssl/ssl.h openssl-SNAP-20080528/ssl/ssl.h
|
|
|
|
|
|
/* used to hold info on the particular ciphers used */
|
|
/* used to hold info on the particular ciphers used */
|
|
typedef struct ssl_cipher_st
|
|
typedef struct ssl_cipher_st
|
|
-@@ -380,6 +381,8 @@ DECLARE_STACK_OF(SSL_CIPHER)
|
|
|
|
- typedef struct ssl_st SSL;
|
|
|
|
- typedef struct ssl_ctx_st SSL_CTX;
|
|
|
|
|
|
+@@ -377,6 +378,8 @@ typedef struct ssl_cipher_st
|
|
|
|
+
|
|
|
|
+ DECLARE_STACK_OF(SSL_CIPHER)
|
|
|
|
|
|
+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);
|
|
+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 */
|
|
/* Used to hold functions for SSLv2 or SSLv3/TLSv1 functions */
|
|
typedef struct ssl_method_st
|
|
typedef struct ssl_method_st
|
|
{
|
|
{
|
|
-@@ -1128,6 +1131,13 @@ struct ssl_st
|
|
|
|
|
|
+@@ -1144,6 +1147,13 @@ struct ssl_st
|
|
void *tlsext_opaque_prf_input;
|
|
void *tlsext_opaque_prf_input;
|
|
size_t tlsext_opaque_prf_input_len;
|
|
size_t tlsext_opaque_prf_input_len;
|
|
|
|
|
|
@@ -165,7 +182,7 @@ diff -upr openssl-SNAP-20080528.orig/ssl/ssl.h openssl-SNAP-20080528/ssl/ssl.h
|
|
SSL_CTX * initial_ctx; /* initial ctx, used to store sessions */
|
|
SSL_CTX * initial_ctx; /* initial ctx, used to store sessions */
|
|
#define session_ctx initial_ctx
|
|
#define session_ctx initial_ctx
|
|
#else
|
|
#else
|
|
-@@ -1729,6 +1739,12 @@ void *SSL_COMP_get_compression_methods(v
|
|
|
|
|
|
+@@ -1745,6 +1755,12 @@ void *SSL_COMP_get_compression_methods(v
|
|
int SSL_COMP_add_compression_method(int id,void *cm);
|
|
int SSL_COMP_add_compression_method(int id,void *cm);
|
|
#endif
|
|
#endif
|
|
|
|
|
|
@@ -178,7 +195,7 @@ diff -upr openssl-SNAP-20080528.orig/ssl/ssl.h openssl-SNAP-20080528/ssl/ssl.h
|
|
/* BEGIN ERROR CODES */
|
|
/* BEGIN ERROR CODES */
|
|
/* The following lines are auto generated by the script mkerr.pl. Any changes
|
|
/* 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.
|
|
* made after this point may be overwritten when the script is next run.
|
|
-@@ -1928,6 +1944,7 @@ void ERR_load_SSL_strings(void);
|
|
|
|
|
|
+@@ -1947,6 +1963,7 @@ void ERR_load_SSL_strings(void);
|
|
#define SSL_F_TLS1_PRF 284
|
|
#define SSL_F_TLS1_PRF 284
|
|
#define SSL_F_TLS1_SETUP_KEY_BLOCK 211
|
|
#define SSL_F_TLS1_SETUP_KEY_BLOCK 211
|
|
#define SSL_F_WRITE_PENDING 212
|
|
#define SSL_F_WRITE_PENDING 212
|
|
@@ -186,26 +203,16 @@ diff -upr openssl-SNAP-20080528.orig/ssl/ssl.h openssl-SNAP-20080528/ssl/ssl.h
|
|
|
|
|
|
/* Reason codes. */
|
|
/* Reason codes. */
|
|
#define SSL_R_APP_DATA_IN_HANDSHAKE 100
|
|
#define SSL_R_APP_DATA_IN_HANDSHAKE 100
|
|
-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
|
|
|
|
-@@ -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-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
|
|
|
|
-@@ -831,6 +831,52 @@ long SSL_CTX_get_timeout(const SSL_CTX *
|
|
|
|
|
|
+Index: openssl-SNAP-20080822/ssl/ssl_sess.c
|
|
|
|
+===================================================================
|
|
|
|
+--- openssl-SNAP-20080822.orig/ssl/ssl_sess.c
|
|
|
|
++++ openssl-SNAP-20080822/ssl/ssl_sess.c
|
|
|
|
+@@ -834,6 +834,52 @@ long SSL_CTX_get_timeout(const SSL_CTX *
|
|
return(s->session_timeout);
|
|
return(s->session_timeout);
|
|
}
|
|
}
|
|
|
|
|
|
+#ifndef OPENSSL_NO_TLSEXT
|
|
+#ifndef OPENSSL_NO_TLSEXT
|
|
-+int SSL_set_session_secret_cb(SSL *s, int (*tls_session_secret_cb)(SSL *s, void *secret, int *secret_len,
|
|
|
|
|
|
++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)
|
|
+ STACK_OF(SSL_CIPHER) *peer_ciphers, SSL_CIPHER **cipher, void *arg), void *arg)
|
|
+{
|
|
+{
|
|
+ if (s == NULL) return(0);
|
|
+ if (s == NULL) return(0);
|
|
@@ -253,9 +260,10 @@ diff -upr openssl-SNAP-20080528.orig/ssl/ssl_sess.c openssl-SNAP-20080528/ssl/ss
|
|
typedef struct timeout_param_st
|
|
typedef struct timeout_param_st
|
|
{
|
|
{
|
|
SSL_CTX *ctx;
|
|
SSL_CTX *ctx;
|
|
-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
|
|
|
|
|
|
+Index: openssl-SNAP-20080822/ssl/t1_lib.c
|
|
|
|
+===================================================================
|
|
|
|
+--- openssl-SNAP-20080822.orig/ssl/t1_lib.c
|
|
|
|
++++ openssl-SNAP-20080822/ssl/t1_lib.c
|
|
@@ -154,6 +154,12 @@ int tls1_new(SSL *s)
|
|
@@ -154,6 +154,12 @@ int tls1_new(SSL *s)
|
|
|
|
|
|
void tls1_free(SSL *s)
|
|
void tls1_free(SSL *s)
|
|
@@ -302,18 +310,26 @@ diff -upr openssl-SNAP-20080528.orig/ssl/t1_lib.c openssl-SNAP-20080528/ssl/t1_l
|
|
|
|
|
|
#ifdef TLSEXT_TYPE_opaque_prf_input
|
|
#ifdef TLSEXT_TYPE_opaque_prf_input
|
|
if (s->s3->client_opaque_prf_input != NULL)
|
|
if (s->s3->client_opaque_prf_input != NULL)
|
|
-@@ -1427,6 +1450,8 @@ int tls1_process_ticket(SSL *s, unsigned
|
|
|
|
|
|
+@@ -1428,6 +1451,15 @@ int tls1_process_ticket(SSL *s, unsigned
|
|
s->tlsext_ticket_expected = 1;
|
|
s->tlsext_ticket_expected = 1;
|
|
return 0; /* Cache miss */
|
|
return 0; /* Cache miss */
|
|
}
|
|
}
|
|
+ if (s->tls_session_secret_cb)
|
|
+ if (s->tls_session_secret_cb)
|
|
|
|
++ {
|
|
|
|
++ /* Indicate cache miss here and instead of
|
|
|
|
++ * generating the session from ticket now,
|
|
|
|
++ * trigger abbreviated handshake based on
|
|
|
|
++ * external mechanism to calculate the master
|
|
|
|
++ * secret later. */
|
|
+ return 0;
|
|
+ return 0;
|
|
|
|
++ }
|
|
return tls_decrypt_ticket(s, p, size, session_id, len,
|
|
return tls_decrypt_ticket(s, p, size, session_id, len,
|
|
ret);
|
|
ret);
|
|
}
|
|
}
|
|
-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
|
|
|
|
|
|
+Index: openssl-SNAP-20080822/ssl/tls1.h
|
|
|
|
+===================================================================
|
|
|
|
+--- openssl-SNAP-20080822.orig/ssl/tls1.h
|
|
|
|
++++ openssl-SNAP-20080822/ssl/tls1.h
|
|
@@ -512,6 +512,14 @@ SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_T
|
|
@@ -512,6 +512,14 @@ SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_T
|
|
#define TLS_MD_MASTER_SECRET_CONST "\x6d\x61\x73\x74\x65\x72\x20\x73\x65\x63\x72\x65\x74" /*master secret*/
|
|
#define TLS_MD_MASTER_SECRET_CONST "\x6d\x61\x73\x74\x65\x72\x20\x73\x65\x63\x72\x65\x74" /*master secret*/
|
|
#endif
|
|
#endif
|
|
@@ -329,12 +345,13 @@ diff -upr openssl-SNAP-20080528.orig/ssl/tls1.h openssl-SNAP-20080528/ssl/tls1.h
|
|
#ifdef __cplusplus
|
|
#ifdef __cplusplus
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
-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
|
|
|
|
-@@ -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
|
|
|
|
|
|
+Index: openssl-SNAP-20080822/util/ssleay.num
|
|
|
|
+===================================================================
|
|
|
|
+--- openssl-SNAP-20080822.orig/util/ssleay.num
|
|
|
|
++++ openssl-SNAP-20080822/util/ssleay.num
|
|
|
|
+@@ -254,3 +254,5 @@ PEM_read_bio_SSL_SESSION
|
|
|
|
+ SSL_CTX_set_psk_server_callback 303 EXIST::FUNCTION:PSK
|
|
|
|
+ SSL_get_psk_identity 304 EXIST::FUNCTION:PSK
|
|
|
|
+ PEM_write_SSL_SESSION 305 EXIST:!WIN16:FUNCTION:
|
|
|
|
++SSL_set_hello_extension 306 EXIST::FUNCTION:TLSEXT
|
|
|
|
++SSL_set_session_secret_cb 307 EXIST::FUNCTION:TLSEXT
|