Make the necessary changes to work with the recent "ex_data" overhaul.
[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 /* 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. */
74 static ENGINE *engine_list_head = NULL;
75 static 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. */
79 static int engine_list_flag = 0;
80 static int ENGINE_free_util(ENGINE *e, int locked);
81
82 /* These static functions starting with a lower case "engine_" always
83  * take place when CRYPTO_LOCK_ENGINE has been locked up. */
84 static 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++;
135         engine_ref_debug(e, 0, 1)
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
142 static 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;
172         ENGINE_free_util(e, 0);
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. */
181 static int engine_internal_check(void)
182         {
183         int toret = 1;
184         ENGINE *def_engine;
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. */
189         def_engine = ENGINE_openssl();
190         if(!engine_list_add(def_engine))
191                 toret = 0;
192         else
193                 engine_list_flag = 1;
194         ENGINE_free_util(def_engine, 0);
195         return 1;
196         }
197
198 /* Get the first/last "ENGINE" type available. */
199 ENGINE *ENGINE_get_first(void)
200         {
201         ENGINE *ret = NULL;
202
203         CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
204         if(engine_internal_check())
205                 {
206                 ret = engine_list_head;
207                 if(ret)
208                         {
209                         ret->struct_ref++;
210                         engine_ref_debug(ret, 0, 1)
211                         }
212                 }
213         CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
214         return ret;
215         }
216 ENGINE *ENGINE_get_last(void)
217         {
218         ENGINE *ret = NULL;
219
220         CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
221         if(engine_internal_check())
222                 {
223                 ret = engine_list_tail;
224                 if(ret)
225                         {
226                         ret->struct_ref++;
227                         engine_ref_debug(ret, 0, 1)
228                         }
229                 }
230         CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
231         return ret;
232         }
233
234 /* Iterate to the next/previous "ENGINE" type (NULL = end of the list). */
235 ENGINE *ENGINE_get_next(ENGINE *e)
236         {
237         ENGINE *ret = NULL;
238         if(e == NULL)
239                 {
240                 ENGINEerr(ENGINE_F_ENGINE_GET_NEXT,
241                         ERR_R_PASSED_NULL_PARAMETER);
242                 return 0;
243                 }
244         CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
245         ret = e->next;
246         if(ret)
247                 {
248                 /* Return a valid structural refernce to the next ENGINE */
249                 ret->struct_ref++;
250                 engine_ref_debug(ret, 0, 1)
251                 }
252         CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
253         /* Release the structural reference to the previous ENGINE */
254         ENGINE_free(e);
255         return ret;
256         }
257 ENGINE *ENGINE_get_prev(ENGINE *e)
258         {
259         ENGINE *ret = NULL;
260         if(e == NULL)
261                 {
262                 ENGINEerr(ENGINE_F_ENGINE_GET_PREV,
263                         ERR_R_PASSED_NULL_PARAMETER);
264                 return 0;
265                 }
266         CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
267         ret = e->prev;
268         if(ret)
269                 {
270                 /* Return a valid structural reference to the next ENGINE */
271                 ret->struct_ref++;
272                 engine_ref_debug(ret, 0, 1)
273                 }
274         CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
275         /* Release the structural reference to the previous ENGINE */
276         ENGINE_free(e);
277         return ret;
278         }
279
280 /* Add another "ENGINE" type into the list. */
281 int ENGINE_add(ENGINE *e)
282         {
283         int to_return = 1;
284         if(e == NULL)
285                 {
286                 ENGINEerr(ENGINE_F_ENGINE_ADD,
287                         ERR_R_PASSED_NULL_PARAMETER);
288                 return 0;
289                 }
290         if((e->id == NULL) || (e->name == NULL))
291                 {
292                 ENGINEerr(ENGINE_F_ENGINE_ADD,
293                         ENGINE_R_ID_OR_NAME_MISSING);
294                 }
295         CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
296         if(!engine_internal_check() || !engine_list_add(e))
297                 {
298                 ENGINEerr(ENGINE_F_ENGINE_ADD,
299                         ENGINE_R_INTERNAL_LIST_ERROR);
300                 to_return = 0;
301                 }
302         CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
303         return to_return;
304         }
305
306 /* Remove an existing "ENGINE" type from the array. */
307 int ENGINE_remove(ENGINE *e)
308         {
309         int to_return = 1;
310         if(e == NULL)
311                 {
312                 ENGINEerr(ENGINE_F_ENGINE_REMOVE,
313                         ERR_R_PASSED_NULL_PARAMETER);
314                 return 0;
315                 }
316         CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
317         if(!engine_internal_check() || !engine_list_remove(e))
318                 {
319                 ENGINEerr(ENGINE_F_ENGINE_REMOVE,
320                         ENGINE_R_INTERNAL_LIST_ERROR);
321                 to_return = 0;
322                 }
323         CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
324         return to_return;
325         }
326
327 ENGINE *ENGINE_by_id(const char *id)
328         {
329         ENGINE *iterator = NULL, *cp = NULL;
330         if(id == NULL)
331                 {
332                 ENGINEerr(ENGINE_F_ENGINE_BY_ID,
333                         ERR_R_PASSED_NULL_PARAMETER);
334                 return NULL;
335                 }
336         CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
337         if(!engine_internal_check())
338                 ENGINEerr(ENGINE_F_ENGINE_BY_ID,
339                         ENGINE_R_INTERNAL_LIST_ERROR);
340         else
341                 {
342                 iterator = engine_list_head;
343                 while(iterator && (strcmp(id, iterator->id) != 0))
344                         iterator = iterator->next;
345                 if(iterator)
346                         {
347                         /* We need to return a structural reference. If this is
348                          * a "dynamic" ENGINE type, make a duplicate - otherwise
349                          * increment the existing ENGINE's reference count. */
350                         if(iterator->flags & ENGINE_FLAGS_BY_ID_COPY)
351                                 {
352                                 cp = ENGINE_new();
353                                 if(!cp)
354                                         iterator = NULL;
355                                 else
356                                         {
357                                         ENGINE_cpy(cp, iterator);
358                                         iterator = cp;
359                                         }
360                                 }
361                         else
362                                 {
363                                 iterator->struct_ref++;
364                                 engine_ref_debug(iterator, 0, 1)
365                                 }
366                         }
367                 }
368         CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
369         if(iterator == NULL)
370                 ENGINEerr(ENGINE_F_ENGINE_BY_ID,
371                         ENGINE_R_NO_SUCH_ENGINE);
372         return iterator;
373         }
374
375 ENGINE *ENGINE_new(void)
376         {
377         ENGINE *ret;
378
379         ret = (ENGINE *)OPENSSL_malloc(sizeof(ENGINE));
380         if(ret == NULL)
381                 {
382                 ENGINEerr(ENGINE_F_ENGINE_NEW, ERR_R_MALLOC_FAILURE);
383                 return NULL;
384                 }
385         memset(ret, 0, sizeof(ENGINE));
386         ret->struct_ref = 1;
387         engine_ref_debug(ret, 0, 1)
388         CRYPTO_new_ex_data(CRYPTO_EX_INDEX_ENGINE, ret, &ret->ex_data);
389         return ret;
390         }
391
392 static int ENGINE_free_util(ENGINE *e, int locked)
393         {
394         int i;
395
396         if(e == NULL)
397                 {
398                 ENGINEerr(ENGINE_F_ENGINE_FREE,
399                         ERR_R_PASSED_NULL_PARAMETER);
400                 return 0;
401                 }
402         if(locked)
403                 i = CRYPTO_add(&e->struct_ref,-1,CRYPTO_LOCK_ENGINE);
404         else
405                 i = --e->struct_ref;
406         engine_ref_debug(e, 0, -1)
407         if (i > 0) return 1;
408 #ifdef REF_CHECK
409         if (i < 0)
410                 {
411                 fprintf(stderr,"ENGINE_free, bad structural reference count\n");
412                 abort();
413                 }
414 #endif
415         sk_ENGINE_EVP_CIPHER_pop_free(e->ciphers,ENGINE_free_engine_cipher);
416         CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ENGINE, e, &e->ex_data);
417         OPENSSL_free(e);
418         return 1;
419         }
420
421 int ENGINE_free(ENGINE *e)
422         {
423         return ENGINE_free_util(e, 1);
424         }
425
426 int ENGINE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
427                 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
428         {
429         return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_ENGINE, argl, argp,
430                         new_func, dup_func, free_func);
431         }
432
433 int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg)
434         {
435         return(CRYPTO_set_ex_data(&e->ex_data, idx, arg));
436         }
437
438 void *ENGINE_get_ex_data(const ENGINE *e, int idx)
439         {
440         return(CRYPTO_get_ex_data(&e->ex_data, idx));
441         }
442
443 void ENGINE_cleanup(void)
444         {
445         ENGINE *iterator = engine_list_head;
446
447         while(iterator != NULL)
448                 {
449                 ENGINE_remove(iterator);
450                 iterator = engine_list_head;
451                 }
452         engine_list_flag = 0;
453         /* Also unset any "default" ENGINEs that may have been set up (a default
454          * constitutes a functional reference on an ENGINE and there's one for
455          * each algorithm). */
456         ENGINE_clear_defaults();
457         return;
458         }
459
460 int ENGINE_set_id(ENGINE *e, const char *id)
461         {
462         if(id == NULL)
463                 {
464                 ENGINEerr(ENGINE_F_ENGINE_SET_ID,
465                         ERR_R_PASSED_NULL_PARAMETER);
466                 return 0;
467                 }
468         e->id = id;
469         return 1;
470         }
471
472 int ENGINE_set_name(ENGINE *e, const char *name)
473         {
474         if(name == NULL)
475                 {
476                 ENGINEerr(ENGINE_F_ENGINE_SET_NAME,
477                         ERR_R_PASSED_NULL_PARAMETER);
478                 return 0;
479                 }
480         e->name = name;
481         return 1;
482         }
483
484 int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth)
485         {
486 #ifndef OPENSSL_NO_RSA
487         e->rsa_meth = rsa_meth;
488         return 1;
489 #else
490         return 0;
491 #endif
492         }
493
494 int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth)
495         {
496 #ifndef OPENSSL_NO_DSA
497         e->dsa_meth = dsa_meth;
498         return 1;
499 #else
500         return 0;
501 #endif
502         }
503
504 int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth)
505         {
506 #ifndef OPENSSL_NO_DH
507         e->dh_meth = dh_meth;
508         return 1;
509 #else
510         return 0;
511 #endif
512         }
513
514 int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth)
515         {
516         e->rand_meth = rand_meth;
517         return 1;
518         }
519
520 int ENGINE_set_BN_mod_exp(ENGINE *e, BN_MOD_EXP bn_mod_exp)
521         {
522         e->bn_mod_exp = bn_mod_exp;
523         return 1;
524         }
525
526 int ENGINE_set_BN_mod_exp_crt(ENGINE *e, BN_MOD_EXP_CRT bn_mod_exp_crt)
527         {
528         e->bn_mod_exp_crt = bn_mod_exp_crt;
529         return 1;
530         }
531
532 int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f)
533         {
534         e->init = init_f;
535         return 1;
536         }
537
538 int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f)
539         {
540         e->finish = finish_f;
541         return 1;
542         }
543
544 int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f)
545         {
546         e->ctrl = ctrl_f;
547         return 1;
548         }
549
550 int ENGINE_set_load_privkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpriv_f)
551         {
552         e->load_privkey = loadpriv_f;
553         return 1;
554         }
555
556 int ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f)
557         {
558         e->load_pubkey = loadpub_f;
559         return 1;
560         }
561
562 int ENGINE_set_flags(ENGINE *e, int flags)
563         {
564         e->flags = flags;
565         return 1;
566         }
567
568 int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns)
569         {
570         e->cmd_defns = defns;
571         return 1;
572         }
573
574 int ENGINE_cpy(ENGINE *dest, const ENGINE *src)
575         {
576         if(ENGINE_set_id(dest, ENGINE_get_id(src)) &&
577                         ENGINE_set_name(dest, ENGINE_get_name(src)) &&
578 #ifndef OPENSSL_NO_RSA
579                         ENGINE_set_RSA(dest, ENGINE_get_RSA(src)) &&
580 #endif
581 #ifndef OPENSSL_NO_RSA
582                         ENGINE_set_DSA(dest, ENGINE_get_DSA(src)) &&
583 #endif
584 #ifndef OPENSSL_NO_RSA
585                         ENGINE_set_DH(dest, ENGINE_get_DH(src)) &&
586 #endif
587                         ENGINE_set_RAND(dest, ENGINE_get_RAND(src)) &&
588                         ENGINE_set_BN_mod_exp(dest,
589                                         ENGINE_get_BN_mod_exp(src)) &&
590                         ENGINE_set_BN_mod_exp_crt(dest,
591                                         ENGINE_get_BN_mod_exp_crt(src)) &&
592                         ENGINE_set_init_function(dest,
593                                         ENGINE_get_init_function(src)) &&
594                         ENGINE_set_finish_function(dest,
595                                         ENGINE_get_finish_function(src)) &&
596                         ENGINE_set_ctrl_function(dest,
597                                         ENGINE_get_ctrl_function(src)) &&
598                         ENGINE_set_load_privkey_function(dest,
599                                         ENGINE_get_load_privkey_function(src)) &&
600                         ENGINE_set_load_pubkey_function(dest,
601                                         ENGINE_get_load_pubkey_function(src)) &&
602                         ENGINE_set_flags(dest, ENGINE_get_flags(src)) &&
603                         ENGINE_set_cmd_defns(dest, ENGINE_get_cmd_defns(src)))
604                 return 1;
605         return 0;
606         }
607
608 const char *ENGINE_get_id(const ENGINE *e)
609         {
610         return e->id;
611         }
612
613 const char *ENGINE_get_name(const ENGINE *e)
614         {
615         return e->name;
616         }
617
618 const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e)
619         {
620         return e->rsa_meth;
621         }
622
623 const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e)
624         {
625         return e->dsa_meth;
626         }
627
628 const DH_METHOD *ENGINE_get_DH(const ENGINE *e)
629         {
630         return e->dh_meth;
631         }
632
633 const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e)
634         {
635         return e->rand_meth;
636         }
637
638 BN_MOD_EXP ENGINE_get_BN_mod_exp(const ENGINE *e)
639         {
640         return e->bn_mod_exp;
641         }
642
643 BN_MOD_EXP_CRT ENGINE_get_BN_mod_exp_crt(const ENGINE *e)
644         {
645         return e->bn_mod_exp_crt;
646         }
647
648 ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e)
649         {
650         return e->init;
651         }
652
653 ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e)
654         {
655         return e->finish;
656         }
657
658 ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const ENGINE *e)
659         {
660         return e->ctrl;
661         }
662
663 ENGINE_LOAD_KEY_PTR ENGINE_get_load_privkey_function(const ENGINE *e)
664         {
665         return e->load_privkey;
666         }
667
668 ENGINE_LOAD_KEY_PTR ENGINE_get_load_pubkey_function(const ENGINE *e)
669         {
670         return e->load_pubkey;
671         }
672
673 int ENGINE_get_flags(const ENGINE *e)
674         {
675         return e->flags;
676         }
677
678 const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e)
679         {
680         return e->cmd_defns;
681         }