Coverage Report

Created: 2025-06-13 06:58

/src/openssl32/crypto/engine/eng_fat.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved.
3
 * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
4
 *
5
 * Licensed under the Apache License 2.0 (the "License").  You may not use
6
 * this file except in compliance with the License.  You can obtain a copy
7
 * in the file LICENSE in the source distribution or at
8
 * https://www.openssl.org/source/license.html
9
 */
10
11
/* We need to use some engine deprecated APIs */
12
#define OPENSSL_SUPPRESS_DEPRECATED
13
14
#include "eng_local.h"
15
#include <openssl/conf.h>
16
17
int ENGINE_set_default(ENGINE *e, unsigned int flags)
18
0
{
19
0
    if ((flags & ENGINE_METHOD_CIPHERS) && !ENGINE_set_default_ciphers(e))
20
0
        return 0;
21
0
    if ((flags & ENGINE_METHOD_DIGESTS) && !ENGINE_set_default_digests(e))
22
0
        return 0;
23
0
    if ((flags & ENGINE_METHOD_RSA) && !ENGINE_set_default_RSA(e))
24
0
        return 0;
25
0
#ifndef OPENSSL_NO_DSA
26
0
    if ((flags & ENGINE_METHOD_DSA) && !ENGINE_set_default_DSA(e))
27
0
        return 0;
28
0
#endif
29
0
#ifndef OPENSSL_NO_DH
30
0
    if ((flags & ENGINE_METHOD_DH) && !ENGINE_set_default_DH(e))
31
0
        return 0;
32
0
#endif
33
0
#ifndef OPENSSL_NO_EC
34
0
    if ((flags & ENGINE_METHOD_EC) && !ENGINE_set_default_EC(e))
35
0
        return 0;
36
0
#endif
37
0
    if ((flags & ENGINE_METHOD_RAND) && !ENGINE_set_default_RAND(e))
38
0
        return 0;
39
0
    if ((flags & ENGINE_METHOD_PKEY_METHS)
40
0
        && !ENGINE_set_default_pkey_meths(e))
41
0
        return 0;
42
0
    if ((flags & ENGINE_METHOD_PKEY_ASN1_METHS)
43
0
        && !ENGINE_set_default_pkey_asn1_meths(e))
44
0
        return 0;
45
0
    return 1;
46
0
}
47
48
/* Set default algorithms using a string */
49
50
static int int_def_cb(const char *alg, int len, void *arg)
51
0
{
52
0
    unsigned int *pflags = arg;
53
0
    if (alg == NULL)
54
0
        return 0;
55
0
    if (strncmp(alg, "ALL", len) == 0)
56
0
        *pflags |= ENGINE_METHOD_ALL;
57
0
    else if (strncmp(alg, "RSA", len) == 0)
58
0
        *pflags |= ENGINE_METHOD_RSA;
59
0
    else if (strncmp(alg, "DSA", len) == 0)
60
0
        *pflags |= ENGINE_METHOD_DSA;
61
0
    else if (strncmp(alg, "DH", len) == 0)
62
0
        *pflags |= ENGINE_METHOD_DH;
63
0
    else if (strncmp(alg, "EC", len) == 0)
64
0
        *pflags |= ENGINE_METHOD_EC;
65
0
    else if (strncmp(alg, "RAND", len) == 0)
66
0
        *pflags |= ENGINE_METHOD_RAND;
67
0
    else if (strncmp(alg, "CIPHERS", len) == 0)
68
0
        *pflags |= ENGINE_METHOD_CIPHERS;
69
0
    else if (strncmp(alg, "DIGESTS", len) == 0)
70
0
        *pflags |= ENGINE_METHOD_DIGESTS;
71
0
    else if (strncmp(alg, "PKEY", len) == 0)
72
0
        *pflags |= ENGINE_METHOD_PKEY_METHS | ENGINE_METHOD_PKEY_ASN1_METHS;
73
0
    else if (strncmp(alg, "PKEY_CRYPTO", len) == 0)
74
0
        *pflags |= ENGINE_METHOD_PKEY_METHS;
75
0
    else if (strncmp(alg, "PKEY_ASN1", len) == 0)
76
0
        *pflags |= ENGINE_METHOD_PKEY_ASN1_METHS;
77
0
    else
78
0
        return 0;
79
0
    return 1;
80
0
}
81
82
int ENGINE_set_default_string(ENGINE *e, const char *def_list)
83
0
{
84
0
    unsigned int flags = 0;
85
0
    if (!CONF_parse_list(def_list, ',', 1, int_def_cb, &flags)) {
86
0
        ERR_raise_data(ERR_LIB_ENGINE, ENGINE_R_INVALID_STRING,
87
0
                       "str=%s", def_list);
88
0
        return 0;
89
0
    }
90
0
    return ENGINE_set_default(e, flags);
91
0
}
92
93
int ENGINE_register_complete(ENGINE *e)
94
0
{
95
0
    ENGINE_register_ciphers(e);
96
0
    ENGINE_register_digests(e);
97
0
    ENGINE_register_RSA(e);
98
0
#ifndef OPENSSL_NO_DSA
99
0
    ENGINE_register_DSA(e);
100
0
#endif
101
0
#ifndef OPENSSL_NO_DH
102
0
    ENGINE_register_DH(e);
103
0
#endif
104
0
#ifndef OPENSSL_NO_EC
105
0
    ENGINE_register_EC(e);
106
0
#endif
107
0
    ENGINE_register_RAND(e);
108
0
    ENGINE_register_pkey_meths(e);
109
0
    ENGINE_register_pkey_asn1_meths(e);
110
0
    return 1;
111
0
}
112
113
int ENGINE_register_all_complete(void)
114
0
{
115
0
    ENGINE *e;
116
117
0
    for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e))
118
0
        if (!(e->flags & ENGINE_FLAGS_NO_REGISTER_ALL))
119
0
            ENGINE_register_complete(e);
120
0
    return 1;
121
0
}