diff options
Diffstat (limited to 'src/lib/libcrypto/engine/engine_lib.c')
-rw-r--r-- | src/lib/libcrypto/engine/engine_lib.c | 489 |
1 files changed, 0 insertions, 489 deletions
diff --git a/src/lib/libcrypto/engine/engine_lib.c b/src/lib/libcrypto/engine/engine_lib.c deleted file mode 100644 index d6e9109f6e..0000000000 --- a/src/lib/libcrypto/engine/engine_lib.c +++ /dev/null | |||
@@ -1,489 +0,0 @@ | |||
1 | /* crypto/engine/engine_lib.c */ | ||
2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL | ||
3 | * project 2000. | ||
4 | */ | ||
5 | /* ==================================================================== | ||
6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * | ||
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer. | ||
14 | * | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in | ||
17 | * the documentation and/or other materials provided with the | ||
18 | * distribution. | ||
19 | * | ||
20 | * 3. All advertising materials mentioning features or use of this | ||
21 | * software must display the following acknowledgment: | ||
22 | * "This product includes software developed by the OpenSSL Project | ||
23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
24 | * | ||
25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
26 | * endorse or promote products derived from this software without | ||
27 | * prior written permission. For written permission, please contact | ||
28 | * licensing@OpenSSL.org. | ||
29 | * | ||
30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
31 | * nor may "OpenSSL" appear in their names without prior written | ||
32 | * permission of the OpenSSL Project. | ||
33 | * | ||
34 | * 6. Redistributions of any form whatsoever must retain the following | ||
35 | * acknowledgment: | ||
36 | * "This product includes software developed by the OpenSSL Project | ||
37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
38 | * | ||
39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
51 | * ==================================================================== | ||
52 | * | ||
53 | * This product includes cryptographic software written by Eric Young | ||
54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
55 | * Hudson (tjh@cryptsoft.com). | ||
56 | * | ||
57 | */ | ||
58 | |||
59 | #include <openssl/crypto.h> | ||
60 | #include "cryptlib.h" | ||
61 | #include "engine_int.h" | ||
62 | #include <openssl/engine.h> | ||
63 | |||
64 | /* These pointers each have their own "functional reference" when they | ||
65 | * are non-NULL. Similarly, when they are retrieved by a call to | ||
66 | * ENGINE_get_default_[RSA|DSA|...] the returned pointer is also a | ||
67 | * reference and the caller is responsible for freeing that when they | ||
68 | * are finished with it (with a call to ENGINE_finish() *NOT* just | ||
69 | * ENGINE_free()!!!!!!). */ | ||
70 | static ENGINE *engine_def_rsa = NULL; | ||
71 | static ENGINE *engine_def_dsa = NULL; | ||
72 | static ENGINE *engine_def_dh = NULL; | ||
73 | static ENGINE *engine_def_rand = NULL; | ||
74 | static ENGINE *engine_def_bn_mod_exp = NULL; | ||
75 | static ENGINE *engine_def_bn_mod_exp_crt = NULL; | ||
76 | /* A static "once-only" flag used to control if/when the above were | ||
77 | * initialised to suitable start-up defaults. */ | ||
78 | static int engine_def_flag = 0; | ||
79 | |||
80 | /* This is used in certain static utility functions to save code | ||
81 | * repetition for per-algorithm functions. */ | ||
82 | typedef enum { | ||
83 | ENGINE_TYPE_RSA, | ||
84 | ENGINE_TYPE_DSA, | ||
85 | ENGINE_TYPE_DH, | ||
86 | ENGINE_TYPE_RAND, | ||
87 | ENGINE_TYPE_BN_MOD_EXP, | ||
88 | ENGINE_TYPE_BN_MOD_EXP_CRT | ||
89 | } ENGINE_TYPE; | ||
90 | |||
91 | static void engine_def_check_util(ENGINE **def, ENGINE *val) | ||
92 | { | ||
93 | *def = val; | ||
94 | val->struct_ref++; | ||
95 | val->funct_ref++; | ||
96 | } | ||
97 | |||
98 | /* In a slight break with convention - this static function must be | ||
99 | * called *outside* any locking of CRYPTO_LOCK_ENGINE. */ | ||
100 | static void engine_def_check(void) | ||
101 | { | ||
102 | ENGINE *e; | ||
103 | if(engine_def_flag) | ||
104 | return; | ||
105 | e = ENGINE_get_first(); | ||
106 | if(e == NULL) | ||
107 | /* The list is empty ... not much we can do! */ | ||
108 | return; | ||
109 | /* We have a structural reference, see if getting a functional | ||
110 | * reference is possible. This is done to cope with init errors | ||
111 | * in the engine - the following locked code does a bunch of | ||
112 | * manual "ENGINE_init"s which do *not* allow such an init | ||
113 | * error so this is worth doing. */ | ||
114 | if(ENGINE_init(e)) | ||
115 | { | ||
116 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | ||
117 | /* Doing another check here prevents an obvious race | ||
118 | * condition because the whole function itself cannot | ||
119 | * be locked. */ | ||
120 | if(engine_def_flag) | ||
121 | goto skip_set_defaults; | ||
122 | /* OK, we got a functional reference, so we get one each | ||
123 | * for the defaults too. */ | ||
124 | engine_def_check_util(&engine_def_rsa, e); | ||
125 | engine_def_check_util(&engine_def_dsa, e); | ||
126 | engine_def_check_util(&engine_def_dh, e); | ||
127 | engine_def_check_util(&engine_def_rand, e); | ||
128 | engine_def_check_util(&engine_def_bn_mod_exp, e); | ||
129 | engine_def_check_util(&engine_def_bn_mod_exp_crt, e); | ||
130 | engine_def_flag = 1; | ||
131 | skip_set_defaults: | ||
132 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | ||
133 | /* The "if" needs to be balanced out. */ | ||
134 | ENGINE_finish(e); | ||
135 | } | ||
136 | /* We need to balance out the fact we obtained a structural | ||
137 | * reference to begin with from ENGINE_get_first(). */ | ||
138 | ENGINE_free(e); | ||
139 | } | ||
140 | |||
141 | /* Initialise a engine type for use (or up its functional reference count | ||
142 | * if it's already in use). */ | ||
143 | int ENGINE_init(ENGINE *e) | ||
144 | { | ||
145 | int to_return = 1; | ||
146 | |||
147 | if(e == NULL) | ||
148 | { | ||
149 | ENGINEerr(ENGINE_F_ENGINE_INIT,ERR_R_PASSED_NULL_PARAMETER); | ||
150 | return 0; | ||
151 | } | ||
152 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | ||
153 | if((e->funct_ref == 0) && e->init) | ||
154 | /* This is the first functional reference and the engine | ||
155 | * requires initialisation so we do it now. */ | ||
156 | to_return = e->init(); | ||
157 | if(to_return) | ||
158 | { | ||
159 | /* OK, we return a functional reference which is also a | ||
160 | * structural reference. */ | ||
161 | e->struct_ref++; | ||
162 | e->funct_ref++; | ||
163 | } | ||
164 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | ||
165 | return to_return; | ||
166 | } | ||
167 | |||
168 | /* Free a functional reference to a engine type */ | ||
169 | int ENGINE_finish(ENGINE *e) | ||
170 | { | ||
171 | int to_return = 1; | ||
172 | |||
173 | if(e == NULL) | ||
174 | { | ||
175 | ENGINEerr(ENGINE_F_ENGINE_FINISH,ERR_R_PASSED_NULL_PARAMETER); | ||
176 | return 0; | ||
177 | } | ||
178 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | ||
179 | if((e->funct_ref == 1) && e->finish) | ||
180 | #if 0 | ||
181 | /* This is the last functional reference and the engine | ||
182 | * requires cleanup so we do it now. */ | ||
183 | to_return = e->finish(); | ||
184 | if(to_return) | ||
185 | { | ||
186 | /* Cleanup the functional reference which is also a | ||
187 | * structural reference. */ | ||
188 | e->struct_ref--; | ||
189 | e->funct_ref--; | ||
190 | } | ||
191 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | ||
192 | #else | ||
193 | /* I'm going to deliberately do a convoluted version of this | ||
194 | * piece of code because we don't want "finish" functions | ||
195 | * being called inside a locked block of code, if at all | ||
196 | * possible. I'd rather have this call take an extra couple | ||
197 | * of ticks than have throughput serialised on a externally- | ||
198 | * provided callback function that may conceivably never come | ||
199 | * back. :-( */ | ||
200 | { | ||
201 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | ||
202 | /* CODE ALERT: This *IS* supposed to be "=" and NOT "==" :-) */ | ||
203 | if((to_return = e->finish())) | ||
204 | { | ||
205 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | ||
206 | /* Cleanup the functional reference which is also a | ||
207 | * structural reference. */ | ||
208 | e->struct_ref--; | ||
209 | e->funct_ref--; | ||
210 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | ||
211 | } | ||
212 | } | ||
213 | else | ||
214 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | ||
215 | #endif | ||
216 | return to_return; | ||
217 | } | ||
218 | |||
219 | EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id, | ||
220 | const char *passphrase) | ||
221 | { | ||
222 | EVP_PKEY *pkey; | ||
223 | |||
224 | if(e == NULL) | ||
225 | { | ||
226 | ENGINEerr(ENGINE_F_ENGINE_LOAD_PRIVATE_KEY, | ||
227 | ERR_R_PASSED_NULL_PARAMETER); | ||
228 | return 0; | ||
229 | } | ||
230 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | ||
231 | if(e->funct_ref == 0) | ||
232 | { | ||
233 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | ||
234 | ENGINEerr(ENGINE_F_ENGINE_LOAD_PRIVATE_KEY, | ||
235 | ENGINE_R_NOT_INITIALISED); | ||
236 | return 0; | ||
237 | } | ||
238 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | ||
239 | if (!e->load_privkey) | ||
240 | { | ||
241 | ENGINEerr(ENGINE_F_ENGINE_LOAD_PRIVATE_KEY, | ||
242 | ENGINE_R_NO_LOAD_FUNCTION); | ||
243 | return 0; | ||
244 | } | ||
245 | pkey = e->load_privkey(key_id, passphrase); | ||
246 | if (!pkey) | ||
247 | { | ||
248 | ENGINEerr(ENGINE_F_ENGINE_LOAD_PRIVATE_KEY, | ||
249 | ENGINE_R_FAILED_LOADING_PRIVATE_KEY); | ||
250 | return 0; | ||
251 | } | ||
252 | return pkey; | ||
253 | } | ||
254 | |||
255 | EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id, | ||
256 | const char *passphrase) | ||
257 | { | ||
258 | EVP_PKEY *pkey; | ||
259 | |||
260 | if(e == NULL) | ||
261 | { | ||
262 | ENGINEerr(ENGINE_F_ENGINE_LOAD_PUBLIC_KEY, | ||
263 | ERR_R_PASSED_NULL_PARAMETER); | ||
264 | return 0; | ||
265 | } | ||
266 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | ||
267 | if(e->funct_ref == 0) | ||
268 | { | ||
269 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | ||
270 | ENGINEerr(ENGINE_F_ENGINE_LOAD_PUBLIC_KEY, | ||
271 | ENGINE_R_NOT_INITIALISED); | ||
272 | return 0; | ||
273 | } | ||
274 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | ||
275 | if (!e->load_pubkey) | ||
276 | { | ||
277 | ENGINEerr(ENGINE_F_ENGINE_LOAD_PUBLIC_KEY, | ||
278 | ENGINE_R_NO_LOAD_FUNCTION); | ||
279 | return 0; | ||
280 | } | ||
281 | pkey = e->load_pubkey(key_id, passphrase); | ||
282 | if (!pkey) | ||
283 | { | ||
284 | ENGINEerr(ENGINE_F_ENGINE_LOAD_PUBLIC_KEY, | ||
285 | ENGINE_R_FAILED_LOADING_PUBLIC_KEY); | ||
286 | return 0; | ||
287 | } | ||
288 | return pkey; | ||
289 | } | ||
290 | |||
291 | int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)()) | ||
292 | { | ||
293 | if(e == NULL) | ||
294 | { | ||
295 | ENGINEerr(ENGINE_F_ENGINE_CTRL,ERR_R_PASSED_NULL_PARAMETER); | ||
296 | return 0; | ||
297 | } | ||
298 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | ||
299 | if(e->struct_ref == 0) | ||
300 | { | ||
301 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | ||
302 | ENGINEerr(ENGINE_F_ENGINE_CTRL,ENGINE_R_NO_REFERENCE); | ||
303 | return 0; | ||
304 | } | ||
305 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | ||
306 | if (!e->ctrl) | ||
307 | { | ||
308 | ENGINEerr(ENGINE_F_ENGINE_CTRL,ENGINE_R_NO_CONTROL_FUNCTION); | ||
309 | return 0; | ||
310 | } | ||
311 | return e->ctrl(cmd, i, p, f); | ||
312 | } | ||
313 | |||
314 | static ENGINE *engine_get_default_type(ENGINE_TYPE t) | ||
315 | { | ||
316 | ENGINE *ret = NULL; | ||
317 | |||
318 | /* engine_def_check is lean and mean and won't replace any | ||
319 | * prior default engines ... so we must ensure that it is always | ||
320 | * the first function to get to touch the default values. */ | ||
321 | engine_def_check(); | ||
322 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | ||
323 | switch(t) | ||
324 | { | ||
325 | case ENGINE_TYPE_RSA: | ||
326 | ret = engine_def_rsa; break; | ||
327 | case ENGINE_TYPE_DSA: | ||
328 | ret = engine_def_dsa; break; | ||
329 | case ENGINE_TYPE_DH: | ||
330 | ret = engine_def_dh; break; | ||
331 | case ENGINE_TYPE_RAND: | ||
332 | ret = engine_def_rand; break; | ||
333 | case ENGINE_TYPE_BN_MOD_EXP: | ||
334 | ret = engine_def_bn_mod_exp; break; | ||
335 | case ENGINE_TYPE_BN_MOD_EXP_CRT: | ||
336 | ret = engine_def_bn_mod_exp_crt; break; | ||
337 | } | ||
338 | /* Unforunately we can't do this work outside the lock with a | ||
339 | * call to ENGINE_init() because that would leave a race | ||
340 | * condition open. */ | ||
341 | if(ret) | ||
342 | { | ||
343 | ret->struct_ref++; | ||
344 | ret->funct_ref++; | ||
345 | } | ||
346 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | ||
347 | return ret; | ||
348 | } | ||
349 | |||
350 | ENGINE *ENGINE_get_default_RSA(void) | ||
351 | { | ||
352 | return engine_get_default_type(ENGINE_TYPE_RSA); | ||
353 | } | ||
354 | |||
355 | ENGINE *ENGINE_get_default_DSA(void) | ||
356 | { | ||
357 | return engine_get_default_type(ENGINE_TYPE_DSA); | ||
358 | } | ||
359 | |||
360 | ENGINE *ENGINE_get_default_DH(void) | ||
361 | { | ||
362 | return engine_get_default_type(ENGINE_TYPE_DH); | ||
363 | } | ||
364 | |||
365 | ENGINE *ENGINE_get_default_RAND(void) | ||
366 | { | ||
367 | return engine_get_default_type(ENGINE_TYPE_RAND); | ||
368 | } | ||
369 | |||
370 | ENGINE *ENGINE_get_default_BN_mod_exp(void) | ||
371 | { | ||
372 | return engine_get_default_type(ENGINE_TYPE_BN_MOD_EXP); | ||
373 | } | ||
374 | |||
375 | ENGINE *ENGINE_get_default_BN_mod_exp_crt(void) | ||
376 | { | ||
377 | return engine_get_default_type(ENGINE_TYPE_BN_MOD_EXP_CRT); | ||
378 | } | ||
379 | |||
380 | static int engine_set_default_type(ENGINE_TYPE t, ENGINE *e) | ||
381 | { | ||
382 | ENGINE *old = NULL; | ||
383 | |||
384 | if(e == NULL) | ||
385 | { | ||
386 | ENGINEerr(ENGINE_F_ENGINE_SET_DEFAULT_TYPE, | ||
387 | ERR_R_PASSED_NULL_PARAMETER); | ||
388 | return 0; | ||
389 | } | ||
390 | /* engine_def_check is lean and mean and won't replace any | ||
391 | * prior default engines ... so we must ensure that it is always | ||
392 | * the first function to get to touch the default values. */ | ||
393 | engine_def_check(); | ||
394 | /* Attempt to get a functional reference (we need one anyway, but | ||
395 | * also, 'e' may be just a structural reference being passed in so | ||
396 | * this call may actually be the first). */ | ||
397 | if(!ENGINE_init(e)) | ||
398 | { | ||
399 | ENGINEerr(ENGINE_F_ENGINE_SET_DEFAULT_TYPE, | ||
400 | ENGINE_R_INIT_FAILED); | ||
401 | return 0; | ||
402 | } | ||
403 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | ||
404 | switch(t) | ||
405 | { | ||
406 | case ENGINE_TYPE_RSA: | ||
407 | old = engine_def_rsa; | ||
408 | engine_def_rsa = e; break; | ||
409 | case ENGINE_TYPE_DSA: | ||
410 | old = engine_def_dsa; | ||
411 | engine_def_dsa = e; break; | ||
412 | case ENGINE_TYPE_DH: | ||
413 | old = engine_def_dh; | ||
414 | engine_def_dh = e; break; | ||
415 | case ENGINE_TYPE_RAND: | ||
416 | old = engine_def_rand; | ||
417 | engine_def_rand = e; break; | ||
418 | case ENGINE_TYPE_BN_MOD_EXP: | ||
419 | old = engine_def_bn_mod_exp; | ||
420 | engine_def_bn_mod_exp = e; break; | ||
421 | case ENGINE_TYPE_BN_MOD_EXP_CRT: | ||
422 | old = engine_def_bn_mod_exp_crt; | ||
423 | engine_def_bn_mod_exp_crt = e; break; | ||
424 | } | ||
425 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | ||
426 | /* If we've replaced a previous value, then we need to remove the | ||
427 | * functional reference we had. */ | ||
428 | if(old && !ENGINE_finish(old)) | ||
429 | { | ||
430 | ENGINEerr(ENGINE_F_ENGINE_SET_DEFAULT_TYPE, | ||
431 | ENGINE_R_FINISH_FAILED); | ||
432 | return 0; | ||
433 | } | ||
434 | return 1; | ||
435 | } | ||
436 | |||
437 | int ENGINE_set_default_RSA(ENGINE *e) | ||
438 | { | ||
439 | return engine_set_default_type(ENGINE_TYPE_RSA, e); | ||
440 | } | ||
441 | |||
442 | int ENGINE_set_default_DSA(ENGINE *e) | ||
443 | { | ||
444 | return engine_set_default_type(ENGINE_TYPE_DSA, e); | ||
445 | } | ||
446 | |||
447 | int ENGINE_set_default_DH(ENGINE *e) | ||
448 | { | ||
449 | return engine_set_default_type(ENGINE_TYPE_DH, e); | ||
450 | } | ||
451 | |||
452 | int ENGINE_set_default_RAND(ENGINE *e) | ||
453 | { | ||
454 | return engine_set_default_type(ENGINE_TYPE_RAND, e); | ||
455 | } | ||
456 | |||
457 | int ENGINE_set_default_BN_mod_exp(ENGINE *e) | ||
458 | { | ||
459 | return engine_set_default_type(ENGINE_TYPE_BN_MOD_EXP, e); | ||
460 | } | ||
461 | |||
462 | int ENGINE_set_default_BN_mod_exp_crt(ENGINE *e) | ||
463 | { | ||
464 | return engine_set_default_type(ENGINE_TYPE_BN_MOD_EXP_CRT, e); | ||
465 | } | ||
466 | |||
467 | int ENGINE_set_default(ENGINE *e, unsigned int flags) | ||
468 | { | ||
469 | if((flags & ENGINE_METHOD_RSA) && e->rsa_meth && | ||
470 | !ENGINE_set_default_RSA(e)) | ||
471 | return 0; | ||
472 | if((flags & ENGINE_METHOD_DSA) && e->dsa_meth && | ||
473 | !ENGINE_set_default_DSA(e)) | ||
474 | return 0; | ||
475 | if((flags & ENGINE_METHOD_DH) && e->dh_meth && | ||
476 | !ENGINE_set_default_DH(e)) | ||
477 | return 0; | ||
478 | if((flags & ENGINE_METHOD_RAND) && e->rand_meth && | ||
479 | !ENGINE_set_default_RAND(e)) | ||
480 | return 0; | ||
481 | if((flags & ENGINE_METHOD_BN_MOD_EXP) && e->bn_mod_exp && | ||
482 | !ENGINE_set_default_BN_mod_exp(e)) | ||
483 | return 0; | ||
484 | if((flags & ENGINE_METHOD_BN_MOD_EXP_CRT) && e->bn_mod_exp_crt && | ||
485 | !ENGINE_set_default_BN_mod_exp_crt(e)) | ||
486 | return 0; | ||
487 | return 1; | ||
488 | } | ||
489 | |||