Coverage Report

Created: 2026-05-30 06:56

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl/ssl/ssl_local.h
Line
Count
Source
1
/*
2
 * Copyright 1995-2026 The OpenSSL Project Authors. All Rights Reserved.
3
 * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
4
 * Copyright 2005 Nokia. All rights reserved.
5
 *
6
 * Licensed under the Apache License 2.0 (the "License").  You may not use
7
 * this file except in compliance with the License.  You can obtain a copy
8
 * in the file LICENSE in the source distribution or at
9
 * https://www.openssl.org/source/license.html
10
 */
11
12
#ifndef OSSL_SSL_LOCAL_H
13
#define OSSL_SSL_LOCAL_H
14
15
#include <stdlib.h>
16
#include <time.h>
17
#include <errno.h>
18
#include "internal/common.h" /* for HAS_PREFIX */
19
20
#include <openssl/buffer.h>
21
#include <openssl/bio.h>
22
#include <openssl/comp.h>
23
#include <openssl/dsa.h>
24
#include <openssl/err.h>
25
#include <openssl/ssl.h>
26
#include <openssl/async.h>
27
#include <openssl/symhacks.h>
28
#include <openssl/ct.h>
29
#include "internal/recordmethod.h"
30
#include "internal/statem.h"
31
#include "internal/packet.h"
32
#include "internal/dane.h"
33
#include "internal/refcount.h"
34
#include "internal/tlssigalgs.h"
35
#include "internal/tsan_assist.h"
36
#include "internal/bio.h"
37
#include "internal/ktls.h"
38
#include "internal/time.h"
39
#include "internal/ssl.h"
40
#include "internal/cryptlib.h"
41
#include "internal/quic_predef.h"
42
#include "record/record.h"
43
#include "internal/quic_predef.h"
44
#include "internal/quic_tls.h"
45
#ifndef OPENSSL_NO_ECH
46
#include "ech/ech_local.h"
47
#endif
48
49
#ifdef OPENSSL_BUILD_SHLIBSSL
50
#undef OPENSSL_EXTERN
51
#define OPENSSL_EXTERN OPENSSL_EXPORT
52
#endif
53
54
0
#define TLS_MAX_VERSION_INTERNAL TLS1_3_VERSION
55
0
#define DTLS_MAX_VERSION_INTERNAL DTLS1_2_VERSION
56
57
/*
58
 * DTLS version numbers are strange because they're inverted. Except for
59
 * DTLS1_BAD_VER, which should be considered "lower" than the rest.
60
 */
61
0
#define dtls_ver_ordinal(v1) (((v1) == DTLS1_BAD_VER) ? 0xff00 : (v1))
62
0
#define DTLS_VERSION_GT(v1, v2) (dtls_ver_ordinal(v1) < dtls_ver_ordinal(v2))
63
0
#define DTLS_VERSION_GE(v1, v2) (dtls_ver_ordinal(v1) <= dtls_ver_ordinal(v2))
64
0
#define DTLS_VERSION_LT(v1, v2) (dtls_ver_ordinal(v1) > dtls_ver_ordinal(v2))
65
0
#define DTLS_VERSION_LE(v1, v2) (dtls_ver_ordinal(v1) >= dtls_ver_ordinal(v2))
66
/* TLS/DTLS version for the given SSL object: XTLS(ssl, 1, 2) == TLS 1.2 or DTLS 1.2 */
67
0
#define XTLS(ssl, m, n) (SSL_is_dtls(ssl) ? (((0xFF - m) << 8) | (0xFF - n)) : (((0x02 + m) << 8) | (0x01 + n)))
68
69
0
#define SSL_AD_NO_ALERT -1
70
71
/*
72
 * Define the Bitmasks for SSL_CIPHER.algorithms.
73
 * This bits are used packed as dense as possible. If new methods/ciphers
74
 * etc will be added, the bits a likely to change, so this information
75
 * is for internal library use only, even though SSL_CIPHER.algorithms
76
 * can be publicly accessed.
77
 * Use the according functions for cipher management instead.
78
 *
79
 * The bit mask handling in the selection and sorting scheme in
80
 * ssl_create_cipher_list() has only limited capabilities, reflecting
81
 * that the different entities within are mutually exclusive:
82
 * ONLY ONE BIT PER MASK CAN BE SET AT A TIME.
83
 */
84
85
/* Bits for algorithm_mkey (key exchange algorithm) */
86
/* RSA key exchange */
87
0
#define SSL_kRSA 0x00000001U
88
/* tmp DH key no DH cert */
89
0
#define SSL_kDHE 0x00000002U
90
/* ephemeral ECDH */
91
0
#define SSL_kECDHE 0x00000004U
92
/* PSK */
93
0
#define SSL_kPSK 0x00000008U
94
/* GOST key exchange */
95
0
#define SSL_kGOST 0x00000010U
96
/* SRP */
97
0
#define SSL_kSRP 0x00000020U
98
99
0
#define SSL_kRSAPSK 0x00000040U
100
0
#define SSL_kECDHEPSK 0x00000080U
101
0
#define SSL_kDHEPSK 0x00000100U
102
/* GOST KDF key exchange, draft-smyshlyaev-tls12-gost-suites */
103
0
#define SSL_kGOST18 0x00000200U
104
105
/* all PSK */
106
107
0
#define SSL_PSK (SSL_kPSK | SSL_kRSAPSK | SSL_kECDHEPSK | SSL_kDHEPSK)
108
109
/* Any appropriate key exchange algorithm (for TLS 1.3 ciphersuites) */
110
0
#define SSL_kANY 0x00000000U
111
112
/* Bits for algorithm_auth (server authentication) */
113
/* RSA auth */
114
0
#define SSL_aRSA 0x00000001U
115
/* DSS auth */
116
0
#define SSL_aDSS 0x00000002U
117
/* no auth (i.e. use ADH or AECDH) */
118
0
#define SSL_aNULL 0x00000004U
119
/* ECDSA auth*/
120
0
#define SSL_aECDSA 0x00000008U
121
/* PSK auth */
122
0
#define SSL_aPSK 0x00000010U
123
/* GOST R 34.10-2001 signature auth */
124
0
#define SSL_aGOST01 0x00000020U
125
/* SRP auth */
126
0
#define SSL_aSRP 0x00000040U
127
/* GOST R 34.10-2012 signature auth */
128
0
#define SSL_aGOST12 0x00000080U
129
/* Any appropriate signature auth (for TLS 1.3 ciphersuites) */
130
0
#define SSL_aANY 0x00000000U
131
/* All bits requiring a certificate */
132
#define SSL_aCERT \
133
0
    (SSL_aRSA | SSL_aDSS | SSL_aECDSA | SSL_aGOST01 | SSL_aGOST12)
134
135
/* Bits for algorithm_enc (symmetric encryption) */
136
0
#define SSL_DES 0x00000001U
137
0
#define SSL_3DES 0x00000002U
138
0
#define SSL_RC4 0x00000004U
139
0
#define SSL_RC2 0x00000008U
140
0
#define SSL_IDEA 0x00000010U
141
0
#define SSL_eNULL 0x00000020U
142
0
#define SSL_AES128 0x00000040U
143
0
#define SSL_AES256 0x00000080U
144
0
#define SSL_CAMELLIA128 0x00000100U
145
0
#define SSL_CAMELLIA256 0x00000200U
146
0
#define SSL_eGOST2814789CNT 0x00000400U
147
0
#define SSL_SEED 0x00000800U
148
0
#define SSL_AES128GCM 0x00001000U
149
0
#define SSL_AES256GCM 0x00002000U
150
0
#define SSL_AES128CCM 0x00004000U
151
0
#define SSL_AES256CCM 0x00008000U
152
0
#define SSL_AES128CCM8 0x00010000U
153
0
#define SSL_AES256CCM8 0x00020000U
154
0
#define SSL_eGOST2814789CNT12 0x00040000U
155
0
#define SSL_CHACHA20POLY1305 0x00080000U
156
0
#define SSL_ARIA128GCM 0x00100000U
157
0
#define SSL_ARIA256GCM 0x00200000U
158
0
#define SSL_MAGMA 0x00400000U
159
0
#define SSL_KUZNYECHIK 0x00800000U
160
0
#define SSL_SM4GCM 0x01000000U
161
0
#define SSL_SM4CCM 0x02000000U
162
163
0
#define SSL_AESGCM (SSL_AES128GCM | SSL_AES256GCM)
164
0
#define SSL_AESCCM (SSL_AES128CCM | SSL_AES256CCM | SSL_AES128CCM8 | SSL_AES256CCM8)
165
0
#define SSL_AES (SSL_AES128 | SSL_AES256 | SSL_AESGCM | SSL_AESCCM)
166
#define SSL_CAMELLIA (SSL_CAMELLIA128 | SSL_CAMELLIA256)
167
0
#define SSL_CHACHA20 (SSL_CHACHA20POLY1305)
168
0
#define SSL_ARIAGCM (SSL_ARIA128GCM | SSL_ARIA256GCM)
169
#define SSL_ARIA (SSL_ARIAGCM)
170
#define SSL_CBC (SSL_DES | SSL_3DES | SSL_RC2 | SSL_IDEA \
171
    | SSL_AES128 | SSL_AES256 | SSL_CAMELLIA128          \
172
    | SSL_CAMELLIA256 | SSL_SEED)
173
174
/* Bits for algorithm_mac (symmetric authentication) */
175
176
0
#define SSL_MD5 0x00000001U
177
0
#define SSL_SHA1 0x00000002U
178
0
#define SSL_GOST94 0x00000004U
179
0
#define SSL_GOST89MAC 0x00000008U
180
0
#define SSL_SHA256 0x00000010U
181
0
#define SSL_SHA384 0x00000020U
182
/* Not a real MAC, just an indication it is part of cipher */
183
0
#define SSL_AEAD 0x00000040U
184
0
#define SSL_GOST12_256 0x00000080U
185
0
#define SSL_GOST89MAC12 0x00000100U
186
0
#define SSL_GOST12_512 0x00000200U
187
0
#define SSL_MAGMAOMAC 0x00000400U
188
0
#define SSL_KUZNYECHIKOMAC 0x00000800U
189
190
/*
191
 * When adding new digest in the ssl_ciph.c and increment SSL_MD_NUM_IDX make
192
 * sure to update this constant too
193
 */
194
195
0
#define SSL_MD_MD5_IDX 0
196
0
#define SSL_MD_SHA1_IDX 1
197
#define SSL_MD_GOST94_IDX 2
198
0
#define SSL_MD_GOST89MAC_IDX 3
199
0
#define SSL_MD_SHA256_IDX 4
200
0
#define SSL_MD_SHA384_IDX 5
201
#define SSL_MD_GOST12_256_IDX 6
202
0
#define SSL_MD_GOST89MAC12_IDX 7
203
#define SSL_MD_GOST12_512_IDX 8
204
0
#define SSL_MD_MD5_SHA1_IDX 9
205
0
#define SSL_MD_SHA224_IDX 10
206
#define SSL_MD_SHA512_IDX 11
207
0
#define SSL_MD_MAGMAOMAC_IDX 12
208
0
#define SSL_MD_KUZNYECHIKOMAC_IDX 13
209
#define SSL_MD_SM3_IDX 14
210
0
#define SSL_MAX_DIGEST 15
211
212
0
#define SSL_MD_NUM_IDX SSL_MAX_DIGEST
213
214
/* Bits for algorithm2 (handshake digests and other extra flags) */
215
216
/* Bits 0-7 are handshake MAC */
217
0
#define SSL_HANDSHAKE_MAC_MASK 0xFF
218
0
#define SSL_HANDSHAKE_MAC_MD5_SHA1 SSL_MD_MD5_SHA1_IDX
219
0
#define SSL_HANDSHAKE_MAC_SHA256 SSL_MD_SHA256_IDX
220
0
#define SSL_HANDSHAKE_MAC_SHA384 SSL_MD_SHA384_IDX
221
#define SSL_HANDSHAKE_MAC_GOST94 SSL_MD_GOST94_IDX
222
#define SSL_HANDSHAKE_MAC_GOST12_256 SSL_MD_GOST12_256_IDX
223
#define SSL_HANDSHAKE_MAC_GOST12_512 SSL_MD_GOST12_512_IDX
224
#define SSL_HANDSHAKE_MAC_SM3 SSL_MD_SM3_IDX
225
0
#define SSL_HANDSHAKE_MAC_DEFAULT SSL_HANDSHAKE_MAC_MD5_SHA1
226
227
/* Bits 8-15 bits are PRF */
228
0
#define TLS1_PRF_DGST_SHIFT 8
229
#define TLS1_PRF_SHA1_MD5 (SSL_MD_MD5_SHA1_IDX << TLS1_PRF_DGST_SHIFT)
230
0
#define TLS1_PRF_SHA256 (SSL_MD_SHA256_IDX << TLS1_PRF_DGST_SHIFT)
231
0
#define TLS1_PRF_SHA384 (SSL_MD_SHA384_IDX << TLS1_PRF_DGST_SHIFT)
232
#define TLS1_PRF_GOST94 (SSL_MD_GOST94_IDX << TLS1_PRF_DGST_SHIFT)
233
#define TLS1_PRF_GOST12_256 (SSL_MD_GOST12_256_IDX << TLS1_PRF_DGST_SHIFT)
234
#define TLS1_PRF_GOST12_512 (SSL_MD_GOST12_512_IDX << TLS1_PRF_DGST_SHIFT)
235
0
#define TLS1_PRF (SSL_MD_MD5_SHA1_IDX << TLS1_PRF_DGST_SHIFT)
236
237
/*
238
 * Stream MAC for GOST ciphersuites from cryptopro draft (currently this also
239
 * goes into algorithm2)
240
 */
241
0
#define TLS1_STREAM_MAC 0x10000
242
/*
243
 * TLSTREE cipher/mac key derivation from draft-smyshlyaev-tls12-gost-suites
244
 * (currently this also  goes into algorithm2)
245
 */
246
0
#define TLS1_TLSTREE 0x20000
247
248
/* Ciphersuite supported in QUIC */
249
0
#define SSL_QUIC 0x00040000U
250
251
0
#define SSL_STRONG_MASK 0x0000001FU
252
0
#define SSL_DEFAULT_MASK 0X00000020U
253
254
#define SSL_STRONG_NONE 0x00000001U
255
#define SSL_LOW 0x00000002U
256
#define SSL_MEDIUM 0x00000004U
257
#define SSL_HIGH 0x00000008U
258
/* #define SSL_FIPS 0x00000010U obsolete FIPS canister remnant */
259
#define SSL_NOT_DEFAULT 0x00000020U
260
261
/* we have used 0000003f - 26 bits left to go */
262
263
/* Flag used on OpenSSL ciphersuite ids to indicate they are for SSLv3+ */
264
0
#define SSL3_CK_CIPHERSUITE_FLAG 0x03000000
265
266
/* Check if an SSL structure is using DTLS */
267
#define SSL_CONNECTION_IS_DTLS(s) \
268
0
    (SSL_CONNECTION_GET_SSL(s)->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_DTLS)
269
270
/* Check if an SSL_CTX structure is using DTLS */
271
#define SSL_CTX_IS_DTLS(ctx) \
272
0
    (ctx->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_DTLS)
273
274
/* Check if we are using TLSv1.3 */
275
0
#define SSL_CONNECTION_IS_TLS13(s) (!SSL_CONNECTION_IS_DTLS(s)      \
276
0
    && SSL_CONNECTION_GET_SSL(s)->method->version >= TLS1_3_VERSION \
277
0
    && SSL_CONNECTION_GET_SSL(s)->method->version != TLS_ANY_VERSION)
278
279
#define SSL_CONNECTION_TREAT_AS_TLS13(s)                         \
280
0
    (SSL_CONNECTION_IS_TLS13(s)                                  \
281
0
        || (s)->early_data_state == SSL_EARLY_DATA_CONNECTING    \
282
0
        || (s)->early_data_state == SSL_EARLY_DATA_CONNECT_RETRY \
283
0
        || (s)->early_data_state == SSL_EARLY_DATA_WRITING       \
284
0
        || (s)->early_data_state == SSL_EARLY_DATA_WRITE_RETRY   \
285
0
        || (s)->hello_retry_request == SSL_HRR_PENDING)
286
287
0
#define SSL_IS_FIRST_HANDSHAKE(s) ((s)->s3.tmp.finish_md_len == 0 \
288
0
    || (s)->s3.tmp.peer_finish_md_len == 0)
289
290
/*
291
 * See if we use signature algorithms extension and signature algorithm
292
 * before signatures.
293
 */
294
#define SSL_USE_SIGALGS(s) \
295
0
    (SSL_CONNECTION_GET_SSL(s)->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_SIGALGS)
296
/*
297
 * Allow TLS 1.2 ciphersuites: applies to DTLS 1.2 as well as TLS 1.2: may
298
 * apply to others in future.
299
 */
300
#define SSL_USE_TLS1_2_CIPHERS(s) \
301
    (SSL_CONNECTION_GET_SSL(s)->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_TLS1_2_CIPHERS)
302
303
#define IS_MAX_FRAGMENT_LENGTH_EXT_VALID(value) \
304
0
    (((value) >= TLSEXT_max_fragment_length_512) && ((value) <= TLSEXT_max_fragment_length_4096))
305
#define USE_MAX_FRAGMENT_LENGTH_EXT(session) \
306
0
    IS_MAX_FRAGMENT_LENGTH_EXT_VALID(session->ext.max_fragment_len_mode)
307
#define GET_MAX_FRAGMENT_LENGTH(session) \
308
0
    (512U << (session->ext.max_fragment_len_mode - 1))
309
310
0
#define SSL_READ_ETM(s) (s->s3.flags & TLS1_FLAGS_ENCRYPT_THEN_MAC_READ)
311
0
#define SSL_WRITE_ETM(s) (s->s3.flags & TLS1_FLAGS_ENCRYPT_THEN_MAC_WRITE)
312
313
0
#define SSL_IS_QUIC_HANDSHAKE(s) (((s)->s3.flags & TLS1_FLAGS_QUIC) != 0)
314
0
#define SSL_IS_QUIC_INT_HANDSHAKE(s) (((s)->s3.flags & TLS1_FLAGS_QUIC_INTERNAL) != 0)
315
316
/* no end of early data */
317
0
#define SSL_NO_EOED(s) SSL_IS_QUIC_HANDSHAKE(s)
318
319
/* alert_dispatch values */
320
321
/* No alert pending */
322
0
#define SSL_ALERT_DISPATCH_NONE 0
323
/* Alert pending */
324
0
#define SSL_ALERT_DISPATCH_PENDING 1
325
/* Pending alert write needs to be retried */
326
0
#define SSL_ALERT_DISPATCH_RETRY 2
327
328
/* Mostly for SSLv3 */
329
0
#define SSL_PKEY_RSA 0
330
0
#define SSL_PKEY_RSA_PSS_SIGN 1
331
0
#define SSL_PKEY_DSA_SIGN 2
332
0
#define SSL_PKEY_ECC 3
333
0
#define SSL_PKEY_GOST01 4
334
0
#define SSL_PKEY_GOST12_256 5
335
0
#define SSL_PKEY_GOST12_512 6
336
0
#define SSL_PKEY_ED25519 7
337
0
#define SSL_PKEY_ED448 8
338
0
#define SSL_PKEY_NUM 9
339
340
#define SSL_ENC_DES_IDX 0
341
#define SSL_ENC_3DES_IDX 1
342
#define SSL_ENC_RC4_IDX 2
343
#define SSL_ENC_RC2_IDX 3
344
#define SSL_ENC_IDEA_IDX 4
345
0
#define SSL_ENC_NULL_IDX 5
346
#define SSL_ENC_AES128_IDX 6
347
#define SSL_ENC_AES256_IDX 7
348
#define SSL_ENC_CAMELLIA128_IDX 8
349
#define SSL_ENC_CAMELLIA256_IDX 9
350
#define SSL_ENC_GOST89_IDX 10
351
#define SSL_ENC_SEED_IDX 11
352
#define SSL_ENC_AES128GCM_IDX 12
353
#define SSL_ENC_AES256GCM_IDX 13
354
#define SSL_ENC_AES128CCM_IDX 14
355
#define SSL_ENC_AES256CCM_IDX 15
356
#define SSL_ENC_AES128CCM8_IDX 16
357
#define SSL_ENC_AES256CCM8_IDX 17
358
#define SSL_ENC_GOST8912_IDX 18
359
#define SSL_ENC_CHACHA_IDX 19
360
#define SSL_ENC_ARIA128GCM_IDX 20
361
#define SSL_ENC_ARIA256GCM_IDX 21
362
#define SSL_ENC_MAGMA_IDX 22
363
#define SSL_ENC_KUZNYECHIK_IDX 23
364
#define SSL_ENC_SM4GCM_IDX 24
365
#define SSL_ENC_SM4CCM_IDX 25
366
0
#define SSL_ENC_NUM_IDX 26
367
368
/*-
369
 * SSL_kRSA <- RSA_ENC
370
 * SSL_kDH  <- DH_ENC & (RSA_ENC | RSA_SIGN | DSA_SIGN)
371
 * SSL_kDHE <- RSA_ENC | RSA_SIGN | DSA_SIGN
372
 * SSL_aRSA <- RSA_ENC | RSA_SIGN
373
 * SSL_aDSS <- DSA_SIGN
374
 */
