Coverage Report

Created: 2026-11-16 07:12

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