]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/engine/eng_fat.c
Reorganize local header files
[thirdparty/openssl.git] / crypto / engine / eng_fat.c
CommitLineData
b1322259
RS
1/*
2 * Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
aa8f3d76 3 * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
354c3ace 4 *
3c120f91 5 * Licensed under the Apache License 2.0 (the "License"). You may not use
b1322259
RS
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
354c3ace 9 */
b1322259 10
706457b7 11#include "eng_local.h"
df5eaa8a 12#include <openssl/conf.h>
354c3ace 13
b6d1e52d 14int ENGINE_set_default(ENGINE *e, unsigned int flags)
0f113f3e
MC
15{
16 if ((flags & ENGINE_METHOD_CIPHERS) && !ENGINE_set_default_ciphers(e))
17 return 0;
18 if ((flags & ENGINE_METHOD_DIGESTS) && !ENGINE_set_default_digests(e))
19 return 0;
b6d1e52d 20#ifndef OPENSSL_NO_RSA
0f113f3e
MC
21 if ((flags & ENGINE_METHOD_RSA) && !ENGINE_set_default_RSA(e))
22 return 0;
b6d1e52d
GT
23#endif
24#ifndef OPENSSL_NO_DSA
0f113f3e
MC
25 if ((flags & ENGINE_METHOD_DSA) && !ENGINE_set_default_DSA(e))
26 return 0;
b6d1e52d
GT
27#endif
28#ifndef OPENSSL_NO_DH
0f113f3e
MC
29 if ((flags & ENGINE_METHOD_DH) && !ENGINE_set_default_DH(e))
30 return 0;
e172d60d 31#endif
10bf4fc2 32#ifndef OPENSSL_NO_EC
7d711cbc
DSH
33 if ((flags & ENGINE_METHOD_EC) && !ENGINE_set_default_EC(e))
34 return 0;
b6d1e52d 35#endif
0f113f3e
MC
36 if ((flags & ENGINE_METHOD_RAND) && !ENGINE_set_default_RAND(e))
37 return 0;
38 if ((flags & ENGINE_METHOD_PKEY_METHS)
39 && !ENGINE_set_default_pkey_meths(e))
40 return 0;
41 if ((flags & ENGINE_METHOD_PKEY_ASN1_METHS)
42 && !ENGINE_set_default_pkey_asn1_meths(e))
43 return 0;
44 return 1;
45}
0e360199 46
df5eaa8a
DSH
47/* Set default algorithms using a string */
48
40889b9c 49static int int_def_cb(const char *alg, int len, void *arg)
0f113f3e
MC
50{
51 unsigned int *pflags = arg;
2747d73c
KR
52 if (alg == NULL)
53 return 0;
86885c28 54 if (strncmp(alg, "ALL", len) == 0)
0f113f3e 55 *pflags |= ENGINE_METHOD_ALL;
86885c28 56 else if (strncmp(alg, "RSA", len) == 0)
0f113f3e 57 *pflags |= ENGINE_METHOD_RSA;
86885c28 58 else if (strncmp(alg, "DSA", len) == 0)
0f113f3e 59 *pflags |= ENGINE_METHOD_DSA;
86885c28 60 else if (strncmp(alg, "DH", len) == 0)
0f113f3e 61 *pflags |= ENGINE_METHOD_DH;
7d711cbc
DSH
62 else if (strncmp(alg, "EC", len) == 0)
63 *pflags |= ENGINE_METHOD_EC;
86885c28 64 else if (strncmp(alg, "RAND", len) == 0)
0f113f3e 65 *pflags |= ENGINE_METHOD_RAND;
86885c28 66 else if (strncmp(alg, "CIPHERS", len) == 0)
0f113f3e 67 *pflags |= ENGINE_METHOD_CIPHERS;
86885c28 68 else if (strncmp(alg, "DIGESTS", len) == 0)
0f113f3e 69 *pflags |= ENGINE_METHOD_DIGESTS;
86885c28 70 else if (strncmp(alg, "PKEY", len) == 0)
0f113f3e 71 *pflags |= ENGINE_METHOD_PKEY_METHS | ENGINE_METHOD_PKEY_ASN1_METHS;
86885c28 72 else if (strncmp(alg, "PKEY_CRYPTO", len) == 0)
0f113f3e 73 *pflags |= ENGINE_METHOD_PKEY_METHS;
86885c28 74 else if (strncmp(alg, "PKEY_ASN1", len) == 0)
0f113f3e
MC
75 *pflags |= ENGINE_METHOD_PKEY_ASN1_METHS;
76 else
77 return 0;
78 return 1;
79}
df5eaa8a 80
3822740c 81int ENGINE_set_default_string(ENGINE *e, const char *def_list)
0f113f3e
MC
82{
83 unsigned int flags = 0;
84 if (!CONF_parse_list(def_list, ',', 1, int_def_cb, &flags)) {
85 ENGINEerr(ENGINE_F_ENGINE_SET_DEFAULT_STRING,
86 ENGINE_R_INVALID_STRING);
87 ERR_add_error_data(2, "str=", def_list);
88 return 0;
89 }
90 return ENGINE_set_default(e, flags);
91}
df5eaa8a 92
b6d1e52d 93int ENGINE_register_complete(ENGINE *e)
0f113f3e
MC
94{
95 ENGINE_register_ciphers(e);
96 ENGINE_register_digests(e);
b6d1e52d 97#ifndef OPENSSL_NO_RSA
0f113f3e 98 ENGINE_register_RSA(e);
b6d1e52d
GT
99#endif
100#ifndef OPENSSL_NO_DSA
0f113f3e 101 ENGINE_register_DSA(e);
b6d1e52d
GT
102#endif
103#ifndef OPENSSL_NO_DH
0f113f3e 104 ENGINE_register_DH(e);
e172d60d 105#endif
10bf4fc2 106#ifndef OPENSSL_NO_EC
7d711cbc 107 ENGINE_register_EC(e);
b6d1e52d 108#endif
0f113f3e
MC
109 ENGINE_register_RAND(e);
110 ENGINE_register_pkey_meths(e);
b35bb37a 111 ENGINE_register_pkey_asn1_meths(e);
0f113f3e
MC
112 return 1;
113}
0e360199 114
b6d1e52d 115int ENGINE_register_all_complete(void)
0f113f3e
MC
116{
117 ENGINE *e;
0e360199 118
0f113f3e
MC
119 for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e))
120 if (!(e->flags & ENGINE_FLAGS_NO_REGISTER_ALL))
121 ENGINE_register_complete(e);
122 return 1;
123}