375
376
/* Certificate Type State */
377
0
#define OSSL_CERT_TYPE_CTOS_NONE 0
378
0
#define OSSL_CERT_TYPE_CTOS_GOOD 1
379
0
#define OSSL_CERT_TYPE_CTOS_ERROR 2
380
381
/* Post-Handshake Authentication state */
382
typedef enum {
383
    SSL_PHA_NONE = 0,
384
    SSL_PHA_EXT_SENT, /* client-side only: extension sent */
385
    SSL_PHA_EXT_RECEIVED, /* server-side only: extension received */
386
    SSL_PHA_REQUEST_PENDING, /* server-side only: request pending */
387
    SSL_PHA_REQUESTED /* request received by client, or sent by server */
388
} SSL_PHA_STATE;
389
390
/* CipherSuite length. SSLv3 and all TLS versions. */
391
0
#define TLS_CIPHER_LEN 2
392
/* used to hold info on the particular ciphers used */
393
struct ssl_cipher_st {
394
    uint32_t valid;
395
    const char *name; /* text name */
396
    const char *stdname; /* RFC name */
397
    uint32_t id; /* id, 4 bytes, first is version */
398
    /*
399
     * changed in 1.0.0: these four used to be portions of a single value
400
     * 'algorithms'
401
     */
402
    uint32_t algorithm_mkey; /* key exchange algorithm */
403
    uint32_t algorithm_auth; /* server authentication */
404
    uint32_t algorithm_enc; /* symmetric encryption */
405
    uint32_t algorithm_mac; /* symmetric authentication */
406
    int min_tls; /* minimum SSL/TLS protocol version */
407
    int max_tls; /* maximum SSL/TLS protocol version */
408
    int min_dtls; /* minimum DTLS protocol version */
409
    int max_dtls; /* maximum DTLS protocol version */
410
    uint32_t algo_strength; /* strength and export flags */
411
    uint32_t algorithm2; /* Extra flags */
412
    int32_t strength_bits; /* Number of bits really used */
413
    uint32_t alg_bits; /* Number of bits for algorithm */
414
};
415
416
/* Used to hold SSL/TLS functions */
417
struct ssl_method_st {
418
    int version;
419
    unsigned flags;
420
    uint64_t mask;
421
    SSL *(*ssl_new)(SSL_CTX *ctx);
422
    void (*ssl_free)(SSL *s);
423
    int (*ssl_reset)(SSL *s);
424
    int (*ssl_init)(SSL *s);
425
    int (*ssl_clear)(SSL *s);
426
    void (*ssl_deinit)(SSL *s);
427
    int (*ssl_accept)(SSL *s);
428
    int (*ssl_connect)(SSL *s);
429
    int (*ssl_read)(SSL *s, void *buf, size_t len, size_t *readbytes);
430
    int (*ssl_peek)(SSL *s, void *buf, size_t len, size_t *readbytes);
431
    int (*ssl_write)(SSL *s, const void *buf, size_t len, size_t *written);
432
    int (*ssl_shutdown)(SSL *s);
433
    int (*ssl_renegotiate)(SSL *s);
434
    int (*ssl_renegotiate_check)(SSL *s, int);
435
    int (*ssl_read_bytes)(SSL *s, uint8_t type, uint8_t *recvd_type,
436
        unsigned char *buf, size_t len, int peek,
437
        size_t *readbytes);
438
    int (*ssl_write_bytes)(SSL *s, uint8_t type, const void *buf_, size_t len,
439
        size_t *written);
440
    int (*ssl_dispatch_alert)(SSL *s);
441
    long (*ssl_ctrl)(SSL *s, int cmd, long larg, void *parg);
442
    long (*ssl_ctx_ctrl)(SSL_CTX *ctx, int cmd, long larg, void *parg);
443
    const SSL_CIPHER *(*get_cipher_by_char)(const unsigned char *ptr);
444
    int (*put_cipher_by_char)(const SSL_CIPHER *cipher, WPACKET *pkt,
445
        size_t *len);
446
    size_t (*ssl_pending)(const SSL *s);
447
    int (*num_ciphers)(void);
448
    const SSL_CIPHER *(*get_cipher)(unsigned ncipher);
449
    OSSL_TIME (*get_timeout)(void);
450
    const struct ssl3_enc_method *ssl3_enc; /* Extra SSLv3/TLS stuff */
451
    int (*ssl_version)(void);
452
    long (*ssl_callback_ctrl)(SSL *s, int cb_id, void (*fp)(void));
453
    long (*ssl_ctx_callback_ctrl)(SSL_CTX *s, int cb_id, void (*fp)(void));
454
};
455
456
/*
457
 * Matches the length of PSK_MAX_PSK_LEN. We keep it the same value for
458
 * consistency, even in the event of OPENSSL_NO_PSK being defined.
459
 */
460
0
#define TLS13_MAX_RESUMPTION_PSK_LENGTH 512
461
462
/*-
463
 * Lets make this into an ASN.1 type structure as follows
464
 * SSL_SESSION_ID ::= SEQUENCE {
465
 *      version                 INTEGER,        -- structure version number
466
 *      SSLversion              INTEGER,        -- SSL version number
467
 *      Cipher                  OCTET STRING,   -- the 3 byte cipher ID
468
 *      Session_ID              OCTET STRING,   -- the Session ID
469
 *      Master_key              OCTET STRING,   -- the master key
470
 *      Key_Arg [ 0 ] IMPLICIT  OCTET STRING,   -- the optional Key argument
471
 *      Time [ 1 ] EXPLICIT     INTEGER,        -- optional Start Time
472
 *      Timeout [ 2 ] EXPLICIT  INTEGER,        -- optional Timeout ins seconds
473
 *      Peer [ 3 ] EXPLICIT     X509,           -- optional Peer Certificate
474
 *      Session_ID_context [ 4 ] EXPLICIT OCTET STRING,   -- the Session ID context
475
 *      Verify_result [ 5 ] EXPLICIT INTEGER,   -- X509_V_... code for `Peer'
476
 *      HostName [ 6 ] EXPLICIT OCTET STRING,   -- optional HostName from servername TLS extension
477
 *      PSK_identity_hint [ 7 ] EXPLICIT OCTET STRING, -- optional PSK identity hint
478
 *      PSK_identity [ 8 ] EXPLICIT OCTET STRING,  -- optional PSK identity
479
 *      Ticket_lifetime_hint [9] EXPLICIT INTEGER, -- server's lifetime hint for session ticket
480
 *      Ticket [10]             EXPLICIT OCTET STRING, -- session ticket (clients only)
481
 *      Compression_meth [11]   EXPLICIT OCTET STRING, -- optional compression method
482
 *      SRP_username [ 12 ] EXPLICIT OCTET STRING -- optional SRP username
483
 *      flags [ 13 ] EXPLICIT INTEGER -- optional flags
484
 *      }
485
 * Look in ssl/ssl_asn1.c for more details
486
 * I'm using EXPLICIT tags so I can read the damn things using asn1parse :-).
487
 */
488
struct ssl_session_st {
489
    int ssl_version; /* what ssl version session info is being kept
490
                      * in here? */
491
    size_t master_key_length;
492
493
    /* TLSv1.3 early_secret used for external PSKs */
494
    unsigned char early_secret[EVP_MAX_MD_SIZE];
495
    /*
496
     * For <=TLS1.2 this is the master_key. For TLS1.3 this is the resumption
497
     * PSK
498
     */
499
    unsigned char master_key[TLS13_MAX_RESUMPTION_PSK_LENGTH];
500
    /* session_id - valid? */
501
    size_t session_id_length;
502
    unsigned char session_id[SSL_MAX_SSL_SESSION_ID_LENGTH];
503
    /*
504
     * this is used to determine whether the session is being reused in the
505
     * appropriate context. It is up to the application to set this, via
506
     * SSL_new
507
     */
508
    size_t sid_ctx_length;
509
    unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];
510
#ifndef OPENSSL_NO_PSK
511
    char *psk_identity_hint;
512
    char *psk_identity;
513
#endif
514
    /*
515
     * Used to indicate that session resumption is not allowed. Applications
516
     * can also set this bit for a new session via not_resumable_session_cb
517
     * to disable session caching and tickets.
518
     */
519
    int not_resumable;
520
    /* Peer raw public key, if available */
521
    EVP_PKEY *peer_rpk;
522
    /* This is the cert and type for the other end. */
523
    X509 *peer;
524
    /* Certificate chain peer sent. */
525
    STACK_OF(X509) *peer_chain;
526
    /*
527
     * when app_verify_callback accepts a session where the peer's
528
     * certificate is not ok, we must remember the error for session reuse:
529
     */
530
    long verify_result; /* only for servers */
531
    OSSL_TIME timeout;
532
    OSSL_TIME time;
533
    OSSL_TIME calc_timeout;
534
    unsigned int compress_meth; /* Need to lookup the method */
535
    const SSL_CIPHER *cipher;
536
    unsigned long cipher_id; /* when ASN.1 loaded, this needs to be used to
537
                              * load the 'cipher' structure */
538
    unsigned int kex_group; /* TLS group from key exchange */
539
    CRYPTO_EX_DATA ex_data; /* application specific data */
540
541
    struct {
542
        char *hostname;
543
        /* RFC4507 info */
544
        unsigned char *tick; /* Session ticket */
545
        size_t ticklen; /* Session ticket length */
546
        /* Session lifetime hint in seconds */
547
        unsigned long tick_lifetime_hint;
548
        uint32_t tick_age_add;
549
        /* Max number of bytes that can be sent as early data */
550
        uint32_t max_early_data;
551
        /* The ALPN protocol selected for this session */
552
        unsigned char *alpn_selected;
553
        size_t alpn_selected_len;
554
        /*
555
         * Maximum Fragment Length as per RFC 4366.
556
         * If this value does not contain RFC 4366 allowed values (1-4) then
557
         * either the Maximum Fragment Length Negotiation failed or was not
558
         * performed at all.
559
         */
560
        uint8_t max_fragment_len_mode;
561
    } ext;
562
#ifndef OPENSSL_NO_SRP
563
    char *srp_username;
564
#endif
565
    unsigned char *ticket_appdata;
566
    size_t ticket_appdata_len;
567
    uint32_t flags;
568
    SSL_CTX *owner;
569
570
    /*
571
     * These are used to make removal of session-ids more efficient and to
572
     * implement a maximum cache size. Access requires protection of ctx->lock.
573
     */
574
    struct ssl_session_st *prev, *next;
575
    CRYPTO_REF_COUNT references;
576
};
577
578
/* Extended master secret support */
579
0
#define SSL_SESS_FLAG_EXTMS 0x1
580
581
#ifndef OPENSSL_NO_SRP
582
583
typedef struct srp_ctx_st {
584
    /* param for all the callbacks */
585
    void *SRP_cb_arg;
586
    /* set client Hello login callback */
587
    int (*TLS_ext_srp_username_callback)(SSL *, int *, void *);
588
    /* set SRP N/g param callback for verification */
589
    int (*SRP_verify_param_callback)(SSL *, void *);
590
    /* set SRP client passwd callback */
591
    char *(*SRP_give_srp_client_pwd_callback)(SSL *, void *);
592
    char *login;
593
    BIGNUM *N, *g, *s, *B, *A;
594
    BIGNUM *a, *b, *v;
595
    char *info;
596
    int strength;
597
    unsigned long srp_Mask;
598
} SRP_CTX;
599
600
#endif
601
602
typedef enum {
603
    SSL_EARLY_DATA_NONE = 0,
604
    SSL_EARLY_DATA_CONNECT_RETRY,
605
    SSL_EARLY_DATA_CONNECTING,
606
    SSL_EARLY_DATA_WRITE_RETRY,
607
    SSL_EARLY_DATA_WRITING,
608
    SSL_EARLY_DATA_WRITE_FLUSH,
609
    SSL_EARLY_DATA_UNAUTH_WRITING,
610
    SSL_EARLY_DATA_FINISHED_WRITING,
611
    SSL_EARLY_DATA_ACCEPT_RETRY,
612
    SSL_EARLY_DATA_ACCEPTING,
613
    SSL_EARLY_DATA_READ_RETRY,
614
    SSL_EARLY_DATA_READING,
615
    SSL_EARLY_DATA_FINISHED_READING
616
} SSL_EARLY_DATA_STATE;
617
618
/*
619
 * We check that the amount of unreadable early data doesn't exceed
620
 * max_early_data. max_early_data is given in plaintext bytes. However if it is
621
 * unreadable then we only know the number of ciphertext bytes. We also don't
622
 * know how much the overhead should be because it depends on the ciphersuite.
623
 * We make a small allowance. We assume 5 records of actual data plus the end
624
 * of early data alert record. Each record has a tag and a content type byte.
625
 * The longest tag length we know of is EVP_GCM_TLS_TAG_LEN. We don't count the
626
 * content of the alert record either which is 2 bytes.
627
 */
628
0
#define EARLY_DATA_CIPHERTEXT_OVERHEAD ((6 * (EVP_GCM_TLS_TAG_LEN + 1)) + 2)
629
630
/*
631
 * The allowance we have between the client's calculated ticket age and our own.
632
 * We allow for 10 seconds. If a ticket is presented and the
633
 * client's age calculation is different by more than this than our own then we
634
 * do not allow that ticket for early_data.
635
 */
636
0
#define TICKET_AGE_ALLOWANCE ossl_seconds2time(10)
637
638
0
#define MAX_COMPRESSIONS_SIZE 255
639
640
typedef struct raw_extension_st {
641
    /* Raw packet data for the extension */
642
    PACKET data;
643
    /* Set to 1 if the extension is present or 0 otherwise */
644
    int present;
645
    /* Set to 1 if we have already parsed the extension or 0 otherwise */
646
    int parsed;
647
    /* The type of this extension, i.e. a TLSEXT_TYPE_* value */
648
    unsigned int type;
649
    /* Track what order extensions are received in (0-based). */
650
    size_t received_order;
651
} RAW_EXTENSION;
652
653
typedef struct {
654
    unsigned int legacy_version;
655
    unsigned char random[SSL3_RANDOM_SIZE];
656
    size_t session_id_len;
657
    unsigned char session_id[SSL_MAX_SSL_SESSION_ID_LENGTH];
658
    size_t dtls_cookie_len;
659
    unsigned char dtls_cookie[DTLS1_COOKIE_LENGTH];
660
    PACKET ciphersuites;
661
    size_t compressions_len;
662
    unsigned char compressions[MAX_COMPRESSIONS_SIZE];
663
    PACKET extensions;
664
    size_t pre_proc_exts_len;
665
    RAW_EXTENSION *pre_proc_exts;
666
} CLIENTHELLO_MSG;
667
668
/*
669
 * Extension index values NOTE: Any updates to these defines should be mirrored
670
 * with equivalent updates to ext_defs in extensions.c
671
 */
672
typedef enum tlsext_index_en {
673
    TLSEXT_IDX_renegotiate,
674
    TLSEXT_IDX_server_name,
675
    TLSEXT_IDX_max_fragment_length,
676
    TLSEXT_IDX_srp,
677
    TLSEXT_IDX_ec_point_formats,
678
    TLSEXT_IDX_supported_groups,
679
    TLSEXT_IDX_session_ticket,
680
    TLSEXT_IDX_status_request,
681
    TLSEXT_IDX_next_proto_neg,
682
    TLSEXT_IDX_application_layer_protocol_negotiation,
683
    TLSEXT_IDX_use_srtp,
684
    TLSEXT_IDX_encrypt_then_mac,
685
    TLSEXT_IDX_signed_certificate_timestamp,
686
    TLSEXT_IDX_extended_master_secret,
687
    TLSEXT_IDX_signature_algorithms_cert,
688
    TLSEXT_IDX_post_handshake_auth,
689
    TLSEXT_IDX_client_cert_type,
690
    TLSEXT_IDX_server_cert_type,
691
    TLSEXT_IDX_signature_algorithms,
692
    TLSEXT_IDX_supported_versions,
693
    TLSEXT_IDX_psk_kex_modes,
694
    TLSEXT_IDX_key_share,
695
    TLSEXT_IDX_cookie,
696
    TLSEXT_IDX_cryptopro_bug,
697
    TLSEXT_IDX_compress_certificate,
698
    TLSEXT_IDX_early_data,
699
    TLSEXT_IDX_certificate_authorities,
700
    TLSEXT_IDX_ech,
701
    TLSEXT_IDX_outer_extensions,
702
    TLSEXT_IDX_grease1,
703
    TLSEXT_IDX_grease2,
704
    TLSEXT_IDX_padding,
705
    TLSEXT_IDX_psk,
706
    /* Dummy index - must always be the last entry */
707
    TLSEXT_IDX_num_builtins
708
} TLSEXT_INDEX;
709
710
/* RFC 8701 GREASE seed indices */
711
0
#define OSSL_GREASE_CIPHER 0
712
0
#define OSSL_GREASE_GROUP 1
713
0
#define OSSL_GREASE_EXT1 2
714
0
#define OSSL_GREASE_EXT2 3
715
#define OSSL_GREASE_VERSION 4
716
#define OSSL_GREASE_SIGALG 5
717
0
#define OSSL_GREASE_LAST_INDEX 5
718
719
DEFINE_LHASH_OF_EX(SSL_SESSION);
720
/* Needed in ssl_cert.c */
721
DEFINE_LHASH_OF_EX(X509_NAME);
722
723
0
#define TLSEXT_KEYNAME_LENGTH 16
724
#define TLSEXT_TICK_KEY_LENGTH 32
725
726
typedef struct ssl_ctx_ext_secure_st {
727
    unsigned char tick_hmac_key[TLSEXT_TICK_KEY_LENGTH];
728
    unsigned char tick_aes_key[TLSEXT_TICK_KEY_LENGTH];
729
} SSL_CTX_EXT_SECURE;
730
731
/*
732
 * Helper function for HMAC
733
 * The structure should be considered opaque, it will change once the low
734
 * level deprecated calls are removed.  At that point it can be replaced
735
 * by EVP_MAC_CTX and most of the functions converted to macros or inlined
736
 * directly.
737
 */
738
typedef struct ssl_hmac_st {
739
    EVP_MAC_CTX *ctx;
740
#ifndef OPENSSL_NO_DEPRECATED_3_0
741
    HMAC_CTX *old_ctx;
742
#endif
743
} SSL_HMAC;
744
745
SSL_HMAC *ssl_hmac_construct(const SSL_CTX *ctx, SSL_HMAC *hctx);
746
void ssl_hmac_destruct(SSL_HMAC *ctx);
747
#ifndef OPENSSL_NO_DEPRECATED_3_0
748
HMAC_CTX *ssl_hmac_get0_HMAC_CTX(SSL_HMAC *ctx);
749
#endif
750
EVP_MAC_CTX *ssl_hmac_get0_EVP_MAC_CTX(SSL_HMAC *ctx);
751
int ssl_hmac_init(SSL_HMAC *ctx, void *key, size_t len, char *md);
752
int ssl_hmac_update(SSL_HMAC *ctx, const unsigned char *data, size_t len);
753
int ssl_hmac_final(SSL_HMAC *ctx, unsigned char *md, size_t *len,
754
    size_t max_size);
755
size_t ssl_hmac_size(const SSL_HMAC *ctx);
756
757
int ssl_get_EC_curve_nid(const EVP_PKEY *pkey);
758
__owur int tls13_set_encoded_pub_key(EVP_PKEY *pkey,
759
    const unsigned char *enckey,
760
    size_t enckeylen);
761
762
typedef struct tls_group_info_st {
763
    char *tlsname; /* Curve Name as in TLS specs */
764
    char *realname; /* Curve Name according to provider */
765
    char *algorithm; /* Algorithm name to fetch */
766
    unsigned int secbits; /* Bits of security (from SP800-57) */
767
    uint16_t group_id; /* Group ID */
768
    int mintls; /* Minimum TLS version, -1 unsupported */
769
    int maxtls; /* Maximum TLS version (or 0 for undefined) */
770
    int mindtls; /* Minimum DTLS version, -1 unsupported */
771
    int maxdtls; /* Maximum DTLS version (or 0 for undefined) */
772
    char is_kem; /* Mode for this Group: 0 is KEX, 1 is KEM */
773
} TLS_GROUP_INFO;
774
775
typedef struct tls_sigalg_info_st {
776
    char *name; /* name as in IANA TLS specs */
777
    uint16_t code_point; /* IANA-specified code point of sigalg-name */
778
    char *sigalg_name; /* (combined) sigalg name */
779
    char *sigalg_oid; /* (combined) sigalg OID */
780
    char *sig_name; /* pure signature algorithm name */
781
    char *sig_oid; /* pure signature algorithm OID */
782
    char *hash_name; /* hash algorithm name */
783
    char *hash_oid; /* hash algorithm OID */
784
    char *keytype; /* keytype name */
785
    char *keytype_oid; /* keytype OID */
786
    unsigned int secbits; /* Bits of security (from SP800-57) */
787
    int mintls; /* Minimum TLS version, -1 unsupported */
788
    int maxtls; /* Maximum TLS version (or 0 for undefined) */
789
    int mindtls; /* Minimum DTLS version, -1 unsupported */
790
    int maxdtls; /* Maximum DTLS version (or 0 for undefined) */
791
} TLS_SIGALG_INFO;
792
793
/*
794
 * Structure containing table entry of certificate info corresponding to
795
 * CERT_PKEY entries
796
 */
797
typedef struct {
798
    int pkey_nid; /* NID of public key algorithm */
799
    uint32_t amask; /* authmask corresponding to key type */
800
} SSL_CERT_LOOKUP;
801
802
/* flags values */
803
#define TLS_GROUP_TYPE 0x0000000FU /* Mask for group type */
804
#define TLS_GROUP_CURVE_PRIME 0x00000001U
805
#define TLS_GROUP_CURVE_CHAR2 0x00000002U
806
#define TLS_GROUP_CURVE_CUSTOM 0x00000004U
807
#define TLS_GROUP_FFDHE 0x00000008U
808
#define TLS_GROUP_ONLY_FOR_TLS1_3 0x00000010U
809
810
#define TLS_GROUP_FFDHE_FOR_TLS1_3 (TLS_GROUP_FFDHE | TLS_GROUP_ONLY_FOR_TLS1_3)
811
812
#if !defined(OPENSSL_NO_TLS1)      \
813
    || !defined(OPENSSL_NO_TLS1_1) \
814
    || !defined(OPENSSL_NO_TLS1_2) \
815
    || !defined(OPENSSL_NO_DTLS1)  \
816
    || !defined(OPENSSL_NO_DTLS1_2)
817
#define OPENSSL_HAVE_TLS1PRF
818
#endif
819
820
struct ssl_ctx_st {
821
    OSSL_LIB_CTX *libctx;
822
823
    const SSL_METHOD *method;
824
    STACK_OF(SSL_CIPHER) *cipher_list;
825
    /* same as above but sorted for lookup */
826
    STACK_OF(SSL_CIPHER) *cipher_list_by_id;
827
    /* TLSv1.3 specific ciphersuites */
828
    STACK_OF(SSL_CIPHER) *tls13_ciphersuites;
829
    struct x509_store_st /* X509_STORE */ *cert_store;
830
    LHASH_OF(SSL_SESSION) *sessions;
831
    EVP_MAC *hmac;
832
    EVP_MD *sha256;
833
    EVP_CIPHER *tktenc;
834
#ifdef OPENSSL_HAVE_TLS1PRF
835
    EVP_KDF *tls1prf;
836
#endif
837
    /*
838
     * Most session-ids that will be cached, default is
839
     * SSL_SESSION_CACHE_MAX_SIZE_DEFAULT. 0 is unlimited.
840
     */
841
    size_t session_cache_size;
842
    struct ssl_session_st *session_cache_head;
843
    struct ssl_session_st *session_cache_tail;
844
    /*
845
     * This can have one of 2 values, ored together, SSL_SESS_CACHE_CLIENT,
846
     * SSL_SESS_CACHE_SERVER, Default is SSL_SESSION_CACHE_SERVER, which
847
     * means only SSL_accept will cache SSL_SESSIONS.
848
     */
849
    uint32_t session_cache_mode;
850
    /*
851
     * If timeout is not 0, it is the default timeout value set when
852
     * SSL_new() is called.  This has been put in to make life easier to set
853
     * things up
854
     */
855
    OSSL_TIME session_timeout;
856
    /*
857
     * If this callback is not null, it will be called each time a session id
858
     * is added to the cache.  If this function returns 1, it means that the
859
     * callback will do an SSL_SESSION_free() when it has finished using it.
860
     * Otherwise, on 0, it means the callback has finished with it. If
861
     * remove_session_cb is not null, it will be called when a session-id is
862
     * removed from the cache.  After the call, OpenSSL will
863
     * SSL_SESSION_free() it.
864
     */
865
    int (*new_session_cb)(struct ssl_st *ssl, SSL_SESSION *sess);
866
    void (*remove_session_cb)(struct ssl_ctx_st *ctx, SSL_SESSION *sess);
867
    SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl,
868
        const unsigned char *data, int len,
869
        int *copy);
870
    struct {
871
        TSAN_QUALIFIER int sess_connect; /* SSL new conn - started */
872
        TSAN_QUALIFIER int sess_connect_renegotiate; /* SSL reneg - requested */
873
        TSAN_QUALIFIER int sess_connect_good; /* SSL new conne/reneg - finished */
874
        TSAN_QUALIFIER int sess_accept; /* SSL new accept - started */
875
        TSAN_QUALIFIER int sess_accept_renegotiate; /* SSL reneg - requested */
876
        TSAN_QUALIFIER int sess_accept_good; /* SSL accept/reneg - finished */
877
        TSAN_QUALIFIER int sess_miss; /* session lookup misses */
878
        TSAN_QUALIFIER int sess_timeout; /* reuse attempt on timeouted session */
879
        TSAN_QUALIFIER int sess_cache_full; /* session removed due to full cache */
880
        TSAN_QUALIFIER int sess_hit; /* session reuse actually done */
881
        TSAN_QUALIFIER int sess_cb_hit; /* session-id that was not in
882
                                         * the cache was passed back via
883
                                         * the callback. This indicates
884
                                         * that the application is
885
                                         * supplying session-id's from
886
                                         * other processes - spooky
887
                                         * :-) */
888
    } stats;
889
#ifdef TSAN_REQUIRES_LOCKING
890
    CRYPTO_RWLOCK *tsan_lock;
891
#endif
892
893
    CRYPTO_REF_COUNT references;
894
895
    /* if defined, these override the X509_verify_cert() calls */
896
    int (*app_verify_callback)(X509_STORE_CTX *, void *);
897
    void *app_verify_arg;
898
    /*
899
     * before OpenSSL 0.9.7, 'app_verify_arg' was ignored
900
     * ('app_verify_callback' was called with just one argument)
901
     */
902
903
    /* Default password callback. */
904
    pem_password_cb *default_passwd_callback;
905
906
    /* Default password callback user data. */
907
    void *default_passwd_callback_userdata;
908
909
    /* get client cert callback */
910
    int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey);
911
912
    /* cookie generate callback */
913
    int (*app_gen_cookie_cb)(SSL *ssl, unsigned char *cookie,
914
        unsigned int *cookie_len);
915
916
    /* verify cookie callback */
917
    int (*app_verify_cookie_cb)(SSL *ssl, const unsigned char *cookie,
918
        unsigned int cookie_len);
919
920
    /* TLS1.3 app-controlled cookie generate callback */
921
    int (*gen_stateless_cookie_cb)(SSL *ssl, unsigned char *cookie,
922
        size_t *cookie_len);
923
924
    /* TLS1.3 verify app-controlled cookie callback */
925
    int (*verify_stateless_cookie_cb)(SSL *ssl, const unsigned char *cookie,
926
        size_t cookie_len);
927
928
    CRYPTO_EX_DATA ex_data;
929
930
    const EVP_MD *md5; /* For SSLv3/TLSv1 'ssl3-md5' */
931
    const EVP_MD *sha1; /* For SSLv3/TLSv1 'ssl3-sha1' */
932
933
    STACK_OF(X509) *extra_certs;
934
    STACK_OF(SSL_COMP) *comp_methods; /* stack of SSL_COMP, SSLv3/TLSv1 */
935
936
    /* Default values used when no per-SSL value is defined follow */
937
938
    /* used if SSL's info_callback is NULL */
939
    void (*info_callback)(const SSL *ssl, int type, int val);
940
941
    /*
942
     * What we put in certificate_authorities extension for TLS 1.3
943
     * (ClientHello and CertificateRequest) or just client cert requests for
944
     * earlier versions. If client_ca_names is populated then it is only used
945
     * for client cert requests, and in preference to ca_names.
946
     */
947
    STACK_OF(X509_NAME) *ca_names;
948
    STACK_OF(X509_NAME) *client_ca_names;
949
950
    /*
951
     * Default values to use in SSL structures follow (these are copied by
952
     * SSL_new)
953
     */
954
955
    uint64_t options;
956
    uint32_t mode;
957
    int min_proto_version;
958
    int max_proto_version;
959
    size_t max_cert_list;
960
961
    struct cert_st /* CERT */ *cert;
962
    SSL_CERT_LOOKUP *ssl_cert_info;
963
    int read_ahead;
964
965
    /* callback that allows applications to peek at protocol messages */
966
    ossl_msg_cb msg_callback;
967
    void *msg_callback_arg;
968
969
    uint32_t verify_mode;
970
    size_t sid_ctx_length;
971
    unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];
972
    /* called 'verify_callback' in the SSL */
973
    int (*default_verify_callback)(int ok, X509_STORE_CTX *ctx);
974
975
    /* Default generate session ID callback. */
976
    GEN_SESSION_CB generate_session_id;
977
978
    X509_VERIFY_PARAM *param;
979
980
    int quiet_shutdown;
981
982
#ifndef OPENSSL_NO_CT
983
    CTLOG_STORE *ctlog_store; /* CT Log Store */
984
    /*
985
     * Validates that the SCTs (Signed Certificate Timestamps) are sufficient.
986
     * If they are not, the connection should be aborted.
987
     */
988
    ssl_ct_validation_cb ct_validation_callback;
989
    void *ct_validation_callback_arg;
990
#endif
991
992
    /*
993
     * If we're using more than one pipeline how should we divide the data
994
     * up between the pipes?
995
     */
996
    size_t split_send_fragment;
997
    /*
998
     * Maximum amount of data to send in one fragment. actual record size can
999
     * be more than this due to padding and MAC overheads.
1000
     */
1001
    size_t max_send_fragment;
1002
1003
    /* Up to how many pipelines should we use? If 0 then 1 is assumed */
1004
    size_t max_pipelines;
1005
1006
    /* The default read buffer length to use (0 means not set) */
1007
    size_t default_read_buf_len;
1008
1009
    /* ClientHello callback.  Mostly for extensions, but not entirely. */
1010
    SSL_client_hello_cb_fn client_hello_cb;
1011
    void *client_hello_cb_arg;
1012
1013
    /* Callback to announce new pending ssl objects in the accept queue */
1014
    SSL_new_pending_conn_cb_fn new_pending_conn_cb;
1015
    void *new_pending_conn_arg;
1016
1017
    /* TLS extensions. */
1018
    struct {
1019
        /* TLS extensions servername callback */
1020
        int (*servername_cb)(SSL *, int *, void *);
1021
        void *servername_arg;
1022
        /* RFC 4507 session ticket keys */
1023
        unsigned char tick_key_name[TLSEXT_KEYNAME_LENGTH];
1024
        SSL_CTX_EXT_SECURE *secure;
1025
#ifndef OPENSSL_NO_DEPRECATED_3_0
1026
        /* Callback to support customisation of ticket key setting */
1027
        int (*ticket_key_cb)(SSL *ssl,
1028
            unsigned char *name, unsigned char *iv,
1029
            EVP_CIPHER_CTX *ectx, HMAC_CTX *hctx, int enc);
1030
#endif
1031
        int (*ticket_key_evp_cb)(SSL *ssl,
1032
            unsigned char *name, unsigned char *iv,
1033
            EVP_CIPHER_CTX *ectx, EVP_MAC_CTX *hctx,
1034
            int enc);
1035
1036
        /* certificate status request info */
1037
        /* Callback for status request */
1038
        int (*status_cb)(SSL *ssl, void *arg);
1039
        void *status_arg;
1040
        /* ext status type used for CSR extension (OCSP Stapling) */
1041
        int status_type;
1042
        /* RFC 4366 Maximum Fragment Length Negotiation */
1043
        uint8_t max_fragment_len_mode;
1044
1045
        /* EC extension values inherited by SSL structure */
1046
        size_t ecpointformats_len;
1047
        unsigned char *ecpointformats;
1048
1049
        size_t supportedgroups_len;
1050
        uint16_t *supportedgroups;
1051
1052
        size_t keyshares_len;
1053
        uint16_t *keyshares;
1054
1055
        size_t tuples_len; /* Number of group tuples */
1056
        size_t *tuples; /* Number of groups in each group tuple */
1057
1058
        /*
1059
         * ALPN information (we are in the process of transitioning from NPN to
1060
         * ALPN.)
1061
         */
1062
1063
        /*-
1064
         * For a server, this contains a callback function that allows the
1065
         * server to select the protocol for the connection.
1066
         *   out: on successful return, this must point to the raw protocol
1067
         *        name (without the length prefix).
1068
         *   outlen: on successful return, this contains the length of |*out|.
1069
         *   in: points to the client's list of supported protocols in
1070
         *       wire-format.
1071
         *   inlen: the length of |in|.
1072
         */
1073
        int (*alpn_select_cb)(SSL *s,
1074
            const unsigned char **out,
1075
            unsigned char *outlen,
1076
            const unsigned char *in,
1077
            unsigned int inlen, void *arg);
1078
        void *alpn_select_cb_arg;
1079
1080
        /*
1081
         * For a client, this contains the list of supported protocols in wire
1082
         * format.
1083
         */
1084
        unsigned char *alpn;
1085
        size_t alpn_len;
1086
1087
#ifndef OPENSSL_NO_NEXTPROTONEG
1088
        /* Next protocol negotiation information */
1089
1090
        /*
1091
         * For a server, this contains a callback function by which the set of
1092
         * advertised protocols can be provided.
1093
         */
1094
        SSL_CTX_npn_advertised_cb_func npn_advertised_cb;
1095
        void *npn_advertised_cb_arg;
1096
        /*
1097
         * For a client, this contains a callback function that selects the next
1098
         * protocol from the list provided by the server.
1099
         */
1100
        SSL_CTX_npn_select_cb_func npn_select_cb;
1101
        void *npn_select_cb_arg;
1102
#endif
1103
1104
        unsigned char cookie_hmac_key[SHA256_DIGEST_LENGTH];
1105
#ifndef OPENSSL_NO_ECH
1106
        OSSL_ECH_CTX ech;
1107
#endif
1108
    } ext;
1109
1110
#ifndef OPENSSL_NO_PSK
1111
    SSL_psk_client_cb_func psk_client_callback;
1112
    SSL_psk_server_cb_func psk_server_callback;
1113
#endif
1114
    SSL_psk_find_session_cb_func psk_find_session_cb;
1115
    SSL_psk_use_session_cb_func psk_use_session_cb;
1116
1117
#ifndef OPENSSL_NO_SRP
1118
    SRP_CTX srp_ctx; /* ctx for SRP authentication */
1119
#endif
1120
1121
    /* Shared DANE context */
1122
    struct dane_ctx_st dane;
1123
1124
#ifndef OPENSSL_NO_SRTP
1125
    /* SRTP profiles we are willing to do from RFC 5764 */
1126
    STACK_OF(SRTP_PROTECTION_PROFILE) *srtp_profiles;
1127
#endif
1128
    /*
1129
     * Callback for disabling session caching and ticket support on a session
1130
     * basis, depending on the chosen cipher.
1131
     */
1132
    int (*not_resumable_session_cb)(SSL *ssl, int is_forward_secure);
1133
1134
    CRYPTO_RWLOCK *lock;
1135
1136
    /*
1137
     * Callback for logging key material for use with debugging tools like
1138
     * Wireshark. The callback should log `line` followed by a newline.
1139
     */
1140
    SSL_CTX_keylog_cb_func keylog_callback;
1141
1142
    /*
1143
     * Private flag for internal key logging based on SSLKEYLOG env
1144
     */
1145
#ifndef OPENSSL_NO_SSLKEYLOG
1146
    uint32_t do_sslkeylog;
1147
#endif
1148
1149
    /*
1150
     * The maximum number of bytes advertised in session tickets that can be
1151
     * sent as early data.
1152
     */
1153
    uint32_t max_early_data;
1154
1155
    /*
1156
     * The maximum number of bytes of early data that a server will tolerate
1157
     * (which should be at least as much as max_early_data).
1158
     */
1159
    uint32_t recv_max_early_data;
1160
1161
    /* TLS1.3 padding callback */
1162
    size_t (*record_padding_cb)(SSL *s, int type, size_t len, void *arg);
1163
    void *record_padding_arg;
1164
    size_t block_padding;
1165
    size_t hs_padding;
1166
1167
    /* Session ticket appdata */
1168
    SSL_CTX_generate_session_ticket_fn generate_ticket_cb;
1169
    SSL_CTX_decrypt_session_ticket_fn decrypt_ticket_cb;
1170
    void *ticket_cb_data;
1171
1172
    /* The number of TLS1.3 tickets to automatically send */
1173
    size_t num_tickets;
1174
1175
    /* Callback to determine if early_data is acceptable or not */
1176
    SSL_allow_early_data_cb_fn allow_early_data_cb;
1177
    void *allow_early_data_cb_data;
1178
1179
    /* Do we advertise Post-handshake auth support? */
1180
    int pha_enabled;
1181
1182
    /* Callback for SSL async handling */
1183
    SSL_async_callback_fn async_cb;
1184
    void *async_cb_arg;
1185
1186
    char *propq;
1187
1188
    int ssl_mac_pkey_id[SSL_MD_NUM_IDX];
1189
    const EVP_CIPHER *ssl_cipher_methods[SSL_ENC_NUM_IDX];
1190
    const EVP_MD *ssl_digest_methods[SSL_MD_NUM_IDX];
1191
    size_t ssl_mac_secret_size[SSL_MD_NUM_IDX];
1192
1193
    size_t sigalg_lookup_cache_len;
1194
    size_t tls12_sigalgs_len;
1195
    /* Cache of all sigalgs we know and whether they are available or not */
1196
    struct sigalg_lookup_st *sigalg_lookup_cache;
1197
    /* List of all sigalgs (code points) available, incl. from providers */
1198
    uint16_t *tls12_sigalgs;
1199
1200
    TLS_GROUP_INFO *group_list;
1201
    size_t group_list_len;
1202
    size_t group_list_max_len;
1203
1204
    TLS_SIGALG_INFO *sigalg_list;
1205
    size_t sigalg_list_len;
1206
    size_t sigalg_list_max_len;
1207
1208
    /* masks of disabled algorithms */
1209
    uint32_t disabled_enc_mask;
1210
    uint32_t disabled_mac_mask;
1211
    uint32_t disabled_mkey_mask;
1212
    uint32_t disabled_auth_mask;
1213
1214
#ifndef OPENSSL_NO_COMP_ALG
1215
    /* certificate compression preferences */
1216
    int cert_comp_prefs[TLSEXT_comp_cert_limit];
1217
#endif
1218
1219
    /* Certificate Type stuff - for RPK vs X.509 */
1220
    unsigned char *client_cert_type;
1221
    size_t client_cert_type_len;
1222
    unsigned char *server_cert_type;
1223
    size_t server_cert_type_len;
1224
1225
#ifndef OPENSSL_NO_QUIC
1226
    uint64_t domain_flags;
1227
    SSL_TOKEN_STORE *tokencache;
1228
#endif
1229
1230
#ifndef OPENSSL_NO_QLOG
1231
    char *qlog_title; /* Session title for qlog */
1232
#endif
1233
};
1234
1235
typedef struct ossl_quic_tls_callbacks_st {
1236
    int (*crypto_send_cb)(SSL *s, const unsigned char *buf, size_t buf_len,
1237
        size_t *consumed, void *arg);
1238
    int (*crypto_recv_rcd_cb)(SSL *s, const unsigned char **buf,
1239
        size_t *bytes_read, void *arg);
1240
    int (*crypto_release_rcd_cb)(SSL *s, size_t bytes_read, void *arg);
1241
    int (*yield_secret_cb)(SSL *s, uint32_t prot_level, int direction,
1242
        const unsigned char *secret, size_t secret_len,
1243
        void *arg);
1244
    int (*got_transport_params_cb)(SSL *s, const unsigned char *params,
1245
        size_t params_len,
1246
        void *arg);
1247
    int (*alert_cb)(SSL *s, unsigned char alert_code, void *arg);
1248
} OSSL_QUIC_TLS_CALLBACKS;
1249
1250
typedef struct cert_pkey_st CERT_PKEY;
1251
1252
0
#define SSL_TYPE_SSL_CONNECTION 0
1253
0
#define SSL_TYPE_QUIC_CONNECTION 0x80
1254
0
#define SSL_TYPE_QUIC_XSO 0x81
1255
0
#define SSL_TYPE_QUIC_LISTENER 0x82
1256
0
#define SSL_TYPE_QUIC_DOMAIN 0x83
1257
1258
0
#define SSL_TYPE_IS_QUIC(x) (((x) & 0x80) != 0)
1259
1260
struct ssl_st {
1261
    int type;
1262
    SSL_CTX *ctx;
1263
    const SSL_METHOD *defltmeth;
1264
    const SSL_METHOD *method;
1265
    CRYPTO_REF_COUNT references;
1266
    CRYPTO_RWLOCK *lock;
1267
    /* extra application data */
1268
    CRYPTO_EX_DATA ex_data;
1269
};
1270
1271
struct ssl_connection_st {
1272
    /* type identifier and common data */
1273
    struct ssl_st ssl;
1274
1275
    /*
1276
     * The actual end user's SSL object. Could be different to this one for
1277
     * QUIC
1278
     */
1279
    SSL *user_ssl;
1280
1281
    /*
1282
     * protocol version (one of SSL2_VERSION, SSL3_VERSION, TLS1_VERSION,
1283
     * DTLS1_VERSION)
1284
     */
1285
    int version;
1286
    /*
1287
     * There are 2 BIO's even though they are normally both the same.  This
1288
     * is so data can be read and written to different handlers
1289
     */
1290
    /* used by SSL_read */
1291
    BIO *rbio;
1292
    /* used by SSL_write */
1293
    BIO *wbio;
1294
    /* used during session-id reuse to concatenate messages */
1295
    BIO *bbio;
1296
    /*
1297
     * This holds a variable that indicates what we were doing when a 0 or -1
1298
     * is returned.  This is needed for non-blocking IO so we know what
1299
     * request needs re-doing when in SSL_accept or SSL_connect
1300
     */
1301
    int rwstate;
1302
    int (*handshake_func)(SSL *);
1303
    /*
1304
     * Imagine that here's a boolean member "init" that is switched as soon
1305
     * as SSL_set_{accept/connect}_state is called for the first time, so
1306
     * that "state" and "handshake_func" are properly initialized.  But as
1307
     * handshake_func is == 0 until then, we use this test instead of an
1308
     * "init" member.
1309
     */
1310
    /* are we the server side? */
1311
    int server;
1312
    /*
1313
     * Generate a new session or reuse an old one.
1314
     * NB: For servers, the 'new' session may actually be a previously
1315
     * cached session or even the previous session unless
1316
     * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION is set
1317
     */
1318
    int new_session;
1319
    /* don't send shutdown packets */
1320
    int quiet_shutdown;
1321
    /* we have shut things down, 0x01 sent, 0x02 for received */
1322
    int shutdown;
1323
    /* Timestamps used to calculate the handshake RTT */
1324
    OSSL_TIME ts_msg_write;
1325
    OSSL_TIME ts_msg_read;
1326
    /* where we are */
1327
    OSSL_STATEM statem;
1328
    SSL_EARLY_DATA_STATE early_data_state;
1329
    BUF_MEM *init_buf; /* buffer used during init */
1330
    void *init_msg; /* pointer to handshake message body, set by
1331
                     * tls_get_message_header() */
1332
    size_t init_num; /* amount read/written */
1333
    size_t init_off; /* amount read/written */
1334
1335
    size_t ssl_pkey_num;
1336
1337
    /* QUIC TLS fields */
1338
    OSSL_QUIC_TLS_CALLBACKS qtcb;
1339
    void *qtarg;
1340
    QUIC_TLS *qtls;
1341
1342
    struct {
1343
        long flags;
1344
        unsigned char server_random[SSL3_RANDOM_SIZE];
1345
        unsigned char client_random[SSL3_RANDOM_SIZE];
1346
1347
        /* used during startup, digest all incoming/outgoing packets */
1348
        BIO *handshake_buffer;
1349
        /*
1350
         * When handshake digest is determined, buffer is hashed and
1351
         * freed and MD_CTX for the required digest is stored here.
1352
         */
1353
        EVP_MD_CTX *handshake_dgst;
1354
        /*
1355
         * Set whenever an expected ChangeCipherSpec message is processed.
1356
         * Unset when the peer's Finished message is received.
1357
         * Unexpected ChangeCipherSpec messages trigger a fatal alert.
1358
         */
1359
        int change_cipher_spec;
1360
        int warn_alert;
1361
        int fatal_alert;
1362
        /*
1363
         * we allow one fatal and one warning alert to be outstanding, send close
1364
         * alert via the warning alert
1365
         */
1366
        int alert_dispatch;
1367
        unsigned char send_alert[2];
1368
        /*
1369
         * This flag is set when we should renegotiate ASAP, basically when there
1370
         * is no more data in the read or write buffers
1371
         */
1372
        int renegotiate;
1373
        int total_renegotiations;
1374
        int num_renegotiations;
1375
        int in_read_app_data;
1376
1377
        struct {
1378
            /* actually only need to be 16+20 for SSLv3 and 12 for TLS */
1379
            unsigned char finish_md[EVP_MAX_MD_SIZE * 2];
1380
            size_t finish_md_len;
1381
            unsigned char peer_finish_md[EVP_MAX_MD_SIZE * 2];
1382
            size_t peer_finish_md_len;
1383
            size_t message_size;
1384
            int message_type;
1385
            /* used to hold the new cipher we are going to use */
1386
            const SSL_CIPHER *new_cipher;
1387
            EVP_PKEY *pkey; /* holds short lived key exchange key */
1388
            /* holds the array of short lived key exchange key (pointers) */
1389
            EVP_PKEY *ks_pkey[OPENSSL_CLIENT_MAX_KEY_SHARES];
1390
            uint16_t ks_group_id[OPENSSL_CLIENT_MAX_KEY_SHARES]; /* The IDs of the keyshare keys */
1391
            size_t num_ks_pkey; /* how many keyshares are there */
1392
            /* used for certificate requests */
1393
            int cert_req;
1394
            /* Certificate types in certificate request message. */
1395
            uint8_t *ctype;
1396
            size_t ctype_len;
1397
            /* Certificate authorities list peer sent */
1398
            STACK_OF(X509_NAME) *peer_ca_names;
1399
            size_t key_block_length;
1400
            unsigned char *key_block;
1401
            const EVP_CIPHER *new_sym_enc;
1402
            const EVP_MD *new_hash;
1403
            int new_mac_pkey_type;
1404
            size_t new_mac_secret_size;
1405
#ifndef OPENSSL_NO_COMP
1406
            const SSL_COMP *new_compression;
1407
#else
1408
            char *new_compression;
1409
#endif
1410
            int cert_request;
1411
            /* Raw values of the cipher list from a client */
1412
            unsigned char *ciphers_raw;
1413
            size_t ciphers_rawlen;
1414
            /* Temporary storage for premaster secret */
1415
            unsigned char *pms;
1416
            size_t pmslen;
1417
#ifndef OPENSSL_NO_PSK
1418
            /* Temporary storage for PSK key */
1419
            unsigned char *psk;
1420
            size_t psklen;
1421
#endif
1422
            /* Signature algorithm we actually use */
1423
            const struct sigalg_lookup_st *sigalg;
1424
            /* Pointer to certificate we use */
1425
            CERT_PKEY *cert;
1426
            /*
1427
             * signature algorithms peer reports: e.g. supported signature
1428
             * algorithms extension for server or as part of a certificate
1429
             * request for client.
1430
             * Keep track of the algorithms for TLS and X.509 usage separately.
1431
             */
1432
            uint16_t *peer_sigalgs;
1433
            uint16_t *peer_cert_sigalgs;
1434
            /* Size of above arrays */
1435
            size_t peer_sigalgslen;
1436
            size_t peer_cert_sigalgslen;
1437
            /* Sigalg peer actually uses */
1438
            const struct sigalg_lookup_st *peer_sigalg;
1439
            /*
1440
             * Set if corresponding CERT_PKEY can be used with current
1441
             * SSL session: e.g. appropriate curve, signature algorithms etc.
1442
             * If zero it can't be used at all.
1443
             */
1444
            uint32_t *valid_flags;
1445
            /*
1446
             * For servers the following masks are for the key and auth algorithms
1447
             * that are supported by the certs below. For clients they are masks of
1448
             * *disabled* algorithms based on the current session.
1449
             */
1450
            uint32_t mask_k;
1451
            uint32_t mask_a;
1452
            /*
1453
             * The following are used by the client to see if a cipher is allowed or
1454
             * not.  It contains the minimum and maximum version the client's using
1455
             * based on what it knows so far.
1456
             */
1457
            int min_ver;
1458
            int max_ver;
1459
        } tmp;
1460
1461
        /* Connection binding to prevent renegotiation attacks */
1462
        unsigned char previous_client_finished[EVP_MAX_MD_SIZE];
1463
        size_t previous_client_finished_len;
1464
        unsigned char previous_server_finished[EVP_MAX_MD_SIZE];
1465
        size_t previous_server_finished_len;
1466
        int send_connection_binding;
1467
1468
#ifndef OPENSSL_NO_NEXTPROTONEG
1469
        /*
1470
         * Set if we saw the Next Protocol Negotiation extension from our peer.
1471
         */
1472
        int npn_seen;
1473
#endif
1474
1475
        /*
1476
         * ALPN information (we are in the process of transitioning from NPN to
1477
         * ALPN.)
1478
         */
1479
1480
        /*
1481
         * In a server these point to the selected ALPN protocol after the
1482
         * ClientHello has been processed. In a client these contain the protocol
1483
         * that the server selected once the ServerHello has been processed.
1484
         */
1485
        unsigned char *alpn_selected;
1486
        size_t alpn_selected_len;
1487
        /* used by the server to know what options were proposed */
1488
        unsigned char *alpn_proposed;
1489
        size_t alpn_proposed_len;
1490
        /* used by the client to know if it actually sent alpn */
1491
        int alpn_sent;
1492
1493
        /*
1494
         * This is set to true if we believe that this is a version of Safari
1495
         * running on OS X 10.6 or newer. We wish to know this because Safari on
1496
         * 10.8 .. 10.8.3 has broken ECDHE-ECDSA support.
1497
         */
1498
        char is_probably_safari;
1499
1500
        /*
1501
         * Track whether we did a key exchange this handshake or not, so
1502
         * SSL_get_negotiated_group() knows whether to fall back to the
1503
         * value in the SSL_SESSION.
1504
         */
1505
        char did_kex;
1506
        /* For clients: peer temporary key */
1507
        /* The group_id for the key exchange key */
1508
        uint16_t group_id;
1509
        EVP_PKEY *peer_tmp;
1510
        /* The cached group_id candidate for the key exchange key */
1511
        uint16_t group_id_candidate;
1512
    } s3;
1513
1514
    struct dtls1_state_st *d1; /* DTLSv1 variables */
1515
    /* callback that allows applications to peek at protocol messages */
1516
    void (*msg_callback)(int write_p, int version, int content_type,
1517
        const void *buf, size_t len, SSL *ssl, void *arg);
1518
    void *msg_callback_arg;
1519
    int hit; /* reusing a previous session */
1520
    X509_VERIFY_PARAM *param;
1521
    /* Per connection DANE state */
1522
    SSL_DANE dane;
1523
    /* crypto */
1524
    STACK_OF(SSL_CIPHER) *peer_ciphers;
1525
    STACK_OF(SSL_CIPHER) *cipher_list;
1526
    STACK_OF(SSL_CIPHER) *cipher_list_by_id;
1527
    /* TLSv1.3 specific ciphersuites */
1528
    STACK_OF(SSL_CIPHER) *tls13_ciphersuites;
1529
    /*
1530
     * These are the ones being used, the ones in SSL_SESSION are the ones to
1531
     * be 'copied' into these ones
1532
     */
1533
    uint32_t mac_flags;
1534
    /*
1535
     * The TLS1.3 secrets.
1536
     */
1537
    unsigned char early_secret[EVP_MAX_MD_SIZE];
1538
    unsigned char handshake_secret[EVP_MAX_MD_SIZE];
1539
    unsigned char master_secret[EVP_MAX_MD_SIZE];
1540
    unsigned char resumption_master_secret[EVP_MAX_MD_SIZE];
1541
    unsigned char client_finished_secret[EVP_MAX_MD_SIZE];
1542
    unsigned char server_finished_secret[EVP_MAX_MD_SIZE];
1543
    unsigned char server_finished_hash[EVP_MAX_MD_SIZE];
1544
    unsigned char handshake_traffic_hash[EVP_MAX_MD_SIZE];
1545
    unsigned char client_app_traffic_secret[EVP_MAX_MD_SIZE];
1546
    unsigned char server_app_traffic_secret[EVP_MAX_MD_SIZE];
1547
    unsigned char exporter_master_secret[EVP_MAX_MD_SIZE];
1548
    unsigned char early_exporter_master_secret[EVP_MAX_MD_SIZE];
1549
1550
    /* session info */
1551
    /* client cert? */
1552
    /* This is used to hold the server certificate used */
1553
    struct cert_st /* CERT */ *cert;
1554
1555
    /*
1556
     * The hash of all messages prior to the CertificateVerify, and the length
1557
     * of that hash.
1558
     */
1559
    unsigned char cert_verify_hash[EVP_MAX_MD_SIZE];
1560
    size_t cert_verify_hash_len;
1561
1562
    /* Flag to indicate whether we should send a HelloRetryRequest or not */
1563
    enum { SSL_HRR_NONE = 0,
1564
        SSL_HRR_PENDING,
1565
        SSL_HRR_COMPLETE } hello_retry_request;
1566
1567
    /*
1568
     * the session_id_context is used to ensure sessions are only reused in
1569
     * the appropriate context
1570
     */
1571
    size_t sid_ctx_length;
1572
    unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];
