2024-07-23 07:40:53 -07:00
|
|
|
/* $OpenBSD: ssl_local.h,v 1.23 2024/07/23 14:40:54 jsing Exp $ */
|
1998-10-05 13:12:28 -07:00
|
|
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This package is an SSL implementation written
|
|
|
|
* by Eric Young (eay@cryptsoft.com).
|
|
|
|
* The implementation was written so as to conform with Netscapes SSL.
|
2014-12-14 07:30:50 -08:00
|
|
|
*
|
1998-10-05 13:12:28 -07:00
|
|
|
* This library is free for commercial and non-commercial use as long as
|
|
|
|
* the following conditions are aheared to. The following conditions
|
|
|
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
|
|
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
|
|
|
* included with this distribution is covered by the same copyright terms
|
|
|
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
2014-12-14 07:30:50 -08:00
|
|
|
*
|
1998-10-05 13:12:28 -07:00
|
|
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
|
|
|
* the code are not to be removed.
|
|
|
|
* If this package is used in a product, Eric Young should be given attribution
|
|
|
|
* as the author of the parts of the library used.
|
|
|
|
* This can be in the form of a textual message at program startup or
|
|
|
|
* in documentation (online or textual) provided with the package.
|
2014-12-14 07:30:50 -08:00
|
|
|
*
|
1998-10-05 13:12:28 -07:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* "This product includes cryptographic software written by
|
|
|
|
* Eric Young (eay@cryptsoft.com)"
|
|
|
|
* The word 'cryptographic' can be left out if the rouines from the library
|
|
|
|
* being used are not cryptographic related :-).
|
2014-12-14 07:30:50 -08:00
|
|
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
1998-10-05 13:12:28 -07:00
|
|
|
* the apps directory (application code) you must include an acknowledgement:
|
|
|
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
2014-12-14 07:30:50 -08:00
|
|
|
*
|
1998-10-05 13:12:28 -07:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
2014-12-14 07:30:50 -08:00
|
|
|
*
|
1998-10-05 13:12:28 -07:00
|
|
|
* The licence and distribution terms for any publically available version or
|
|
|
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
|
|
|
* copied and put under another distribution licence
|
|
|
|
* [including the GNU Public Licence.]
|
|
|
|
*/
|
2001-06-21 17:02:45 -07:00
|
|
|
/* ====================================================================
|
2010-10-01 15:58:41 -07:00
|
|
|
* Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved.
|
2001-06-21 17:02:45 -07:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
2014-12-14 07:30:50 -08:00
|
|
|
* notice, this list of conditions and the following disclaimer.
|
2001-06-21 17:02:45 -07:00
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
*
|
|
|
|
* 3. All advertising materials mentioning features or use of this
|
|
|
|
* software must display the following acknowledgment:
|
|
|
|
* "This product includes software developed by the OpenSSL Project
|
|
|
|
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
|
|
|
*
|
|
|
|
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
|
|
|
* endorse or promote products derived from this software without
|
|
|
|
* prior written permission. For written permission, please contact
|
|
|
|
* openssl-core@openssl.org.
|
|
|
|
*
|
|
|
|
* 5. Products derived from this software may not be called "OpenSSL"
|
|
|
|
* nor may "OpenSSL" appear in their names without prior written
|
|
|
|
* permission of the OpenSSL Project.
|
|
|
|
*
|
|
|
|
* 6. Redistributions of any form whatsoever must retain the following
|
|
|
|
* acknowledgment:
|
|
|
|
* "This product includes software developed by the OpenSSL Project
|
|
|
|
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
|
|
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
|
|
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
|
|
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
* ====================================================================
|
|
|
|
*
|
|
|
|
* This product includes cryptographic software written by Eric Young
|
|
|
|
* (eay@cryptsoft.com). This product includes software written by Tim
|
|
|
|
* Hudson (tjh@cryptsoft.com).
|
|
|
|
*
|
|
|
|
*/
|
2008-09-06 05:17:47 -07:00
|
|
|
/* ====================================================================
|
|
|
|
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
|
2014-12-14 07:30:50 -08:00
|
|
|
* ECC cipher suite support in OpenSSL originally developed by
|
2008-09-06 05:17:47 -07:00
|
|
|
* SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
|
|
|
|
*/
|
2010-10-01 15:58:41 -07:00
|
|
|
/* ====================================================================
|
|
|
|
* Copyright 2005 Nokia. All rights reserved.
|
|
|
|
*
|
|
|
|
* The portions of the attached software ("Contribution") is developed by
|
|
|
|
* Nokia Corporation and is licensed pursuant to the OpenSSL open source
|
|
|
|
* license.
|
|
|
|
*
|
|
|
|
* The Contribution, originally written by Mika Kousa and Pasi Eronen of
|
|
|
|
* Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites
|
|
|
|
* support (see RFC 4279) to OpenSSL.
|
|
|
|
*
|
|
|
|
* No patent licenses or other rights except those expressly stated in
|
|
|
|
* the OpenSSL open source license shall be deemed granted or received
|
|
|
|
* expressly, by implication, estoppel, or otherwise.
|
|
|
|
*
|
|
|
|
* No assurances are provided by Nokia that the Contribution does not
|
|
|
|
* infringe the patent or other intellectual property rights of any third
|
|
|
|
* party or that the license provides you with all the necessary rights
|
|
|
|
* to make use of the Contribution.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN
|
|
|
|
* ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA
|
|
|
|
* SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY
|
|
|
|
* OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR
|
|
|
|
* OTHERWISE.
|
|
|
|
*/
|
1998-10-05 13:12:28 -07:00
|
|
|
|
|
|
|
#ifndef HEADER_SSL_LOCL_H
|
|
|
|
#define HEADER_SSL_LOCL_H
|
2014-04-13 14:11:19 -07:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
2014-11-16 06:12:47 -08:00
|
|
|
#include <errno.h>
|
1998-10-05 13:12:28 -07:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2014-11-16 06:12:47 -08:00
|
|
|
#include <time.h>
|
2014-04-13 14:11:19 -07:00
|
|
|
#include <unistd.h>
|
1998-10-05 13:12:28 -07:00
|
|
|
|
2014-04-13 14:11:19 -07:00
|
|
|
#include <openssl/opensslconf.h>
|
2021-05-16 01:24:21 -07:00
|
|
|
|
1999-09-28 21:35:07 -07:00
|
|
|
#include <openssl/bio.h>
|
2014-11-16 06:12:47 -08:00
|
|
|
#include <openssl/buffer.h>
|
2008-09-06 05:17:47 -07:00
|
|
|
#include <openssl/dsa.h>
|
1999-09-28 21:35:07 -07:00
|
|
|
#include <openssl/err.h>
|
2014-11-16 06:12:47 -08:00
|
|
|
#include <openssl/rsa.h>
|
1999-09-28 21:35:07 -07:00
|
|
|
#include <openssl/ssl.h>
|
2014-11-16 06:12:47 -08:00
|
|
|
#include <openssl/stack.h>
|
2002-05-14 19:29:01 -07:00
|
|
|
|
2016-12-06 05:17:52 -08:00
|
|
|
#include "bytestring.h"
|
2022-11-11 09:15:26 -08:00
|
|
|
#include "tls_content.h"
|
2019-01-18 04:09:52 -08:00
|
|
|
#include "tls13_internal.h"
|
2016-12-06 05:17:52 -08:00
|
|
|
|
2016-11-04 11:28:57 -07:00
|
|
|
__BEGIN_HIDDEN_DECLS
|
|
|
|
|
Implement RSA key exchange in constant time.
RSA key exchange is known to have multiple security weaknesses,
including being potentially susceptible to padding oracle and timing
attacks.
The RSA key exchange code that we inherited from OpenSSL was riddled
with timing leaks, many of which we fixed (or minimised) early on.
However, a number of issues still remained, particularly those
related to libcrypto's RSA decryption and padding checks.
Rework the RSA key exchange code such that we decrypt with
RSA_NO_PADDING and then check the padding ourselves in constant
time. In this case, the pre-master secret is of a known length,
hence the padding is also a known length based on the size of the
RSA key. This makes it easy to implement a check that is much safer
than having RSA_private_decrypt() depad for us.
Regardless, we still strongly recommend disabling RSA key exchange
and using other key exchange methods that provide perfect forward
secrecy and do not depend on client generated keys.
Thanks to Marcel Maehren, Nurullah Erinola, Robert Merget, Juraj
Somorovsky, Joerg Schwenk and Hubert Kario for raising these issues
with us at various points in time.
ok tb@
2024-06-25 07:10:45 -07:00
|
|
|
#ifndef CTASSERT
|
2018-01-27 07:30:05 -08:00
|
|
|
#define CTASSERT(x) extern char _ctassert[(x) ? 1 : -1 ] \
|
|
|
|
__attribute__((__unused__))
|
Implement RSA key exchange in constant time.
RSA key exchange is known to have multiple security weaknesses,
including being potentially susceptible to padding oracle and timing
attacks.
The RSA key exchange code that we inherited from OpenSSL was riddled
with timing leaks, many of which we fixed (or minimised) early on.
However, a number of issues still remained, particularly those
related to libcrypto's RSA decryption and padding checks.
Rework the RSA key exchange code such that we decrypt with
RSA_NO_PADDING and then check the padding ourselves in constant
time. In this case, the pre-master secret is of a known length,
hence the padding is also a known length based on the size of the
RSA key. This makes it easy to implement a check that is much safer
than having RSA_private_decrypt() depad for us.
Regardless, we still strongly recommend disabling RSA key exchange
and using other key exchange methods that provide perfect forward
secrecy and do not depend on client generated keys.
Thanks to Marcel Maehren, Nurullah Erinola, Robert Merget, Juraj
Somorovsky, Joerg Schwenk and Hubert Kario for raising these issues
with us at various points in time.
ok tb@
2024-06-25 07:10:45 -07:00
|
|
|
#endif
|
2018-01-27 07:30:05 -08:00
|
|
|
|
2021-03-17 10:42:53 -07:00
|
|
|
#ifndef LIBRESSL_HAS_DTLS1_2
|
|
|
|
#define LIBRESSL_HAS_DTLS1_2
|
|
|
|
#endif
|
|
|
|
|
1998-10-05 13:12:28 -07:00
|
|
|
/* LOCAL STUFF */
|
|
|
|
|
|
|
|
#define SSL_DECRYPT 0
|
|
|
|
#define SSL_ENCRYPT 1
|
|
|
|
|
2000-03-19 03:07:35 -08:00
|
|
|
/*
|
|
|
|
* Define the Bitmasks for SSL_CIPHER.algorithms.
|
|
|
|
* This bits are used packed as dense as possible. If new methods/ciphers
|
|
|
|
* etc will be added, the bits a likely to change, so this information
|
|
|
|
* is for internal library use only, even though SSL_CIPHER.algorithms
|
|
|
|
* can be publicly accessed.
|
|
|
|
* Use the according functions for cipher management instead.
|
|
|
|
*
|
|
|
|
* The bit mask handling in the selection and sorting scheme in
|
|
|
|
* ssl_create_cipher_list() has only limited capabilities, reflecting
|
|
|
|
* that the different entities within are mutually exclusive:
|
|
|
|
* ONLY ONE BIT PER MASK CAN BE SET AT A TIME.
|
|
|
|
*/
|
2010-10-01 15:58:41 -07:00
|
|
|
|
|
|
|
/* Bits for algorithm_mkey (key exchange algorithm) */
|
1998-10-05 13:12:28 -07:00
|
|
|
#define SSL_kRSA 0x00000001L /* RSA key exchange */
|
2014-07-12 15:33:39 -07:00
|
|
|
#define SSL_kDHE 0x00000008L /* tmp DH key no DH cert */
|
|
|
|
#define SSL_kECDHE 0x00000080L /* ephemeral ECDH */
|
2018-11-06 17:53:36 -08:00
|
|
|
#define SSL_kTLS1_3 0x00000400L /* TLSv1.3 key exchange */
|
2010-10-01 15:58:41 -07:00
|
|
|
|
|
|
|
/* Bits for algorithm_auth (server authentication) */
|
|
|
|
#define SSL_aRSA 0x00000001L /* RSA auth */
|
2022-06-06 01:48:11 -07:00
|
|
|
#define SSL_aDSS 0x00000002L /* DSS auth */
|
|
|
|
#define SSL_aNULL 0x00000004L /* no auth (i.e. use ADH or AECDH) */
|
2010-10-01 15:58:41 -07:00
|
|
|
#define SSL_aECDSA 0x00000040L /* ECDSA auth*/
|
2018-11-06 17:53:36 -08:00
|
|
|
#define SSL_aTLS1_3 0x00000400L /* TLSv1.3 authentication */
|
2010-10-01 15:58:41 -07:00
|
|
|
|
|
|
|
/* Bits for algorithm_enc (symmetric encryption) */
|
|
|
|
#define SSL_DES 0x00000001L
|
|
|
|
#define SSL_3DES 0x00000002L
|
|
|
|
#define SSL_RC4 0x00000004L
|
2014-11-02 02:42:38 -08:00
|
|
|
#define SSL_IDEA 0x00000008L
|
|
|
|
#define SSL_eNULL 0x00000010L
|
|
|
|
#define SSL_AES128 0x00000020L
|
|
|
|
#define SSL_AES256 0x00000040L
|
|
|
|
#define SSL_CAMELLIA128 0x00000080L
|
|
|
|
#define SSL_CAMELLIA256 0x00000100L
|
|
|
|
#define SSL_AES128GCM 0x00000400L
|
|
|
|
#define SSL_AES256GCM 0x00000800L
|
|
|
|
#define SSL_CHACHA20POLY1305 0x00001000L
|
2010-10-01 15:58:41 -07:00
|
|
|
|
2022-06-06 01:48:11 -07:00
|
|
|
#define SSL_AES (SSL_AES128|SSL_AES256|SSL_AES128GCM|SSL_AES256GCM)
|
2010-10-01 15:58:41 -07:00
|
|
|
#define SSL_CAMELLIA (SSL_CAMELLIA128|SSL_CAMELLIA256)
|
|
|
|
|
|
|
|
|
|
|
|
/* Bits for algorithm_mac (symmetric authentication) */
|
2012-10-13 14:25:05 -07:00
|
|
|
|
2010-10-01 15:58:41 -07:00
|
|
|
#define SSL_MD5 0x00000001L
|
|
|
|
#define SSL_SHA1 0x00000002L
|
2012-10-13 14:25:05 -07:00
|
|
|
#define SSL_SHA256 0x00000010L
|
|
|
|
#define SSL_SHA384 0x00000020L
|
|
|
|
/* Not a real MAC, just an indication it is part of cipher */
|
|
|
|
#define SSL_AEAD 0x00000040L
|
2014-11-17 21:33:43 -08:00
|
|
|
#define SSL_STREEBOG256 0x00000080L
|
2010-10-01 15:58:41 -07:00
|
|
|
|
|
|
|
/* Bits for algorithm_ssl (protocol version) */
|
|
|
|
#define SSL_SSLV3 0x00000002L
|
2000-03-19 03:07:35 -08:00
|
|
|
#define SSL_TLSV1 SSL_SSLV3 /* for now */
|
2012-10-13 14:25:05 -07:00
|
|
|
#define SSL_TLSV1_2 0x00000004L
|
2018-11-06 17:53:36 -08:00
|
|
|
#define SSL_TLSV1_3 0x00000008L
|
2000-03-19 03:07:35 -08:00
|
|
|
|
2010-10-01 15:58:41 -07:00
|
|
|
|
|
|
|
/* Bits for algorithm2 (handshake digests and other extra flags) */
|
|
|
|
|
2017-03-05 06:39:53 -08:00
|
|
|
#define SSL_HANDSHAKE_MAC_MASK 0xff0
|
|
|
|
#define SSL_HANDSHAKE_MAC_SHA256 0x080
|
|
|
|
#define SSL_HANDSHAKE_MAC_SHA384 0x100
|
2010-10-01 15:58:41 -07:00
|
|
|
|
2014-08-23 07:52:41 -07:00
|
|
|
#define SSL3_CK_ID 0x03000000
|
2014-08-24 07:36:45 -07:00
|
|
|
#define SSL3_CK_VALUE_MASK 0x0000ffff
|
2014-08-23 07:52:41 -07:00
|
|
|
|
2000-03-19 03:07:35 -08:00
|
|
|
/*
|
2014-07-09 04:25:42 -07:00
|
|
|
* Cipher strength information.
|
2000-03-19 03:07:35 -08:00
|
|
|
*/
|
2010-10-01 15:58:41 -07:00
|
|
|
#define SSL_STRONG_MASK 0x000001fcL
|
2002-09-10 09:31:53 -07:00
|
|
|
#define SSL_STRONG_NONE 0x00000004L
|
|
|
|
#define SSL_LOW 0x00000020L
|
|
|
|
#define SSL_MEDIUM 0x00000040L
|
|
|
|
#define SSL_HIGH 0x00000080L
|
2000-03-19 03:07:35 -08:00
|
|
|
|
2014-07-27 21:23:12 -07:00
|
|
|
/*
|
|
|
|
* The keylength (measured in RSA key bits, I guess) for temporary keys.
|
|
|
|
* Cipher argument is so that this can be variable in the future.
|
|
|
|
*/
|
|
|
|
#define SSL_C_PKEYLENGTH(c) 1024
|
|
|
|
|
2014-05-29 09:00:16 -07:00
|
|
|
/* See if we use signature algorithms extension. */
|
|
|
|
#define SSL_USE_SIGALGS(s) \
|
2021-07-01 10:53:39 -07:00
|
|
|
(s->method->enc_flags & SSL_ENC_FLAG_SIGALGS)
|
2020-10-11 05:45:51 -07:00
|
|
|
|
2014-05-29 09:00:16 -07:00
|
|
|
/* Allow TLS 1.2 ciphersuites: applies to DTLS 1.2 as well as TLS 1.2. */
|
|
|
|
#define SSL_USE_TLS1_2_CIPHERS(s) \
|
2021-07-01 10:53:39 -07:00
|
|
|
(s->method->enc_flags & SSL_ENC_FLAG_TLS1_2_CIPHERS)
|
1998-10-05 13:12:28 -07:00
|
|
|
|
2020-01-23 02:40:59 -08:00
|
|
|
/* Allow TLS 1.3 ciphersuites only. */
|
|
|
|
#define SSL_USE_TLS1_3_CIPHERS(s) \
|
2021-07-01 10:53:39 -07:00
|
|
|
(s->method->enc_flags & SSL_ENC_FLAG_TLS1_3_CIPHERS)
|
2020-01-23 02:40:59 -08:00
|
|
|
|
2020-05-19 09:35:20 -07:00
|
|
|
#define SSL_PKEY_RSA 0
|
|
|
|
#define SSL_PKEY_ECC 1
|
2024-02-03 07:58:33 -08:00
|
|
|
#define SSL_PKEY_NUM 2
|
1998-10-05 13:12:28 -07:00
|
|
|
|
2017-01-25 23:20:57 -08:00
|
|
|
#define SSL_MAX_EMPTY_RECORDS 32
|
|
|
|
|
1998-10-05 13:12:28 -07:00
|
|
|
/* SSL_kRSA <- RSA_ENC | (RSA_TMP & RSA_SIGN) |
|
2022-06-06 01:48:11 -07:00
|
|
|
* <- (EXPORT & (RSA_ENC | RSA_TMP) & RSA_SIGN)
|
1998-10-05 13:12:28 -07:00
|
|
|
* SSL_kDH <- DH_ENC & (RSA_ENC | RSA_SIGN | DSA_SIGN)
|
2014-07-12 15:33:39 -07:00
|
|
|
* SSL_kDHE <- RSA_ENC | RSA_SIGN | DSA_SIGN
|
1998-10-05 13:12:28 -07:00
|
|
|
* SSL_aRSA <- RSA_ENC | RSA_SIGN
|
|
|
|
* SSL_aDSS <- DSA_SIGN
|
|
|
|
*/
|
|
|
|
|
2014-12-14 07:30:50 -08:00
|
|
|
/* From ECC-TLS draft, used in encoding the curve type in
|
2008-09-06 05:17:47 -07:00
|
|
|
* ECParameters
|
|
|
|
*/
|
2014-12-14 07:30:50 -08:00
|
|
|
#define EXPLICIT_PRIME_CURVE_TYPE 1
|
2008-09-06 05:17:47 -07:00
|
|
|
#define EXPLICIT_CHAR2_CURVE_TYPE 2
|
|
|
|
#define NAMED_CURVE_TYPE 3
|
|
|
|
|
2022-01-08 04:43:44 -08:00
|
|
|
typedef struct ssl_cert_pkey_st {
|
|
|
|
X509 *x509;
|
|
|
|
EVP_PKEY *privatekey;
|
|
|
|
STACK_OF(X509) *chain;
|
|
|
|
} SSL_CERT_PKEY;
|
|
|
|
|
|
|
|
typedef struct ssl_cert_st {
|
|
|
|
/* Current active set */
|
|
|
|
/* ALWAYS points to an element of the pkeys array
|
|
|
|
* Probably it would make more sense to store
|
|
|
|
* an index, not a pointer. */
|
|
|
|
SSL_CERT_PKEY *key;
|
|
|
|
|
|
|
|
SSL_CERT_PKEY pkeys[SSL_PKEY_NUM];
|
|
|
|
|
|
|
|
/* The following masks are for the key and auth
|
|
|
|
* algorithms that are supported by the certs below */
|
|
|
|
int valid;
|
|
|
|
unsigned long mask_k;
|
|
|
|
unsigned long mask_a;
|
|
|
|
|
|
|
|
DH *dhe_params;
|
|
|
|
DH *(*dhe_params_cb)(SSL *ssl, int is_export, int keysize);
|
|
|
|
int dhe_params_auto;
|
|
|
|
|
2022-06-28 13:31:43 -07:00
|
|
|
int (*security_cb)(const SSL *s, const SSL_CTX *ctx, int op, int bits,
|
2022-07-10 11:40:55 -07:00
|
|
|
int nid, void *other, void *ex_data); /* Not exposed in API. */
|
2022-06-28 13:31:43 -07:00
|
|
|
int security_level;
|
2022-07-10 11:40:55 -07:00
|
|
|
void *security_ex_data; /* Not exposed in API. */
|
2022-06-28 13:31:43 -07:00
|
|
|
|
2022-01-08 04:43:44 -08:00
|
|
|
int references; /* >1 only if SSL_copy_session_id is used */
|
|
|
|
} SSL_CERT;
|
|
|
|
|
2021-10-15 09:48:46 -07:00
|
|
|
struct ssl_comp_st {
|
|
|
|
int id;
|
|
|
|
const char *name;
|
|
|
|
};
|
|
|
|
|
2021-06-30 11:04:05 -07:00
|
|
|
struct ssl_cipher_st {
|
2024-07-22 07:47:15 -07:00
|
|
|
uint16_t value; /* Cipher suite value. */
|
|
|
|
|
2021-06-30 11:04:05 -07:00
|
|
|
const char *name; /* text name */
|
|
|
|
|
|
|
|
unsigned long algorithm_mkey; /* key exchange algorithm */
|
|
|
|
unsigned long algorithm_auth; /* server authentication */
|
|
|
|
unsigned long algorithm_enc; /* symmetric encryption */
|
|
|
|
unsigned long algorithm_mac; /* symmetric authentication */
|
|
|
|
unsigned long algorithm_ssl; /* (major) protocol version */
|
|
|
|
|
|
|
|
unsigned long algo_strength; /* strength and export flags */
|
|
|
|
unsigned long algorithm2; /* Extra flags */
|
|
|
|
int strength_bits; /* Number of bits really used */
|
|
|
|
int alg_bits; /* Number of bits for algorithm */
|
|
|
|
};
|
|
|
|
|
2021-07-01 10:53:39 -07:00
|
|
|
struct ssl_method_st {
|
2020-10-14 09:44:15 -07:00
|
|
|
int dtls;
|
2020-11-30 23:46:01 -08:00
|
|
|
int server;
|
2017-01-23 05:36:12 -08:00
|
|
|
int version;
|
|
|
|
|
2021-02-25 09:06:05 -08:00
|
|
|
uint16_t min_tls_version;
|
|
|
|
uint16_t max_tls_version;
|
2017-01-23 05:36:12 -08:00
|
|
|
|
|
|
|
int (*ssl_new)(SSL *s);
|
|
|
|
void (*ssl_clear)(SSL *s);
|
|
|
|
void (*ssl_free)(SSL *s);
|
|
|
|
|
|
|
|
int (*ssl_accept)(SSL *s);
|
|
|
|
int (*ssl_connect)(SSL *s);
|
2019-11-17 11:07:07 -08:00
|
|
|
int (*ssl_shutdown)(SSL *s);
|
2017-01-23 05:36:12 -08:00
|
|
|
|
|
|
|
int (*ssl_renegotiate)(SSL *s);
|
|
|
|
int (*ssl_renegotiate_check)(SSL *s);
|
|
|
|
|
2020-01-22 19:17:40 -08:00
|
|
|
int (*ssl_pending)(const SSL *s);
|
|
|
|
int (*ssl_read_bytes)(SSL *s, int type, unsigned char *buf, int len,
|
|
|
|
int peek);
|
2017-01-23 05:36:12 -08:00
|
|
|
int (*ssl_write_bytes)(SSL *s, int type, const void *buf_, int len);
|
|
|
|
|
2021-07-01 10:53:39 -07:00
|
|
|
unsigned int enc_flags; /* SSL_ENC_FLAG_* */
|
2021-06-30 11:04:05 -07:00
|
|
|
};
|
|
|
|
|
2022-06-06 09:11:00 -07:00
|
|
|
/*
|
|
|
|
* Let's make this into an ASN.1 type structure as follows
|
2021-06-30 11:04:05 -07:00
|
|
|
* SSL_SESSION_ID ::= SEQUENCE {
|
2022-06-06 01:48:11 -07:00
|
|
|
* version INTEGER, -- structure version number
|
|
|
|
* SSLversion INTEGER, -- SSL version number
|
2022-06-06 09:11:00 -07:00
|
|
|
* Cipher OCTET STRING, -- the 2 byte cipher ID
|
2022-06-06 01:48:11 -07:00
|
|
|
* Session_ID OCTET STRING, -- the Session ID
|
|
|
|
* Master_key OCTET STRING, -- the master key
|
2021-06-30 11:04:05 -07:00
|
|
|
* KRB5_principal OCTET STRING -- optional Kerberos principal
|
|
|
|
* Time [ 1 ] EXPLICIT INTEGER, -- optional Start Time
|
|
|
|
* Timeout [ 2 ] EXPLICIT INTEGER, -- optional Timeout ins seconds
|
|
|
|
* Peer [ 3 ] EXPLICIT X509, -- optional Peer Certificate
|
|
|
|
* Session_ID_context [ 4 ] EXPLICIT OCTET STRING, -- the Session ID context
|
|
|
|
* Verify_result [ 5 ] EXPLICIT INTEGER, -- X509_V_... code for `Peer'
|
|
|
|
* HostName [ 6 ] EXPLICIT OCTET STRING, -- optional HostName from servername TLS extension
|
|
|
|
* PSK_identity_hint [ 7 ] EXPLICIT OCTET STRING, -- optional PSK identity hint
|
|
|
|
* PSK_identity [ 8 ] EXPLICIT OCTET STRING, -- optional PSK identity
|
|
|
|
* Ticket_lifetime_hint [9] EXPLICIT INTEGER, -- server's lifetime hint for session ticket
|
|
|
|
* Ticket [10] EXPLICIT OCTET STRING, -- session ticket (clients only)
|
|
|
|
* Compression_meth [11] EXPLICIT OCTET STRING, -- optional compression method
|
|
|
|
* SRP_username [ 12 ] EXPLICIT OCTET STRING -- optional SRP username
|
2022-06-06 09:11:00 -07:00
|
|
|
* }
|
2021-06-30 11:04:05 -07:00
|
|
|
* Look in ssl/ssl_asn1.c for more details
|
|
|
|
* I'm using EXPLICIT tags so I can read the damn things using asn1parse :-).
|
|
|
|
*/
|
|
|
|
struct ssl_session_st {
|
|
|
|
int ssl_version; /* what ssl version session info is
|
|
|
|
* being kept in here? */
|
|
|
|
|
2022-06-07 10:18:21 -07:00
|
|
|
size_t master_key_length;
|
2021-06-30 11:04:05 -07:00
|
|
|
unsigned char master_key[SSL_MAX_MASTER_KEY_LENGTH];
|
|
|
|
|
|
|
|
/* session_id - valid? */
|
2022-06-07 10:42:35 -07:00
|
|
|
size_t session_id_length;
|
2021-06-30 11:04:05 -07:00
|
|
|
unsigned char session_id[SSL_MAX_SSL_SESSION_ID_LENGTH];
|
|
|
|
|
|
|
|
/* this is used to determine whether the session is being reused in
|
|
|
|
* the appropriate context. It is up to the application to set this,
|
|
|
|
* via SSL_new */
|
2022-06-07 10:52:00 -07:00
|
|
|
size_t sid_ctx_length;
|
2021-06-30 11:04:05 -07:00
|
|
|
unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];
|
|
|
|
|
2022-01-11 11:03:15 -08:00
|
|
|
/* Peer provided leaf (end-entity) certificate. */
|
2022-01-11 10:39:28 -08:00
|
|
|
X509 *peer_cert;
|
2022-01-11 11:03:15 -08:00
|
|
|
int peer_cert_type;
|
2021-06-30 11:04:05 -07:00
|
|
|
|
|
|
|
/* when app_verify_callback accepts a session where the peer's certificate
|
|
|
|
* is not ok, we must remember the error for session reuse: */
|
|
|
|
long verify_result; /* only for servers */
|
|
|
|
|
|
|
|
long timeout;
|
|
|
|
time_t time;
|
|
|
|
int references;
|
|
|
|
|
2024-07-22 07:47:15 -07:00
|
|
|
uint16_t cipher_value;
|
2021-06-30 11:04:05 -07:00
|
|
|
|
|
|
|
char *tlsext_hostname;
|
|
|
|
|
2022-10-20 08:20:27 -07:00
|
|
|
/* Session resumption - RFC 5077 and RFC 8446. */
|
2021-10-23 01:13:02 -07:00
|
|
|
unsigned char *tlsext_tick; /* Session ticket */
|
|
|
|
size_t tlsext_ticklen; /* Session ticket length */
|
|
|
|
uint32_t tlsext_tick_lifetime_hint; /* Session lifetime hint in seconds */
|
2022-10-20 08:20:27 -07:00
|
|
|
uint32_t tlsext_tick_age_add; /* TLSv1.3 ticket age obfuscation (in ms) */
|
|
|
|
struct tls13_secret resumption_master_secret;
|
2021-06-30 11:04:05 -07:00
|
|
|
|
2021-10-25 03:01:46 -07:00
|
|
|
CRYPTO_EX_DATA ex_data; /* application specific data */
|
|
|
|
|
|
|
|
/* These are used to make removal of session-ids more
|
|
|
|
* efficient and to implement a maximum cache size. */
|
|
|
|
struct ssl_session_st *prev, *next;
|
|
|
|
|
|
|
|
/* Used to indicate that session resumption is not allowed.
|
|
|
|
* Applications can also set this bit for a new session via
|
|
|
|
* not_resumable_session_cb to disable session caching and tickets. */
|
|
|
|
int not_resumable;
|
|
|
|
|
|
|
|
size_t tlsext_ecpointformatlist_length;
|
|
|
|
uint8_t *tlsext_ecpointformatlist; /* peer's list */
|
|
|
|
size_t tlsext_supportedgroups_length;
|
|
|
|
uint16_t *tlsext_supportedgroups; /* peer's list */
|
2021-06-30 11:04:05 -07:00
|
|
|
};
|
|
|
|
|
2021-05-16 03:55:17 -07:00
|
|
|
struct ssl_sigalg;
|
|
|
|
|
2021-03-24 11:40:03 -07:00
|
|
|
typedef struct ssl_handshake_tls12_st {
|
|
|
|
/* Used when SSL_ST_FLUSH_DATA is entered. */
|
|
|
|
int next_state;
|
|
|
|
|
2021-04-19 09:51:56 -07:00
|
|
|
/* Handshake message type and size. */
|
|
|
|
int message_type;
|
|
|
|
unsigned long message_size;
|
|
|
|
|
|
|
|
/* Reuse current handshake message. */
|
|
|
|
int reuse_message;
|
|
|
|
|
2021-04-21 12:27:56 -07:00
|
|
|
/* Client certificate requests. */
|
|
|
|
int cert_request;
|
|
|
|
STACK_OF(X509_NAME) *ca_names;
|
|
|
|
|
2021-03-24 11:40:03 -07:00
|
|
|
/* Record-layer key block for TLS 1.2 and earlier. */
|
2021-05-05 03:05:27 -07:00
|
|
|
struct tls12_key_block *key_block;
|
2021-04-19 09:51:56 -07:00
|
|
|
|
|
|
|
/* Transcript hash prior to sending certificate verify message. */
|
|
|
|
uint8_t cert_verify[EVP_MAX_MD_SIZE];
|
2021-03-24 11:40:03 -07:00
|
|
|
} SSL_HANDSHAKE_TLS12;
|
|
|
|
|
2021-03-21 11:36:34 -07:00
|
|
|
typedef struct ssl_handshake_tls13_st {
|
|
|
|
int use_legacy;
|
|
|
|
int hrr;
|
|
|
|
|
2022-06-03 06:28:36 -07:00
|
|
|
/* Client indicates psk_dhe_ke support in PskKeyExchangeMode. */
|
|
|
|
int use_psk_dhe_ke;
|
|
|
|
|
2021-06-27 12:23:51 -07:00
|
|
|
/* Certificate selected for use (static pointer). */
|
2022-01-08 04:43:44 -08:00
|
|
|
const SSL_CERT_PKEY *cpk;
|
2021-03-21 11:36:34 -07:00
|
|
|
|
|
|
|
/* Version proposed by peer server. */
|
|
|
|
uint16_t server_version;
|
|
|
|
|
|
|
|
uint16_t server_group;
|
|
|
|
struct tls13_secrets *secrets;
|
|
|
|
|
|
|
|
uint8_t *cookie;
|
|
|
|
size_t cookie_len;
|
|
|
|
|
|
|
|
/* Preserved transcript hash. */
|
|
|
|
uint8_t transcript_hash[EVP_MAX_MD_SIZE];
|
|
|
|
size_t transcript_hash_len;
|
|
|
|
|
|
|
|
/* Legacy session ID. */
|
|
|
|
uint8_t legacy_session_id[SSL_MAX_SSL_SESSION_ID_LENGTH];
|
|
|
|
size_t legacy_session_id_len;
|
|
|
|
|
|
|
|
/* ClientHello hash, used to validate following HelloRetryRequest */
|
|
|
|
EVP_MD_CTX *clienthello_md_ctx;
|
|
|
|
unsigned char *clienthello_hash;
|
|
|
|
unsigned int clienthello_hash_len;
|
2022-07-24 07:28:16 -07:00
|
|
|
|
2022-08-21 12:39:44 -07:00
|
|
|
/* QUIC read buffer and read/write encryption levels. */
|
|
|
|
struct tls_buffer *quic_read_buffer;
|
2022-07-24 07:28:16 -07:00
|
|
|
enum ssl_encryption_level_t quic_read_level;
|
|
|
|
enum ssl_encryption_level_t quic_write_level;
|
2021-03-21 11:36:34 -07:00
|
|
|
} SSL_HANDSHAKE_TLS13;
|
|
|
|
|
2017-05-06 15:24:57 -07:00
|
|
|
typedef struct ssl_handshake_st {
|
2021-03-10 10:27:01 -08:00
|
|
|
/*
|
|
|
|
* Minimum and maximum versions supported for this handshake. These are
|
|
|
|
* initialised at the start of a handshake based on the method in use
|
|
|
|
* and the current protocol version configuration.
|
|
|
|
*/
|
|
|
|
uint16_t our_min_tls_version;
|
|
|
|
uint16_t our_max_tls_version;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Version negotiated for this session. For a client this is set once
|
|
|
|
* the server selected version is parsed from the ServerHello (either
|
|
|
|
* from the legacy version or supported versions extension). For a
|
|
|
|
* server this is set once we select the version we will use with the
|
|
|
|
* client.
|
|
|
|
*/
|
|
|
|
uint16_t negotiated_tls_version;
|
|
|
|
|
2021-10-23 07:40:54 -07:00
|
|
|
/*
|
|
|
|
* Legacy version advertised by our peer. For a server this is the
|
|
|
|
* version specified by the client in the ClientHello message. For a
|
|
|
|
* client, this is the version provided in the ServerHello message.
|
|
|
|
*/
|
|
|
|
uint16_t peer_legacy_version;
|
|
|
|
|
2021-03-24 11:40:03 -07:00
|
|
|
/*
|
|
|
|
* Current handshake state - contains one of the SSL3_ST_* values and
|
|
|
|
* is used by the TLSv1.2 state machine, as well as being updated by
|
|
|
|
* the TLSv1.3 stack due to it being exposed externally.
|
|
|
|
*/
|
2017-05-06 21:22:24 -07:00
|
|
|
int state;
|
|
|
|
|
2021-03-24 11:40:03 -07:00
|
|
|
/* Cipher being negotiated in this handshake. */
|
2021-03-24 11:43:59 -07:00
|
|
|
const SSL_CIPHER *cipher;
|
2017-05-06 15:24:57 -07:00
|
|
|
|
2024-07-19 01:54:31 -07:00
|
|
|
/* Ciphers sent by the client. */
|
|
|
|
STACK_OF(SSL_CIPHER) *client_ciphers;
|
|
|
|
|
2019-01-23 17:50:41 -08:00
|
|
|
/* Extensions seen in this handshake. */
|
|
|
|
uint32_t extensions_seen;
|
2019-03-25 10:21:18 -07:00
|
|
|
|
2024-03-25 20:44:11 -07:00
|
|
|
/* Extensions processed in this handshake. */
|
|
|
|
uint32_t extensions_processed;
|
|
|
|
|
2021-06-27 12:23:51 -07:00
|
|
|
/* Signature algorithms selected for use (static pointers). */
|
|
|
|
const struct ssl_sigalg *our_sigalg;
|
|
|
|
const struct ssl_sigalg *peer_sigalg;
|
|
|
|
|
2019-03-25 10:21:18 -07:00
|
|
|
/* sigalgs offered in this handshake in wire form */
|
|
|
|
uint8_t *sigalgs;
|
2021-03-24 11:40:03 -07:00
|
|
|
size_t sigalgs_len;
|
|
|
|
|
2022-01-05 09:10:02 -08:00
|
|
|
/* Key share for ephemeral key exchange. */
|
|
|
|
struct tls_key_share *key_share;
|
|
|
|
|
2021-03-29 09:46:09 -07:00
|
|
|
/*
|
|
|
|
* Copies of the verify data sent in our finished message and the
|
|
|
|
* verify data received in the finished message sent by our peer.
|
|
|
|
*/
|
|
|
|
uint8_t finished[EVP_MAX_MD_SIZE];
|
|
|
|
size_t finished_len;
|
|
|
|
uint8_t peer_finished[EVP_MAX_MD_SIZE];
|
|
|
|
size_t peer_finished_len;
|
|
|
|
|
2022-08-17 00:39:19 -07:00
|
|
|
/* List of certificates received from our peer. */
|
|
|
|
STACK_OF(X509) *peer_certs;
|
|
|
|
STACK_OF(X509) *peer_certs_no_leaf;
|
|
|
|
|
2023-05-26 06:44:05 -07:00
|
|
|
/* Certificate chain resulting from X.509 verification. */
|
|
|
|
STACK_OF(X509) *verified_chain;
|
|
|
|
|
2021-03-24 11:40:03 -07:00
|
|
|
SSL_HANDSHAKE_TLS12 tls12;
|
|
|
|
SSL_HANDSHAKE_TLS13 tls13;
|
2017-05-06 15:24:57 -07:00
|
|
|
} SSL_HANDSHAKE;
|
|
|
|
|
2021-10-15 09:48:46 -07:00
|
|
|
typedef struct tls_session_ticket_ext_st TLS_SESSION_TICKET_EXT;
|
|
|
|
|
|
|
|
/* TLS Session Ticket extension struct. */
|
|
|
|
struct tls_session_ticket_ext_st {
|
|
|
|
unsigned short length;
|
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
2021-05-05 03:05:27 -07:00
|
|
|
struct tls12_key_block;
|
|
|
|
|
|
|
|
struct tls12_key_block *tls12_key_block_new(void);
|
|
|
|
void tls12_key_block_free(struct tls12_key_block *kb);
|
|
|
|
void tls12_key_block_client_write(struct tls12_key_block *kb, CBS *mac_key,
|
|
|
|
CBS *key, CBS *iv);
|
|
|
|
void tls12_key_block_server_write(struct tls12_key_block *kb, CBS *mac_key,
|
|
|
|
CBS *key, CBS *iv);
|
|
|
|
int tls12_key_block_generate(struct tls12_key_block *kb, SSL *s,
|
|
|
|
const EVP_AEAD *aead, const EVP_CIPHER *cipher, const EVP_MD *mac_hash);
|
|
|
|
|
2020-08-30 08:40:19 -07:00
|
|
|
struct tls12_record_layer;
|
|
|
|
|
|
|
|
struct tls12_record_layer *tls12_record_layer_new(void);
|
|
|
|
void tls12_record_layer_free(struct tls12_record_layer *rl);
|
2020-10-03 10:35:16 -07:00
|
|
|
void tls12_record_layer_alert(struct tls12_record_layer *rl,
|
|
|
|
uint8_t *alert_desc);
|
2021-01-19 10:51:08 -08:00
|
|
|
int tls12_record_layer_write_overhead(struct tls12_record_layer *rl,
|
|
|
|
size_t *overhead);
|
2021-01-19 10:57:09 -08:00
|
|
|
int tls12_record_layer_read_protected(struct tls12_record_layer *rl);
|
|
|
|
int tls12_record_layer_write_protected(struct tls12_record_layer *rl);
|
2021-01-28 09:00:38 -08:00
|
|
|
void tls12_record_layer_set_aead(struct tls12_record_layer *rl,
|
|
|
|
const EVP_AEAD *aead);
|
2021-02-27 06:20:50 -08:00
|
|
|
void tls12_record_layer_set_cipher_hash(struct tls12_record_layer *rl,
|
|
|
|
const EVP_CIPHER *cipher, const EVP_MD *handshake_hash,
|
|
|
|
const EVP_MD *mac_hash);
|
2020-08-30 08:40:19 -07:00
|
|
|
void tls12_record_layer_set_version(struct tls12_record_layer *rl,
|
|
|
|
uint16_t version);
|
2021-06-19 09:52:47 -07:00
|
|
|
void tls12_record_layer_set_initial_epoch(struct tls12_record_layer *rl,
|
|
|
|
uint16_t epoch);
|
2021-08-30 12:12:25 -07:00
|
|
|
uint16_t tls12_record_layer_read_epoch(struct tls12_record_layer *rl);
|
2021-05-05 12:52:00 -07:00
|
|
|
uint16_t tls12_record_layer_write_epoch(struct tls12_record_layer *rl);
|
2021-01-19 11:07:39 -08:00
|
|
|
int tls12_record_layer_use_write_epoch(struct tls12_record_layer *rl,
|
|
|
|
uint16_t epoch);
|
|
|
|
void tls12_record_layer_write_epoch_done(struct tls12_record_layer *rl,
|
|
|
|
uint16_t epoch);
|
2020-08-30 08:40:19 -07:00
|
|
|
void tls12_record_layer_clear_read_state(struct tls12_record_layer *rl);
|
|
|
|
void tls12_record_layer_clear_write_state(struct tls12_record_layer *rl);
|
2021-01-26 06:22:19 -08:00
|
|
|
void tls12_record_layer_reflect_seq_num(struct tls12_record_layer *rl);
|
2021-01-19 11:07:39 -08:00
|
|
|
int tls12_record_layer_change_read_cipher_state(struct tls12_record_layer *rl,
|
2021-05-05 03:05:27 -07:00
|
|
|
CBS *mac_key, CBS *key, CBS *iv);
|
2021-01-19 11:07:39 -08:00
|
|
|
int tls12_record_layer_change_write_cipher_state(struct tls12_record_layer *rl,
|
2021-05-05 03:05:27 -07:00
|
|
|
CBS *mac_key, CBS *key, CBS *iv);
|
2020-10-03 10:35:16 -07:00
|
|
|
int tls12_record_layer_open_record(struct tls12_record_layer *rl,
|
2022-11-11 09:15:26 -08:00
|
|
|
uint8_t *buf, size_t buf_len, struct tls_content *out);
|
2020-08-30 08:40:19 -07:00
|
|
|
int tls12_record_layer_seal_record(struct tls12_record_layer *rl,
|
|
|
|
uint8_t content_type, const uint8_t *content, size_t content_len,
|
|
|
|
CBB *out);
|
|
|
|
|
2021-08-30 12:25:43 -07:00
|
|
|
typedef void (ssl_info_callback_fn)(const SSL *s, int type, int val);
|
|
|
|
typedef void (ssl_msg_callback_fn)(int is_write, int version, int content_type,
|
|
|
|
const void *buf, size_t len, SSL *ssl, void *arg);
|
|
|
|
|
2022-10-02 09:36:41 -07:00
|
|
|
struct ssl_ctx_st {
|
|
|
|
const SSL_METHOD *method;
|
|
|
|
const SSL_QUIC_METHOD *quic_method;
|
|
|
|
|
|
|
|
STACK_OF(SSL_CIPHER) *cipher_list;
|
|
|
|
|
|
|
|
struct x509_store_st /* X509_STORE */ *cert_store;
|
|
|
|
|
|
|
|
/* If timeout is not 0, it is the default timeout value set
|
|
|
|
* when SSL_new() is called. This has been put in to make
|
|
|
|
* life easier to set things up */
|
|
|
|
long session_timeout;
|
|
|
|
|
|
|
|
int references;
|
|
|
|
|
|
|
|
/* Default values to use in SSL structures follow (these are copied by SSL_new) */
|
|
|
|
|
|
|
|
STACK_OF(X509) *extra_certs;
|
|
|
|
|
|
|
|
int verify_mode;
|
|
|
|
size_t sid_ctx_length;
|
|
|
|
unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];
|
|
|
|
|
|
|
|
X509_VERIFY_PARAM *param;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX
|
|
|
|
* default_passwd_cb used by python and openvpn, need to keep it until we
|
|
|
|
* add an accessor
|
|
|
|
*/
|
|
|
|
/* Default password callback. */
|
|
|
|
pem_password_cb *default_passwd_callback;
|
|
|
|
|
|
|
|
/* Default password callback user data. */
|
|
|
|
void *default_passwd_callback_userdata;
|
|
|
|
|
2021-02-25 09:06:05 -08:00
|
|
|
uint16_t min_tls_version;
|
|
|
|
uint16_t max_tls_version;
|
2017-01-21 22:36:49 -08:00
|
|
|
|
2021-02-20 01:43:29 -08:00
|
|
|
/*
|
|
|
|
* These may be zero to imply minimum or maximum version supported by
|
|
|
|
* the method.
|
|
|
|
*/
|
|
|
|
uint16_t min_proto_version;
|
|
|
|
uint16_t max_proto_version;
|
|
|
|
|
2017-01-23 06:35:42 -08:00
|
|
|
unsigned long options;
|
|
|
|
unsigned long mode;
|
|
|
|
|
2017-01-22 20:15:28 -08:00
|
|
|
/* If this callback is not null, it will be called each
|
|
|
|
* time a session id is added to the cache. If this function
|
|
|
|
* returns 1, it means that the callback will do a
|
|
|
|
* SSL_SESSION_free() when it has finished using it. Otherwise,
|
|
|
|
* on 0, it means the callback has finished with it.
|
|
|
|
* If remove_session_cb is not null, it will be called when
|
|
|
|
* a session-id is removed from the cache. After the call,
|
|
|
|
* OpenSSL will SSL_SESSION_free() it. */
|
|
|
|
int (*new_session_cb)(struct ssl_st *ssl, SSL_SESSION *sess);
|
|
|
|
void (*remove_session_cb)(struct ssl_ctx_st *ctx, SSL_SESSION *sess);
|
|
|
|
SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl,
|
2018-04-25 00:10:39 -07:00
|
|
|
const unsigned char *data, int len, int *copy);
|
2017-01-22 20:15:28 -08:00
|
|
|
|
|
|
|
/* if defined, these override the X509_verify_cert() calls */
|
|
|
|
int (*app_verify_callback)(X509_STORE_CTX *, void *);
|
|
|
|
void *app_verify_arg;
|
|
|
|
|
|
|
|
/* get client cert callback */
|
|
|
|
int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey);
|
|
|
|
|
|
|
|
/* cookie generate callback */
|
|
|
|
int (*app_gen_cookie_cb)(SSL *ssl, unsigned char *cookie,
|
|
|
|
unsigned int *cookie_len);
|
|
|
|
|
|
|
|
/* verify cookie callback */
|
2018-04-25 00:10:39 -07:00
|
|
|
int (*app_verify_cookie_cb)(SSL *ssl, const unsigned char *cookie,
|
2017-01-22 20:15:28 -08:00
|
|
|
unsigned int cookie_len);
|
|
|
|
|
2021-08-30 12:25:43 -07:00
|
|
|
ssl_info_callback_fn *info_callback;
|
2017-01-22 20:15:28 -08:00
|
|
|
|
|
|
|
/* callback that allows applications to peek at protocol messages */
|
2021-08-30 12:25:43 -07:00
|
|
|
ssl_msg_callback_fn *msg_callback;
|
2017-01-22 20:15:28 -08:00
|
|
|
void *msg_callback_arg;
|
|
|
|
|
|
|
|
int (*default_verify_callback)(int ok,X509_STORE_CTX *ctx); /* called 'verify_callback' in the SSL */
|
|
|
|
|
|
|
|
/* Default generate session ID callback. */
|
|
|
|
GEN_SESSION_CB generate_session_id;
|
|
|
|
|
|
|
|
/* TLS extensions servername callback */
|
|
|
|
int (*tlsext_servername_callback)(SSL*, int *, void *);
|
|
|
|
void *tlsext_servername_arg;
|
|
|
|
|
|
|
|
/* Callback to support customisation of ticket key setting */
|
|
|
|
int (*tlsext_ticket_key_cb)(SSL *ssl, unsigned char *name,
|
|
|
|
unsigned char *iv, EVP_CIPHER_CTX *ectx, HMAC_CTX *hctx, int enc);
|
|
|
|
|
|
|
|
/* certificate status request info */
|
|
|
|
/* Callback for status request */
|
|
|
|
int (*tlsext_status_cb)(SSL *ssl, void *arg);
|
|
|
|
void *tlsext_status_arg;
|
|
|
|
|
2017-01-22 21:13:02 -08:00
|
|
|
struct lhash_st_SSL_SESSION *sessions;
|
|
|
|
|
|
|
|
/* Most session-ids that will be cached, default is
|
|
|
|
* SSL_SESSION_CACHE_MAX_SIZE_DEFAULT. 0 is unlimited. */
|
|
|
|
unsigned long session_cache_size;
|
|
|
|
struct ssl_session_st *session_cache_head;
|
|
|
|
struct ssl_session_st *session_cache_tail;
|
|
|
|
|
|
|
|
/* This can have one of 2 values, ored together,
|
|
|
|
* SSL_SESS_CACHE_CLIENT,
|
|
|
|
* SSL_SESS_CACHE_SERVER,
|
|
|
|
* Default is SSL_SESSION_CACHE_SERVER, which means only
|
|
|
|
* SSL_accept which cache SSL_SESSIONS. */
|
|
|
|
int session_cache_mode;
|
|
|
|
|
2017-01-22 16:12:54 -08:00
|
|
|
struct {
|
|
|
|
int sess_connect; /* SSL new conn - started */
|
|
|
|
int sess_connect_renegotiate;/* SSL reneg - requested */
|
|
|
|
int sess_connect_good; /* SSL new conne/reneg - finished */
|
|
|
|
int sess_accept; /* SSL new accept - started */
|
|
|
|
int sess_accept_renegotiate;/* SSL reneg - requested */
|
|
|
|
int sess_accept_good; /* SSL accept/reneg - finished */
|
|
|
|
int sess_miss; /* session lookup misses */
|
|
|
|
int sess_timeout; /* reuse attempt on timeouted session */
|
|
|
|
int sess_cache_full; /* session removed due to full cache */
|
|
|
|
int sess_hit; /* session reuse actually done */
|
|
|
|
int sess_cb_hit; /* session-id that was not
|
|
|
|
* in the cache was
|
|
|
|
* passed back via the callback. This
|
|
|
|
* indicates that the application is
|
|
|
|
* supplying session-id's from other
|
|
|
|
* processes - spooky :-) */
|
|
|
|
} stats;
|
|
|
|
|
2017-01-22 21:13:02 -08:00
|
|
|
CRYPTO_EX_DATA ex_data;
|
|
|
|
|
2020-09-13 09:49:05 -07:00
|
|
|
STACK_OF(SSL_CIPHER) *cipher_list_tls13;
|
|
|
|
|
2022-01-08 04:43:44 -08:00
|
|
|
SSL_CERT *cert;
|
2017-01-22 21:13:02 -08:00
|
|
|
|
|
|
|
/* Default values used when no per-SSL value is defined follow */
|
|
|
|
|
|
|
|
/* what we put in client cert requests */
|
|
|
|
STACK_OF(X509_NAME) *client_CA;
|
|
|
|
|
|
|
|
long max_cert_list;
|
|
|
|
|
|
|
|
int read_ahead;
|
|
|
|
|
|
|
|
int quiet_shutdown;
|
|
|
|
|
|
|
|
/* Maximum amount of data to send in one fragment.
|
|
|
|
* actual record size can be more than this due to
|
|
|
|
* padding and MAC overheads.
|
|
|
|
*/
|
|
|
|
unsigned int max_send_fragment;
|
|
|
|
|
|
|
|
/* RFC 4507 session ticket keys */
|
|
|
|
unsigned char tlsext_tick_key_name[16];
|
|
|
|
unsigned char tlsext_tick_hmac_key[16];
|
|
|
|
unsigned char tlsext_tick_aes_key[16];
|
|
|
|
|
|
|
|
/* SRTP profiles we are willing to do from RFC 5764 */
|
|
|
|
STACK_OF(SRTP_PROTECTION_PROFILE) *srtp_profiles;
|
|
|
|
|
2017-01-21 22:36:49 -08:00
|
|
|
/*
|
2017-08-12 14:03:08 -07:00
|
|
|
* ALPN information.
|
2017-01-21 22:36:49 -08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Server callback function that allows the server to select the
|
|
|
|
* protocol for the connection.
|
|
|
|
* out: on successful return, this must point to the raw protocol
|
|
|
|
* name (without the length prefix).
|
|
|
|
* outlen: on successful return, this contains the length of out.
|
|
|
|
* in: points to the client's list of supported protocols in
|
|
|
|
* wire-format.
|
|
|
|
* inlen: the length of in.
|
|
|
|
*/
|
|
|
|
int (*alpn_select_cb)(SSL *s, const unsigned char **out,
|
|
|
|
unsigned char *outlen, const unsigned char *in, unsigned int inlen,
|
|
|
|
void *arg);
|
|
|
|
void *alpn_select_cb_arg;
|
|
|
|
|
|
|
|
/* Client list of supported protocols in wire format. */
|
2022-07-20 06:43:33 -07:00
|
|
|
uint8_t *alpn_client_proto_list;
|
|
|
|
size_t alpn_client_proto_list_len;
|
2017-01-24 01:03:21 -08:00
|
|
|
|
|
|
|
size_t tlsext_ecpointformatlist_length;
|
|
|
|
uint8_t *tlsext_ecpointformatlist; /* our list */
|
|
|
|
size_t tlsext_supportedgroups_length;
|
|
|
|
uint16_t *tlsext_supportedgroups; /* our list */
|
2021-10-23 04:41:51 -07:00
|
|
|
SSL_CTX_keylog_cb_func keylog_callback; /* Unused. For OpenSSL compatibility. */
|
2021-10-23 09:29:15 -07:00
|
|
|
size_t num_tickets; /* Unused, for OpenSSL compatibility */
|
2022-10-02 09:36:41 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ssl_st {
|
|
|
|
/* protocol version
|
|
|
|
* (one of SSL2_VERSION, SSL3_VERSION, TLS1_VERSION, DTLS1_VERSION)
|
|
|
|
*/
|
|
|
|
int version;
|
2017-01-21 19:50:45 -08:00
|
|
|
|
2021-10-15 09:48:46 -07:00
|
|
|
const SSL_METHOD *method;
|
2022-08-21 12:32:38 -07:00
|
|
|
const SSL_QUIC_METHOD *quic_method;
|
2021-10-15 09:48:46 -07:00
|
|
|
|
2022-10-02 09:36:41 -07:00
|
|
|
/* There are 2 BIO's even though they are normally both the
|
|
|
|
* same. This is so data can be read and written to different
|
|
|
|
* handlers */
|
2021-10-15 09:48:46 -07:00
|
|
|
|
2022-10-02 09:36:41 -07:00
|
|
|
BIO *rbio; /* used by SSL_read */
|
|
|
|
BIO *wbio; /* used by SSL_write */
|
|
|
|
BIO *bbio; /* used during session-id reuse to concatenate
|
|
|
|
* messages */
|
|
|
|
int server; /* are we the server side? - mostly used by SSL_clear*/
|
2021-10-15 09:48:46 -07:00
|
|
|
|
2022-10-02 09:36:41 -07:00
|
|
|
struct ssl3_state_st *s3; /* SSLv3 variables */
|
|
|
|
struct dtls1_state_st *d1; /* DTLSv1 variables */
|
2021-10-15 09:48:46 -07:00
|
|
|
|
2022-10-02 09:36:41 -07:00
|
|
|
X509_VERIFY_PARAM *param;
|
2021-10-15 09:48:46 -07:00
|
|
|
|
2022-10-02 09:36:41 -07:00
|
|
|
/* crypto */
|
|
|
|
STACK_OF(SSL_CIPHER) *cipher_list;
|
2021-10-15 09:48:46 -07:00
|
|
|
|
2022-10-02 09:36:41 -07:00
|
|
|
/* This is used to hold the server certificate used */
|
|
|
|
SSL_CERT *cert;
|
2021-10-15 09:48:46 -07:00
|
|
|
|
2022-10-02 09:36:41 -07:00
|
|
|
/* the session_id_context is used to ensure sessions are only reused
|
|
|
|
* in the appropriate context */
|
2022-06-07 10:52:00 -07:00
|
|
|
size_t sid_ctx_length;
|
2021-10-15 09:48:46 -07:00
|
|
|
unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];
|
|
|
|
|
2022-10-02 09:36:41 -07:00
|
|
|
/* This can also be in the session once a session is established */
|
|
|
|
SSL_SESSION *session;
|
2021-10-15 09:48:46 -07:00
|
|
|
|
2022-10-02 09:36:41 -07:00
|
|
|
/* Used in SSL2 and SSL3 */
|
|
|
|
int verify_mode; /* 0 don't care about verify failure.
|
|
|
|
* 1 fail if verify fails */
|
|
|
|
int error; /* error bytes to be written */
|
|
|
|
int error_code; /* actual code */
|
2021-10-15 09:48:46 -07:00
|
|
|
|
2022-10-02 09:36:41 -07:00
|
|
|
SSL_CTX *ctx;
|
2021-10-15 09:48:46 -07:00
|
|
|
|
2022-10-02 09:36:41 -07:00
|
|
|
long verify_result;
|
|
|
|
|
|
|
|
int references;
|
|
|
|
|
|
|
|
int client_version; /* what was passed, used for
|
|
|
|
* SSLv3/TLS rollback check */
|
|
|
|
|
|
|
|
unsigned int max_send_fragment;
|
|
|
|
|
2023-04-23 11:51:53 -07:00
|
|
|
const struct tls_extension **tlsext_build_order;
|
2023-04-25 00:48:15 -07:00
|
|
|
size_t tlsext_build_order_len;
|
|
|
|
|
2022-10-02 09:36:41 -07:00
|
|
|
char *tlsext_hostname;
|
|
|
|
|
|
|
|
/* certificate status request info */
|
|
|
|
/* Status type or -1 if no status type */
|
|
|
|
int tlsext_status_type;
|
|
|
|
|
|
|
|
SSL_CTX * initial_ctx; /* initial ctx, used to store sessions */
|
|
|
|
#define session_ctx initial_ctx
|
2021-10-15 09:48:46 -07:00
|
|
|
|
2019-01-20 22:58:44 -08:00
|
|
|
struct tls13_ctx *tls13;
|
|
|
|
|
2021-02-25 09:06:05 -08:00
|
|
|
uint16_t min_tls_version;
|
|
|
|
uint16_t max_tls_version;
|
2017-01-21 22:36:49 -08:00
|
|
|
|
2021-02-20 01:43:29 -08:00
|
|
|
/*
|
|
|
|
* These may be zero to imply minimum or maximum version supported by
|
|
|
|
* the method.
|
|
|
|
*/
|
|
|
|
uint16_t min_proto_version;
|
|
|
|
uint16_t max_proto_version;
|
|
|
|
|
2017-01-23 06:35:42 -08:00
|
|
|
unsigned long options; /* protocol behaviour */
|
|
|
|
unsigned long mode; /* API behaviour */
|
|
|
|
|
2017-01-21 22:36:49 -08:00
|
|
|
/* Client list of supported protocols in wire format. */
|
2022-07-20 06:43:33 -07:00
|
|
|
uint8_t *alpn_client_proto_list;
|
|
|
|
size_t alpn_client_proto_list_len;
|
2017-01-22 20:55:26 -08:00
|
|
|
|
2022-06-29 10:39:20 -07:00
|
|
|
/* QUIC transport params we will send */
|
|
|
|
uint8_t *quic_transport_params;
|
|
|
|
size_t quic_transport_params_len;
|
|
|
|
|
2017-01-22 20:55:26 -08:00
|
|
|
/* XXX Callbacks */
|
|
|
|
|
|
|
|
/* true when we are actually in SSL_accept() or SSL_connect() */
|
|
|
|
int in_handshake;
|
|
|
|
int (*handshake_func)(SSL *);
|
2021-08-30 12:25:43 -07:00
|
|
|
|
|
|
|
ssl_info_callback_fn *info_callback;
|
|
|
|
|
2017-01-22 20:55:26 -08:00
|
|
|
/* callback that allows applications to peek at protocol messages */
|
2021-08-30 12:25:43 -07:00
|
|
|
ssl_msg_callback_fn *msg_callback;
|
2017-01-22 20:55:26 -08:00
|
|
|
void *msg_callback_arg;
|
|
|
|
|
|
|
|
int (*verify_callback)(int ok,X509_STORE_CTX *ctx); /* fail if callback returns 0 */
|
|
|
|
|
2021-08-30 12:25:43 -07:00
|
|
|
/* Default generate session ID callback. */
|
|
|
|
GEN_SESSION_CB generate_session_id;
|
2017-01-22 20:55:26 -08:00
|
|
|
|
|
|
|
/* TLS extension debug callback */
|
|
|
|
void (*tlsext_debug_cb)(SSL *s, int client_server, int type,
|
|
|
|
unsigned char *data, int len, void *arg);
|
|
|
|
void *tlsext_debug_arg;
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
2017-01-22 22:45:30 -08:00
|
|
|
/* XXX non-callback */
|
|
|
|
|
|
|
|
/* This holds a variable that indicates what we were doing
|
|
|
|
* when a 0 or -1 is returned. This is needed for
|
|
|
|
* non-blocking IO so we know what request needs re-doing when
|
|
|
|
* in SSL_accept or SSL_connect */
|
|
|
|
int rwstate;
|
|
|
|
|
|
|
|
/* Imagine that here's a boolean member "init" that is
|
|
|
|
* switched as soon as SSL_set_{accept/connect}_state
|
|
|
|
* is called for the first time, so that "state" and
|
|
|
|
* "handshake_func" are properly initialized. But as
|
|
|
|
* handshake_func is == 0 until then, we use this
|
|
|
|
* test instead of an "init" member.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int new_session;/* Generate a new session or reuse an old one.
|
|
|
|
* NB: For servers, the 'new' session may actually be a previously
|
|
|
|
* cached session or even the previous session unless
|
|
|
|
* SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION is set */
|
|
|
|
int quiet_shutdown;/* don't send shutdown packets */
|
|
|
|
int shutdown; /* we have shut things down, 0x01 sent, 0x02
|
|
|
|
* for received */
|
|
|
|
BUF_MEM *init_buf; /* buffer used during init */
|
|
|
|
void *init_msg; /* pointer to handshake message body, set by ssl3_get_message() */
|
|
|
|
int init_num; /* amount read/written */
|
|
|
|
int init_off; /* amount read/written */
|
|
|
|
|
|
|
|
/* used internally to point at a raw packet */
|
|
|
|
unsigned char *packet;
|
|
|
|
unsigned int packet_length;
|
|
|
|
|
|
|
|
int read_ahead; /* Read as many input bytes as possible
|
|
|
|
* (for non-blocking reads) */
|
|
|
|
|
|
|
|
int hit; /* reusing a previous session */
|
|
|
|
|
2020-09-13 09:49:05 -07:00
|
|
|
STACK_OF(SSL_CIPHER) *cipher_list_tls13;
|
|
|
|
|
2020-08-30 08:40:19 -07:00
|
|
|
struct tls12_record_layer *rl;
|
|
|
|
|
2017-01-22 22:45:30 -08:00
|
|
|
/* session info */
|
|
|
|
|
|
|
|
/* extra application data */
|
|
|
|
CRYPTO_EX_DATA ex_data;
|
|
|
|
|
|
|
|
/* client cert? */
|
|
|
|
/* for server side, keep the list of CA_dn we can use */
|
|
|
|
STACK_OF(X509_NAME) *client_CA;
|
|
|
|
|
|
|
|
long max_cert_list;
|
|
|
|
int first_packet;
|
|
|
|
|
|
|
|
/* Expect OCSP CertificateStatus message */
|
|
|
|
int tlsext_status_expected;
|
|
|
|
/* OCSP status request only */
|
|
|
|
STACK_OF(OCSP_RESPID) *tlsext_ocsp_ids;
|
|
|
|
X509_EXTENSIONS *tlsext_ocsp_exts;
|
2020-05-10 07:17:47 -07:00
|
|
|
|
2017-01-22 22:45:30 -08:00
|
|
|
/* OCSP response received or to be sent */
|
|
|
|
unsigned char *tlsext_ocsp_resp;
|
2020-05-10 07:17:47 -07:00
|
|
|
size_t tlsext_ocsp_resp_len;
|
2017-01-22 22:45:30 -08:00
|
|
|
|
|
|
|
/* RFC4507 session ticket expected to be received or sent */
|
|
|
|
int tlsext_ticket_expected;
|
2017-01-24 01:03:21 -08:00
|
|
|
|
2017-01-22 22:45:30 -08:00
|
|
|
size_t tlsext_ecpointformatlist_length;
|
|
|
|
uint8_t *tlsext_ecpointformatlist; /* our list */
|
2017-01-24 01:03:21 -08:00
|
|
|
size_t tlsext_supportedgroups_length;
|
|
|
|
uint16_t *tlsext_supportedgroups; /* our list */
|
2017-01-22 22:45:30 -08:00
|
|
|
|
|
|
|
/* TLS Session Ticket extension override */
|
|
|
|
TLS_SESSION_TICKET_EXT *tlsext_session_ticket;
|
|
|
|
|
|
|
|
STACK_OF(SRTP_PROTECTION_PROFILE) *srtp_profiles; /* What we'll do */
|
2020-10-10 18:16:31 -07:00
|
|
|
const SRTP_PROTECTION_PROFILE *srtp_profile; /* What's been chosen */
|
2017-01-22 22:45:30 -08:00
|
|
|
|
|
|
|
int renegotiate;/* 1 if we are renegotiating.
|
2022-06-06 01:48:11 -07:00
|
|
|
* 2 if we are a server and are inside a handshake
|
2017-01-22 22:45:30 -08:00
|
|
|
* (i.e. not just sending a HelloRequest) */
|
2017-01-23 00:48:44 -08:00
|
|
|
|
|
|
|
int rstate; /* where we are when reading */
|
|
|
|
|
2017-01-25 21:31:25 -08:00
|
|
|
int mac_packet;
|
2017-01-25 23:20:57 -08:00
|
|
|
|
|
|
|
int empty_record_count;
|
2021-10-23 09:29:15 -07:00
|
|
|
|
|
|
|
size_t num_tickets; /* Unused, for OpenSSL compatibility */
|
2021-10-15 09:48:46 -07:00
|
|
|
};
|
|
|
|
|
2020-03-12 10:01:53 -07:00
|
|
|
typedef struct ssl3_record_internal_st {
|
|
|
|
int type; /* type of record */
|
|
|
|
unsigned int length; /* How many bytes available */
|
2020-03-12 10:09:02 -07:00
|
|
|
unsigned int padding_length; /* Number of padding bytes. */
|
2020-03-12 10:01:53 -07:00
|
|
|
unsigned int off; /* read/write offset into 'buf' */
|
|
|
|
unsigned char *data; /* pointer to the record data */
|
|
|
|
unsigned char *input; /* where the decode bytes are */
|
2021-06-19 10:21:39 -07:00
|
|
|
uint16_t epoch; /* epoch number, needed by DTLS1 */
|
2020-03-12 10:01:53 -07:00
|
|
|
unsigned char seq_num[8]; /* sequence number, needed by DTLS1 */
|
|
|
|
} SSL3_RECORD_INTERNAL;
|
|
|
|
|
|
|
|
typedef struct ssl3_buffer_internal_st {
|
|
|
|
unsigned char *buf; /* at least SSL3_RT_MAX_PACKET_SIZE bytes,
|
|
|
|
* see ssl3_setup_buffers() */
|
|
|
|
size_t len; /* buffer size */
|
|
|
|
int offset; /* where to 'copy from' */
|
|
|
|
int left; /* how many bytes left */
|
|
|
|
} SSL3_BUFFER_INTERNAL;
|
|
|
|
|
2022-02-05 06:54:10 -08:00
|
|
|
typedef struct ssl3_state_st {
|
|
|
|
long flags;
|
|
|
|
|
|
|
|
unsigned char server_random[SSL3_RANDOM_SIZE];
|
|
|
|
unsigned char client_random[SSL3_RANDOM_SIZE];
|
|
|
|
|
2020-03-12 10:01:53 -07:00
|
|
|
SSL3_BUFFER_INTERNAL rbuf; /* read IO goes into here */
|
|
|
|
SSL3_BUFFER_INTERNAL wbuf; /* write IO goes into here */
|
2018-10-24 11:04:50 -07:00
|
|
|
|
2022-11-11 09:15:26 -08:00
|
|
|
SSL3_RECORD_INTERNAL rrec; /* each decoded record goes in here */
|
|
|
|
|
|
|
|
struct tls_content *rcontent; /* Content from opened TLS records. */
|
|
|
|
|
2018-10-24 11:04:50 -07:00
|
|
|
/* we allow one fatal and one warning alert to be outstanding,
|
|
|
|
* send close alert via the warning alert */
|
|
|
|
int alert_dispatch;
|
|
|
|
unsigned char send_alert[2];
|
|
|
|
|
2017-01-22 01:02:07 -08:00
|
|
|
/* flags for countermeasure against known-IV weakness */
|
|
|
|
int need_empty_fragments;
|
|
|
|
int empty_fragment_done;
|
|
|
|
|
2022-11-10 10:06:37 -08:00
|
|
|
/* Unprocessed Alert/Handshake protocol data. */
|
|
|
|
struct tls_buffer *alert_fragment;
|
|
|
|
struct tls_buffer *handshake_fragment;
|
2017-01-22 01:02:07 -08:00
|
|
|
|
|
|
|
/* partial write - check the numbers match */
|
|
|
|
unsigned int wnum; /* number of bytes sent so far */
|
|
|
|
int wpend_tot; /* number bytes written */
|
|
|
|
int wpend_type;
|
|
|
|
int wpend_ret; /* number of bytes submitted */
|
|
|
|
const unsigned char *wpend_buf;
|
|
|
|
|
2018-11-08 14:28:52 -08:00
|
|
|
/* Transcript of handshake messages that have been sent and received. */
|
2022-07-22 12:54:46 -07:00
|
|
|
struct tls_buffer *handshake_transcript;
|
2017-03-05 06:39:53 -08:00
|
|
|
|
|
|
|
/* Rolling hash of handshake messages. */
|
|
|
|
EVP_MD_CTX *handshake_hash;
|
|
|
|
|
2017-01-22 01:02:07 -08:00
|
|
|
/* this is set whenerver we see a change_cipher_spec message
|
|
|
|
* come in when we are not looking for one */
|
|
|
|
int change_cipher_spec;
|
|
|
|
|
|
|
|
int warn_alert;
|
|
|
|
int fatal_alert;
|
|
|
|
|
|
|
|
/* This flag is set when we should renegotiate ASAP, basically when
|
|
|
|
* there is no more data in the read or write buffers */
|
|
|
|
int renegotiate;
|
|
|
|
int total_renegotiations;
|
|
|
|
int num_renegotiations;
|
|
|
|
|
|
|
|
int in_read_app_data;
|
|
|
|
|
2017-05-06 15:24:57 -07:00
|
|
|
SSL_HANDSHAKE hs;
|
|
|
|
|
2017-01-22 01:02:07 -08:00
|
|
|
/* Connection binding to prevent renegotiation attacks */
|
|
|
|
unsigned char previous_client_finished[EVP_MAX_MD_SIZE];
|
|
|
|
unsigned char previous_client_finished_len;
|
|
|
|
unsigned char previous_server_finished[EVP_MAX_MD_SIZE];
|
|
|
|
unsigned char previous_server_finished_len;
|
|
|
|
int send_connection_binding; /* TODOEKR */
|
|
|
|
|
2017-07-24 10:10:31 -07:00
|
|
|
/* Set if we saw a Renegotiation Indication extension from our peer. */
|
|
|
|
int renegotiate_seen;
|
|
|
|
|
2017-01-22 01:02:07 -08:00
|
|
|
/*
|
2017-08-12 14:03:08 -07:00
|
|
|
* ALPN information.
|
|
|
|
*
|
2017-01-22 01:02:07 -08:00
|
|
|
* In a server these point to the selected ALPN protocol after the
|
|
|
|
* ClientHello has been processed. In a client these contain the
|
|
|
|
* protocol that the server selected once the ServerHello has been
|
|
|
|
* processed.
|
|
|
|
*/
|
2022-07-20 06:43:33 -07:00
|
|
|
uint8_t *alpn_selected;
|
2017-08-26 13:23:46 -07:00
|
|
|
size_t alpn_selected_len;
|
2022-06-29 10:39:20 -07:00
|
|
|
|
|
|
|
/* Contains the QUIC transport params received from our peer. */
|
|
|
|
uint8_t *peer_quic_transport_params;
|
|
|
|
size_t peer_quic_transport_params_len;
|
2021-06-30 11:04:05 -07:00
|
|
|
} SSL3_STATE;
|
|
|
|
|
2014-05-29 09:00:16 -07:00
|
|
|
/*
|
|
|
|
* Flag values for enc_flags.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Uses signature algorithms extension. */
|
|
|
|
#define SSL_ENC_FLAG_SIGALGS (1 << 1)
|
|
|
|
|
|
|
|
/* Allow TLS 1.2 ciphersuites: applies to DTLS 1.2 as well as TLS 1.2. */
|
|
|
|
#define SSL_ENC_FLAG_TLS1_2_CIPHERS (1 << 4)
|
|
|
|
|
2020-01-23 02:40:59 -08:00
|
|
|
/* Allow TLS 1.3 ciphersuites only. */
|
|
|
|
#define SSL_ENC_FLAG_TLS1_3_CIPHERS (1 << 5)
|
|
|
|
|
2020-10-11 05:45:51 -07:00
|
|
|
#define TLSV1_ENC_FLAGS 0
|
|
|
|
#define TLSV1_1_ENC_FLAGS 0
|
|
|
|
#define TLSV1_2_ENC_FLAGS (SSL_ENC_FLAG_SIGALGS | \
|
|
|
|
SSL_ENC_FLAG_TLS1_2_CIPHERS)
|
|
|
|
#define TLSV1_3_ENC_FLAGS (SSL_ENC_FLAG_SIGALGS | \
|
|
|
|
SSL_ENC_FLAG_TLS1_3_CIPHERS)
|
|
|
|
|
2020-10-10 18:13:04 -07:00
|
|
|
extern const SSL_CIPHER ssl3_ciphers[];
|
1998-10-05 13:12:28 -07:00
|
|
|
|
2014-07-12 12:45:53 -07:00
|
|
|
const char *ssl_version_string(int ver);
|
2021-02-25 09:06:05 -08:00
|
|
|
int ssl_version_set_min(const SSL_METHOD *meth, uint16_t proto_ver,
|
|
|
|
uint16_t max_tls_ver, uint16_t *out_tls_ver, uint16_t *out_proto_ver);
|
|
|
|
int ssl_version_set_max(const SSL_METHOD *meth, uint16_t proto_ver,
|
|
|
|
uint16_t min_tls_ver, uint16_t *out_tls_ver, uint16_t *out_proto_ver);
|
|
|
|
int ssl_enabled_tls_version_range(SSL *s, uint16_t *min_ver, uint16_t *max_ver);
|
|
|
|
int ssl_supported_tls_version_range(SSL *s, uint16_t *min_ver, uint16_t *max_ver);
|
2021-03-10 10:27:01 -08:00
|
|
|
uint16_t ssl_tls_version(uint16_t version);
|
|
|
|
uint16_t ssl_effective_tls_version(SSL *s);
|
2021-02-22 07:59:10 -08:00
|
|
|
int ssl_max_supported_version(SSL *s, uint16_t *max_ver);
|
2021-10-23 07:40:54 -07:00
|
|
|
int ssl_max_legacy_version(SSL *s, uint16_t *max_ver);
|
2021-02-22 07:59:10 -08:00
|
|
|
int ssl_max_shared_version(SSL *s, uint16_t peer_ver, uint16_t *max_ver);
|
|
|
|
int ssl_check_version_from_server(SSL *s, uint16_t server_version);
|
2021-02-07 07:04:10 -08:00
|
|
|
int ssl_legacy_stack_version(SSL *s, uint16_t version);
|
2020-09-11 10:36:27 -07:00
|
|
|
int ssl_cipher_in_list(STACK_OF(SSL_CIPHER) *ciphers, const SSL_CIPHER *cipher);
|
2021-02-25 09:06:05 -08:00
|
|
|
int ssl_cipher_allowed_in_tls_version_range(const SSL_CIPHER *cipher,
|
2020-09-11 08:28:07 -07:00
|
|
|
uint16_t min_ver, uint16_t max_ver);
|
1998-10-05 13:12:28 -07:00
|
|
|
|
2020-07-07 12:24:23 -07:00
|
|
|
const SSL_METHOD *tls_legacy_method(void);
|
2020-10-10 19:22:27 -07:00
|
|
|
const SSL_METHOD *ssl_get_method(uint16_t version);
|
2017-01-25 21:31:25 -08:00
|
|
|
|
2018-09-05 09:48:11 -07:00
|
|
|
void ssl_clear_cipher_state(SSL *s);
|
1998-10-05 13:12:28 -07:00
|
|
|
int ssl_clear_bad_session(SSL *s);
|
2021-08-30 12:25:43 -07:00
|
|
|
|
|
|
|
void ssl_info_callback(const SSL *s, int type, int value);
|
|
|
|
void ssl_msg_callback(SSL *s, int is_write, int content_type,
|
|
|
|
const void *msg_buf, size_t msg_len);
|
2022-09-10 08:29:33 -07:00
|
|
|
void ssl_msg_callback_cbs(SSL *s, int is_write, int content_type, CBS *cbs);
|
2019-03-25 09:24:57 -07:00
|
|
|
|
2022-01-08 04:43:44 -08:00
|
|
|
SSL_CERT *ssl_cert_new(void);
|
|
|
|
SSL_CERT *ssl_cert_dup(SSL_CERT *cert);
|
|
|
|
void ssl_cert_free(SSL_CERT *c);
|
2022-06-29 14:12:19 -07:00
|
|
|
SSL_CERT *ssl_get0_cert(SSL_CTX *ctx, SSL *ssl);
|
2022-06-29 14:17:22 -07:00
|
|
|
int ssl_cert_set0_chain(SSL_CTX *ctx, SSL *ssl, STACK_OF(X509) *chain);
|
|
|
|
int ssl_cert_set1_chain(SSL_CTX *ctx, SSL *ssl, STACK_OF(X509) *chain);
|
2022-06-29 14:18:04 -07:00
|
|
|
int ssl_cert_add0_chain_cert(SSL_CTX *ctx, SSL *ssl, X509 *cert);
|
|
|
|
int ssl_cert_add1_chain_cert(SSL_CTX *ctx, SSL *ssl, X509 *cert);
|
2019-03-25 09:24:57 -07:00
|
|
|
|
2022-06-28 13:40:24 -07:00
|
|
|
int ssl_security_default_cb(const SSL *ssl, const SSL_CTX *ctx, int op,
|
|
|
|
int bits, int nid, void *other, void *ex_data);
|
|
|
|
|
2022-07-02 09:31:04 -07:00
|
|
|
int ssl_security_cipher_check(const SSL *ssl, SSL_CIPHER *cipher);
|
|
|
|
int ssl_security_shared_cipher(const SSL *ssl, SSL_CIPHER *cipher);
|
|
|
|
int ssl_security_supported_cipher(const SSL *ssl, SSL_CIPHER *cipher);
|
2022-06-29 01:30:04 -07:00
|
|
|
int ssl_ctx_security_dh(const SSL_CTX *ctx, DH *dh);
|
2022-06-29 01:27:51 -07:00
|
|
|
int ssl_security_dh(const SSL *ssl, DH *dh);
|
2022-07-02 09:31:04 -07:00
|
|
|
int ssl_security_sigalg_check(const SSL *ssl, const EVP_PKEY *pkey);
|
|
|
|
int ssl_security_tickets(const SSL *ssl);
|
2022-06-30 04:17:49 -07:00
|
|
|
int ssl_security_version(const SSL *ssl, int version);
|
2022-06-29 14:10:20 -07:00
|
|
|
int ssl_security_cert(const SSL_CTX *ctx, const SSL *ssl, X509 *x509,
|
|
|
|
int is_peer, int *out_error);
|
|
|
|
int ssl_security_cert_chain(const SSL *ssl, STACK_OF(X509) *sk,
|
|
|
|
X509 *x509, int *out_error);
|
2022-08-17 11:41:17 -07:00
|
|
|
int ssl_security_shared_group(const SSL *ssl, uint16_t group_id);
|
2022-07-02 09:00:12 -07:00
|
|
|
int ssl_security_supported_group(const SSL *ssl, uint16_t group_id);
|
2022-06-28 14:14:32 -07:00
|
|
|
|
2022-10-20 08:22:51 -07:00
|
|
|
SSL_SESSION *ssl_session_dup(SSL_SESSION *src, int include_ticket);
|
1998-10-05 13:12:28 -07:00
|
|
|
int ssl_get_new_session(SSL *s, int session);
|
2020-08-31 07:04:51 -07:00
|
|
|
int ssl_get_prev_session(SSL *s, CBS *session_id, CBS *ext_block,
|
|
|
|
int *alert);
|
2017-10-11 10:35:00 -07:00
|
|
|
int ssl_cipher_list_to_bytes(SSL *s, STACK_OF(SSL_CIPHER) *ciphers, CBB *cbb);
|
2017-10-10 09:51:38 -07:00
|
|
|
STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s, CBS *cbs);
|
2000-03-19 03:07:35 -08:00
|
|
|
STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *meth,
|
2020-09-13 09:49:05 -07:00
|
|
|
STACK_OF(SSL_CIPHER) **pref, STACK_OF(SSL_CIPHER) *tls13,
|
2022-06-29 13:04:28 -07:00
|
|
|
const char *rule_str, SSL_CERT *cert);
|
2020-09-13 09:49:05 -07:00
|
|
|
int ssl_parse_ciphersuites(STACK_OF(SSL_CIPHER) **out_ciphers, const char *str);
|
|
|
|
int ssl_merge_cipherlists(STACK_OF(SSL_CIPHER) *cipherlist,
|
|
|
|
STACK_OF(SSL_CIPHER) *cipherlist_tls13,
|
|
|
|
STACK_OF(SSL_CIPHER) **out_cipherlist);
|
1998-10-05 13:12:28 -07:00
|
|
|
void ssl_update_cache(SSL *s, int mode);
|
2024-07-19 21:04:23 -07:00
|
|
|
int ssl_cipher_get_evp(SSL *s, const EVP_CIPHER **enc,
|
2014-05-25 06:27:38 -07:00
|
|
|
const EVP_MD **md, int *mac_pkey_type, int *mac_secret_size);
|
2024-07-19 21:04:23 -07:00
|
|
|
int ssl_cipher_get_evp_aead(SSL *s, const EVP_AEAD **aead);
|
2017-03-05 06:39:53 -08:00
|
|
|
int ssl_get_handshake_evp_md(SSL *s, const EVP_MD **md);
|
2014-04-15 05:00:25 -07:00
|
|
|
|
|
|
|
int ssl_verify_cert_chain(SSL *s, STACK_OF(X509) *sk);
|
1998-10-05 13:12:28 -07:00
|
|
|
int ssl_undefined_function(SSL *s);
|
2008-09-06 05:17:47 -07:00
|
|
|
int ssl_undefined_void_function(void);
|
2005-04-28 22:39:09 -07:00
|
|
|
int ssl_undefined_const_function(const SSL *s);
|
2022-01-08 04:43:44 -08:00
|
|
|
SSL_CERT_PKEY *ssl_get_server_send_pkey(const SSL *s);
|
2018-11-09 17:19:09 -08:00
|
|
|
EVP_PKEY *ssl_get_sign_pkey(SSL *s, const SSL_CIPHER *c, const EVP_MD **pmd,
|
|
|
|
const struct ssl_sigalg **sap);
|
2021-12-04 06:03:22 -08:00
|
|
|
size_t ssl_dhe_params_auto_key_bits(SSL *s);
|
2022-02-03 08:33:12 -08:00
|
|
|
int ssl_cert_type(EVP_PKEY *pkey);
|
2022-01-08 04:43:44 -08:00
|
|
|
void ssl_set_cert_masks(SSL_CERT *c, const SSL_CIPHER *cipher);
|
1999-09-28 21:35:07 -07:00
|
|
|
STACK_OF(SSL_CIPHER) *ssl_get_ciphers_by_id(SSL *s);
|
2017-08-09 15:24:25 -07:00
|
|
|
int ssl_has_ecc_ciphers(SSL *s);
|
1998-10-05 13:12:28 -07:00
|
|
|
int ssl_verify_alarm_type(long type);
|
|
|
|
|
2018-08-27 09:42:48 -07:00
|
|
|
int SSL_SESSION_ticket(SSL_SESSION *ss, unsigned char **out, size_t *out_len);
|
|
|
|
|
2014-04-15 05:00:25 -07:00
|
|
|
int ssl3_do_write(SSL *s, int type);
|
|
|
|
int ssl3_send_alert(SSL *s, int level, int desc);
|
2017-08-11 10:54:41 -07:00
|
|
|
int ssl3_get_req_cert_types(SSL *s, CBB *cbb);
|
2021-10-23 01:34:36 -07:00
|
|
|
int ssl3_get_message(SSL *s, int st1, int stn, int mt, long max);
|
1998-10-05 13:12:28 -07:00
|
|
|
int ssl3_num_ciphers(void);
|
2024-07-23 07:40:53 -07:00
|
|
|
const SSL_CIPHER *ssl3_get_cipher_by_index(int idx);
|
2015-02-06 20:17:11 -08:00
|
|
|
const SSL_CIPHER *ssl3_get_cipher_by_value(uint16_t value);
|
2014-04-15 05:00:25 -07:00
|
|
|
int ssl3_renegotiate(SSL *ssl);
|
|
|
|
|
|
|
|
int ssl3_renegotiate_check(SSL *ssl);
|
|
|
|
|
2021-10-25 03:09:28 -07:00
|
|
|
void ssl_force_want_read(SSL *s);
|
|
|
|
|
1998-10-05 13:12:28 -07:00
|
|
|
int ssl3_dispatch_alert(SSL *s);
|
2022-02-21 10:22:20 -08:00
|
|
|
int ssl3_read_alert(SSL *s);
|
2022-03-12 04:53:03 -08:00
|
|
|
int ssl3_read_change_cipher_spec(SSL *s);
|
2001-06-21 17:02:45 -07:00
|
|
|
int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek);
|
1999-09-28 21:35:07 -07:00
|
|
|
int ssl3_write_bytes(SSL *s, int type, const void *buf, int len);
|
2022-01-08 04:43:44 -08:00
|
|
|
int ssl3_output_cert_chain(SSL *s, CBB *cbb, SSL_CERT_PKEY *cpk);
|
2014-04-15 05:00:25 -07:00
|
|
|
SSL_CIPHER *ssl3_choose_cipher(SSL *ssl, STACK_OF(SSL_CIPHER) *clnt,
|
|
|
|
STACK_OF(SSL_CIPHER) *srvr);
|
1998-10-05 13:12:28 -07:00
|
|
|
int ssl3_setup_buffers(SSL *s);
|
2015-03-27 05:29:54 -07:00
|
|
|
int ssl3_setup_init_buffer(SSL *s);
|
2020-09-24 11:12:00 -07:00
|
|
|
void ssl3_release_init_buffer(SSL *s);
|
2010-10-01 15:58:41 -07:00
|
|
|
int ssl3_setup_read_buffer(SSL *s);
|
|
|
|
int ssl3_setup_write_buffer(SSL *s);
|
2020-09-24 10:59:54 -07:00
|
|
|
void ssl3_release_buffer(SSL3_BUFFER_INTERNAL *b);
|
|
|
|
void ssl3_release_read_buffer(SSL *s);
|
|
|
|
void ssl3_release_write_buffer(SSL *s);
|
1998-10-05 13:12:28 -07:00
|
|
|
int ssl3_new(SSL *s);
|
|
|
|
void ssl3_free(SSL *s);
|
|
|
|
int ssl3_accept(SSL *s);
|
|
|
|
int ssl3_connect(SSL *s);
|
1999-09-28 21:35:07 -07:00
|
|
|
int ssl3_read(SSL *s, void *buf, int len);
|
2001-06-21 17:02:45 -07:00
|
|
|
int ssl3_peek(SSL *s, void *buf, int len);
|
1999-09-28 21:35:07 -07:00
|
|
|
int ssl3_write(SSL *s, const void *buf, int len);
|
1998-10-05 13:12:28 -07:00
|
|
|
int ssl3_shutdown(SSL *s);
|
|
|
|
void ssl3_clear(SSL *s);
|
2014-04-15 05:00:25 -07:00
|
|
|
long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg);
|
|
|
|
long ssl3_ctx_ctrl(SSL_CTX *s, int cmd, long larg, void *parg);
|
|
|
|
long ssl3_callback_ctrl(SSL *s, int cmd, void (*fp)(void));
|
|
|
|
long ssl3_ctx_callback_ctrl(SSL_CTX *s, int cmd, void (*fp)(void));
|
2005-04-28 22:39:09 -07:00
|
|
|
int ssl3_pending(const SSL *s);
|
1998-10-05 13:12:28 -07:00
|
|
|
|
2015-09-12 08:03:39 -07:00
|
|
|
int ssl3_handshake_msg_hdr_len(SSL *s);
|
2018-08-24 10:30:32 -07:00
|
|
|
int ssl3_handshake_msg_start(SSL *s, CBB *handshake, CBB *body,
|
2016-12-06 05:17:52 -08:00
|
|
|
uint8_t msg_type);
|
2018-08-24 10:30:32 -07:00
|
|
|
int ssl3_handshake_msg_finish(SSL *s, CBB *handshake);
|
2014-12-14 08:19:38 -08:00
|
|
|
int ssl3_handshake_write(SSL *s);
|
2017-10-08 09:24:02 -07:00
|
|
|
int ssl3_record_write(SSL *s, int type);
|
2014-12-14 08:19:38 -08:00
|
|
|
|
2008-09-06 05:17:47 -07:00
|
|
|
int ssl3_do_change_cipher_spec(SSL *ssl);
|
|
|
|
|
2017-01-24 22:13:02 -08:00
|
|
|
int ssl3_packet_read(SSL *s, int plen);
|
|
|
|
int ssl3_packet_extend(SSL *s, int plen);
|
2017-01-25 21:31:25 -08:00
|
|
|
int ssl_server_legacy_first_packet(SSL *s);
|
2008-09-06 05:17:47 -07:00
|
|
|
int ssl3_write_pending(SSL *s, int type, const unsigned char *buf,
|
2014-04-15 05:00:25 -07:00
|
|
|
unsigned int len);
|
2008-09-06 05:17:47 -07:00
|
|
|
|
2021-11-29 08:00:32 -08:00
|
|
|
int ssl_kex_generate_dhe(DH *dh, DH *dh_params);
|
2021-12-04 06:03:22 -08:00
|
|
|
int ssl_kex_generate_dhe_params_auto(DH *dh, size_t key_len);
|
2021-11-29 08:00:32 -08:00
|
|
|
int ssl_kex_params_dhe(DH *dh, CBB *cbb);
|
|
|
|
int ssl_kex_public_dhe(DH *dh, CBB *cbb);
|
2022-01-11 10:28:41 -08:00
|
|
|
int ssl_kex_peer_params_dhe(DH *dh, CBS *cbs, int *decode_error,
|
|
|
|
int *invalid_params);
|
|
|
|
int ssl_kex_peer_public_dhe(DH *dh, CBS *cbs, int *decode_error,
|
|
|
|
int *invalid_key);
|
2021-11-29 08:00:32 -08:00
|
|
|
int ssl_kex_derive_dhe(DH *dh, DH *dh_peer,
|
|
|
|
uint8_t **shared_key, size_t *shared_key_len);
|
|
|
|
|
2020-04-18 07:07:56 -07:00
|
|
|
int ssl_kex_dummy_ecdhe_x25519(EVP_PKEY *pkey);
|
2020-01-30 08:25:09 -08:00
|
|
|
int ssl_kex_generate_ecdhe_ecp(EC_KEY *ecdh, int nid);
|
|
|
|
int ssl_kex_public_ecdhe_ecp(EC_KEY *ecdh, CBB *cbb);
|
|
|
|
int ssl_kex_peer_public_ecdhe_ecp(EC_KEY *ecdh, int nid, CBS *cbs);
|
|
|
|
int ssl_kex_derive_ecdhe_ecp(EC_KEY *ecdh, EC_KEY *ecdh_peer,
|
|
|
|
uint8_t **shared_key, size_t *shared_key_len);
|
|
|
|
|
1998-10-05 13:12:28 -07:00
|
|
|
int tls1_new(SSL *s);
|
|
|
|
void tls1_free(SSL *s);
|
|
|
|
void tls1_clear(SSL *s);
|
|
|
|
|
|
|
|
int ssl_init_wbio_buffer(SSL *s, int push);
|
1999-09-28 21:35:07 -07:00
|
|
|
void ssl_free_wbio_buffer(SSL *s);
|
1998-10-05 13:12:28 -07:00
|
|
|
|
2019-02-09 07:26:15 -08:00
|
|
|
int tls1_transcript_hash_init(SSL *s);
|
|
|
|
int tls1_transcript_hash_update(SSL *s, const unsigned char *buf, size_t len);
|
2022-03-17 10:22:16 -07:00
|
|
|
int tls1_transcript_hash_value(SSL *s, unsigned char *out, size_t len,
|
2017-03-05 06:39:53 -08:00
|
|
|
size_t *outlen);
|
2019-02-09 07:26:15 -08:00
|
|
|
void tls1_transcript_hash_free(SSL *s);
|
2017-03-05 06:39:53 -08:00
|
|
|
|
2018-11-08 14:28:52 -08:00
|
|
|
int tls1_transcript_init(SSL *s);
|
|
|
|
void tls1_transcript_free(SSL *s);
|
2018-11-21 07:13:29 -08:00
|
|
|
void tls1_transcript_reset(SSL *s);
|
2018-11-08 14:28:52 -08:00
|
|
|
int tls1_transcript_append(SSL *s, const unsigned char *buf, size_t len);
|
|
|
|
int tls1_transcript_data(SSL *s, const unsigned char **data, size_t *len);
|
|
|
|
void tls1_transcript_freeze(SSL *s);
|
2020-02-05 08:47:34 -08:00
|
|
|
void tls1_transcript_unfreeze(SSL *s);
|
2018-11-08 14:28:52 -08:00
|
|
|
int tls1_transcript_record(SSL *s, const unsigned char *buf, size_t len);
|
|
|
|
|
2021-04-25 06:15:22 -07:00
|
|
|
int tls1_PRF(SSL *s, const unsigned char *secret, size_t secret_len,
|
|
|
|
const void *seed1, size_t seed1_len, const void *seed2, size_t seed2_len,
|
|
|
|
const void *seed3, size_t seed3_len, const void *seed4, size_t seed4_len,
|
|
|
|
const void *seed5, size_t seed5_len, unsigned char *out, size_t out_len);
|
|
|
|
|
2015-09-11 11:08:21 -07:00
|
|
|
void tls1_cleanup_key_block(SSL *s);
|
2021-05-02 10:46:58 -07:00
|
|
|
int tls1_change_read_cipher_state(SSL *s);
|
|
|
|
int tls1_change_write_cipher_state(SSL *s);
|
1998-10-05 13:12:28 -07:00
|
|
|
int tls1_setup_key_block(SSL *s);
|
2021-05-05 03:05:27 -07:00
|
|
|
int tls1_generate_key_block(SSL *s, uint8_t *key_block, size_t key_block_len);
|
1999-09-28 21:35:07 -07:00
|
|
|
int ssl_ok(SSL *s);
|
1998-10-05 13:12:28 -07:00
|
|
|
|
2021-04-25 06:15:22 -07:00
|
|
|
int tls12_derive_finished(SSL *s);
|
|
|
|
int tls12_derive_peer_finished(SSL *s);
|
2021-04-30 12:26:44 -07:00
|
|
|
int tls12_derive_master_secret(SSL *s, uint8_t *premaster_secret,
|
|
|
|
size_t premaster_secret_len);
|
2021-04-25 06:15:22 -07:00
|
|
|
|
2017-08-09 15:24:25 -07:00
|
|
|
int ssl_using_ecc_cipher(SSL *s);
|
2022-01-09 07:53:52 -08:00
|
|
|
int ssl_check_srvr_ecc_cert_and_alg(SSL *s, X509 *x);
|
2008-09-06 05:17:47 -07:00
|
|
|
|
2022-08-17 11:42:13 -07:00
|
|
|
void tls1_get_formatlist(const SSL *s, int client_formats,
|
|
|
|
const uint8_t **pformats, size_t *pformatslen);
|
|
|
|
void tls1_get_group_list(const SSL *s, int client_groups,
|
|
|
|
const uint16_t **pgroups, size_t *pgroupslen);
|
2018-11-05 12:41:30 -08:00
|
|
|
|
2017-01-24 01:03:21 -08:00
|
|
|
int tls1_set_groups(uint16_t **out_group_ids, size_t *out_group_ids_len,
|
|
|
|
const int *groups, size_t ngroups);
|
2018-11-05 12:41:30 -08:00
|
|
|
int tls1_set_group_list(uint16_t **out_group_ids, size_t *out_group_ids_len,
|
2017-01-24 01:03:21 -08:00
|
|
|
const char *groups);
|
|
|
|
|
2022-07-02 09:00:12 -07:00
|
|
|
int tls1_ec_group_id2nid(uint16_t group_id, int *out_nid);
|
|
|
|
int tls1_ec_group_id2bits(uint16_t group_id, int *out_bits);
|
|
|
|
int tls1_ec_nid2group_id(int nid, uint16_t *out_group_id);
|
|
|
|
int tls1_check_group(SSL *s, uint16_t group_id);
|
2022-08-17 11:45:25 -07:00
|
|
|
int tls1_count_shared_groups(const SSL *ssl, size_t *out_count);
|
2022-08-18 00:00:59 -07:00
|
|
|
int tls1_get_shared_group_by_index(const SSL *ssl, size_t index, int *out_nid);
|
2022-08-17 11:45:25 -07:00
|
|
|
int tls1_get_supported_group(const SSL *s, int *out_nid);
|
2010-10-01 15:58:41 -07:00
|
|
|
|
2014-04-13 08:25:20 -07:00
|
|
|
int ssl_check_clienthello_tlsext_early(SSL *s);
|
|
|
|
int ssl_check_clienthello_tlsext_late(SSL *s);
|
2008-09-06 05:17:47 -07:00
|
|
|
int ssl_check_serverhello_tlsext(SSL *s);
|
2010-10-01 15:58:41 -07:00
|
|
|
|
2020-08-31 07:34:01 -07:00
|
|
|
#define TLS1_TICKET_FATAL_ERROR -1
|
|
|
|
#define TLS1_TICKET_NONE 0
|
|
|
|
#define TLS1_TICKET_EMPTY 1
|
|
|
|
#define TLS1_TICKET_NOT_DECRYPTED 2
|
|
|
|
#define TLS1_TICKET_DECRYPTED 3
|
|
|
|
|
2020-09-01 05:40:53 -07:00
|
|
|
int tls1_process_ticket(SSL *s, CBS *ext_block, int *alert, SSL_SESSION **ret);
|
2012-10-13 14:25:05 -07:00
|
|
|
|
2014-09-30 08:40:09 -07:00
|
|
|
int tls1_check_ec_server_key(SSL *s);
|
|
|
|
|
2013-02-14 07:11:43 -08:00
|
|
|
/* s3_cbc.c */
|
2020-03-12 10:01:53 -07:00
|
|
|
void ssl3_cbc_copy_mac(unsigned char *out, const SSL3_RECORD_INTERNAL *rec,
|
2020-03-16 08:25:13 -07:00
|
|
|
unsigned int md_size, unsigned int orig_len);
|
2020-10-03 10:35:16 -07:00
|
|
|
int ssl3_cbc_remove_padding(SSL3_RECORD_INTERNAL *rec, unsigned int eiv_len,
|
|
|
|
unsigned int mac_size);
|
2013-02-14 07:11:43 -08:00
|
|
|
char ssl3_cbc_record_digest_supported(const EVP_MD_CTX *ctx);
|
2014-12-14 16:46:53 -08:00
|
|
|
int ssl3_cbc_digest_record(const EVP_MD_CTX *ctx, unsigned char *md_out,
|
2014-04-15 05:00:25 -07:00
|
|
|
size_t *md_out_size, const unsigned char header[13],
|
|
|
|
const unsigned char *data, size_t data_plus_mac_size,
|
|
|
|
size_t data_plus_mac_plus_padding_size, const unsigned char *mac_secret,
|
2020-03-16 08:25:13 -07:00
|
|
|
unsigned int mac_secret_length);
|
2017-02-06 18:08:38 -08:00
|
|
|
int SSL_state_func_code(int _state);
|
2014-04-15 05:00:25 -07:00
|
|
|
|
2017-05-06 21:22:24 -07:00
|
|
|
#define SSLerror(s, r) SSL_error_internal(s, r, __FILE__, __LINE__)
|
2017-02-06 18:08:38 -08:00
|
|
|
#define SSLerrorx(r) ERR_PUT_error(ERR_LIB_SSL,(0xfff),(r),__FILE__,__LINE__)
|
2017-05-06 21:22:24 -07:00
|
|
|
void SSL_error_internal(const SSL *s, int r, char *f, int l);
|
2017-01-26 02:40:21 -08:00
|
|
|
|
2017-08-26 19:58:04 -07:00
|
|
|
#ifndef OPENSSL_NO_SRTP
|
|
|
|
|
2020-10-10 19:44:27 -07:00
|
|
|
int srtp_find_profile_by_name(const char *profile_name,
|
2020-10-10 18:16:31 -07:00
|
|
|
const SRTP_PROTECTION_PROFILE **pptr, unsigned int len);
|
2020-03-16 08:25:13 -07:00
|
|
|
int srtp_find_profile_by_num(unsigned int profile_num,
|
2020-10-10 18:16:31 -07:00
|
|
|
const SRTP_PROTECTION_PROFILE **pptr);
|
2017-08-26 19:58:04 -07:00
|
|
|
|
|
|
|
#endif /* OPENSSL_NO_SRTP */
|
|
|
|
|
2022-08-17 00:39:19 -07:00
|
|
|
int tls_process_peer_certs(SSL *s, STACK_OF(X509) *peer_certs);
|
|
|
|
|
2016-11-04 11:28:57 -07:00
|
|
|
__END_HIDDEN_DECLS
|
|
|
|
|
2022-11-26 09:23:17 -08:00
|
|
|
#endif /* !HEADER_SSL_LOCL_H */
|