/src/openssl30/crypto/engine/tb_eckey.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved. |
3 | | * |
4 | | * Licensed under the Apache License 2.0 (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 |
8 | | */ |
9 | | |
10 | | /* We need to use some engine deprecated APIs */ |
11 | | #define OPENSSL_SUPPRESS_DEPRECATED |
12 | | |
13 | | #include "eng_local.h" |
14 | | |
15 | | static ENGINE_TABLE *dh_table = NULL; |
16 | | static const int dummy_nid = 1; |
17 | | |
18 | | void ENGINE_unregister_EC(ENGINE *e) |
19 | 0 | { |
20 | 0 | engine_table_unregister(&dh_table, e); |
21 | 0 | } |
22 | | |
23 | | static void engine_unregister_all_EC(void) |
24 | 0 | { |
25 | 0 | engine_table_cleanup(&dh_table); |
26 | 0 | } |
27 | | |
28 | | int ENGINE_register_EC(ENGINE *e) |
29 | 0 | { |
30 | 0 | if (e->ec_meth != NULL) |
31 | 0 | return engine_table_register(&dh_table, |
32 | 0 | engine_unregister_all_EC, e, &dummy_nid, |
33 | 0 | 1, 0); |
34 | 0 | return 1; |
35 | 0 | } |
36 | | |
37 | | void ENGINE_register_all_EC(void) |
38 | 0 | { |
39 | 0 | ENGINE *e; |
40 | |
|
41 | 0 | for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) |
42 | 0 | ENGINE_register_EC(e); |
43 | 0 | } |
44 | | |
45 | | int ENGINE_set_default_EC(ENGINE *e) |
46 | 0 | { |
47 | 0 | if (e->ec_meth != NULL) |
48 | 0 | return engine_table_register(&dh_table, |
49 | 0 | engine_unregister_all_EC, e, &dummy_nid, |
50 | 0 | 1, 1); |
51 | 0 | return 1; |
52 | 0 | } |
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 | | */ |
59 | | ENGINE *ENGINE_get_default_EC(void) |
60 | 621k | { |
61 | 621k | return ossl_engine_table_select(&dh_table, dummy_nid, |
62 | 621k | OPENSSL_FILE, OPENSSL_LINE); |
63 | 621k | } |
64 | | |
65 | | /* Obtains an EC_KEY implementation from an ENGINE functional reference */ |
66 | | const EC_KEY_METHOD *ENGINE_get_EC(const ENGINE *e) |
67 | 0 | { |
68 | 0 | return e->ec_meth; |
69 | 0 | } |
70 | | |
71 | | /* Sets an EC_KEY implementation in an ENGINE structure */ |
72 | | int ENGINE_set_EC(ENGINE *e, const EC_KEY_METHOD *ec_meth) |
73 | 0 | { |
74 | 0 | e->ec_meth = ec_meth; |
75 | 0 | return 1; |
76 | 0 | } |