1573
    /* This can also be in the session once a session is established */
1574
    SSL_SESSION *session;
1575
    /* TLSv1.3 PSK session */
1576
    SSL_SESSION *psksession;
1577
    unsigned char *psksession_id;
1578
    size_t psksession_id_len;
1579
    /* Default generate session ID callback. */
1580
    GEN_SESSION_CB generate_session_id;
1581
    /*
1582
     * The temporary TLSv1.3 session id. This isn't really a session id at all
1583
     * but is a random value sent in the legacy session id field.
1584
     */
1585
    unsigned char tmp_session_id[SSL_MAX_SSL_SESSION_ID_LENGTH];
1586
    size_t tmp_session_id_len;
1587
    /* Used in SSL3 */
1588
    /*
1589
     * 0 don't care about verify failure.
1590
     * 1 fail if verify fails
1591
     */
1592
    uint32_t verify_mode;
1593
    /* fail if callback returns 0 */
1594
    int (*verify_callback)(int ok, X509_STORE_CTX *ctx);
1595
    /* optional informational callback */
1596
    void (*info_callback)(const SSL *ssl, int type, int val);
1597
    /* error bytes to be written */
1598
    int error;
1599
    /* actual code */
1600
    int error_code;
1601
#ifndef OPENSSL_NO_PSK
1602
    SSL_psk_client_cb_func psk_client_callback;
1603
    SSL_psk_server_cb_func psk_server_callback;
1604
#endif
1605
    SSL_psk_find_session_cb_func psk_find_session_cb;
1606
    SSL_psk_use_session_cb_func psk_use_session_cb;
1607
1608
    /* Verified chain of peer */
1609
    STACK_OF(X509) *verified_chain;
1610
    long verify_result;
1611
    /*
1612
     * What we put in certificate_authorities extension for TLS 1.3
1613
     * (ClientHello and CertificateRequest) or just client cert requests for
1614
     * earlier versions. If client_ca_names is populated then it is only used
1615
     * for client cert requests, and in preference to ca_names.
1616
     */
1617
    STACK_OF(X509_NAME) *ca_names;
1618
    STACK_OF(X509_NAME) *client_ca_names;
1619
    /* protocol behaviour */
1620
    uint64_t options;
1621
    /* API behaviour */
1622
    uint32_t mode;
1623
    int min_proto_version;
1624
    int max_proto_version;
1625
    size_t max_cert_list;
1626
    int first_packet;
1627
    /*
1628
     * What was passed in ClientHello.legacy_version. Used for RSA pre-master
1629
     * secret and SSLv3/TLS (<=1.2) rollback check
1630
     */
1631
    int client_version;
1632
    /*
1633
     * If we're using more than one pipeline how should we divide the data
1634
     * up between the pipes?
1635
     */
1636
    size_t split_send_fragment;
1637
    /*
1638
     * Maximum amount of data to send in one fragment. actual record size can
1639
     * be more than this due to padding and MAC overheads.
1640
     */
1641
    size_t max_send_fragment;
1642
    /* Up to how many pipelines should we use? If 0 then 1 is assumed */
1643
    size_t max_pipelines;
1644
1645
    struct {
1646
        /* Built-in extension flags */
1647
        uint8_t extflags[TLSEXT_IDX_num_builtins];
1648
        /* TLS extension debug callback */
1649
        void (*debug_cb)(SSL *s, int client_server, int type,
1650
            const unsigned char *data, int len, void *arg);
1651
        void *debug_arg;
1652
        char *hostname;
1653
        /* certificate status request info */
1654
        /* Status type or -1 if no status type */
1655
        int status_type;
1656
        /* Raw extension data, if seen */
1657
        unsigned char *scts;
1658
        /* Length of raw extension data, if seen */
1659
        uint16_t scts_len;
1660
        /* Expect OCSP CertificateStatus message */
1661
        int status_expected;
1662
1663
        struct {
1664
            /* OCSP status request only */
1665
            STACK_OF(OCSP_RESPID) *ids;
1666
            X509_EXTENSIONS *exts;
1667
            /* OCSP response received or to be sent */
1668
            unsigned char *resp;
1669
            size_t resp_len;
1670
            STACK_OF(OCSP_RESPONSE) *resp_ex;
1671
        } ocsp;
1672
1673
        /* RFC4507 session ticket expected to be received or sent */
1674
        int ticket_expected;
1675
        /* TLS 1.3 tickets requested by the application. */
1676
        int extra_tickets_expected;
1677
1678
        /* our list */
1679
        size_t ecpointformats_len;
1680
        unsigned char *ecpointformats;
1681
        /* peer's list */
1682
        size_t peer_ecpointformats_len;
1683
        unsigned char *peer_ecpointformats;
1684
1685
        /* our list */
1686
        size_t supportedgroups_len;
1687
        uint16_t *supportedgroups;
1688
        /* peer's list */
1689
        size_t peer_supportedgroups_len;
1690
        uint16_t *peer_supportedgroups;
1691
1692
        /* key shares */
1693
        size_t keyshares_len;
1694
        uint16_t *keyshares;
1695
        /* supported groups tuples */
1696
        size_t tuples_len;
1697
        size_t *tuples;
1698
1699
        /* TLS Session Ticket extension override */
1700
        TLS_SESSION_TICKET_EXT *session_ticket;
1701
        /* TLS Session Ticket extension callback */
1702
        tls_session_ticket_ext_cb_fn session_ticket_cb;
1703
        void *session_ticket_cb_arg;
1704
        /* TLS pre-shared secret session resumption */
1705
        tls_session_secret_cb_fn session_secret_cb;
1706
        void *session_secret_cb_arg;
1707
        /*
1708
         * For a client, this contains the list of supported protocols in wire
1709
         * format.
1710
         */
1711
        unsigned char *alpn;
1712
        size_t alpn_len;
1713
        /*
1714
         * Next protocol negotiation. For the client, this is the protocol that
1715
         * we sent in NextProtocol and is set when handling ServerHello
1716
         * extensions. For a server, this is the client's selected_protocol from
1717
         * NextProtocol and is set when handling the NextProtocol message, before
1718
         * the Finished message.
1719
         */
1720
        unsigned char *npn;
1721
        size_t npn_len;
1722
1723
        /* The available PSK key exchange modes */
1724
        int psk_kex_mode;
1725
1726
        /* Set to one if we have negotiated ETM */
1727
        int use_etm;
1728
1729
        /* Are we expecting to receive early data? */
1730
        int early_data;
1731
        /* Is the session suitable for early data? */
1732
        int early_data_ok;
1733
1734
        /* May be sent by a server in HRR. Must be echoed back in ClientHello */
1735
        unsigned char *tls13_cookie;
1736
        size_t tls13_cookie_len;
1737
        /* Have we received a cookie from the client? */
1738
        int cookieok;
1739
1740
        /*
1741
         * Maximum Fragment Length as per RFC 4366.
1742
         * If this member contains one of the allowed values (1-4)
1743
         * then we should include Maximum Fragment Length Negotiation
1744
         * extension in Client Hello.
1745
         * Please note that value of this member does not have direct
1746
         * effect. The actual (binding) value is stored in SSL_SESSION,
1747
         * as this extension is optional on server side.
1748
         */
1749
        uint8_t max_fragment_len_mode;
1750
1751
        /*
1752
         * On the client side the number of ticket identities we sent in the
1753
         * ClientHello. On the server side the identity of the ticket we
1754
         * selected.
1755
         */
1756
        int tick_identity;
1757
1758
        /* This is the list of algorithms the peer supports that we also support */
1759
        int compress_certificate_from_peer[TLSEXT_comp_cert_limit];
1760
        /* indicate that we sent the extension, so we'll accept it */
1761
        int compress_certificate_sent;
1762
1763
        uint8_t client_cert_type;
1764
        uint8_t client_cert_type_ctos;
1765
        uint8_t server_cert_type;
1766
        uint8_t server_cert_type_ctos;
1767
1768
#ifndef OPENSSL_NO_ECH
1769
        OSSL_ECH_CONN ech;
1770
#endif
1771
1772
        /* RFC 8701 GREASE */
1773
        uint8_t grease_seed[OSSL_GREASE_LAST_INDEX + 1];
1774
        int grease_seeded;
1775
    } ext;
1776
1777
    /*
1778
     * Parsed form of the ClientHello, kept around across client_hello_cb
1779
     * calls.
1780
     */
1781
    CLIENTHELLO_MSG *clienthello;
1782
1783
    /*-
1784
     * no further mod of servername
1785
     * 0 : call the servername extension callback.
1786
     * 1 : prepare 2, allow last ack just after in server callback.
1787
     * 2 : don't call servername callback, no ack in server hello
1788
     */
1789
    int servername_done;
1790
#ifndef OPENSSL_NO_CT
1791
    /*
1792
     * Validates that the SCTs (Signed Certificate Timestamps) are sufficient.
1793
     * If they are not, the connection should be aborted.
1794
     */
1795
    ssl_ct_validation_cb ct_validation_callback;
1796
    /* User-supplied argument that is passed to the ct_validation_callback */
1797
    void *ct_validation_callback_arg;
1798
    /*
1799
     * Consolidated stack of SCTs from all sources.
1800
     * Lazily populated by CT_get_peer_scts(SSL*)
1801
     */
1802
    STACK_OF(SCT) *scts;
1803
    /* Have we attempted to find/parse SCTs yet? */
1804
    int scts_parsed;
1805
#endif
1806
    SSL_CTX *session_ctx; /* initial ctx, used to store sessions */
1807
#ifndef OPENSSL_NO_SRTP
1808
    /* What we'll do */
1809
    STACK_OF(SRTP_PROTECTION_PROFILE) *srtp_profiles;
1810
    /* What's been chosen */
1811
    SRTP_PROTECTION_PROFILE *srtp_profile;
1812
#endif
1813
    /*-
1814
     * 1 if we are renegotiating.
1815
     * 2 if we are a server and are inside a handshake
1816
     * (i.e. not just sending a HelloRequest)
1817
     */
1818
    int renegotiate;
1819
    /* If sending a KeyUpdate is pending */
1820
    int key_update;
1821
    /* Post-handshake authentication state */
1822
    SSL_PHA_STATE post_handshake_auth;
1823
    int pha_enabled;
1824
    uint8_t *pha_context;
1825
    size_t pha_context_len;
1826
    int certreqs_sent;
1827
    EVP_MD_CTX *pha_dgst; /* this is just the digest through ClientFinished */
1828
1829
#ifndef OPENSSL_NO_SRP
1830
    /* ctx for SRP authentication */
1831
    SRP_CTX srp_ctx;
1832
#endif
1833
    /*
1834
     * Callback for disabling session caching and ticket support on a session
1835
     * basis, depending on the chosen cipher.
1836
     */
1837
    int (*not_resumable_session_cb)(SSL *ssl, int is_forward_secure);
1838
1839
    /* Record layer data */
1840
    RECORD_LAYER rlayer;
1841
1842
    /* Default password callback. */
1843
    pem_password_cb *default_passwd_callback;
1844
    /* Default password callback user data. */
1845
    void *default_passwd_callback_userdata;
1846
    /* Async Job info */
1847
    ASYNC_JOB *job;
1848
    ASYNC_WAIT_CTX *waitctx;
1849
    size_t asyncrw;
1850
1851
    /*
1852
     * The maximum number of bytes advertised in session tickets that can be
1853
     * sent as early data.
1854
     */
1855
    uint32_t max_early_data;
1856
    /*
1857
     * The maximum number of bytes of early data that a server will tolerate
1858
     * (which should be at least as much as max_early_data).
1859
     */
1860
    uint32_t recv_max_early_data;
1861
1862
    /*
1863
     * The number of bytes of early data received so far. If we accepted early
1864
     * data then this is a count of the plaintext bytes. If we rejected it then
1865
     * this is a count of the ciphertext bytes.
1866
     */
1867
    uint32_t early_data_count;
1868
1869
    /* The number of TLS1.3 tickets to automatically send */
1870
    size_t num_tickets;
1871
    /* The number of TLS1.3 tickets actually sent so far */
1872
    size_t sent_tickets;
1873
    /* The next nonce value to use when we send a ticket on this connection */
1874
    uint64_t next_ticket_nonce;
1875
1876
    /* Callback to determine if early_data is acceptable or not */
1877
    SSL_allow_early_data_cb_fn allow_early_data_cb;
1878
    void *allow_early_data_cb_data;
1879
1880
    /* Callback for SSL async handling */
1881
    SSL_async_callback_fn async_cb;
1882
    void *async_cb_arg;
1883
1884
    /*
1885
     * Signature algorithms shared by client and server: cached because these
1886
     * are used most often.
1887
     */
1888
    const struct sigalg_lookup_st **shared_sigalgs;
1889
    size_t shared_sigalgslen;
1890
1891
#ifndef OPENSSL_NO_COMP_ALG
1892
    /* certificate compression preferences */
1893
    int cert_comp_prefs[TLSEXT_comp_cert_limit];
1894
#endif
1895
1896
    /* Certificate Type stuff - for RPK vs X.509 */
1897
    unsigned char *client_cert_type;
1898
    size_t client_cert_type_len;
1899
    unsigned char *server_cert_type;
1900
    size_t server_cert_type_len;
1901
};
1902
1903
/*
1904
 * Structure containing table entry of values associated with the signature
1905
 * algorithms (signature scheme) extension
1906
 */
1907
typedef struct sigalg_lookup_st {
1908
    /* TLS 1.3 signature scheme name */
1909
    const char *name;
1910
    /* TLS 1.2 signature scheme name */
1911
    const char *name12;
1912
    /* Raw value used in extension */
1913
    uint16_t sigalg;
1914
    /* NID of hash algorithm or NID_undef if no hash */
1915
    int hash;
1916
    /* Index of hash algorithm or -1 if no hash algorithm */
1917
    int hash_idx;
1918
    /* NID of signature algorithm */
1919
    int sig;
1920
    /* Index of signature algorithm */
1921
    int sig_idx;
1922
    /* Combined hash and signature NID, if any */
1923
    int sigandhash;
1924
    /* Required public key curve (ECDSA only) */
1925
    int curve;
1926
    /* Whether this signature algorithm is actually available for use */
1927
    int available;
1928
    /* Whether this signature algorithm is by default advertised */
1929
    int advertise;
1930
    /* Supported protocol ranges */
1931
    int mintls;
1932
    int maxtls;
1933
    int mindtls;
1934
    int maxdtls;
1935
} SIGALG_LOOKUP;
1936
1937
/* DTLS structures */
1938
1939
#ifndef OPENSSL_NO_SCTP
1940
#define DTLS1_SCTP_AUTH_LABEL "EXPORTER_DTLS_OVER_SCTP"
1941
#endif
1942
1943
/* Max MTU overhead we know about so far is 40 for IPv6 + 8 for UDP */
1944
0
#define DTLS1_MAX_MTU_OVERHEAD 48
1945
1946
struct dtls1_retransmit_state {
1947
    const OSSL_RECORD_METHOD *wrlmethod;
1948
    OSSL_RECORD_LAYER *wrl;
1949
};
1950
1951
struct hm_header_st {
1952
    unsigned char type;
1953
    size_t msg_len;
1954
    unsigned short seq;
1955
    size_t frag_off;
1956
    size_t frag_len;
1957
    unsigned int is_ccs;
1958
    struct dtls1_retransmit_state saved_retransmit_state;
1959
};
1960
1961
typedef struct hm_fragment_st {
1962
    struct hm_header_st msg_header;
1963
    unsigned char *fragment;
1964
    unsigned char *reassembly;
1965
} hm_fragment;
1966
1967
typedef struct pqueue_st pqueue;
1968
typedef struct pitem_st pitem;
1969
1970
struct pitem_st {
1971
    unsigned char priority[8]; /* 64-bit value in big-endian encoding */
1972
    void *data;
1973
    pitem *next;
1974
};
1975
1976
typedef struct pitem_st *piterator;
1977
1978
pitem *pitem_new(unsigned char *prio64be, void *data);
1979
void pitem_free(pitem *item);
1980
pqueue *pqueue_new(void);
1981
void pqueue_free(pqueue *pq);
1982
pitem *pqueue_insert(pqueue *pq, pitem *item);
1983
pitem *pqueue_peek(pqueue *pq);
1984
pitem *pqueue_pop(pqueue *pq);
1985
pitem *pqueue_find(pqueue *pq, unsigned char *prio64be);
1986
pitem *pqueue_iterator(pqueue *pq);
1987
pitem *pqueue_next(piterator *iter);
1988
size_t pqueue_size(pqueue *pq);
1989
1990
typedef struct dtls1_state_st {
1991
    unsigned char cookie[DTLS1_COOKIE_LENGTH];
1992
    size_t cookie_len;
1993
    unsigned int cookie_verified;
1994
    /* handshake message numbers */
1995
    unsigned short handshake_write_seq;
1996
    unsigned short next_handshake_write_seq;
1997
    unsigned short handshake_read_seq;
1998
    /* Buffered handshake messages */
1999
    pqueue *buffered_messages;
2000
    /* Buffered (sent) handshake records */
2001
    pqueue *sent_messages;
2002
    size_t link_mtu; /* max on-the-wire DTLS packet size */
2003
    size_t mtu; /* max DTLS packet size */
2004
    struct hm_header_st w_msg_hdr;
2005
    struct hm_header_st r_msg_hdr;
2006
    /* Number of alerts received so far */
2007
    unsigned int timeout_num_alerts;
2008
    /*
2009
     * Indicates when the last handshake msg sent will timeout
2010
     */
2011
    OSSL_TIME next_timeout;
2012
    /* Timeout duration */
2013
    unsigned int timeout_duration_us;
2014
2015
    unsigned int retransmitting;
2016
    unsigned int has_change_cipher_spec;
2017
#ifndef OPENSSL_NO_SCTP
2018
    int shutdown_received;
2019
#endif
2020
2021
    DTLS_timer_cb timer_cb;
2022
2023
} DTLS1_STATE;
2024
2025
/*
2026
 * From ECC-TLS draft, used in encoding the curve type in ECParameters
2027
 */
