2 * Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (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
10 /* ====================================================================
11 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
12 * ECDH support in OpenSSL originally developed by
13 * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
17 #include <openssl/conf.h>
19 int ENGINE_set_default(ENGINE *e, unsigned int flags)
21 if ((flags & ENGINE_METHOD_CIPHERS) && !ENGINE_set_default_ciphers(e))
23 if ((flags & ENGINE_METHOD_DIGESTS) && !ENGINE_set_default_digests(e))
25 #ifndef OPENSSL_NO_RSA
26 if ((flags & ENGINE_METHOD_RSA) && !ENGINE_set_default_RSA(e))
29 #ifndef OPENSSL_NO_DSA
30 if ((flags & ENGINE_METHOD_DSA) && !ENGINE_set_default_DSA(e))
34 if ((flags & ENGINE_METHOD_DH) && !ENGINE_set_default_DH(e))
38 if ((flags & ENGINE_METHOD_EC) && !ENGINE_set_default_EC(e))
41 if ((flags & ENGINE_METHOD_RAND) && !ENGINE_set_default_RAND(e))
43 if ((flags & ENGINE_METHOD_PKEY_METHS)
44 && !ENGINE_set_default_pkey_meths(e))
46 if ((flags & ENGINE_METHOD_PKEY_ASN1_METHS)
47 && !ENGINE_set_default_pkey_asn1_meths(e))
52 /* Set default algorithms using a string */
54 static int int_def_cb(const char *alg, int len, void *arg)
56 unsigned int *pflags = arg;
59 if (strncmp(alg, "ALL", len) == 0)
60 *pflags |= ENGINE_METHOD_ALL;
61 else if (strncmp(alg, "RSA", len) == 0)
62 *pflags |= ENGINE_METHOD_RSA;
63 else if (strncmp(alg, "DSA", len) == 0)
64 *pflags |= ENGINE_METHOD_DSA;
65 else if (strncmp(alg, "DH", len) == 0)
66 *pflags |= ENGINE_METHOD_DH;
67 else if (strncmp(alg, "EC", len) == 0)
68 *pflags |= ENGINE_METHOD_EC;
69 else if (strncmp(alg, "RAND", len) == 0)
70 *pflags |= ENGINE_METHOD_RAND;
71 else if (strncmp(alg, "CIPHERS", len) == 0)
72 *pflags |= ENGINE_METHOD_CIPHERS;
73 else if (strncmp(alg, "DIGESTS", len) == 0)
74 *pflags |= ENGINE_METHOD_DIGESTS;
75 else if (strncmp(alg, "PKEY", len) == 0)
76 *pflags |= ENGINE_METHOD_PKEY_METHS | ENGINE_METHOD_PKEY_ASN1_METHS;
77 else if (strncmp(alg, "PKEY_CRYPTO", len) == 0)
78 *pflags |= ENGINE_METHOD_PKEY_METHS;
79 else if (strncmp(alg, "PKEY_ASN1", len) == 0)
80 *pflags |= ENGINE_METHOD_PKEY_ASN1_METHS;
86 int ENGINE_set_default_string(ENGINE *e, const char *def_list)
88 unsigned int flags = 0;
89 if (!CONF_parse_list(def_list, ',', 1, int_def_cb, &flags)) {
90 ENGINEerr(ENGINE_F_ENGINE_SET_DEFAULT_STRING,
91 ENGINE_R_INVALID_STRING);
92 ERR_add_error_data(2, "str=", def_list);
95 return ENGINE_set_default(e, flags);
98 int ENGINE_register_complete(ENGINE *e)
100 ENGINE_register_ciphers(e);
101 ENGINE_register_digests(e);
102 #ifndef OPENSSL_NO_RSA
103 ENGINE_register_RSA(e);
105 #ifndef OPENSSL_NO_DSA
106 ENGINE_register_DSA(e);
108 #ifndef OPENSSL_NO_DH
109 ENGINE_register_DH(e);
111 #ifndef OPENSSL_NO_EC
112 ENGINE_register_EC(e);
114 ENGINE_register_RAND(e);
115 ENGINE_register_pkey_meths(e);
119 int ENGINE_register_all_complete(void)
123 for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e))
124 if (!(e->flags & ENGINE_FLAGS_NO_REGISTER_ALL))
125 ENGINE_register_complete(e);