diff options
author | jsing <> | 2014-06-22 12:16:28 +0000 |
---|---|---|
committer | jsing <> | 2014-06-22 12:16:28 +0000 |
commit | 0fc56655c369d9eb08790eff2fab8d2b47085ab1 (patch) | |
tree | 1b822059398c5ad77b6b027187d443c62fdc9361 | |
parent | 76145303a8345eadeb8eb36e46f50b090c9770b6 (diff) | |
download | openbsd-0fc56655c369d9eb08790eff2fab8d2b47085ab1.tar.gz openbsd-0fc56655c369d9eb08790eff2fab8d2b47085ab1.tar.bz2 openbsd-0fc56655c369d9eb08790eff2fab8d2b47085ab1.zip |
KNF.
-rw-r--r-- | src/lib/libcrypto/engine/eng_int.h | 27 | ||||
-rw-r--r-- | src/lib/libcrypto/engine/eng_list.c | 307 | ||||
-rw-r--r-- | src/lib/libcrypto/engine/engine.h | 77 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/engine/eng_int.h | 27 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/engine/eng_list.c | 307 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/engine/engine.h | 77 |
6 files changed, 406 insertions, 416 deletions
diff --git a/src/lib/libcrypto/engine/eng_int.h b/src/lib/libcrypto/engine/eng_int.h index 992cba676b..22049fd7fd 100644 --- a/src/lib/libcrypto/engine/eng_int.h +++ b/src/lib/libcrypto/engine/eng_int.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: eng_int.h,v 1.5 2014/06/12 15:49:29 deraadt Exp $ */ | 1 | /* $OpenBSD: eng_int.h,v 1.6 2014/06/22 12:16:28 jsing Exp $ */ |
2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL | 2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL |
3 | * project 2000. | 3 | * project 2000. |
4 | */ | 4 | */ |
@@ -10,7 +10,7 @@ | |||
10 | * are met: | 10 | * are met: |
11 | * | 11 | * |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * | 14 | * |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
@@ -57,7 +57,7 @@ | |||
57 | */ | 57 | */ |
58 | /* ==================================================================== | 58 | /* ==================================================================== |
59 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 59 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
60 | * ECDH support in OpenSSL originally developed by | 60 | * ECDH support in OpenSSL originally developed by |
61 | * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. | 61 | * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. |
62 | */ | 62 | */ |
63 | 63 | ||
@@ -98,10 +98,9 @@ extern "C" { | |||
98 | * order. NB: both the "add" functions assume CRYPTO_LOCK_ENGINE to already be | 98 | * order. NB: both the "add" functions assume CRYPTO_LOCK_ENGINE to already be |
99 | * held (in "write" mode). */ | 99 | * held (in "write" mode). */ |
100 | typedef void (ENGINE_CLEANUP_CB)(void); | 100 | typedef void (ENGINE_CLEANUP_CB)(void); |
101 | typedef struct st_engine_cleanup_item | 101 | typedef struct st_engine_cleanup_item { |
102 | { | ||
103 | ENGINE_CLEANUP_CB *cb; | 102 | ENGINE_CLEANUP_CB *cb; |
104 | } ENGINE_CLEANUP_ITEM; | 103 | } ENGINE_CLEANUP_ITEM; |
105 | DECLARE_STACK_OF(ENGINE_CLEANUP_ITEM) | 104 | DECLARE_STACK_OF(ENGINE_CLEANUP_ITEM) |
106 | void engine_cleanup_add_first(ENGINE_CLEANUP_CB *cb); | 105 | void engine_cleanup_add_first(ENGINE_CLEANUP_CB *cb); |
107 | void engine_cleanup_add_last(ENGINE_CLEANUP_CB *cb); | 106 | void engine_cleanup_add_last(ENGINE_CLEANUP_CB *cb); |
@@ -118,17 +117,20 @@ DECLARE_STACK_OF(ENGINE) | |||
118 | * as a (ENGINE_TABLE *) pointer value set initially to NULL. */ | 117 | * as a (ENGINE_TABLE *) pointer value set initially to NULL. */ |
119 | typedef struct st_engine_table ENGINE_TABLE; | 118 | typedef struct st_engine_table ENGINE_TABLE; |
120 | int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup, | 119 | int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup, |
121 | ENGINE *e, const int *nids, int num_nids, int setdefault); | 120 | ENGINE *e, const int *nids, int num_nids, int setdefault); |
122 | void engine_table_unregister(ENGINE_TABLE **table, ENGINE *e); | 121 | void engine_table_unregister(ENGINE_TABLE **table, ENGINE *e); |
123 | void engine_table_cleanup(ENGINE_TABLE **table); | 122 | void engine_table_cleanup(ENGINE_TABLE **table); |
124 | #ifndef ENGINE_TABLE_DEBUG | 123 | #ifndef ENGINE_TABLE_DEBUG |
125 | ENGINE *engine_table_select(ENGINE_TABLE **table, int nid); | 124 | ENGINE *engine_table_select(ENGINE_TABLE **table, int nid); |
126 | #else | 125 | #else |
127 | ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f, int l); | 126 | ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f, |
127 | int l); | ||
128 | #define engine_table_select(t,n) engine_table_select_tmp(t,n,__FILE__,__LINE__) | 128 | #define engine_table_select(t,n) engine_table_select_tmp(t,n,__FILE__,__LINE__) |
129 | #endif | 129 | #endif |
130 | typedef void (engine_table_doall_cb)(int nid, STACK_OF(ENGINE) *sk, ENGINE *def, void *arg); | 130 | typedef void (engine_table_doall_cb)(int nid, STACK_OF(ENGINE) *sk, |
131 | void engine_table_doall(ENGINE_TABLE *table, engine_table_doall_cb *cb, void *arg); | 131 | ENGINE *def, void *arg); |
132 | void engine_table_doall(ENGINE_TABLE *table, engine_table_doall_cb *cb, | ||
133 | void *arg); | ||
132 | 134 | ||
133 | /* Internal versions of API functions that have control over locking. These are | 135 | /* Internal versions of API functions that have control over locking. These are |
134 | * used between C files when functionality needs to be shared but the caller may | 136 | * used between C files when functionality needs to be shared but the caller may |
@@ -152,8 +154,7 @@ void engine_pkey_asn1_meths_free(ENGINE *e); | |||
152 | 154 | ||
153 | /* This is a structure for storing implementations of various crypto | 155 | /* This is a structure for storing implementations of various crypto |
154 | * algorithms and functions. */ | 156 | * algorithms and functions. */ |
155 | struct engine_st | 157 | struct engine_st { |
156 | { | ||
157 | const char *id; | 158 | const char *id; |
158 | const char *name; | 159 | const char *name; |
159 | const RSA_METHOD *rsa_meth; | 160 | const RSA_METHOD *rsa_meth; |
@@ -197,7 +198,7 @@ struct engine_st | |||
197 | /* Used to maintain the linked-list of engines. */ | 198 | /* Used to maintain the linked-list of engines. */ |
198 | struct engine_st *prev; | 199 | struct engine_st *prev; |
199 | struct engine_st *next; | 200 | struct engine_st *next; |
200 | }; | 201 | }; |
201 | 202 | ||
202 | #ifdef __cplusplus | 203 | #ifdef __cplusplus |
203 | } | 204 | } |
diff --git a/src/lib/libcrypto/engine/eng_list.c b/src/lib/libcrypto/engine/eng_list.c index 05ed61a38a..053767c646 100644 --- a/src/lib/libcrypto/engine/eng_list.c +++ b/src/lib/libcrypto/engine/eng_list.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: eng_list.c,v 1.9 2014/06/12 15:49:29 deraadt Exp $ */ | 1 | /* $OpenBSD: eng_list.c,v 1.10 2014/06/22 12:15:53 jsing Exp $ */ |
2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL | 2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL |
3 | * project 2000. | 3 | * project 2000. |
4 | */ | 4 | */ |
@@ -10,7 +10,7 @@ | |||
10 | * are met: | 10 | * are met: |
11 | * | 11 | * |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * | 14 | * |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
@@ -57,7 +57,7 @@ | |||
57 | */ | 57 | */ |
58 | /* ==================================================================== | 58 | /* ==================================================================== |
59 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 59 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
60 | * ECDH support in OpenSSL originally developed by | 60 | * ECDH support in OpenSSL originally developed by |
61 | * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. | 61 | * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. |
62 | */ | 62 | */ |
63 | 63 | ||
@@ -79,71 +79,64 @@ static ENGINE *engine_list_tail = NULL; | |||
79 | /* This cleanup function is only needed internally. If it should be called, we | 79 | /* This cleanup function is only needed internally. If it should be called, we |
80 | * register it with the "ENGINE_cleanup()" stack to be called during cleanup. */ | 80 | * register it with the "ENGINE_cleanup()" stack to be called during cleanup. */ |
81 | 81 | ||
82 | static void engine_list_cleanup(void) | 82 | static void |
83 | { | 83 | engine_list_cleanup(void) |
84 | { | ||
84 | ENGINE *iterator = engine_list_head; | 85 | ENGINE *iterator = engine_list_head; |
85 | 86 | ||
86 | while(iterator != NULL) | 87 | while (iterator != NULL) { |
87 | { | ||
88 | ENGINE_remove(iterator); | 88 | ENGINE_remove(iterator); |
89 | iterator = engine_list_head; | 89 | iterator = engine_list_head; |
90 | } | ||
91 | return; | ||
92 | } | 90 | } |
91 | return; | ||
92 | } | ||
93 | 93 | ||
94 | /* These static functions starting with a lower case "engine_" always | 94 | /* These static functions starting with a lower case "engine_" always |
95 | * take place when CRYPTO_LOCK_ENGINE has been locked up. */ | 95 | * take place when CRYPTO_LOCK_ENGINE has been locked up. */ |
96 | static int engine_list_add(ENGINE *e) | 96 | static int |
97 | { | 97 | engine_list_add(ENGINE *e) |
98 | { | ||
98 | int conflict = 0; | 99 | int conflict = 0; |
99 | ENGINE *iterator = NULL; | 100 | ENGINE *iterator = NULL; |
100 | 101 | ||
101 | if(e == NULL) | 102 | if (e == NULL) { |
102 | { | ||
103 | ENGINEerr(ENGINE_F_ENGINE_LIST_ADD, | 103 | ENGINEerr(ENGINE_F_ENGINE_LIST_ADD, |
104 | ERR_R_PASSED_NULL_PARAMETER); | 104 | ERR_R_PASSED_NULL_PARAMETER); |
105 | return 0; | 105 | return 0; |
106 | } | 106 | } |
107 | iterator = engine_list_head; | 107 | iterator = engine_list_head; |
108 | while(iterator && !conflict) | 108 | while (iterator && !conflict) { |
109 | { | ||
110 | conflict = (strcmp(iterator->id, e->id) == 0); | 109 | conflict = (strcmp(iterator->id, e->id) == 0); |
111 | iterator = iterator->next; | 110 | iterator = iterator->next; |
112 | } | 111 | } |
113 | if(conflict) | 112 | if (conflict) { |
114 | { | ||
115 | ENGINEerr(ENGINE_F_ENGINE_LIST_ADD, | 113 | ENGINEerr(ENGINE_F_ENGINE_LIST_ADD, |
116 | ENGINE_R_CONFLICTING_ENGINE_ID); | 114 | ENGINE_R_CONFLICTING_ENGINE_ID); |
117 | return 0; | 115 | return 0; |
118 | } | 116 | } |
119 | if(engine_list_head == NULL) | 117 | if (engine_list_head == NULL) { |
120 | { | ||
121 | /* We are adding to an empty list. */ | 118 | /* We are adding to an empty list. */ |
122 | if(engine_list_tail) | 119 | if (engine_list_tail) { |
123 | { | ||
124 | ENGINEerr(ENGINE_F_ENGINE_LIST_ADD, | 120 | ENGINEerr(ENGINE_F_ENGINE_LIST_ADD, |
125 | ENGINE_R_INTERNAL_LIST_ERROR); | 121 | ENGINE_R_INTERNAL_LIST_ERROR); |
126 | return 0; | 122 | return 0; |
127 | } | 123 | } |
128 | engine_list_head = e; | 124 | engine_list_head = e; |
129 | e->prev = NULL; | 125 | e->prev = NULL; |
130 | /* The first time the list allocates, we should register the | 126 | /* The first time the list allocates, we should register the |
131 | * cleanup. */ | 127 | * cleanup. */ |
132 | engine_cleanup_add_last(engine_list_cleanup); | 128 | engine_cleanup_add_last(engine_list_cleanup); |
133 | } | 129 | } else { |
134 | else | ||
135 | { | ||
136 | /* We are adding to the tail of an existing list. */ | 130 | /* We are adding to the tail of an existing list. */ |
137 | if((engine_list_tail == NULL) || | 131 | if ((engine_list_tail == NULL) || |
138 | (engine_list_tail->next != NULL)) | 132 | (engine_list_tail->next != NULL)) { |
139 | { | ||
140 | ENGINEerr(ENGINE_F_ENGINE_LIST_ADD, | 133 | ENGINEerr(ENGINE_F_ENGINE_LIST_ADD, |
141 | ENGINE_R_INTERNAL_LIST_ERROR); | 134 | ENGINE_R_INTERNAL_LIST_ERROR); |
142 | return 0; | 135 | return 0; |
143 | } | 136 | } |
144 | engine_list_tail->next = e; | 137 | engine_list_tail->next = e; |
145 | e->prev = engine_list_tail; | 138 | e->prev = engine_list_tail; |
146 | } | 139 | } |
147 | /* Having the engine in the list assumes a structural | 140 | /* Having the engine in the list assumes a structural |
148 | * reference. */ | 141 | * reference. */ |
149 | e->struct_ref++; | 142 | e->struct_ref++; |
@@ -152,169 +145,168 @@ static int engine_list_add(ENGINE *e) | |||
152 | engine_list_tail = e; | 145 | engine_list_tail = e; |
153 | e->next = NULL; | 146 | e->next = NULL; |
154 | return 1; | 147 | return 1; |
155 | } | 148 | } |
156 | 149 | ||
157 | static int engine_list_remove(ENGINE *e) | 150 | static int |
158 | { | 151 | engine_list_remove(ENGINE *e) |
152 | { | ||
159 | ENGINE *iterator; | 153 | ENGINE *iterator; |
160 | 154 | ||
161 | if(e == NULL) | 155 | if (e == NULL) { |
162 | { | ||
163 | ENGINEerr(ENGINE_F_ENGINE_LIST_REMOVE, | 156 | ENGINEerr(ENGINE_F_ENGINE_LIST_REMOVE, |
164 | ERR_R_PASSED_NULL_PARAMETER); | 157 | ERR_R_PASSED_NULL_PARAMETER); |
165 | return 0; | 158 | return 0; |
166 | } | 159 | } |
167 | /* We need to check that e is in our linked list! */ | 160 | /* We need to check that e is in our linked list! */ |
168 | iterator = engine_list_head; | 161 | iterator = engine_list_head; |
169 | while(iterator && (iterator != e)) | 162 | while (iterator && (iterator != e)) |
170 | iterator = iterator->next; | 163 | iterator = iterator->next; |
171 | if(iterator == NULL) | 164 | if (iterator == NULL) { |
172 | { | ||
173 | ENGINEerr(ENGINE_F_ENGINE_LIST_REMOVE, | 165 | ENGINEerr(ENGINE_F_ENGINE_LIST_REMOVE, |
174 | ENGINE_R_ENGINE_IS_NOT_IN_LIST); | 166 | ENGINE_R_ENGINE_IS_NOT_IN_LIST); |
175 | return 0; | 167 | return 0; |
176 | } | 168 | } |
177 | /* un-link e from the chain. */ | 169 | /* un-link e from the chain. */ |
178 | if(e->next) | 170 | if (e->next) |
179 | e->next->prev = e->prev; | 171 | e->next->prev = e->prev; |
180 | if(e->prev) | 172 | if (e->prev) |
181 | e->prev->next = e->next; | 173 | e->prev->next = e->next; |
182 | /* Correct our head/tail if necessary. */ | 174 | /* Correct our head/tail if necessary. */ |
183 | if(engine_list_head == e) | 175 | if (engine_list_head == e) |
184 | engine_list_head = e->next; | 176 | engine_list_head = e->next; |
185 | if(engine_list_tail == e) | 177 | if (engine_list_tail == e) |
186 | engine_list_tail = e->prev; | 178 | engine_list_tail = e->prev; |
187 | engine_free_util(e, 0); | 179 | engine_free_util(e, 0); |
188 | return 1; | 180 | return 1; |
189 | } | 181 | } |
190 | 182 | ||
191 | /* Get the first/last "ENGINE" type available. */ | 183 | /* Get the first/last "ENGINE" type available. */ |
192 | ENGINE *ENGINE_get_first(void) | 184 | ENGINE * |
193 | { | 185 | ENGINE_get_first(void) |
186 | { | ||
194 | ENGINE *ret; | 187 | ENGINE *ret; |
195 | 188 | ||
196 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | 189 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); |
197 | ret = engine_list_head; | 190 | ret = engine_list_head; |
198 | if(ret) | 191 | if (ret) { |
199 | { | ||
200 | ret->struct_ref++; | 192 | ret->struct_ref++; |
201 | engine_ref_debug(ret, 0, 1) | 193 | engine_ref_debug(ret, 0, 1) |
202 | } | 194 | } |
203 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | 195 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); |
204 | return ret; | 196 | return ret; |
205 | } | 197 | } |
206 | 198 | ||
207 | ENGINE *ENGINE_get_last(void) | 199 | ENGINE * |
208 | { | 200 | ENGINE_get_last(void) |
201 | { | ||
209 | ENGINE *ret; | 202 | ENGINE *ret; |
210 | 203 | ||
211 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | 204 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); |
212 | ret = engine_list_tail; | 205 | ret = engine_list_tail; |
213 | if(ret) | 206 | if (ret) { |
214 | { | ||
215 | ret->struct_ref++; | 207 | ret->struct_ref++; |
216 | engine_ref_debug(ret, 0, 1) | 208 | engine_ref_debug(ret, 0, 1) |
217 | } | 209 | } |
218 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | 210 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); |
219 | return ret; | 211 | return ret; |
220 | } | 212 | } |
221 | 213 | ||
222 | /* Iterate to the next/previous "ENGINE" type (NULL = end of the list). */ | 214 | /* Iterate to the next/previous "ENGINE" type (NULL = end of the list). */ |
223 | ENGINE *ENGINE_get_next(ENGINE *e) | 215 | ENGINE * |
224 | { | 216 | ENGINE_get_next(ENGINE *e) |
217 | { | ||
225 | ENGINE *ret = NULL; | 218 | ENGINE *ret = NULL; |
226 | if(e == NULL) | 219 | |
227 | { | 220 | if (e == NULL) { |
228 | ENGINEerr(ENGINE_F_ENGINE_GET_NEXT, | 221 | ENGINEerr(ENGINE_F_ENGINE_GET_NEXT, |
229 | ERR_R_PASSED_NULL_PARAMETER); | 222 | ERR_R_PASSED_NULL_PARAMETER); |
230 | return 0; | 223 | return 0; |
231 | } | 224 | } |
232 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | 225 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); |
233 | ret = e->next; | 226 | ret = e->next; |
234 | if(ret) | 227 | if (ret) { |
235 | { | ||
236 | /* Return a valid structural refernce to the next ENGINE */ | 228 | /* Return a valid structural refernce to the next ENGINE */ |
237 | ret->struct_ref++; | 229 | ret->struct_ref++; |
238 | engine_ref_debug(ret, 0, 1) | 230 | engine_ref_debug(ret, 0, 1) |
239 | } | 231 | } |
240 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | 232 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); |
241 | /* Release the structural reference to the previous ENGINE */ | 233 | /* Release the structural reference to the previous ENGINE */ |
242 | ENGINE_free(e); | 234 | ENGINE_free(e); |
243 | return ret; | 235 | return ret; |
244 | } | 236 | } |
245 | 237 | ||
246 | ENGINE *ENGINE_get_prev(ENGINE *e) | 238 | ENGINE * |
247 | { | 239 | ENGINE_get_prev(ENGINE *e) |
240 | { | ||
248 | ENGINE *ret = NULL; | 241 | ENGINE *ret = NULL; |
249 | if(e == NULL) | 242 | |
250 | { | 243 | if (e == NULL) { |
251 | ENGINEerr(ENGINE_F_ENGINE_GET_PREV, | 244 | ENGINEerr(ENGINE_F_ENGINE_GET_PREV, |
252 | ERR_R_PASSED_NULL_PARAMETER); | 245 | ERR_R_PASSED_NULL_PARAMETER); |
253 | return 0; | 246 | return 0; |
254 | } | 247 | } |
255 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | 248 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); |
256 | ret = e->prev; | 249 | ret = e->prev; |
257 | if(ret) | 250 | if (ret) { |
258 | { | ||
259 | /* Return a valid structural reference to the next ENGINE */ | 251 | /* Return a valid structural reference to the next ENGINE */ |
260 | ret->struct_ref++; | 252 | ret->struct_ref++; |
261 | engine_ref_debug(ret, 0, 1) | 253 | engine_ref_debug(ret, 0, 1) |
262 | } | 254 | } |
263 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | 255 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); |
264 | /* Release the structural reference to the previous ENGINE */ | 256 | /* Release the structural reference to the previous ENGINE */ |
265 | ENGINE_free(e); | 257 | ENGINE_free(e); |
266 | return ret; | 258 | return ret; |
267 | } | 259 | } |
268 | 260 | ||
269 | /* Add another "ENGINE" type into the list. */ | 261 | /* Add another "ENGINE" type into the list. */ |
270 | int ENGINE_add(ENGINE *e) | 262 | int |
271 | { | 263 | ENGINE_add(ENGINE *e) |
264 | { | ||
272 | int to_return = 1; | 265 | int to_return = 1; |
273 | if(e == NULL) | 266 | |
274 | { | 267 | if (e == NULL) { |
275 | ENGINEerr(ENGINE_F_ENGINE_ADD, | 268 | ENGINEerr(ENGINE_F_ENGINE_ADD, |
276 | ERR_R_PASSED_NULL_PARAMETER); | 269 | ERR_R_PASSED_NULL_PARAMETER); |
277 | return 0; | 270 | return 0; |
278 | } | 271 | } |
279 | if((e->id == NULL) || (e->name == NULL)) | 272 | if ((e->id == NULL) || (e->name == NULL)) { |
280 | { | ||
281 | ENGINEerr(ENGINE_F_ENGINE_ADD, | 273 | ENGINEerr(ENGINE_F_ENGINE_ADD, |
282 | ENGINE_R_ID_OR_NAME_MISSING); | 274 | ENGINE_R_ID_OR_NAME_MISSING); |
283 | } | 275 | } |
284 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | 276 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); |
285 | if(!engine_list_add(e)) | 277 | if (!engine_list_add(e)) { |
286 | { | ||
287 | ENGINEerr(ENGINE_F_ENGINE_ADD, | 278 | ENGINEerr(ENGINE_F_ENGINE_ADD, |
288 | ENGINE_R_INTERNAL_LIST_ERROR); | 279 | ENGINE_R_INTERNAL_LIST_ERROR); |
289 | to_return = 0; | 280 | to_return = 0; |
290 | } | 281 | } |
291 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | 282 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); |
292 | return to_return; | 283 | return to_return; |
293 | } | 284 | } |
294 | 285 | ||
295 | /* Remove an existing "ENGINE" type from the array. */ | 286 | /* Remove an existing "ENGINE" type from the array. */ |
296 | int ENGINE_remove(ENGINE *e) | 287 | int |
297 | { | 288 | ENGINE_remove(ENGINE *e) |
289 | { | ||
298 | int to_return = 1; | 290 | int to_return = 1; |
299 | if(e == NULL) | 291 | |
300 | { | 292 | if (e == NULL) { |
301 | ENGINEerr(ENGINE_F_ENGINE_REMOVE, | 293 | ENGINEerr(ENGINE_F_ENGINE_REMOVE, |
302 | ERR_R_PASSED_NULL_PARAMETER); | 294 | ERR_R_PASSED_NULL_PARAMETER); |
303 | return 0; | 295 | return 0; |
304 | } | 296 | } |
305 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | 297 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); |
306 | if(!engine_list_remove(e)) | 298 | if (!engine_list_remove(e)) { |
307 | { | ||
308 | ENGINEerr(ENGINE_F_ENGINE_REMOVE, | 299 | ENGINEerr(ENGINE_F_ENGINE_REMOVE, |
309 | ENGINE_R_INTERNAL_LIST_ERROR); | 300 | ENGINE_R_INTERNAL_LIST_ERROR); |
310 | to_return = 0; | 301 | to_return = 0; |
311 | } | 302 | } |
312 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | 303 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); |
313 | return to_return; | 304 | return to_return; |
314 | } | 305 | } |
315 | 306 | ||
316 | static void engine_cpy(ENGINE *dest, const ENGINE *src) | 307 | static void |
317 | { | 308 | engine_cpy(ENGINE *dest, const ENGINE *src) |
309 | { | ||
318 | dest->id = src->id; | 310 | dest->id = src->id; |
319 | dest->name = src->name; | 311 | dest->name = src->name; |
320 | #ifndef OPENSSL_NO_RSA | 312 | #ifndef OPENSSL_NO_RSA |
@@ -345,86 +337,83 @@ static void engine_cpy(ENGINE *dest, const ENGINE *src) | |||
345 | dest->load_pubkey = src->load_pubkey; | 337 | dest->load_pubkey = src->load_pubkey; |
346 | dest->cmd_defns = src->cmd_defns; | 338 | dest->cmd_defns = src->cmd_defns; |
347 | dest->flags = src->flags; | 339 | dest->flags = src->flags; |
348 | } | 340 | } |
349 | 341 | ||
350 | ENGINE *ENGINE_by_id(const char *id) | 342 | ENGINE * |
351 | { | 343 | ENGINE_by_id(const char *id) |
344 | { | ||
352 | ENGINE *iterator; | 345 | ENGINE *iterator; |
353 | char *load_dir = NULL; | 346 | char *load_dir = NULL; |
354 | if(id == NULL) | 347 | |
355 | { | 348 | if (id == NULL) { |
356 | ENGINEerr(ENGINE_F_ENGINE_BY_ID, | 349 | ENGINEerr(ENGINE_F_ENGINE_BY_ID, |
357 | ERR_R_PASSED_NULL_PARAMETER); | 350 | ERR_R_PASSED_NULL_PARAMETER); |
358 | return NULL; | 351 | return NULL; |
359 | } | 352 | } |
360 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | 353 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); |
361 | iterator = engine_list_head; | 354 | iterator = engine_list_head; |
362 | while(iterator && (strcmp(id, iterator->id) != 0)) | 355 | while (iterator && (strcmp(id, iterator->id) != 0)) |
363 | iterator = iterator->next; | 356 | iterator = iterator->next; |
364 | if(iterator) | 357 | if (iterator) { |
365 | { | ||
366 | /* We need to return a structural reference. If this is an | 358 | /* We need to return a structural reference. If this is an |
367 | * ENGINE type that returns copies, make a duplicate - otherwise | 359 | * ENGINE type that returns copies, make a duplicate - otherwise |
368 | * increment the existing ENGINE's reference count. */ | 360 | * increment the existing ENGINE's reference count. */ |
369 | if(iterator->flags & ENGINE_FLAGS_BY_ID_COPY) | 361 | if (iterator->flags & ENGINE_FLAGS_BY_ID_COPY) { |
370 | { | ||
371 | ENGINE *cp = ENGINE_new(); | 362 | ENGINE *cp = ENGINE_new(); |
372 | if(!cp) | 363 | if (!cp) |
373 | iterator = NULL; | 364 | iterator = NULL; |
374 | else | 365 | else { |
375 | { | ||
376 | engine_cpy(cp, iterator); | 366 | engine_cpy(cp, iterator); |
377 | iterator = cp; | 367 | iterator = cp; |
378 | } | ||
379 | } | 368 | } |
380 | else | 369 | } else { |
381 | { | ||
382 | iterator->struct_ref++; | 370 | iterator->struct_ref++; |
383 | engine_ref_debug(iterator, 0, 1) | 371 | engine_ref_debug(iterator, 0, 1) |
384 | } | ||
385 | } | 372 | } |
373 | } | ||
386 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | 374 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); |
387 | #if 0 | 375 | #if 0 |
388 | if(iterator == NULL) | 376 | if (iterator == NULL) { |
389 | { | ||
390 | ENGINEerr(ENGINE_F_ENGINE_BY_ID, | 377 | ENGINEerr(ENGINE_F_ENGINE_BY_ID, |
391 | ENGINE_R_NO_SUCH_ENGINE); | 378 | ENGINE_R_NO_SUCH_ENGINE); |
392 | ERR_asprintf_error_data("id=%s", id); | 379 | ERR_asprintf_error_data("id=%s", id); |
393 | } | 380 | } |
394 | return iterator; | 381 | return iterator; |
395 | #else | 382 | #else |
396 | /* EEK! Experimental code starts */ | 383 | /* EEK! Experimental code starts */ |
397 | if(iterator) return iterator; | 384 | if (iterator) |
385 | return iterator; | ||
398 | /* Prevent infinite recusrion if we're looking for the dynamic engine. */ | 386 | /* Prevent infinite recusrion if we're looking for the dynamic engine. */ |
399 | if (strcmp(id, "dynamic")) | 387 | if (strcmp(id, "dynamic")) { |
400 | { | 388 | if ((load_dir = getenv("OPENSSL_ENGINES")) == 0) |
401 | if((load_dir = getenv("OPENSSL_ENGINES")) == 0) load_dir = ENGINESDIR; | 389 | load_dir = ENGINESDIR; |
402 | iterator = ENGINE_by_id("dynamic"); | 390 | iterator = ENGINE_by_id("dynamic"); |
403 | if(!iterator || !ENGINE_ctrl_cmd_string(iterator, "ID", id, 0) || | 391 | if (!iterator || |
404 | !ENGINE_ctrl_cmd_string(iterator, "DIR_LOAD", "2", 0) || | 392 | !ENGINE_ctrl_cmd_string(iterator, "ID", id, 0) || |
405 | !ENGINE_ctrl_cmd_string(iterator, "DIR_ADD", | 393 | !ENGINE_ctrl_cmd_string(iterator, "DIR_LOAD", "2", 0) || |
406 | load_dir, 0) || | 394 | !ENGINE_ctrl_cmd_string(iterator, "DIR_ADD", load_dir, 0) || |
407 | !ENGINE_ctrl_cmd_string(iterator, "LIST_ADD", "1", 0) || | 395 | !ENGINE_ctrl_cmd_string(iterator, "LIST_ADD", "1", 0) || |
408 | !ENGINE_ctrl_cmd_string(iterator, "LOAD", NULL, 0)) | 396 | !ENGINE_ctrl_cmd_string(iterator, "LOAD", NULL, 0)) |
409 | goto notfound; | 397 | goto notfound; |
410 | return iterator; | 398 | return iterator; |
411 | } | 399 | } |
400 | |||
412 | notfound: | 401 | notfound: |
413 | ENGINE_free(iterator); | 402 | ENGINE_free(iterator); |
414 | ENGINEerr(ENGINE_F_ENGINE_BY_ID,ENGINE_R_NO_SUCH_ENGINE); | 403 | ENGINEerr(ENGINE_F_ENGINE_BY_ID, ENGINE_R_NO_SUCH_ENGINE); |
415 | ERR_asprintf_error_data("id=%s", id); | 404 | ERR_asprintf_error_data("id=%s", id); |
416 | return NULL; | 405 | return NULL; |
417 | /* EEK! Experimental code ends */ | 406 | /* EEK! Experimental code ends */ |
418 | #endif | 407 | #endif |
419 | } | 408 | } |
420 | 409 | ||
421 | int ENGINE_up_ref(ENGINE *e) | 410 | int |
422 | { | 411 | ENGINE_up_ref(ENGINE *e) |
423 | if (e == NULL) | 412 | { |
424 | { | 413 | if (e == NULL) { |
425 | ENGINEerr(ENGINE_F_ENGINE_UP_REF,ERR_R_PASSED_NULL_PARAMETER); | 414 | ENGINEerr(ENGINE_F_ENGINE_UP_REF, ERR_R_PASSED_NULL_PARAMETER); |
426 | return 0; | 415 | return 0; |
427 | } | ||
428 | CRYPTO_add(&e->struct_ref,1,CRYPTO_LOCK_ENGINE); | ||
429 | return 1; | ||
430 | } | 416 | } |
417 | CRYPTO_add(&e->struct_ref, 1, CRYPTO_LOCK_ENGINE); | ||
418 | return 1; | ||
419 | } | ||
diff --git a/src/lib/libcrypto/engine/engine.h b/src/lib/libcrypto/engine/engine.h index 6dfd0ad6d1..24d2c5eac5 100644 --- a/src/lib/libcrypto/engine/engine.h +++ b/src/lib/libcrypto/engine/engine.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: engine.h,v 1.28 2014/06/12 15:49:29 deraadt Exp $ */ | 1 | /* $OpenBSD: engine.h,v 1.29 2014/06/22 12:16:28 jsing Exp $ */ |
2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL | 2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL |
3 | * project 2000. | 3 | * project 2000. |
4 | */ | 4 | */ |
@@ -10,7 +10,7 @@ | |||
10 | * are met: | 10 | * are met: |
11 | * | 11 | * |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * | 14 | * |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
@@ -57,7 +57,7 @@ | |||
57 | */ | 57 | */ |
58 | /* ==================================================================== | 58 | /* ==================================================================== |
59 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 59 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
60 | * ECDH support in OpenSSL originally developed by | 60 | * ECDH support in OpenSSL originally developed by |
61 | * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. | 61 | * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. |
62 | */ | 62 | */ |
63 | 63 | ||
@@ -140,7 +140,7 @@ extern "C" { | |||
140 | * the existing ENGINE's structural reference count. */ | 140 | * the existing ENGINE's structural reference count. */ |
141 | #define ENGINE_FLAGS_BY_ID_COPY (int)0x0004 | 141 | #define ENGINE_FLAGS_BY_ID_COPY (int)0x0004 |
142 | 142 | ||
143 | /* This flag if for an ENGINE that does not want its methods registered as | 143 | /* This flag if for an ENGINE that does not want its methods registered as |
144 | * part of ENGINE_register_all_complete() for example if the methods are | 144 | * part of ENGINE_register_all_complete() for example if the methods are |
145 | * not usable as default methods. | 145 | * not usable as default methods. |
146 | */ | 146 | */ |
@@ -254,26 +254,27 @@ extern "C" { | |||
254 | * array). NB: The array must be ordered in increasing order of cmd_num. | 254 | * array). NB: The array must be ordered in increasing order of cmd_num. |
255 | * "null-terminated" means that the last ENGINE_CMD_DEFN element has cmd_num set | 255 | * "null-terminated" means that the last ENGINE_CMD_DEFN element has cmd_num set |
256 | * to zero and/or cmd_name set to NULL. */ | 256 | * to zero and/or cmd_name set to NULL. */ |
257 | typedef struct ENGINE_CMD_DEFN_st | 257 | typedef struct ENGINE_CMD_DEFN_st { |
258 | { | ||
259 | unsigned int cmd_num; /* The command number */ | 258 | unsigned int cmd_num; /* The command number */ |
260 | const char *cmd_name; /* The command name itself */ | 259 | const char *cmd_name; /* The command name itself */ |
261 | const char *cmd_desc; /* A short description of the command */ | 260 | const char *cmd_desc; /* A short description of the command */ |
262 | unsigned int cmd_flags; /* The input the command expects */ | 261 | unsigned int cmd_flags; /* The input the command expects */ |
263 | } ENGINE_CMD_DEFN; | 262 | } ENGINE_CMD_DEFN; |
264 | 263 | ||
265 | /* Generic function pointer */ | 264 | /* Generic function pointer */ |
266 | typedef int (*ENGINE_GEN_FUNC_PTR)(void); | 265 | typedef int (*ENGINE_GEN_FUNC_PTR)(void); |
267 | /* Generic function pointer taking no arguments */ | 266 | /* Generic function pointer taking no arguments */ |
268 | typedef int (*ENGINE_GEN_INT_FUNC_PTR)(ENGINE *); | 267 | typedef int (*ENGINE_GEN_INT_FUNC_PTR)(ENGINE *); |
269 | /* Specific control function pointer */ | 268 | /* Specific control function pointer */ |
270 | typedef int (*ENGINE_CTRL_FUNC_PTR)(ENGINE *, int, long, void *, void (*f)(void)); | 269 | typedef int (*ENGINE_CTRL_FUNC_PTR)(ENGINE *, int, long, void *, |
270 | void (*f)(void)); | ||
271 | /* Generic load_key function pointer */ | 271 | /* Generic load_key function pointer */ |
272 | typedef EVP_PKEY * (*ENGINE_LOAD_KEY_PTR)(ENGINE *, const char *, | 272 | typedef EVP_PKEY * (*ENGINE_LOAD_KEY_PTR)(ENGINE *, const char *, |
273 | UI_METHOD *ui_method, void *callback_data); | 273 | UI_METHOD *ui_method, void *callback_data); |
274 | typedef int (*ENGINE_SSL_CLIENT_CERT_PTR)(ENGINE *, SSL *ssl, | 274 | typedef int (*ENGINE_SSL_CLIENT_CERT_PTR)(ENGINE *, SSL *ssl, |
275 | STACK_OF(X509_NAME) *ca_dn, X509 **pcert, EVP_PKEY **pkey, | 275 | STACK_OF(X509_NAME) *ca_dn, X509 **pcert, EVP_PKEY **pkey, |
276 | STACK_OF(X509) **pother, UI_METHOD *ui_method, void *callback_data); | 276 | STACK_OF(X509) **pother, UI_METHOD *ui_method, void *callback_data); |
277 | |||
277 | /* These callback types are for an ENGINE's handler for cipher and digest logic. | 278 | /* These callback types are for an ENGINE's handler for cipher and digest logic. |
278 | * These handlers have these prototypes; | 279 | * These handlers have these prototypes; |
279 | * int foo(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid); | 280 | * int foo(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid); |
@@ -286,10 +287,14 @@ typedef int (*ENGINE_SSL_CLIENT_CERT_PTR)(ENGINE *, SSL *ssl, | |||
286 | */ | 287 | */ |
287 | /* Returns to a pointer to the array of supported cipher 'nid's. If the second | 288 | /* Returns to a pointer to the array of supported cipher 'nid's. If the second |
288 | * parameter is non-NULL it is set to the size of the returned array. */ | 289 | * parameter is non-NULL it is set to the size of the returned array. */ |
289 | typedef int (*ENGINE_CIPHERS_PTR)(ENGINE *, const EVP_CIPHER **, const int **, int); | 290 | typedef int (*ENGINE_CIPHERS_PTR)(ENGINE *, const EVP_CIPHER **, |
291 | const int **, int); | ||
290 | typedef int (*ENGINE_DIGESTS_PTR)(ENGINE *, const EVP_MD **, const int **, int); | 292 | typedef int (*ENGINE_DIGESTS_PTR)(ENGINE *, const EVP_MD **, const int **, int); |
291 | typedef int (*ENGINE_PKEY_METHS_PTR)(ENGINE *, EVP_PKEY_METHOD **, const int **, int); | 293 | typedef int (*ENGINE_PKEY_METHS_PTR)(ENGINE *, EVP_PKEY_METHOD **, |
292 | typedef int (*ENGINE_PKEY_ASN1_METHS_PTR)(ENGINE *, EVP_PKEY_ASN1_METHOD **, const int **, int); | 294 | const int **, int); |
295 | typedef int (*ENGINE_PKEY_ASN1_METHS_PTR)(ENGINE *, EVP_PKEY_ASN1_METHOD **, | ||
296 | const int **, int); | ||
297 | |||
293 | /* STRUCTURE functions ... all of these functions deal with pointers to ENGINE | 298 | /* STRUCTURE functions ... all of these functions deal with pointers to ENGINE |
294 | * structures where the pointers have a "structural reference". This means that | 299 | * structures where the pointers have a "structural reference". This means that |
295 | * their reference is to allowed access to the structure but it does not imply | 300 | * their reference is to allowed access to the structure but it does not imply |
@@ -405,7 +410,7 @@ int ENGINE_cmd_is_executable(ENGINE *e, int cmd); | |||
405 | * See the comment on ENGINE_ctrl_cmd_string() for an explanation on how to | 410 | * See the comment on ENGINE_ctrl_cmd_string() for an explanation on how to |
406 | * use the cmd_name and cmd_optional. */ | 411 | * use the cmd_name and cmd_optional. */ |
407 | int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name, | 412 | int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name, |
408 | long i, void *p, void (*f)(void), int cmd_optional); | 413 | long i, void *p, void (*f)(void), int cmd_optional); |
409 | 414 | ||
410 | /* This function passes a command-name and argument to an ENGINE. The cmd_name | 415 | /* This function passes a command-name and argument to an ENGINE. The cmd_name |
411 | * is converted to a command number and the control command is called using | 416 | * is converted to a command number and the control command is called using |
@@ -427,7 +432,7 @@ int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name, | |||
427 | * compliant ENGINE-based applications can work consistently with the same | 432 | * compliant ENGINE-based applications can work consistently with the same |
428 | * configuration for the same ENGINE-enabled devices, across applications. */ | 433 | * configuration for the same ENGINE-enabled devices, across applications. */ |
429 | int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg, | 434 | int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg, |
430 | int cmd_optional); | 435 | int cmd_optional); |
431 | 436 | ||
432 | /* These functions are useful for manufacturing new ENGINE structures. They | 437 | /* These functions are useful for manufacturing new ENGINE structures. They |
433 | * don't address reference counting at all - one uses them to populate an ENGINE | 438 | * don't address reference counting at all - one uses them to populate an ENGINE |
@@ -454,7 +459,7 @@ int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f); | |||
454 | int ENGINE_set_load_privkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpriv_f); | 459 | int ENGINE_set_load_privkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpriv_f); |
455 | int ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f); | 460 | int ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f); |
456 | int ENGINE_set_load_ssl_client_cert_function(ENGINE *e, | 461 | int ENGINE_set_load_ssl_client_cert_function(ENGINE *e, |
457 | ENGINE_SSL_CLIENT_CERT_PTR loadssl_f); | 462 | ENGINE_SSL_CLIENT_CERT_PTR loadssl_f); |
458 | int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f); | 463 | int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f); |
459 | int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f); | 464 | int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f); |
460 | int ENGINE_set_pkey_meths(ENGINE *e, ENGINE_PKEY_METHS_PTR f); | 465 | int ENGINE_set_pkey_meths(ENGINE *e, ENGINE_PKEY_METHS_PTR f); |
@@ -463,7 +468,7 @@ int ENGINE_set_flags(ENGINE *e, int flags); | |||
463 | int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns); | 468 | int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns); |
464 | /* These functions allow control over any per-structure ENGINE data. */ | 469 | /* These functions allow control over any per-structure ENGINE data. */ |
465 | int ENGINE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, | 470 | int ENGINE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, |
466 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); | 471 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); |
467 | int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg); | 472 | int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg); |
468 | void *ENGINE_get_ex_data(const ENGINE *e, int idx); | 473 | void *ENGINE_get_ex_data(const ENGINE *e, int idx); |
469 | 474 | ||
@@ -502,9 +507,9 @@ const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid); | |||
502 | const EVP_PKEY_METHOD *ENGINE_get_pkey_meth(ENGINE *e, int nid); | 507 | const EVP_PKEY_METHOD *ENGINE_get_pkey_meth(ENGINE *e, int nid); |
503 | const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth(ENGINE *e, int nid); | 508 | const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth(ENGINE *e, int nid); |
504 | const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth_str(ENGINE *e, | 509 | const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth_str(ENGINE *e, |
505 | const char *str, int len); | 510 | const char *str, int len); |
506 | const EVP_PKEY_ASN1_METHOD *ENGINE_pkey_asn1_find_str(ENGINE **pe, | 511 | const EVP_PKEY_ASN1_METHOD *ENGINE_pkey_asn1_find_str(ENGINE **pe, |
507 | const char *str, int len); | 512 | const char *str, int len); |
508 | const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e); | 513 | const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e); |
509 | int ENGINE_get_flags(const ENGINE *e); | 514 | int ENGINE_get_flags(const ENGINE *e); |
510 | 515 | ||
@@ -533,13 +538,13 @@ int ENGINE_finish(ENGINE *e); | |||
533 | * location, handled by the engine. The storage may be on a card or | 538 | * location, handled by the engine. The storage may be on a card or |
534 | * whatever. */ | 539 | * whatever. */ |
535 | EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id, | 540 | EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id, |
536 | UI_METHOD *ui_method, void *callback_data); | 541 | UI_METHOD *ui_method, void *callback_data); |
537 | EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id, | 542 | EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id, |
538 | UI_METHOD *ui_method, void *callback_data); | 543 | UI_METHOD *ui_method, void *callback_data); |
539 | int ENGINE_load_ssl_client_cert(ENGINE *e, SSL *s, | 544 | int ENGINE_load_ssl_client_cert(ENGINE *e, SSL *s, |
540 | STACK_OF(X509_NAME) *ca_dn, X509 **pcert, EVP_PKEY **ppkey, | 545 | STACK_OF(X509_NAME) *ca_dn, X509 **pcert, EVP_PKEY **ppkey, |
541 | STACK_OF(X509) **pother, | 546 | STACK_OF(X509) **pother, |
542 | UI_METHOD *ui_method, void *callback_data); | 547 | UI_METHOD *ui_method, void *callback_data); |
543 | 548 | ||
544 | /* This returns a pointer for the current ENGINE structure that | 549 | /* This returns a pointer for the current ENGINE structure that |
545 | * is (by default) performing any RSA operations. The value returned | 550 | * is (by default) performing any RSA operations. The value returned |
@@ -614,24 +619,24 @@ typedef struct st_dynamic_MEM_fns { | |||
614 | dyn_MEM_malloc_cb malloc_cb; | 619 | dyn_MEM_malloc_cb malloc_cb; |
615 | dyn_MEM_realloc_cb realloc_cb; | 620 | dyn_MEM_realloc_cb realloc_cb; |
616 | dyn_MEM_free_cb free_cb; | 621 | dyn_MEM_free_cb free_cb; |
617 | } dynamic_MEM_fns; | 622 | } dynamic_MEM_fns; |
618 | /* FIXME: Perhaps the memory and locking code (crypto.h) should declare and use | 623 | /* FIXME: Perhaps the memory and locking code (crypto.h) should declare and use |
619 | * these types so we (and any other dependant code) can simplify a bit?? */ | 624 | * these types so we (and any other dependant code) can simplify a bit?? */ |
620 | typedef void (*dyn_lock_locking_cb)(int,int,const char *,int); | 625 | typedef void (*dyn_lock_locking_cb)(int, int, const char *, int); |
621 | typedef int (*dyn_lock_add_lock_cb)(int*,int,int,const char *,int); | 626 | typedef int (*dyn_lock_add_lock_cb)(int*, int, int, const char *, int); |
622 | typedef struct CRYPTO_dynlock_value *(*dyn_dynlock_create_cb)( | 627 | typedef struct CRYPTO_dynlock_value *(*dyn_dynlock_create_cb)( |
623 | const char *,int); | 628 | const char *, int); |
624 | typedef void (*dyn_dynlock_lock_cb)(int,struct CRYPTO_dynlock_value *, | 629 | typedef void (*dyn_dynlock_lock_cb)(int, struct CRYPTO_dynlock_value *, |
625 | const char *,int); | 630 | const char *, int); |
626 | typedef void (*dyn_dynlock_destroy_cb)(struct CRYPTO_dynlock_value *, | 631 | typedef void (*dyn_dynlock_destroy_cb)(struct CRYPTO_dynlock_value *, |
627 | const char *,int); | 632 | const char *, int); |
628 | typedef struct st_dynamic_LOCK_fns { | 633 | typedef struct st_dynamic_LOCK_fns { |
629 | dyn_lock_locking_cb lock_locking_cb; | 634 | dyn_lock_locking_cb lock_locking_cb; |
630 | dyn_lock_add_lock_cb lock_add_lock_cb; | 635 | dyn_lock_add_lock_cb lock_add_lock_cb; |
631 | dyn_dynlock_create_cb dynlock_create_cb; | 636 | dyn_dynlock_create_cb dynlock_create_cb; |
632 | dyn_dynlock_lock_cb dynlock_lock_cb; | 637 | dyn_dynlock_lock_cb dynlock_lock_cb; |
633 | dyn_dynlock_destroy_cb dynlock_destroy_cb; | 638 | dyn_dynlock_destroy_cb dynlock_destroy_cb; |
634 | } dynamic_LOCK_fns; | 639 | } dynamic_LOCK_fns; |
635 | /* The top-level structure */ | 640 | /* The top-level structure */ |
636 | typedef struct st_dynamic_fns { | 641 | typedef struct st_dynamic_fns { |
637 | void *static_state; | 642 | void *static_state; |
@@ -639,7 +644,7 @@ typedef struct st_dynamic_fns { | |||
639 | const CRYPTO_EX_DATA_IMPL *ex_data_fns; | 644 | const CRYPTO_EX_DATA_IMPL *ex_data_fns; |
640 | dynamic_MEM_fns mem_fns; | 645 | dynamic_MEM_fns mem_fns; |
641 | dynamic_LOCK_fns lock_fns; | 646 | dynamic_LOCK_fns lock_fns; |
642 | } dynamic_fns; | 647 | } dynamic_fns; |
643 | 648 | ||
644 | /* The version checking function should be of this prototype. NB: The | 649 | /* The version checking function should be of this prototype. NB: The |
645 | * ossl_version value passed in is the OSSL_DYNAMIC_VERSION of the loading code. | 650 | * ossl_version value passed in is the OSSL_DYNAMIC_VERSION of the loading code. |
@@ -673,7 +678,7 @@ typedef unsigned long (*dynamic_v_check_fn)(unsigned long ossl_version); | |||
673 | * and returns an int value (zero for failure). 'fn' should have prototype; | 678 | * and returns an int value (zero for failure). 'fn' should have prototype; |
674 | * [static] int fn(ENGINE *e, const char *id); */ | 679 | * [static] int fn(ENGINE *e, const char *id); */ |
675 | typedef int (*dynamic_bind_engine)(ENGINE *e, const char *id, | 680 | typedef int (*dynamic_bind_engine)(ENGINE *e, const char *id, |
676 | const dynamic_fns *fns); | 681 | const dynamic_fns *fns); |
677 | #define IMPLEMENT_DYNAMIC_BIND_FN(fn) \ | 682 | #define IMPLEMENT_DYNAMIC_BIND_FN(fn) \ |
678 | extern \ | 683 | extern \ |
679 | int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns); \ | 684 | int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns); \ |
@@ -704,7 +709,7 @@ typedef int (*dynamic_bind_engine)(ENGINE *e, const char *id, | |||
704 | * detect this is to have a function that returns a pointer to some static data | 709 | * detect this is to have a function that returns a pointer to some static data |
705 | * and let the loading application and loaded ENGINE compare their respective | 710 | * and let the loading application and loaded ENGINE compare their respective |
706 | * values. */ | 711 | * values. */ |
707 | void *ENGINE_get_static_state(void); | 712 | void *ENGINE_get_static_state(void); |
708 | 713 | ||
709 | /* BEGIN ERROR CODES */ | 714 | /* BEGIN ERROR CODES */ |
710 | /* The following lines are auto generated by the script mkerr.pl. Any changes | 715 | /* The following lines are auto generated by the script mkerr.pl. Any changes |
diff --git a/src/lib/libssl/src/crypto/engine/eng_int.h b/src/lib/libssl/src/crypto/engine/eng_int.h index 992cba676b..22049fd7fd 100644 --- a/src/lib/libssl/src/crypto/engine/eng_int.h +++ b/src/lib/libssl/src/crypto/engine/eng_int.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: eng_int.h,v 1.5 2014/06/12 15:49:29 deraadt Exp $ */ | 1 | /* $OpenBSD: eng_int.h,v 1.6 2014/06/22 12:16:28 jsing Exp $ */ |
2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL | 2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL |
3 | * project 2000. | 3 | * project 2000. |
4 | */ | 4 | */ |
@@ -10,7 +10,7 @@ | |||
10 | * are met: | 10 | * are met: |
11 | * | 11 | * |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * | 14 | * |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
@@ -57,7 +57,7 @@ | |||
57 | */ | 57 | */ |
58 | /* ==================================================================== | 58 | /* ==================================================================== |
59 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 59 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
60 | * ECDH support in OpenSSL originally developed by | 60 | * ECDH support in OpenSSL originally developed by |
61 | * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. | 61 | * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. |
62 | */ | 62 | */ |
63 | 63 | ||
@@ -98,10 +98,9 @@ extern "C" { | |||
98 | * order. NB: both the "add" functions assume CRYPTO_LOCK_ENGINE to already be | 98 | * order. NB: both the "add" functions assume CRYPTO_LOCK_ENGINE to already be |
99 | * held (in "write" mode). */ | 99 | * held (in "write" mode). */ |
100 | typedef void (ENGINE_CLEANUP_CB)(void); | 100 | typedef void (ENGINE_CLEANUP_CB)(void); |
101 | typedef struct st_engine_cleanup_item | 101 | typedef struct st_engine_cleanup_item { |
102 | { | ||
103 | ENGINE_CLEANUP_CB *cb; | 102 | ENGINE_CLEANUP_CB *cb; |
104 | } ENGINE_CLEANUP_ITEM; | 103 | } ENGINE_CLEANUP_ITEM; |
105 | DECLARE_STACK_OF(ENGINE_CLEANUP_ITEM) | 104 | DECLARE_STACK_OF(ENGINE_CLEANUP_ITEM) |
106 | void engine_cleanup_add_first(ENGINE_CLEANUP_CB *cb); | 105 | void engine_cleanup_add_first(ENGINE_CLEANUP_CB *cb); |
107 | void engine_cleanup_add_last(ENGINE_CLEANUP_CB *cb); | 106 | void engine_cleanup_add_last(ENGINE_CLEANUP_CB *cb); |
@@ -118,17 +117,20 @@ DECLARE_STACK_OF(ENGINE) | |||
118 | * as a (ENGINE_TABLE *) pointer value set initially to NULL. */ | 117 | * as a (ENGINE_TABLE *) pointer value set initially to NULL. */ |
119 | typedef struct st_engine_table ENGINE_TABLE; | 118 | typedef struct st_engine_table ENGINE_TABLE; |
120 | int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup, | 119 | int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup, |
121 | ENGINE *e, const int *nids, int num_nids, int setdefault); | 120 | ENGINE *e, const int *nids, int num_nids, int setdefault); |
122 | void engine_table_unregister(ENGINE_TABLE **table, ENGINE *e); | 121 | void engine_table_unregister(ENGINE_TABLE **table, ENGINE *e); |
123 | void engine_table_cleanup(ENGINE_TABLE **table); | 122 | void engine_table_cleanup(ENGINE_TABLE **table); |
124 | #ifndef ENGINE_TABLE_DEBUG | 123 | #ifndef ENGINE_TABLE_DEBUG |
125 | ENGINE *engine_table_select(ENGINE_TABLE **table, int nid); | 124 | ENGINE *engine_table_select(ENGINE_TABLE **table, int nid); |
126 | #else | 125 | #else |
127 | ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f, int l); | 126 | ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f, |
127 | int l); | ||
128 | #define engine_table_select(t,n) engine_table_select_tmp(t,n,__FILE__,__LINE__) | 128 | #define engine_table_select(t,n) engine_table_select_tmp(t,n,__FILE__,__LINE__) |
129 | #endif | 129 | #endif |
130 | typedef void (engine_table_doall_cb)(int nid, STACK_OF(ENGINE) *sk, ENGINE *def, void *arg); | 130 | typedef void (engine_table_doall_cb)(int nid, STACK_OF(ENGINE) *sk, |
131 | void engine_table_doall(ENGINE_TABLE *table, engine_table_doall_cb *cb, void *arg); | 131 | ENGINE *def, void *arg); |
132 | void engine_table_doall(ENGINE_TABLE *table, engine_table_doall_cb *cb, | ||
133 | void *arg); | ||
132 | 134 | ||
133 | /* Internal versions of API functions that have control over locking. These are | 135 | /* Internal versions of API functions that have control over locking. These are |
134 | * used between C files when functionality needs to be shared but the caller may | 136 | * used between C files when functionality needs to be shared but the caller may |
@@ -152,8 +154,7 @@ void engine_pkey_asn1_meths_free(ENGINE *e); | |||
152 | 154 | ||
153 | /* This is a structure for storing implementations of various crypto | 155 | /* This is a structure for storing implementations of various crypto |
154 | * algorithms and functions. */ | 156 | * algorithms and functions. */ |
155 | struct engine_st | 157 | struct engine_st { |
156 | { | ||
157 | const char *id; | 158 | const char *id; |
158 | const char *name; | 159 | const char *name; |
159 | const RSA_METHOD *rsa_meth; | 160 | const RSA_METHOD *rsa_meth; |
@@ -197,7 +198,7 @@ struct engine_st | |||
197 | /* Used to maintain the linked-list of engines. */ | 198 | /* Used to maintain the linked-list of engines. */ |
198 | struct engine_st *prev; | 199 | struct engine_st *prev; |
199 | struct engine_st *next; | 200 | struct engine_st *next; |
200 | }; | 201 | }; |
201 | 202 | ||
202 | #ifdef __cplusplus | 203 | #ifdef __cplusplus |
203 | } | 204 | } |
diff --git a/src/lib/libssl/src/crypto/engine/eng_list.c b/src/lib/libssl/src/crypto/engine/eng_list.c index 05ed61a38a..053767c646 100644 --- a/src/lib/libssl/src/crypto/engine/eng_list.c +++ b/src/lib/libssl/src/crypto/engine/eng_list.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: eng_list.c,v 1.9 2014/06/12 15:49:29 deraadt Exp $ */ | 1 | /* $OpenBSD: eng_list.c,v 1.10 2014/06/22 12:15:53 jsing Exp $ */ |
2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL | 2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL |
3 | * project 2000. | 3 | * project 2000. |
4 | */ | 4 | */ |
@@ -10,7 +10,7 @@ | |||
10 | * are met: | 10 | * are met: |
11 | * | 11 | * |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * | 14 | * |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
@@ -57,7 +57,7 @@ | |||
57 | */ | 57 | */ |
58 | /* ==================================================================== | 58 | /* ==================================================================== |
59 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 59 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
60 | * ECDH support in OpenSSL originally developed by | 60 | * ECDH support in OpenSSL originally developed by |
61 | * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. | 61 | * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. |
62 | */ | 62 | */ |
63 | 63 | ||
@@ -79,71 +79,64 @@ static ENGINE *engine_list_tail = NULL; | |||
79 | /* This cleanup function is only needed internally. If it should be called, we | 79 | /* This cleanup function is only needed internally. If it should be called, we |
80 | * register it with the "ENGINE_cleanup()" stack to be called during cleanup. */ | 80 | * register it with the "ENGINE_cleanup()" stack to be called during cleanup. */ |
81 | 81 | ||
82 | static void engine_list_cleanup(void) | 82 | static void |
83 | { | 83 | engine_list_cleanup(void) |
84 | { | ||
84 | ENGINE *iterator = engine_list_head; | 85 | ENGINE *iterator = engine_list_head; |
85 | 86 | ||
86 | while(iterator != NULL) | 87 | while (iterator != NULL) { |
87 | { | ||
88 | ENGINE_remove(iterator); | 88 | ENGINE_remove(iterator); |
89 | iterator = engine_list_head; | 89 | iterator = engine_list_head; |
90 | } | ||
91 | return; | ||
92 | } | 90 | } |
91 | return; | ||
92 | } | ||
93 | 93 | ||
94 | /* These static functions starting with a lower case "engine_" always | 94 | /* These static functions starting with a lower case "engine_" always |
95 | * take place when CRYPTO_LOCK_ENGINE has been locked up. */ | 95 | * take place when CRYPTO_LOCK_ENGINE has been locked up. */ |
96 | static int engine_list_add(ENGINE *e) | 96 | static int |
97 | { | 97 | engine_list_add(ENGINE *e) |
98 | { | ||
98 | int conflict = 0; | 99 | int conflict = 0; |
99 | ENGINE *iterator = NULL; | 100 | ENGINE *iterator = NULL; |
100 | 101 | ||
101 | if(e == NULL) | 102 | if (e == NULL) { |
102 | { | ||
103 | ENGINEerr(ENGINE_F_ENGINE_LIST_ADD, | 103 | ENGINEerr(ENGINE_F_ENGINE_LIST_ADD, |
104 | ERR_R_PASSED_NULL_PARAMETER); | 104 | ERR_R_PASSED_NULL_PARAMETER); |
105 | return 0; | 105 | return 0; |
106 | } | 106 | } |
107 | iterator = engine_list_head; | 107 | iterator = engine_list_head; |
108 | while(iterator && !conflict) | 108 | while (iterator && !conflict) { |
109 | { | ||
110 | conflict = (strcmp(iterator->id, e->id) == 0); | 109 | conflict = (strcmp(iterator->id, e->id) == 0); |
111 | iterator = iterator->next; | 110 | iterator = iterator->next; |
112 | } | 111 | } |
113 | if(conflict) | 112 | if (conflict) { |
114 | { | ||
115 | ENGINEerr(ENGINE_F_ENGINE_LIST_ADD, | 113 | ENGINEerr(ENGINE_F_ENGINE_LIST_ADD, |
116 | ENGINE_R_CONFLICTING_ENGINE_ID); | 114 | ENGINE_R_CONFLICTING_ENGINE_ID); |
117 | return 0; | 115 | return 0; |
118 | } | 116 | } |
119 | if(engine_list_head == NULL) | 117 | if (engine_list_head == NULL) { |
120 | { | ||
121 | /* We are adding to an empty list. */ | 118 | /* We are adding to an empty list. */ |
122 | if(engine_list_tail) | 119 | if (engine_list_tail) { |
123 | { | ||
124 | ENGINEerr(ENGINE_F_ENGINE_LIST_ADD, | 120 | ENGINEerr(ENGINE_F_ENGINE_LIST_ADD, |
125 | ENGINE_R_INTERNAL_LIST_ERROR); | 121 | ENGINE_R_INTERNAL_LIST_ERROR); |
126 | return 0; | 122 | return 0; |
127 | } | 123 | } |
128 | engine_list_head = e; | 124 | engine_list_head = e; |
129 | e->prev = NULL; | 125 | e->prev = NULL; |
130 | /* The first time the list allocates, we should register the | 126 | /* The first time the list allocates, we should register the |
131 | * cleanup. */ | 127 | * cleanup. */ |
132 | engine_cleanup_add_last(engine_list_cleanup); | 128 | engine_cleanup_add_last(engine_list_cleanup); |
133 | } | 129 | } else { |
134 | else | ||
135 | { | ||
136 | /* We are adding to the tail of an existing list. */ | 130 | /* We are adding to the tail of an existing list. */ |
137 | if((engine_list_tail == NULL) || | 131 | if ((engine_list_tail == NULL) || |
138 | (engine_list_tail->next != NULL)) | 132 | (engine_list_tail->next != NULL)) { |
139 | { | ||
140 | ENGINEerr(ENGINE_F_ENGINE_LIST_ADD, | 133 | ENGINEerr(ENGINE_F_ENGINE_LIST_ADD, |
141 | ENGINE_R_INTERNAL_LIST_ERROR); | 134 | ENGINE_R_INTERNAL_LIST_ERROR); |
142 | return 0; | 135 | return 0; |
143 | } | 136 | } |
144 | engine_list_tail->next = e; | 137 | engine_list_tail->next = e; |
145 | e->prev = engine_list_tail; | 138 | e->prev = engine_list_tail; |
146 | } | 139 | } |
147 | /* Having the engine in the list assumes a structural | 140 | /* Having the engine in the list assumes a structural |
148 | * reference. */ | 141 | * reference. */ |
149 | e->struct_ref++; | 142 | e->struct_ref++; |
@@ -152,169 +145,168 @@ static int engine_list_add(ENGINE *e) | |||
152 | engine_list_tail = e; | 145 | engine_list_tail = e; |
153 | e->next = NULL; | 146 | e->next = NULL; |
154 | return 1; | 147 | return 1; |
155 | } | 148 | } |
156 | 149 | ||
157 | static int engine_list_remove(ENGINE *e) | 150 | static int |
158 | { | 151 | engine_list_remove(ENGINE *e) |
152 | { | ||
159 | ENGINE *iterator; | 153 | ENGINE *iterator; |
160 | 154 | ||
161 | if(e == NULL) | 155 | if (e == NULL) { |
162 | { | ||
163 | ENGINEerr(ENGINE_F_ENGINE_LIST_REMOVE, | 156 | ENGINEerr(ENGINE_F_ENGINE_LIST_REMOVE, |
164 | ERR_R_PASSED_NULL_PARAMETER); | 157 | ERR_R_PASSED_NULL_PARAMETER); |
165 | return 0; | 158 | return 0; |
166 | } | 159 | } |
167 | /* We need to check that e is in our linked list! */ | 160 | /* We need to check that e is in our linked list! */ |
168 | iterator = engine_list_head; | 161 | iterator = engine_list_head; |
169 | while(iterator && (iterator != e)) | 162 | while (iterator && (iterator != e)) |
170 | iterator = iterator->next; | 163 | iterator = iterator->next; |
171 | if(iterator == NULL) | 164 | if (iterator == NULL) { |
172 | { | ||
173 | ENGINEerr(ENGINE_F_ENGINE_LIST_REMOVE, | 165 | ENGINEerr(ENGINE_F_ENGINE_LIST_REMOVE, |
174 | ENGINE_R_ENGINE_IS_NOT_IN_LIST); | 166 | ENGINE_R_ENGINE_IS_NOT_IN_LIST); |
175 | return 0; | 167 | return 0; |
176 | } | 168 | } |
177 | /* un-link e from the chain. */ | 169 | /* un-link e from the chain. */ |
178 | if(e->next) | 170 | if (e->next) |
179 | e->next->prev = e->prev; | 171 | e->next->prev = e->prev; |
180 | if(e->prev) | 172 | if (e->prev) |
181 | e->prev->next = e->next; | 173 | e->prev->next = e->next; |
182 | /* Correct our head/tail if necessary. */ | 174 | /* Correct our head/tail if necessary. */ |
183 | if(engine_list_head == e) | 175 | if (engine_list_head == e) |
184 | engine_list_head = e->next; | 176 | engine_list_head = e->next; |
185 | if(engine_list_tail == e) | 177 | if (engine_list_tail == e) |
186 | engine_list_tail = e->prev; | 178 | engine_list_tail = e->prev; |
187 | engine_free_util(e, 0); | 179 | engine_free_util(e, 0); |
188 | return 1; | 180 | return 1; |
189 | } | 181 | } |
190 | 182 | ||
191 | /* Get the first/last "ENGINE" type available. */ | 183 | /* Get the first/last "ENGINE" type available. */ |
192 | ENGINE *ENGINE_get_first(void) | 184 | ENGINE * |
193 | { | 185 | ENGINE_get_first(void) |
186 | { | ||
194 | ENGINE *ret; | 187 | ENGINE *ret; |
195 | 188 | ||
196 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | 189 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); |
197 | ret = engine_list_head; | 190 | ret = engine_list_head; |
198 | if(ret) | 191 | if (ret) { |
199 | { | ||
200 | ret->struct_ref++; | 192 | ret->struct_ref++; |
201 | engine_ref_debug(ret, 0, 1) | 193 | engine_ref_debug(ret, 0, 1) |
202 | } | 194 | } |
203 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | 195 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); |
204 | return ret; | 196 | return ret; |
205 | } | 197 | } |
206 | 198 | ||
207 | ENGINE *ENGINE_get_last(void) | 199 | ENGINE * |
208 | { | 200 | ENGINE_get_last(void) |
201 | { | ||
209 | ENGINE *ret; | 202 | ENGINE *ret; |
210 | 203 | ||
211 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | 204 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); |
212 | ret = engine_list_tail; | 205 | ret = engine_list_tail; |
213 | if(ret) | 206 | if (ret) { |
214 | { | ||
215 | ret->struct_ref++; | 207 | ret->struct_ref++; |
216 | engine_ref_debug(ret, 0, 1) | 208 | engine_ref_debug(ret, 0, 1) |
217 | } | 209 | } |
218 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | 210 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); |
219 | return ret; | 211 | return ret; |
220 | } | 212 | } |
221 | 213 | ||
222 | /* Iterate to the next/previous "ENGINE" type (NULL = end of the list). */ | 214 | /* Iterate to the next/previous "ENGINE" type (NULL = end of the list). */ |
223 | ENGINE *ENGINE_get_next(ENGINE *e) | 215 | ENGINE * |
224 | { | 216 | ENGINE_get_next(ENGINE *e) |
217 | { | ||
225 | ENGINE *ret = NULL; | 218 | ENGINE *ret = NULL; |
226 | if(e == NULL) | 219 | |
227 | { | 220 | if (e == NULL) { |
228 | ENGINEerr(ENGINE_F_ENGINE_GET_NEXT, | 221 | ENGINEerr(ENGINE_F_ENGINE_GET_NEXT, |
229 | ERR_R_PASSED_NULL_PARAMETER); | 222 | ERR_R_PASSED_NULL_PARAMETER); |
230 | return 0; | 223 | return 0; |
231 | } | 224 | } |
232 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | 225 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); |
233 | ret = e->next; | 226 | ret = e->next; |
234 | if(ret) | 227 | if (ret) { |
235 | { | ||
236 | /* Return a valid structural refernce to the next ENGINE */ | 228 | /* Return a valid structural refernce to the next ENGINE */ |
237 | ret->struct_ref++; | 229 | ret->struct_ref++; |
238 | engine_ref_debug(ret, 0, 1) | 230 | engine_ref_debug(ret, 0, 1) |
239 | } | 231 | } |
240 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | 232 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); |
241 | /* Release the structural reference to the previous ENGINE */ | 233 | /* Release the structural reference to the previous ENGINE */ |
242 | ENGINE_free(e); | 234 | ENGINE_free(e); |
243 | return ret; | 235 | return ret; |
244 | } | 236 | } |
245 | 237 | ||
246 | ENGINE *ENGINE_get_prev(ENGINE *e) | 238 | ENGINE * |
247 | { | 239 | ENGINE_get_prev(ENGINE *e) |
240 | { | ||
248 | ENGINE *ret = NULL; | 241 | ENGINE *ret = NULL; |
249 | if(e == NULL) | 242 | |
250 | { | 243 | if (e == NULL) { |
251 | ENGINEerr(ENGINE_F_ENGINE_GET_PREV, | 244 | ENGINEerr(ENGINE_F_ENGINE_GET_PREV, |
252 | ERR_R_PASSED_NULL_PARAMETER); | 245 | ERR_R_PASSED_NULL_PARAMETER); |
253 | return 0; | 246 | return 0; |
254 | } | 247 | } |
255 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | 248 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); |
256 | ret = e->prev; | 249 | ret = e->prev; |
257 | if(ret) | 250 | if (ret) { |
258 | { | ||
259 | /* Return a valid structural reference to the next ENGINE */ | 251 | /* Return a valid structural reference to the next ENGINE */ |
260 | ret->struct_ref++; | 252 | ret->struct_ref++; |
261 | engine_ref_debug(ret, 0, 1) | 253 | engine_ref_debug(ret, 0, 1) |
262 | } | 254 | } |
263 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | 255 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); |
264 | /* Release the structural reference to the previous ENGINE */ | 256 | /* Release the structural reference to the previous ENGINE */ |
265 | ENGINE_free(e); | 257 | ENGINE_free(e); |
266 | return ret; | 258 | return ret; |
267 | } | 259 | } |
268 | 260 | ||
269 | /* Add another "ENGINE" type into the list. */ | 261 | /* Add another "ENGINE" type into the list. */ |
270 | int ENGINE_add(ENGINE *e) | 262 | int |
271 | { | 263 | ENGINE_add(ENGINE *e) |
264 | { | ||
272 | int to_return = 1; | 265 | int to_return = 1; |
273 | if(e == NULL) | 266 | |
274 | { | 267 | if (e == NULL) { |
275 | ENGINEerr(ENGINE_F_ENGINE_ADD, | 268 | ENGINEerr(ENGINE_F_ENGINE_ADD, |
276 | ERR_R_PASSED_NULL_PARAMETER); | 269 | ERR_R_PASSED_NULL_PARAMETER); |
277 | return 0; | 270 | return 0; |
278 | } | 271 | } |
279 | if((e->id == NULL) || (e->name == NULL)) | 272 | if ((e->id == NULL) || (e->name == NULL)) { |
280 | { | ||
281 | ENGINEerr(ENGINE_F_ENGINE_ADD, | 273 | ENGINEerr(ENGINE_F_ENGINE_ADD, |
282 | ENGINE_R_ID_OR_NAME_MISSING); | 274 | ENGINE_R_ID_OR_NAME_MISSING); |
283 | } | 275 | } |
284 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | 276 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); |
285 | if(!engine_list_add(e)) | 277 | if (!engine_list_add(e)) { |
286 | { | ||
287 | ENGINEerr(ENGINE_F_ENGINE_ADD, | 278 | ENGINEerr(ENGINE_F_ENGINE_ADD, |
288 | ENGINE_R_INTERNAL_LIST_ERROR); | 279 | ENGINE_R_INTERNAL_LIST_ERROR); |
289 | to_return = 0; | 280 | to_return = 0; |
290 | } | 281 | } |
291 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | 282 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); |
292 | return to_return; | 283 | return to_return; |
293 | } | 284 | } |
294 | 285 | ||
295 | /* Remove an existing "ENGINE" type from the array. */ | 286 | /* Remove an existing "ENGINE" type from the array. */ |
296 | int ENGINE_remove(ENGINE *e) | 287 | int |
297 | { | 288 | ENGINE_remove(ENGINE *e) |
289 | { | ||
298 | int to_return = 1; | 290 | int to_return = 1; |
299 | if(e == NULL) | 291 | |
300 | { | 292 | if (e == NULL) { |
301 | ENGINEerr(ENGINE_F_ENGINE_REMOVE, | 293 | ENGINEerr(ENGINE_F_ENGINE_REMOVE, |
302 | ERR_R_PASSED_NULL_PARAMETER); | 294 | ERR_R_PASSED_NULL_PARAMETER); |
303 | return 0; | 295 | return 0; |
304 | } | 296 | } |
305 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | 297 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); |
306 | if(!engine_list_remove(e)) | 298 | if (!engine_list_remove(e)) { |
307 | { | ||
308 | ENGINEerr(ENGINE_F_ENGINE_REMOVE, | 299 | ENGINEerr(ENGINE_F_ENGINE_REMOVE, |
309 | ENGINE_R_INTERNAL_LIST_ERROR); | 300 | ENGINE_R_INTERNAL_LIST_ERROR); |
310 | to_return = 0; | 301 | to_return = 0; |
311 | } | 302 | } |
312 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | 303 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); |
313 | return to_return; | 304 | return to_return; |
314 | } | 305 | } |
315 | 306 | ||
316 | static void engine_cpy(ENGINE *dest, const ENGINE *src) | 307 | static void |
317 | { | 308 | engine_cpy(ENGINE *dest, const ENGINE *src) |
309 | { | ||
318 | dest->id = src->id; | 310 | dest->id = src->id; |
319 | dest->name = src->name; | 311 | dest->name = src->name; |
320 | #ifndef OPENSSL_NO_RSA | 312 | #ifndef OPENSSL_NO_RSA |
@@ -345,86 +337,83 @@ static void engine_cpy(ENGINE *dest, const ENGINE *src) | |||
345 | dest->load_pubkey = src->load_pubkey; | 337 | dest->load_pubkey = src->load_pubkey; |
346 | dest->cmd_defns = src->cmd_defns; | 338 | dest->cmd_defns = src->cmd_defns; |
347 | dest->flags = src->flags; | 339 | dest->flags = src->flags; |
348 | } | 340 | } |
349 | 341 | ||
350 | ENGINE *ENGINE_by_id(const char *id) | 342 | ENGINE * |
351 | { | 343 | ENGINE_by_id(const char *id) |
344 | { | ||
352 | ENGINE *iterator; | 345 | ENGINE *iterator; |
353 | char *load_dir = NULL; | 346 | char *load_dir = NULL; |
354 | if(id == NULL) | 347 | |
355 | { | 348 | if (id == NULL) { |
356 | ENGINEerr(ENGINE_F_ENGINE_BY_ID, | 349 | ENGINEerr(ENGINE_F_ENGINE_BY_ID, |
357 | ERR_R_PASSED_NULL_PARAMETER); | 350 | ERR_R_PASSED_NULL_PARAMETER); |
358 | return NULL; | 351 | return NULL; |
359 | } | 352 | } |
360 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | 353 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); |
361 | iterator = engine_list_head; | 354 | iterator = engine_list_head; |
362 | while(iterator && (strcmp(id, iterator->id) != 0)) | 355 | while (iterator && (strcmp(id, iterator->id) != 0)) |
363 | iterator = iterator->next; | 356 | iterator = iterator->next; |
364 | if(iterator) | 357 | if (iterator) { |
365 | { | ||
366 | /* We need to return a structural reference. If this is an | 358 | /* We need to return a structural reference. If this is an |
367 | * ENGINE type that returns copies, make a duplicate - otherwise | 359 | * ENGINE type that returns copies, make a duplicate - otherwise |
368 | * increment the existing ENGINE's reference count. */ | 360 | * increment the existing ENGINE's reference count. */ |
369 | if(iterator->flags & ENGINE_FLAGS_BY_ID_COPY) | 361 | if (iterator->flags & ENGINE_FLAGS_BY_ID_COPY) { |
370 | { | ||
371 | ENGINE *cp = ENGINE_new(); | 362 | ENGINE *cp = ENGINE_new(); |
372 | if(!cp) | 363 | if (!cp) |
373 | iterator = NULL; | 364 | iterator = NULL; |
374 | else | 365 | else { |
375 | { | ||
376 | engine_cpy(cp, iterator); | 366 | engine_cpy(cp, iterator); |
377 | iterator = cp; | 367 | iterator = cp; |
378 | } | ||
379 | } | 368 | } |
380 | else | 369 | } else { |
381 | { | ||
382 | iterator->struct_ref++; | 370 | iterator->struct_ref++; |
383 | engine_ref_debug(iterator, 0, 1) | 371 | engine_ref_debug(iterator, 0, 1) |
384 | } | ||
385 | } | 372 | } |
373 | } | ||
386 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | 374 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); |
387 | #if 0 | 375 | #if 0 |
388 | if(iterator == NULL) | 376 | if (iterator == NULL) { |
389 | { | ||
390 | ENGINEerr(ENGINE_F_ENGINE_BY_ID, | 377 | ENGINEerr(ENGINE_F_ENGINE_BY_ID, |
391 | ENGINE_R_NO_SUCH_ENGINE); | 378 | ENGINE_R_NO_SUCH_ENGINE); |
392 | ERR_asprintf_error_data("id=%s", id); | 379 | ERR_asprintf_error_data("id=%s", id); |
393 | } | 380 | } |
394 | return iterator; | 381 | return iterator; |
395 | #else | 382 | #else |
396 | /* EEK! Experimental code starts */ | 383 | /* EEK! Experimental code starts */ |
397 | if(iterator) return iterator; | 384 | if (iterator) |
385 | return iterator; | ||
398 | /* Prevent infinite recusrion if we're looking for the dynamic engine. */ | 386 | /* Prevent infinite recusrion if we're looking for the dynamic engine. */ |
399 | if (strcmp(id, "dynamic")) | 387 | if (strcmp(id, "dynamic")) { |
400 | { | 388 | if ((load_dir = getenv("OPENSSL_ENGINES")) == 0) |
401 | if((load_dir = getenv("OPENSSL_ENGINES")) == 0) load_dir = ENGINESDIR; | 389 | load_dir = ENGINESDIR; |
402 | iterator = ENGINE_by_id("dynamic"); | 390 | iterator = ENGINE_by_id("dynamic"); |
403 | if(!iterator || !ENGINE_ctrl_cmd_string(iterator, "ID", id, 0) || | 391 | if (!iterator || |
404 | !ENGINE_ctrl_cmd_string(iterator, "DIR_LOAD", "2", 0) || | 392 | !ENGINE_ctrl_cmd_string(iterator, "ID", id, 0) || |
405 | !ENGINE_ctrl_cmd_string(iterator, "DIR_ADD", | 393 | !ENGINE_ctrl_cmd_string(iterator, "DIR_LOAD", "2", 0) || |
406 | load_dir, 0) || | 394 | !ENGINE_ctrl_cmd_string(iterator, "DIR_ADD", load_dir, 0) || |
407 | !ENGINE_ctrl_cmd_string(iterator, "LIST_ADD", "1", 0) || | 395 | !ENGINE_ctrl_cmd_string(iterator, "LIST_ADD", "1", 0) || |
408 | !ENGINE_ctrl_cmd_string(iterator, "LOAD", NULL, 0)) | 396 | !ENGINE_ctrl_cmd_string(iterator, "LOAD", NULL, 0)) |
409 | goto notfound; | 397 | goto notfound; |
410 | return iterator; | 398 | return iterator; |
411 | } | 399 | } |
400 | |||
412 | notfound: | 401 | notfound: |
413 | ENGINE_free(iterator); | 402 | ENGINE_free(iterator); |
414 | ENGINEerr(ENGINE_F_ENGINE_BY_ID,ENGINE_R_NO_SUCH_ENGINE); | 403 | ENGINEerr(ENGINE_F_ENGINE_BY_ID, ENGINE_R_NO_SUCH_ENGINE); |
415 | ERR_asprintf_error_data("id=%s", id); | 404 | ERR_asprintf_error_data("id=%s", id); |
416 | return NULL; | 405 | return NULL; |
417 | /* EEK! Experimental code ends */ | 406 | /* EEK! Experimental code ends */ |
418 | #endif | 407 | #endif |
419 | } | 408 | } |
420 | 409 | ||
421 | int ENGINE_up_ref(ENGINE *e) | 410 | int |
422 | { | 411 | ENGINE_up_ref(ENGINE *e) |
423 | if (e == NULL) | 412 | { |
424 | { | 413 | if (e == NULL) { |
425 | ENGINEerr(ENGINE_F_ENGINE_UP_REF,ERR_R_PASSED_NULL_PARAMETER); | 414 | ENGINEerr(ENGINE_F_ENGINE_UP_REF, ERR_R_PASSED_NULL_PARAMETER); |
426 | return 0; | 415 | return 0; |
427 | } | ||
428 | CRYPTO_add(&e->struct_ref,1,CRYPTO_LOCK_ENGINE); | ||
429 | return 1; | ||
430 | } | 416 | } |
417 | CRYPTO_add(&e->struct_ref, 1, CRYPTO_LOCK_ENGINE); | ||
418 | return 1; | ||
419 | } | ||
diff --git a/src/lib/libssl/src/crypto/engine/engine.h b/src/lib/libssl/src/crypto/engine/engine.h index 6dfd0ad6d1..24d2c5eac5 100644 --- a/src/lib/libssl/src/crypto/engine/engine.h +++ b/src/lib/libssl/src/crypto/engine/engine.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: engine.h,v 1.28 2014/06/12 15:49:29 deraadt Exp $ */ | 1 | /* $OpenBSD: engine.h,v 1.29 2014/06/22 12:16:28 jsing Exp $ */ |
2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL | 2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL |
3 | * project 2000. | 3 | * project 2000. |
4 | */ | 4 | */ |
@@ -10,7 +10,7 @@ | |||
10 | * are met: | 10 | * are met: |
11 | * | 11 | * |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * | 14 | * |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
@@ -57,7 +57,7 @@ | |||
57 | */ | 57 | */ |
58 | /* ==================================================================== | 58 | /* ==================================================================== |
59 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 59 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
60 | * ECDH support in OpenSSL originally developed by | 60 | * ECDH support in OpenSSL originally developed by |
61 | * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. | 61 | * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. |
62 | */ | 62 | */ |
63 | 63 | ||
@@ -140,7 +140,7 @@ extern "C" { | |||
140 | * the existing ENGINE's structural reference count. */ | 140 | * the existing ENGINE's structural reference count. */ |
141 | #define ENGINE_FLAGS_BY_ID_COPY (int)0x0004 | 141 | #define ENGINE_FLAGS_BY_ID_COPY (int)0x0004 |
142 | 142 | ||
143 | /* This flag if for an ENGINE that does not want its methods registered as | 143 | /* This flag if for an ENGINE that does not want its methods registered as |
144 | * part of ENGINE_register_all_complete() for example if the methods are | 144 | * part of ENGINE_register_all_complete() for example if the methods are |
145 | * not usable as default methods. | 145 | * not usable as default methods. |
146 | */ | 146 | */ |
@@ -254,26 +254,27 @@ extern "C" { | |||
254 | * array). NB: The array must be ordered in increasing order of cmd_num. | 254 | * array). NB: The array must be ordered in increasing order of cmd_num. |
255 | * "null-terminated" means that the last ENGINE_CMD_DEFN element has cmd_num set | 255 | * "null-terminated" means that the last ENGINE_CMD_DEFN element has cmd_num set |
256 | * to zero and/or cmd_name set to NULL. */ | 256 | * to zero and/or cmd_name set to NULL. */ |
257 | typedef struct ENGINE_CMD_DEFN_st | 257 | typedef struct ENGINE_CMD_DEFN_st { |
258 | { | ||
259 | unsigned int cmd_num; /* The command number */ | 258 | unsigned int cmd_num; /* The command number */ |
260 | const char *cmd_name; /* The command name itself */ | 259 | const char *cmd_name; /* The command name itself */ |
261 | const char *cmd_desc; /* A short description of the command */ | 260 | const char *cmd_desc; /* A short description of the command */ |
262 | unsigned int cmd_flags; /* The input the command expects */ | 261 | unsigned int cmd_flags; /* The input the command expects */ |
263 | } ENGINE_CMD_DEFN; | 262 | } ENGINE_CMD_DEFN; |
264 | 263 | ||
265 | /* Generic function pointer */ | 264 | /* Generic function pointer */ |
266 | typedef int (*ENGINE_GEN_FUNC_PTR)(void); | 265 | typedef int (*ENGINE_GEN_FUNC_PTR)(void); |
267 | /* Generic function pointer taking no arguments */ | 266 | /* Generic function pointer taking no arguments */ |
268 | typedef int (*ENGINE_GEN_INT_FUNC_PTR)(ENGINE *); | 267 | typedef int (*ENGINE_GEN_INT_FUNC_PTR)(ENGINE *); |
269 | /* Specific control function pointer */ | 268 | /* Specific control function pointer */ |
270 | typedef int (*ENGINE_CTRL_FUNC_PTR)(ENGINE *, int, long, void *, void (*f)(void)); | 269 | typedef int (*ENGINE_CTRL_FUNC_PTR)(ENGINE *, int, long, void *, |
270 | void (*f)(void)); | ||
271 | /* Generic load_key function pointer */ | 271 | /* Generic load_key function pointer */ |
272 | typedef EVP_PKEY * (*ENGINE_LOAD_KEY_PTR)(ENGINE *, const char *, | 272 | typedef EVP_PKEY * (*ENGINE_LOAD_KEY_PTR)(ENGINE *, const char *, |
273 | UI_METHOD *ui_method, void *callback_data); | 273 | UI_METHOD *ui_method, void *callback_data); |
274 | typedef int (*ENGINE_SSL_CLIENT_CERT_PTR)(ENGINE *, SSL *ssl, | 274 | typedef int (*ENGINE_SSL_CLIENT_CERT_PTR)(ENGINE *, SSL *ssl, |
275 | STACK_OF(X509_NAME) *ca_dn, X509 **pcert, EVP_PKEY **pkey, | 275 | STACK_OF(X509_NAME) *ca_dn, X509 **pcert, EVP_PKEY **pkey, |
276 | STACK_OF(X509) **pother, UI_METHOD *ui_method, void *callback_data); | 276 | STACK_OF(X509) **pother, UI_METHOD *ui_method, void *callback_data); |
277 | |||
277 | /* These callback types are for an ENGINE's handler for cipher and digest logic. | 278 | /* These callback types are for an ENGINE's handler for cipher and digest logic. |
278 | * These handlers have these prototypes; | 279 | * These handlers have these prototypes; |
279 | * int foo(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid); | 280 | * int foo(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid); |
@@ -286,10 +287,14 @@ typedef int (*ENGINE_SSL_CLIENT_CERT_PTR)(ENGINE *, SSL *ssl, | |||
286 | */ | 287 | */ |
287 | /* Returns to a pointer to the array of supported cipher 'nid's. If the second | 288 | /* Returns to a pointer to the array of supported cipher 'nid's. If the second |
288 | * parameter is non-NULL it is set to the size of the returned array. */ | 289 | * parameter is non-NULL it is set to the size of the returned array. */ |
289 | typedef int (*ENGINE_CIPHERS_PTR)(ENGINE *, const EVP_CIPHER **, const int **, int); | 290 | typedef int (*ENGINE_CIPHERS_PTR)(ENGINE *, const EVP_CIPHER **, |
291 | const int **, int); | ||
290 | typedef int (*ENGINE_DIGESTS_PTR)(ENGINE *, const EVP_MD **, const int **, int); | 292 | typedef int (*ENGINE_DIGESTS_PTR)(ENGINE *, const EVP_MD **, const int **, int); |
291 | typedef int (*ENGINE_PKEY_METHS_PTR)(ENGINE *, EVP_PKEY_METHOD **, const int **, int); | 293 | typedef int (*ENGINE_PKEY_METHS_PTR)(ENGINE *, EVP_PKEY_METHOD **, |
292 | typedef int (*ENGINE_PKEY_ASN1_METHS_PTR)(ENGINE *, EVP_PKEY_ASN1_METHOD **, const int **, int); | 294 | const int **, int); |
295 | typedef int (*ENGINE_PKEY_ASN1_METHS_PTR)(ENGINE *, EVP_PKEY_ASN1_METHOD **, | ||
296 | const int **, int); | ||
297 | |||
293 | /* STRUCTURE functions ... all of these functions deal with pointers to ENGINE | 298 | /* STRUCTURE functions ... all of these functions deal with pointers to ENGINE |
294 | * structures where the pointers have a "structural reference". This means that | 299 | * structures where the pointers have a "structural reference". This means that |
295 | * their reference is to allowed access to the structure but it does not imply | 300 | * their reference is to allowed access to the structure but it does not imply |
@@ -405,7 +410,7 @@ int ENGINE_cmd_is_executable(ENGINE *e, int cmd); | |||
405 | * See the comment on ENGINE_ctrl_cmd_string() for an explanation on how to | 410 | * See the comment on ENGINE_ctrl_cmd_string() for an explanation on how to |
406 | * use the cmd_name and cmd_optional. */ | 411 | * use the cmd_name and cmd_optional. */ |
407 | int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name, | 412 | int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name, |
408 | long i, void *p, void (*f)(void), int cmd_optional); | 413 | long i, void *p, void (*f)(void), int cmd_optional); |
409 | 414 | ||
410 | /* This function passes a command-name and argument to an ENGINE. The cmd_name | 415 | /* This function passes a command-name and argument to an ENGINE. The cmd_name |
411 | * is converted to a command number and the control command is called using | 416 | * is converted to a command number and the control command is called using |
@@ -427,7 +432,7 @@ int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name, | |||
427 | * compliant ENGINE-based applications can work consistently with the same | 432 | * compliant ENGINE-based applications can work consistently with the same |
428 | * configuration for the same ENGINE-enabled devices, across applications. */ | 433 | * configuration for the same ENGINE-enabled devices, across applications. */ |
429 | int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg, | 434 | int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg, |
430 | int cmd_optional); | 435 | int cmd_optional); |
431 | 436 | ||
432 | /* These functions are useful for manufacturing new ENGINE structures. They | 437 | /* These functions are useful for manufacturing new ENGINE structures. They |
433 | * don't address reference counting at all - one uses them to populate an ENGINE | 438 | * don't address reference counting at all - one uses them to populate an ENGINE |
@@ -454,7 +459,7 @@ int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f); | |||
454 | int ENGINE_set_load_privkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpriv_f); | 459 | int ENGINE_set_load_privkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpriv_f); |
455 | int ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f); | 460 | int ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f); |
456 | int ENGINE_set_load_ssl_client_cert_function(ENGINE *e, | 461 | int ENGINE_set_load_ssl_client_cert_function(ENGINE *e, |
457 | ENGINE_SSL_CLIENT_CERT_PTR loadssl_f); | 462 | ENGINE_SSL_CLIENT_CERT_PTR loadssl_f); |
458 | int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f); | 463 | int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f); |
459 | int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f); | 464 | int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f); |
460 | int ENGINE_set_pkey_meths(ENGINE *e, ENGINE_PKEY_METHS_PTR f); | 465 | int ENGINE_set_pkey_meths(ENGINE *e, ENGINE_PKEY_METHS_PTR f); |
@@ -463,7 +468,7 @@ int ENGINE_set_flags(ENGINE *e, int flags); | |||
463 | int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns); | 468 | int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns); |
464 | /* These functions allow control over any per-structure ENGINE data. */ | 469 | /* These functions allow control over any per-structure ENGINE data. */ |
465 | int ENGINE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, | 470 | int ENGINE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, |
466 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); | 471 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); |
467 | int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg); | 472 | int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg); |
468 | void *ENGINE_get_ex_data(const ENGINE *e, int idx); | 473 | void *ENGINE_get_ex_data(const ENGINE *e, int idx); |
469 | 474 | ||
@@ -502,9 +507,9 @@ const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid); | |||
502 | const EVP_PKEY_METHOD *ENGINE_get_pkey_meth(ENGINE *e, int nid); | 507 | const EVP_PKEY_METHOD *ENGINE_get_pkey_meth(ENGINE *e, int nid); |
503 | const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth(ENGINE *e, int nid); | 508 | const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth(ENGINE *e, int nid); |
504 | const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth_str(ENGINE *e, | 509 | const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth_str(ENGINE *e, |
505 | const char *str, int len); | 510 | const char *str, int len); |
506 | const EVP_PKEY_ASN1_METHOD *ENGINE_pkey_asn1_find_str(ENGINE **pe, | 511 | const EVP_PKEY_ASN1_METHOD *ENGINE_pkey_asn1_find_str(ENGINE **pe, |
507 | const char *str, int len); | 512 | const char *str, int len); |
508 | const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e); | 513 | const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e); |
509 | int ENGINE_get_flags(const ENGINE *e); | 514 | int ENGINE_get_flags(const ENGINE *e); |
510 | 515 | ||
@@ -533,13 +538,13 @@ int ENGINE_finish(ENGINE *e); | |||
533 | * location, handled by the engine. The storage may be on a card or | 538 | * location, handled by the engine. The storage may be on a card or |
534 | * whatever. */ | 539 | * whatever. */ |
535 | EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id, | 540 | EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id, |
536 | UI_METHOD *ui_method, void *callback_data); | 541 | UI_METHOD *ui_method, void *callback_data); |
537 | EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id, | 542 | EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id, |
538 | UI_METHOD *ui_method, void *callback_data); | 543 | UI_METHOD *ui_method, void *callback_data); |
539 | int ENGINE_load_ssl_client_cert(ENGINE *e, SSL *s, | 544 | int ENGINE_load_ssl_client_cert(ENGINE *e, SSL *s, |
540 | STACK_OF(X509_NAME) *ca_dn, X509 **pcert, EVP_PKEY **ppkey, | 545 | STACK_OF(X509_NAME) *ca_dn, X509 **pcert, EVP_PKEY **ppkey, |
541 | STACK_OF(X509) **pother, | 546 | STACK_OF(X509) **pother, |
542 | UI_METHOD *ui_method, void *callback_data); | 547 | UI_METHOD *ui_method, void *callback_data); |
543 | 548 | ||
544 | /* This returns a pointer for the current ENGINE structure that | 549 | /* This returns a pointer for the current ENGINE structure that |
545 | * is (by default) performing any RSA operations. The value returned | 550 | * is (by default) performing any RSA operations. The value returned |
@@ -614,24 +619,24 @@ typedef struct st_dynamic_MEM_fns { | |||
614 | dyn_MEM_malloc_cb malloc_cb; | 619 | dyn_MEM_malloc_cb malloc_cb; |
615 | dyn_MEM_realloc_cb realloc_cb; | 620 | dyn_MEM_realloc_cb realloc_cb; |
616 | dyn_MEM_free_cb free_cb; | 621 | dyn_MEM_free_cb free_cb; |
617 | } dynamic_MEM_fns; | 622 | } dynamic_MEM_fns; |
618 | /* FIXME: Perhaps the memory and locking code (crypto.h) should declare and use | 623 | /* FIXME: Perhaps the memory and locking code (crypto.h) should declare and use |
619 | * these types so we (and any other dependant code) can simplify a bit?? */ | 624 | * these types so we (and any other dependant code) can simplify a bit?? */ |
620 | typedef void (*dyn_lock_locking_cb)(int,int,const char *,int); | 625 | typedef void (*dyn_lock_locking_cb)(int, int, const char *, int); |
621 | typedef int (*dyn_lock_add_lock_cb)(int*,int,int,const char *,int); | 626 | typedef int (*dyn_lock_add_lock_cb)(int*, int, int, const char *, int); |
622 | typedef struct CRYPTO_dynlock_value *(*dyn_dynlock_create_cb)( | 627 | typedef struct CRYPTO_dynlock_value *(*dyn_dynlock_create_cb)( |
623 | const char *,int); | 628 | const char *, int); |
624 | typedef void (*dyn_dynlock_lock_cb)(int,struct CRYPTO_dynlock_value *, | 629 | typedef void (*dyn_dynlock_lock_cb)(int, struct CRYPTO_dynlock_value *, |
625 | const char *,int); | 630 | const char *, int); |
626 | typedef void (*dyn_dynlock_destroy_cb)(struct CRYPTO_dynlock_value *, | 631 | typedef void (*dyn_dynlock_destroy_cb)(struct CRYPTO_dynlock_value *, |
627 | const char *,int); | 632 | const char *, int); |
628 | typedef struct st_dynamic_LOCK_fns { | 633 | typedef struct st_dynamic_LOCK_fns { |
629 | dyn_lock_locking_cb lock_locking_cb; | 634 | dyn_lock_locking_cb lock_locking_cb; |
630 | dyn_lock_add_lock_cb lock_add_lock_cb; | 635 | dyn_lock_add_lock_cb lock_add_lock_cb; |
631 | dyn_dynlock_create_cb dynlock_create_cb; | 636 | dyn_dynlock_create_cb dynlock_create_cb; |
632 | dyn_dynlock_lock_cb dynlock_lock_cb; | 637 | dyn_dynlock_lock_cb dynlock_lock_cb; |
633 | dyn_dynlock_destroy_cb dynlock_destroy_cb; | 638 | dyn_dynlock_destroy_cb dynlock_destroy_cb; |
634 | } dynamic_LOCK_fns; | 639 | } dynamic_LOCK_fns; |
635 | /* The top-level structure */ | 640 | /* The top-level structure */ |
636 | typedef struct st_dynamic_fns { | 641 | typedef struct st_dynamic_fns { |
637 | void *static_state; | 642 | void *static_state; |
@@ -639,7 +644,7 @@ typedef struct st_dynamic_fns { | |||
639 | const CRYPTO_EX_DATA_IMPL *ex_data_fns; | 644 | const CRYPTO_EX_DATA_IMPL *ex_data_fns; |
640 | dynamic_MEM_fns mem_fns; | 645 | dynamic_MEM_fns mem_fns; |
641 | dynamic_LOCK_fns lock_fns; | 646 | dynamic_LOCK_fns lock_fns; |
642 | } dynamic_fns; | 647 | } dynamic_fns; |
643 | 648 | ||
644 | /* The version checking function should be of this prototype. NB: The | 649 | /* The version checking function should be of this prototype. NB: The |
645 | * ossl_version value passed in is the OSSL_DYNAMIC_VERSION of the loading code. | 650 | * ossl_version value passed in is the OSSL_DYNAMIC_VERSION of the loading code. |
@@ -673,7 +678,7 @@ typedef unsigned long (*dynamic_v_check_fn)(unsigned long ossl_version); | |||
673 | * and returns an int value (zero for failure). 'fn' should have prototype; | 678 | * and returns an int value (zero for failure). 'fn' should have prototype; |
674 | * [static] int fn(ENGINE *e, const char *id); */ | 679 | * [static] int fn(ENGINE *e, const char *id); */ |
675 | typedef int (*dynamic_bind_engine)(ENGINE *e, const char *id, | 680 | typedef int (*dynamic_bind_engine)(ENGINE *e, const char *id, |
676 | const dynamic_fns *fns); | 681 | const dynamic_fns *fns); |
677 | #define IMPLEMENT_DYNAMIC_BIND_FN(fn) \ | 682 | #define IMPLEMENT_DYNAMIC_BIND_FN(fn) \ |
678 | extern \ | 683 | extern \ |
679 | int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns); \ | 684 | int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns); \ |
@@ -704,7 +709,7 @@ typedef int (*dynamic_bind_engine)(ENGINE *e, const char *id, | |||
704 | * detect this is to have a function that returns a pointer to some static data | 709 | * detect this is to have a function that returns a pointer to some static data |
705 | * and let the loading application and loaded ENGINE compare their respective | 710 | * and let the loading application and loaded ENGINE compare their respective |
706 | * values. */ | 711 | * values. */ |
707 | void *ENGINE_get_static_state(void); | 712 | void *ENGINE_get_static_state(void); |
708 | 713 | ||
709 | /* BEGIN ERROR CODES */ | 714 | /* BEGIN ERROR CODES */ |
710 | /* The following lines are auto generated by the script mkerr.pl. Any changes | 715 | /* The following lines are auto generated by the script mkerr.pl. Any changes |