2028
#define EXPLICIT_PRIME_CURVE_TYPE 1
2029
#define EXPLICIT_CHAR2_CURVE_TYPE 2
2030
0
#define NAMED_CURVE_TYPE 3
2031
2032
#ifndef OPENSSL_NO_COMP_ALG
2033
struct ossl_comp_cert_st {
2034
    unsigned char *data;
2035
    size_t len;
2036
    size_t orig_len;
2037
    CRYPTO_REF_COUNT references;
2038
    int alg;
2039
};
2040
typedef struct ossl_comp_cert_st OSSL_COMP_CERT;
2041
2042
void OSSL_COMP_CERT_free(OSSL_COMP_CERT *c);
2043
int OSSL_COMP_CERT_up_ref(OSSL_COMP_CERT *c);
2044
#endif
2045
2046
struct cert_pkey_st {
2047
    X509 *x509;
2048
    EVP_PKEY *privatekey;
2049
    /* Chain for this certificate */
2050
    STACK_OF(X509) *chain;
2051
    /*-
2052
     * serverinfo data for this certificate.  The data is in TLS Extension
2053
     * wire format, specifically it's a series of records like:
2054
     *   uint16_t extension_type; // (RFC 5246, 7.4.1.4, Extension)
2055
     *   uint16_t length;
2056
     *   uint8_t data[length];
2057
     */
2058
    unsigned char *serverinfo;
2059
    size_t serverinfo_length;
2060
#ifndef OPENSSL_NO_COMP_ALG
2061
    /* Compressed certificate data - index 0 is unused */
2062
    OSSL_COMP_CERT *comp_cert[TLSEXT_comp_cert_limit];
2063
    int cert_comp_used;
2064
#endif
2065
};
2066
/* Retrieve Suite B flags */
2067
0
#define tls1_suiteb(s) (s->cert->cert_flags & SSL_CERT_FLAG_SUITEB_128_LOS)
2068
/* Uses to check strict mode: suite B modes are always strict */
2069
#define SSL_CERT_FLAGS_CHECK_TLS_STRICT \
2070
0
    (SSL_CERT_FLAG_SUITEB_128_LOS | SSL_CERT_FLAG_TLS_STRICT)
2071
2072
typedef enum {
2073
    ENDPOINT_CLIENT = 0,
2074
    ENDPOINT_SERVER,
2075
    ENDPOINT_BOTH
2076
} ENDPOINT;
2077
2078
typedef struct {
2079
    unsigned short ext_type;
2080
    ENDPOINT role;
2081
    /* The context which this extension applies to */
2082
    unsigned int context;
2083
    /*
2084
     * Per-connection flags relating to this extension type: not used if
2085
     * part of an SSL_CTX structure.
2086
     */
2087
    uint32_t ext_flags;
2088
    SSL_custom_ext_add_cb_ex add_cb;
2089
    SSL_custom_ext_free_cb_ex free_cb;
2090
    void *add_arg;
2091
    SSL_custom_ext_parse_cb_ex parse_cb;
2092
    void *parse_arg;
2093
} custom_ext_method;
2094
2095
/* ext_flags values */
2096
2097
/*
2098
 * Indicates an extension has been received. Used to check for unsolicited or
2099
 * duplicate extensions.
2100
 */
2101
0
#define SSL_EXT_FLAG_RECEIVED 0x1
2102
/*
2103
 * Indicates an extension has been sent: used to enable sending of
2104
 * corresponding ServerHello extension.
2105
 */
2106
0
#define SSL_EXT_FLAG_SENT 0x2
2107
2108
typedef struct {
2109
    custom_ext_method *meths;
2110
    size_t meths_count;
2111
} custom_ext_methods;
2112
2113
typedef struct cert_st {
2114
    /* Current active set */
2115
    /*
2116
     * ALWAYS points to an element of the pkeys array
2117
     * Probably it would make more sense to store
2118
     * an index, not a pointer.
2119
     */
2120
    CERT_PKEY *key;
2121
2122
    EVP_PKEY *dh_tmp;
2123
    DH *(*dh_tmp_cb)(SSL *ssl, int is_export, int keysize);
2124
    int dh_tmp_auto;
2125
    /* Flags related to certificates */
2126
    uint32_t cert_flags;
2127
    CERT_PKEY *pkeys;
2128
    size_t ssl_pkey_num;
2129
    /* Custom certificate types sent in certificate request message. */
2130
    uint8_t *ctype;
2131
    size_t ctype_len;
2132
    /*
2133
     * supported signature algorithms. When set on a client this is sent in
2134
     * the client hello as the supported signature algorithms extension. For
2135
     * servers it represents the signature algorithms we are willing to use.
2136
     */
2137
    uint16_t *conf_sigalgs;
2138
    /* Size of above array */
2139
    size_t conf_sigalgslen;
2140
    /*
2141
     * Client authentication signature algorithms, if not set then uses
2142
     * conf_sigalgs. On servers these will be the signature algorithms sent
2143
     * to the client in a certificate request for TLS 1.2. On a client this
2144
     * represents the signature algorithms we are willing to use for client
2145
     * authentication.
2146
     */
2147
    uint16_t *client_sigalgs;
2148
    /* Size of above array */
2149
    size_t client_sigalgslen;
2150
    /*
2151
     * Certificate setup callback: if set is called whenever a certificate
2152
     * may be required (client or server). the callback can then examine any
2153
     * appropriate parameters and setup any certificates required. This
2154
     * allows advanced applications to select certificates on the fly: for
2155
     * example based on supported signature algorithms or curves.
2156
     */
2157
    int (*cert_cb)(SSL *ssl, void *arg);
2158
    void *cert_cb_arg;
2159
    /*
2160
     * Optional X509_STORE for chain building or certificate validation If
2161
     * NULL the parent SSL_CTX store is used instead.
2162
     */
2163
    X509_STORE *chain_store;
2164
    X509_STORE *verify_store;
2165
    /* Custom extensions */
2166
    custom_ext_methods custext;
2167
    /* Security callback */
2168
    int (*sec_cb)(const SSL *s, const SSL_CTX *ctx, int op, int bits, int nid,
2169
        void *other, void *ex);
2170
    /* Security level */
2171
    int sec_level;
2172
    void *sec_ex;
2173
#ifndef OPENSSL_NO_PSK
2174
    /* If not NULL psk identity hint to use for servers */
2175
    char *psk_identity_hint;
2176
#endif
2177
    CRYPTO_REF_COUNT references; /* >1 only if SSL_copy_session_id is used */
2178
} CERT;
2179
2180
/*
2181
 * This is for the SSLv3/TLSv1.0 differences in crypto/hash stuff It is a bit
2182
 * of a mess of functions, but hell, think of it as an opaque structure :-)
2183
 */
2184
typedef struct ssl3_enc_method {
2185
    int (*setup_key_block)(SSL_CONNECTION *);
2186
    int (*generate_master_secret)(SSL_CONNECTION *, unsigned char *,
2187
        unsigned char *, size_t, size_t *);
2188
    int (*change_cipher_state)(SSL_CONNECTION *, int);
2189
    size_t (*final_finish_mac)(SSL_CONNECTION *, const char *, size_t,
2190
        unsigned char *);
2191
    const char *client_finished_label;
2192
    size_t client_finished_label_len;
2193
    const char *server_finished_label;
2194
    size_t server_finished_label_len;
2195
    int (*alert_value)(int);
2196
    int (*export_keying_material)(SSL_CONNECTION *, unsigned char *, size_t,
2197
        const char *, size_t,
2198
        const unsigned char *, size_t,
2199
        int use_context);
2200
    /* Various flags indicating protocol version requirements */
2201
    uint32_t enc_flags;
2202
    /* Set the handshake header */
2203
    int (*set_handshake_header)(SSL_CONNECTION *s, WPACKET *pkt, int type);
2204
    /* Close construction of the handshake message */
2205
    int (*close_construct_packet)(SSL_CONNECTION *s, WPACKET *pkt, int htype);
2206
    /* Write out handshake message */
2207
    int (*do_write)(SSL_CONNECTION *s);
2208
} SSL3_ENC_METHOD;
2209
2210
#define ssl_set_handshake_header(s, pkt, htype) \
2211
0
    SSL_CONNECTION_GET_SSL(s)->method->ssl3_enc->set_handshake_header((s), (pkt), (htype))
2212
#define ssl_close_construct_packet(s, pkt, htype) \
2213
0
    SSL_CONNECTION_GET_SSL(s)->method->ssl3_enc->close_construct_packet((s), (pkt), (htype))
2214
0
#define ssl_do_write(s) SSL_CONNECTION_GET_SSL(s)->method->ssl3_enc->do_write(s)
2215
2216
/* Values for enc_flags */
2217
2218
/* Uses signature algorithms extension */
2219
0
#define SSL_ENC_FLAG_SIGALGS 0x2
2220
/* Uses SHA256 default PRF */
2221
0
#define SSL_ENC_FLAG_SHA256_PRF 0x4
2222
/* Is DTLS */
2223
0
#define SSL_ENC_FLAG_DTLS 0x8
2224
/*
2225
 * Allow TLS 1.2 ciphersuites: applies to DTLS 1.2 as well as TLS 1.2: may
2226
 * apply to others in future.
2227
 */
2228
0
#define SSL_ENC_FLAG_TLS1_2_CIPHERS 0x10
2229
2230
typedef enum downgrade_en {
2231
    DOWNGRADE_NONE,
2232
    DOWNGRADE_TO_1_2,
2233
    DOWNGRADE_TO_1_1
2234
} DOWNGRADE;
2235
2236
/*
2237
 * Dummy status type for the status_type extension. Indicates no status type
2238
 * set
2239
 */
2240
0
#define TLSEXT_STATUSTYPE_nothing -1
2241
2242
/* Known PSK key exchange modes */
2243
0
#define TLSEXT_KEX_MODE_KE 0x00
2244
0
#define TLSEXT_KEX_MODE_KE_DHE 0x01
2245
2246
/*
2247
 * Internal representations of key exchange modes
2248
 */
2249
0
#define TLSEXT_KEX_MODE_FLAG_NONE 0
2250
0
#define TLSEXT_KEX_MODE_FLAG_KE 1
2251
0
#define TLSEXT_KEX_MODE_FLAG_KE_DHE 2
2252
2253
0
#define SSL_USE_PSS(s) (s->s3.tmp.peer_sigalg != NULL && s->s3.tmp.peer_sigalg->sig == EVP_PKEY_RSA_PSS)
2254
2255
/* TLSv1.3 downgrade protection sentinel values */
2256
extern const unsigned char tls11downgrade[8];
2257
extern const unsigned char tls12downgrade[8];
2258
2259
extern const SSL3_ENC_METHOD ssl3_undef_enc_method;
2260
2261
__owur const SSL_METHOD *tlsv1_method(void);
2262
__owur const SSL_METHOD *tlsv1_server_method(void);
2263
__owur const SSL_METHOD *tlsv1_client_method(void);
2264
__owur const SSL_METHOD *tlsv1_1_method(void);
2265
__owur const SSL_METHOD *tlsv1_1_server_method(void);
2266
__owur const SSL_METHOD *tlsv1_1_client_method(void);
2267
__owur const SSL_METHOD *tlsv1_2_method(void);
2268
__owur const SSL_METHOD *tlsv1_2_server_method(void);
2269
__owur const SSL_METHOD *tlsv1_2_client_method(void);
2270
__owur const SSL_METHOD *tlsv1_3_method(void);
2271
__owur const SSL_METHOD *tlsv1_3_server_method(void);
2272
__owur const SSL_METHOD *tlsv1_3_client_method(void);
2273
__owur const SSL_METHOD *dtlsv1_method(void);
2274
__owur const SSL_METHOD *dtlsv1_server_method(void);
2275
__owur const SSL_METHOD *dtlsv1_client_method(void);
2276
__owur const SSL_METHOD *dtls_bad_ver_client_method(void);
2277
__owur const SSL_METHOD *dtlsv1_2_method(void);
2278
__owur const SSL_METHOD *dtlsv1_2_server_method(void);
2279
__owur const SSL_METHOD *dtlsv1_2_client_method(void);
2280
2281
extern const SSL3_ENC_METHOD TLSv1_enc_data;
2282
extern const SSL3_ENC_METHOD TLSv1_1_enc_data;
2283
extern const SSL3_ENC_METHOD TLSv1_2_enc_data;
2284
extern const SSL3_ENC_METHOD TLSv1_3_enc_data;
2285
extern const SSL3_ENC_METHOD DTLSv1_enc_data;
2286
extern const SSL3_ENC_METHOD DTLSv1_2_enc_data;
2287
2288
/*
2289
 * Flags for SSL methods
2290
 */
2291
#define SSL_METHOD_NO_FIPS (1U << 0)
2292
0
#define SSL_METHOD_NO_SUITEB (1U << 1)
2293
2294
#define IMPLEMENT_tls_meth_func(version, flags, mask, func_name, s_accept, \
2295
    s_connect, enc_data)                                                   \
2296
    const SSL_METHOD *func_name(void)                                      \
2297
0
    {                                                                      \
2298
0
        static const SSL_METHOD func_name##_data = {                       \
2299
0
            version,                                                       \
2300
0
            flags,                                                         \
2301
0
            mask,                                                          \
2302
0
            ossl_ssl_connection_new,                                       \
2303
0
            ossl_ssl_connection_free,                                      \
2304
0
            ossl_ssl_connection_reset,                                     \
2305
0
            tls1_new,                                                      \
2306
0
            tls1_clear,                                                    \
2307
0
            tls1_free,                                                     \
2308
0
            s_accept,                                                      \
2309
0
            s_connect,                                                     \
2310
0
            ssl3_read,                                                     \
2311
0
            ssl3_peek,                                                     \
2312
0
            ssl3_write,                                                    \
2313
0
            ssl3_shutdown,                                                 \
2314
0
            ssl3_renegotiate,                                              \
2315
0
            ssl3_renegotiate_check,                                        \
2316
0
            ssl3_read_bytes,                                               \
2317
0
            ssl3_write_bytes,                                              \
2318
0
            ssl3_dispatch_alert,                                           \
2319
0
            ssl3_ctrl,                                                     \
2320
0
            ssl3_ctx_ctrl,                                                 \
2321
0
            ssl3_get_cipher_by_char,                                       \
2322
0
            ssl3_put_cipher_by_char,                                       \
2323
0
            ssl3_pending,                                                  \
2324
0
            ssl3_num_ciphers,                                              \
2325
0
            ssl3_get_cipher,                                               \
2326
0
            tls1_default_timeout,                                          \
2327
0
            &enc_data,                                                     \
2328
0
            ssl_undefined_void_function,                                   \
2329
0
            ssl3_callback_ctrl,                                            \
2330
0
            ssl3_ctx_callback_ctrl,                                        \
2331
0
        };                                                                 \
2332
0
        return &func_name##_data;                                          \
2333
0
    }
Unexecuted instantiation: TLS_method
Unexecuted instantiation: tlsv1_3_method
Unexecuted instantiation: tlsv1_2_method
Unexecuted instantiation: tlsv1_1_method
Unexecuted instantiation: tlsv1_method
Unexecuted instantiation: TLS_server_method
Unexecuted instantiation: tlsv1_3_server_method
Unexecuted instantiation: tlsv1_2_server_method
Unexecuted instantiation: tlsv1_1_server_method
Unexecuted instantiation: tlsv1_server_method
Unexecuted instantiation: TLS_client_method
Unexecuted instantiation: tlsv1_3_client_method
Unexecuted instantiation: tlsv1_2_client_method
Unexecuted instantiation: tlsv1_1_client_method
Unexecuted instantiation: tlsv1_client_method
2334
2335
#define IMPLEMENT_dtls1_meth_func(version, flags, mask, func_name, s_accept, \
2336
    s_connect, enc_data)                                                     \
2337
    const SSL_METHOD *func_name(void)                                        \
2338
0
    {                                                                        \
2339
0
        static const SSL_METHOD func_name##_data = {                         \
2340
0
            version,                                                         \
2341
0
            flags,                                                           \
2342
0
            mask,                                                            \
2343
0
            ossl_ssl_connection_new,                                         \
2344
0
            ossl_ssl_connection_free,                                        \
2345
0
            ossl_ssl_connection_reset,                                       \
2346
0
            dtls1_new,                                                       \
2347
0
            dtls1_clear,                                                     \
2348
0
            dtls1_free,                                                      \
2349
0
            s_accept,                                                        \
2350
0
            s_connect,                                                       \
2351
0
            ssl3_read,                                                       \
2352
0
            ssl3_peek,                                                       \
2353
0
            ssl3_write,                                                      \
2354
0
            dtls1_shutdown,                                                  \
2355
0
            ssl3_renegotiate,                                                \
2356
0
            ssl3_renegotiate_check,                                          \
2357
0
            dtls1_read_bytes,                                                \
2358
0
            dtls1_write_app_data_bytes,                                      \
2359
0
            dtls1_dispatch_alert,                                            \
2360
0
            dtls1_ctrl,                                                      \
2361
0
            ssl3_ctx_ctrl,                                                   \
2362
0
            ssl3_get_cipher_by_char,                                         \
2363
0
            ssl3_put_cipher_by_char,                                         \
2364
0
            ssl3_pending,                                                    \
2365
0
            ssl3_num_ciphers,                                                \
2366
0
            ssl3_get_cipher,                                                 \
2367
0
            dtls1_default_timeout,                                           \
2368
0
            &enc_data,                                                       \
2369
0
            ssl_undefined_void_function,                                     \
2370
0
            ssl3_callback_ctrl,                                              \
2371
0
            ssl3_ctx_callback_ctrl,                                          \
2372
0
        };                                                                   \
2373
0
        return &func_name##_data;                                            \
2374
0
    }
