Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/workdir/UnpackedTarball/openssl/crypto/context.c
Line
Count
Source
1
/*
2
 * Copyright 2019-2025 The OpenSSL Project Authors. All Rights Reserved.
3
 *
4
 * Licensed under the Apache License 2.0 (the "License").  You may not use
5
 * this file except in compliance with the License.  You can obtain a copy
6
 * in the file LICENSE in the source distribution or at
7
 * https://www.openssl.org/source/license.html
8
 */
9
10
#include "crypto/cryptlib.h"
11
#include <openssl/conf.h>
12
#include <openssl/trace.h>
13
#include "internal/thread_once.h"
14
#include "internal/property.h"
15
#include "internal/cryptlib.h"
16
#include "internal/core.h"
17
#include "internal/bio.h"
18
#include "internal/provider.h"
19
#include "crypto/decoder.h"
20
#include "crypto/context.h"
21
22
struct ossl_lib_ctx_st {
23
    CRYPTO_RWLOCK *lock;
24
    OSSL_EX_DATA_GLOBAL global;
25
26
    void *property_string_data;
27
    void *evp_method_store;
28
    void *provider_store;
29
    void *namemap;
30
    void *property_defns;
31
    void *global_properties;
32
    void *drbg;
33
    void *drbg_nonce;
34
    CRYPTO_THREAD_LOCAL rcu_local_key;
35
#ifndef FIPS_MODULE
36
    void *provider_conf;
37
    void *bio_core;
38
    void *child_provider;
39
    OSSL_METHOD_STORE *decoder_store;
40
    void *decoder_cache;
41
    OSSL_METHOD_STORE *encoder_store;
42
    OSSL_METHOD_STORE *store_loader_store;
43
    void *self_test_cb;
44
    void *indicator_cb;
45
#endif
46
#if defined(OPENSSL_THREADS)
47
    void *threads;
48
#endif
49
#ifdef FIPS_MODULE
50
    void *thread_event_handler;
51
    void *fips_prov;
52
#endif
53
    STACK_OF(SSL_COMP) *comp_methods;
54
55
    int ischild;
56
    int conf_diagnostics;
57
};
58
59
int ossl_lib_ctx_write_lock(OSSL_LIB_CTX *ctx)
60
5
{
61
5
    if ((ctx = ossl_lib_ctx_get_concrete(ctx)) == NULL)
62
0
        return 0;
63
5
    return CRYPTO_THREAD_write_lock(ctx->lock);
64
5
}
65
66
int ossl_lib_ctx_read_lock(OSSL_LIB_CTX *ctx)
67
387
{
68
387
    if ((ctx = ossl_lib_ctx_get_concrete(ctx)) == NULL)
69
0
        return 0;
70
387
    return CRYPTO_THREAD_read_lock(ctx->lock);
71
387
}
72
73
int ossl_lib_ctx_unlock(OSSL_LIB_CTX *ctx)
74
392
{
75
392
    if ((ctx = ossl_lib_ctx_get_concrete(ctx)) == NULL)
76
0
        return 0;
77
392
    return CRYPTO_THREAD_unlock(ctx->lock);
78
392
}
79
80
int ossl_lib_ctx_is_child(OSSL_LIB_CTX *ctx)
81
0
{
82
0
    ctx = ossl_lib_ctx_get_concrete(ctx);
83
84
0
    if (ctx == NULL)
85
0
        return 0;
86
0
    return ctx->ischild;
87
0
}
88
89
static void context_deinit_objs(OSSL_LIB_CTX *ctx);
90
91
static int context_init(OSSL_LIB_CTX *ctx)
92
5
{
93
5
    int exdata_done = 0;
94
95
5
    if (!CRYPTO_THREAD_init_local(&ctx->rcu_local_key, NULL))
96
0
        return 0;
97
98
5
    ctx->lock = CRYPTO_THREAD_lock_new();
99
5
    if (ctx->lock == NULL)
100
0
        goto err;
101
102
    /* Initialize ex_data. */
103
5
    if (!ossl_do_ex_data_init(ctx))
104
0
        goto err;
105
5
    exdata_done = 1;
106
107
    /* P2. We want evp_method_store to be cleaned up before the provider store */
108
5
    ctx->evp_method_store = ossl_method_store_new(ctx);
109
5
    if (ctx->evp_method_store == NULL)
110
0
        goto err;
111
5
    OSSL_TRACE1(QUERY, "context_init: allocating store %p\n", ctx->evp_method_store);
112
113
5
#ifndef FIPS_MODULE
114
    /* P2. Must be freed before the provider store is freed */
115
5
    ctx->provider_conf = ossl_prov_conf_ctx_new(ctx);
116
5
    if (ctx->provider_conf == NULL)
117
0
        goto err;
118
5
#endif
119
120
    /* P2. */
121
5
    ctx->drbg = ossl_rand_ctx_new(ctx);
122
5
    if (ctx->drbg == NULL)
123
0
        goto err;
124
125
5
#ifndef FIPS_MODULE
126
    /*
127
     * P2. We want decoder_store/decoder_cache to be cleaned up before the
128
     * provider store
129
     */
130
5
    ctx->decoder_store = ossl_method_store_new(ctx);
131
5
    if (ctx->decoder_store == NULL)
132
0
        goto err;
133
5
    ctx->decoder_cache = ossl_decoder_cache_new(ctx);
134
5
    if (ctx->decoder_cache == NULL)
135
0
        goto err;
136
137
    /* P2. We want encoder_store to be cleaned up before the provider store */
138
5
    ctx->encoder_store = ossl_method_store_new(ctx);
139
5
    if (ctx->encoder_store == NULL)
140
0
        goto err;
141
142
    /* P2. We want loader_store to be cleaned up before the provider store */
143
5
    ctx->store_loader_store = ossl_method_store_new(ctx);
144
5
    if (ctx->store_loader_store == NULL)
145
0
        goto err;
146
5
#endif
147
148
    /* P1. Needs to be freed before the child provider data is freed */
149
5
    ctx->provider_store = ossl_provider_store_new(ctx);
150
5
    if (ctx->provider_store == NULL)
151
0
        goto err;
152
153
    /* Default priority. */
154
5
    ctx->property_string_data = ossl_property_string_data_new(ctx);
155
5
    if (ctx->property_string_data == NULL)
156
0
        goto err;
157
158
5
    ctx->namemap = ossl_stored_namemap_new(ctx);
159
5
    if (ctx->namemap == NULL)
160
0
        goto err;
161
162
5
    ctx->property_defns = ossl_property_defns_new(ctx);
163
5
    if (ctx->property_defns == NULL)
164
0
        goto err;
165
166
5
    ctx->global_properties = ossl_ctx_global_properties_new(ctx);
167
5
    if (ctx->global_properties == NULL)
168
0
        goto err;
169
170
5
#ifndef FIPS_MODULE
171
5
    ctx->bio_core = ossl_bio_core_globals_new(ctx);
172
5
    if (ctx->bio_core == NULL)
173
0
        goto err;
174
5
#endif
175
176
5
    ctx->drbg_nonce = ossl_prov_drbg_nonce_ctx_new(ctx);
177
5
    if (ctx->drbg_nonce == NULL)
178
0
        goto err;
179
180
5
#ifndef FIPS_MODULE
181
5
    ctx->self_test_cb = ossl_self_test_set_callback_new(ctx);
182
5
    if (ctx->self_test_cb == NULL)
183
0
        goto err;
184
5
    ctx->indicator_cb = ossl_indicator_set_callback_new(ctx);
185
5
    if (ctx->indicator_cb == NULL)
186
0
        goto err;
187
5
#endif
188
189
#ifdef FIPS_MODULE
190
    ctx->thread_event_handler = ossl_thread_event_ctx_new(ctx);
191
    if (ctx->thread_event_handler == NULL)
192
        goto err;
193
194
    ctx->fips_prov = ossl_fips_prov_ossl_ctx_new(ctx);
195
    if (ctx->fips_prov == NULL)
196
        goto err;
197
#endif
198
199
5
#ifndef OPENSSL_NO_THREAD_POOL
200
5
    ctx->threads = ossl_threads_ctx_new(ctx);
201
5
    if (ctx->threads == NULL)
202
0
        goto err;
203
5
#endif
204
205
    /* Low priority. */
206
5
#ifndef FIPS_MODULE
207
5
    ctx->child_provider = ossl_child_prov_ctx_new(ctx);
208
5
    if (ctx->child_provider == NULL)
209
0
        goto err;
210
5
#endif
211
212
    /* Everything depends on properties, so we also pre-initialise that */
213
5
    if (!ossl_property_parse_init(ctx))
214
0
        goto err;
215
216
5
#ifndef FIPS_MODULE
217
5
    ctx->comp_methods = ossl_load_builtin_compressions();
218
5
#endif
219
220
5
    return 1;
221
222
0
err:
223
0
    context_deinit_objs(ctx);
224
225
0
    if (exdata_done)
226
0
        ossl_crypto_cleanup_all_ex_data_int(ctx);
227
228
0
    CRYPTO_THREAD_lock_free(ctx->lock);
229
0
    CRYPTO_THREAD_cleanup_local(&ctx->rcu_local_key);
230
0
    memset(ctx, '\0', sizeof(*ctx));
231
0
    return 0;
232
5
}
233
234
static void context_deinit_objs(OSSL_LIB_CTX *ctx)
235
5
{
236
    /* P2. We want evp_method_store to be cleaned up before the provider store */
237
5
    if (ctx->evp_method_store != NULL) {
238
5
        ossl_method_store_free(ctx->evp_method_store);
239
5
        ctx->evp_method_store = NULL;
240
5
    }
241
242
    /* P2. */
243
5
    if (ctx->drbg != NULL) {
244
5
        ossl_rand_ctx_free(ctx->drbg);
245
5
        ctx->drbg = NULL;
246
5
    }
247
248
5
#ifndef FIPS_MODULE
249
    /* P2. */
250
5
    if (ctx->provider_conf != NULL) {
251
5
        ossl_prov_conf_ctx_free(ctx->provider_conf);
252
5
        ctx->provider_conf = NULL;
253
5
    }
254
255
    /*
256
     * P2. We want decoder_store/decoder_cache to be cleaned up before the
257
     * provider store
258
     */
259
5
    if (ctx->decoder_store != NULL) {
260
5
        ossl_method_store_free(ctx->decoder_store);
261
5
        ctx->decoder_store = NULL;
262
5
    }
263
5
    if (ctx->decoder_cache != NULL) {
264
5
        ossl_decoder_cache_free(ctx->decoder_cache);
265
5
        ctx->decoder_cache = NULL;
266
5
    }
267
268
    /* P2. We want encoder_store to be cleaned up before the provider store */
269
5
    if (ctx->encoder_store != NULL) {
270
5
        ossl_method_store_free(ctx->encoder_store);
271
5
        ctx->encoder_store = NULL;
272
5
    }
273
274
    /* P2. We want loader_store to be cleaned up before the provider store */
275
5
    if (ctx->store_loader_store != NULL) {
276
5
        ossl_method_store_free(ctx->store_loader_store);
277
5
        ctx->store_loader_store = NULL;
278
5
    }
279
5
#endif
280
281
    /* P1. Needs to be freed before the child provider data is freed */
282
5
    if (ctx->provider_store != NULL) {
283
5
        ossl_provider_store_free(ctx->provider_store);
284
5
        ctx->provider_store = NULL;
285
5
    }
286
287
    /* Default priority. */
288
5
    if (ctx->property_string_data != NULL) {
289
5
        ossl_property_string_data_free(ctx->property_string_data);
290
5
        ctx->property_string_data = NULL;
291
5
    }
292
293
5
    if (ctx->namemap != NULL) {
294
5
        ossl_stored_namemap_free(ctx->namemap);
295
5
        ctx->namemap = NULL;
296
5
    }
297
298
5
    if (ctx->property_defns != NULL) {
299
5
        ossl_property_defns_free(ctx->property_defns);
300
5
        ctx->property_defns = NULL;
301
5
    }
302
303
5
    if (ctx->global_properties != NULL) {
304
5
        ossl_ctx_global_properties_free(ctx->global_properties);
305
5
        ctx->global_properties = NULL;
306
5
    }
307
308
5
#ifndef FIPS_MODULE
309
5
    if (ctx->bio_core != NULL) {
310
5
        ossl_bio_core_globals_free(ctx->bio_core);
311
5
        ctx->bio_core = NULL;
312
5
    }
313
5
#endif
314
315
5
    if (ctx->drbg_nonce != NULL) {
316
5
        ossl_prov_drbg_nonce_ctx_free(ctx->drbg_nonce);
317
5
        ctx->drbg_nonce = NULL;
318
5
    }
319
320
5
#ifndef FIPS_MODULE
321
5
    if (ctx->indicator_cb != NULL) {
322
5
        ossl_indicator_set_callback_free(ctx->indicator_cb);
323
5
        ctx->indicator_cb = NULL;
324
5
    }
325
326
5
    if (ctx->self_test_cb != NULL) {
327
5
        ossl_self_test_set_callback_free(ctx->self_test_cb);
328
5
        ctx->self_test_cb = NULL;
329
5
    }
330
5
#endif
331
332
#ifdef FIPS_MODULE
333
    if (ctx->thread_event_handler != NULL) {
334
        ossl_thread_event_ctx_free(ctx->thread_event_handler);
335
        ctx->thread_event_handler = NULL;
336
    }
337
338
    if (ctx->fips_prov != NULL) {
339
        ossl_fips_prov_ossl_ctx_free(ctx->fips_prov);
340
        ctx->fips_prov = NULL;
341
    }
342
#endif
343
344
5
#ifndef OPENSSL_NO_THREAD_POOL
345
5
    if (ctx->threads != NULL) {
346
5
        ossl_threads_ctx_free(ctx->threads);
347
5
        ctx->threads = NULL;
348
5
    }
349
5
#endif
350
351
    /* Low priority. */
352
5
#ifndef FIPS_MODULE
353
5
    if (ctx->child_provider != NULL) {
354
5
        ossl_child_prov_ctx_free(ctx->child_provider);
355
5
        ctx->child_provider = NULL;
356
5
    }
357
5
#endif
358
359
5
#ifndef FIPS_MODULE
360
5
    if (ctx->comp_methods != NULL) {
361
5
        ossl_free_compression_methods_int(ctx->comp_methods);
362
5
        ctx->comp_methods = NULL;
363
5
    }
364
5
#endif
365
5
}
366
367
static int context_deinit(OSSL_LIB_CTX *ctx)
368
5
{
369
5
    if (ctx == NULL)
370
0
        return 1;
371
372
5
    ossl_ctx_thread_stop(ctx);
373
374
5
    context_deinit_objs(ctx);
375
376
5
    ossl_crypto_cleanup_all_ex_data_int(ctx);
377
378
5
    CRYPTO_THREAD_lock_free(ctx->lock);
379
5
    ctx->lock = NULL;
380
5
    CRYPTO_THREAD_cleanup_local(&ctx->rcu_local_key);
381
5
    return 1;
382
5
}
383
384
#ifndef FIPS_MODULE
385
/* The default default context */
386
static OSSL_LIB_CTX default_context_int;
387
388
static CRYPTO_ONCE default_context_init = CRYPTO_ONCE_STATIC_INIT;
389
static CRYPTO_THREAD_LOCAL default_context_thread_local;
390
static int default_context_inited = 0;
391
392
DEFINE_RUN_ONCE_STATIC(default_context_do_init)
393
5
{
394
5
    if (!CRYPTO_THREAD_init_local(&default_context_thread_local, NULL))
395
0
        goto err;
396
397
5
    if (!context_init(&default_context_int))
398
0
        goto deinit_thread;
399
400
5
    default_context_inited = 1;
401
5
    return 1;
402
403
0
deinit_thread:
404
0
    CRYPTO_THREAD_cleanup_local(&default_context_thread_local);
405
0
err:
406
0
    return 0;
407
0
}
408
409
void ossl_lib_ctx_default_deinit(void)
410
5
{
411
5
    if (!default_context_inited)
412
0
        return;
413
5
    context_deinit(&default_context_int);
414
5
    CRYPTO_THREAD_cleanup_local(&default_context_thread_local);
415
5
    default_context_inited = 0;
416
5
}
417
418
static OSSL_LIB_CTX *get_thread_default_context(void)
419
4.32M
{
420
4.32M
    if (!RUN_ONCE(&default_context_init, default_context_do_init))
421
0
        return NULL;
422
423
4.32M
    return CRYPTO_THREAD_get_local(&default_context_thread_local);
424
4.32M
}
425
426
static OSSL_LIB_CTX *get_default_context(void)
427
4.32M
{
428
4.32M
    OSSL_LIB_CTX *current_defctx = get_thread_default_context();
429
430
4.32M
    if (current_defctx == NULL && default_context_inited)
431
4.32M
        current_defctx = &default_context_int;
432
4.32M
    return current_defctx;
433
4.32M
}
434
435
static int set_default_context(OSSL_LIB_CTX *defctx)
436
0
{
437
0
    if (defctx == &default_context_int)
438
0
        defctx = NULL;
439
440
0
    return CRYPTO_THREAD_set_local(&default_context_thread_local, defctx);
441
0
}
442
#endif
443
444
OSSL_LIB_CTX *OSSL_LIB_CTX_new(void)
445
0
{
446
0
    OSSL_LIB_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
447
448
0
    if (ctx != NULL && !context_init(ctx)) {
449
0
        OPENSSL_free(ctx);
450
0
        ctx = NULL;
451
0
    }
452
0
    return ctx;
453
0
}
454
455
#ifndef FIPS_MODULE
456
OSSL_LIB_CTX *OSSL_LIB_CTX_new_from_dispatch(const OSSL_CORE_HANDLE *handle,
457
    const OSSL_DISPATCH *in)
