/src/openssl/crypto/conf/conf_sap.c
Line  | Count  | Source (jump to first uncovered line)  | 
1  |  | /*  | 
2  |  |  * Copyright 2002-2024 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 <stdio.h>  | 
11  |  | #include <openssl/crypto.h>  | 
12  |  | #include "internal/cryptlib.h"  | 
13  |  | #include "internal/conf.h"  | 
14  |  | #include "conf_local.h"  | 
15  |  | #include <openssl/x509.h>  | 
16  |  | #include <openssl/asn1.h>  | 
17  |  | #include <openssl/engine.h>  | 
18  |  |  | 
19  |  | #if defined(_WIN32) && !defined(__BORLANDC__)  | 
20  |  | # define strdup _strdup  | 
21  |  | #endif  | 
22  |  |  | 
23  |  | /*  | 
24  |  |  * This is the automatic configuration loader: it is called automatically by  | 
25  |  |  * OpenSSL when any of a number of standard initialisation functions are  | 
26  |  |  * called, unless this is overridden by calling OPENSSL_no_config()  | 
27  |  |  */  | 
28  |  |  | 
29  |  | static int openssl_configured = 0;  | 
30  |  |  | 
31  |  | #ifndef OPENSSL_NO_DEPRECATED_1_1_0  | 
32  |  | void OPENSSL_config(const char *appname)  | 
33  | 0  | { | 
34  | 0  |     OPENSSL_INIT_SETTINGS settings;  | 
35  |  | 
  | 
36  | 0  |     memset(&settings, 0, sizeof(settings));  | 
37  | 0  |     if (appname != NULL)  | 
38  | 0  |         settings.appname = strdup(appname);  | 
39  | 0  |     settings.flags = DEFAULT_CONF_MFLAGS;  | 
40  | 0  |     OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, &settings);  | 
41  |  | 
  | 
42  | 0  |     free(settings.appname);  | 
43  | 0  | }  | 
44  |  | #endif  | 
45  |  |  | 
46  |  | int ossl_config_int(const OPENSSL_INIT_SETTINGS *settings)  | 
47  | 2  | { | 
48  | 2  |     int ret = 0;  | 
49  | 2  | #if defined(OPENSSL_INIT_DEBUG) || !defined(OPENSSL_SYS_UEFI)  | 
50  | 2  |     const char *filename;  | 
51  | 2  |     const char *appname;  | 
52  | 2  |     unsigned long flags;  | 
53  | 2  | #endif  | 
54  |  |  | 
55  | 2  |     if (openssl_configured)  | 
56  | 0  |         return 1;  | 
57  |  |  | 
58  | 2  | #if defined(OPENSSL_INIT_DEBUG) || !defined(OPENSSL_SYS_UEFI)  | 
59  | 2  |     filename = settings ? settings->filename : NULL;  | 
60  | 2  |     appname = settings ? settings->appname : NULL;  | 
61  | 2  |     flags = settings ? settings->flags : DEFAULT_CONF_MFLAGS;  | 
62  | 2  | #endif  | 
63  |  |  | 
64  |  | #ifdef OPENSSL_INIT_DEBUG  | 
65  |  |     fprintf(stderr, "OPENSSL_INIT: ossl_config_int(%s, %s, %lu)\n",  | 
66  |  |             filename, appname, flags);  | 
67  |  | #endif  | 
68  |  |  | 
69  | 2  | #ifndef OPENSSL_SYS_UEFI  | 
70  | 2  |     ret = CONF_modules_load_file_ex(OSSL_LIB_CTX_get0_global_default(),  | 
71  | 2  |                                     filename, appname, flags);  | 
72  |  | #else  | 
73  |  |     ret = 1;  | 
74  |  | #endif  | 
75  | 2  |     openssl_configured = 1;  | 
76  | 2  |     return ret;  | 
77  | 2  | }  | 
78  |  |  | 
79  |  | void ossl_no_config_int(void)  | 
80  | 0  | { | 
81  | 0  |     openssl_configured = 1;  | 
82  | 0  | }  |