mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-12-04 17:11:31 +08:00
2568 lines
123 KiB
C++
2568 lines
123 KiB
C++
|
/*
|
||
|
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||
|
*
|
||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||
|
* this file except in compliance with the License. You can obtain a copy
|
||
|
* in the file LICENSE in the source distribution or at
|
||
|
* https://www.openssl.org/source/license.html
|
||
|
*/
|
||
|
|
||
|
/* ====================================================================
|
||
|
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
|
||
|
* ECC cipher suite support in OpenSSL originally developed by
|
||
|
* SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
|
||
|
*/
|
||
|
/* ====================================================================
|
||
|
* 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.
|
||
|
*/
|
||
|
|
||
|
#ifndef HEADER_SSL_H
|
||
|
# define HEADER_SSL_H
|
||
|
|
||
|
# include <openssl/e_os2.h>
|
||
|
# include <openssl/opensslconf.h>
|
||
|
# include <openssl/comp.h>
|
||
|
# include <openssl/bio.h>
|
||
|
# if OPENSSL_API_COMPAT < 0x10100000L
|
||
|
# include <openssl/x509.h>
|
||
|
# include <openssl/crypto.h>
|
||
|
# include <openssl/lhash.h>
|
||
|
# include <openssl/buffer.h>
|
||
|
# endif
|
||
|
# include <openssl/pem.h>
|
||
|
# include <openssl/hmac.h>
|
||
|
# include <openssl/async.h>
|
||
|
|
||
|
# include <openssl/safestack.h>
|
||
|
# include <openssl/symhacks.h>
|
||
|
# include <openssl/ct.h>
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
extern "C" {
|
||
|
#endif
|
||
|
|
||
|
/* OpenSSL version number for ASN.1 encoding of the session information */
|
||
|
/*-
|
||
|
* Version 0 - initial version
|
||
|
* Version 1 - added the optional peer certificate
|
||
|
*/
|
||
|
# define SSL_SESSION_ASN1_VERSION 0x0001
|
||
|
|
||
|
# define SSL_MAX_SSL_SESSION_ID_LENGTH 32
|
||
|
# define SSL_MAX_SID_CTX_LENGTH 32
|
||
|
|
||
|
# define SSL_MIN_RSA_MODULUS_LENGTH_IN_BYTES (512/8)
|
||
|
# define SSL_MAX_KEY_ARG_LENGTH 8
|
||
|
# define SSL_MAX_MASTER_KEY_LENGTH 48
|
||
|
|
||
|
/* The maximum number of encrypt/decrypt pipelines we can support */
|
||
|
# define SSL_MAX_PIPELINES 32
|
||
|
|
||
|
/* text strings for the ciphers */
|
||
|
|
||
|
/* These are used to specify which ciphers to use and not to use */
|
||
|
|
||
|
# define SSL_TXT_LOW "LOW"
|
||
|
# define SSL_TXT_MEDIUM "MEDIUM"
|
||
|
# define SSL_TXT_HIGH "HIGH"
|
||
|
# define SSL_TXT_FIPS "FIPS"
|
||
|
|
||
|
# define SSL_TXT_aNULL "aNULL"
|
||
|
# define SSL_TXT_eNULL "eNULL"
|
||
|
# define SSL_TXT_NULL "NULL"
|
||
|
|
||
|
# define SSL_TXT_kRSA "kRSA"
|
||
|
# define SSL_TXT_kDHr "kDHr"/* this cipher class has been removed */
|
||
|
# define SSL_TXT_kDHd "kDHd"/* this cipher class has been removed */
|
||
|
# define SSL_TXT_kDH "kDH"/* this cipher class has been removed */
|
||
|
# define SSL_TXT_kEDH "kEDH"/* alias for kDHE */
|
||
|
# define SSL_TXT_kDHE "kDHE"
|
||
|
# define SSL_TXT_kECDHr "kECDHr"/* this cipher class has been removed */
|
||
|
# define SSL_TXT_kECDHe "kECDHe"/* this cipher class has been removed */
|
||
|
# define SSL_TXT_kECDH "kECDH"/* this cipher class has been removed */
|
||
|
# define SSL_TXT_kEECDH "kEECDH"/* alias for kECDHE */
|
||
|
# define SSL_TXT_kECDHE "kECDHE"
|
||
|
# define SSL_TXT_kPSK "kPSK"
|
||
|
# define SSL_TXT_kRSAPSK "kRSAPSK"
|
||
|
# define SSL_TXT_kECDHEPSK "kECDHEPSK"
|
||
|
# define SSL_TXT_kDHEPSK "kDHEPSK"
|
||
|
# define SSL_TXT_kGOST "kGOST"
|
||
|
# define SSL_TXT_kSRP "kSRP"
|
||
|
|
||
|
# define SSL_TXT_aRSA "aRSA"
|
||
|
# define SSL_TXT_aDSS "aDSS"
|
||
|
# define SSL_TXT_aDH "aDH"/* this cipher class has been removed */
|
||
|
# define SSL_TXT_aECDH "aECDH"/* this cipher class has been removed */
|
||
|
# define SSL_TXT_aECDSA "aECDSA"
|
||
|
# define SSL_TXT_aPSK "aPSK"
|
||
|
# define SSL_TXT_aGOST94 "aGOST94"
|
||
|
# define SSL_TXT_aGOST01 "aGOST01"
|
||
|
# define SSL_TXT_aGOST12 "aGOST12"
|
||
|
# define SSL_TXT_aGOST "aGOST"
|
||
|
# define SSL_TXT_aSRP "aSRP"
|
||
|
|
||
|
# define SSL_TXT_DSS "DSS"
|
||
|
# define SSL_TXT_DH "DH"
|
||
|
# define SSL_TXT_DHE "DHE"/* same as "kDHE:-ADH" */
|
||
|
# define SSL_TXT_EDH "EDH"/* alias for DHE */
|
||
|
# define SSL_TXT_ADH "ADH"
|
||
|
# define SSL_TXT_RSA "RSA"
|
||
|
# define SSL_TXT_ECDH "ECDH"
|
||
|
# define SSL_TXT_EECDH "EECDH"/* alias for ECDHE" */
|
||
|
# define SSL_TXT_ECDHE "ECDHE"/* same as "kECDHE:-AECDH" */
|
||
|
# define SSL_TXT_AECDH "AECDH"
|
||
|
# define SSL_TXT_ECDSA "ECDSA"
|
||
|
# define SSL_TXT_PSK "PSK"
|
||
|
# define SSL_TXT_SRP "SRP"
|
||
|
|
||
|
# define SSL_TXT_DES "DES"
|
||
|
# define SSL_TXT_3DES "3DES"
|
||
|
# define SSL_TXT_RC4 "RC4"
|
||
|
# define SSL_TXT_RC2 "RC2"
|
||
|
# define SSL_TXT_IDEA "IDEA"
|
||
|
# define SSL_TXT_SEED "SEED"
|
||
|
# define SSL_TXT_AES128 "AES128"
|
||
|
# define SSL_TXT_AES256 "AES256"
|
||
|
# define SSL_TXT_AES "AES"
|
||
|
# define SSL_TXT_AES_GCM "AESGCM"
|
||
|
# define SSL_TXT_AES_CCM "AESCCM"
|
||
|
# define SSL_TXT_AES_CCM_8 "AESCCM8"
|
||
|
# define SSL_TXT_CAMELLIA128 "CAMELLIA128"
|
||
|
# define SSL_TXT_CAMELLIA256 "CAMELLIA256"
|
||
|
# define SSL_TXT_CAMELLIA "CAMELLIA"
|
||
|
# define SSL_TXT_CHACHA20 "CHACHA20"
|
||
|
# define SSL_TXT_GOST "GOST89"
|
||
|
|
||
|
# define SSL_TXT_MD5 "MD5"
|
||
|
# define SSL_TXT_SHA1 "SHA1"
|
||
|
# define SSL_TXT_SHA "SHA"/* same as "SHA1" */
|
||
|
# define SSL_TXT_GOST94 "GOST94"
|
||
|
# define SSL_TXT_GOST89MAC "GOST89MAC"
|
||
|
# define SSL_TXT_GOST12 "GOST12"
|
||
|
# define SSL_TXT_GOST89MAC12 "GOST89MAC12"
|
||
|
# define SSL_TXT_SHA256 "SHA256"
|
||
|
# define SSL_TXT_SHA384 "SHA384"
|
||
|
|
||
|
# define SSL_TXT_SSLV3 "SSLv3"
|
||
|
# define SSL_TXT_TLSV1 "TLSv1"
|
||
|
# define SSL_TXT_TLSV1_1 "TLSv1.1"
|
||
|
# define SSL_TXT_TLSV1_2 "TLSv1.2"
|
||
|
|
||
|
# define SSL_TXT_ALL "ALL"
|
||
|
|
||
|
/*-
|
||
|
* COMPLEMENTOF* definitions. These identifiers are used to (de-select)
|
||
|
* ciphers normally not being used.
|
||
|
* Example: "RC4" will activate all ciphers using RC4 including ciphers
|
||
|
* without authentication, which would normally disabled by DEFAULT (due
|
||
|
* the "!ADH" being part of default). Therefore "RC4:!COMPLEMENTOFDEFAULT"
|
||
|
* will make sure that it is also disabled in the specific selection.
|
||
|
* COMPLEMENTOF* identifiers are portable between version, as adjustments
|
||
|
* to the default cipher setup will also be included here.
|
||
|
*
|
||
|
* COMPLEMENTOFDEFAULT does not experience the same special treatment that
|
||
|
* DEFAULT gets, as only selection is being done and no sorting as needed
|
||
|
* for DEFAULT.
|
||
|
*/
|
||
|
# define SSL_TXT_CMPALL "COMPLEMENTOFALL"
|
||
|
# define SSL_TXT_CMPDEF "COMPLEMENTOFDEFAULT"
|
||
|
|
||
|
/*
|
||
|
* The following cipher list is used by default. It also is substituted when
|
||
|
* an application-defined cipher list string starts with 'DEFAULT'.
|
||
|
*/
|
||
|
# define SSL_DEFAULT_CIPHER_LIST "ALL:!COMPLEMENTOFDEFAULT:!eNULL"
|
||
|
/*
|
||
|
* As of OpenSSL 1.0.0, ssl_create_cipher_list() in ssl/ssl_ciph.c always
|
||
|
* starts with a reasonable order, and all we have to do for DEFAULT is
|
||
|
* throwing out anonymous and unencrypted ciphersuites! (The latter are not
|
||
|
* actually enabled by ALL, but "ALL:RSA" would enable some of them.)
|
||
|
*/
|
||
|
|
||
|
/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */
|
||
|
# define SSL_SENT_SHUTDOWN 1
|
||
|
# define SSL_RECEIVED_SHUTDOWN 2
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
extern "C" {
|
||
|
#endif
|
||
|
|
||
|
# define SSL_FILETYPE_ASN1 X509_FILETYPE_ASN1
|
||
|
# define SSL_FILETYPE_PEM X509_FILETYPE_PEM
|
||
|
|
||
|
/*
|
||
|
* This is needed to stop compilers complaining about the 'struct ssl_st *'
|
||
|
* function parameters used to prototype callbacks in SSL_CTX.
|
||
|
*/
|
||
|
typedef struct ssl_st *ssl_crock_st;
|
||
|
typedef struct tls_session_ticket_ext_st TLS_SESSION_TICKET_EXT;
|
||
|
typedef struct ssl_method_st SSL_METHOD;
|
||
|
typedef struct ssl_cipher_st SSL_CIPHER;
|
||
|
typedef struct ssl_session_st SSL_SESSION;
|
||
|
typedef struct tls_sigalgs_st TLS_SIGALGS;
|
||
|
typedef struct ssl_conf_ctx_st SSL_CONF_CTX;
|
||
|
typedef struct ssl_comp_st SSL_COMP;
|
||
|
|
||
|
STACK_OF(SSL_CIPHER);
|
||
|
STACK_OF(SSL_COMP);
|
||
|
|
||
|
/* SRTP protection profiles for use with the use_srtp extension (RFC 5764)*/
|
||
|
typedef struct srtp_protection_profile_st {
|
||
|
const char *name;
|
||
|
unsigned long id;
|
||
|
} SRTP_PROTECTION_PROFILE;
|
||
|
|
||
|
DEFINE_STACK_OF(SRTP_PROTECTION_PROFILE)
|
||
|
|
||
|
typedef int (*tls_session_ticket_ext_cb_fn) (SSL *s,
|
||
|
const unsigned char *data,
|
||
|
int len, void *arg);
|
||
|
typedef int (*tls_session_secret_cb_fn) (SSL *s, void *secret,
|
||
|
int *secret_len,
|
||
|
STACK_OF(SSL_CIPHER) *peer_ciphers,
|
||
|
const SSL_CIPHER **cipher, void *arg);
|
||
|
|
||
|
/* Typedefs for handling custom extensions */
|
||
|
|
||
|
typedef int (*custom_ext_add_cb) (SSL *s, unsigned int ext_type,
|
||
|
const unsigned char **out,
|
||
|
size_t *outlen, int *al, void *add_arg);
|
||
|
|
||
|
typedef void (*custom_ext_free_cb) (SSL *s, unsigned int ext_type,
|
||
|
const unsigned char *out, void *add_arg);
|
||
|
|
||
|
typedef int (*custom_ext_parse_cb) (SSL *s, unsigned int ext_type,
|
||
|
const unsigned char *in,
|
||
|
size_t inlen, int *al, void *parse_arg);
|
||
|
|
||
|
/* Typedef for verification callback */
|
||
|
typedef int (*SSL_verify_cb)(int preverify_ok, X509_STORE_CTX *x509_ctx);
|
||
|
|
||
|
/* Allow initial connection to servers that don't support RI */
|
||
|
# define SSL_OP_LEGACY_SERVER_CONNECT 0x00000004U
|
||
|
# define SSL_OP_TLSEXT_PADDING 0x00000010U
|
||
|
# define SSL_OP_SAFARI_ECDHE_ECDSA_BUG 0x00000040U
|
||
|
|
||
|
/*
|
||
|
* Disable SSL 3.0/TLS 1.0 CBC vulnerability workaround that was added in
|
||
|
* OpenSSL 0.9.6d. Usually (depending on the application protocol) the
|
||
|
* workaround is not needed. Unfortunately some broken SSL/TLS
|
||
|
* implementations cannot handle it at all, which is why we include it in
|
||
|
* SSL_OP_ALL. Added in 0.9.6e
|
||
|
*/
|
||
|
# define SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS 0x00000800U
|
||
|
|
||
|
/* DTLS options */
|
||
|
# define SSL_OP_NO_QUERY_MTU 0x00001000U
|
||
|
/* Turn on Cookie Exchange (on relevant for servers) */
|
||
|
# define SSL_OP_COOKIE_EXCHANGE 0x00002000U
|
||
|
/* Don't use RFC4507 ticket extension */
|
||
|
# define SSL_OP_NO_TICKET 0x00004000U
|
||
|
# ifndef OPENSSL_NO_DTLS1_METHOD
|
||
|
/* Use Cisco's "speshul" version of DTLS_BAD_VER
|
||
|
* (only with deprecated DTLSv1_client_method()) */
|
||
|
# define SSL_OP_CISCO_ANYCONNECT 0x00008000U
|
||
|
# endif
|
||
|
|
||
|
/* As server, disallow session resumption on renegotiation */
|
||
|
# define SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION 0x00010000U
|
||
|
/* Don't use compression even if supported */
|
||
|
# define SSL_OP_NO_COMPRESSION 0x00020000U
|
||
|
/* Permit unsafe legacy renegotiation */
|
||
|
# define SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION 0x00040000U
|
||
|
/* Disable encrypt-then-mac */
|
||
|
# define SSL_OP_NO_ENCRYPT_THEN_MAC 0x00080000U
|
||
|
/*
|
||
|
* Set on servers to choose the cipher according to the server's preferences
|
||
|
*/
|
||
|
# define SSL_OP_CIPHER_SERVER_PREFERENCE 0x00400000U
|
||
|
/*
|
||
|
* If set, a server will allow a client to issue a SSLv3.0 version number as
|
||
|
* latest version supported in the premaster secret, even when TLSv1.0
|
||
|
* (version 3.1) was announced in the client hello. Normally this is
|
||
|
* forbidden to prevent version rollback attacks.
|
||
|
*/
|
||
|
# define SSL_OP_TLS_ROLLBACK_BUG 0x00800000U
|
||
|
|
||
|
# define SSL_OP_NO_SSLv3 0x02000000U
|
||
|
# define SSL_OP_NO_TLSv1 0x04000000U
|
||
|
# define SSL_OP_NO_TLSv1_2 0x08000000U
|
||
|
# define SSL_OP_NO_TLSv1_1 0x10000000U
|
||
|
|
||
|
# define SSL_OP_NO_DTLSv1 0x04000000U
|
||
|
# define SSL_OP_NO_DTLSv1_2 0x08000000U
|
||
|
|
||
|
# define SSL_OP_NO_SSL_MASK (SSL_OP_NO_SSLv3|\
|
||
|
SSL_OP_NO_TLSv1|SSL_OP_NO_TLSv1_1|SSL_OP_NO_TLSv1_2)
|
||
|
# define SSL_OP_NO_DTLS_MASK (SSL_OP_NO_DTLSv1|SSL_OP_NO_DTLSv1_2)
|
||
|
|
||
|
/* Disallow all renegotiation */
|
||
|
# define SSL_OP_NO_RENEGOTIATION 0x40000000U
|
||
|
|
||
|
/*
|
||
|
* Make server add server-hello extension from early version of cryptopro
|
||
|
* draft, when GOST ciphersuite is negotiated. Required for interoperability
|
||
|
* with CryptoPro CSP 3.x
|
||
|
*/
|
||
|
# define SSL_OP_CRYPTOPRO_TLSEXT_BUG 0x80000000U
|
||
|
|
||
|
/*
|
||
|
* SSL_OP_ALL: various bug workarounds that should be rather harmless.
|
||
|
* This used to be 0x000FFFFFL before 0.9.7.
|
||
|
* This used to be 0x80000BFFU before 1.1.1.
|
||
|
*/
|
||
|
# define SSL_OP_ALL (SSL_OP_CRYPTOPRO_TLSEXT_BUG|\
|
||
|
SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS|\
|
||
|
SSL_OP_LEGACY_SERVER_CONNECT|\
|
||
|
SSL_OP_TLSEXT_PADDING|\
|
||
|
SSL_OP_SAFARI_ECDHE_ECDSA_BUG)
|
||
|
|
||
|
/* OBSOLETE OPTIONS: retained for compatibility */
|
||
|
|
||
|
/* Removed from OpenSSL 1.1.0. Was 0x00000001L */
|
||
|
/* Related to removed SSLv2. */
|
||
|
# define SSL_OP_MICROSOFT_SESS_ID_BUG 0x0
|
||
|
/* Removed from OpenSSL 1.1.0. Was 0x00000002L */
|
||
|
/* Related to removed SSLv2. */
|
||
|
# define SSL_OP_NETSCAPE_CHALLENGE_BUG 0x0
|
||
|
/* Removed from OpenSSL 0.9.8q and 1.0.0c. Was 0x00000008L */
|
||
|
/* Dead forever, see CVE-2010-4180 */
|
||
|
# define SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG 0x0
|
||
|
/* Removed from OpenSSL 1.0.1h and 1.0.2. Was 0x00000010L */
|
||
|
/* Refers to ancient SSLREF and SSLv2. */
|
||
|
# define SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG 0x0
|
||
|
/* Removed from OpenSSL 1.1.0. Was 0x00000020 */
|
||
|
# define SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER 0x0
|
||
|
/* Removed from OpenSSL 0.9.7h and 0.9.8b. Was 0x00000040L */
|
||
|
# define SSL_OP_MSIE_SSLV2_RSA_PADDING 0x0
|
||
|
/* Removed from OpenSSL 1.1.0. Was 0x00000080 */
|
||
|
/* Ancient SSLeay version. */
|
||
|
# define SSL_OP_SSLEAY_080_CLIENT_DH_BUG 0x0
|
||
|
/* Removed from OpenSSL 1.1.0. Was 0x00000100L */
|
||
|
# define SSL_OP_TLS_D5_BUG 0x0
|
||
|
/* Removed from OpenSSL 1.1.0. Was 0x00000200L */
|
||
|
# define SSL_OP_TLS_BLOCK_PADDING_BUG 0x0
|
||
|
/* Removed from OpenSSL 1.1.0. Was 0x00080000L */
|
||
|
# define SSL_OP_SINGLE_ECDH_USE 0x0
|
||
|
/* Removed from OpenSSL 1.1.0. Was 0x00100000L */
|
||
|
# define SSL_OP_SINGLE_DH_USE 0x0
|
||
|
/* Removed from OpenSSL 1.0.1k and 1.0.2. Was 0x00200000L */
|
||
|
# define SSL_OP_EPHEMERAL_RSA 0x0
|
||
|
/* Removed from OpenSSL 1.1.0. Was 0x01000000L */
|
||
|
# define SSL_OP_NO_SSLv2 0x0
|
||
|
/* Removed from OpenSSL 1.0.1. Was 0x08000000L */
|
||
|
# define SSL_OP_PKCS1_CHECK_1 0x0
|
||
|
/* Removed from OpenSSL 1.0.1. Was 0x10000000L */
|
||
|
# define SSL_OP_PKCS1_CHECK_2 0x0
|
||
|
/* Removed from OpenSSL 1.1.0. Was 0x20000000L */
|
||
|
# define SSL_OP_NETSCAPE_CA_DN_BUG 0x0
|
||
|
/* Removed from OpenSSL 1.1.0. Was 0x40000000L */
|
||
|
# define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG 0x0
|
||
|
|
||
|
/*
|
||
|
* Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success
|
||
|
* when just a single record has been written):
|
||
|
*/
|
||
|
# define SSL_MODE_ENABLE_PARTIAL_WRITE 0x00000001U
|
||
|
/*
|
||
|
* Make it possible to retry SSL_write() with changed buffer location (buffer
|
||
|
* contents must stay the same!); this is not the default to avoid the
|
||
|
* misconception that non-blocking SSL_write() behaves like non-blocking
|
||
|
* write():
|
||
|
*/
|
||
|
# define SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 0x00000002U
|
||
|
/*
|
||
|
* Never bother the application with retries if the transport is blocking:
|
||
|
*/
|
||
|
# define SSL_MODE_AUTO_RETRY 0x00000004U
|
||
|
/* Don't attempt to automatically build certificate chain */
|
||
|
# define SSL_MODE_NO_AUTO_CHAIN 0x00000008U
|
||
|
/*
|
||
|
* Save RAM by releasing read and write buffers when they're empty. (SSL3 and
|
||
|
* TLS only.) "Released" buffers are put onto a free-list in the context or
|
||
|
* just freed (depending on the context's setting for freelist_max_len).
|
||
|
*/
|
||
|
# define SSL_MODE_RELEASE_BUFFERS 0x00000010U
|
||
|
/*
|
||
|
* Send the current time in the Random fields of the ClientHello and
|
||
|
* ServerHello records for compatibility with hypothetical implementations
|
||
|
* that require it.
|
||
|
*/
|
||
|
# define SSL_MODE_SEND_CLIENTHELLO_TIME 0x00000020U
|
||
|
# define SSL_MODE_SEND_SERVERHELLO_TIME 0x00000040U
|
||
|
/*
|
||
|
* Send TLS_FALLBACK_SCSV in the ClientHello. To be set only by applications
|
||
|
* that reconnect with a downgraded protocol version; see
|
||
|
* draft-ietf-tls-downgrade-scsv-00 for details. DO NOT ENABLE THIS if your
|
||
|
* application attempts a normal handshake. Only use this in explicit
|
||
|
* fallback retries, following the guidance in
|
||
|
* draft-ietf-tls-downgrade-scsv-00.
|
||
|
*/
|
||
|
# define SSL_MODE_SEND_FALLBACK_SCSV 0x00000080U
|
||
|
/*
|
||
|
* Support Asynchronous operation
|
||
|
*/
|
||
|
# define SSL_MODE_ASYNC 0x00000100U
|
||
|
|
||
|
/* Cert related flags */
|
||
|
/*
|
||
|
* Many implementations ignore some aspects of the TLS standards such as
|
||
|
* enforcing certificate chain algorithms. When this is set we enforce them.
|
||
|
*/
|
||
|
# define SSL_CERT_FLAG_TLS_STRICT 0x00000001U
|
||
|
|
||
|
/* Suite B modes, takes same values as certificate verify flags */
|
||
|
# define SSL_CERT_FLAG_SUITEB_128_LOS_ONLY 0x10000
|
||
|
/* Suite B 192 bit only mode */
|
||
|
# define SSL_CERT_FLAG_SUITEB_192_LOS 0x20000
|
||
|
/* Suite B 128 bit mode allowing 192 bit algorithms */
|
||
|
# define SSL_CERT_FLAG_SUITEB_128_LOS 0x30000
|
||
|
|
||
|
/* Perform all sorts of protocol violations for testing purposes */
|
||
|
# define SSL_CERT_FLAG_BROKEN_PROTOCOL 0x10000000
|
||
|
|
||
|
/* Flags for building certificate chains */
|
||
|
/* Treat any existing certificates as untrusted CAs */
|
||
|
# define SSL_BUILD_CHAIN_FLAG_UNTRUSTED 0x1
|
||
|
/* Don't include root CA in chain */
|
||
|
# define SSL_BUILD_CHAIN_FLAG_NO_ROOT 0x2
|
||
|
/* Just check certificates already there */
|
||
|
# define SSL_BUILD_CHAIN_FLAG_CHECK 0x4
|
||
|
/* Ignore verification errors */
|
||
|
# define SSL_BUILD_CHAIN_FLAG_IGNORE_ERROR 0x8
|
||
|
/* Clear verification errors from queue */
|
||
|
# define SSL_BUILD_CHAIN_FLAG_CLEAR_ERROR 0x10
|
||
|
|
||
|
/* Flags returned by SSL_check_chain */
|
||
|
/* Certificate can be used with this session */
|
||
|
# define CERT_PKEY_VALID 0x1
|
||
|
/* Certificate can also be used for signing */
|
||
|
# define CERT_PKEY_SIGN 0x2
|
||
|
/* EE certificate signing algorithm OK */
|
||
|
# define CERT_PKEY_EE_SIGNATURE 0x10
|
||
|
/* CA signature algorithms OK */
|
||
|
# define CERT_PKEY_CA_SIGNATURE 0x20
|
||
|
/* EE certificate parameters OK */
|
||
|
# define CERT_PKEY_EE_PARAM 0x40
|
||
|
/* CA certificate parameters OK */
|
||
|
# define CERT_PKEY_CA_PARAM 0x80
|
||
|
/* Signing explicitly allowed as opposed to SHA1 fallback */
|
||
|
# define CERT_PKEY_EXPLICIT_SIGN 0x100
|
||
|
/* Client CA issuer names match (always set for server cert) */
|
||
|
# define CERT_PKEY_ISSUER_NAME 0x200
|
||
|
/* Cert type matches client types (always set for server cert) */
|
||
|
# define CERT_PKEY_CERT_TYPE 0x400
|
||
|
/* Cert chain suitable to Suite B */
|
||
|
# define CERT_PKEY_SUITEB 0x800
|
||
|
|
||
|
# define SSL_CONF_FLAG_CMDLINE 0x1
|
||
|
# define SSL_CONF_FLAG_FILE 0x2
|
||
|
# define SSL_CONF_FLAG_CLIENT 0x4
|
||
|
# define SSL_CONF_FLAG_SERVER 0x8
|
||
|
# define SSL_CONF_FLAG_SHOW_ERRORS 0x10
|
||
|
# define SSL_CONF_FLAG_CERTIFICATE 0x20
|
||
|
# define SSL_CONF_FLAG_REQUIRE_PRIVATE 0x40
|
||
|
/* Configuration value types */
|
||
|
# define SSL_CONF_TYPE_UNKNOWN 0x0
|
||
|
# define SSL_CONF_TYPE_STRING 0x1
|
||
|
# define SSL_CONF_TYPE_FILE 0x2
|
||
|
# define SSL_CONF_TYPE_DIR 0x3
|
||
|
# define SSL_CONF_TYPE_NONE 0x4
|
||
|
|
||
|
/*
|
||
|
* Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value, they
|
||
|
* cannot be used to clear bits.
|
||
|
*/
|
||
|
|
||
|
unsigned long SSL_CTX_get_options(const SSL_CTX *ctx);
|
||
|
unsigned long SSL_get_options(const SSL* s);
|
||
|
unsigned long SSL_CTX_clear_options(SSL_CTX *ctx, unsigned long op);
|
||
|
unsigned long SSL_clear_options(SSL *s, unsigned long op);
|
||
|
unsigned long SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
|
||
|
unsigned long SSL_set_options(SSL *s, unsigned long op);
|
||
|
|
||
|
# define SSL_CTX_set_mode(ctx,op) \
|
||
|
SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,(op),NULL)
|
||
|
# define SSL_CTX_clear_mode(ctx,op) \
|
||
|
SSL_CTX_ctrl((ctx),SSL_CTRL_CLEAR_MODE,(op),NULL)
|
||
|
# define SSL_CTX_get_mode(ctx) \
|
||
|
SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,0,NULL)
|
||
|
# define SSL_clear_mode(ssl,op) \
|
||
|
SSL_ctrl((ssl),SSL_CTRL_CLEAR_MODE,(op),NULL)
|
||
|
# define SSL_set_mode(ssl,op) \
|
||
|
SSL_ctrl((ssl),SSL_CTRL_MODE,(op),NULL)
|
||
|
# define SSL_get_mode(ssl) \
|
||
|
SSL_ctrl((ssl),SSL_CTRL_MODE,0,NULL)
|
||
|
# define SSL_set_mtu(ssl, mtu) \
|
||
|
SSL_ctrl((ssl),SSL_CTRL_SET_MTU,(mtu),NULL)
|
||
|
# define DTLS_set_link_mtu(ssl, mtu) \
|
||
|
SSL_ctrl((ssl),DTLS_CTRL_SET_LINK_MTU,(mtu),NULL)
|
||
|