]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/engine/tb_eckey.c
deprecate engines in libcrypto
[thirdparty/openssl.git] / crypto / engine / tb_eckey.c
CommitLineData
b1322259 1/*
83cf7abf 2 * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
28572b57 3 *
3c120f91 4 * Licensed under the Apache License 2.0 (the "License"). You may not use
b1322259
RS
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
28572b57
DSH
8 */
9
e4468e6d
P
10/* We need to use some engine deprecated APIs */
11#define OPENSSL_SUPPRESS_DEPRECATED
12
706457b7 13#include "eng_local.h"
28572b57 14
28572b57
DSH
15static ENGINE_TABLE *dh_table = NULL;
16static const int dummy_nid = 1;
17
7d711cbc 18void ENGINE_unregister_EC(ENGINE *e)
28572b57
DSH
19{
20 engine_table_unregister(&dh_table, e);
21}
22
7d711cbc 23static void engine_unregister_all_EC(void)
28572b57
DSH
24{
25 engine_table_cleanup(&dh_table);
26}
27
7d711cbc 28int ENGINE_register_EC(ENGINE *e)
28572b57 29{
91e7bcc2 30 if (e->ec_meth != NULL)
28572b57 31 return engine_table_register(&dh_table,
7d711cbc 32 engine_unregister_all_EC, e, &dummy_nid,
28572b57
DSH
33 1, 0);
34 return 1;
35}
36
3cb7c5cf 37void ENGINE_register_all_EC(void)
28572b57
DSH
38{
39 ENGINE *e;
40
41 for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e))
7d711cbc 42 ENGINE_register_EC(e);
28572b57
DSH
43}
44
7d711cbc 45int ENGINE_set_default_EC(ENGINE *e)
28572b57 46{
91e7bcc2 47 if (e->ec_meth != NULL)
28572b57 48 return engine_table_register(&dh_table,
7d711cbc 49 engine_unregister_all_EC, e, &dummy_nid,
28572b57
DSH
50 1, 1);
51 return 1;
52}
53
54/*
55 * Exposed API function to get a functional reference from the implementation
56 * table (ie. try to get a functional reference from the tabled structural
57 * references).
58 */
7d711cbc 59ENGINE *ENGINE_get_default_EC(void)
28572b57
DSH
60{
61 return engine_table_select(&dh_table, dummy_nid);
62}
63
64/* Obtains an EC_KEY implementation from an ENGINE functional reference */
7d711cbc 65const EC_KEY_METHOD *ENGINE_get_EC(const ENGINE *e)
28572b57 66{
7d711cbc 67 return e->ec_meth;
28572b57
DSH
68}
69
70/* Sets an EC_KEY implementation in an ENGINE structure */
7d711cbc 71int ENGINE_set_EC(ENGINE *e, const EC_KEY_METHOD *ec_meth)
28572b57 72{
7d711cbc 73 e->ec_meth = ec_meth;
28572b57
DSH
74 return 1;
75}