summaryrefslogtreecommitdiff
path: root/src/lib/libssl/ssl_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libssl/ssl_lib.c')
-rw-r--r--src/lib/libssl/ssl_lib.c78
1 files changed, 9 insertions, 69 deletions
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c
index de78ad2fcf..32a5680db7 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.166 2017/08/12 02:55:22 jsing Exp $ */ 1/* $OpenBSD: ssl_lib.c,v 1.167 2017/08/12 21:03:08 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 *
@@ -339,8 +339,6 @@ SSL_new(SSL_CTX *ctx)
339 ctx->internal->tlsext_supportedgroups_length; 339 ctx->internal->tlsext_supportedgroups_length;
340 } 340 }
341 341
342 s->internal->next_proto_negotiated = NULL;
343
344 if (s->ctx->internal->alpn_client_proto_list != NULL) { 342 if (s->ctx->internal->alpn_client_proto_list != NULL) {
345 s->internal->alpn_client_proto_list = 343 s->internal->alpn_client_proto_list =
346 malloc(s->ctx->internal->alpn_client_proto_list_len); 344 malloc(s->ctx->internal->alpn_client_proto_list_len);
@@ -548,7 +546,6 @@ SSL_free(SSL *s)
548 546
549 SSL_CTX_free(s->ctx); 547 SSL_CTX_free(s->ctx);
550 548
551 free(s->internal->next_proto_negotiated);
552 free(s->internal->alpn_client_proto_list); 549 free(s->internal->alpn_client_proto_list);
553 550
554#ifndef OPENSSL_NO_SRTP 551#ifndef OPENSSL_NO_SRTP
@@ -1541,33 +1538,15 @@ SSL_get_servername_type(const SSL *s)
1541} 1538}
1542 1539
1543/* 1540/*
1544 * SSL_select_next_proto implements the standard protocol selection. It is 1541 * SSL_select_next_proto implements standard protocol selection. It is
1545 * expected that this function is called from the callback set by 1542 * expected that this function is called from the callback set by
1546 * SSL_CTX_set_next_proto_select_cb. 1543 * SSL_CTX_set_alpn_select_cb.
1547 * 1544 *
1548 * The protocol data is assumed to be a vector of 8-bit, length prefixed byte 1545 * The protocol data is assumed to be a vector of 8-bit, length prefixed byte
1549 * strings. The length byte itself is not included in the length. A byte 1546 * strings. The length byte itself is not included in the length. A byte
1550 * string of length 0 is invalid. No byte string may be truncated. 1547 * string of length 0 is invalid. No byte string may be truncated.
1551 * 1548 *
1552 * The current, but experimental algorithm for selecting the protocol is: 1549 * It returns either:
1553 *
1554 * 1) If the server doesn't support NPN then this is indicated to the
1555 * callback. In this case, the client application has to abort the connection
1556 * or have a default application level protocol.
1557 *
1558 * 2) If the server supports NPN, but advertises an empty list then the
1559 * client selects the first protcol in its list, but indicates via the
1560 * API that this fallback case was enacted.
1561 *
1562 * 3) Otherwise, the client finds the first protocol in the server's list
1563 * that it supports and selects this protocol. This is because it's
1564 * assumed that the server has better information about which protocol
1565 * a client should use.
1566 *
1567 * 4) If the client doesn't support any of the server's advertised
1568 * protocols, then this is treated the same as case 2.
1569 *
1570 * It returns either
1571 * OPENSSL_NPN_NEGOTIATED if a common protocol was found, or 1550 * OPENSSL_NPN_NEGOTIATED if a common protocol was found, or
1572 * OPENSSL_NPN_NO_OVERLAP if the fallback case was reached. 1551 * OPENSSL_NPN_NO_OVERLAP if the fallback case was reached.
1573 */ 1552 */
@@ -1611,64 +1590,28 @@ found:
1611 return (status); 1590 return (status);
1612} 1591}
1613 1592
1614/* 1593/* SSL_get0_next_proto_negotiated is deprecated. */
1615 * SSL_get0_next_proto_negotiated sets *data and *len to point to the client's
1616 * requested protocol for this connection and returns 0. If the client didn't
1617 * request any protocol, then *data is set to NULL.
1618 *
1619 * Note that the client can request any protocol it chooses. The value returned
1620 * from this function need not be a member of the list of supported protocols
1621 * provided by the callback.
1622 */
1623void 1594void
1624SSL_get0_next_proto_negotiated(const SSL *s, const unsigned char **data, 1595SSL_get0_next_proto_negotiated(const SSL *s, const unsigned char **data,
1625 unsigned *len) 1596 unsigned *len)
1626{ 1597{
1627 *data = s->internal->next_proto_negotiated; 1598 *data = NULL;
1628 if (!*data) { 1599 *len = 0;
1629 *len = 0;
1630 } else {
1631 *len = s->internal->next_proto_negotiated_len;
1632 }
1633} 1600}
1634 1601
1635/* 1602/* SSL_CTX_set_next_protos_advertised_cb is deprecated. */
1636 * SSL_CTX_set_next_protos_advertised_cb sets a callback that is called when a
1637 * TLS server needs a list of supported protocols for Next Protocol
1638 * Negotiation. The returned list must be in wire format. The list is returned
1639 * by setting |out| to point to it and |outlen| to its length. This memory will
1640 * not be modified, but one should assume that the SSL* keeps a reference to
1641 * it.
1642 *
1643 * The callback should return SSL_TLSEXT_ERR_OK if it wishes to advertise.
1644 * Otherwise, no such extension will be included in the ServerHello.
1645 */
1646void 1603void
1647SSL_CTX_set_next_protos_advertised_cb(SSL_CTX *ctx, int (*cb) (SSL *ssl, 1604SSL_CTX_set_next_protos_advertised_cb(SSL_CTX *ctx, int (*cb) (SSL *ssl,
1648 const unsigned char **out, unsigned int *outlen, void *arg), void *arg) 1605 const unsigned char **out, unsigned int *outlen, void *arg), void *arg)
1649{ 1606{
1650 ctx->internal->next_protos_advertised_cb = cb;
1651 ctx->internal->next_protos_advertised_cb_arg = arg;
1652} 1607}
1653 1608
1654/* 1609/* SSL_CTX_set_next_proto_select_cb is deprecated. */
1655 * SSL_CTX_set_next_proto_select_cb sets a callback that is called when a
1656 * client needs to select a protocol from the server's provided list. |out|
1657 * must be set to point to the selected protocol (which may be within |in|).
1658 * The length of the protocol name must be written into |outlen|. The server's
1659 * advertised protocols are provided in |in| and |inlen|. The callback can
1660 * assume that |in| is syntactically valid.
1661 *
1662 * The client must select a protocol. It is fatal to the connection if this
1663 * callback returns a value other than SSL_TLSEXT_ERR_OK.
1664 */
1665void 1610void
1666SSL_CTX_set_next_proto_select_cb(SSL_CTX *ctx, int (*cb) (SSL *s, 1611SSL_CTX_set_next_proto_select_cb(SSL_CTX *ctx, int (*cb) (SSL *s,
1667 unsigned char **out, unsigned char *outlen, const unsigned char *in, 1612 unsigned char **out, unsigned char *outlen, const unsigned char *in,
1668 unsigned int inlen, void *arg), void *arg) 1613 unsigned int inlen, void *arg), void *arg)
1669{ 1614{
1670 ctx->internal->next_proto_select_cb = cb;
1671 ctx->internal->next_proto_select_cb_arg = arg;
1672} 1615}
1673 1616
1674/* 1617/*
@@ -1912,9 +1855,6 @@ SSL_CTX_new(const SSL_METHOD *meth)
1912 ret->internal->tlsext_status_cb = 0; 1855 ret->internal->tlsext_status_cb = 0;
1913 ret->internal->tlsext_status_arg = NULL; 1856 ret->internal->tlsext_status_arg = NULL;
1914 1857
1915 ret->internal->next_protos_advertised_cb = 0;
1916 ret->internal->next_proto_select_cb = 0;
1917
1918#ifndef OPENSSL_NO_ENGINE 1858#ifndef OPENSSL_NO_ENGINE
1919 ret->internal->client_cert_engine = NULL; 1859 ret->internal->client_cert_engine = NULL;
1920#ifdef OPENSSL_SSL_CLIENT_ENGINE_AUTO 1860#ifdef OPENSSL_SSL_CLIENT_ENGINE_AUTO