]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/engine/eng_list.c
Fix a typo in the preprocessor logic in eng_list.c that had left RSA, DSA,
[thirdparty/openssl.git] / crypto / engine / eng_list.c
CommitLineData
5270e702
RL
1/* crypto/engine/engine_list.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"
14cfde9c 61#include "eng_int.h"
5270e702
RL
62#include <openssl/engine.h>
63
64/* The linked-list of pointers to engine types. engine_list_head
65 * incorporates an implicit structural reference but engine_list_tail
66 * does not - the latter is a computational niceity and only points
67 * to something that is already pointed to by its predecessor in the
68 * list (or engine_list_head itself). In the same way, the use of the
69 * "prev" pointer in each ENGINE is to save excessive list iteration,
70 * it doesn't correspond to an extra structural reference. Hence,
71 * engine_list_head, and each non-null "next" pointer account for
72 * the list itself assuming exactly 1 structural reference on each
73 * list member. */
74static ENGINE *engine_list_head = NULL;
75static ENGINE *engine_list_tail = NULL;
76/* A boolean switch, used to ensure we only initialise once. This
77 * is needed because the engine list may genuinely become empty during
78 * use (so we can't use engine_list_head as an indicator for example. */
79static int engine_list_flag = 0;
79aa04ef 80static int ENGINE_free_util(ENGINE *e, int locked);
5270e702
RL
81
82/* These static functions starting with a lower case "engine_" always
83 * take place when CRYPTO_LOCK_ENGINE has been locked up. */
84static int engine_list_add(ENGINE *e)
85 {
86 int conflict = 0;
87 ENGINE *iterator = NULL;
88
89 if(e == NULL)
90 {
91 ENGINEerr(ENGINE_F_ENGINE_LIST_ADD,
92 ERR_R_PASSED_NULL_PARAMETER);
93 return 0;
94 }
95 iterator = engine_list_head;
96 while(iterator && !conflict)
97 {
98 conflict = (strcmp(iterator->id, e->id) == 0);
99 iterator = iterator->next;
100 }
101 if(conflict)
102 {
103 ENGINEerr(ENGINE_F_ENGINE_LIST_ADD,
104 ENGINE_R_CONFLICTING_ENGINE_ID);
105 return 0;
106 }
107 if(engine_list_head == NULL)
108 {
109 /* We are adding to an empty list. */
110 if(engine_list_tail)
111 {
112 ENGINEerr(ENGINE_F_ENGINE_LIST_ADD,
113 ENGINE_R_INTERNAL_LIST_ERROR);
114 return 0;
115 }
116 engine_list_head = e;
117 e->prev = NULL;
118 }
119 else
120 {
121 /* We are adding to the tail of an existing list. */
122 if((engine_list_tail == NULL) ||
123 (engine_list_tail->next != NULL))
124 {
125 ENGINEerr(ENGINE_F_ENGINE_LIST_ADD,
126 ENGINE_R_INTERNAL_LIST_ERROR);
127 return 0;
128 }
129 engine_list_tail->next = e;
130 e->prev = engine_list_tail;
131 }
132 /* Having the engine in the list assumes a structural
133 * reference. */
134 e->struct_ref++;
b41f836e 135 engine_ref_debug(e, 0, 1)
5270e702
RL
136 /* However it came to be, e is the last item in the list. */
137 engine_list_tail = e;
138 e->next = NULL;
139 return 1;
140 }
141
142static int engine_list_remove(ENGINE *e)
143 {
144 ENGINE *iterator;
145
146 if(e == NULL)
147 {
148 ENGINEerr(ENGINE_F_ENGINE_LIST_REMOVE,
149 ERR_R_PASSED_NULL_PARAMETER);
150 return 0;
151 }
152 /* We need to check that e is in our linked list! */
153 iterator = engine_list_head;
154 while(iterator && (iterator != e))
155 iterator = iterator->next;
156 if(iterator == NULL)
157 {
158 ENGINEerr(ENGINE_F_ENGINE_LIST_REMOVE,
159 ENGINE_R_ENGINE_IS_NOT_IN_LIST);
160 return 0;
161 }
162 /* un-link e from the chain. */
163 if(e->next)
164 e->next->prev = e->prev;
165 if(e->prev)
166 e->prev->next = e->next;
167 /* Correct our head/tail if necessary. */
168 if(engine_list_head == e)
169 engine_list_head = e->next;
170 if(engine_list_tail == e)
171 engine_list_tail = e->prev;
79aa04ef 172 ENGINE_free_util(e, 0);
5270e702
RL
173 return 1;
174 }
175
176/* This check always takes place with CRYPTO_LOCK_ENGINE locked up
177 * so we're synchronised, but we can't call anything that tries to
178 * lock it again! :-) NB: For convenience (and code-clarity) we
179 * don't output errors for failures of the engine_list_add function
180 * as it will generate errors itself. */
181static int engine_internal_check(void)
182 {
b41f836e 183 int toret = 1;
9391f977 184 ENGINE *def_engine1, *def_engine2;
5270e702
RL
185 if(engine_list_flag)
186 return 1;
187 /* This is our first time up, we need to populate the list
188 * with our statically compiled-in engines. */
9391f977
GT
189 def_engine1 = ENGINE_openssl();
190 def_engine2 = ENGINE_dynamic();
191 if(!engine_list_add(def_engine1) ||
192 !engine_list_add(def_engine2))
b41f836e
GT
193 toret = 0;
194 else
195 engine_list_flag = 1;
9391f977
GT
196 ENGINE_free_util(def_engine1, 0);
197 ENGINE_free_util(def_engine2, 0);
5270e702
RL
198 return 1;
199 }
200
201/* Get the first/last "ENGINE" type available. */
202ENGINE *ENGINE_get_first(void)
203 {
204 ENGINE *ret = NULL;
205
206 CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
207 if(engine_internal_check())
208 {
209 ret = engine_list_head;
210 if(ret)
b41f836e 211 {
5270e702 212 ret->struct_ref++;
b41f836e
GT
213 engine_ref_debug(ret, 0, 1)
214 }
5270e702
RL
215 }
216 CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
217 return ret;
218 }
219ENGINE *ENGINE_get_last(void)
220 {
221 ENGINE *ret = NULL;
222
223 CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
224 if(engine_internal_check())
225 {
226 ret = engine_list_tail;
227 if(ret)
b41f836e 228 {
5270e702 229 ret->struct_ref++;
b41f836e
GT
230 engine_ref_debug(ret, 0, 1)
231 }
5270e702
RL
232 }
233 CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
234 return ret;
235 }
236
237/* Iterate to the next/previous "ENGINE" type (NULL = end of the list). */
238ENGINE *ENGINE_get_next(ENGINE *e)
239 {
240 ENGINE *ret = NULL;
241 if(e == NULL)
242 {
243 ENGINEerr(ENGINE_F_ENGINE_GET_NEXT,
244 ERR_R_PASSED_NULL_PARAMETER);
245 return 0;
246 }
247 CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
248 ret = e->next;
5270e702 249 if(ret)
b41f836e 250 {
ea3a429e 251 /* Return a valid structural refernce to the next ENGINE */
5270e702 252 ret->struct_ref++;
b41f836e
GT
253 engine_ref_debug(ret, 0, 1)
254 }
5270e702 255 CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
ea3a429e
GT
256 /* Release the structural reference to the previous ENGINE */
257 ENGINE_free(e);
5270e702
RL
258 return ret;
259 }
260ENGINE *ENGINE_get_prev(ENGINE *e)
261 {
262 ENGINE *ret = NULL;
263 if(e == NULL)
264 {
265 ENGINEerr(ENGINE_F_ENGINE_GET_PREV,
266 ERR_R_PASSED_NULL_PARAMETER);
267 return 0;
268 }
269 CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
270 ret = e->prev;
5270e702 271 if(ret)
b41f836e 272 {
ea3a429e 273 /* Return a valid structural reference to the next ENGINE */
5270e702 274 ret->struct_ref++;
b41f836e
GT
275 engine_ref_debug(ret, 0, 1)
276 }
5270e702 277 CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
ea3a429e
GT
278 /* Release the structural reference to the previous ENGINE */
279 ENGINE_free(e);
5270e702
RL
280 return ret;
281 }
282
283/* Add another "ENGINE" type into the list. */
284int ENGINE_add(ENGINE *e)
285 {
286 int to_return = 1;
287 if(e == NULL)
288 {
289 ENGINEerr(ENGINE_F_ENGINE_ADD,
290 ERR_R_PASSED_NULL_PARAMETER);
291 return 0;
292 }
293 if((e->id == NULL) || (e->name == NULL))
294 {
295 ENGINEerr(ENGINE_F_ENGINE_ADD,
296 ENGINE_R_ID_OR_NAME_MISSING);
297 }
298 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
299 if(!engine_internal_check() || !engine_list_add(e))
300 {
301 ENGINEerr(ENGINE_F_ENGINE_ADD,
302 ENGINE_R_INTERNAL_LIST_ERROR);
303 to_return = 0;
304 }
305 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
306 return to_return;
307 }
308
309/* Remove an existing "ENGINE" type from the array. */
310int ENGINE_remove(ENGINE *e)
311 {
312 int to_return = 1;
313 if(e == NULL)
314 {
315 ENGINEerr(ENGINE_F_ENGINE_REMOVE,
316 ERR_R_PASSED_NULL_PARAMETER);
317 return 0;
318 }
319 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
320 if(!engine_internal_check() || !engine_list_remove(e))
321 {
322 ENGINEerr(ENGINE_F_ENGINE_REMOVE,
323 ENGINE_R_INTERNAL_LIST_ERROR);
324 to_return = 0;
325 }
326 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
327 return to_return;
328 }
329
330ENGINE *ENGINE_by_id(const char *id)
331 {
0ce5f3e4 332 ENGINE *iterator = NULL, *cp = NULL;
5270e702
RL
333 if(id == NULL)
334 {
335 ENGINEerr(ENGINE_F_ENGINE_BY_ID,
336 ERR_R_PASSED_NULL_PARAMETER);
337 return NULL;
338 }
339 CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
340 if(!engine_internal_check())
341 ENGINEerr(ENGINE_F_ENGINE_BY_ID,
342 ENGINE_R_INTERNAL_LIST_ERROR);
343 else
344 {
345 iterator = engine_list_head;
346 while(iterator && (strcmp(id, iterator->id) != 0))
347 iterator = iterator->next;
348 if(iterator)
0ce5f3e4
GT
349 {
350 /* We need to return a structural reference. If this is
351 * a "dynamic" ENGINE type, make a duplicate - otherwise
352 * increment the existing ENGINE's reference count. */
353 if(iterator->flags & ENGINE_FLAGS_BY_ID_COPY)
354 {
355 cp = ENGINE_new();
356 if(!cp)
357 iterator = NULL;
358 else
359 {
360 ENGINE_cpy(cp, iterator);
361 iterator = cp;
362 }
363 }
364 else
b41f836e 365 {
0ce5f3e4 366 iterator->struct_ref++;
b41f836e
GT
367 engine_ref_debug(iterator, 0, 1)
368 }
0ce5f3e4 369 }
5270e702
RL
370 }
371 CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
372 if(iterator == NULL)
373 ENGINEerr(ENGINE_F_ENGINE_BY_ID,
374 ENGINE_R_NO_SUCH_ENGINE);
375 return iterator;
376 }
377
5270e702
RL
378ENGINE *ENGINE_new(void)
379 {
380 ENGINE *ret;
381
382 ret = (ENGINE *)OPENSSL_malloc(sizeof(ENGINE));
383 if(ret == NULL)
384 {
385 ENGINEerr(ENGINE_F_ENGINE_NEW, ERR_R_MALLOC_FAILURE);
386 return NULL;
387 }
388 memset(ret, 0, sizeof(ENGINE));
5270e702 389 ret->struct_ref = 1;
b41f836e 390 engine_ref_debug(ret, 0, 1)
79aa04ef 391 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_ENGINE, ret, &ret->ex_data);
5270e702
RL
392 return ret;
393 }
5270e702 394
79aa04ef 395static int ENGINE_free_util(ENGINE *e, int locked)
5270e702
RL
396 {
397 int i;
398
399 if(e == NULL)
400 {
401 ENGINEerr(ENGINE_F_ENGINE_FREE,
402 ERR_R_PASSED_NULL_PARAMETER);
403 return 0;
404 }
79aa04ef
GT
405 if(locked)
406 i = CRYPTO_add(&e->struct_ref,-1,CRYPTO_LOCK_ENGINE);
407 else
408 i = --e->struct_ref;
b41f836e 409 engine_ref_debug(e, 0, -1)
5270e702
RL
410 if (i > 0) return 1;
411#ifdef REF_CHECK
412 if (i < 0)
413 {
b41f836e 414 fprintf(stderr,"ENGINE_free, bad structural reference count\n");
5270e702
RL
415 abort();
416 }
417#endif
f524ddbe
GT
418 /* Give the ENGINE a chance to do any structural cleanup corresponding
419 * to allocation it did in its constructor (eg. unload error strings) */
420 if(e->destroy)
421 e->destroy(e);
354c3ace 422 sk_ENGINE_EVP_CIPHER_pop_free(e->ciphers,ENGINE_free_engine_cipher);
79aa04ef 423 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ENGINE, e, &e->ex_data);
dcd87618 424 OPENSSL_free(e);
5270e702
RL
425 return 1;
426 }
427
79aa04ef 428int ENGINE_free(ENGINE *e)
853b1eb4 429 {
79aa04ef 430 return ENGINE_free_util(e, 1);
853b1eb4
BL
431 }
432
0ce5f3e4
GT
433int ENGINE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
434 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
435 {
79aa04ef
GT
436 return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_ENGINE, argl, argp,
437 new_func, dup_func, free_func);
0ce5f3e4
GT
438 }
439
440int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg)
441 {
442 return(CRYPTO_set_ex_data(&e->ex_data, idx, arg));
443 }
444
445void *ENGINE_get_ex_data(const ENGINE *e, int idx)
446 {
447 return(CRYPTO_get_ex_data(&e->ex_data, idx));
448 }
449
a679116f 450void ENGINE_cleanup(void)
b41f836e
GT
451 {
452 ENGINE *iterator = engine_list_head;
453
454 while(iterator != NULL)
455 {
456 ENGINE_remove(iterator);
457 iterator = engine_list_head;
458 }
459 engine_list_flag = 0;
460 /* Also unset any "default" ENGINEs that may have been set up (a default
461 * constitutes a functional reference on an ENGINE and there's one for
462 * each algorithm). */
463 ENGINE_clear_defaults();
464 return;
465 }
a679116f 466
5270e702
RL
467int ENGINE_set_id(ENGINE *e, const char *id)
468 {
d54bf145 469 if(id == NULL)
5270e702
RL
470 {
471 ENGINEerr(ENGINE_F_ENGINE_SET_ID,
472 ERR_R_PASSED_NULL_PARAMETER);
473 return 0;
474 }
475 e->id = id;
476 return 1;
477 }
478
479int ENGINE_set_name(ENGINE *e, const char *name)
480 {
d54bf145 481 if(name == NULL)
5270e702
RL
482 {
483 ENGINEerr(ENGINE_F_ENGINE_SET_NAME,
484 ERR_R_PASSED_NULL_PARAMETER);
485 return 0;
486 }
487 e->name = name;
488 return 1;
489 }
490
10e473e9 491int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth)
5270e702 492 {
9e78e6c3 493#ifndef OPENSSL_NO_RSA
5270e702
RL
494 e->rsa_meth = rsa_meth;
495 return 1;
9e78e6c3 496#else
b41f836e 497 return 0;
9e78e6c3 498#endif
5270e702
RL
499 }
500
a4aba800 501int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth)
5270e702 502 {
9e78e6c3 503#ifndef OPENSSL_NO_DSA
5270e702
RL
504 e->dsa_meth = dsa_meth;
505 return 1;
9e78e6c3 506#else
b41f836e 507 return 0;
9e78e6c3 508#endif
5270e702
RL
509 }
510
f971ccb2 511int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth)
5270e702 512 {
9e78e6c3 513#ifndef OPENSSL_NO_DH
5270e702
RL
514 e->dh_meth = dh_meth;
515 return 1;
9e78e6c3 516#else
b41f836e 517 return 0;
9e78e6c3 518#endif
5270e702
RL
519 }
520
d54bf145 521int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth)
5270e702 522 {
5270e702
RL
523 e->rand_meth = rand_meth;
524 return 1;
525 }
526
527int ENGINE_set_BN_mod_exp(ENGINE *e, BN_MOD_EXP bn_mod_exp)
528 {
5270e702
RL
529 e->bn_mod_exp = bn_mod_exp;
530 return 1;
531 }
532
533int ENGINE_set_BN_mod_exp_crt(ENGINE *e, BN_MOD_EXP_CRT bn_mod_exp_crt)
534 {
5270e702
RL
535 e->bn_mod_exp_crt = bn_mod_exp_crt;
536 return 1;
537 }
538
f524ddbe
GT
539int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f)
540 {
541 e->destroy = destroy_f;
542 return 1;
543 }
544
5270e702
RL
545int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f)
546 {
5270e702
RL
547 e->init = init_f;
548 return 1;
549 }
550
551int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f)
552 {
5270e702
RL
553 e->finish = finish_f;
554 return 1;
555 }
556
557int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f)
558 {
5270e702
RL
559 e->ctrl = ctrl_f;
560 return 1;
561 }
562
d54bf145
GT
563int ENGINE_set_load_privkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpriv_f)
564 {
565 e->load_privkey = loadpriv_f;
566 return 1;
567 }
568
569int ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f)
570 {
571 e->load_pubkey = loadpub_f;
572 return 1;
573 }
574
575int ENGINE_set_flags(ENGINE *e, int flags)
576 {
577 e->flags = flags;
578 return 1;
579 }
580
40fcda29
GT
581int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns)
582 {
583 e->cmd_defns = defns;
584 return 1;
585 }
586
d54bf145
GT
587int ENGINE_cpy(ENGINE *dest, const ENGINE *src)
588 {
589 if(ENGINE_set_id(dest, ENGINE_get_id(src)) &&
590 ENGINE_set_name(dest, ENGINE_get_name(src)) &&
9e78e6c3 591#ifndef OPENSSL_NO_RSA
d54bf145 592 ENGINE_set_RSA(dest, ENGINE_get_RSA(src)) &&
9e78e6c3 593#endif
db744f89 594#ifndef OPENSSL_NO_DSA
d54bf145 595 ENGINE_set_DSA(dest, ENGINE_get_DSA(src)) &&
9e78e6c3 596#endif
db744f89 597#ifndef OPENSSL_NO_DH
d54bf145 598 ENGINE_set_DH(dest, ENGINE_get_DH(src)) &&
9e78e6c3 599#endif
d54bf145
GT
600 ENGINE_set_RAND(dest, ENGINE_get_RAND(src)) &&
601 ENGINE_set_BN_mod_exp(dest,
602 ENGINE_get_BN_mod_exp(src)) &&
603 ENGINE_set_BN_mod_exp_crt(dest,
604 ENGINE_get_BN_mod_exp_crt(src)) &&
605 ENGINE_set_init_function(dest,
606 ENGINE_get_init_function(src)) &&
607 ENGINE_set_finish_function(dest,
608 ENGINE_get_finish_function(src)) &&
609 ENGINE_set_ctrl_function(dest,
610 ENGINE_get_ctrl_function(src)) &&
611 ENGINE_set_load_privkey_function(dest,
612 ENGINE_get_load_privkey_function(src)) &&
613 ENGINE_set_load_pubkey_function(dest,
614 ENGINE_get_load_pubkey_function(src)) &&
40fcda29
GT
615 ENGINE_set_flags(dest, ENGINE_get_flags(src)) &&
616 ENGINE_set_cmd_defns(dest, ENGINE_get_cmd_defns(src)))
d54bf145
GT
617 return 1;
618 return 0;
619 }
620
621const char *ENGINE_get_id(const ENGINE *e)
5270e702 622 {
5270e702
RL
623 return e->id;
624 }
625
d54bf145 626const char *ENGINE_get_name(const ENGINE *e)
5270e702 627 {
5270e702
RL
628 return e->name;
629 }
630
d54bf145 631const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e)
5270e702 632 {
5270e702
RL
633 return e->rsa_meth;
634 }
635
d54bf145 636const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e)
5270e702 637 {
5270e702
RL
638 return e->dsa_meth;
639 }
640
d54bf145 641const DH_METHOD *ENGINE_get_DH(const ENGINE *e)
5270e702 642 {
5270e702
RL
643 return e->dh_meth;
644 }
645
d54bf145 646const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e)
5270e702 647 {
5270e702
RL
648 return e->rand_meth;
649 }
650
d54bf145 651BN_MOD_EXP ENGINE_get_BN_mod_exp(const ENGINE *e)
5270e702 652 {
5270e702
RL
653 return e->bn_mod_exp;
654 }
655
d54bf145 656BN_MOD_EXP_CRT ENGINE_get_BN_mod_exp_crt(const ENGINE *e)
5270e702 657 {
5270e702
RL
658 return e->bn_mod_exp_crt;
659 }
660
f524ddbe
GT
661ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e)
662 {
663 return e->destroy;
664 }
665
d54bf145 666ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e)
5270e702 667 {
5270e702
RL
668 return e->init;
669 }
670
d54bf145 671ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e)
5270e702 672 {
5270e702
RL
673 return e->finish;
674 }
675
d54bf145 676ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const ENGINE *e)
5270e702 677 {
5270e702
RL
678 return e->ctrl;
679 }
680
d54bf145
GT
681ENGINE_LOAD_KEY_PTR ENGINE_get_load_privkey_function(const ENGINE *e)
682 {
683 return e->load_privkey;
684 }
685
686ENGINE_LOAD_KEY_PTR ENGINE_get_load_pubkey_function(const ENGINE *e)
687 {
688 return e->load_pubkey;
689 }
690
691int ENGINE_get_flags(const ENGINE *e)
692 {
693 return e->flags;
694 }
40fcda29
GT
695
696const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e)
697 {
698 return e->cmd_defns;
699 }