Unexecuted instantiation: dtlsv1_method
Unexecuted instantiation: dtlsv1_2_method
Unexecuted instantiation: DTLS_method
Unexecuted instantiation: dtlsv1_server_method
Unexecuted instantiation: dtlsv1_2_server_method
Unexecuted instantiation: DTLS_server_method
Unexecuted instantiation: dtlsv1_client_method
Unexecuted instantiation: dtls_bad_ver_client_method
Unexecuted instantiation: dtlsv1_2_client_method
Unexecuted instantiation: DTLS_client_method
2375
2376
struct openssl_ssl_test_functions {
2377
    int (*p_ssl_init_wbio_buffer)(SSL_CONNECTION *s);
2378
};
2379
2380
const char *ssl_protocol_to_string(int version);
2381
2382
static ossl_inline int tls12_rpk_and_privkey(const SSL_CONNECTION *sc, int idx)
2383
0
{
2384
    /*
2385
     * This is to check for special cases when using RPK with just
2386
     * a private key, and NO CERTIFICATE
2387
     */
2388
0
    return ((sc->server && sc->ext.server_cert_type == TLSEXT_cert_type_rpk)
2389
0
               || (!sc->server && sc->ext.client_cert_type == TLSEXT_cert_type_rpk))
2390
0
        && sc->cert->pkeys[idx].privatekey != NULL
2391
0
        && sc->cert->pkeys[idx].x509 == NULL;
2392
0
}
Unexecuted instantiation: methods.c:tls12_rpk_and_privkey
Unexecuted instantiation: s3_lib.c:tls12_rpk_and_privkey
Unexecuted instantiation: s3_msg.c:tls12_rpk_and_privkey
Unexecuted instantiation: ssl_cert.c:tls12_rpk_and_privkey
Unexecuted instantiation: ssl_ciph.c:tls12_rpk_and_privkey
Unexecuted instantiation: ssl_init.c:tls12_rpk_and_privkey
Unexecuted instantiation: ssl_lib.c:tls12_rpk_and_privkey
Unexecuted instantiation: ssl_mcnf.c:tls12_rpk_and_privkey
Unexecuted instantiation: ssl_rsa.c:tls12_rpk_and_privkey
Unexecuted instantiation: ssl_sess.c:tls12_rpk_and_privkey
Unexecuted instantiation: ssl_stat.c:tls12_rpk_and_privkey
Unexecuted instantiation: t1_lib.c:tls12_rpk_and_privkey
Unexecuted instantiation: tls13_enc.c:tls12_rpk_and_privkey
Unexecuted instantiation: tls_depr.c:tls12_rpk_and_privkey
Unexecuted instantiation: tls_srp.c:tls12_rpk_and_privkey
Unexecuted instantiation: quic_impl.c:tls12_rpk_and_privkey
Unexecuted instantiation: quic_method.c:tls12_rpk_and_privkey
Unexecuted instantiation: quic_obj.c:tls12_rpk_and_privkey
Unexecuted instantiation: quic_port.c:tls12_rpk_and_privkey
Unexecuted instantiation: quic_record_rx.c:tls12_rpk_and_privkey
Unexecuted instantiation: quic_record_shared.c:tls12_rpk_and_privkey
Unexecuted instantiation: quic_record_tx.c:tls12_rpk_and_privkey
Unexecuted instantiation: quic_record_util.c:tls12_rpk_and_privkey
Unexecuted instantiation: quic_thread_assist.c:tls12_rpk_and_privkey
Unexecuted instantiation: quic_tls.c:tls12_rpk_and_privkey
Unexecuted instantiation: rec_layer_d1.c:tls12_rpk_and_privkey
Unexecuted instantiation: rec_layer_s3.c:tls12_rpk_and_privkey
Unexecuted instantiation: dtls_meth.c:tls12_rpk_and_privkey
Unexecuted instantiation: tls1_meth.c:tls12_rpk_and_privkey
Unexecuted instantiation: tls_common.c:tls12_rpk_and_privkey
Unexecuted instantiation: tls_multib.c:tls12_rpk_and_privkey
Unexecuted instantiation: tlsany_meth.c:tls12_rpk_and_privkey
Unexecuted instantiation: extensions.c:tls12_rpk_and_privkey
Unexecuted instantiation: extensions_clnt.c:tls12_rpk_and_privkey
Unexecuted instantiation: extensions_cust.c:tls12_rpk_and_privkey
Unexecuted instantiation: extensions_srvr.c:tls12_rpk_and_privkey
Unexecuted instantiation: statem.c:tls12_rpk_and_privkey
Unexecuted instantiation: statem_clnt.c:tls12_rpk_and_privkey
Unexecuted instantiation: statem_dtls.c:tls12_rpk_and_privkey
Unexecuted instantiation: statem_lib.c:tls12_rpk_and_privkey
Unexecuted instantiation: statem_srvr.c:tls12_rpk_and_privkey
Unexecuted instantiation: ech_helper.c:tls12_rpk_and_privkey
Unexecuted instantiation: ech_internal.c:tls12_rpk_and_privkey
Unexecuted instantiation: ech_store.c:tls12_rpk_and_privkey
Unexecuted instantiation: d1_lib.c:tls12_rpk_and_privkey
Unexecuted instantiation: d1_msg.c:tls12_rpk_and_privkey
Unexecuted instantiation: d1_srtp.c:tls12_rpk_and_privkey
Unexecuted instantiation: pqueue.c:tls12_rpk_and_privkey
Unexecuted instantiation: s3_enc.c:tls12_rpk_and_privkey
Unexecuted instantiation: ssl_asn1.c:tls12_rpk_and_privkey
Unexecuted instantiation: ssl_conf.c:tls12_rpk_and_privkey
Unexecuted instantiation: t1_enc.c:tls12_rpk_and_privkey
Unexecuted instantiation: quic_channel.c:tls12_rpk_and_privkey
Unexecuted instantiation: quic_engine.c:tls12_rpk_and_privkey
Unexecuted instantiation: quic_rx_depack.c:tls12_rpk_and_privkey
Unexecuted instantiation: tls13_meth.c:tls12_rpk_and_privkey
2393
2394
static ossl_inline int ssl_has_cert_type(const SSL_CONNECTION *sc, unsigned char ct)
2395
0
{
2396
0
    unsigned char *ptr;
2397
0
    size_t len;
2398
2399
0
    if (sc->server) {
2400
0
        ptr = sc->server_cert_type;
2401
0
        len = sc->server_cert_type_len;
2402
0
    } else {
2403
0
        ptr = sc->client_cert_type;
2404
0
        len = sc->client_cert_type_len;
2405
0
    }
2406
2407
0
    if (ptr == NULL)
2408
0
        return 0;
2409
2410
0
    return memchr(ptr, ct, len) != NULL;
2411
0
}
Unexecuted instantiation: methods.c:ssl_has_cert_type
Unexecuted instantiation: s3_lib.c:ssl_has_cert_type
Unexecuted instantiation: s3_msg.c:ssl_has_cert_type
Unexecuted instantiation: ssl_cert.c:ssl_has_cert_type
Unexecuted instantiation: ssl_ciph.c:ssl_has_cert_type
Unexecuted instantiation: ssl_init.c:ssl_has_cert_type
Unexecuted instantiation: ssl_lib.c:ssl_has_cert_type
Unexecuted instantiation: ssl_mcnf.c:ssl_has_cert_type
Unexecuted instantiation: ssl_rsa.c:ssl_has_cert_type
Unexecuted instantiation: ssl_sess.c:ssl_has_cert_type
Unexecuted instantiation: ssl_stat.c:ssl_has_cert_type
Unexecuted instantiation: t1_lib.c:ssl_has_cert_type
Unexecuted instantiation: tls13_enc.c:ssl_has_cert_type
Unexecuted instantiation: tls_depr.c:ssl_has_cert_type
Unexecuted instantiation: tls_srp.c:ssl_has_cert_type
Unexecuted instantiation: quic_impl.c:ssl_has_cert_type
Unexecuted instantiation: quic_method.c:ssl_has_cert_type
Unexecuted instantiation: quic_obj.c:ssl_has_cert_type
Unexecuted instantiation: quic_port.c:ssl_has_cert_type
Unexecuted instantiation: quic_record_rx.c:ssl_has_cert_type
Unexecuted instantiation: quic_record_shared.c:ssl_has_cert_type
Unexecuted instantiation: quic_record_tx.c:ssl_has_cert_type
Unexecuted instantiation: quic_record_util.c:ssl_has_cert_type
Unexecuted instantiation: quic_thread_assist.c:ssl_has_cert_type
Unexecuted instantiation: quic_tls.c:ssl_has_cert_type
Unexecuted instantiation: rec_layer_d1.c:ssl_has_cert_type
Unexecuted instantiation: rec_layer_s3.c:ssl_has_cert_type
Unexecuted instantiation: dtls_meth.c:ssl_has_cert_type
Unexecuted instantiation: tls1_meth.c:ssl_has_cert_type
Unexecuted instantiation: tls_common.c:ssl_has_cert_type
Unexecuted instantiation: tls_multib.c:ssl_has_cert_type
Unexecuted instantiation: tlsany_meth.c:ssl_has_cert_type
Unexecuted instantiation: extensions.c:ssl_has_cert_type
Unexecuted instantiation: extensions_clnt.c:ssl_has_cert_type
Unexecuted instantiation: extensions_cust.c:ssl_has_cert_type
Unexecuted instantiation: extensions_srvr.c:ssl_has_cert_type
Unexecuted instantiation: statem.c:ssl_has_cert_type
Unexecuted instantiation: statem_clnt.c:ssl_has_cert_type
Unexecuted instantiation: statem_dtls.c:ssl_has_cert_type
Unexecuted instantiation: statem_lib.c:ssl_has_cert_type
Unexecuted instantiation: statem_srvr.c:ssl_has_cert_type
Unexecuted instantiation: ech_helper.c:ssl_has_cert_type
Unexecuted instantiation: ech_internal.c:ssl_has_cert_type
Unexecuted instantiation: ech_store.c:ssl_has_cert_type
Unexecuted instantiation: d1_lib.c:ssl_has_cert_type
Unexecuted instantiation: d1_msg.c:ssl_has_cert_type
Unexecuted instantiation: d1_srtp.c:ssl_has_cert_type
Unexecuted instantiation: pqueue.c:ssl_has_cert_type
Unexecuted instantiation: s3_enc.c:ssl_has_cert_type
Unexecuted instantiation: ssl_asn1.c:ssl_has_cert_type
Unexecuted instantiation: ssl_conf.c:ssl_has_cert_type
Unexecuted instantiation: t1_enc.c:ssl_has_cert_type
Unexecuted instantiation: quic_channel.c:ssl_has_cert_type
Unexecuted instantiation: quic_engine.c:ssl_has_cert_type
Unexecuted instantiation: quic_rx_depack.c:ssl_has_cert_type
Unexecuted instantiation: tls13_meth.c:ssl_has_cert_type
2412
2413
/* Returns true if certificate and private key for 'idx' are present */
2414
static ossl_inline int ssl_has_cert(const SSL_CONNECTION *s, int idx)
2415
0
{
2416
0
    if (idx < 0 || idx >= (int)s->ssl_pkey_num)
2417
0
        return 0;
2418
2419
    /* If RPK is enabled for this SSL... only require private key */
2420
0
    if (ssl_has_cert_type(s, TLSEXT_cert_type_rpk))
2421
0
        return s->cert->pkeys[idx].privatekey != NULL;
2422
2423
0
    return s->cert->pkeys[idx].x509 != NULL
2424
0
        && s->cert->pkeys[idx].privatekey != NULL;
2425
0
}
Unexecuted instantiation: methods.c:ssl_has_cert
Unexecuted instantiation: s3_lib.c:ssl_has_cert
Unexecuted instantiation: s3_msg.c:ssl_has_cert
Unexecuted instantiation: ssl_cert.c:ssl_has_cert
Unexecuted instantiation: ssl_ciph.c:ssl_has_cert
Unexecuted instantiation: ssl_init.c:ssl_has_cert
Unexecuted instantiation: ssl_lib.c:ssl_has_cert
Unexecuted instantiation: ssl_mcnf.c:ssl_has_cert
Unexecuted instantiation: ssl_rsa.c:ssl_has_cert
Unexecuted instantiation: ssl_sess.c:ssl_has_cert
Unexecuted instantiation: ssl_stat.c:ssl_has_cert
Unexecuted instantiation: t1_lib.c:ssl_has_cert
Unexecuted instantiation: tls13_enc.c:ssl_has_cert
Unexecuted instantiation: tls_depr.c:ssl_has_cert
Unexecuted instantiation: tls_srp.c:ssl_has_cert
Unexecuted instantiation: quic_impl.c:ssl_has_cert
Unexecuted instantiation: quic_method.c:ssl_has_cert
Unexecuted instantiation: quic_obj.c:ssl_has_cert
Unexecuted instantiation: quic_port.c:ssl_has_cert
Unexecuted instantiation: quic_record_rx.c:ssl_has_cert
Unexecuted instantiation: quic_record_shared.c:ssl_has_cert
Unexecuted instantiation: quic_record_tx.c:ssl_has_cert
Unexecuted instantiation: quic_record_util.c:ssl_has_cert
Unexecuted instantiation: quic_thread_assist.c:ssl_has_cert
Unexecuted instantiation: quic_tls.c:ssl_has_cert
Unexecuted instantiation: rec_layer_d1.c:ssl_has_cert
Unexecuted instantiation: rec_layer_s3.c:ssl_has_cert
Unexecuted instantiation: dtls_meth.c:ssl_has_cert
Unexecuted instantiation: tls1_meth.c:ssl_has_cert
Unexecuted instantiation: tls_common.c:ssl_has_cert
Unexecuted instantiation: tls_multib.c:ssl_has_cert
Unexecuted instantiation: tlsany_meth.c:ssl_has_cert
Unexecuted instantiation: extensions.c:ssl_has_cert
Unexecuted instantiation: extensions_clnt.c:ssl_has_cert
Unexecuted instantiation: extensions_cust.c:ssl_has_cert
Unexecuted instantiation: extensions_srvr.c:ssl_has_cert
Unexecuted instantiation: statem.c:ssl_has_cert
Unexecuted instantiation: statem_clnt.c:ssl_has_cert
Unexecuted instantiation: statem_dtls.c:ssl_has_cert
Unexecuted instantiation: statem_lib.c:ssl_has_cert
Unexecuted instantiation: statem_srvr.c:ssl_has_cert
Unexecuted instantiation: ech_helper.c:ssl_has_cert
Unexecuted instantiation: ech_internal.c:ssl_has_cert
Unexecuted instantiation: ech_store.c:ssl_has_cert
Unexecuted instantiation: d1_lib.c:ssl_has_cert
Unexecuted instantiation: d1_msg.c:ssl_has_cert
Unexecuted instantiation: d1_srtp.c:ssl_has_cert
Unexecuted instantiation: pqueue.c:ssl_has_cert
Unexecuted instantiation: s3_enc.c:ssl_has_cert
Unexecuted instantiation: ssl_asn1.c:ssl_has_cert
Unexecuted instantiation: ssl_conf.c:ssl_has_cert
Unexecuted instantiation: t1_enc.c:ssl_has_cert
Unexecuted instantiation: quic_channel.c:ssl_has_cert
Unexecuted instantiation: quic_engine.c:ssl_has_cert
Unexecuted instantiation: quic_rx_depack.c:ssl_has_cert
Unexecuted instantiation: tls13_meth.c:ssl_has_cert
2426
2427
static ossl_inline void tls1_get_peer_groups(SSL_CONNECTION *s,
2428
    const uint16_t **pgroups,
2429
    size_t *pgroupslen)
2430
0
{
2431
0
    *pgroups = s->ext.peer_supportedgroups;
2432
0
    *pgroupslen = s->ext.peer_supportedgroups_len;
2433
0
}
Unexecuted instantiation: methods.c:tls1_get_peer_groups
Unexecuted instantiation: s3_lib.c:tls1_get_peer_groups
Unexecuted instantiation: s3_msg.c:tls1_get_peer_groups
Unexecuted instantiation: ssl_cert.c:tls1_get_peer_groups
Unexecuted instantiation: ssl_ciph.c:tls1_get_peer_groups
Unexecuted instantiation: ssl_init.c:tls1_get_peer_groups
Unexecuted instantiation: ssl_lib.c:tls1_get_peer_groups
Unexecuted instantiation: ssl_mcnf.c:tls1_get_peer_groups
Unexecuted instantiation: ssl_rsa.c:tls1_get_peer_groups
Unexecuted instantiation: ssl_sess.c:tls1_get_peer_groups
Unexecuted instantiation: ssl_stat.c:tls1_get_peer_groups
Unexecuted instantiation: t1_lib.c:tls1_get_peer_groups
Unexecuted instantiation: tls13_enc.c:tls1_get_peer_groups
Unexecuted instantiation: tls_depr.c:tls1_get_peer_groups
Unexecuted instantiation: tls_srp.c:tls1_get_peer_groups
Unexecuted instantiation: quic_impl.c:tls1_get_peer_groups
Unexecuted instantiation: quic_method.c:tls1_get_peer_groups
Unexecuted instantiation: quic_obj.c:tls1_get_peer_groups
Unexecuted instantiation: quic_port.c:tls1_get_peer_groups
Unexecuted instantiation: quic_record_rx.c:tls1_get_peer_groups
Unexecuted instantiation: quic_record_shared.c:tls1_get_peer_groups
Unexecuted instantiation: quic_record_tx.c:tls1_get_peer_groups
Unexecuted instantiation: quic_record_util.c:tls1_get_peer_groups
Unexecuted instantiation: quic_thread_assist.c:tls1_get_peer_groups
Unexecuted instantiation: quic_tls.c:tls1_get_peer_groups
Unexecuted instantiation: rec_layer_d1.c:tls1_get_peer_groups
Unexecuted instantiation: rec_layer_s3.c:tls1_get_peer_groups
Unexecuted instantiation: dtls_meth.c:tls1_get_peer_groups
Unexecuted instantiation: tls1_meth.c:tls1_get_peer_groups
Unexecuted instantiation: tls_common.c:tls1_get_peer_groups
Unexecuted instantiation: tls_multib.c:tls1_get_peer_groups
Unexecuted instantiation: tlsany_meth.c:tls1_get_peer_groups
Unexecuted instantiation: extensions.c:tls1_get_peer_groups
Unexecuted instantiation: extensions_clnt.c:tls1_get_peer_groups
Unexecuted instantiation: extensions_cust.c:tls1_get_peer_groups
Unexecuted instantiation: extensions_srvr.c:tls1_get_peer_groups
Unexecuted instantiation: statem.c:tls1_get_peer_groups
Unexecuted instantiation: statem_clnt.c:tls1_get_peer_groups
Unexecuted instantiation: statem_dtls.c:tls1_get_peer_groups
Unexecuted instantiation: statem_lib.c:tls1_get_peer_groups
Unexecuted instantiation: statem_srvr.c:tls1_get_peer_groups
Unexecuted instantiation: ech_helper.c:tls1_get_peer_groups
Unexecuted instantiation: ech_internal.c:tls1_get_peer_groups
Unexecuted instantiation: ech_store.c:tls1_get_peer_groups
Unexecuted instantiation: d1_lib.c:tls1_get_peer_groups
Unexecuted instantiation: d1_msg.c:tls1_get_peer_groups
Unexecuted instantiation: d1_srtp.c:tls1_get_peer_groups
Unexecuted instantiation: pqueue.c:tls1_get_peer_groups
Unexecuted instantiation: s3_enc.c:tls1_get_peer_groups
Unexecuted instantiation: ssl_asn1.c:tls1_get_peer_groups
Unexecuted instantiation: ssl_conf.c:tls1_get_peer_groups
Unexecuted instantiation: t1_enc.c:tls1_get_peer_groups
Unexecuted instantiation: quic_channel.c:tls1_get_peer_groups
Unexecuted instantiation: quic_engine.c:tls1_get_peer_groups
Unexecuted instantiation: quic_rx_depack.c:tls1_get_peer_groups
Unexecuted instantiation: tls13_meth.c:tls1_get_peer_groups
2434
2435
#ifndef OPENSSL_UNIT_TEST
2436
2437
__owur int ossl_ssl_init(SSL *ssl, SSL_CTX *ctx, const SSL_METHOD *method,
2438
    int type);
2439
__owur SSL *ossl_ssl_connection_new_int(SSL_CTX *ctx, SSL *user_ssl,
2440
    const SSL_METHOD *method);
2441
__owur SSL *ossl_ssl_connection_new(SSL_CTX *ctx);
2442
void ossl_ssl_connection_free(SSL *ssl);
2443
__owur int ossl_ssl_connection_reset(SSL *ssl);
2444
2445
__owur int ssl_read_internal(SSL *s, void *buf, size_t num, size_t *readbytes);
2446
__owur int ssl_write_internal(SSL *s, const void *buf, size_t num,
2447
    uint64_t flags, size_t *written);
2448
int ssl_clear_bad_session(SSL_CONNECTION *s);
2449
__owur CERT *ssl_cert_new(size_t ssl_pkey_num);
2450
__owur CERT *ssl_cert_dup(CERT *cert);
2451
void ssl_cert_clear_certs(CERT *c);
2452
void ssl_cert_free(CERT *c);
2453
__owur int ssl_generate_session_id(SSL_CONNECTION *s, SSL_SESSION *ss);
2454
__owur int ssl_get_new_session(SSL_CONNECTION *s, int session);
2455
__owur SSL_SESSION *lookup_sess_in_cache(SSL_CONNECTION *s,
2456
    const unsigned char *sess_id,
2457
    size_t sess_id_len);
2458
__owur int ssl_get_prev_session(SSL_CONNECTION *s, CLIENTHELLO_MSG *hello);
2459
__owur SSL_SESSION *ssl_session_dup(const SSL_SESSION *src, int ticket);
2460
__owur int ssl_cipher_id_cmp(const SSL_CIPHER *a, const SSL_CIPHER *b);
2461
DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(SSL_CIPHER, SSL_CIPHER, ssl_cipher_id);
2462
__owur int ssl_cipher_ptr_id_cmp(const SSL_CIPHER *const *ap,
2463
    const SSL_CIPHER *const *bp);
2464
__owur STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(SSL_CTX *ctx,
2465
    STACK_OF(SSL_CIPHER) *tls13_ciphersuites,
2466
    STACK_OF(SSL_CIPHER) **cipher_list,
2467
    STACK_OF(SSL_CIPHER) **cipher_list_by_id,
2468
    const char *rule_str,
2469
    CERT *c);
2470
__owur int ssl_cache_cipherlist(SSL_CONNECTION *s, PACKET *cipher_suites);
2471
__owur int ossl_bytes_to_cipher_list(SSL_CONNECTION *s, PACKET *cipher_suites,
2472
    STACK_OF(SSL_CIPHER) **skp,
2473
    STACK_OF(SSL_CIPHER) **scsvs,
2474
    int fatal);
2475
void ssl_update_cache(SSL_CONNECTION *s, int mode);
2476
__owur int ssl_cipher_get_evp_cipher(SSL_CTX *ctx, const SSL_CIPHER *sslc,
2477
    const EVP_CIPHER **enc);
2478
__owur int ssl_cipher_get_evp_md_mac(SSL_CTX *ctx, const SSL_CIPHER *sslc,
2479
    const EVP_MD **md,
2480
    int *mac_pkey_type, size_t *mac_secret_size);
2481
__owur int ssl_cipher_get_evp(SSL_CTX *ctxc, const SSL_SESSION *s,
2482
    const EVP_CIPHER **enc, const EVP_MD **md,
2483
    int *mac_pkey_type, size_t *mac_secret_size,
2484
    SSL_COMP **comp, int use_etm);
2485
__owur int ssl_cipher_get_overhead(const SSL_CIPHER *c, size_t *mac_overhead,
2486
    size_t *int_overhead, size_t *blocksize,
2487
    size_t *ext_overhead);
2488
__owur int ssl_cert_is_disabled(SSL_CTX *ctx, size_t idx);
2489
__owur const SSL_CIPHER *ssl_get_cipher_by_char(SSL_CONNECTION *ssl,
2490
    const unsigned char *ptr,
2491
    int all);
2492
__owur int ssl_cert_set0_chain(SSL_CONNECTION *s, SSL_CTX *ctx,
2493
    STACK_OF(X509) *chain);
2494
__owur int ssl_cert_set1_chain(SSL_CONNECTION *s, SSL_CTX *ctx,
2495
    STACK_OF(X509) *chain);
2496
__owur int ssl_cert_add0_chain_cert(SSL_CONNECTION *s, SSL_CTX *ctx, X509 *x);
2497
__owur int ssl_cert_add1_chain_cert(SSL_CONNECTION *s, SSL_CTX *ctx, X509 *x);
2498
__owur int ssl_cert_select_current(CERT *c, X509 *x);
2499
__owur int ssl_cert_set_current(CERT *c, long arg);
2500
void ssl_cert_set_cert_cb(CERT *c, int (*cb)(SSL *ssl, void *arg), void *arg);
2501
2502
__owur int ssl_verify_cert_chain(SSL_CONNECTION *s, STACK_OF(X509) *sk);
2503
__owur int ssl_verify_rpk(SSL_CONNECTION *s, EVP_PKEY *rpk);
2504
__owur int ssl_verify_ocsp(SSL *s, STACK_OF(X509) *sk);
2505
__owur int ssl_build_cert_chain(SSL_CONNECTION *s, SSL_CTX *ctx, int flags);
2506
__owur int ssl_cert_set_cert_store(CERT *c, X509_STORE *store, int chain,
2507
    int ref);
2508
__owur int ssl_cert_get_cert_store(CERT *c, X509_STORE **pstore, int chain);
2509
2510
__owur int ssl_security(const SSL_CONNECTION *s, int op, int bits, int nid,
2511
    void *other);
2512
__owur int ssl_ctx_security(const SSL_CTX *ctx, int op, int bits, int nid,
2513
    void *other);
2514
int ssl_get_security_level_bits(const SSL *s, const SSL_CTX *ctx, int *levelp);
2515
2516
__owur int ssl_cert_lookup_by_nid(int nid, size_t *pidx, SSL_CTX *ctx);
2517
__owur const SSL_CERT_LOOKUP *ssl_cert_lookup_by_pkey(const EVP_PKEY *pk,
2518
    size_t *pidx,
2519
    SSL_CTX *ctx);
2520
__owur const SSL_CERT_LOOKUP *ssl_cert_lookup_by_idx(size_t idx, SSL_CTX *ctx);
2521
2522
int ssl_undefined_function(SSL *s);
2523
__owur int ssl_undefined_void_function(void);
2524
__owur int ssl_get_server_cert_serverinfo(SSL_CONNECTION *s,
2525
    const unsigned char **serverinfo,
2526
    size_t *serverinfo_length);
2527
void ssl_set_masks(SSL_CONNECTION *s);
2528
__owur STACK_OF(SSL_CIPHER) *ssl_get_ciphers_by_id(SSL_CONNECTION *sc);
2529
__owur int ssl_x509err2alert(int type);
2530
void ssl_sort_cipher_list(void);
2531
int ssl_load_ciphers(SSL_CTX *ctx);
2532
int ssl_cipher_list_to_bytes(SSL_CONNECTION *s, STACK_OF(SSL_CIPHER) *sk,
2533
    WPACKET *pkt);