458
0
{
459
0
    OSSL_LIB_CTX *ctx = OSSL_LIB_CTX_new();
460
461
0
    if (ctx == NULL)
462
0
        return NULL;
463
464
0
    if (!ossl_bio_init_core(ctx, in)) {
465
0
        OSSL_LIB_CTX_free(ctx);
466
0
        return NULL;
467
0
    }
468
469
0
    return ctx;
470
0
}
471
472
OSSL_LIB_CTX *OSSL_LIB_CTX_new_child(const OSSL_CORE_HANDLE *handle,
473
    const OSSL_DISPATCH *in)
474
0
{
475
0
    OSSL_LIB_CTX *ctx = OSSL_LIB_CTX_new_from_dispatch(handle, in);
476
477
0
    if (ctx == NULL)
478
0
        return NULL;
479
480
0
    if (!ossl_provider_init_as_child(ctx, handle, in)) {
481
0
        OSSL_LIB_CTX_free(ctx);
482
0
        return NULL;
483
0
    }
484
0
    ctx->ischild = 1;
485
486
0
    return ctx;
487
0
}
488
489
int OSSL_LIB_CTX_load_config(OSSL_LIB_CTX *ctx, const char *config_file)
490
0
{
491
0
    return CONF_modules_load_file_ex(ctx, config_file, NULL, 0) > 0;
492
0
}
493
#endif
494
495
void OSSL_LIB_CTX_free(OSSL_LIB_CTX *ctx)
496
0
{
497
0
    if (ctx == NULL || ossl_lib_ctx_is_default(ctx))
498
0
        return;
499
500
0
#ifndef FIPS_MODULE
501
0
    if (ctx->ischild)
502
0
        ossl_provider_deinit_child(ctx);
503
0
#endif
504
0
    context_deinit(ctx);
505
0
    OPENSSL_free(ctx);
506
0
}
507
508
#ifndef FIPS_MODULE
509
OSSL_LIB_CTX *OSSL_LIB_CTX_get0_global_default(void)
510
5
{
511
5
    if (!RUN_ONCE(&default_context_init, default_context_do_init))
512
0
        return NULL;
513
514
5
    return &default_context_int;
515
5
}
516
517
OSSL_LIB_CTX *OSSL_LIB_CTX_set0_default(OSSL_LIB_CTX *libctx)
518
0
{
519
0
    OSSL_LIB_CTX *current_defctx;
520
521
0
    if ((current_defctx = get_default_context()) != NULL) {
522
0
        if (libctx != NULL)
523
0
            set_default_context(libctx);
524
0
        return current_defctx;
525
0
    }
526
527
0
    return NULL;
528
0
}
529
530
void ossl_release_default_drbg_ctx(void)
531
0
{
532
    /* early release of the DRBG in global default libctx */
533
0
    if (default_context_int.drbg != NULL) {
534
0
        ossl_rand_ctx_free(default_context_int.drbg);
535
0
        default_context_int.drbg = NULL;
536
0
    }
537
0
}
538
#endif
539
540
OSSL_LIB_CTX *ossl_lib_ctx_get_concrete(OSSL_LIB_CTX *ctx)
541
4.32M
{
542
4.32M
#ifndef FIPS_MODULE
543
4.32M
    if (ctx == NULL)
544
4.32M
        return get_default_context();
545
2.04k
#endif
546
2.04k
    return ctx;
547
4.32M
}
548
549
int ossl_lib_ctx_is_default(OSSL_LIB_CTX *ctx)
550
22
{
551
22
#ifndef FIPS_MODULE
552
22
    if (ctx == NULL || ctx == get_default_context())
553
22
        return 1;
554
0
#endif
555
0
    return 0;
556
22
}
557
558
int ossl_lib_ctx_is_global_default(OSSL_LIB_CTX *ctx)
559
0
{
560
0
#ifndef FIPS_MODULE
561
0
    if (ossl_lib_ctx_get_concrete(ctx) == &default_context_int)
562
0
        return 1;
563
0
#endif
564
0
    return 0;
565
0
}
566
567
void *ossl_lib_ctx_get_data(OSSL_LIB_CTX *ctx, int index)
568
4.32M
{
569
4.32M
    ctx = ossl_lib_ctx_get_concrete(ctx);
570
4.32M
    if (ctx == NULL)
571
0
        return NULL;
572
573
4.32M
    switch (index) {
574
50
    case OSSL_LIB_CTX_PROPERTY_STRING_INDEX:
575
50
        return ctx->property_string_data;
576
2.16M
    case OSSL_LIB_CTX_EVP_METHOD_STORE_INDEX:
577
2.16M
        return ctx->evp_method_store;
578
21
    case OSSL_LIB_CTX_PROVIDER_STORE_INDEX:
579
21
        return ctx->provider_store;
580
2.16M
    case OSSL_LIB_CTX_NAMEMAP_INDEX:
581
2.16M
        return ctx->namemap;
582
392
    case OSSL_LIB_CTX_PROPERTY_DEFN_INDEX:
583
392
        return ctx->property_defns;
584
11
    case OSSL_LIB_CTX_GLOBAL_PROPERTIES:
585
11
        return ctx->global_properties;
586
0
    case OSSL_LIB_CTX_DRBG_INDEX:
587
0
        return ctx->drbg;
588
0
    case OSSL_LIB_CTX_DRBG_NONCE_INDEX:
589
0
        return ctx->drbg_nonce;
590
0
#ifndef FIPS_MODULE
591
0
    case OSSL_LIB_CTX_PROVIDER_CONF_INDEX:
592
0
        return ctx->provider_conf;
593
0
    case OSSL_LIB_CTX_BIO_CORE_INDEX:
594
0
        return ctx->bio_core;
595
0
    case OSSL_LIB_CTX_CHILD_PROVIDER_INDEX:
596
0
        return ctx->child_provider;
597
0
    case OSSL_LIB_CTX_DECODER_STORE_INDEX:
598
0
        return ctx->decoder_store;
599
5
    case OSSL_LIB_CTX_DECODER_CACHE_INDEX:
600
5
        return ctx->decoder_cache;
601
0
    case OSSL_LIB_CTX_ENCODER_STORE_INDEX:
602
0
        return ctx->encoder_store;
603
0
    case OSSL_LIB_CTX_STORE_LOADER_STORE_INDEX:
604
0
        return ctx->store_loader_store;
605
0
    case OSSL_LIB_CTX_SELF_TEST_CB_INDEX:
606
0
        return ctx->self_test_cb;
607
0
    case OSSL_LIB_CTX_INDICATOR_CB_INDEX:
608
0
        return ctx->indicator_cb;
609
0
#endif
610
0
#ifndef OPENSSL_NO_THREAD_POOL
611
0
    case OSSL_LIB_CTX_THREAD_INDEX:
612
0
        return ctx->threads;
613
0
#endif
614
615
#ifdef FIPS_MODULE
616
    case OSSL_LIB_CTX_THREAD_EVENT_HANDLER_INDEX:
617
        return ctx->thread_event_handler;
618
619
    case OSSL_LIB_CTX_FIPS_PROV_INDEX:
620
        return ctx->fips_prov;
621
#endif
622
623
0
    case OSSL_LIB_CTX_COMP_METHODS:
624
0
        return (void *)&ctx->comp_methods;
625
626
0
    default:
627
0
        return NULL;
628
4.32M
    }
629
4.32M
}
630
631
void *OSSL_LIB_CTX_get_data(OSSL_LIB_CTX *ctx, int index)
632
0
{
633
0
    return ossl_lib_ctx_get_data(ctx, index);
634
0
}
635
636
OSSL_EX_DATA_GLOBAL *ossl_lib_ctx_get_ex_data_global(OSSL_LIB_CTX *ctx)
637
10
{
638
10
    ctx = ossl_lib_ctx_get_concrete(ctx);
639
10
    if (ctx == NULL)
640
0
        return NULL;
641
10
    return &ctx->global;
642
10
}
643
644
const char *ossl_lib_ctx_get_descriptor(OSSL_LIB_CTX *libctx)
645
0
{
646
#ifdef FIPS_MODULE
647
    return "FIPS internal library context";
648
#else
649
0
    if (ossl_lib_ctx_is_global_default(libctx))
650
0
        return "Global default library context";
651
0
    if (ossl_lib_ctx_is_default(libctx))
652
0
        return "Thread-local default library context";
653
0
    return "Non-default library context";
654
0
#endif
655
0
}
656
657
CRYPTO_THREAD_LOCAL *ossl_lib_ctx_get_rcukey(OSSL_LIB_CTX *libctx)
658
0
{
659
0
    libctx = ossl_lib_ctx_get_concrete(libctx);
660
0
    if (libctx == NULL)
661
0
        return NULL;
662
0
    return &libctx->rcu_local_key;
663
0
}
664
665
int OSSL_LIB_CTX_get_conf_diagnostics(OSSL_LIB_CTX *libctx)
666
5
{
667
5
    libctx = ossl_lib_ctx_get_concrete(libctx);
668
5
    if (libctx == NULL)
669
0
        return 0;
670
5
    return libctx->conf_diagnostics;
671
5
}
672
673
void OSSL_LIB_CTX_set_conf_diagnostics(OSSL_LIB_CTX *libctx, int value)
674
0
{
675
0
    libctx = ossl_lib_ctx_get_concrete(libctx);
676
0
    if (libctx == NULL)
677
0
        return;
678
0
    libctx->conf_diagnostics = value;
679
0
}