]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/engine/eng_fat.c
Copyright consolidation 09/10
[thirdparty/openssl.git] / crypto / engine / eng_fat.c
CommitLineData
b1322259
RS
1/*
2 * Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
354c3ace 3 *
b1322259
RS
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
354c3ace 8 */
b1322259 9
e172d60d
BM
10/* ====================================================================
11 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
0f113f3e 12 * ECDH support in OpenSSL originally developed by
e172d60d
BM
13 * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
14 */
354c3ace 15
14cfde9c 16#include "eng_int.h"
df5eaa8a 17#include <openssl/conf.h>
354c3ace 18
b6d1e52d 19int ENGINE_set_default(ENGINE *e, unsigned int flags)
0f113f3e
MC
20{
21 if ((flags & ENGINE_METHOD_CIPHERS) && !ENGINE_set_default_ciphers(e))
22 return 0;
23 if ((flags & ENGINE_METHOD_DIGESTS) && !ENGINE_set_default_digests(e))
24 return 0;
b6d1e52d 25#ifndef OPENSSL_NO_RSA
0f113f3e
MC
26 if ((flags & ENGINE_METHOD_RSA) && !ENGINE_set_default_RSA(e))
27 return 0;
b6d1e52d
GT
28#endif
29#ifndef OPENSSL_NO_DSA
0f113f3e
MC
30 if ((flags & ENGINE_METHOD_DSA) && !ENGINE_set_default_DSA(e))
31 return 0;
b6d1e52d
GT
32#endif
33#ifndef OPENSSL_NO_DH
0f113f3e
MC
34 if ((flags & ENGINE_METHOD_DH) && !ENGINE_set_default_DH(e))
35 return 0;
e172d60d 36#endif
10bf4fc2 37#ifndef OPENSSL_NO_EC
7d711cbc
DSH
38 if ((flags & ENGINE_METHOD_EC) && !ENGINE_set_default_EC(e))
39 return 0;
b6d1e52d 40#endif
0f113f3e
MC
41 if ((flags & ENGINE_METHOD_RAND) && !ENGINE_set_default_RAND(e))
42 return 0;
43 if ((flags & ENGINE_METHOD_PKEY_METHS)
44 && !ENGINE_set_default_pkey_meths(e))
45 return 0;
46 if ((flags & ENGINE_METHOD_PKEY_ASN1_METHS)
47 && !ENGINE_set_default_pkey_asn1_meths(e))
48 return 0;
49 return 1;
50}
0e360199 51
df5eaa8a
DSH
52/* Set default algorithms using a string */
53
40889b9c 54static int int_def_cb(const char *alg, int len, void *arg)
0f113f3e
MC
55{
56 unsigned int *pflags = arg;
2747d73c
KR
57 if (alg == NULL)
58 return 0;
86885c28 59 if (strncmp(alg, "ALL", len) == 0)
0f113f3e 60 *pflags |= ENGINE_METHOD_ALL;
86885c28 61 else if (strncmp(alg, "RSA", len) == 0)
0f113f3e 62 *pflags |= ENGINE_METHOD_RSA;
86885c28 63 else if (strncmp(alg, "DSA", len) == 0)
0f113f3e 64 *pflags |= ENGINE_METHOD_DSA;
86885c28 65 else if (strncmp(alg, "DH", len) == 0)
0f113f3e 66 *pflags |= ENGINE_METHOD_DH;
7d711cbc
DSH
67 else if (strncmp(alg, "EC", len) == 0)
68 *pflags |= ENGINE_METHOD_EC;
86885c28 69 else if (strncmp(alg, "RAND", len) == 0)
0f113f3e 70 *pflags |= ENGINE_METHOD_RAND;
86885c28 71 else if (strncmp(alg, "CIPHERS", len) == 0)
0f113f3e 72 *pflags |= ENGINE_METHOD_CIPHERS;
86885c28 73 else if (strncmp(alg, "DIGESTS", len) == 0)
0f113f3e 74 *pflags |= ENGINE_METHOD_DIGESTS;
86885c28 75 else if (strncmp(alg, "PKEY", len) == 0)
0f113f3e 76 *pflags |= ENGINE_METHOD_PKEY_METHS | ENGINE_METHOD_PKEY_ASN1_METHS;
86885c28 77 else if (strncmp(alg, "PKEY_CRYPTO", len) == 0)
0f113f3e 78 *pflags |= ENGINE_METHOD_PKEY_METHS;
86885c28 79 else if (strncmp(alg, "PKEY_ASN1", len) == 0)
0f113f3e
MC
80 *pflags |= ENGINE_METHOD_PKEY_ASN1_METHS;
81 else
82 return 0;
83 return 1;
84}
df5eaa8a 85
3822740c 86int ENGINE_set_default_string(ENGINE *e, const char *def_list)
0f113f3e
MC
87{
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);
93 return 0;
94 }
95 return ENGINE_set_default(e, flags);
96}
df5eaa8a 97
b6d1e52d 98int ENGINE_register_complete(ENGINE *e)
0f113f3e
MC
99{
100 ENGINE_register_ciphers(e);
101 ENGINE_register_digests(e);
b6d1e52d 102#ifndef OPENSSL_NO_RSA
0f113f3e 103 ENGINE_register_RSA(e);
b6d1e52d
GT
104#endif
105#ifndef OPENSSL_NO_DSA
0f113f3e 106 ENGINE_register_DSA(e);
b6d1e52d
GT
107#endif
108#ifndef OPENSSL_NO_DH
0f113f3e 109 ENGINE_register_DH(e);
e172d60d 110#endif
10bf4fc2 111#ifndef OPENSSL_NO_EC
7d711cbc 112 ENGINE_register_EC(e);
b6d1e52d 113#endif
0f113f3e
MC
114 ENGINE_register_RAND(e);
115 ENGINE_register_pkey_meths(e);
116 return 1;
117}
0e360199 118
b6d1e52d 119int ENGINE_register_all_complete(void)
0f113f3e
MC
120{
121 ENGINE *e;
0e360199 122
0f113f3e
MC
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);
126 return 1;
127}