2534
uint16_t ossl_grease_value(SSL_CONNECTION *s, int index);
2535
static ossl_inline int ossl_is_grease_value(uint16_t val)
2536
0
{
2537
0
    return (val & 0x0f0f) == 0x0a0a && (val >> 8) == (val & 0xff);
2538
0
}
Unexecuted instantiation: methods.c:ossl_is_grease_value
Unexecuted instantiation: s3_lib.c:ossl_is_grease_value
Unexecuted instantiation: s3_msg.c:ossl_is_grease_value
Unexecuted instantiation: ssl_cert.c:ossl_is_grease_value
Unexecuted instantiation: ssl_ciph.c:ossl_is_grease_value
Unexecuted instantiation: ssl_init.c:ossl_is_grease_value
Unexecuted instantiation: ssl_lib.c:ossl_is_grease_value
Unexecuted instantiation: ssl_mcnf.c:ossl_is_grease_value
Unexecuted instantiation: ssl_rsa.c:ossl_is_grease_value
Unexecuted instantiation: ssl_sess.c:ossl_is_grease_value
Unexecuted instantiation: ssl_stat.c:ossl_is_grease_value
Unexecuted instantiation: t1_lib.c:ossl_is_grease_value
Unexecuted instantiation: tls13_enc.c:ossl_is_grease_value
Unexecuted instantiation: tls_depr.c:ossl_is_grease_value
Unexecuted instantiation: tls_srp.c:ossl_is_grease_value
Unexecuted instantiation: quic_impl.c:ossl_is_grease_value
Unexecuted instantiation: quic_method.c:ossl_is_grease_value
Unexecuted instantiation: quic_obj.c:ossl_is_grease_value
Unexecuted instantiation: quic_port.c:ossl_is_grease_value
Unexecuted instantiation: quic_record_rx.c:ossl_is_grease_value
Unexecuted instantiation: quic_record_shared.c:ossl_is_grease_value
Unexecuted instantiation: quic_record_tx.c:ossl_is_grease_value
Unexecuted instantiation: quic_record_util.c:ossl_is_grease_value
Unexecuted instantiation: quic_thread_assist.c:ossl_is_grease_value
Unexecuted instantiation: quic_tls.c:ossl_is_grease_value
Unexecuted instantiation: rec_layer_d1.c:ossl_is_grease_value
Unexecuted instantiation: rec_layer_s3.c:ossl_is_grease_value
Unexecuted instantiation: dtls_meth.c:ossl_is_grease_value
Unexecuted instantiation: tls1_meth.c:ossl_is_grease_value
Unexecuted instantiation: tls_common.c:ossl_is_grease_value
Unexecuted instantiation: tls_multib.c:ossl_is_grease_value
Unexecuted instantiation: tlsany_meth.c:ossl_is_grease_value
Unexecuted instantiation: extensions.c:ossl_is_grease_value
Unexecuted instantiation: extensions_clnt.c:ossl_is_grease_value
Unexecuted instantiation: extensions_cust.c:ossl_is_grease_value
Unexecuted instantiation: extensions_srvr.c:ossl_is_grease_value
Unexecuted instantiation: statem.c:ossl_is_grease_value
Unexecuted instantiation: statem_clnt.c:ossl_is_grease_value
Unexecuted instantiation: statem_dtls.c:ossl_is_grease_value
Unexecuted instantiation: statem_lib.c:ossl_is_grease_value
Unexecuted instantiation: statem_srvr.c:ossl_is_grease_value
Unexecuted instantiation: ech_helper.c:ossl_is_grease_value
Unexecuted instantiation: ech_internal.c:ossl_is_grease_value
Unexecuted instantiation: ech_store.c:ossl_is_grease_value
Unexecuted instantiation: d1_lib.c:ossl_is_grease_value
Unexecuted instantiation: d1_msg.c:ossl_is_grease_value
Unexecuted instantiation: d1_srtp.c:ossl_is_grease_value
Unexecuted instantiation: pqueue.c:ossl_is_grease_value
Unexecuted instantiation: s3_enc.c:ossl_is_grease_value
Unexecuted instantiation: ssl_asn1.c:ossl_is_grease_value
Unexecuted instantiation: ssl_conf.c:ossl_is_grease_value
Unexecuted instantiation: t1_enc.c:ossl_is_grease_value
Unexecuted instantiation: quic_channel.c:ossl_is_grease_value
Unexecuted instantiation: quic_engine.c:ossl_is_grease_value
Unexecuted instantiation: quic_rx_depack.c:ossl_is_grease_value
Unexecuted instantiation: tls13_meth.c:ossl_is_grease_value
2539
__owur int ssl_setup_sigalgs(SSL_CTX *ctx);
2540
int ssl_load_groups(SSL_CTX *ctx);
2541
int ssl_load_sigalgs(SSL_CTX *ctx);
2542
__owur int ssl_fill_hello_random(SSL_CONNECTION *s, int server,
2543
    unsigned char *field, size_t len,
2544
    DOWNGRADE dgrd);
2545
__owur int ssl_generate_master_secret(SSL_CONNECTION *s, unsigned char *pms,
2546
    size_t pmslen, int free_pms);
2547
__owur EVP_PKEY *ssl_generate_pkey(SSL_CONNECTION *s, EVP_PKEY *pm);
2548
__owur int ssl_gensecret(SSL_CONNECTION *s, unsigned char *pms, size_t pmslen);
2549
__owur int ssl_derive(SSL_CONNECTION *s, EVP_PKEY *privkey, EVP_PKEY *pubkey,
2550
    int genmaster);
2551
__owur int ssl_decapsulate(SSL_CONNECTION *s, EVP_PKEY *privkey,
2552
    const unsigned char *ct, size_t ctlen,
2553
    int gensecret);
2554
__owur int ssl_encapsulate(SSL_CONNECTION *s, EVP_PKEY *pubkey,
2555
    unsigned char **ctp, size_t *ctlenp,
2556
    int gensecret);
2557
__owur EVP_PKEY *ssl_dh_to_pkey(DH *dh);
2558
__owur int ssl_set_tmp_ecdh_groups(uint16_t **pext, size_t *pextlen,
2559
    uint16_t **ksext, size_t *ksextlen,
2560
    size_t **tplext, size_t *tplextlen,
2561
    void *key);
2562
__owur unsigned int ssl_get_max_send_fragment(const SSL_CONNECTION *sc);
2563
__owur unsigned int ssl_get_split_send_fragment(const SSL_CONNECTION *sc);
2564
2565
__owur const SSL_CIPHER *ssl3_get_cipher_by_id(uint32_t id);
2566
__owur const SSL_CIPHER *ssl3_get_cipher_by_std_name(const char *stdname);
2567
__owur const SSL_CIPHER *ssl3_get_tls13_cipher_by_std_name(const char *stdname);
2568
__owur const SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p);
2569
__owur int ssl3_put_cipher_by_char(const SSL_CIPHER *c, WPACKET *pkt,
2570
    size_t *len);
2571
int ssl3_init_finished_mac(SSL_CONNECTION *s);
2572
void ssl3_cleanup_key_block(SSL_CONNECTION *s);
2573
__owur int ssl3_do_write(SSL_CONNECTION *s, uint8_t type);
2574
int ssl3_send_alert(SSL_CONNECTION *s, int level, int desc);
2575
__owur int ssl3_get_req_cert_type(SSL_CONNECTION *s, WPACKET *pkt);
2576
__owur int ssl3_num_ciphers(void);
2577
__owur const SSL_CIPHER *ssl3_get_cipher(unsigned int u);
2578
int ssl3_renegotiate(SSL *ssl);
2579
int ssl3_renegotiate_check(SSL *ssl, int initok);
2580
__owur int ssl3_dispatch_alert(SSL *s);
2581
__owur int ssl3_finish_mac(SSL_CONNECTION *s, const unsigned char *buf,
2582
    size_t len);
2583
void ssl3_free_digest_list(SSL_CONNECTION *s);
2584
__owur unsigned long ssl3_output_cert_chain(SSL_CONNECTION *s, WPACKET *pkt,
2585
    CERT_PKEY *cpk, int for_comp);
2586
__owur const SSL_CIPHER *ssl3_choose_cipher(SSL_CONNECTION *s,
2587
    STACK_OF(SSL_CIPHER) *clnt,
2588
    STACK_OF(SSL_CIPHER) *srvr);
2589
__owur int ssl3_digest_cached_records(SSL_CONNECTION *s, int keep);
2590
__owur int ssl3_new(SSL *s);
2591
void ssl3_free(SSL *s);
2592
__owur int ssl3_read(SSL *s, void *buf, size_t len, size_t *readbytes);
2593
__owur int ssl3_peek(SSL *s, void *buf, size_t len, size_t *readbytes);
2594
__owur int ssl3_write(SSL *s, const void *buf, size_t len, size_t *written);
2595
__owur int ssl3_shutdown(SSL *s);
2596
int ssl3_clear(SSL *s);
2597
__owur long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg);
2598
__owur long ssl3_ctx_ctrl(SSL_CTX *s, int cmd, long larg, void *parg);
2599
__owur long ssl3_callback_ctrl(SSL *s, int cmd, void (*fp)(void));
2600
__owur long ssl3_ctx_callback_ctrl(SSL_CTX *s, int cmd, void (*fp)(void));
2601
2602
__owur int ssl3_do_change_cipher_spec(SSL_CONNECTION *s);
2603
2604
__owur int ssl3_set_handshake_header(SSL_CONNECTION *s, WPACKET *pkt,
2605
    int htype);
2606
__owur int tls_close_construct_packet(SSL_CONNECTION *s, WPACKET *pkt, int htype);
2607
__owur int tls_setup_handshake(SSL_CONNECTION *s);
2608
__owur int dtls1_set_handshake_header(SSL_CONNECTION *s, WPACKET *pkt, int htype);
2609
__owur int dtls1_close_construct_packet(SSL_CONNECTION *s, WPACKET *pkt, int htype);
2610
__owur int ssl3_handshake_write(SSL_CONNECTION *s);
2611
2612
__owur int ssl_allow_compression(SSL_CONNECTION *s);
2613
2614
__owur int ssl_version_cmp(const SSL_CONNECTION *s, int versiona, int versionb);
2615
__owur int ssl_version_supported(const SSL_CONNECTION *s, int version,
2616
    const SSL_METHOD **meth);
2617
2618
__owur int ssl_set_client_hello_version(SSL_CONNECTION *s);
2619
__owur int ssl_check_version_downgrade(SSL_CONNECTION *s);
2620
__owur int ssl_set_version_bound(int method_version, int version, int *bound);
2621
__owur int ssl_choose_server_version(SSL_CONNECTION *s, CLIENTHELLO_MSG *hello,
2622
    DOWNGRADE *dgrd);
2623
__owur int ssl_choose_client_version(SSL_CONNECTION *s, int version,
2624
    RAW_EXTENSION *extensions);
2625
__owur int ssl_get_min_max_version(const SSL_CONNECTION *s, int *min_version,
2626
    int *max_version, int *real_max);
2627
2628
__owur OSSL_TIME tls1_default_timeout(void);
2629
__owur int dtls1_do_write(SSL_CONNECTION *s, uint8_t type);
2630
void dtls1_set_message_header(SSL_CONNECTION *s,
2631
    unsigned char mt,
2632
    size_t len,
2633
    size_t frag_off, size_t frag_len);
2634
2635
int dtls1_write_app_data_bytes(SSL *s, uint8_t type, const void *buf_,
2636
    size_t len, size_t *written);
2637
2638
__owur int dtls1_read_failed(SSL_CONNECTION *s, int code);
2639
__owur int dtls1_buffer_message(SSL_CONNECTION *s, int ccs);
2640
__owur int dtls1_retransmit_message(SSL_CONNECTION *s, unsigned short seq,
2641
    int *found);
2642
__owur int dtls1_get_queue_priority(unsigned short seq, int is_ccs);
2643
int dtls1_retransmit_buffered_messages(SSL_CONNECTION *s);
2644
void dtls1_clear_received_buffer(SSL_CONNECTION *s);
2645
void dtls1_clear_sent_buffer(SSL_CONNECTION *s);
2646
void dtls1_get_message_header(const unsigned char *data,
2647
    struct hm_header_st *msg_hdr);
2648
__owur OSSL_TIME dtls1_default_timeout(void);
2649
__owur int dtls1_get_timeout(const SSL_CONNECTION *s, OSSL_TIME *timeleft);
2650
__owur int dtls1_check_timeout_num(SSL_CONNECTION *s);
2651
__owur int dtls1_handle_timeout(SSL_CONNECTION *s);
2652
void dtls1_start_timer(SSL_CONNECTION *s);
2653
void dtls1_stop_timer(SSL_CONNECTION *s);
2654
__owur int dtls1_is_timer_expired(SSL_CONNECTION *s);
2655
__owur int dtls_raw_hello_verify_request(WPACKET *pkt, unsigned char *cookie,
2656
    size_t cookie_len);
2657
__owur size_t dtls1_min_mtu(SSL_CONNECTION *s);
2658
void dtls1_hm_fragment_free(hm_fragment *frag);
2659
__owur int dtls1_query_mtu(SSL_CONNECTION *s);
2660
2661
__owur int tls1_new(SSL *s);
2662
void tls1_free(SSL *s);
2663
int tls1_clear(SSL *s);
2664
2665
__owur int dtls1_new(SSL *s);
2666
void dtls1_free(SSL *s);
2667
int dtls1_clear(SSL *s);
2668
long dtls1_ctrl(SSL *s, int cmd, long larg, void *parg);
2669
__owur int dtls1_shutdown(SSL *s);
2670
2671
__owur int dtls1_dispatch_alert(SSL *s);
2672
2673
__owur int ssl_init_wbio_buffer(SSL_CONNECTION *s);
2674
int ssl_free_wbio_buffer(SSL_CONNECTION *s);
2675
2676
__owur int tls1_change_cipher_state(SSL_CONNECTION *s, int which);
2677
__owur int tls1_setup_key_block(SSL_CONNECTION *s);
2678
__owur size_t tls1_final_finish_mac(SSL_CONNECTION *s, const char *str,
2679
    size_t slen, unsigned char *p);
2680
__owur int tls1_generate_master_secret(SSL_CONNECTION *s, unsigned char *out,
2681
    unsigned char *p, size_t len,
2682
    size_t *secret_size);
2683
__owur int tls13_setup_key_block(SSL_CONNECTION *s);
2684
__owur size_t tls13_final_finish_mac(SSL_CONNECTION *s, const char *str, size_t slen,
2685
    unsigned char *p);
2686
__owur int tls13_store_handshake_traffic_hash(SSL_CONNECTION *s);
2687
__owur int tls13_store_server_finished_hash(SSL_CONNECTION *s);
2688
__owur int tls13_change_cipher_state(SSL_CONNECTION *s, int which);
2689
__owur int tls13_update_key(SSL_CONNECTION *s, int send);
2690
__owur int tls13_hkdf_expand(SSL_CONNECTION *s,
2691
    const EVP_MD *md,
2692
    const unsigned char *secret,
2693
    const unsigned char *label, size_t labellen,
2694
    const unsigned char *data, size_t datalen,
2695
    unsigned char *out, size_t outlen, int fatal);
2696
__owur int tls13_hkdf_expand_ex(OSSL_LIB_CTX *libctx, const char *propq,
2697
    const EVP_MD *md,
2698
    const unsigned char *secret,
2699
    const unsigned char *label, size_t labellen,
2700
    const unsigned char *data, size_t datalen,
2701
    unsigned char *out, size_t outlen,
2702
    int raise_error);
2703
__owur int tls13_derive_key(SSL_CONNECTION *s, const EVP_MD *md,
2704
    const unsigned char *secret, unsigned char *key,
2705
    size_t keylen);
2706
__owur int tls13_derive_iv(SSL_CONNECTION *s, const EVP_MD *md,
2707
    const unsigned char *secret, unsigned char *iv,
2708
    size_t ivlen);
2709
__owur int tls13_derive_finishedkey(SSL_CONNECTION *s, const EVP_MD *md,
2710
    const unsigned char *secret,
2711
    unsigned char *fin, size_t finlen);
2712
int tls13_generate_secret(SSL_CONNECTION *s, const EVP_MD *md,
2713
    const unsigned char *prevsecret,
2714
    const unsigned char *insecret,
2715
    size_t insecretlen,
2716
    unsigned char *outsecret);
2717
__owur int tls13_generate_handshake_secret(SSL_CONNECTION *s,
2718
    const unsigned char *insecret,
2719
    size_t insecretlen);
2720
__owur int tls13_generate_master_secret(SSL_CONNECTION *s, unsigned char *out,
2721
    unsigned char *prev, size_t prevlen,
2722
    size_t *secret_size);
2723
__owur int tls1_export_keying_material(SSL_CONNECTION *s,
2724
    unsigned char *out, size_t olen,
2725
    const char *label, size_t llen,
2726
    const unsigned char *p, size_t plen,
2727
    int use_context);
2728
__owur int tls13_export_keying_material(SSL_CONNECTION *s,
2729
    unsigned char *out, size_t olen,
2730
    const char *label, size_t llen,
2731
    const unsigned char *context,
2732
    size_t contextlen, int use_context);
2733
__owur int tls13_export_keying_material_early(SSL_CONNECTION *s,
2734
    unsigned char *out, size_t olen,
2735
    const char *label, size_t llen,
2736
    const unsigned char *context,
2737
    size_t contextlen);
2738
__owur int tls1_alert_code(int code);
2739
__owur int tls13_alert_code(int code);
2740
2741
__owur int ssl_check_srvr_ecc_cert_and_alg(X509 *x, SSL_CONNECTION *s);
2742
2743
SSL_COMP *ssl3_comp_find(STACK_OF(SSL_COMP) *sk, int n);
2744
2745
0
#define TLS1_GROUPS_RETURN_NUMBER -1
2746
0
#define TLS1_GROUPS_RETURN_TMP_ID -2
2747
0
#define TLS1_GROUPS_FFDHE_GROUPS 0
2748
0
#define TLS1_GROUPS_NON_FFDHE_GROUPS 1
2749
0
#define TLS1_GROUPS_ALL_GROUPS 2
2750
2751
__owur const TLS_GROUP_INFO *tls1_group_id_lookup(SSL_CTX *ctx, uint16_t curve_id);
2752
__owur const char *tls1_group_id2name(SSL_CTX *ctx, uint16_t group_id);
2753
__owur int tls1_group_id2nid(uint16_t group_id, int include_unknown);
2754
__owur uint16_t tls1_nid2group_id(int nid);
2755
__owur int tls1_check_group_id(SSL_CONNECTION *s, uint16_t group_id,
2756
    int check_own_curves);
2757
__owur int tls1_get0_implemented_groups(int min_proto_version,
2758
    int max_proto_version,
2759
    TLS_GROUP_INFO *grps,
2760
    size_t num, long all,
2761
    STACK_OF(OPENSSL_CSTRING) *out);
2762
__owur uint16_t tls1_shared_group(SSL_CONNECTION *s, int nmatch, int groups);
2763
__owur int tls1_set_groups(uint16_t **grpext, size_t *grpextlen,
2764
    uint16_t **ksext, size_t *ksextlen,
2765
    size_t **tplext, size_t *tplextlen,
2766
    int *curves, size_t ncurves);
2767
__owur int tls1_set_groups_list(SSL_CTX *ctx,
2768
    uint16_t **grpext, size_t *grpextlen,
2769
    uint16_t **ksext, size_t *ksextlen,
2770
    size_t **tplext, size_t *tplextlen,
2771
    const char *str);
2772
__owur EVP_PKEY *ssl_generate_pkey_group(SSL_CONNECTION *s, uint16_t id);
2773
__owur int tls_valid_group(SSL_CONNECTION *s, uint16_t group_id, int minversion,
2774
    int maxversion, int *okfortls13, const TLS_GROUP_INFO **giptr);
2775
__owur EVP_PKEY *ssl_generate_param_group(SSL_CONNECTION *s, uint16_t id);
2776
void tls1_get_formatlist(SSL_CONNECTION *s, const unsigned char **pformats,
2777
    size_t *num_formats);
2778
__owur int tls1_check_ffdhe_tmp_key(SSL_CONNECTION *s, unsigned long id);
2779
__owur int tls1_check_ec_tmp_key(SSL_CONNECTION *s, unsigned long id);
2780
2781
__owur int tls_group_allowed(SSL_CONNECTION *s, uint16_t curve, int op);
2782
void tls1_get_supported_groups(SSL_CONNECTION *s, const uint16_t **pgroups,
2783
    size_t *pgroupslen);
2784
void tls1_get_requested_keyshare_groups(SSL_CONNECTION *s, const uint16_t **pgroups,
2785
    size_t *pgroupslen);
2786
void tls1_get_group_tuples(SSL_CONNECTION *s, const size_t **ptuples,
2787
    size_t *ptupleslen);
2788
2789
__owur int tls1_set_server_sigalgs(SSL_CONNECTION *s);
2790
2791
__owur SSL_TICKET_STATUS tls_get_ticket_from_client(SSL_CONNECTION *s,
2792
    CLIENTHELLO_MSG *hello,
2793
    SSL_SESSION **ret);
2794
__owur SSL_TICKET_STATUS tls_decrypt_ticket(SSL_CONNECTION *s,
2795
    const unsigned char *etick,
2796
    size_t eticklen,
2797
    const unsigned char *sess_id,
2798
    size_t sesslen, SSL_SESSION **psess);
2799
2800
__owur int tls_use_ticket(SSL_CONNECTION *s);
2801
2802
void ssl_set_sig_mask(uint32_t *pmask_a, SSL_CONNECTION *s, int op);
2803
2804
__owur int tls1_set_sigalgs_list(SSL_CTX *ctx, CERT *c, const char *str, int client);
2805
__owur int tls1_set_raw_sigalgs(CERT *c, const uint16_t *psigs, size_t salglen,
2806
    int client);
2807
__owur int tls1_set_sigalgs(CERT *c, const int *salg, size_t salglen,
2808
    int client);
2809
int tls1_check_chain(SSL_CONNECTION *s, X509 *x, EVP_PKEY *pk,
2810
    STACK_OF(X509) *chain, int idx);
2811
void tls1_set_cert_validity(SSL_CONNECTION *s);
2812
2813
#ifndef OPENSSL_NO_CT
2814
__owur int ssl_validate_ct(SSL_CONNECTION *s);
2815
#endif
2816
2817
__owur EVP_PKEY *ssl_get_auto_dh(SSL_CONNECTION *s);
2818
2819
__owur int ssl_security_cert(SSL_CONNECTION *s, SSL_CTX *ctx, X509 *x, int vfy,
2820
    int is_ee);
2821
__owur int ssl_security_cert_chain(SSL_CONNECTION *s, STACK_OF(X509) *sk,
2822
    X509 *ex, int vfy);
2823
2824
int tls_choose_sigalg(SSL_CONNECTION *s, int fatalerrs);
2825
2826
__owur long ssl_get_algorithm2(SSL_CONNECTION *s);
2827
__owur int tls12_copy_sigalgs(SSL_CONNECTION *s, WPACKET *pkt,
2828
    const uint16_t *psig, size_t psiglen);
2829
__owur int tls1_save_u16(PACKET *pkt, uint16_t **pdest, size_t *pdestlen, size_t maxnum);
2830
__owur int tls1_save_sigalgs(SSL_CONNECTION *s, PACKET *pkt, int cert);
2831
__owur int tls1_process_sigalgs(SSL_CONNECTION *s);
2832
__owur int tls1_set_peer_legacy_sigalg(SSL_CONNECTION *s, const EVP_PKEY *pkey);
2833
__owur int tls1_lookup_md(SSL_CTX *ctx, const SIGALG_LOOKUP *lu,
2834
    const EVP_MD **pmd);
2835
__owur size_t tls12_get_psigalgs(SSL_CONNECTION *s, int sent,
2836
    const uint16_t **psigs);
2837
__owur int tls_check_sigalg_curve(const SSL_CONNECTION *s, int curve);
2838
__owur int tls12_check_peer_sigalg(SSL_CONNECTION *s, uint16_t, EVP_PKEY *pkey);
2839
__owur int ssl_set_client_disabled(SSL_CONNECTION *s);
2840
__owur int ssl_cipher_disabled(const SSL_CONNECTION *s, const SSL_CIPHER *c,
2841
    int op, int echde);
2842
2843
__owur int ssl_handshake_hash(SSL_CONNECTION *s,
2844
    unsigned char *out, size_t outlen,
2845
    size_t *hashlen);
2846
__owur const EVP_MD *ssl_md(SSL_CTX *ctx, int idx);
2847
int ssl_get_md_idx(int md_nid);
2848
__owur const EVP_MD *ssl_handshake_md(SSL_CONNECTION *s);
2849
__owur const EVP_MD *ssl_prf_md(SSL_CONNECTION *s);
2850
2851
__owur int ossl_adjust_domain_flags(uint64_t domain_flags,
2852
    uint64_t *p_domain_flags);
2853
2854
/*
2855
 * ssl_log_rsa_client_key_exchange logs |premaster| to the SSL_CTX associated
2856
 * with |ssl|, if logging is enabled. It returns one on success and zero on
2857
 * failure. The entry is identified by the first 8 bytes of
2858
 * |encrypted_premaster|.
2859
 */
2860
__owur int ssl_log_rsa_client_key_exchange(SSL_CONNECTION *s,
2861
    const uint8_t *encrypted_premaster,
2862
    size_t encrypted_premaster_len,
2863
    const uint8_t *premaster,
2864
    size_t premaster_len);
2865
2866
/*
2867
 * ssl_log_secret logs |secret| to the SSL_CTX associated with |ssl|, if
2868
 * logging is available. It returns one on success and zero on failure. It tags
2869
 * the entry with |label|.
2870
 */
