summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/engine/tb_ecdh.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/engine/tb_ecdh.c')
-rw-r--r--src/lib/libcrypto/engine/tb_ecdh.c68
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 @@
77static ENGINE_TABLE *ecdh_table = NULL; 77static ENGINE_TABLE *ecdh_table = NULL;
78static const int dummy_nid = 1; 78static const int dummy_nid = 1;
79 79
80void ENGINE_unregister_ECDH(ENGINE *e) 80void
81 { 81ENGINE_unregister_ECDH(ENGINE *e)
82{
82 engine_table_unregister(&ecdh_table, e); 83 engine_table_unregister(&ecdh_table, e);
83 } 84}
84 85
85static void engine_unregister_all_ECDH(void) 86static void
86 { 87engine_unregister_all_ECDH(void)
88{
87 engine_table_cleanup(&ecdh_table); 89 engine_table_cleanup(&ecdh_table);
88 } 90}
89 91
90int ENGINE_register_ECDH(ENGINE *e) 92int
91 { 93ENGINE_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
98void ENGINE_register_all_ECDH(void) 101void
99 { 102ENGINE_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
106int ENGINE_set_default_ECDH(ENGINE *e) 110int
107 { 111ENGINE_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). */
117ENGINE *ENGINE_get_default_ECDH(void) 122ENGINE *
118 { 123ENGINE_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 */
123const ECDH_METHOD *ENGINE_get_ECDH(const ENGINE *e) 129const ECDH_METHOD *
124 { 130ENGINE_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 */
129int ENGINE_set_ECDH(ENGINE *e, const ECDH_METHOD *ecdh_meth) 136int
130 { 137ENGINE_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}