Coverage Report

Created: 2026-10-28 06:28

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