2871
__owur int ssl_log_secret(SSL_CONNECTION *s, const char *label,
2872
    const uint8_t *secret, size_t secret_len);
2873
2874
0
#define MASTER_SECRET_LABEL "CLIENT_RANDOM"
2875
0
#define CLIENT_EARLY_LABEL "CLIENT_EARLY_TRAFFIC_SECRET"
2876
0
#define CLIENT_HANDSHAKE_LABEL "CLIENT_HANDSHAKE_TRAFFIC_SECRET"
2877
0
#define SERVER_HANDSHAKE_LABEL "SERVER_HANDSHAKE_TRAFFIC_SECRET"
2878
0
#define CLIENT_APPLICATION_LABEL "CLIENT_TRAFFIC_SECRET_0"
2879
0
#define CLIENT_APPLICATION_N_LABEL "CLIENT_TRAFFIC_SECRET_N"
2880
0
#define SERVER_APPLICATION_LABEL "SERVER_TRAFFIC_SECRET_0"
2881
0
#define SERVER_APPLICATION_N_LABEL "SERVER_TRAFFIC_SECRET_N"
2882
0
#define EARLY_EXPORTER_SECRET_LABEL "EARLY_EXPORTER_SECRET"
2883
0
#define EXPORTER_SECRET_LABEL "EXPORTER_SECRET"
2884
2885
__owur int srp_generate_server_master_secret(SSL_CONNECTION *s);
2886
__owur int srp_generate_client_master_secret(SSL_CONNECTION *s);
2887
__owur int srp_verify_server_param(SSL_CONNECTION *s);
2888
2889
/* statem/statem_srvr.c */
2890
2891
__owur int send_certificate_request(SSL_CONNECTION *s);
2892
2893
OCSP_RESPONSE *ossl_get_ocsp_response(SSL_CONNECTION *s, int chainidx);
2894
2895
/* statem/extensions_cust.c */
2896
2897
custom_ext_method *custom_ext_find(const custom_ext_methods *exts,
2898
    ENDPOINT role, unsigned int ext_type,
2899
    size_t *idx);
2900
2901
void custom_ext_init(custom_ext_methods *meths);
2902
2903
int ossl_tls_add_custom_ext_intern(SSL_CTX *ctx, custom_ext_methods *exts,
2904
    ENDPOINT role, unsigned int ext_type,
2905
    unsigned int context,
2906
    SSL_custom_ext_add_cb_ex add_cb,
2907
    SSL_custom_ext_free_cb_ex free_cb,
2908
    void *add_arg,
2909
    SSL_custom_ext_parse_cb_ex parse_cb,
2910
    void *parse_arg);
2911
__owur int custom_ext_parse(SSL_CONNECTION *s, unsigned int context,
2912
    unsigned int ext_type,
2913
    const unsigned char *ext_data, size_t ext_size,
2914
    X509 *x, size_t chainidx);
2915
__owur int custom_ext_add(SSL_CONNECTION *s, int context, WPACKET *pkt, X509 *x,
2916
    size_t chainidx, int maxversion);
2917
2918
__owur int custom_exts_copy(custom_ext_methods *dst,
2919
    const custom_ext_methods *src);
2920
__owur int custom_exts_copy_flags(custom_ext_methods *dst,
2921
    const custom_ext_methods *src);
2922
void custom_exts_free(custom_ext_methods *exts);
2923
2924
/* ssl_mcnf.c */
2925
int ssl_ctx_system_config(SSL_CTX *ctx);
2926
2927
const EVP_CIPHER *ssl_evp_cipher_fetch(OSSL_LIB_CTX *libctx,
2928
    const char *name,
2929
    const char *properties);
2930
int ssl_evp_cipher_up_ref(const EVP_CIPHER *cipher);
2931
void ssl_evp_cipher_free(const EVP_CIPHER *cipher);
2932
int ssl_evp_md_up_ref(const EVP_MD *md);
2933
void ssl_evp_md_free(const EVP_MD *md);
2934
2935
SSL_HMAC *ssl_hmac_old_construct(SSL_HMAC *ret);
2936
void ssl_hmac_old_destruct(SSL_HMAC *ctx);
2937
int ssl_hmac_old_init(SSL_HMAC *ctx, void *key, size_t len, char *md);
2938
int ssl_hmac_old_update(SSL_HMAC *ctx, const unsigned char *data, size_t len);
2939
int ssl_hmac_old_final(SSL_HMAC *ctx, unsigned char *md, size_t *len);
2940
size_t ssl_hmac_old_size(const SSL_HMAC *ctx);
2941
2942
int ssl_ctx_srp_ctx_free_intern(SSL_CTX *ctx);
2943
int ssl_ctx_srp_ctx_init_intern(SSL_CTX *ctx);
2944
int ssl_srp_ctx_free_intern(SSL_CONNECTION *s);
2945
int ssl_srp_ctx_init_intern(SSL_CONNECTION *s);
2946
2947
int ssl_srp_calc_a_param_intern(SSL_CONNECTION *s);
2948
int ssl_srp_server_param_with_username_intern(SSL_CONNECTION *s, int *ad);
2949
2950
void ssl_session_calculate_timeout(SSL_SESSION *ss);
2951
2952
#else /* OPENSSL_UNIT_TEST */
2953
2954
#define ssl_init_wbio_buffer SSL_test_functions()->p_ssl_init_wbio_buffer
2955
2956
#endif
2957
2958
/* Some helper routines to support TSAN operations safely */
2959
static ossl_unused ossl_inline int ssl_tsan_lock(const SSL_CTX *ctx)
2960
0
{
2961
#ifdef TSAN_REQUIRES_LOCKING
2962
    if (!CRYPTO_THREAD_write_lock(ctx->tsan_lock))
2963
        return 0;
2964
#endif
2965
0
    return 1;
2966
0
}
Unexecuted instantiation: methods.c:ssl_tsan_lock
Unexecuted instantiation: s3_lib.c:ssl_tsan_lock
Unexecuted instantiation: s3_msg.c:ssl_tsan_lock
Unexecuted instantiation: ssl_cert.c:ssl_tsan_lock
Unexecuted instantiation: ssl_ciph.c:ssl_tsan_lock
Unexecuted instantiation: ssl_init.c:ssl_tsan_lock
Unexecuted instantiation: ssl_lib.c:ssl_tsan_lock
Unexecuted instantiation: ssl_mcnf.c:ssl_tsan_lock
Unexecuted instantiation: ssl_rsa.c:ssl_tsan_lock
Unexecuted instantiation: ssl_sess.c:ssl_tsan_lock
Unexecuted instantiation: ssl_stat.c:ssl_tsan_lock
Unexecuted instantiation: t1_lib.c:ssl_tsan_lock
Unexecuted instantiation: tls13_enc.c:ssl_tsan_lock
Unexecuted instantiation: tls_depr.c:ssl_tsan_lock
Unexecuted instantiation: tls_srp.c:ssl_tsan_lock
Unexecuted instantiation: quic_impl.c:ssl_tsan_lock
Unexecuted instantiation: quic_method.c:ssl_tsan_lock
Unexecuted instantiation: quic_obj.c:ssl_tsan_lock
Unexecuted instantiation: quic_port.c:ssl_tsan_lock
Unexecuted instantiation: quic_record_rx.c:ssl_tsan_lock
Unexecuted instantiation: quic_record_shared.c:ssl_tsan_lock
Unexecuted instantiation: quic_record_tx.c:ssl_tsan_lock
Unexecuted instantiation: quic_record_util.c:ssl_tsan_lock
Unexecuted instantiation: quic_thread_assist.c:ssl_tsan_lock
Unexecuted instantiation: quic_tls.c:ssl_tsan_lock
Unexecuted instantiation: rec_layer_d1.c:ssl_tsan_lock
Unexecuted instantiation: rec_layer_s3.c:ssl_tsan_lock
Unexecuted instantiation: dtls_meth.c:ssl_tsan_lock
Unexecuted instantiation: tls1_meth.c:ssl_tsan_lock
Unexecuted instantiation: tls_common.c:ssl_tsan_lock
Unexecuted instantiation: tls_multib.c:ssl_tsan_lock
Unexecuted instantiation: tlsany_meth.c:ssl_tsan_lock
Unexecuted instantiation: extensions.c:ssl_tsan_lock
Unexecuted instantiation: extensions_clnt.c:ssl_tsan_lock
Unexecuted instantiation: extensions_cust.c:ssl_tsan_lock
Unexecuted instantiation: extensions_srvr.c:ssl_tsan_lock
Unexecuted instantiation: statem.c:ssl_tsan_lock
Unexecuted instantiation: statem_clnt.c:ssl_tsan_lock
Unexecuted instantiation: statem_dtls.c:ssl_tsan_lock
Unexecuted instantiation: statem_lib.c:ssl_tsan_lock
Unexecuted instantiation: statem_srvr.c:ssl_tsan_lock
Unexecuted instantiation: ech_helper.c:ssl_tsan_lock
Unexecuted instantiation: ech_internal.c:ssl_tsan_lock
Unexecuted instantiation: ech_store.c:ssl_tsan_lock
Unexecuted instantiation: d1_lib.c:ssl_tsan_lock
Unexecuted instantiation: d1_msg.c:ssl_tsan_lock
Unexecuted instantiation: d1_srtp.c:ssl_tsan_lock
Unexecuted instantiation: pqueue.c:ssl_tsan_lock
Unexecuted instantiation: s3_enc.c:ssl_tsan_lock
Unexecuted instantiation: ssl_asn1.c:ssl_tsan_lock
Unexecuted instantiation: ssl_conf.c:ssl_tsan_lock
Unexecuted instantiation: t1_enc.c:ssl_tsan_lock
Unexecuted instantiation: quic_channel.c:ssl_tsan_lock
Unexecuted instantiation: quic_engine.c:ssl_tsan_lock
Unexecuted instantiation: quic_rx_depack.c:ssl_tsan_lock
Unexecuted instantiation: tls13_meth.c:ssl_tsan_lock
2967
2968
static ossl_unused ossl_inline void ssl_tsan_unlock(const SSL_CTX *ctx)
2969
0
{
2970
#ifdef TSAN_REQUIRES_LOCKING
2971
    CRYPTO_THREAD_unlock(ctx->tsan_lock);
2972
#endif
2973
0
}
Unexecuted instantiation: methods.c:ssl_tsan_unlock
Unexecuted instantiation: s3_lib.c:ssl_tsan_unlock
Unexecuted instantiation: s3_msg.c:ssl_tsan_unlock
Unexecuted instantiation: ssl_cert.c:ssl_tsan_unlock
Unexecuted instantiation: ssl_ciph.c:ssl_tsan_unlock
Unexecuted instantiation: ssl_init.c:ssl_tsan_unlock
Unexecuted instantiation: ssl_lib.c:ssl_tsan_unlock
Unexecuted instantiation: ssl_mcnf.c:ssl_tsan_unlock
Unexecuted instantiation: ssl_rsa.c:ssl_tsan_unlock
Unexecuted instantiation: ssl_sess.c:ssl_tsan_unlock
Unexecuted instantiation: ssl_stat.c:ssl_tsan_unlock
Unexecuted instantiation: t1_lib.c:ssl_tsan_unlock
Unexecuted instantiation: tls13_enc.c:ssl_tsan_unlock
Unexecuted instantiation: tls_depr.c:ssl_tsan_unlock
Unexecuted instantiation: tls_srp.c:ssl_tsan_unlock
Unexecuted instantiation: quic_impl.c:ssl_tsan_unlock
Unexecuted instantiation: quic_method.c:ssl_tsan_unlock
Unexecuted instantiation: quic_obj.c:ssl_tsan_unlock
Unexecuted instantiation: quic_port.c:ssl_tsan_unlock
Unexecuted instantiation: quic_record_rx.c:ssl_tsan_unlock
Unexecuted instantiation: quic_record_shared.c:ssl_tsan_unlock
Unexecuted instantiation: quic_record_tx.c:ssl_tsan_unlock
Unexecuted instantiation: quic_record_util.c:ssl_tsan_unlock
Unexecuted instantiation: quic_thread_assist.c:ssl_tsan_unlock
Unexecuted instantiation: quic_tls.c:ssl_tsan_unlock
Unexecuted instantiation: rec_layer_d1.c:ssl_tsan_unlock
Unexecuted instantiation: rec_layer_s3.c:ssl_tsan_unlock
Unexecuted instantiation: dtls_meth.c:ssl_tsan_unlock
Unexecuted instantiation: tls1_meth.c:ssl_tsan_unlock
Unexecuted instantiation: tls_common.c:ssl_tsan_unlock
Unexecuted instantiation: tls_multib.c:ssl_tsan_unlock
Unexecuted instantiation: tlsany_meth.c:ssl_tsan_unlock
Unexecuted instantiation: extensions.c:ssl_tsan_unlock
Unexecuted instantiation: extensions_clnt.c:ssl_tsan_unlock
Unexecuted instantiation: extensions_cust.c:ssl_tsan_unlock
Unexecuted instantiation: extensions_srvr.c:ssl_tsan_unlock
Unexecuted instantiation: statem.c:ssl_tsan_unlock
Unexecuted instantiation: statem_clnt.c:ssl_tsan_unlock
Unexecuted instantiation: statem_dtls.c:ssl_tsan_unlock
Unexecuted instantiation: statem_lib.c:ssl_tsan_unlock
Unexecuted instantiation: statem_srvr.c:ssl_tsan_unlock
Unexecuted instantiation: ech_helper.c:ssl_tsan_unlock
Unexecuted instantiation: ech_internal.c:ssl_tsan_unlock
Unexecuted instantiation: ech_store.c:ssl_tsan_unlock
Unexecuted instantiation: d1_lib.c:ssl_tsan_unlock
Unexecuted instantiation: d1_msg.c:ssl_tsan_unlock
Unexecuted instantiation: d1_srtp.c:ssl_tsan_unlock
Unexecuted instantiation: pqueue.c:ssl_tsan_unlock
Unexecuted instantiation: s3_enc.c:ssl_tsan_unlock
Unexecuted instantiation: ssl_asn1.c:ssl_tsan_unlock
Unexecuted instantiation: ssl_conf.c:ssl_tsan_unlock
Unexecuted instantiation: t1_enc.c:ssl_tsan_unlock
Unexecuted instantiation: quic_channel.c:ssl_tsan_unlock
Unexecuted instantiation: quic_engine.c:ssl_tsan_unlock
Unexecuted instantiation: quic_rx_depack.c:ssl_tsan_unlock
Unexecuted instantiation: tls13_meth.c:ssl_tsan_unlock
2974
2975
static ossl_unused ossl_inline void ssl_tsan_counter(const SSL_CTX *ctx,
2976
    TSAN_QUALIFIER int *stat)
2977
0
{
2978
0
    if (ssl_tsan_lock(ctx)) {
2979
0
        tsan_counter(stat);
2980
0
        ssl_tsan_unlock(ctx);
2981
0
    }
2982
0
}
Unexecuted instantiation: methods.c:ssl_tsan_counter
Unexecuted instantiation: s3_lib.c:ssl_tsan_counter
Unexecuted instantiation: s3_msg.c:ssl_tsan_counter
Unexecuted instantiation: ssl_cert.c:ssl_tsan_counter
Unexecuted instantiation: ssl_ciph.c:ssl_tsan_counter
Unexecuted instantiation: ssl_init.c:ssl_tsan_counter
Unexecuted instantiation: ssl_lib.c:ssl_tsan_counter
Unexecuted instantiation: ssl_mcnf.c:ssl_tsan_counter
Unexecuted instantiation: ssl_rsa.c:ssl_tsan_counter
Unexecuted instantiation: ssl_sess.c:ssl_tsan_counter
Unexecuted instantiation: ssl_stat.c:ssl_tsan_counter
Unexecuted instantiation: t1_lib.c:ssl_tsan_counter
Unexecuted instantiation: tls13_enc.c:ssl_tsan_counter
Unexecuted instantiation: tls_depr.c:ssl_tsan_counter
Unexecuted instantiation: tls_srp.c:ssl_tsan_counter
Unexecuted instantiation: quic_impl.c:ssl_tsan_counter
Unexecuted instantiation: quic_method.c:ssl_tsan_counter
Unexecuted instantiation: quic_obj.c:ssl_tsan_counter
Unexecuted instantiation: quic_port.c:ssl_tsan_counter
Unexecuted instantiation: quic_record_rx.c:ssl_tsan_counter
Unexecuted instantiation: quic_record_shared.c:ssl_tsan_counter
Unexecuted instantiation: quic_record_tx.c:ssl_tsan_counter
Unexecuted instantiation: quic_record_util.c:ssl_tsan_counter
Unexecuted instantiation: quic_thread_assist.c:ssl_tsan_counter
Unexecuted instantiation: quic_tls.c:ssl_tsan_counter
Unexecuted instantiation: rec_layer_d1.c:ssl_tsan_counter
Unexecuted instantiation: rec_layer_s3.c:ssl_tsan_counter
Unexecuted instantiation: dtls_meth.c:ssl_tsan_counter
Unexecuted instantiation: tls1_meth.c:ssl_tsan_counter
Unexecuted instantiation: tls_common.c:ssl_tsan_counter
Unexecuted instantiation: tls_multib.c:ssl_tsan_counter
Unexecuted instantiation: tlsany_meth.c:ssl_tsan_counter
Unexecuted instantiation: extensions.c:ssl_tsan_counter
Unexecuted instantiation: extensions_clnt.c:ssl_tsan_counter
Unexecuted instantiation: extensions_cust.c:ssl_tsan_counter
Unexecuted instantiation: extensions_srvr.c:ssl_tsan_counter
Unexecuted instantiation: statem.c:ssl_tsan_counter
Unexecuted instantiation: statem_clnt.c:ssl_tsan_counter
Unexecuted instantiation: statem_dtls.c:ssl_tsan_counter
Unexecuted instantiation: statem_lib.c:ssl_tsan_counter
Unexecuted instantiation: statem_srvr.c:ssl_tsan_counter
Unexecuted instantiation: ech_helper.c:ssl_tsan_counter
Unexecuted instantiation: ech_internal.c:ssl_tsan_counter
Unexecuted instantiation: ech_store.c:ssl_tsan_counter
Unexecuted instantiation: d1_lib.c:ssl_tsan_counter
Unexecuted instantiation: d1_msg.c:ssl_tsan_counter
Unexecuted instantiation: d1_srtp.c:ssl_tsan_counter
Unexecuted instantiation: pqueue.c:ssl_tsan_counter
Unexecuted instantiation: s3_enc.c:ssl_tsan_counter
Unexecuted instantiation: ssl_asn1.c:ssl_tsan_counter
Unexecuted instantiation: ssl_conf.c:ssl_tsan_counter
Unexecuted instantiation: t1_enc.c:ssl_tsan_counter
Unexecuted instantiation: quic_channel.c:ssl_tsan_counter
Unexecuted instantiation: quic_engine.c:ssl_tsan_counter
Unexecuted instantiation: quic_rx_depack.c:ssl_tsan_counter
Unexecuted instantiation: tls13_meth.c:ssl_tsan_counter
2983
2984
int ossl_comp_has_alg(int a);
2985
size_t ossl_calculate_comp_expansion(int alg, size_t length);
2986
2987
void ossl_ssl_set_custom_record_layer(SSL_CONNECTION *s,
2988
    const OSSL_RECORD_METHOD *meth,
2989
    void *rlarg);
2990
2991
long ossl_ctrl_internal(SSL *s, int cmd, long larg, void *parg, int no_quic);
2992
2993
/*
2994
 * Options which no longer have any effect, but which can be implemented
2995
 * as no-ops for QUIC.
2996
 */
2997
#define OSSL_LEGACY_SSL_OPTIONS \
2998
0
    (SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG | SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER | SSL_OP_SSLEAY_080_CLIENT_DH_BUG | SSL_OP_TLS_D5_BUG | SSL_OP_TLS_BLOCK_PADDING_BUG | SSL_OP_MSIE_SSLV2_RSA_PADDING | SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG | SSL_OP_MICROSOFT_SESS_ID_BUG | SSL_OP_NETSCAPE_CHALLENGE_BUG | SSL_OP_PKCS1_CHECK_1 | SSL_OP_PKCS1_CHECK_2 | SSL_OP_SINGLE_DH_USE | SSL_OP_SINGLE_ECDH_USE | SSL_OP_EPHEMERAL_RSA)
2999
3000
/* This option is undefined in public headers with no-dtls1-method. */
3001
#ifndef SSL_OP_CISCO_ANYCONNECT
3002
#define SSL_OP_CISCO_ANYCONNECT 0
3003
#endif
3004
/*
3005
 * Options which are no-ops under QUIC or TLSv1.3 and which are therefore
3006
 * allowed but ignored under QUIC.
3007
 */
3008
#define OSSL_TLS1_2_OPTIONS \
3009
0
    (SSL_OP_CRYPTOPRO_TLSEXT_BUG | SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS | SSL_OP_ALLOW_CLIENT_RENEGOTIATION | SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION | SSL_OP_NO_COMPRESSION | SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1 | SSL_OP_NO_TLSv1_2 | SSL_OP_NO_DTLSv1 | SSL_OP_NO_DTLSv1_2 | SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION | SSL_OP_CISCO_ANYCONNECT | SSL_OP_NO_RENEGOTIATION | SSL_OP_NO_EXTENDED_MASTER_SECRET | SSL_OP_NO_ENCRYPT_THEN_MAC | SSL_OP_COOKIE_EXCHANGE | SSL_OP_LEGACY_SERVER_CONNECT | SSL_OP_IGNORE_UNEXPECTED_EOF)
3010
3011
/* Total mask of connection-level options permitted or ignored under QUIC. */
3012
#define OSSL_QUIC_PERMITTED_OPTIONS_CONN \
3013
0
    (OSSL_LEGACY_SSL_OPTIONS | OSSL_TLS1_2_OPTIONS | SSL_OP_SERVER_PREFERENCE | SSL_OP_DISABLE_TLSEXT_CA_NAMES | SSL_OP_NO_TX_CERTIFICATE_COMPRESSION | SSL_OP_NO_RX_CERTIFICATE_COMPRESSION | SSL_OP_PRIORITIZE_CHACHA | SSL_OP_NO_QUERY_MTU | SSL_OP_NO_TICKET | SSL_OP_NO_ANTI_REPLAY)
3014
3015
/* Total mask of stream-level options permitted or ignored under QUIC. */
3016
#define OSSL_QUIC_PERMITTED_OPTIONS_STREAM \
3017
0
    (OSSL_LEGACY_SSL_OPTIONS | OSSL_TLS1_2_OPTIONS | SSL_OP_CLEANSE_PLAINTEXT)
3018
3019
/* Total mask of options permitted on either connections or streams. */
3020
#define OSSL_QUIC_PERMITTED_OPTIONS \
3021
0
    (OSSL_QUIC_PERMITTED_OPTIONS_CONN | OSSL_QUIC_PERMITTED_OPTIONS_STREAM)
3022
3023
/* Total mask of domain flags supported on a QUIC SSL_CTX. */
3024
#define OSSL_QUIC_SUPPORTED_DOMAIN_FLAGS \
3025
0
    (SSL_DOMAIN_FLAG_SINGLE_THREAD | SSL_DOMAIN_FLAG_MULTI_THREAD | SSL_DOMAIN_FLAG_THREAD_ASSISTED | SSL_DOMAIN_FLAG_BLOCKING | SSL_DOMAIN_FLAG_LEGACY_BLOCKING)
3026
3027
#endif