VirtualBox

source: vbox/trunk/src/libs/openssl-3.0.1/crypto/engine/eng_fat.c@ 94082

Last change on this file since 94082 was 94082, checked in by vboxsync, 3 years ago

libs/openssl-3.0.1: started applying and adjusting our OpenSSL changes to 3.0.1. bugref:10128

File size: 3.6 KB
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
17int ENGINE_set_default(ENGINE *e, unsigned int flags)
18{
19 if ((flags & ENGINE_METHOD_CIPHERS) && !ENGINE_set_default_ciphers(e))
20 return 0;
21 if ((flags & ENGINE_METHOD_DIGESTS) && !ENGINE_set_default_digests(e))
22 return 0;
23 if ((flags & ENGINE_METHOD_RSA) && !ENGINE_set_default_RSA(e))
24 return 0;
25#ifndef OPENSSL_NO_DSA
26 if ((flags & ENGINE_METHOD_DSA) && !ENGINE_set_default_DSA(e))
27 return 0;
28#endif
29#ifndef OPENSSL_NO_DH
30 if ((flags & ENGINE_METHOD_DH) && !ENGINE_set_default_DH(e))
31 return 0;
32#endif
33#ifndef OPENSSL_NO_EC
34 if ((flags & ENGINE_METHOD_EC) && !ENGINE_set_default_EC(e))
35 return 0;
36#endif
37 if ((flags & ENGINE_METHOD_RAND) && !ENGINE_set_default_RAND(e))
38 return 0;
39 if ((flags & ENGINE_METHOD_PKEY_METHS)
40 && !ENGINE_set_default_pkey_meths(e))
41 return 0;
42 if ((flags & ENGINE_METHOD_PKEY_ASN1_METHS)
43 && !ENGINE_set_default_pkey_asn1_meths(e))
44 return 0;
45 return 1;
46}
47
48/* Set default algorithms using a string */
49
50static int int_def_cb(const char *alg, int len, void *arg)
51{
52 unsigned int *pflags = arg;
53 if (alg == NULL)
54 return 0;
55 if (strncmp(alg, "ALL", len) == 0)
56 *pflags |= ENGINE_METHOD_ALL;
57 else if (strncmp(alg, "RSA", len) == 0)
58 *pflags |= ENGINE_METHOD_RSA;
59 else if (strncmp(alg, "DSA", len) == 0)
60 *pflags |= ENGINE_METHOD_DSA;
61 else if (strncmp(alg, "DH", len) == 0)
62 *pflags |= ENGINE_METHOD_DH;
63 else if (strncmp(alg, "EC", len) == 0)
64 *pflags |= ENGINE_METHOD_EC;
65 else if (strncmp(alg, "RAND", len) == 0)
66 *pflags |= ENGINE_METHOD_RAND;
67 else if (strncmp(alg, "CIPHERS", len) == 0)
68 *pflags |= ENGINE_METHOD_CIPHERS;
69 else if (strncmp(alg, "DIGESTS", len) == 0)
70 *pflags |= ENGINE_METHOD_DIGESTS;
71 else if (strncmp(alg, "PKEY", len) == 0)
72 *pflags |= ENGINE_METHOD_PKEY_METHS | ENGINE_METHOD_PKEY_ASN1_METHS;
73 else if (strncmp(alg, "PKEY_CRYPTO", len) == 0)
74 *pflags |= ENGINE_METHOD_PKEY_METHS;
75 else if (strncmp(alg, "PKEY_ASN1", len) == 0)
76 *pflags |= ENGINE_METHOD_PKEY_ASN1_METHS;
77 else
78 return 0;
79 return 1;
80}
81
82int ENGINE_set_default_string(ENGINE *e, const char *def_list)
83{
84 unsigned int flags = 0;
85 if (!CONF_parse_list(def_list, ',', 1, int_def_cb, &flags)) {
86 ERR_raise_data(ERR_LIB_ENGINE, ENGINE_R_INVALID_STRING,
87 "str=%s", def_list);
88 return 0;
89 }
90 return ENGINE_set_default(e, flags);
91}
92
93int ENGINE_register_complete(ENGINE *e)
94{
95 ENGINE_register_ciphers(e);
96 ENGINE_register_digests(e);
97 ENGINE_register_RSA(e);
98#ifndef OPENSSL_NO_DSA
99 ENGINE_register_DSA(e);
100#endif
101#ifndef OPENSSL_NO_DH
102 ENGINE_register_DH(e);
103#endif
104#ifndef OPENSSL_NO_EC
105 ENGINE_register_EC(e);
106#endif
107 ENGINE_register_RAND(e);
108 ENGINE_register_pkey_meths(e);
109 ENGINE_register_pkey_asn1_meths(e);
110 return 1;
111}
112
113int ENGINE_register_all_complete(void)
114{
115 ENGINE *e;
116
117 for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e))
118 if (!(e->flags & ENGINE_FLAGS_NO_REGISTER_ALL))
119 ENGINE_register_complete(e);
120 return 1;
121}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette