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