3550 lines
122 KiB
Diff
3550 lines
122 KiB
Diff
From f5fa824e9a86940835e30a5a0b1fd3d8a7c4c640 Mon Sep 17 00:00:00 2001
|
|
From: Jouni Malinen <j@w1.fi>
|
|
Date: Thu, 5 Jun 2014 20:43:00 +0300
|
|
Subject: [PATCH] Update OpenSSL 0.9.8 patch for EAP-FAST support
|
|
|
|
The 0.9.9 branch was for development purposes only, so no one should be
|
|
using that in production and there is not much point in maintaining the
|
|
obsolete patch here either. Similarly, the old 0.9.8 versions are
|
|
obsolete at this point in time and taken into account the recent OpenSSL
|
|
vulnerabilities, anything older than 0.9.8za should not really be used.
|
|
|
|
Prepare an updated version of the TLS session ticket patch based on the
|
|
current OpenSSL 0.9.8za release and remove all the older TLS extension
|
|
patches.
|
|
|
|
Signed-off-by: Jouni Malinen <j@w1.fi>
|
|
---
|
|
patches/openssl-0.9.8-tls-extensions.patch | 429 --------------------------
|
|
patches/openssl-0.9.8d-tls-extensions.patch | 429 --------------------------
|
|
patches/openssl-0.9.8e-tls-extensions.patch | 353 ---------------------
|
|
patches/openssl-0.9.8g-tls-extensions.patch | 330 --------------------
|
|
patches/openssl-0.9.8h-tls-extensions.patch | 344 ---------------------
|
|
patches/openssl-0.9.8i-tls-extensions.patch | 404 ------------------------
|
|
patches/openssl-0.9.8x-tls-extensions.patch | 396 ------------------------
|
|
patches/openssl-0.9.8za-tls-extensions.patch | 396 ++++++++++++++++++++++++
|
|
patches/openssl-0.9.9-session-ticket.patch | 374 ----------------------
|
|
9 files changed, 396 insertions(+), 3059 deletions(-)
|
|
delete mode 100644 patches/openssl-0.9.8-tls-extensions.patch
|
|
delete mode 100644 patches/openssl-0.9.8d-tls-extensions.patch
|
|
delete mode 100644 patches/openssl-0.9.8e-tls-extensions.patch
|
|
delete mode 100644 patches/openssl-0.9.8g-tls-extensions.patch
|
|
delete mode 100644 patches/openssl-0.9.8h-tls-extensions.patch
|
|
delete mode 100644 patches/openssl-0.9.8i-tls-extensions.patch
|
|
delete mode 100644 patches/openssl-0.9.8x-tls-extensions.patch
|
|
create mode 100644 patches/openssl-0.9.8za-tls-extensions.patch
|
|
delete mode 100644 patches/openssl-0.9.9-session-ticket.patch
|
|
|
|
diff --git a/patches/openssl-0.9.8-tls-extensions.patch b/patches/openssl-0.9.8-tls-extensions.patch
|
|
deleted file mode 100644
|
|
index 44490cc..0000000
|
|
--- a/patches/openssl-0.9.8-tls-extensions.patch
|
|
+++ /dev/null
|
|
@@ -1,429 +0,0 @@
|
|
-This patch is adding support for TLS hello extensions and externally
|
|
-generated pre-shared key material to OpenSSL 0.9.8. This is
|
|
-based on the patch from Alexey Kobozev <akobozev@cisco.com>
|
|
-(sent to openssl-dev mailing list on Tue, 07 Jun 2005 15:40:58 +0300).
|
|
-
|
|
-
|
|
-
|
|
-diff -uprN openssl-0.9.8.orig/include/openssl/ssl.h openssl-0.9.8/include/openssl/ssl.h
|
|
---- openssl-0.9.8.orig/include/openssl/ssl.h 2005-06-10 12:51:16.000000000 -0700
|
|
-+++ openssl-0.9.8/include/openssl/ssl.h 2005-07-19 20:02:15.000000000 -0700
|
|
-@@ -340,6 +340,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
|
|
-@@ -361,6 +362,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
|
|
- {
|
|
-@@ -968,6 +971,15 @@ struct ssl_st
|
|
- int first_packet;
|
|
- int client_version; /* what was passed, used for
|
|
- * SSLv3/TLS rollback check */
|
|
-+
|
|
-+ /* TLS externsions */
|
|
-+ TLS_EXTENSION *tls_extension;
|
|
-+ int (*tls_extension_cb)(SSL *s, TLS_EXTENSION *tls_ext, void *arg);
|
|
-+ void *tls_extension_cb_arg;
|
|
-+
|
|
-+ /* TLS pre-shared secret session resumption */
|
|
-+ tls_session_secret_cb_fn tls_session_secret_cb;
|
|
-+ void *tls_session_secret_cb_arg;
|
|
- };
|
|
-
|
|
- #ifdef __cplusplus
|
|
-@@ -1533,6 +1545,13 @@ 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);
|
|
-+int SSL_set_hello_extension_cb(SSL *s, int (*cb)(SSL *, TLS_EXTENSION *, void *), void *arg);
|
|
-+
|
|
-+/* 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.
|
|
-@@ -1714,6 +1733,7 @@ void ERR_load_SSL_strings(void);
|
|
- #define SSL_F_TLS1_ENC 210
|
|
- #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 -uprN openssl-0.9.8.orig/include/openssl/tls1.h openssl-0.9.8/include/openssl/tls1.h
|
|
---- openssl-0.9.8.orig/include/openssl/tls1.h 2003-07-22 05:34:21.000000000 -0700
|
|
-+++ openssl-0.9.8/include/openssl/tls1.h 2005-07-19 20:02:15.000000000 -0700
|
|
-@@ -282,6 +282,14 @@ extern "C" {
|
|
- #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 -uprN openssl-0.9.8.orig/ssl/Makefile openssl-0.9.8/ssl/Makefile
|
|
---- openssl-0.9.8.orig/ssl/Makefile 2005-05-30 16:20:30.000000000 -0700
|
|
-+++ openssl-0.9.8/ssl/Makefile 2005-07-19 20:02:15.000000000 -0700
|
|
-@@ -24,7 +24,7 @@ LIBSRC= \
|
|
- s2_meth.c s2_srvr.c s2_clnt.c s2_lib.c s2_enc.c s2_pkt.c \
|
|
- s3_meth.c s3_srvr.c s3_clnt.c s3_lib.c s3_enc.c s3_pkt.c s3_both.c \
|
|
- s23_meth.c s23_srvr.c s23_clnt.c s23_lib.c s23_pkt.c \
|
|
-- t1_meth.c t1_srvr.c t1_clnt.c t1_lib.c t1_enc.c \
|
|
-+ t1_meth.c t1_srvr.c t1_clnt.c t1_lib.c t1_enc.c t1_ext.c \
|
|
- d1_meth.c d1_srvr.c d1_clnt.c d1_lib.c d1_pkt.c \
|
|
- d1_both.c d1_enc.c \
|
|
- ssl_lib.c ssl_err2.c ssl_cert.c ssl_sess.c \
|
|
-@@ -35,7 +35,7 @@ LIBOBJ= \
|
|
- s2_meth.o s2_srvr.o s2_clnt.o s2_lib.o s2_enc.o s2_pkt.o \
|
|
- s3_meth.o s3_srvr.o s3_clnt.o s3_lib.o s3_enc.o s3_pkt.o s3_both.o \
|
|
- s23_meth.o s23_srvr.o s23_clnt.o s23_lib.o s23_pkt.o \
|
|
-- t1_meth.o t1_srvr.o t1_clnt.o t1_lib.o t1_enc.o \
|
|
-+ t1_meth.o t1_srvr.o t1_clnt.o t1_lib.o t1_enc.o t1_ext.o \
|
|
- d1_meth.o d1_srvr.o d1_clnt.o d1_lib.o d1_pkt.o \
|
|
- d1_both.o d1_enc.o \
|
|
- ssl_lib.o ssl_err2.o ssl_cert.o ssl_sess.o \
|
|
-@@ -968,3 +968,4 @@ t1_srvr.o: ../include/openssl/ssl23.h ..
|
|
- t1_srvr.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
|
|
- t1_srvr.o: ../include/openssl/tls1.h ../include/openssl/x509.h
|
|
- t1_srvr.o: ../include/openssl/x509_vfy.h ssl_locl.h t1_srvr.c
|
|
-+t1_ext.o: t1_ext.c ssl_locl.h
|
|
-diff -uprN openssl-0.9.8.orig/ssl/s3_clnt.c openssl-0.9.8/ssl/s3_clnt.c
|
|
---- openssl-0.9.8.orig/ssl/s3_clnt.c 2005-05-16 03:11:03.000000000 -0700
|
|
-+++ openssl-0.9.8/ssl/s3_clnt.c 2005-07-19 20:02:15.000000000 -0700
|
|
-@@ -606,6 +606,20 @@ int ssl3_client_hello(SSL *s)
|
|
- }
|
|
- *(p++)=0; /* Add the NULL method */
|
|
-
|
|
-+ /* send client hello extensions if any */
|
|
-+ if (s->version >= TLS1_VERSION && s->tls_extension)
|
|
-+ {
|
|
-+ // set the total extensions length
|
|
-+ s2n(s->tls_extension->length + 4, p);
|
|
-+
|
|
-+ // put the extensions with type and length
|
|
-+ s2n(s->tls_extension->type, p);
|
|
-+ s2n(s->tls_extension->length, p);
|
|
-+
|
|
-+ memcpy(p, s->tls_extension->data, s->tls_extension->length);
|
|
-+ p+=s->tls_extension->length;
|
|
-+ }
|
|
-+
|
|
- l=(p-d);
|
|
- d=buf;
|
|
- *(d++)=SSL3_MT_CLIENT_HELLO;
|
|
-@@ -628,7 +642,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;
|
|
- SSL_COMP *comp;
|
|
-@@ -693,7 +707,24 @@ 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;
|
|
-+ 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;
|
|
-+ }
|
|
-+ }
|
|
-+
|
|
-+ 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 -uprN openssl-0.9.8.orig/ssl/s3_srvr.c openssl-0.9.8/ssl/s3_srvr.c
|
|
---- openssl-0.9.8.orig/ssl/s3_srvr.c 2005-05-22 17:32:55.000000000 -0700
|
|
-+++ openssl-0.9.8/ssl/s3_srvr.c 2005-07-19 20:02:15.000000000 -0700
|
|
-@@ -955,6 +955,75 @@ int ssl3_get_client_hello(SSL *s)
|
|
- }
|
|
- #endif
|
|
-
|
|
-+ /* Check for TLS client hello extension here */
|
|
-+ if (p < (d+n) && s->version >= TLS1_VERSION)
|
|
-+ {
|
|
-+ if (s->tls_extension_cb)
|
|
-+ {
|
|
-+ TLS_EXTENSION tls_ext;
|
|
-+ unsigned short ext_total_len;
|
|
-+
|
|
-+ n2s(p, ext_total_len);
|
|
-+ n2s(p, tls_ext.type);
|
|
-+ n2s(p, tls_ext.length);
|
|
-+
|
|
-+ // sanity check in TLS extension len
|
|
-+ if (tls_ext.length > (d+n) - p)
|
|
-+ {
|
|
-+ // just cut the lenth to packet border
|
|
-+ tls_ext.length = (d+n) - p;
|
|
-+ }
|
|
-+
|
|
-+ tls_ext.data = p;
|
|
-+
|
|
-+ // returns an alert code or 0
|
|
-+ al = s->tls_extension_cb(s, &tls_ext, s->tls_extension_cb_arg);
|
|
-+ if (al != 0)
|
|
-+ {
|
|
-+ SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_PEER_ERROR);
|
|
-+ goto f_err;
|
|
-+ }
|
|
-+ }
|
|
-+ }
|
|
-+
|
|
-+ /* Check if we want to use external pre-shared secret for this handshake */
|
|
-+ /* for not reused session only */
|
|
-+ 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);
|
|
-+ }
|
|
-+ }
|
|
-+
|
|
- /* Given s->session->ciphers and SSL_get_ciphers, we must
|
|
- * pick a cipher */
|
|
-
|
|
-diff -uprN openssl-0.9.8.orig/ssl/ssl_err.c openssl-0.9.8/ssl/ssl_err.c
|
|
---- openssl-0.9.8.orig/ssl/ssl_err.c 2005-06-10 12:51:16.000000000 -0700
|
|
-+++ openssl-0.9.8/ssl/ssl_err.c 2005-07-19 20:02:15.000000000 -0700
|
|
-@@ -242,6 +242,7 @@ static ERR_STRING_DATA SSL_str_functs[]=
|
|
- {ERR_FUNC(SSL_F_TLS1_ENC), "TLS1_ENC"},
|
|
- {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 -uprN openssl-0.9.8.orig/ssl/ssl.h openssl-0.9.8/ssl/ssl.h
|
|
---- openssl-0.9.8.orig/ssl/ssl.h 2005-06-10 12:51:16.000000000 -0700
|
|
-+++ openssl-0.9.8/ssl/ssl.h 2005-07-19 20:02:15.000000000 -0700
|
|
-@@ -340,6 +340,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
|
|
-@@ -361,6 +362,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
|
|
- {
|
|
-@@ -968,6 +971,15 @@ struct ssl_st
|
|
- int first_packet;
|
|
- int client_version; /* what was passed, used for
|
|
- * SSLv3/TLS rollback check */
|
|
-+
|
|
-+ /* TLS externsions */
|
|
-+ TLS_EXTENSION *tls_extension;
|
|
-+ int (*tls_extension_cb)(SSL *s, TLS_EXTENSION *tls_ext, void *arg);
|
|
-+ void *tls_extension_cb_arg;
|
|
-+
|
|
-+ /* TLS pre-shared secret session resumption */
|
|
-+ tls_session_secret_cb_fn tls_session_secret_cb;
|
|
-+ void *tls_session_secret_cb_arg;
|
|
- };
|
|
-
|
|
- #ifdef __cplusplus
|
|
-@@ -1533,6 +1545,13 @@ 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);
|
|
-+int SSL_set_hello_extension_cb(SSL *s, int (*cb)(SSL *, TLS_EXTENSION *, void *), void *arg);
|
|
-+
|
|
-+/* 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.
|
|
-@@ -1714,6 +1733,7 @@ void ERR_load_SSL_strings(void);
|
|
- #define SSL_F_TLS1_ENC 210
|
|
- #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 -uprN openssl-0.9.8.orig/ssl/ssl_sess.c openssl-0.9.8/ssl/ssl_sess.c
|
|
---- openssl-0.9.8.orig/ssl/ssl_sess.c 2005-04-29 13:10:06.000000000 -0700
|
|
-+++ openssl-0.9.8/ssl/ssl_sess.c 2005-07-19 20:02:15.000000000 -0700
|
|
-@@ -656,6 +656,15 @@ long SSL_CTX_get_timeout(const SSL_CTX *
|
|
- return(s->session_timeout);
|
|
- }
|
|
-
|
|
-+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);
|
|
-+}
|
|
-+
|
|
- typedef struct timeout_param_st
|
|
- {
|
|
- SSL_CTX *ctx;
|
|
-diff -uprN openssl-0.9.8.orig/ssl/t1_ext.c openssl-0.9.8/ssl/t1_ext.c
|
|
---- openssl-0.9.8.orig/ssl/t1_ext.c 1969-12-31 16:00:00.000000000 -0800
|
|
-+++ openssl-0.9.8/ssl/t1_ext.c 2005-07-19 20:03:29.000000000 -0700
|
|
-@@ -0,0 +1,48 @@
|
|
-+
|
|
-+#include <stdio.h>
|
|
-+#include "ssl_locl.h"
|
|
-+
|
|
-+
|
|
-+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;
|
|
-+ }
|
|
-+
|
|
-+ if(ext_data)
|
|
-+ {
|
|
-+ 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;
|
|
-+ s->tls_extension->length = ext_len;
|
|
-+ s->tls_extension->data = s->tls_extension + 1;
|
|
-+ memcpy(s->tls_extension->data, ext_data, ext_len);
|
|
-+ }
|
|
-+
|
|
-+ return 1;
|
|
-+ }
|
|
-+
|
|
-+ return 0;
|
|
-+}
|
|
-+
|
|
-+int SSL_set_hello_extension_cb(SSL *s, int (*cb)(SSL *, TLS_EXTENSION *, void *), void *arg)
|
|
-+{
|
|
-+ if(s->version >= TLS1_VERSION)
|
|
-+ {
|
|
-+ s->tls_extension_cb = cb;
|
|
-+ s->tls_extension_cb_arg = arg;
|
|
-+
|
|
-+ return 1;
|
|
-+ }
|
|
-+
|
|
-+ return 0;
|
|
-+}
|
|
-diff -uprN openssl-0.9.8.orig/ssl/t1_lib.c openssl-0.9.8/ssl/t1_lib.c
|
|
---- openssl-0.9.8.orig/ssl/t1_lib.c 2005-04-26 09:02:40.000000000 -0700
|
|
-+++ openssl-0.9.8/ssl/t1_lib.c 2005-07-19 20:02:15.000000000 -0700
|
|
-@@ -131,6 +131,10 @@ int tls1_new(SSL *s)
|
|
-
|
|
- void tls1_free(SSL *s)
|
|
- {
|
|
-+ if(s->tls_extension)
|
|
-+ {
|
|
-+ OPENSSL_free(s->tls_extension);
|
|
-+ }
|
|
- ssl3_free(s);
|
|
- }
|
|
-
|
|
-diff -uprN openssl-0.9.8.orig/ssl/tls1.h openssl-0.9.8/ssl/tls1.h
|
|
---- openssl-0.9.8.orig/ssl/tls1.h 2003-07-22 05:34:21.000000000 -0700
|
|
-+++ openssl-0.9.8/ssl/tls1.h 2005-07-19 20:02:15.000000000 -0700
|
|
-@@ -282,6 +282,14 @@ extern "C" {
|
|
- #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 -uprN openssl-0.9.8.orig/util/ssleay.num openssl-0.9.8/util/ssleay.num
|
|
---- openssl-0.9.8.orig/util/ssleay.num 2005-05-08 17:22:02.000000000 -0700
|
|
-+++ openssl-0.9.8/util/ssleay.num 2005-07-19 20:02:15.000000000 -0700
|
|
-@@ -226,3 +226,6 @@ DTLSv1_server_method
|
|
- SSL_COMP_get_compression_methods 276 EXIST:!VMS:FUNCTION:COMP
|
|
- SSL_COMP_get_compress_methods 276 EXIST:VMS:FUNCTION:COMP
|
|
- SSL_SESSION_get_id 277 EXIST::FUNCTION:
|
|
-+SSL_set_hello_extension 278 EXIST::FUNCTION:
|
|
-+SSL_set_hello_extension_cb 279 EXIST::FUNCTION:
|
|
-+SSL_set_session_secret_cb 280 EXIST::FUNCTION:
|
|
diff --git a/patches/openssl-0.9.8d-tls-extensions.patch b/patches/openssl-0.9.8d-tls-extensions.patch
|
|
deleted file mode 100644
|
|
index eec6db8..0000000
|
|
--- a/patches/openssl-0.9.8d-tls-extensions.patch
|
|
+++ /dev/null
|
|
@@ -1,429 +0,0 @@
|
|
-This patch is adding support for TLS hello extensions and externally
|
|
-generated pre-shared key material to OpenSSL 0.9.8d. This is
|
|
-based on the patch from Alexey Kobozev <akobozev@cisco.com>
|
|
-(sent to openssl-dev mailing list on Tue, 07 Jun 2005 15:40:58 +0300).
|
|
-
|
|
-
|
|
-
|
|
-diff -uprN openssl-0.9.8d.orig/include/openssl/ssl.h openssl-0.9.8d/include/openssl/ssl.h
|
|
---- openssl-0.9.8d.orig/include/openssl/ssl.h 2006-06-14 06:52:49.000000000 -0700
|
|
-+++ openssl-0.9.8d/include/openssl/ssl.h 2006-12-10 08:20:02.000000000 -0800
|
|
-@@ -345,6 +345,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
|
|
-@@ -366,6 +367,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
|
|
- {
|
|
-@@ -973,6 +976,15 @@ struct ssl_st
|
|
- int first_packet;
|
|
- int client_version; /* what was passed, used for
|
|
- * SSLv3/TLS rollback check */
|
|
-+
|
|
-+ /* TLS externsions */
|
|
-+ TLS_EXTENSION *tls_extension;
|
|
-+ int (*tls_extension_cb)(SSL *s, TLS_EXTENSION *tls_ext, void *arg);
|
|
-+ void *tls_extension_cb_arg;
|
|
-+
|
|
-+ /* TLS pre-shared secret session resumption */
|
|
-+ tls_session_secret_cb_fn tls_session_secret_cb;
|
|
-+ void *tls_session_secret_cb_arg;
|
|
- };
|
|
-
|
|
- #ifdef __cplusplus
|
|
-@@ -1538,6 +1550,13 @@ 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);
|
|
-+int SSL_set_hello_extension_cb(SSL *s, int (*cb)(SSL *, TLS_EXTENSION *, void *), void *arg);
|
|
-+
|
|
-+/* 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.
|
|
-@@ -1719,6 +1738,7 @@ void ERR_load_SSL_strings(void);
|
|
- #define SSL_F_TLS1_ENC 210
|
|
- #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 -uprN openssl-0.9.8d.orig/include/openssl/tls1.h openssl-0.9.8d/include/openssl/tls1.h
|
|
---- openssl-0.9.8d.orig/include/openssl/tls1.h 2006-06-14 10:52:01.000000000 -0700
|
|
-+++ openssl-0.9.8d/include/openssl/tls1.h 2006-12-10 08:20:02.000000000 -0800
|
|
-@@ -296,6 +296,14 @@ extern "C" {
|
|
- #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 -uprN openssl-0.9.8d.orig/ssl/Makefile openssl-0.9.8d/ssl/Makefile
|
|
---- openssl-0.9.8d.orig/ssl/Makefile 2006-02-03 17:49:35.000000000 -0800
|
|
-+++ openssl-0.9.8d/ssl/Makefile 2006-12-10 08:20:02.000000000 -0800
|
|
-@@ -24,7 +24,7 @@ LIBSRC= \
|
|
- s2_meth.c s2_srvr.c s2_clnt.c s2_lib.c s2_enc.c s2_pkt.c \
|
|
- s3_meth.c s3_srvr.c s3_clnt.c s3_lib.c s3_enc.c s3_pkt.c s3_both.c \
|
|
- s23_meth.c s23_srvr.c s23_clnt.c s23_lib.c s23_pkt.c \
|
|
-- t1_meth.c t1_srvr.c t1_clnt.c t1_lib.c t1_enc.c \
|
|
-+ t1_meth.c t1_srvr.c t1_clnt.c t1_lib.c t1_enc.c t1_ext.c \
|
|
- d1_meth.c d1_srvr.c d1_clnt.c d1_lib.c d1_pkt.c \
|
|
- d1_both.c d1_enc.c \
|
|
- ssl_lib.c ssl_err2.c ssl_cert.c ssl_sess.c \
|
|
-@@ -35,7 +35,7 @@ LIBOBJ= \
|
|
- s2_meth.o s2_srvr.o s2_clnt.o s2_lib.o s2_enc.o s2_pkt.o \
|
|
- s3_meth.o s3_srvr.o s3_clnt.o s3_lib.o s3_enc.o s3_pkt.o s3_both.o \
|
|
- s23_meth.o s23_srvr.o s23_clnt.o s23_lib.o s23_pkt.o \
|
|
-- t1_meth.o t1_srvr.o t1_clnt.o t1_lib.o t1_enc.o \
|
|
-+ t1_meth.o t1_srvr.o t1_clnt.o t1_lib.o t1_enc.o t1_ext.o \
|
|
- d1_meth.o d1_srvr.o d1_clnt.o d1_lib.o d1_pkt.o \
|
|
- d1_both.o d1_enc.o \
|
|
- ssl_lib.o ssl_err2.o ssl_cert.o ssl_sess.o \
|
|
-@@ -968,3 +968,4 @@ t1_srvr.o: ../include/openssl/ssl23.h ..
|
|
- t1_srvr.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
|
|
- t1_srvr.o: ../include/openssl/tls1.h ../include/openssl/x509.h
|
|
- t1_srvr.o: ../include/openssl/x509_vfy.h ssl_locl.h t1_srvr.c
|
|
-+t1_ext.o: t1_ext.c ssl_locl.h
|
|
-diff -uprN openssl-0.9.8d.orig/ssl/s3_clnt.c openssl-0.9.8d/ssl/s3_clnt.c
|
|
---- openssl-0.9.8d.orig/ssl/s3_clnt.c 2005-12-12 23:41:46.000000000 -0800
|
|
-+++ openssl-0.9.8d/ssl/s3_clnt.c 2006-12-10 08:20:02.000000000 -0800
|
|
-@@ -601,6 +601,20 @@ int ssl3_client_hello(SSL *s)
|
|
- #endif
|
|
- *(p++)=0; /* Add the NULL method */
|
|
-
|
|
-+ /* send client hello extensions if any */
|
|
-+ if (s->version >= TLS1_VERSION && s->tls_extension)
|
|
-+ {
|
|
-+ // set the total extensions length
|
|
-+ s2n(s->tls_extension->length + 4, p);
|
|
-+
|
|
-+ // put the extensions with type and length
|
|
-+ s2n(s->tls_extension->type, p);
|
|
-+ s2n(s->tls_extension->length, p);
|
|
-+
|
|
-+ memcpy(p, s->tls_extension->data, s->tls_extension->length);
|
|
-+ p+=s->tls_extension->length;
|
|
-+ }
|
|
-+
|
|
- l=(p-d);
|
|
- d=buf;
|
|
- *(d++)=SSL3_MT_CLIENT_HELLO;
|
|
-@@ -623,7 +637,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
|
|
-@@ -690,7 +704,24 @@ 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;
|
|
-+ 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;
|
|
-+ }
|
|
-+ }
|
|
-+
|
|
-+ 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 -uprN openssl-0.9.8d.orig/ssl/s3_srvr.c openssl-0.9.8d/ssl/s3_srvr.c
|
|
---- openssl-0.9.8d.orig/ssl/s3_srvr.c 2006-09-28 04:29:03.000000000 -0700
|
|
-+++ openssl-0.9.8d/ssl/s3_srvr.c 2006-12-10 08:20:02.000000000 -0800
|
|
-@@ -943,6 +943,75 @@ int ssl3_get_client_hello(SSL *s)
|
|
- }
|
|
- #endif
|
|
-
|
|
-+ /* Check for TLS client hello extension here */
|
|
-+ if (p < (d+n) && s->version >= TLS1_VERSION)
|
|
-+ {
|
|
-+ if (s->tls_extension_cb)
|
|
-+ {
|
|
-+ TLS_EXTENSION tls_ext;
|
|
-+ unsigned short ext_total_len;
|
|
-+
|
|
-+ n2s(p, ext_total_len);
|
|
-+ n2s(p, tls_ext.type);
|
|
-+ n2s(p, tls_ext.length);
|
|
-+
|
|
-+ // sanity check in TLS extension len
|
|
-+ if (tls_ext.length > (d+n) - p)
|
|
-+ {
|
|
-+ // just cut the lenth to packet border
|
|
-+ tls_ext.length = (d+n) - p;
|
|
-+ }
|
|
-+
|
|
-+ tls_ext.data = p;
|
|
-+
|
|
-+ // returns an alert code or 0
|
|
-+ al = s->tls_extension_cb(s, &tls_ext, s->tls_extension_cb_arg);
|
|
-+ if (al != 0)
|
|
-+ {
|
|
-+ SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_PEER_ERROR);
|
|
-+ goto f_err;
|
|
-+ }
|
|
-+ }
|
|
-+ }
|
|
-+
|
|
-+ /* Check if we want to use external pre-shared secret for this handshake */
|
|
-+ /* for not reused session only */
|
|
-+ 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);
|
|
-+ }
|
|
-+ }
|
|
-+
|
|
- /* Given s->session->ciphers and SSL_get_ciphers, we must
|
|
- * pick a cipher */
|
|
-
|
|
-diff -uprN openssl-0.9.8d.orig/ssl/ssl.h openssl-0.9.8d/ssl/ssl.h
|
|
---- openssl-0.9.8d.orig/ssl/ssl.h 2006-06-14 06:52:49.000000000 -0700
|
|
-+++ openssl-0.9.8d/ssl/ssl.h 2006-12-10 08:20:02.000000000 -0800
|
|
-@@ -345,6 +345,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
|
|
-@@ -366,6 +367,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
|
|
- {
|
|
-@@ -973,6 +976,15 @@ struct ssl_st
|
|
- int first_packet;
|
|
- int client_version; /* what was passed, used for
|
|
- * SSLv3/TLS rollback check */
|
|
-+
|
|
-+ /* TLS externsions */
|
|
-+ TLS_EXTENSION *tls_extension;
|
|
-+ int (*tls_extension_cb)(SSL *s, TLS_EXTENSION *tls_ext, void *arg);
|
|
-+ void *tls_extension_cb_arg;
|
|
-+
|
|
-+ /* TLS pre-shared secret session resumption */
|
|
-+ tls_session_secret_cb_fn tls_session_secret_cb;
|
|
-+ void *tls_session_secret_cb_arg;
|
|
- };
|
|
-
|
|
- #ifdef __cplusplus
|
|
-@@ -1538,6 +1550,13 @@ 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);
|
|
-+int SSL_set_hello_extension_cb(SSL *s, int (*cb)(SSL *, TLS_EXTENSION *, void *), void *arg);
|
|
-+
|
|
-+/* 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.
|
|
-@@ -1719,6 +1738,7 @@ void ERR_load_SSL_strings(void);
|
|
- #define SSL_F_TLS1_ENC 210
|
|
- #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 -uprN openssl-0.9.8d.orig/ssl/ssl_err.c openssl-0.9.8d/ssl/ssl_err.c
|
|
---- openssl-0.9.8d.orig/ssl/ssl_err.c 2006-01-08 13:52:46.000000000 -0800
|
|
-+++ openssl-0.9.8d/ssl/ssl_err.c 2006-12-10 08:20:02.000000000 -0800
|
|
-@@ -242,6 +242,7 @@ static ERR_STRING_DATA SSL_str_functs[]=
|
|
- {ERR_FUNC(SSL_F_TLS1_ENC), "TLS1_ENC"},
|
|
- {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 -uprN openssl-0.9.8d.orig/ssl/ssl_sess.c openssl-0.9.8d/ssl/ssl_sess.c
|
|
---- openssl-0.9.8d.orig/ssl/ssl_sess.c 2005-12-30 15:51:57.000000000 -0800
|
|
-+++ openssl-0.9.8d/ssl/ssl_sess.c 2006-12-10 08:20:02.000000000 -0800
|
|
-@@ -656,6 +656,15 @@ long SSL_CTX_get_timeout(const SSL_CTX *
|
|
- return(s->session_timeout);
|
|
- }
|
|
-
|
|
-+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);
|
|
-+}
|
|
-+
|
|
- typedef struct timeout_param_st
|
|
- {
|
|
- SSL_CTX *ctx;
|
|
-diff -uprN openssl-0.9.8d.orig/ssl/t1_ext.c openssl-0.9.8d/ssl/t1_ext.c
|
|
---- openssl-0.9.8d.orig/ssl/t1_ext.c 1969-12-31 16:00:00.000000000 -0800
|
|
-+++ openssl-0.9.8d/ssl/t1_ext.c 2006-12-10 08:20:02.000000000 -0800
|
|
-@@ -0,0 +1,48 @@
|
|
-+
|
|
-+#include <stdio.h>
|
|
-+#include "ssl_locl.h"
|
|
-+
|
|
-+
|
|
-+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;
|
|
-+ }
|
|
-+
|
|
-+ if(ext_data)
|
|
-+ {
|
|
-+ 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;
|
|
-+ s->tls_extension->length = ext_len;
|
|
-+ s->tls_extension->data = s->tls_extension + 1;
|
|
-+ memcpy(s->tls_extension->data, ext_data, ext_len);
|
|
-+ }
|
|
-+
|
|
-+ return 1;
|
|
-+ }
|
|
-+
|
|
-+ return 0;
|
|
-+}
|
|
-+
|
|
-+int SSL_set_hello_extension_cb(SSL *s, int (*cb)(SSL *, TLS_EXTENSION *, void *), void *arg)
|
|
-+{
|
|
-+ if(s->version >= TLS1_VERSION)
|
|
-+ {
|
|
-+ s->tls_extension_cb = cb;
|
|
-+ s->tls_extension_cb_arg = arg;
|
|
-+
|
|
-+ return 1;
|
|
-+ }
|
|
-+
|
|
-+ return 0;
|
|
-+}
|
|
-diff -uprN openssl-0.9.8d.orig/ssl/t1_lib.c openssl-0.9.8d/ssl/t1_lib.c
|
|
---- openssl-0.9.8d.orig/ssl/t1_lib.c 2005-08-05 16:52:07.000000000 -0700
|
|
-+++ openssl-0.9.8d/ssl/t1_lib.c 2006-12-10 08:20:02.000000000 -0800
|
|
-@@ -97,6 +97,10 @@ int tls1_new(SSL *s)
|
|
-
|
|
- void tls1_free(SSL *s)
|
|
- {
|
|
-+ if(s->tls_extension)
|
|
-+ {
|
|
-+ OPENSSL_free(s->tls_extension);
|
|
-+ }
|
|
- ssl3_free(s);
|
|
- }
|
|
-
|
|
-diff -uprN openssl-0.9.8d.orig/ssl/tls1.h openssl-0.9.8d/ssl/tls1.h
|
|
---- openssl-0.9.8d.orig/ssl/tls1.h 2006-06-14 10:52:01.000000000 -0700
|
|
-+++ openssl-0.9.8d/ssl/tls1.h 2006-12-10 08:20:02.000000000 -0800
|
|
-@@ -296,6 +296,14 @@ extern "C" {
|
|
- #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 -uprN openssl-0.9.8d.orig/util/ssleay.num openssl-0.9.8d/util/ssleay.num
|
|
---- openssl-0.9.8d.orig/util/ssleay.num 2005-05-08 17:22:02.000000000 -0700
|
|
-+++ openssl-0.9.8d/util/ssleay.num 2006-12-10 08:20:02.000000000 -0800
|
|
-@@ -226,3 +226,6 @@ DTLSv1_server_method
|
|
- SSL_COMP_get_compression_methods 276 EXIST:!VMS:FUNCTION:COMP
|
|
- SSL_COMP_get_compress_methods 276 EXIST:VMS:FUNCTION:COMP
|
|
- SSL_SESSION_get_id 277 EXIST::FUNCTION:
|
|
-+SSL_set_hello_extension 278 EXIST::FUNCTION:
|
|
-+SSL_set_hello_extension_cb 279 EXIST::FUNCTION:
|
|
-+SSL_set_session_secret_cb 280 EXIST::FUNCTION:
|
|
diff --git a/patches/openssl-0.9.8e-tls-extensions.patch b/patches/openssl-0.9.8e-tls-extensions.patch
|
|
deleted file mode 100644
|
|
index ede053f..0000000
|
|
--- a/patches/openssl-0.9.8e-tls-extensions.patch
|
|
+++ /dev/null
|
|
@@ -1,353 +0,0 @@
|
|
-This patch is adding support for TLS hello extensions and externally
|
|
-generated pre-shared key material to OpenSSL 0.9.8e. This is
|
|
-based on the patch from Alexey Kobozev <akobozev@cisco.com>
|
|
-(sent to openssl-dev mailing list on Tue, 07 Jun 2005 15:40:58 +0300).
|
|
-
|
|
-
|
|
-
|
|
-diff -uprN openssl-0.9.8e.orig/ssl/Makefile openssl-0.9.8e/ssl/Makefile
|
|
---- openssl-0.9.8e.orig/ssl/Makefile 2006-02-03 17:49:35.000000000 -0800
|
|
-+++ openssl-0.9.8e/ssl/Makefile 2007-03-22 20:23:19.000000000 -0700
|
|
-@@ -24,7 +24,7 @@ LIBSRC= \
|
|
- s2_meth.c s2_srvr.c s2_clnt.c s2_lib.c s2_enc.c s2_pkt.c \
|
|
- s3_meth.c s3_srvr.c s3_clnt.c s3_lib.c s3_enc.c s3_pkt.c s3_both.c \
|
|
- s23_meth.c s23_srvr.c s23_clnt.c s23_lib.c s23_pkt.c \
|
|
-- t1_meth.c t1_srvr.c t1_clnt.c t1_lib.c t1_enc.c \
|
|
-+ t1_meth.c t1_srvr.c t1_clnt.c t1_lib.c t1_enc.c t1_ext.c \
|
|
- d1_meth.c d1_srvr.c d1_clnt.c d1_lib.c d1_pkt.c \
|
|
- d1_both.c d1_enc.c \
|
|
- ssl_lib.c ssl_err2.c ssl_cert.c ssl_sess.c \
|
|
-@@ -35,7 +35,7 @@ LIBOBJ= \
|
|
- s2_meth.o s2_srvr.o s2_clnt.o s2_lib.o s2_enc.o s2_pkt.o \
|
|
- s3_meth.o s3_srvr.o s3_clnt.o s3_lib.o s3_enc.o s3_pkt.o s3_both.o \
|
|
- s23_meth.o s23_srvr.o s23_clnt.o s23_lib.o s23_pkt.o \
|
|
-- t1_meth.o t1_srvr.o t1_clnt.o t1_lib.o t1_enc.o \
|
|
-+ t1_meth.o t1_srvr.o t1_clnt.o t1_lib.o t1_enc.o t1_ext.o \
|
|
- d1_meth.o d1_srvr.o d1_clnt.o d1_lib.o d1_pkt.o \
|
|
- d1_both.o d1_enc.o \
|
|
- ssl_lib.o ssl_err2.o ssl_cert.o ssl_sess.o \
|
|
-@@ -968,3 +968,4 @@ t1_srvr.o: ../include/openssl/ssl23.h ..
|
|
- t1_srvr.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
|
|
- t1_srvr.o: ../include/openssl/tls1.h ../include/openssl/x509.h
|
|
- t1_srvr.o: ../include/openssl/x509_vfy.h ssl_locl.h t1_srvr.c
|
|
-+t1_ext.o: t1_ext.c ssl_locl.h
|
|
-diff -uprN openssl-0.9.8e.orig/ssl/s3_clnt.c openssl-0.9.8e/ssl/s3_clnt.c
|
|
---- openssl-0.9.8e.orig/ssl/s3_clnt.c 2006-09-28 05:23:15.000000000 -0700
|
|
-+++ openssl-0.9.8e/ssl/s3_clnt.c 2007-03-22 20:23:19.000000000 -0700
|
|
-@@ -601,6 +601,20 @@ int ssl3_client_hello(SSL *s)
|
|
- #endif
|
|
- *(p++)=0; /* Add the NULL method */
|
|
-
|
|
-+ /* send client hello extensions if any */
|
|
-+ if (s->version >= TLS1_VERSION && s->tls_extension)
|
|
-+ {
|
|
-+ // set the total extensions length
|
|
-+ s2n(s->tls_extension->length + 4, p);
|
|
-+
|
|
-+ // put the extensions with type and length
|
|
-+ s2n(s->tls_extension->type, p);
|
|
-+ s2n(s->tls_extension->length, p);
|
|
-+
|
|
-+ memcpy(p, s->tls_extension->data, s->tls_extension->length);
|
|
-+ p+=s->tls_extension->length;
|
|
-+ }
|
|
-+
|
|
- l=(p-d);
|
|
- d=buf;
|
|
- *(d++)=SSL3_MT_CLIENT_HELLO;
|
|
-@@ -623,7 +637,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
|
|
-@@ -690,7 +704,24 @@ 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;
|
|
-+ 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;
|
|
-+ }
|
|
-+ }
|
|
-+
|
|
-+ 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 -uprN openssl-0.9.8e.orig/ssl/s3_srvr.c openssl-0.9.8e/ssl/s3_srvr.c
|
|
---- openssl-0.9.8e.orig/ssl/s3_srvr.c 2007-02-07 12:36:40.000000000 -0800
|
|
-+++ openssl-0.9.8e/ssl/s3_srvr.c 2007-03-22 20:23:19.000000000 -0700
|
|
-@@ -945,6 +945,75 @@ int ssl3_get_client_hello(SSL *s)
|
|
- }
|
|
- #endif
|
|
-
|
|
-+ /* Check for TLS client hello extension here */
|
|
-+ if (p < (d+n) && s->version >= TLS1_VERSION)
|
|
-+ {
|
|
-+ if (s->tls_extension_cb)
|
|
-+ {
|
|
-+ TLS_EXTENSION tls_ext;
|
|
-+ unsigned short ext_total_len;
|
|
-+
|
|
-+ n2s(p, ext_total_len);
|
|
-+ n2s(p, tls_ext.type);
|
|
-+ n2s(p, tls_ext.length);
|
|
-+
|
|
-+ // sanity check in TLS extension len
|
|
-+ if (tls_ext.length > (d+n) - p)
|
|
-+ {
|
|
-+ // just cut the lenth to packet border
|
|
-+ tls_ext.length = (d+n) - p;
|
|
-+ }
|
|
-+
|
|
-+ tls_ext.data = p;
|
|
-+
|
|
-+ // returns an alert code or 0
|
|
-+ al = s->tls_extension_cb(s, &tls_ext, s->tls_extension_cb_arg);
|
|
-+ if (al != 0)
|
|
-+ {
|
|
-+ SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_PEER_ERROR);
|
|
-+ goto f_err;
|
|
-+ }
|
|
-+ }
|
|
-+ }
|
|
-+
|
|
-+ /* Check if we want to use external pre-shared secret for this handshake */
|
|
-+ /* for not reused session only */
|
|
-+ 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);
|
|
-+ }
|
|
-+ }
|
|
-+
|
|
- /* Given s->session->ciphers and SSL_get_ciphers, we must
|
|
- * pick a cipher */
|
|
-
|
|
-diff -uprN openssl-0.9.8e.orig/ssl/ssl.h openssl-0.9.8e/ssl/ssl.h
|
|
---- openssl-0.9.8e.orig/ssl/ssl.h 2007-02-19 09:55:07.000000000 -0800
|
|
-+++ openssl-0.9.8e/ssl/ssl.h 2007-03-22 20:23:19.000000000 -0700
|
|
-@@ -345,6 +345,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
|
|
-@@ -366,6 +367,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
|
|
- {
|
|
-@@ -973,6 +976,15 @@ struct ssl_st
|
|
- int first_packet;
|
|
- int client_version; /* what was passed, used for
|
|
- * SSLv3/TLS rollback check */
|
|
-+
|
|
-+ /* TLS externsions */
|
|
-+ TLS_EXTENSION *tls_extension;
|
|
-+ int (*tls_extension_cb)(SSL *s, TLS_EXTENSION *tls_ext, void *arg);
|
|
-+ void *tls_extension_cb_arg;
|
|
-+
|
|
-+ /* TLS pre-shared secret session resumption */
|
|
-+ tls_session_secret_cb_fn tls_session_secret_cb;
|
|
-+ void *tls_session_secret_cb_arg;
|
|
- };
|
|
-
|
|
- #ifdef __cplusplus
|
|
-@@ -1538,6 +1550,13 @@ 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);
|
|
-+int SSL_set_hello_extension_cb(SSL *s, int (*cb)(SSL *, TLS_EXTENSION *, void *), void *arg);
|
|
-+
|
|
-+/* 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.
|
|
-@@ -1719,6 +1738,7 @@ void ERR_load_SSL_strings(void);
|
|
- #define SSL_F_TLS1_ENC 210
|
|
- #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 -uprN openssl-0.9.8e.orig/ssl/ssl_err.c openssl-0.9.8e/ssl/ssl_err.c
|
|
---- openssl-0.9.8e.orig/ssl/ssl_err.c 2006-11-21 12:14:46.000000000 -0800
|
|
-+++ openssl-0.9.8e/ssl/ssl_err.c 2007-03-22 20:23:19.000000000 -0700
|
|
-@@ -242,6 +242,7 @@ static ERR_STRING_DATA SSL_str_functs[]=
|
|
- {ERR_FUNC(SSL_F_TLS1_ENC), "TLS1_ENC"},
|
|
- {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 -uprN openssl-0.9.8e.orig/ssl/ssl_sess.c openssl-0.9.8e/ssl/ssl_sess.c
|
|
---- openssl-0.9.8e.orig/ssl/ssl_sess.c 2007-02-10 02:40:24.000000000 -0800
|
|
-+++ openssl-0.9.8e/ssl/ssl_sess.c 2007-03-22 20:23:19.000000000 -0700
|
|
-@@ -656,6 +656,15 @@ long SSL_CTX_get_timeout(const SSL_CTX *
|
|
- return(s->session_timeout);
|
|
- }
|
|
-
|
|
-+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);
|
|
-+}
|
|
-+
|
|
- typedef struct timeout_param_st
|
|
- {
|
|
- SSL_CTX *ctx;
|
|
-diff -uprN openssl-0.9.8e.orig/ssl/t1_ext.c openssl-0.9.8e/ssl/t1_ext.c
|
|
---- openssl-0.9.8e.orig/ssl/t1_ext.c 1969-12-31 16:00:00.000000000 -0800
|
|
-+++ openssl-0.9.8e/ssl/t1_ext.c 2007-03-22 20:23:19.000000000 -0700
|
|
-@@ -0,0 +1,48 @@
|
|
-+
|
|
-+#include <stdio.h>
|
|
-+#include "ssl_locl.h"
|
|
-+
|
|
-+
|
|
-+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;
|
|
-+ }
|
|
-+
|
|
-+ if(ext_data)
|
|
-+ {
|
|
-+ 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;
|
|
-+ s->tls_extension->length = ext_len;
|
|
-+ s->tls_extension->data = s->tls_extension + 1;
|
|
-+ memcpy(s->tls_extension->data, ext_data, ext_len);
|
|
-+ }
|
|
-+
|
|
-+ return 1;
|
|
-+ }
|
|
-+
|
|
-+ return 0;
|
|
-+}
|
|
-+
|
|
-+int SSL_set_hello_extension_cb(SSL *s, int (*cb)(SSL *, TLS_EXTENSION *, void *), void *arg)
|
|
-+{
|
|
-+ if(s->version >= TLS1_VERSION)
|
|
-+ {
|
|
-+ s->tls_extension_cb = cb;
|
|
-+ s->tls_extension_cb_arg = arg;
|
|
-+
|
|
-+ return 1;
|
|
-+ }
|
|
-+
|
|
-+ return 0;
|
|
-+}
|
|
-diff -uprN openssl-0.9.8e.orig/ssl/t1_lib.c openssl-0.9.8e/ssl/t1_lib.c
|
|
---- openssl-0.9.8e.orig/ssl/t1_lib.c 2007-01-21 08:07:25.000000000 -0800
|
|
-+++ openssl-0.9.8e/ssl/t1_lib.c 2007-03-22 20:23:19.000000000 -0700
|
|
-@@ -97,6 +97,10 @@ int tls1_new(SSL *s)
|
|
-
|
|
- void tls1_free(SSL *s)
|
|
- {
|
|
-+ if(s->tls_extension)
|
|
-+ {
|
|
-+ OPENSSL_free(s->tls_extension);
|
|
-+ }
|
|
- ssl3_free(s);
|
|
- }
|
|
-
|
|
-diff -uprN openssl-0.9.8e.orig/ssl/tls1.h openssl-0.9.8e/ssl/tls1.h
|
|
---- openssl-0.9.8e.orig/ssl/tls1.h 2006-06-14 10:52:01.000000000 -0700
|
|
-+++ openssl-0.9.8e/ssl/tls1.h 2007-03-22 20:23:19.000000000 -0700
|
|
-@@ -296,6 +296,14 @@ extern "C" {
|
|
- #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 -uprN openssl-0.9.8e.orig/util/ssleay.num openssl-0.9.8e/util/ssleay.num
|
|
---- openssl-0.9.8e.orig/util/ssleay.num 2006-11-30 05:04:43.000000000 -0800
|
|
-+++ openssl-0.9.8e/util/ssleay.num 2007-03-22 20:24:07.000000000 -0700
|
|
-@@ -238,3 +238,6 @@ SSL_CTX_set_info_callback
|
|
- SSL_CTX_sess_get_new_cb 287 EXIST::FUNCTION:
|
|
- SSL_CTX_get_client_cert_cb 288 EXIST::FUNCTION:
|
|
- SSL_CTX_sess_get_remove_cb 289 EXIST::FUNCTION:
|
|
-+SSL_set_hello_extension 290 EXIST::FUNCTION:
|
|
-+SSL_set_hello_extension_cb 291 EXIST::FUNCTION:
|
|
-+SSL_set_session_secret_cb 292 EXIST::FUNCTION:
|
|
diff --git a/patches/openssl-0.9.8g-tls-extensions.patch b/patches/openssl-0.9.8g-tls-extensions.patch
|
|
deleted file mode 100644
|
|
index 8ccbfaa..0000000
|
|
--- a/patches/openssl-0.9.8g-tls-extensions.patch
|
|
+++ /dev/null
|
|
@@ -1,330 +0,0 @@
|
|
-This patch adds support for TLS SessionTicket extension (RFC 5077) for
|
|
-the parts used by EAP-FAST (RFC 4851).
|
|
-
|
|
-This is based on the patch from Alexey Kobozev <akobozev@cisco.com>
|
|
-(sent to openssl-dev mailing list on Tue, 07 Jun 2005 15:40:58 +0300).
|
|
-
|
|
-OpenSSL 0.9.8g does not enable TLS extension support by default, so it
|
|
-will need to be enabled by adding enable-tlsext to config script
|
|
-command line.
|
|
-
|
|
-
|
|
-diff -upr openssl-0.9.8g.orig/ssl/s3_clnt.c openssl-0.9.8g/ssl/s3_clnt.c
|
|
---- openssl-0.9.8g.orig/ssl/s3_clnt.c 2007-08-31 03:28:51.000000000 +0300
|
|
-+++ openssl-0.9.8g/ssl/s3_clnt.c 2008-04-15 17:11:46.000000000 +0300
|
|
-@@ -727,6 +727,20 @@ int ssl3_get_server_hello(SSL *s)
|
|
- goto f_err;
|
|
- }
|
|
-
|
|
-+#ifndef OPENSSL_NO_TLSEXT
|
|
-+ /* check if we want to resume the session based on external pre-shared secret */
|
|
-+ 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->session->cipher=pref_cipher ? pref_cipher : ssl_get_cipher_by_char(s,p+j);
|
|
-+ }
|
|
-+ }
|
|
-+#endif /* OPENSSL_NO_TLSEXT */
|
|
-+
|
|
- if (j != 0 && j == s->session->session_id_length
|
|
- && memcmp(p,s->session->session_id,j) == 0)
|
|
- {
|
|
-diff -upr openssl-0.9.8g.orig/ssl/s3_srvr.c openssl-0.9.8g/ssl/s3_srvr.c
|
|
---- openssl-0.9.8g.orig/ssl/s3_srvr.c 2007-09-30 21:55:59.000000000 +0300
|
|
-+++ openssl-0.9.8g/ssl/s3_srvr.c 2008-04-15 17:10:37.000000000 +0300
|
|
-@@ -928,6 +928,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
|
|
- * options, we will now look for them. We have i-1 compression
|
|
-@@ -1066,16 +1119,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-0.9.8g.orig/ssl/ssl.h openssl-0.9.8g/ssl/ssl.h
|
|
---- openssl-0.9.8g.orig/ssl/ssl.h 2007-10-19 10:42:38.000000000 +0300
|
|
-+++ openssl-0.9.8g/ssl/ssl.h 2008-04-15 17:10:37.000000000 +0300
|
|
-@@ -342,6 +342,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
|
|
-@@ -363,6 +364,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
|
|
- {
|
|
-@@ -1004,6 +1007,14 @@ struct ssl_st
|
|
- */
|
|
- /* RFC4507 session ticket expected to be received or sent */
|
|
- int tlsext_ticket_expected;
|
|
-+
|
|
-+ /* 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
|
|
-@@ -1589,6 +1600,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.
|
|
-@@ -1778,6 +1795,7 @@ void ERR_load_SSL_strings(void);
|
|
- #define SSL_F_TLS1_ENC 210
|
|
- #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-0.9.8g.orig/ssl/ssl_err.c openssl-0.9.8g/ssl/ssl_err.c
|
|
---- openssl-0.9.8g.orig/ssl/ssl_err.c 2007-10-11 17:36:59.000000000 +0300
|
|
-+++ openssl-0.9.8g/ssl/ssl_err.c 2008-04-15 17:10:37.000000000 +0300
|
|
-@@ -250,6 +250,7 @@ static ERR_STRING_DATA SSL_str_functs[]=
|
|
- {ERR_FUNC(SSL_F_TLS1_ENC), "TLS1_ENC"},
|
|
- {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-0.9.8g.orig/ssl/ssl_sess.c openssl-0.9.8g/ssl/ssl_sess.c
|
|
---- openssl-0.9.8g.orig/ssl/ssl_sess.c 2007-10-19 10:36:34.000000000 +0300
|
|
-+++ openssl-0.9.8g/ssl/ssl_sess.c 2008-04-15 17:10:37.000000000 +0300
|
|
-@@ -704,6 +704,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-0.9.8g.orig/ssl/t1_lib.c openssl-0.9.8g/ssl/t1_lib.c
|
|
---- openssl-0.9.8g.orig/ssl/t1_lib.c 2007-10-19 10:44:10.000000000 +0300
|
|
-+++ openssl-0.9.8g/ssl/t1_lib.c 2008-04-15 17:10:37.000000000 +0300
|
|
-@@ -105,6 +105,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);
|
|
- }
|
|
-
|
|
-@@ -174,8 +180,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
|
|
- */
|
|
-@@ -189,6 +211,7 @@ unsigned char *ssl_add_clienthello_tlsex
|
|
- ret += ticklen;
|
|
- }
|
|
- }
|
|
-+ skip_ext:
|
|
-
|
|
- if ((extdatalen = ret-p-2)== 0)
|
|
- return p;
|
|
-@@ -543,6 +566,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-0.9.8g.orig/ssl/tls1.h openssl-0.9.8g/ssl/tls1.h
|
|
---- openssl-0.9.8g.orig/ssl/tls1.h 2007-08-28 04:12:44.000000000 +0300
|
|
-+++ openssl-0.9.8g/ssl/tls1.h 2008-04-15 17:10:37.000000000 +0300
|
|
-@@ -365,6 +365,14 @@ SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TLSEXT_SER
|
|
- #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-0.9.8g.orig/util/ssleay.num openssl-0.9.8g/util/ssleay.num
|
|
---- openssl-0.9.8g.orig/util/ssleay.num 2007-08-13 01:31:16.000000000 +0300
|
|
-+++ openssl-0.9.8g/util/ssleay.num 2008-04-15 17:10:37.000000000 +0300
|
|
-@@ -241,3 +241,5 @@ SSL_CTX_sess_get_remove_cb
|
|
- SSL_set_SSL_CTX 290 EXIST::FUNCTION:
|
|
- SSL_get_servername 291 EXIST::FUNCTION:TLSEXT
|
|
- SSL_get_servername_type 292 EXIST::FUNCTION:TLSEXT
|
|
-+SSL_set_hello_extension 305 EXIST::FUNCTION:TLSEXT
|
|
-+SSL_set_session_secret_cb 306 EXIST::FUNCTION:TLSEXT
|
|
diff --git a/patches/openssl-0.9.8h-tls-extensions.patch b/patches/openssl-0.9.8h-tls-extensions.patch
|
|
deleted file mode 100644
|
|
index c68f227..0000000
|
|
--- a/patches/openssl-0.9.8h-tls-extensions.patch
|
|
+++ /dev/null
|
|
@@ -1,344 +0,0 @@
|
|
-This patch adds support for TLS SessionTicket extension (RFC 5077) for
|
|
-the parts used by EAP-FAST (RFC 4851).
|
|
-
|
|
-This is based on the patch from Alexey Kobozev <akobozev@cisco.com>
|
|
-(sent to openssl-dev mailing list on Tue, 07 Jun 2005 15:40:58 +0300).
|
|
-
|
|
-OpenSSL 0.9.8h does not enable TLS extension support by default, so it
|
|
-will need to be enabled by adding enable-tlsext to config script
|
|
-command line.
|
|
-
|
|
-
|
|
-diff -upr openssl-0.9.8h.orig/ssl/s3_clnt.c openssl-0.9.8h/ssl/s3_clnt.c
|
|
---- openssl-0.9.8h.orig/ssl/s3_clnt.c 2008-05-28 10:29:27.000000000 +0300
|
|
-+++ openssl-0.9.8h/ssl/s3_clnt.c 2008-05-29 10:44:25.000000000 +0300
|
|
-@@ -752,6 +752,20 @@ int ssl3_get_server_hello(SSL *s)
|
|
- goto f_err;
|
|
- }
|
|
-
|
|
-+#ifndef OPENSSL_NO_TLSEXT
|
|
-+ /* check if we want to resume the session based on external pre-shared secret */
|
|
-+ 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->session->cipher=pref_cipher ? pref_cipher : ssl_get_cipher_by_char(s,p+j);
|
|
-+ }
|
|
-+ }
|
|
-+#endif /* OPENSSL_NO_TLSEXT */
|
|
-+
|
|
- if (j != 0 && j == s->session->session_id_length
|
|
- && memcmp(p,s->session->session_id,j) == 0)
|
|
- {
|
|
-@@ -2693,11 +2707,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-0.9.8h.orig/ssl/s3_srvr.c openssl-0.9.8h/ssl/s3_srvr.c
|
|
---- openssl-0.9.8h.orig/ssl/s3_srvr.c 2008-04-30 19:11:32.000000000 +0300
|
|
-+++ openssl-0.9.8h/ssl/s3_srvr.c 2008-05-28 18:49:34.000000000 +0300
|
|
-@@ -959,6 +959,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
|
|
- * options, we will now look for them. We have i-1 compression
|
|
-@@ -1097,16 +1150,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-0.9.8h.orig/ssl/ssl.h openssl-0.9.8h/ssl/ssl.h
|
|
---- openssl-0.9.8h.orig/ssl/ssl.h 2008-04-30 19:11:32.000000000 +0300
|
|
-+++ openssl-0.9.8h/ssl/ssl.h 2008-05-28 18:49:34.000000000 +0300
|
|
-@@ -343,6 +343,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
|
|
-@@ -364,6 +365,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
|
|
- {
|
|
-@@ -1027,6 +1030,14 @@ struct ssl_st
|
|
-
|
|
- /* RFC4507 session ticket expected to be received or sent */
|
|
- int tlsext_ticket_expected;
|
|
-+
|
|
-+ /* 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
|
|
-@@ -1625,6 +1636,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.
|
|
-@@ -1815,6 +1832,7 @@ void ERR_load_SSL_strings(void);
|
|
- #define SSL_F_TLS1_ENC 210
|
|
- #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-0.9.8h.orig/ssl/ssl_err.c openssl-0.9.8h/ssl/ssl_err.c
|
|
---- openssl-0.9.8h.orig/ssl/ssl_err.c 2007-10-12 03:00:30.000000000 +0300
|
|
-+++ openssl-0.9.8h/ssl/ssl_err.c 2008-05-28 18:49:34.000000000 +0300
|
|
-@@ -251,6 +251,7 @@ static ERR_STRING_DATA SSL_str_functs[]=
|
|
- {ERR_FUNC(SSL_F_TLS1_ENC), "TLS1_ENC"},
|
|
- {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-0.9.8h.orig/ssl/ssl_sess.c openssl-0.9.8h/ssl/ssl_sess.c
|
|
---- openssl-0.9.8h.orig/ssl/ssl_sess.c 2007-10-17 20:30:15.000000000 +0300
|
|
-+++ openssl-0.9.8h/ssl/ssl_sess.c 2008-05-28 18:49:34.000000000 +0300
|
|
-@@ -704,6 +704,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-0.9.8h.orig/ssl/t1_lib.c openssl-0.9.8h/ssl/t1_lib.c
|
|
---- openssl-0.9.8h.orig/ssl/t1_lib.c 2008-05-28 10:26:33.000000000 +0300
|
|
-+++ openssl-0.9.8h/ssl/t1_lib.c 2008-05-28 18:49:34.000000000 +0300
|
|
-@@ -106,6 +106,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);
|
|
- }
|
|
-
|
|
-@@ -175,8 +181,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
|
|
- */
|
|
-@@ -190,6 +212,7 @@ unsigned char *ssl_add_clienthello_tlsex
|
|
- ret += ticklen;
|
|
- }
|
|
- }
|
|
-+ skip_ext:
|
|
-
|
|
- if (s->tlsext_status_type == TLSEXT_STATUSTYPE_ocsp)
|
|
- {
|
|
-@@ -774,6 +797,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-0.9.8h.orig/ssl/tls1.h openssl-0.9.8h/ssl/tls1.h
|
|
---- openssl-0.9.8h.orig/ssl/tls1.h 2008-04-30 19:11:33.000000000 +0300
|
|
-+++ openssl-0.9.8h/ssl/tls1.h 2008-05-28 18:49:34.000000000 +0300
|
|
-@@ -398,6 +398,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*/
|
|
- #endif
|
|
-
|
|
-+/* TLS extension struct */
|
|
-+struct tls_extension_st
|
|
-+{
|
|
-+ unsigned short type;
|
|
-+ unsigned short length;
|
|
-+ void *data;
|
|
-+};
|
|
-+
|
|
- #ifdef __cplusplus
|
|
- }
|
|
- #endif
|
|
-diff -upr openssl-0.9.8h.orig/util/ssleay.num openssl-0.9.8h/util/ssleay.num
|
|
---- openssl-0.9.8h.orig/util/ssleay.num 2007-08-13 01:31:16.000000000 +0300
|
|
-+++ openssl-0.9.8h/util/ssleay.num 2008-05-28 18:49:34.000000000 +0300
|
|
-@@ -241,3 +241,5 @@ SSL_CTX_sess_get_remove_cb
|
|
- SSL_set_SSL_CTX 290 EXIST::FUNCTION:
|
|
- SSL_get_servername 291 EXIST::FUNCTION:TLSEXT
|
|
- SSL_get_servername_type 292 EXIST::FUNCTION:TLSEXT
|
|
-+SSL_set_hello_extension 305 EXIST::FUNCTION:TLSEXT
|
|
-+SSL_set_session_secret_cb 306 EXIST::FUNCTION:TLSEXT
|
|
diff --git a/patches/openssl-0.9.8i-tls-extensions.patch b/patches/openssl-0.9.8i-tls-extensions.patch
|
|
deleted file mode 100644
|
|
index 90bff54..0000000
|
|
--- a/patches/openssl-0.9.8i-tls-extensions.patch
|
|
+++ /dev/null
|
|
@@ -1,404 +0,0 @@
|
|
-This patch adds support for TLS SessionTicket extension (RFC 5077) for
|
|
-the parts used by EAP-FAST (RFC 4851).
|
|
-
|
|
-This is based on the patch from Alexey Kobozev <akobozev@cisco.com>
|
|
-(sent to openssl-dev mailing list on Tue, 07 Jun 2005 15:40:58 +0300).
|
|
-
|
|
-OpenSSL 0.9.8i does not enable TLS extension support by default, so it
|
|
-will need to be enabled by adding enable-tlsext to config script
|
|
-command line.
|
|
-
|
|
-
|
|
-Index: openssl-0.9.8i/ssl/s3_clnt.c
|
|
-===================================================================
|
|
---- openssl-0.9.8i.orig/ssl/s3_clnt.c 2008-06-16 19:56:41.000000000 +0300
|
|
-+++ openssl-0.9.8i/ssl/s3_clnt.c 2008-11-23 20:39:40.000000000 +0200
|
|
-@@ -759,6 +759,21 @@
|
|
- goto f_err;
|
|
- }
|
|
-
|
|
-+#ifndef OPENSSL_NO_TLSEXT
|
|
-+ /* check if we want to resume the session based on external pre-shared secret */
|
|
-+ 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->session->cipher=pref_cipher ?
|
|
-+ pref_cipher : ssl_get_cipher_by_char(s,p+j);
|
|
-+ }
|
|
-+ }
|
|
-+#endif /* OPENSSL_NO_TLSEXT */
|
|
-+
|
|
- if (j != 0 && j == s->session->session_id_length
|
|
- && memcmp(p,s->session->session_id,j) == 0)
|
|
- {
|
|
-@@ -2701,11 +2716,8 @@
|
|
- {
|
|
- 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 */
|
|
-Index: openssl-0.9.8i/ssl/s3_srvr.c
|
|
-===================================================================
|
|
---- openssl-0.9.8i.orig/ssl/s3_srvr.c 2008-09-14 21:16:09.000000000 +0300
|
|
-+++ openssl-0.9.8i/ssl/s3_srvr.c 2008-11-23 20:37:40.000000000 +0200
|
|
-@@ -959,6 +959,59 @@
|
|
- 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
|
|
- * options, we will now look for them. We have i-1 compression
|
|
-@@ -1097,16 +1150,22 @@
|
|
- 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]);
|
|
-
|
|
-Index: openssl-0.9.8i/ssl/ssl_err.c
|
|
-===================================================================
|
|
---- openssl-0.9.8i.orig/ssl/ssl_err.c 2008-08-13 22:44:44.000000000 +0300
|
|
-+++ openssl-0.9.8i/ssl/ssl_err.c 2008-11-23 20:33:43.000000000 +0200
|
|
-@@ -253,6 +253,7 @@
|
|
- {ERR_FUNC(SSL_F_TLS1_ENC), "TLS1_ENC"},
|
|
- {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_SESSION_TICKET_EXT), "SSL_set_session_ticket_ext"},
|
|
- {0,NULL}
|
|
- };
|
|
-
|
|
-Index: openssl-0.9.8i/ssl/ssl.h
|
|
-===================================================================
|
|
---- openssl-0.9.8i.orig/ssl/ssl.h 2008-08-13 22:44:44.000000000 +0300
|
|
-+++ openssl-0.9.8i/ssl/ssl.h 2008-11-23 20:35:41.000000000 +0200
|
|
-@@ -344,6 +344,7 @@
|
|
- * 'struct ssl_st *' function parameters used to prototype callbacks
|
|
- * in SSL_CTX. */
|
|
- typedef struct ssl_st *ssl_crock_st;
|
|
-+typedef struct tls_session_ticket_ext_st TLS_SESSION_TICKET_EXT;
|
|
-
|
|
- /* used to hold info on the particular ciphers used */
|
|
- typedef struct ssl_cipher_st
|
|
-@@ -362,6 +363,9 @@
|
|
-
|
|
- DECLARE_STACK_OF(SSL_CIPHER)
|
|
-
|
|
-+typedef int (*tls_session_ticket_ext_cb_fn)(SSL *s, const unsigned char *data, int len, 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 */
|
|
- typedef struct ssl_method_st
|
|
- {
|
|
-@@ -1034,6 +1038,18 @@
|
|
-
|
|
- /* RFC4507 session ticket expected to be received or sent */
|
|
- int tlsext_ticket_expected;
|
|
-+
|
|
-+ /* TLS Session Ticket extension override */
|
|
-+ TLS_SESSION_TICKET_EXT *tlsext_session_ticket;
|
|
-+
|
|
-+ /* TLS Session Ticket extension callback */
|
|
-+ tls_session_ticket_ext_cb_fn tls_session_ticket_ext_cb;
|
|
-+ void *tls_session_ticket_ext_cb_arg;
|
|
-+
|
|
-+ /* 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
|
|
-@@ -1632,6 +1648,15 @@
|
|
- int SSL_COMP_add_compression_method(int id,void *cm);
|
|
- #endif
|
|
-
|
|
-+/* TLS extensions functions */
|
|
-+int SSL_set_session_ticket_ext(SSL *s, void *ext_data, int ext_len);
|
|
-+
|
|
-+int SSL_set_session_ticket_ext_cb(SSL *s, tls_session_ticket_ext_cb_fn cb,
|
|
-+ void *arg);
|
|
-+
|
|
-+/* 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.
|
|
-@@ -1824,6 +1849,7 @@
|
|
- #define SSL_F_TLS1_ENC 210
|
|
- #define SSL_F_TLS1_SETUP_KEY_BLOCK 211
|
|
- #define SSL_F_WRITE_PENDING 212
|
|
-+#define SSL_F_SSL_SET_SESSION_TICKET_EXT 213
|
|
-
|
|
- /* Reason codes. */
|
|
- #define SSL_R_APP_DATA_IN_HANDSHAKE 100
|
|
-Index: openssl-0.9.8i/ssl/ssl_sess.c
|
|
-===================================================================
|
|
---- openssl-0.9.8i.orig/ssl/ssl_sess.c 2008-06-04 21:35:27.000000000 +0300
|
|
-+++ openssl-0.9.8i/ssl/ssl_sess.c 2008-11-23 20:32:24.000000000 +0200
|
|
-@@ -707,6 +707,61 @@
|
|
- 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_session_ticket_ext_cb(SSL *s, tls_session_ticket_ext_cb_fn cb,
|
|
-+ void *arg)
|
|
-+ {
|
|
-+ if (s == NULL) return(0);
|
|
-+ s->tls_session_ticket_ext_cb = cb;
|
|
-+ s->tls_session_ticket_ext_cb_arg = arg;
|
|
-+ return(1);
|
|
-+ }
|
|
-+
|
|
-+int SSL_set_session_ticket_ext(SSL *s, void *ext_data, int ext_len)
|
|
-+ {
|
|
-+ if (s->version >= TLS1_VERSION)
|
|
-+ {
|
|
-+ if (s->tlsext_session_ticket)
|
|
-+ {
|
|
-+ OPENSSL_free(s->tlsext_session_ticket);
|
|
-+ s->tlsext_session_ticket = NULL;
|
|
-+ }
|
|
-+
|
|
-+ s->tlsext_session_ticket = OPENSSL_malloc(sizeof(TLS_SESSION_TICKET_EXT) + ext_len);
|
|
-+ if (!s->tlsext_session_ticket)
|
|
-+ {
|
|
-+ SSLerr(SSL_F_SSL_SET_SESSION_TICKET_EXT, ERR_R_MALLOC_FAILURE);
|
|
-+ return 0;
|
|
-+ }
|
|
-+
|
|
-+ if (ext_data)
|
|
-+ {
|
|
-+ s->tlsext_session_ticket->length = ext_len;
|
|
-+ s->tlsext_session_ticket->data = s->tlsext_session_ticket + 1;
|
|
-+ memcpy(s->tlsext_session_ticket->data, ext_data, ext_len);
|
|
-+ }
|
|
-+ else
|
|
-+ {
|
|
-+ s->tlsext_session_ticket->length = 0;
|
|
-+ s->tlsext_session_ticket->data = NULL;
|
|
-+ }
|
|
-+
|
|
-+ return 1;
|
|
-+ }
|
|
-+
|
|
-+ return 0;
|
|
-+ }
|
|
-+#endif /* OPENSSL_NO_TLSEXT */
|
|
-+
|
|
- typedef struct timeout_param_st
|
|
- {
|
|
- SSL_CTX *ctx;
|
|
-Index: openssl-0.9.8i/ssl/t1_lib.c
|
|
-===================================================================
|
|
---- openssl-0.9.8i.orig/ssl/t1_lib.c 2008-09-04 01:13:04.000000000 +0300
|
|
-+++ openssl-0.9.8i/ssl/t1_lib.c 2008-11-23 20:31:20.000000000 +0200
|
|
-@@ -106,6 +106,12 @@
|
|
-
|
|
- void tls1_free(SSL *s)
|
|
- {
|
|
-+#ifndef OPENSSL_NO_TLSEXT
|
|
-+ if (s->tlsext_session_ticket)
|
|
-+ {
|
|
-+ OPENSSL_free(s->tlsext_session_ticket);
|
|
-+ }
|
|
-+#endif
|
|
- ssl3_free(s);
|
|
- }
|
|
-
|
|
-@@ -175,8 +181,23 @@
|
|
- int ticklen;
|
|
- if (s->session && s->session->tlsext_tick)
|
|
- ticklen = s->session->tlsext_ticklen;
|
|
-+ else if (s->session && s->tlsext_session_ticket &&
|
|
-+ s->tlsext_session_ticket->data)
|
|
-+ {
|
|
-+ ticklen = s->tlsext_session_ticket->length;
|
|
-+ s->session->tlsext_tick = OPENSSL_malloc(ticklen);
|
|
-+ if (!s->session->tlsext_tick)
|
|
-+ return NULL;
|
|
-+ memcpy(s->session->tlsext_tick,
|
|
-+ s->tlsext_session_ticket->data,
|
|
-+ ticklen);
|
|
-+ s->session->tlsext_ticklen = ticklen;
|
|
-+ }
|
|
- else
|
|
- ticklen = 0;
|
|
-+ if (ticklen == 0 && s->tlsext_session_ticket &&
|
|
-+ s->tlsext_session_ticket->data == NULL)
|
|
-+ goto skip_ext;
|
|
- /* Check for enough room 2 for extension type, 2 for len
|
|
- * rest for ticket
|
|
- */
|
|
-@@ -190,6 +211,7 @@
|
|
- ret += ticklen;
|
|
- }
|
|
- }
|
|
-+ skip_ext:
|
|
-
|
|
- if (s->tlsext_status_type == TLSEXT_STATUSTYPE_ocsp)
|
|
- {
|
|
-@@ -407,6 +429,15 @@
|
|
- }
|
|
-
|
|
- }
|
|
-+ else if (type == TLSEXT_TYPE_session_ticket)
|
|
-+ {
|
|
-+ if (s->tls_session_ticket_ext_cb &&
|
|
-+ !s->tls_session_ticket_ext_cb(s, data, size, s->tls_session_ticket_ext_cb_arg))
|
|
-+ {
|
|
-+ *al = TLS1_AD_INTERNAL_ERROR;
|
|
-+ return 0;
|
|
-+ }
|
|
-+ }
|
|
- else if (type == TLSEXT_TYPE_status_request
|
|
- && s->ctx->tlsext_status_cb)
|
|
- {
|
|
-@@ -553,6 +584,12 @@
|
|
- }
|
|
- else if (type == TLSEXT_TYPE_session_ticket)
|
|
- {
|
|
-+ if (s->tls_session_ticket_ext_cb &&
|
|
-+ !s->tls_session_ticket_ext_cb(s, data, size, s->tls_session_ticket_ext_cb_arg))
|
|
-+ {
|
|
-+ *al = TLS1_AD_INTERNAL_ERROR;
|
|
-+ return 0;
|
|
-+ }
|
|
- if ((SSL_get_options(s) & SSL_OP_NO_TICKET)
|
|
- || (size > 0))
|
|
- {
|
|
-@@ -776,6 +813,15 @@
|
|
- s->tlsext_ticket_expected = 1;
|
|
- return 0; /* Cache miss */
|
|
- }
|
|
-+ 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 tls_decrypt_ticket(s, p, size, session_id, len,
|
|
- ret);
|
|
- }
|
|
-Index: openssl-0.9.8i/ssl/tls1.h
|
|
-===================================================================
|
|
---- openssl-0.9.8i.orig/ssl/tls1.h 2008-04-30 19:11:33.000000000 +0300
|
|
-+++ openssl-0.9.8i/ssl/tls1.h 2008-11-23 20:22:38.000000000 +0200
|
|
-@@ -398,6 +398,13 @@
|
|
- #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_session_ticket_ext_st
|
|
-+ {
|
|
-+ unsigned short length;
|
|
-+ void *data;
|
|
-+ };
|
|
-+
|
|
- #ifdef __cplusplus
|
|
- }
|
|
- #endif
|
|
-Index: openssl-0.9.8i/util/ssleay.num
|
|
-===================================================================
|
|
---- openssl-0.9.8i.orig/util/ssleay.num 2008-06-05 13:57:21.000000000 +0300
|
|
-+++ openssl-0.9.8i/util/ssleay.num 2008-11-23 20:22:05.000000000 +0200
|
|
-@@ -242,3 +242,5 @@
|
|
- SSL_get_servername 291 EXIST::FUNCTION:TLSEXT
|
|
- SSL_get_servername_type 292 EXIST::FUNCTION:TLSEXT
|
|
- SSL_CTX_set_client_cert_engine 293 EXIST::FUNCTION:ENGINE
|
|
-+SSL_set_session_ticket_ext 306 EXIST::FUNCTION:TLSEXT
|
|
-+SSL_set_session_secret_cb 307 EXIST::FUNCTION:TLSEXT
|
|
diff --git a/patches/openssl-0.9.8x-tls-extensions.patch b/patches/openssl-0.9.8x-tls-extensions.patch
|
|
deleted file mode 100644
|
|
index d1c0dbe..0000000
|
|
--- a/patches/openssl-0.9.8x-tls-extensions.patch
|
|
+++ /dev/null
|
|
@@ -1,396 +0,0 @@
|
|
-This patch adds support for TLS SessionTicket extension (RFC 5077) for
|
|
-the parts used by EAP-FAST (RFC 4851).
|
|
-
|
|
-This is based on the patch from Alexey Kobozev <akobozev@cisco.com>
|
|
-(sent to openssl-dev mailing list on Tue, 07 Jun 2005 15:40:58 +0300).
|
|
-
|
|
-OpenSSL 0.9.8x does not enable TLS extension support by default, so it
|
|
-will need to be enabled by adding enable-tlsext to config script
|
|
-command line.
|
|
-
|
|
-
|
|
-diff -upr openssl-0.9.8x.orig/ssl/s3_clnt.c openssl-0.9.8x/ssl/s3_clnt.c
|
|
---- openssl-0.9.8x.orig/ssl/s3_clnt.c 2011-12-26 21:38:28.000000000 +0200
|
|
-+++ openssl-0.9.8x/ssl/s3_clnt.c 2012-07-07 10:46:31.501140621 +0300
|
|
-@@ -757,6 +757,21 @@ int ssl3_get_server_hello(SSL *s)
|
|
- goto f_err;
|
|
- }
|
|
-
|
|
-+#ifndef OPENSSL_NO_TLSEXT
|
|
-+ /* check if we want to resume the session based on external pre-shared secret */
|
|
-+ 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->session->cipher=pref_cipher ?
|
|
-+ pref_cipher : ssl_get_cipher_by_char(s,p+j);
|
|
-+ }
|
|
-+ }
|
|
-+#endif /* OPENSSL_NO_TLSEXT */
|
|
-+
|
|
- if (j != 0 && j == s->session->session_id_length
|
|
- && memcmp(p,s->session->session_id,j) == 0)
|
|
- {
|
|
-@@ -2725,11 +2740,8 @@ 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-0.9.8x.orig/ssl/s3_srvr.c openssl-0.9.8x/ssl/s3_srvr.c
|
|
---- openssl-0.9.8x.orig/ssl/s3_srvr.c 2012-02-16 17:21:17.000000000 +0200
|
|
-+++ openssl-0.9.8x/ssl/s3_srvr.c 2012-07-07 10:46:31.501140621 +0300
|
|
-@@ -1009,6 +1009,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
|
|
- * options, we will now look for them. We have i-1 compression
|
|
-@@ -1147,16 +1200,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-0.9.8x.orig/ssl/ssl_err.c openssl-0.9.8x/ssl/ssl_err.c
|
|
---- openssl-0.9.8x.orig/ssl/ssl_err.c 2012-03-12 16:50:55.000000000 +0200
|
|
-+++ openssl-0.9.8x/ssl/ssl_err.c 2012-07-07 10:46:31.501140621 +0300
|
|
-@@ -264,6 +264,7 @@ static ERR_STRING_DATA SSL_str_functs[]=
|
|
- {ERR_FUNC(SSL_F_TLS1_ENC), "TLS1_ENC"},
|
|
- {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_SESSION_TICKET_EXT), "SSL_set_session_ticket_ext"},
|
|
- {0,NULL}
|
|
- };
|
|
-
|
|
-diff -upr openssl-0.9.8x.orig/ssl/ssl.h openssl-0.9.8x/ssl/ssl.h
|
|
---- openssl-0.9.8x.orig/ssl/ssl.h 2012-03-12 16:50:55.000000000 +0200
|
|
-+++ openssl-0.9.8x/ssl/ssl.h 2012-07-07 10:46:31.501140621 +0300
|
|
-@@ -344,6 +344,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_session_ticket_ext_st TLS_SESSION_TICKET_EXT;
|
|
-
|
|
- /* used to hold info on the particular ciphers used */
|
|
- typedef struct ssl_cipher_st
|
|
-@@ -362,6 +363,9 @@ typedef struct ssl_cipher_st
|
|
-
|
|
- DECLARE_STACK_OF(SSL_CIPHER)
|
|
-
|
|
-+typedef int (*tls_session_ticket_ext_cb_fn)(SSL *s, const unsigned char *data, int len, 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 */
|
|
- typedef struct ssl_method_st
|
|
- {
|
|
-@@ -1050,6 +1054,18 @@ struct ssl_st
|
|
-
|
|
- /* RFC4507 session ticket expected to be received or sent */
|
|
- int tlsext_ticket_expected;
|
|
-+
|
|
-+ /* TLS Session Ticket extension override */
|
|
-+ TLS_SESSION_TICKET_EXT *tlsext_session_ticket;
|
|
-+
|
|
-+ /* TLS Session Ticket extension callback */
|
|
-+ tls_session_ticket_ext_cb_fn tls_session_ticket_ext_cb;
|
|
-+ void *tls_session_ticket_ext_cb_arg;
|
|
-+
|
|
-+ /* 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
|
|
-@@ -1663,6 +1679,15 @@ void *SSL_COMP_get_compression_methods(v
|
|
- int SSL_COMP_add_compression_method(int id,void *cm);
|
|
- #endif
|
|
-
|
|
-+/* TLS extensions functions */
|
|
-+int SSL_set_session_ticket_ext(SSL *s, void *ext_data, int ext_len);
|
|
-+
|
|
-+int SSL_set_session_ticket_ext_cb(SSL *s, tls_session_ticket_ext_cb_fn cb,
|
|
-+ void *arg);
|
|
-+
|
|
-+/* 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.
|
|
-@@ -1866,6 +1891,7 @@ void ERR_load_SSL_strings(void);
|
|
- #define SSL_F_TLS1_ENC 210
|
|
- #define SSL_F_TLS1_SETUP_KEY_BLOCK 211
|
|
- #define SSL_F_WRITE_PENDING 212
|
|
-+#define SSL_F_SSL_SET_SESSION_TICKET_EXT 213
|
|
-
|
|
- /* Reason codes. */
|
|
- #define SSL_R_APP_DATA_IN_HANDSHAKE 100
|
|
-diff -upr openssl-0.9.8x.orig/ssl/ssl_sess.c openssl-0.9.8x/ssl/ssl_sess.c
|
|
---- openssl-0.9.8x.orig/ssl/ssl_sess.c 2010-02-01 18:48:40.000000000 +0200
|
|
-+++ openssl-0.9.8x/ssl/ssl_sess.c 2012-07-07 10:46:31.501140621 +0300
|
|
-@@ -712,6 +712,61 @@ 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_session_ticket_ext_cb(SSL *s, tls_session_ticket_ext_cb_fn cb,
|
|
-+ void *arg)
|
|
-+ {
|
|
-+ if (s == NULL) return(0);
|
|
-+ s->tls_session_ticket_ext_cb = cb;
|
|
-+ s->tls_session_ticket_ext_cb_arg = arg;
|
|
-+ return(1);
|
|
-+ }
|
|
-+
|
|
-+int SSL_set_session_ticket_ext(SSL *s, void *ext_data, int ext_len)
|
|
-+ {
|
|
-+ if (s->version >= TLS1_VERSION)
|
|
-+ {
|
|
-+ if (s->tlsext_session_ticket)
|
|
-+ {
|
|
-+ OPENSSL_free(s->tlsext_session_ticket);
|
|
-+ s->tlsext_session_ticket = NULL;
|
|
-+ }
|
|
-+
|
|
-+ s->tlsext_session_ticket = OPENSSL_malloc(sizeof(TLS_SESSION_TICKET_EXT) + ext_len);
|
|
-+ if (!s->tlsext_session_ticket)
|
|
-+ {
|
|
-+ SSLerr(SSL_F_SSL_SET_SESSION_TICKET_EXT, ERR_R_MALLOC_FAILURE);
|
|
-+ return 0;
|
|
-+ }
|
|
-+
|
|
-+ if (ext_data)
|
|
-+ {
|
|
-+ s->tlsext_session_ticket->length = ext_len;
|
|
-+ s->tlsext_session_ticket->data = s->tlsext_session_ticket + 1;
|
|
-+ memcpy(s->tlsext_session_ticket->data, ext_data, ext_len);
|
|
-+ }
|
|
-+ else
|
|
-+ {
|
|
-+ s->tlsext_session_ticket->length = 0;
|
|
-+ s->tlsext_session_ticket->data = NULL;
|
|
-+ }
|
|
-+
|
|
-+ return 1;
|
|
-+ }
|
|
-+
|
|
-+ return 0;
|
|
-+ }
|
|
-+#endif /* OPENSSL_NO_TLSEXT */
|
|
-+
|
|
- typedef struct timeout_param_st
|
|
- {
|
|
- SSL_CTX *ctx;
|
|
-diff -upr openssl-0.9.8x.orig/ssl/t1_lib.c openssl-0.9.8x/ssl/t1_lib.c
|
|
---- openssl-0.9.8x.orig/ssl/t1_lib.c 2012-01-04 16:25:10.000000000 +0200
|
|
-+++ openssl-0.9.8x/ssl/t1_lib.c 2012-07-07 10:47:31.153140501 +0300
|
|
-@@ -106,6 +106,12 @@ int tls1_new(SSL *s)
|
|
-
|
|
- void tls1_free(SSL *s)
|
|
- {
|
|
-+#ifndef OPENSSL_NO_TLSEXT
|
|
-+ if (s->tlsext_session_ticket)
|
|
-+ {
|
|
-+ OPENSSL_free(s->tlsext_session_ticket);
|
|
-+ }
|
|
-+#endif
|
|
- ssl3_free(s);
|
|
- }
|
|
-
|
|
-@@ -206,8 +212,23 @@ unsigned char *ssl_add_clienthello_tlsex
|
|
- int ticklen;
|
|
- if (!s->new_session && s->session && s->session->tlsext_tick)
|
|
- ticklen = s->session->tlsext_ticklen;
|
|
-+ else if (s->session && s->tlsext_session_ticket &&
|
|
-+ s->tlsext_session_ticket->data)
|
|
-+ {
|
|
-+ ticklen = s->tlsext_session_ticket->length;
|
|
-+ s->session->tlsext_tick = OPENSSL_malloc(ticklen);
|
|
-+ if (!s->session->tlsext_tick)
|
|
-+ return NULL;
|
|
-+ memcpy(s->session->tlsext_tick,
|
|
-+ s->tlsext_session_ticket->data,
|
|
-+ ticklen);
|
|
-+ s->session->tlsext_ticklen = ticklen;
|
|
-+ }
|
|
- else
|
|
- ticklen = 0;
|
|
-+ if (ticklen == 0 && s->tlsext_session_ticket &&
|
|
-+ s->tlsext_session_ticket->data == NULL)
|
|
-+ goto skip_ext;
|
|
- /* Check for enough room 2 for extension type, 2 for len
|
|
- * rest for ticket
|
|
- */
|
|
-@@ -221,6 +242,7 @@ unsigned char *ssl_add_clienthello_tlsex
|
|
- ret += ticklen;
|
|
- }
|
|
- }
|
|
-+ skip_ext:
|
|
-
|
|
- if (s->tlsext_status_type == TLSEXT_STATUSTYPE_ocsp &&
|
|
- s->version != DTLS1_VERSION)
|
|
-@@ -486,6 +508,15 @@ int ssl_parse_clienthello_tlsext(SSL *s,
|
|
- return 0;
|
|
- renegotiate_seen = 1;
|
|
- }
|
|
-+ else if (type == TLSEXT_TYPE_session_ticket)
|
|
-+ {
|
|
-+ if (s->tls_session_ticket_ext_cb &&
|
|
-+ !s->tls_session_ticket_ext_cb(s, data, size, s->tls_session_ticket_ext_cb_arg))
|
|
-+ {
|
|
-+ *al = TLS1_AD_INTERNAL_ERROR;
|
|
-+ return 0;
|
|
-+ }
|
|
-+ }
|
|
- else if (type == TLSEXT_TYPE_status_request &&
|
|
- s->version != DTLS1_VERSION && s->ctx->tlsext_status_cb)
|
|
- {
|
|
-@@ -663,6 +694,12 @@ int ssl_parse_serverhello_tlsext(SSL *s,
|
|
- }
|
|
- else if (type == TLSEXT_TYPE_session_ticket)
|
|
- {
|
|
-+ if (s->tls_session_ticket_ext_cb &&
|
|
-+ !s->tls_session_ticket_ext_cb(s, data, size, s->tls_session_ticket_ext_cb_arg))
|
|
-+ {
|
|
-+ *al = TLS1_AD_INTERNAL_ERROR;
|
|
-+ return 0;
|
|
-+ }
|
|
- if ((SSL_get_options(s) & SSL_OP_NO_TICKET)
|
|
- || (size > 0))
|
|
- {
|
|
-@@ -920,6 +957,15 @@ int tls1_process_ticket(SSL *s, unsigned
|
|
- s->tlsext_ticket_expected = 1;
|
|
- return 0; /* Cache miss */
|
|
- }
|
|
-+ 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 tls_decrypt_ticket(s, p, size, session_id, len,
|
|
- ret);
|
|
- }
|
|
-diff -upr openssl-0.9.8x.orig/ssl/tls1.h openssl-0.9.8x/ssl/tls1.h
|
|
---- openssl-0.9.8x.orig/ssl/tls1.h 2009-11-08 16:51:54.000000000 +0200
|
|
-+++ openssl-0.9.8x/ssl/tls1.h 2012-07-07 10:46:31.501140621 +0300
|
|
-@@ -401,6 +401,13 @@ 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*/
|
|
- #endif
|
|
-
|
|
-+/* TLS extension struct */
|
|
-+struct tls_session_ticket_ext_st
|
|
-+ {
|
|
-+ unsigned short length;
|
|
-+ void *data;
|
|
-+ };
|
|
-+
|
|
- #ifdef __cplusplus
|
|
- }
|
|
- #endif
|
|
-diff -upr openssl-0.9.8x.orig/util/ssleay.num openssl-0.9.8x/util/ssleay.num
|
|
---- openssl-0.9.8x.orig/util/ssleay.num 2008-06-05 13:57:21.000000000 +0300
|
|
-+++ openssl-0.9.8x/util/ssleay.num 2012-07-07 10:46:31.505140623 +0300
|
|
-@@ -242,3 +242,5 @@ SSL_set_SSL_CTX
|
|
- SSL_get_servername 291 EXIST::FUNCTION:TLSEXT
|
|
- SSL_get_servername_type 292 EXIST::FUNCTION:TLSEXT
|
|
- SSL_CTX_set_client_cert_engine 293 EXIST::FUNCTION:ENGINE
|
|
-+SSL_set_session_ticket_ext 306 EXIST::FUNCTION:TLSEXT
|
|
-+SSL_set_session_secret_cb 307 EXIST::FUNCTION:TLSEXT
|
|
diff --git a/patches/openssl-0.9.8za-tls-extensions.patch b/patches/openssl-0.9.8za-tls-extensions.patch
|
|
new file mode 100644
|
|
index 0000000..3ae5aa9
|
|
--- /dev/null
|
|
+++ b/patches/openssl-0.9.8za-tls-extensions.patch
|
|
@@ -0,0 +1,396 @@
|
|
+This patch adds support for TLS SessionTicket extension (RFC 5077) for
|
|
+the parts used by EAP-FAST (RFC 4851).
|
|
+
|
|
+This is based on the patch from Alexey Kobozev <akobozev@cisco.com>
|
|
+(sent to openssl-dev mailing list on Tue, 07 Jun 2005 15:40:58 +0300).
|
|
+
|
|
+OpenSSL 0.9.8za does not enable TLS extension support by default, so it
|
|
+will need to be enabled by adding enable-tlsext to config script
|
|
+command line.
|
|
+
|
|
+
|
|
+diff -upr openssl-0.9.8za.orig/ssl/s3_clnt.c openssl-0.9.8za/ssl/s3_clnt.c
|
|
+--- openssl-0.9.8za.orig/ssl/s3_clnt.c 2014-06-05 11:09:26.000000000 +0300
|
|
++++ openssl-0.9.8za/ssl/s3_clnt.c 2014-06-05 20:37:09.221387312 +0300
|
|
+@@ -767,6 +767,21 @@ int ssl3_get_server_hello(SSL *s)
|
|
+ goto f_err;
|
|
+ }
|
|
+
|
|
++#ifndef OPENSSL_NO_TLSEXT
|
|
++ /* check if we want to resume the session based on external pre-shared secret */
|
|
++ 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->session->cipher=pref_cipher ?
|
|
++ pref_cipher : ssl_get_cipher_by_char(s,p+j);
|
|
++ }
|
|
++ }
|
|
++#endif /* OPENSSL_NO_TLSEXT */
|
|
++
|
|
+ if (j != 0 && j == s->session->session_id_length
|
|
+ && memcmp(p,s->session->session_id,j) == 0)
|
|
+ {
|
|
+@@ -2745,11 +2760,8 @@ 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-0.9.8za.orig/ssl/s3_srvr.c openssl-0.9.8za/ssl/s3_srvr.c
|
|
+--- openssl-0.9.8za.orig/ssl/s3_srvr.c 2014-06-05 11:09:26.000000000 +0300
|
|
++++ openssl-0.9.8za/ssl/s3_srvr.c 2014-06-05 20:37:09.225387312 +0300
|
|
+@@ -1011,6 +1011,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
|
|
+ * options, we will now look for them. We have i-1 compression
|
|
+@@ -1161,16 +1214,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-0.9.8za.orig/ssl/ssl_err.c openssl-0.9.8za/ssl/ssl_err.c
|
|
+--- openssl-0.9.8za.orig/ssl/ssl_err.c 2014-06-05 11:09:08.000000000 +0300
|
|
++++ openssl-0.9.8za/ssl/ssl_err.c 2014-06-05 20:37:09.225387312 +0300
|
|
+@@ -265,6 +265,7 @@ static ERR_STRING_DATA SSL_str_functs[]=
|
|
+ {ERR_FUNC(SSL_F_TLS1_ENC), "TLS1_ENC"},
|
|
+ {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_SESSION_TICKET_EXT), "SSL_set_session_ticket_ext"},
|
|
+ {0,NULL}
|
|
+ };
|
|
+
|
|
+diff -upr openssl-0.9.8za.orig/ssl/ssl.h openssl-0.9.8za/ssl/ssl.h
|
|
+--- openssl-0.9.8za.orig/ssl/ssl.h 2014-06-05 11:09:08.000000000 +0300
|
|
++++ openssl-0.9.8za/ssl/ssl.h 2014-06-05 20:37:09.229387312 +0300
|
|
+@@ -344,6 +344,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_session_ticket_ext_st TLS_SESSION_TICKET_EXT;
|
|
+
|
|
+ /* used to hold info on the particular ciphers used */
|
|
+ typedef struct ssl_cipher_st
|
|
+@@ -362,6 +363,9 @@ typedef struct ssl_cipher_st
|
|
+
|
|
+ DECLARE_STACK_OF(SSL_CIPHER)
|
|
+
|
|
++typedef int (*tls_session_ticket_ext_cb_fn)(SSL *s, const unsigned char *data, int len, 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 */
|
|
+ typedef struct ssl_method_st
|
|
+ {
|
|
+@@ -1053,6 +1057,18 @@ struct ssl_st
|
|
+
|
|
+ /* RFC4507 session ticket expected to be received or sent */
|
|
+ int tlsext_ticket_expected;
|
|
++
|
|
++ /* TLS Session Ticket extension override */
|
|
++ TLS_SESSION_TICKET_EXT *tlsext_session_ticket;
|
|
++
|
|
++ /* TLS Session Ticket extension callback */
|
|
++ tls_session_ticket_ext_cb_fn tls_session_ticket_ext_cb;
|
|
++ void *tls_session_ticket_ext_cb_arg;
|
|
++
|
|
++ /* 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
|
|
+@@ -1668,6 +1684,15 @@ void *SSL_COMP_get_compression_methods(v
|
|
+ int SSL_COMP_add_compression_method(int id,void *cm);
|
|
+ #endif
|
|
+
|
|
++/* TLS extensions functions */
|
|
++int SSL_set_session_ticket_ext(SSL *s, void *ext_data, int ext_len);
|
|
++
|
|
++int SSL_set_session_ticket_ext_cb(SSL *s, tls_session_ticket_ext_cb_fn cb,
|
|
++ void *arg);
|
|
++
|
|
++/* 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.
|
|
+@@ -1872,6 +1897,7 @@ void ERR_load_SSL_strings(void);
|
|
+ #define SSL_F_TLS1_ENC 210
|
|
+ #define SSL_F_TLS1_SETUP_KEY_BLOCK 211
|
|
+ #define SSL_F_WRITE_PENDING 212
|
|
++#define SSL_F_SSL_SET_SESSION_TICKET_EXT 213
|
|
+
|
|
+ /* Reason codes. */
|
|
+ #define SSL_R_APP_DATA_IN_HANDSHAKE 100
|
|
+diff -upr openssl-0.9.8za.orig/ssl/ssl_sess.c openssl-0.9.8za/ssl/ssl_sess.c
|
|
+--- openssl-0.9.8za.orig/ssl/ssl_sess.c 2014-06-05 11:09:08.000000000 +0300
|
|
++++ openssl-0.9.8za/ssl/ssl_sess.c 2014-06-05 20:37:09.229387312 +0300
|
|
+@@ -712,6 +712,61 @@ 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_session_ticket_ext_cb(SSL *s, tls_session_ticket_ext_cb_fn cb,
|
|
++ void *arg)
|
|
++ {
|
|
++ if (s == NULL) return(0);
|
|
++ s->tls_session_ticket_ext_cb = cb;
|
|
++ s->tls_session_ticket_ext_cb_arg = arg;
|
|
++ return(1);
|
|
++ }
|
|
++
|
|
++int SSL_set_session_ticket_ext(SSL *s, void *ext_data, int ext_len)
|
|
++ {
|
|
++ if (s->version >= TLS1_VERSION)
|
|
++ {
|
|
++ if (s->tlsext_session_ticket)
|
|
++ {
|
|
++ OPENSSL_free(s->tlsext_session_ticket);
|
|
++ s->tlsext_session_ticket = NULL;
|
|
++ }
|
|
++
|
|
++ s->tlsext_session_ticket = OPENSSL_malloc(sizeof(TLS_SESSION_TICKET_EXT) + ext_len);
|
|
++ if (!s->tlsext_session_ticket)
|
|
++ {
|
|
++ SSLerr(SSL_F_SSL_SET_SESSION_TICKET_EXT, ERR_R_MALLOC_FAILURE);
|
|
++ return 0;
|
|
++ }
|
|
++
|
|
++ if (ext_data)
|
|
++ {
|
|
++ s->tlsext_session_ticket->length = ext_len;
|
|
++ s->tlsext_session_ticket->data = s->tlsext_session_ticket + 1;
|
|
++ memcpy(s->tlsext_session_ticket->data, ext_data, ext_len);
|
|
++ }
|
|
++ else
|
|
++ {
|
|
++ s->tlsext_session_ticket->length = 0;
|
|
++ s->tlsext_session_ticket->data = NULL;
|
|
++ }
|
|
++
|
|
++ return 1;
|
|
++ }
|
|
++
|
|
++ return 0;
|
|
++ }
|
|
++#endif /* OPENSSL_NO_TLSEXT */
|
|
++
|
|
+ typedef struct timeout_param_st
|
|
+ {
|
|
+ SSL_CTX *ctx;
|
|
+diff -upr openssl-0.9.8za.orig/ssl/t1_lib.c openssl-0.9.8za/ssl/t1_lib.c
|
|
+--- openssl-0.9.8za.orig/ssl/t1_lib.c 2014-06-05 11:09:08.000000000 +0300
|
|
++++ openssl-0.9.8za/ssl/t1_lib.c 2014-06-05 20:37:09.229387312 +0300
|
|
+@@ -106,6 +106,12 @@ int tls1_new(SSL *s)
|
|
+
|
|
+ void tls1_free(SSL *s)
|
|
+ {
|
|
++#ifndef OPENSSL_NO_TLSEXT
|
|
++ if (s->tlsext_session_ticket)
|
|
++ {
|
|
++ OPENSSL_free(s->tlsext_session_ticket);
|
|
++ }
|
|
++#endif
|
|
+ ssl3_free(s);
|
|
+ }
|
|
+
|
|
+@@ -206,8 +212,23 @@ unsigned char *ssl_add_clienthello_tlsex
|
|
+ int ticklen;
|
|
+ if (!s->new_session && s->session && s->session->tlsext_tick)
|
|
+ ticklen = s->session->tlsext_ticklen;
|
|
++ else if (s->session && s->tlsext_session_ticket &&
|
|
++ s->tlsext_session_ticket->data)
|
|
++ {
|
|
++ ticklen = s->tlsext_session_ticket->length;
|
|
++ s->session->tlsext_tick = OPENSSL_malloc(ticklen);
|
|
++ if (!s->session->tlsext_tick)
|
|
++ return NULL;
|
|
++ memcpy(s->session->tlsext_tick,
|
|
++ s->tlsext_session_ticket->data,
|
|
++ ticklen);
|
|
++ s->session->tlsext_ticklen = ticklen;
|
|
++ }
|
|
+ else
|
|
+ ticklen = 0;
|
|
++ if (ticklen == 0 && s->tlsext_session_ticket &&
|
|
++ s->tlsext_session_ticket->data == NULL)
|
|
++ goto skip_ext;
|
|
+ /* Check for enough room 2 for extension type, 2 for len
|
|
+ * rest for ticket
|
|
+ */
|
|
+@@ -221,6 +242,7 @@ unsigned char *ssl_add_clienthello_tlsex
|
|
+ ret += ticklen;
|
|
+ }
|
|
+ }
|
|
++ skip_ext:
|
|
+
|
|
+ if (s->tlsext_status_type == TLSEXT_STATUSTYPE_ocsp &&
|
|
+ s->version != DTLS1_VERSION)
|
|
+@@ -574,6 +596,15 @@ int ssl_parse_clienthello_tlsext(SSL *s,
|
|
+ return 0;
|
|
+ renegotiate_seen = 1;
|
|
+ }
|
|
++ else if (type == TLSEXT_TYPE_session_ticket)
|
|
++ {
|
|
++ if (s->tls_session_ticket_ext_cb &&
|
|
++ !s->tls_session_ticket_ext_cb(s, data, size, s->tls_session_ticket_ext_cb_arg))
|
|
++ {
|
|
++ *al = TLS1_AD_INTERNAL_ERROR;
|
|
++ return 0;
|
|
++ }
|
|
++ }
|
|
+ else if (type == TLSEXT_TYPE_status_request &&
|
|
+ s->version != DTLS1_VERSION && s->ctx->tlsext_status_cb)
|
|
+ {
|
|
+@@ -751,6 +782,12 @@ int ssl_parse_serverhello_tlsext(SSL *s,
|
|
+ }
|
|
+ else if (type == TLSEXT_TYPE_session_ticket)
|
|
+ {
|
|
++ if (s->tls_session_ticket_ext_cb &&
|
|
++ !s->tls_session_ticket_ext_cb(s, data, size, s->tls_session_ticket_ext_cb_arg))
|
|
++ {
|
|
++ *al = TLS1_AD_INTERNAL_ERROR;
|
|
++ return 0;
|
|
++ }
|
|
+ if ((SSL_get_options(s) & SSL_OP_NO_TICKET)
|
|
+ || (size > 0))
|
|
+ {
|
|
+@@ -1043,6 +1080,15 @@ int tls1_process_ticket(SSL *s, unsigned
|
|
+ s->tlsext_ticket_expected = 1;
|
|
+ return 0; /* Cache miss */
|
|
+ }
|
|
++ 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 tls_decrypt_ticket(s, p, size, session_id, len,
|
|
+ ret);
|
|
+ }
|
|
+diff -upr openssl-0.9.8za.orig/ssl/tls1.h openssl-0.9.8za/ssl/tls1.h
|
|
+--- openssl-0.9.8za.orig/ssl/tls1.h 2014-06-05 11:09:08.000000000 +0300
|
|
++++ openssl-0.9.8za/ssl/tls1.h 2014-06-05 20:37:09.229387312 +0300
|
|
+@@ -415,6 +415,13 @@ 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*/
|
|
+ #endif
|
|
+
|
|
++/* TLS extension struct */
|
|
++struct tls_session_ticket_ext_st
|
|
++ {
|
|
++ unsigned short length;
|
|
++ void *data;
|
|
++ };
|
|
++
|
|
+ #ifdef __cplusplus
|
|
+ }
|
|
+ #endif
|
|
+diff -upr openssl-0.9.8za.orig/util/ssleay.num openssl-0.9.8za/util/ssleay.num
|
|
+--- openssl-0.9.8za.orig/util/ssleay.num 2014-06-05 12:38:45.000000000 +0300
|
|
++++ openssl-0.9.8za/util/ssleay.num 2014-06-05 20:37:09.229387312 +0300
|
|
+@@ -242,3 +242,5 @@ SSL_set_SSL_CTX
|
|
+ SSL_get_servername 291 EXIST::FUNCTION:TLSEXT
|
|
+ SSL_get_servername_type 292 EXIST::FUNCTION:TLSEXT
|
|
+ SSL_CTX_set_client_cert_engine 293 EXIST::FUNCTION:ENGINE
|
|
++SSL_set_session_ticket_ext 306 EXIST::FUNCTION:TLSEXT
|
|
++SSL_set_session_secret_cb 307 EXIST::FUNCTION:TLSEXT
|
|
diff --git a/patches/openssl-0.9.9-session-ticket.patch b/patches/openssl-0.9.9-session-ticket.patch
|
|
deleted file mode 100644
|
|
index 3afa639..0000000
|
|
--- a/patches/openssl-0.9.9-session-ticket.patch
|
|
+++ /dev/null
|
|
@@ -1,374 +0,0 @@
|
|
-This patch adds support for TLS SessionTicket extension (RFC 5077) for
|
|
-the parts used by EAP-FAST (RFC 4851).
|
|
-
|
|
-This is based on the patch from Alexey Kobozev <akobozev@cisco.com>
|
|
-(sent to openssl-dev mailing list on Tue, 07 Jun 2005 15:40:58 +0300).
|
|
-
|
|
-NOTE: This patch (without SSL_set_hello_extension() wrapper) was
|
|
-merged into the upstream OpenSSL 0.9.9 tree and as such, an external
|
|
-patch for EAP-FAST support is not needed anymore.
|
|
-
|
|
-
|
|
-
|
|
-Index: openssl-SNAP-20081111/ssl/s3_clnt.c
|
|
-===================================================================
|
|
---- openssl-SNAP-20081111.orig/ssl/s3_clnt.c
|
|
-+++ openssl-SNAP-20081111/ssl/s3_clnt.c
|
|
-@@ -788,6 +788,23 @@ int ssl3_get_server_hello(SSL *s)
|
|
- goto f_err;
|
|
- }
|
|
-
|
|
-+#ifndef OPENSSL_NO_TLSEXT
|
|
-+ /* check if we want to resume the session based on external pre-shared secret */
|
|
-+ 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->session->cipher = pref_cipher ?
|
|
-+ pref_cipher : ssl_get_cipher_by_char(s, p+j);
|
|
-+ }
|
|
-+ }
|
|
-+#endif /* OPENSSL_NO_TLSEXT */
|
|
-+
|
|
- if (j != 0 && j == s->session->session_id_length
|
|
- && memcmp(p,s->session->session_id,j) == 0)
|
|
- {
|
|
-@@ -2927,11 +2944,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 */
|
|
-Index: openssl-SNAP-20081111/ssl/s3_srvr.c
|
|
-===================================================================
|
|
---- openssl-SNAP-20081111.orig/ssl/s3_srvr.c
|
|
-+++ openssl-SNAP-20081111/ssl/s3_srvr.c
|
|
-@@ -1010,6 +1010,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
|
|
-@@ -1134,16 +1187,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]);
|
|
-
|
|
-Index: openssl-SNAP-20081111/ssl/ssl_err.c
|
|
-===================================================================
|
|
---- openssl-SNAP-20081111.orig/ssl/ssl_err.c
|
|
-+++ openssl-SNAP-20081111/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_SESSION_TICKET_EXT), "SSL_set_session_ticket_ext"},
|
|
- {0,NULL}
|
|
- };
|
|
-
|
|
-Index: openssl-SNAP-20081111/ssl/ssl.h
|
|
-===================================================================
|
|
---- openssl-SNAP-20081111.orig/ssl/ssl.h
|
|
-+++ openssl-SNAP-20081111/ssl/ssl.h
|
|
-@@ -355,6 +355,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_session_ticket_ext_st TLS_SESSION_TICKET_EXT;
|
|
-
|
|
- /* used to hold info on the particular ciphers used */
|
|
- typedef struct ssl_cipher_st
|
|
-@@ -378,6 +379,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);
|
|
-+
|
|
- /* Used to hold functions for SSLv2 or SSLv3/TLSv1 functions */
|
|
- typedef struct ssl_method_st
|
|
- {
|
|
-@@ -1145,6 +1148,13 @@ struct ssl_st
|
|
- void *tlsext_opaque_prf_input;
|
|
- size_t tlsext_opaque_prf_input_len;
|
|
-
|
|
-+ /* TLS Session Ticket extension override */
|
|
-+ TLS_SESSION_TICKET_EXT *tlsext_session_ticket;
|
|
-+
|
|
-+ /* 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
|
|
-@@ -1746,6 +1756,16 @@ void *SSL_COMP_get_compression_methods(v
|
|
- int SSL_COMP_add_compression_method(int id,void *cm);
|
|
- #endif
|
|
-
|
|
-+/* NOTE: This function will be removed; it is only here for backwards
|
|
-+ * compatibility for the API during testing. */
|
|
-+int SSL_set_hello_extension(SSL *s, int ext_type, void *ext_data, int ext_len);
|
|
-+
|
|
-+/* TLS extensions functions */
|
|
-+int SSL_set_session_ticket_ext(SSL *s, 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.
|
|
-@@ -1948,6 +1968,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_SESSION_TICKET_EXT 213
|
|
-
|
|
- /* Reason codes. */
|
|
- #define SSL_R_APP_DATA_IN_HANDSHAKE 100
|
|
-Index: openssl-SNAP-20081111/ssl/ssl_sess.c
|
|
-===================================================================
|
|
---- openssl-SNAP-20081111.orig/ssl/ssl_sess.c
|
|
-+++ openssl-SNAP-20081111/ssl/ssl_sess.c
|
|
-@@ -834,6 +834,62 @@ 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_session_ticket_ext(SSL *s, void *ext_data, int ext_len)
|
|
-+ {
|
|
-+ if (s->version >= TLS1_VERSION)
|
|
-+ {
|
|
-+ if (s->tlsext_session_ticket)
|
|
-+ {
|
|
-+ OPENSSL_free(s->tlsext_session_ticket);
|
|
-+ s->tlsext_session_ticket = NULL;
|
|
-+ }
|
|
-+
|
|
-+ s->tlsext_session_ticket = OPENSSL_malloc(sizeof(TLS_SESSION_TICKET_EXT) + ext_len);
|
|
-+ if (!s->tlsext_session_ticket)
|
|
-+ {
|
|
-+ SSLerr(SSL_F_SSL_SET_SESSION_TICKET_EXT, ERR_R_MALLOC_FAILURE);
|
|
-+ return 0;
|
|
-+ }
|
|
-+
|
|
-+ if (ext_data)
|
|
-+ {
|
|
-+ s->tlsext_session_ticket->length = ext_len;
|
|
-+ s->tlsext_session_ticket->data = s->tlsext_session_ticket + 1;
|
|
-+ memcpy(s->tlsext_session_ticket->data, ext_data, ext_len);
|
|
-+ }
|
|
-+ else
|
|
-+ {
|
|
-+ s->tlsext_session_ticket->length = 0;
|
|
-+ s->tlsext_session_ticket->data = NULL;
|
|
-+ }
|
|
-+
|
|
-+ return 1;
|
|
-+ }
|
|
-+
|
|
-+ return 0;
|
|
-+ }
|
|
-+
|
|
-+/* NOTE: This function will be removed; it is only here for backwards
|
|
-+ * compatibility for the API during testing. */
|
|
-+int SSL_set_hello_extension(SSL *s, int ext_type, void *ext_data, int ext_len)
|
|
-+ {
|
|
-+ if (ext_type != TLSEXT_TYPE_session_ticket)
|
|
-+ return 0;
|
|
-+
|
|
-+ return SSL_set_session_ticket_ext(s, ext_data, ext_len);
|
|
-+ }
|
|
-+#endif /* OPENSSL_NO_TLSEXT */
|
|
-+
|
|
- typedef struct timeout_param_st
|
|
- {
|
|
- SSL_CTX *ctx;
|
|
-Index: openssl-SNAP-20081111/ssl/t1_lib.c
|
|
-===================================================================
|
|
---- openssl-SNAP-20081111.orig/ssl/t1_lib.c
|
|
-+++ openssl-SNAP-20081111/ssl/t1_lib.c
|
|
-@@ -154,6 +154,12 @@ int tls1_new(SSL *s)
|
|
-
|
|
- void tls1_free(SSL *s)
|
|
- {
|
|
-+#ifndef OPENSSL_NO_TLSEXT
|
|
-+ if (s->tlsext_session_ticket)
|
|
-+ {
|
|
-+ OPENSSL_free(s->tlsext_session_ticket);
|
|
-+ }
|
|
-+#endif /* OPENSSL_NO_TLSEXT */
|
|
- ssl3_free(s);
|
|
- }
|
|
-
|
|
-@@ -357,8 +363,23 @@ 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->tlsext_session_ticket &&
|
|
-+ s->tlsext_session_ticket->data)
|
|
-+ {
|
|
-+ ticklen = s->tlsext_session_ticket->length;
|
|
-+ s->session->tlsext_tick = OPENSSL_malloc(ticklen);
|
|
-+ if (!s->session->tlsext_tick)
|
|
-+ return NULL;
|
|
-+ memcpy(s->session->tlsext_tick,
|
|
-+ s->tlsext_session_ticket->data,
|
|
-+ ticklen);
|
|
-+ s->session->tlsext_ticklen = ticklen;
|
|
-+ }
|
|
- else
|
|
- ticklen = 0;
|
|
-+ if (ticklen == 0 && s->tlsext_session_ticket &&
|
|
-+ s->tlsext_session_ticket->data == NULL)
|
|
-+ goto skip_ext;
|
|
- /* Check for enough room 2 for extension type, 2 for len
|
|
- * rest for ticket
|
|
- */
|
|
-@@ -371,6 +392,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)
|
|
-@@ -1435,6 +1457,15 @@ int tls1_process_ticket(SSL *s, unsigned
|
|
- s->tlsext_ticket_expected = 1;
|
|
- return 0; /* Cache miss */
|
|
- }
|
|
-+ 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 tls_decrypt_ticket(s, p, size, session_id, len,
|
|
- ret);
|
|
- }
|
|
-Index: openssl-SNAP-20081111/ssl/tls1.h
|
|
-===================================================================
|
|
---- openssl-SNAP-20081111.orig/ssl/tls1.h
|
|
-+++ openssl-SNAP-20081111/ssl/tls1.h
|
|
-@@ -512,6 +512,13 @@ 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*/
|
|
- #endif
|
|
-
|
|
-+/* TLS Session Ticket extension struct */
|
|
-+struct tls_session_ticket_ext_st
|
|
-+ {
|
|
-+ unsigned short length;
|
|
-+ void *data;
|
|
-+ };
|
|
-+
|
|
- #ifdef __cplusplus
|
|
- }
|
|
- #endif
|
|
-Index: openssl-SNAP-20081111/util/ssleay.num
|
|
-===================================================================
|
|
---- openssl-SNAP-20081111.orig/util/ssleay.num
|
|
-+++ openssl-SNAP-20081111/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_session_ticket_ext 306 EXIST::FUNCTION:TLSEXT
|
|
-+SSL_set_session_secret_cb 307 EXIST::FUNCTION:TLSEXT
|
|
--
|
|
1.7.9.5
|
|
|