]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/engine/tb_eckey.c
Reorganize local header files
[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
706457b7 10#include "eng_local.h"
28572b57 11
28572b57
DSH
12static ENGINE_TABLE *dh_table = NULL;
13static const int dummy_nid = 1;
14
7d711cbc 15void ENGINE_unregister_EC(ENGINE *e)
28572b57
DSH
16{
17 engine_table_unregister(&dh_table, e);
18}
19
7d711cbc 20static void engine_unregister_all_EC(void)
28572b57
DSH
21{
22 engine_table_cleanup(&dh_table);
23}
24
7d711cbc 25int ENGINE_register_EC(ENGINE *e)
28572b57 26{
91e7bcc2 27 if (e->ec_meth != NULL)
28572b57 28 return engine_table_register(&dh_table,
7d711cbc 29 engine_unregister_all_EC, e, &dummy_nid,
28572b57
DSH
30 1, 0);
31 return 1;
32}
33
3cb7c5cf 34void ENGINE_register_all_EC(void)
28572b57
DSH
35{
36 ENGINE *e;
37
38 for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e))
7d711cbc 39 ENGINE_register_EC(e);
28572b57
DSH
40}
41
7d711cbc 42int ENGINE_set_default_EC(ENGINE *e)
28572b57 43{
91e7bcc2 44 if (e->ec_meth != NULL)
28572b57 45 return engine_table_register(&dh_table,
7d711cbc 46 engine_unregister_all_EC, e, &dummy_nid,
28572b57
DSH
47 1, 1);
48 return 1;
49}
50
51/*
52 * Exposed API function to get a functional reference from the implementation
53 * table (ie. try to get a functional reference from the tabled structural
54 * references).
55 */
7d711cbc 56ENGINE *ENGINE_get_default_EC(void)
28572b57
DSH
57{
58 return engine_table_select(&dh_table, dummy_nid);
59}
60
61/* Obtains an EC_KEY implementation from an ENGINE functional reference */
7d711cbc 62const EC_KEY_METHOD *ENGINE_get_EC(const ENGINE *e)
28572b57 63{
7d711cbc 64 return e->ec_meth;
28572b57
DSH
65}
66
67/* Sets an EC_KEY implementation in an ENGINE structure */
7d711cbc 68int ENGINE_set_EC(ENGINE *e, const EC_KEY_METHOD *ec_meth)
28572b57 69{
7d711cbc 70 e->ec_meth = ec_meth;
28572b57
DSH
71 return 1;
72}