summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2017-01-22 06:36:49 +0000
committerjsing <>2017-01-22 06:36:49 +0000
commit334c9196a27db4244daba48e4ba2118985c535ed (patch)
tree765f88b1c5ef0790c3644c70ffacf8e9a39b9ceb /src
parent107eff56043a3070d462256dca1675a3db9d9eab (diff)
downloadopenbsd-334c9196a27db4244daba48e4ba2118985c535ed.tar.gz
openbsd-334c9196a27db4244daba48e4ba2118985c535ed.tar.bz2
openbsd-334c9196a27db4244daba48e4ba2118985c535ed.zip
Move ALPN and NPN fields from SSL/SSL_CTX to internal.
ok beck@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libssl/s3_clnt.c6
-rw-r--r--src/lib/libssl/s3_lib.c8
-rw-r--r--src/lib/libssl/s3_srvr.c10
-rw-r--r--src/lib/libssl/ssl.h58
-rw-r--r--src/lib/libssl/ssl_lib.c64
-rw-r--r--src/lib/libssl/ssl_locl.h56
-rw-r--r--src/lib/libssl/t1_lib.c52
7 files changed, 129 insertions, 125 deletions
diff --git a/src/lib/libssl/s3_clnt.c b/src/lib/libssl/s3_clnt.c
index 874e4d398a..74f44dd930 100644
--- a/src/lib/libssl/s3_clnt.c
+++ b/src/lib/libssl/s3_clnt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: s3_clnt.c,v 1.159 2016/12/26 16:33:51 jsing Exp $ */ 1/* $OpenBSD: s3_clnt.c,v 1.160 2017/01/22 06:36:49 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -2702,10 +2702,10 @@ ssl3_send_next_proto(SSL *s)
2702 if (s->state == SSL3_ST_CW_NEXT_PROTO_A) { 2702 if (s->state == SSL3_ST_CW_NEXT_PROTO_A) {
2703 d = p = ssl3_handshake_msg_start(s, SSL3_MT_NEXT_PROTO); 2703 d = p = ssl3_handshake_msg_start(s, SSL3_MT_NEXT_PROTO);
2704 2704
2705 len = s->next_proto_negotiated_len; 2705 len = s->internal->next_proto_negotiated_len;
2706 padding_len = 32 - ((len + 2) % 32); 2706 padding_len = 32 - ((len + 2) % 32);
2707 *(p++) = len; 2707 *(p++) = len;
2708 memcpy(p, s->next_proto_negotiated, len); 2708 memcpy(p, s->internal->next_proto_negotiated, len);
2709 p += len; 2709 p += len;
2710 *(p++) = padding_len; 2710 *(p++) = padding_len;
2711 memset(p, 0, padding_len); 2711 memset(p, 0, padding_len);
diff --git a/src/lib/libssl/s3_lib.c b/src/lib/libssl/s3_lib.c
index 6f5ee4fa50..ef7a368d8f 100644
--- a/src/lib/libssl/s3_lib.c
+++ b/src/lib/libssl/s3_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: s3_lib.c,v 1.118 2017/01/22 03:50:45 jsing Exp $ */ 1/* $OpenBSD: s3_lib.c,v 1.119 2017/01/22 06:36:49 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -1902,9 +1902,9 @@ ssl3_clear(SSL *s)
1902 s->packet_length = 0; 1902 s->packet_length = 0;
1903 s->version = TLS1_VERSION; 1903 s->version = TLS1_VERSION;
1904 1904
1905 free(s->next_proto_negotiated); 1905 free(s->internal->next_proto_negotiated);
1906 s->next_proto_negotiated = NULL; 1906 s->internal->next_proto_negotiated = NULL;
1907 s->next_proto_negotiated_len = 0; 1907 s->internal->next_proto_negotiated_len = 0;
1908} 1908}
1909 1909
1910static long 1910static long
diff --git a/src/lib/libssl/s3_srvr.c b/src/lib/libssl/s3_srvr.c
index 8e3dc11fc1..72d90a85c4 100644
--- a/src/lib/libssl/s3_srvr.c
+++ b/src/lib/libssl/s3_srvr.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: s3_srvr.c,v 1.138 2016/12/21 16:44:31 jsing Exp $ */ 1/* $OpenBSD: s3_srvr.c,v 1.139 2017/01/22 06:36:49 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -2905,15 +2905,15 @@ ssl3_get_next_proto(SSL *s)
2905 * XXX We should not NULL it, but this matches old behavior of not 2905 * XXX We should not NULL it, but this matches old behavior of not
2906 * freeing before malloc. 2906 * freeing before malloc.
2907 */ 2907 */
2908 s->next_proto_negotiated = NULL; 2908 s->internal->next_proto_negotiated = NULL;
2909 s->next_proto_negotiated_len = 0; 2909 s->internal->next_proto_negotiated_len = 0;
2910 2910
2911 if (!CBS_stow(&proto, &s->next_proto_negotiated, &len)) { 2911 if (!CBS_stow(&proto, &s->internal->next_proto_negotiated, &len)) {
2912 SSLerr(SSL_F_SSL3_GET_NEXT_PROTO, 2912 SSLerr(SSL_F_SSL3_GET_NEXT_PROTO,
2913 ERR_R_MALLOC_FAILURE); 2913 ERR_R_MALLOC_FAILURE);
2914 return (0); 2914 return (0);
2915 } 2915 }
2916 s->next_proto_negotiated_len = (uint8_t)len; 2916 s->internal->next_proto_negotiated_len = (uint8_t)len;
2917 2917
2918 return (1); 2918 return (1);
2919} 2919}
diff --git a/src/lib/libssl/ssl.h b/src/lib/libssl/ssl.h
index b0f54100e2..fa1027fa28 100644
--- a/src/lib/libssl/ssl.h
+++ b/src/lib/libssl/ssl.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl.h,v 1.105 2017/01/22 05:14:42 beck Exp $ */ 1/* $OpenBSD: ssl.h,v 1.106 2017/01/22 06:36:49 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -841,48 +841,6 @@ struct ssl_ctx_st {
841 int (*tlsext_status_cb)(SSL *ssl, void *arg); 841 int (*tlsext_status_cb)(SSL *ssl, void *arg);
842 void *tlsext_status_arg; 842 void *tlsext_status_arg;
843 843
844
845
846
847 /* Next protocol negotiation information */
848 /* (for experimental NPN extension). */
849
850 /* For a server, this contains a callback function by which the set of
851 * advertised protocols can be provided. */
852 int (*next_protos_advertised_cb)(SSL *s, const unsigned char **buf,
853 unsigned int *len, void *arg);
854 void *next_protos_advertised_cb_arg;
855 /* For a client, this contains a callback function that selects the
856 * next protocol from the list provided by the server. */
857 int (*next_proto_select_cb)(SSL *s, unsigned char **out,
858 unsigned char *outlen, const unsigned char *in,
859 unsigned int inlen, void *arg);
860 void *next_proto_select_cb_arg;
861
862 /*
863 * ALPN information
864 * (we are in the process of transitioning from NPN to ALPN).
865 */
866
867 /*
868 * Server callback function that allows the server to select the
869 * protocol for the connection.
870 * out: on successful return, this must point to the raw protocol
871 * name (without the length prefix).
872 * outlen: on successful return, this contains the length of out.
873 * in: points to the client's list of supported protocols in
874 * wire-format.
875 * inlen: the length of in.
876 */
877 int (*alpn_select_cb)(SSL *s, const unsigned char **out,
878 unsigned char *outlen, const unsigned char *in, unsigned int inlen,
879 void *arg);
880 void *alpn_select_cb_arg;
881
882 /* Client list of supported protocols in wire format. */
883 unsigned char *alpn_client_proto_list;
884 unsigned int alpn_client_proto_list_len;
885
886 /* SRTP profiles we are willing to do from RFC 5764 */ 844 /* SRTP profiles we are willing to do from RFC 5764 */
887 STACK_OF(SRTP_PROTECTION_PROFILE) *srtp_profiles; 845 STACK_OF(SRTP_PROTECTION_PROFILE) *srtp_profiles;
888 846
@@ -1194,16 +1152,6 @@ struct ssl_st {
1194 SSL_CTX * initial_ctx; /* initial ctx, used to store sessions */ 1152 SSL_CTX * initial_ctx; /* initial ctx, used to store sessions */
1195#define session_ctx initial_ctx 1153#define session_ctx initial_ctx
1196 1154
1197 /* Next protocol negotiation. For the client, this is the protocol that
1198 * we sent in NextProtocol and is set when handling ServerHello
1199 * extensions.
1200 *
1201 * For a server, this is the client's selected_protocol from
1202 * NextProtocol and is set when handling the NextProtocol message,
1203 * before the Finished message. */
1204 unsigned char *next_proto_negotiated;
1205 unsigned char next_proto_negotiated_len;
1206
1207 STACK_OF(SRTP_PROTECTION_PROFILE) *srtp_profiles; /* What we'll do */ 1155 STACK_OF(SRTP_PROTECTION_PROFILE) *srtp_profiles; /* What we'll do */
1208 SRTP_PROTECTION_PROFILE *srtp_profile; /* What's been chosen */ 1156 SRTP_PROTECTION_PROFILE *srtp_profile; /* What's been chosen */
1209 1157
@@ -1215,10 +1163,6 @@ struct ssl_st {
1215 unsigned int tlsext_hb_pending; /* Indicates if a HeartbeatRequest is in flight */ 1163 unsigned int tlsext_hb_pending; /* Indicates if a HeartbeatRequest is in flight */
1216 unsigned int tlsext_hb_seq; /* HeartbeatRequest sequence number */ 1164 unsigned int tlsext_hb_seq; /* HeartbeatRequest sequence number */
1217 1165
1218 /* Client list of supported protocols in wire format. */
1219 unsigned char *alpn_client_proto_list;
1220 unsigned int alpn_client_proto_list_len;
1221
1222 int renegotiate;/* 1 if we are renegotiating. 1166 int renegotiate;/* 1 if we are renegotiating.
1223 * 2 if we are a server and are inside a handshake 1167 * 2 if we are a server and are inside a handshake
1224 * (i.e. not just sending a HelloRequest) */ 1168 * (i.e. not just sending a HelloRequest) */
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c
index d9e5166cdd..7031c91e1c 100644
--- a/src/lib/libssl/ssl_lib.c
+++ b/src/lib/libssl/ssl_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_lib.c,v 1.126 2017/01/22 03:50:45 jsing Exp $ */ 1/* $OpenBSD: ssl_lib.c,v 1.127 2017/01/22 06:36:49 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -336,18 +336,18 @@ SSL_new(SSL_CTX *ctx)
336 s->tlsext_ocsp_resplen = -1; 336 s->tlsext_ocsp_resplen = -1;
337 CRYPTO_add(&ctx->references, 1, CRYPTO_LOCK_SSL_CTX); 337 CRYPTO_add(&ctx->references, 1, CRYPTO_LOCK_SSL_CTX);
338 s->initial_ctx = ctx; 338 s->initial_ctx = ctx;
339 s->next_proto_negotiated = NULL; 339 s->internal->next_proto_negotiated = NULL;
340 340
341 if (s->ctx->alpn_client_proto_list != NULL) { 341 if (s->ctx->internal->alpn_client_proto_list != NULL) {
342 s->alpn_client_proto_list = 342 s->internal->alpn_client_proto_list =
343 malloc(s->ctx->alpn_client_proto_list_len); 343 malloc(s->ctx->internal->alpn_client_proto_list_len);
344 if (s->alpn_client_proto_list == NULL) 344 if (s->internal->alpn_client_proto_list == NULL)
345 goto err; 345 goto err;
346 memcpy(s->alpn_client_proto_list, 346 memcpy(s->internal->alpn_client_proto_list,
347 s->ctx->alpn_client_proto_list, 347 s->ctx->internal->alpn_client_proto_list,
348 s->ctx->alpn_client_proto_list_len); 348 s->ctx->internal->alpn_client_proto_list_len);
349 s->alpn_client_proto_list_len = 349 s->internal->alpn_client_proto_list_len =
350 s->ctx->alpn_client_proto_list_len; 350 s->ctx->internal->alpn_client_proto_list_len;
351 } 351 }
352 352
353 s->verify_result = X509_V_OK; 353 s->verify_result = X509_V_OK;
@@ -554,8 +554,8 @@ SSL_free(SSL *s)
554 554
555 SSL_CTX_free(s->ctx); 555 SSL_CTX_free(s->ctx);
556 556
557 free(s->next_proto_negotiated); 557 free(s->internal->next_proto_negotiated);
558 free(s->alpn_client_proto_list); 558 free(s->internal->alpn_client_proto_list);
559 559
560#ifndef OPENSSL_NO_SRTP 560#ifndef OPENSSL_NO_SRTP
561 if (s->srtp_profiles) 561 if (s->srtp_profiles)
@@ -1614,11 +1614,11 @@ void
1614SSL_get0_next_proto_negotiated(const SSL *s, const unsigned char **data, 1614SSL_get0_next_proto_negotiated(const SSL *s, const unsigned char **data,
1615 unsigned *len) 1615 unsigned *len)
1616{ 1616{
1617 *data = s->next_proto_negotiated; 1617 *data = s->internal->next_proto_negotiated;
1618 if (!*data) { 1618 if (!*data) {
1619 *len = 0; 1619 *len = 0;
1620 } else { 1620 } else {
1621 *len = s->next_proto_negotiated_len; 1621 *len = s->internal->next_proto_negotiated_len;
1622 } 1622 }
1623} 1623}
1624 1624
@@ -1637,8 +1637,8 @@ void
1637SSL_CTX_set_next_protos_advertised_cb(SSL_CTX *ctx, int (*cb) (SSL *ssl, 1637SSL_CTX_set_next_protos_advertised_cb(SSL_CTX *ctx, int (*cb) (SSL *ssl,
1638 const unsigned char **out, unsigned int *outlen, void *arg), void *arg) 1638 const unsigned char **out, unsigned int *outlen, void *arg), void *arg)
1639{ 1639{
1640 ctx->next_protos_advertised_cb = cb; 1640 ctx->internal->next_protos_advertised_cb = cb;
1641 ctx->next_protos_advertised_cb_arg = arg; 1641 ctx->internal->next_protos_advertised_cb_arg = arg;
1642} 1642}
1643 1643
1644/* 1644/*
@@ -1657,8 +1657,8 @@ SSL_CTX_set_next_proto_select_cb(SSL_CTX *ctx, int (*cb) (SSL *s,
1657 unsigned char **out, unsigned char *outlen, const unsigned char *in, 1657 unsigned char **out, unsigned char *outlen, const unsigned char *in,
1658 unsigned int inlen, void *arg), void *arg) 1658 unsigned int inlen, void *arg), void *arg)
1659{ 1659{
1660 ctx->next_proto_select_cb = cb; 1660 ctx->internal->next_proto_select_cb = cb;
1661 ctx->next_proto_select_cb_arg = arg; 1661 ctx->internal->next_proto_select_cb_arg = arg;
1662} 1662}
1663 1663
1664/* 1664/*
@@ -1670,11 +1670,11 @@ int
1670SSL_CTX_set_alpn_protos(SSL_CTX *ctx, const unsigned char *protos, 1670SSL_CTX_set_alpn_protos(SSL_CTX *ctx, const unsigned char *protos,
1671 unsigned int protos_len) 1671 unsigned int protos_len)
1672{ 1672{
1673 free(ctx->alpn_client_proto_list); 1673 free(ctx->internal->alpn_client_proto_list);
1674 if ((ctx->alpn_client_proto_list = malloc(protos_len)) == NULL) 1674 if ((ctx->internal->alpn_client_proto_list = malloc(protos_len)) == NULL)
1675 return (1); 1675 return (1);
1676 memcpy(ctx->alpn_client_proto_list, protos, protos_len); 1676 memcpy(ctx->internal->alpn_client_proto_list, protos, protos_len);
1677 ctx->alpn_client_proto_list_len = protos_len; 1677 ctx->internal->alpn_client_proto_list_len = protos_len;
1678 1678
1679 return (0); 1679 return (0);
1680} 1680}
@@ -1688,11 +1688,11 @@ int
1688SSL_set_alpn_protos(SSL *ssl, const unsigned char* protos, 1688SSL_set_alpn_protos(SSL *ssl, const unsigned char* protos,
1689 unsigned int protos_len) 1689 unsigned int protos_len)
1690{ 1690{
1691 free(ssl->alpn_client_proto_list); 1691 free(ssl->internal->alpn_client_proto_list);
1692 if ((ssl->alpn_client_proto_list = malloc(protos_len)) == NULL) 1692 if ((ssl->internal->alpn_client_proto_list = malloc(protos_len)) == NULL)
1693 return (1); 1693 return (1);
1694 memcpy(ssl->alpn_client_proto_list, protos, protos_len); 1694 memcpy(ssl->internal->alpn_client_proto_list, protos, protos_len);
1695 ssl->alpn_client_proto_list_len = protos_len; 1695 ssl->internal->alpn_client_proto_list_len = protos_len;
1696 1696
1697 return (0); 1697 return (0);
1698} 1698}
@@ -1707,8 +1707,8 @@ SSL_CTX_set_alpn_select_cb(SSL_CTX* ctx,
1707 int (*cb) (SSL *ssl, const unsigned char **out, unsigned char *outlen, 1707 int (*cb) (SSL *ssl, const unsigned char **out, unsigned char *outlen,
1708 const unsigned char *in, unsigned int inlen, void *arg), void *arg) 1708 const unsigned char *in, unsigned int inlen, void *arg), void *arg)
1709{ 1709{
1710 ctx->alpn_select_cb = cb; 1710 ctx->internal->alpn_select_cb = cb;
1711 ctx->alpn_select_cb_arg = arg; 1711 ctx->internal->alpn_select_cb_arg = arg;
1712} 1712}
1713 1713
1714/* 1714/*
@@ -1912,8 +1912,8 @@ SSL_CTX_new(const SSL_METHOD *meth)
1912 ret->tlsext_status_cb = 0; 1912 ret->tlsext_status_cb = 0;
1913 ret->tlsext_status_arg = NULL; 1913 ret->tlsext_status_arg = NULL;
1914 1914
1915 ret->next_protos_advertised_cb = 0; 1915 ret->internal->next_protos_advertised_cb = 0;
1916 ret->next_proto_select_cb = 0; 1916 ret->internal->next_proto_select_cb = 0;
1917#ifndef OPENSSL_NO_ENGINE 1917#ifndef OPENSSL_NO_ENGINE
1918 ret->client_cert_engine = NULL; 1918 ret->client_cert_engine = NULL;
1919#ifdef OPENSSL_SSL_CLIENT_ENGINE_AUTO 1919#ifdef OPENSSL_SSL_CLIENT_ENGINE_AUTO
@@ -2003,7 +2003,7 @@ SSL_CTX_free(SSL_CTX *a)
2003 ENGINE_finish(a->client_cert_engine); 2003 ENGINE_finish(a->client_cert_engine);
2004#endif 2004#endif
2005 2005
2006 free(a->alpn_client_proto_list); 2006 free(a->internal->alpn_client_proto_list);
2007 2007
2008 free(a->internal); 2008 free(a->internal);
2009 free(a); 2009 free(a);
diff --git a/src/lib/libssl/ssl_locl.h b/src/lib/libssl/ssl_locl.h
index b8b5dd0b1b..805d68906a 100644
--- a/src/lib/libssl/ssl_locl.h
+++ b/src/lib/libssl/ssl_locl.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_locl.h,v 1.148 2017/01/22 05:14:42 beck Exp $ */ 1/* $OpenBSD: ssl_locl.h,v 1.149 2017/01/22 06:36:49 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -383,11 +383,65 @@ typedef struct ssl_session_internal_st {
383typedef struct ssl_ctx_internal_st { 383typedef struct ssl_ctx_internal_st {
384 uint16_t min_version; 384 uint16_t min_version;
385 uint16_t max_version; 385 uint16_t max_version;
386
387 /* Next protocol negotiation information */
388 /* (for experimental NPN extension). */
389
390 /* For a server, this contains a callback function by which the set of
391 * advertised protocols can be provided. */
392 int (*next_protos_advertised_cb)(SSL *s, const unsigned char **buf,
393 unsigned int *len, void *arg);
394 void *next_protos_advertised_cb_arg;
395 /* For a client, this contains a callback function that selects the
396 * next protocol from the list provided by the server. */
397 int (*next_proto_select_cb)(SSL *s, unsigned char **out,
398 unsigned char *outlen, const unsigned char *in,
399 unsigned int inlen, void *arg);
400 void *next_proto_select_cb_arg;
401
402 /*
403 * ALPN information
404 * (we are in the process of transitioning from NPN to ALPN).
405 */
406
407 /*
408 * Server callback function that allows the server to select the
409 * protocol for the connection.
410 * out: on successful return, this must point to the raw protocol
411 * name (without the length prefix).
412 * outlen: on successful return, this contains the length of out.
413 * in: points to the client's list of supported protocols in
414 * wire-format.
415 * inlen: the length of in.
416 */
417 int (*alpn_select_cb)(SSL *s, const unsigned char **out,
418 unsigned char *outlen, const unsigned char *in, unsigned int inlen,
419 void *arg);
420 void *alpn_select_cb_arg;
421
422 /* Client list of supported protocols in wire format. */
423 unsigned char *alpn_client_proto_list;
424 unsigned int alpn_client_proto_list_len;
425
386} SSL_CTX_INTERNAL; 426} SSL_CTX_INTERNAL;
387 427
388typedef struct ssl_internal_st { 428typedef struct ssl_internal_st {
389 uint16_t min_version; 429 uint16_t min_version;
390 uint16_t max_version; 430 uint16_t max_version;
431
432 /* Next protocol negotiation. For the client, this is the protocol that
433 * we sent in NextProtocol and is set when handling ServerHello
434 * extensions.
435 *
436 * For a server, this is the client's selected_protocol from
437 * NextProtocol and is set when handling the NextProtocol message,
438 * before the Finished message. */
439 unsigned char *next_proto_negotiated;
440 unsigned char next_proto_negotiated_len;
441
442 /* Client list of supported protocols in wire format. */
443 unsigned char *alpn_client_proto_list;
444 unsigned int alpn_client_proto_list_len;
391} SSL_INTERNAL; 445} SSL_INTERNAL;
392 446
393typedef struct ssl3_state_internal_st { 447typedef struct ssl3_state_internal_st {
diff --git a/src/lib/libssl/t1_lib.c b/src/lib/libssl/t1_lib.c
index 958c105dd9..55624a2d24 100644
--- a/src/lib/libssl/t1_lib.c
+++ b/src/lib/libssl/t1_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: t1_lib.c,v 1.97 2017/01/22 05:14:42 beck Exp $ */ 1/* $OpenBSD: t1_lib.c,v 1.98 2017/01/22 06:36:49 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -862,7 +862,8 @@ skip_ext:
862 i2d_X509_EXTENSIONS(s->tlsext_ocsp_exts, &ret); 862 i2d_X509_EXTENSIONS(s->tlsext_ocsp_exts, &ret);
863 } 863 }
864 864
865 if (s->ctx->next_proto_select_cb && !s->s3->tmp.finish_md_len) { 865 if (s->ctx->internal->next_proto_select_cb &&
866 !s->s3->tmp.finish_md_len) {
866 /* The client advertises an emtpy extension to indicate its 867 /* The client advertises an emtpy extension to indicate its
867 * support for Next Protocol Negotiation */ 868 * support for Next Protocol Negotiation */
868 if ((size_t)(limit - ret) < 4) 869 if ((size_t)(limit - ret) < 4)
@@ -871,16 +872,17 @@ skip_ext:
871 s2n(0, ret); 872 s2n(0, ret);
872 } 873 }
873 874
874 if (s->alpn_client_proto_list != NULL && 875 if (s->internal->alpn_client_proto_list != NULL &&
875 s->s3->tmp.finish_md_len == 0) { 876 s->s3->tmp.finish_md_len == 0) {
876 if ((size_t)(limit - ret) < 6 + s->alpn_client_proto_list_len) 877 if ((size_t)(limit - ret) <
878 6 + s->internal->alpn_client_proto_list_len)
877 return (NULL); 879 return (NULL);
878 s2n(TLSEXT_TYPE_application_layer_protocol_negotiation, ret); 880 s2n(TLSEXT_TYPE_application_layer_protocol_negotiation, ret);
879 s2n(2 + s->alpn_client_proto_list_len, ret); 881 s2n(2 + s->internal->alpn_client_proto_list_len, ret);
880 s2n(s->alpn_client_proto_list_len, ret); 882 s2n(s->internal->alpn_client_proto_list_len, ret);
881 memcpy(ret, s->alpn_client_proto_list, 883 memcpy(ret, s->internal->alpn_client_proto_list,
882 s->alpn_client_proto_list_len); 884 s->internal->alpn_client_proto_list_len);
883 ret += s->alpn_client_proto_list_len; 885 ret += s->internal->alpn_client_proto_list_len;
884 } 886 }
885 887
886#ifndef OPENSSL_NO_SRTP 888#ifndef OPENSSL_NO_SRTP
@@ -1085,13 +1087,13 @@ ssl_add_serverhello_tlsext(SSL *s, unsigned char *p, unsigned char *limit)
1085 1087
1086 next_proto_neg_seen = s->s3->next_proto_neg_seen; 1088 next_proto_neg_seen = s->s3->next_proto_neg_seen;
1087 s->s3->next_proto_neg_seen = 0; 1089 s->s3->next_proto_neg_seen = 0;
1088 if (next_proto_neg_seen && s->ctx->next_protos_advertised_cb) { 1090 if (next_proto_neg_seen && s->ctx->internal->next_protos_advertised_cb) {
1089 const unsigned char *npa; 1091 const unsigned char *npa;
1090 unsigned int npalen; 1092 unsigned int npalen;
1091 int r; 1093 int r;
1092 1094
1093 r = s->ctx->next_protos_advertised_cb(s, &npa, &npalen, 1095 r = s->ctx->internal->next_protos_advertised_cb(s, &npa, &npalen,
1094 s->ctx->next_protos_advertised_cb_arg); 1096 s->ctx->internal->next_protos_advertised_cb_arg);
1095 if (r == SSL_TLSEXT_ERR_OK) { 1097 if (r == SSL_TLSEXT_ERR_OK) {
1096 if ((size_t)(limit - ret) < 4 + npalen) 1098 if ((size_t)(limit - ret) < 4 + npalen)
1097 return NULL; 1099 return NULL;
@@ -1142,7 +1144,7 @@ tls1_alpn_handle_client_hello(SSL *s, const unsigned char *data,
1142 unsigned char selected_len; 1144 unsigned char selected_len;
1143 int r; 1145 int r;
1144 1146
1145 if (s->ctx->alpn_select_cb == NULL) 1147 if (s->ctx->internal->alpn_select_cb == NULL)
1146 return (1); 1148 return (1);
1147 1149
1148 if (data_len < 2) 1150 if (data_len < 2)
@@ -1169,8 +1171,9 @@ tls1_alpn_handle_client_hello(SSL *s, const unsigned char *data,
1169 goto parse_error; 1171 goto parse_error;
1170 } 1172 }
1171 1173
1172 r = s->ctx->alpn_select_cb(s, &selected, &selected_len, 1174 r = s->ctx->internal->alpn_select_cb(s, &selected, &selected_len,
1173 CBS_data(&alpn), CBS_len(&alpn), s->ctx->alpn_select_cb_arg); 1175 CBS_data(&alpn), CBS_len(&alpn),
1176 s->ctx->internal->alpn_select_cb_arg);
1174 if (r == SSL_TLSEXT_ERR_OK) { 1177 if (r == SSL_TLSEXT_ERR_OK) {
1175 free(s->s3->alpn_selected); 1178 free(s->s3->alpn_selected);
1176 if ((s->s3->alpn_selected = malloc(selected_len)) == NULL) { 1179 if ((s->s3->alpn_selected = malloc(selected_len)) == NULL) {
@@ -1547,7 +1550,7 @@ ssl_parse_clienthello_tlsext(SSL *s, unsigned char **p, unsigned char *d,
1547 } 1550 }
1548 else if (type == 1551 else if (type ==
1549 TLSEXT_TYPE_application_layer_protocol_negotiation && 1552 TLSEXT_TYPE_application_layer_protocol_negotiation &&
1550 s->ctx->alpn_select_cb != NULL && 1553 s->ctx->internal->alpn_select_cb != NULL &&
1551 s->s3->tmp.finish_md_len == 0) { 1554 s->s3->tmp.finish_md_len == 0) {
1552 if (tls1_alpn_handle_client_hello(s, data, 1555 if (tls1_alpn_handle_client_hello(s, data,
1553 size, al) != 1) 1556 size, al) != 1)
@@ -1716,7 +1719,7 @@ ssl_parse_serverhello_tlsext(SSL *s, unsigned char **p, size_t n, int *al)
1716 unsigned char selected_len; 1719 unsigned char selected_len;
1717 1720
1718 /* We must have requested it. */ 1721 /* We must have requested it. */
1719 if (s->ctx->next_proto_select_cb == NULL) { 1722 if (s->ctx->internal->next_proto_select_cb == NULL) {
1720 *al = TLS1_AD_UNSUPPORTED_EXTENSION; 1723 *al = TLS1_AD_UNSUPPORTED_EXTENSION;
1721 return 0; 1724 return 0;
1722 } 1725 }
@@ -1725,17 +1728,20 @@ ssl_parse_serverhello_tlsext(SSL *s, unsigned char **p, size_t n, int *al)
1725 *al = TLS1_AD_DECODE_ERROR; 1728 *al = TLS1_AD_DECODE_ERROR;
1726 return 0; 1729 return 0;
1727 } 1730 }
1728 if (s->ctx->next_proto_select_cb(s, &selected, &selected_len, data, size, s->ctx->next_proto_select_cb_arg) != SSL_TLSEXT_ERR_OK) { 1731 if (s->ctx->internal->next_proto_select_cb(s, &selected,
1732 &selected_len, data, size,
1733 s->ctx->internal->next_proto_select_cb_arg) !=
1734 SSL_TLSEXT_ERR_OK) {
1729 *al = TLS1_AD_INTERNAL_ERROR; 1735 *al = TLS1_AD_INTERNAL_ERROR;
1730 return 0; 1736 return 0;
1731 } 1737 }
1732 s->next_proto_negotiated = malloc(selected_len); 1738 s->internal->next_proto_negotiated = malloc(selected_len);
1733 if (!s->next_proto_negotiated) { 1739 if (!s->internal->next_proto_negotiated) {
1734 *al = TLS1_AD_INTERNAL_ERROR; 1740 *al = TLS1_AD_INTERNAL_ERROR;
1735 return 0; 1741 return 0;
1736 } 1742 }
1737 memcpy(s->next_proto_negotiated, selected, selected_len); 1743 memcpy(s->internal->next_proto_negotiated, selected, selected_len);
1738 s->next_proto_negotiated_len = selected_len; 1744 s->internal->next_proto_negotiated_len = selected_len;
1739 s->s3->next_proto_neg_seen = 1; 1745 s->s3->next_proto_neg_seen = 1;
1740 } 1746 }
1741 else if (type == 1747 else if (type ==
@@ -1743,7 +1749,7 @@ ssl_parse_serverhello_tlsext(SSL *s, unsigned char **p, size_t n, int *al)
1743 unsigned int len; 1749 unsigned int len;
1744 1750
1745 /* We must have requested it. */ 1751 /* We must have requested it. */
1746 if (s->alpn_client_proto_list == NULL) { 1752 if (s->internal->alpn_client_proto_list == NULL) {
1747 *al = TLS1_AD_UNSUPPORTED_EXTENSION; 1753 *al = TLS1_AD_UNSUPPORTED_EXTENSION;
1748 return 0; 1754 return 0;
1749 } 1755 }