diff options
Diffstat (limited to 'src/lib/libcrypto/engine/tb_ecdh.c')
-rw-r--r-- | src/lib/libcrypto/engine/tb_ecdh.c | 68 |
1 files changed, 38 insertions, 30 deletions
diff --git a/src/lib/libcrypto/engine/tb_ecdh.c b/src/lib/libcrypto/engine/tb_ecdh.c index 57354b8c11..0abeee163e 100644 --- a/src/lib/libcrypto/engine/tb_ecdh.c +++ b/src/lib/libcrypto/engine/tb_ecdh.c | |||
@@ -21,7 +21,7 @@ | |||
21 | * are met: | 21 | * are met: |
22 | * | 22 | * |
23 | * 1. Redistributions of source code must retain the above copyright | 23 | * 1. Redistributions of source code must retain the above copyright |
24 | * notice, this list of conditions and the following disclaimer. | 24 | * notice, this list of conditions and the following disclaimer. |
25 | * | 25 | * |
26 | * 2. Redistributions in binary form must reproduce the above copyright | 26 | * 2. Redistributions in binary form must reproduce the above copyright |
27 | * notice, this list of conditions and the following disclaimer in | 27 | * notice, this list of conditions and the following disclaimer in |
@@ -77,57 +77,65 @@ | |||
77 | static ENGINE_TABLE *ecdh_table = NULL; | 77 | static ENGINE_TABLE *ecdh_table = NULL; |
78 | static const int dummy_nid = 1; | 78 | static const int dummy_nid = 1; |
79 | 79 | ||
80 | void ENGINE_unregister_ECDH(ENGINE *e) | 80 | void |
81 | { | 81 | ENGINE_unregister_ECDH(ENGINE *e) |
82 | { | ||
82 | engine_table_unregister(&ecdh_table, e); | 83 | engine_table_unregister(&ecdh_table, e); |
83 | } | 84 | } |
84 | 85 | ||
85 | static void engine_unregister_all_ECDH(void) | 86 | static void |
86 | { | 87 | engine_unregister_all_ECDH(void) |
88 | { | ||
87 | engine_table_cleanup(&ecdh_table); | 89 | engine_table_cleanup(&ecdh_table); |
88 | } | 90 | } |
89 | 91 | ||
90 | int ENGINE_register_ECDH(ENGINE *e) | 92 | int |
91 | { | 93 | ENGINE_register_ECDH(ENGINE *e) |
92 | if(e->ecdh_meth) | 94 | { |
95 | if (e->ecdh_meth) | ||
93 | return engine_table_register(&ecdh_table, | 96 | return engine_table_register(&ecdh_table, |
94 | engine_unregister_all_ECDH, e, &dummy_nid, 1, 0); | 97 | engine_unregister_all_ECDH, e, &dummy_nid, 1, 0); |
95 | return 1; | 98 | return 1; |
96 | } | 99 | } |
97 | 100 | ||
98 | void ENGINE_register_all_ECDH(void) | 101 | void |
99 | { | 102 | ENGINE_register_all_ECDH(void) |
103 | { | ||
100 | ENGINE *e; | 104 | ENGINE *e; |
101 | 105 | ||
102 | for(e=ENGINE_get_first() ; e ; e=ENGINE_get_next(e)) | 106 | for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) |
103 | ENGINE_register_ECDH(e); | 107 | ENGINE_register_ECDH(e); |
104 | } | 108 | } |
105 | 109 | ||
106 | int ENGINE_set_default_ECDH(ENGINE *e) | 110 | int |
107 | { | 111 | ENGINE_set_default_ECDH(ENGINE *e) |
108 | if(e->ecdh_meth) | 112 | { |
113 | if (e->ecdh_meth) | ||
109 | return engine_table_register(&ecdh_table, | 114 | return engine_table_register(&ecdh_table, |
110 | engine_unregister_all_ECDH, e, &dummy_nid, 1, 1); | 115 | engine_unregister_all_ECDH, e, &dummy_nid, 1, 1); |
111 | return 1; | 116 | return 1; |
112 | } | 117 | } |
113 | 118 | ||
114 | /* Exposed API function to get a functional reference from the implementation | 119 | /* Exposed API function to get a functional reference from the implementation |
115 | * table (ie. try to get a functional reference from the tabled structural | 120 | * table (ie. try to get a functional reference from the tabled structural |
116 | * references). */ | 121 | * references). */ |
117 | ENGINE *ENGINE_get_default_ECDH(void) | 122 | ENGINE * |
118 | { | 123 | ENGINE_get_default_ECDH(void) |
124 | { | ||
119 | return engine_table_select(&ecdh_table, dummy_nid); | 125 | return engine_table_select(&ecdh_table, dummy_nid); |
120 | } | 126 | } |
121 | 127 | ||
122 | /* Obtains an ECDH implementation from an ENGINE functional reference */ | 128 | /* Obtains an ECDH implementation from an ENGINE functional reference */ |
123 | const ECDH_METHOD *ENGINE_get_ECDH(const ENGINE *e) | 129 | const ECDH_METHOD * |
124 | { | 130 | ENGINE_get_ECDH(const ENGINE *e) |
131 | { | ||
125 | return e->ecdh_meth; | 132 | return e->ecdh_meth; |
126 | } | 133 | } |
127 | 134 | ||
128 | /* Sets an ECDH implementation in an ENGINE structure */ | 135 | /* Sets an ECDH implementation in an ENGINE structure */ |
129 | int ENGINE_set_ECDH(ENGINE *e, const ECDH_METHOD *ecdh_meth) | 136 | int |
130 | { | 137 | ENGINE_set_ECDH(ENGINE *e, const ECDH_METHOD *ecdh_meth) |
138 | { | ||
131 | e->ecdh_meth = ecdh_meth; | 139 | e->ecdh_meth = ecdh_meth; |
132 | return 1; | 140 | return 1; |
133 | } | 141 | } |