summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/engine/engine.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/engine/engine.h')
-rw-r--r--src/lib/libcrypto/engine/engine.h158
1 files changed, 51 insertions, 107 deletions
diff --git a/src/lib/libcrypto/engine/engine.h b/src/lib/libcrypto/engine/engine.h
index 3ec59338ff..900f75ce8d 100644
--- a/src/lib/libcrypto/engine/engine.h
+++ b/src/lib/libcrypto/engine/engine.h
@@ -3,7 +3,7 @@
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
6 * Copyright (c) 1999-2004 The OpenSSL Project. All rights reserved. 6 * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
@@ -55,11 +55,6 @@
55 * Hudson (tjh@cryptsoft.com). 55 * Hudson (tjh@cryptsoft.com).
56 * 56 *
57 */ 57 */
58/* ====================================================================
59 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
60 * ECDH support in OpenSSL originally developed by
61 * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
62 */
63 58
64#ifndef HEADER_ENGINE_H 59#ifndef HEADER_ENGINE_H
65#define HEADER_ENGINE_H 60#define HEADER_ENGINE_H
@@ -70,7 +65,7 @@
70#error ENGINE is disabled. 65#error ENGINE is disabled.
71#endif 66#endif
72 67
73#ifndef OPENSSL_NO_DEPRECATED 68#include <openssl/ossl_typ.h>
74#include <openssl/bn.h> 69#include <openssl/bn.h>
75#ifndef OPENSSL_NO_RSA 70#ifndef OPENSSL_NO_RSA
76#include <openssl/rsa.h> 71#include <openssl/rsa.h>
@@ -81,36 +76,34 @@
81#ifndef OPENSSL_NO_DH 76#ifndef OPENSSL_NO_DH
82#include <openssl/dh.h> 77#include <openssl/dh.h>
83#endif 78#endif
84#ifndef OPENSSL_NO_ECDH
85#include <openssl/ecdh.h>
86#endif
87#ifndef OPENSSL_NO_ECDSA
88#include <openssl/ecdsa.h>
89#endif
90#include <openssl/rand.h> 79#include <openssl/rand.h>
91#include <openssl/store.h>
92#include <openssl/ui.h> 80#include <openssl/ui.h>
93#include <openssl/err.h>
94#endif
95
96#include <openssl/ossl_typ.h>
97#include <openssl/symhacks.h> 81#include <openssl/symhacks.h>
82#include <openssl/err.h>
98 83
99#ifdef __cplusplus 84#ifdef __cplusplus
100extern "C" { 85extern "C" {
101#endif 86#endif
102 87
88/* Fixups for missing algorithms */
89#ifdef OPENSSL_NO_RSA
90typedef void RSA_METHOD;
91#endif
92#ifdef OPENSSL_NO_DSA
93typedef void DSA_METHOD;
94#endif
95#ifdef OPENSSL_NO_DH
96typedef void DH_METHOD;
97#endif
98
103/* These flags are used to control combinations of algorithm (methods) 99/* These flags are used to control combinations of algorithm (methods)
104 * by bitwise "OR"ing. */ 100 * by bitwise "OR"ing. */
105#define ENGINE_METHOD_RSA (unsigned int)0x0001 101#define ENGINE_METHOD_RSA (unsigned int)0x0001
106#define ENGINE_METHOD_DSA (unsigned int)0x0002 102#define ENGINE_METHOD_DSA (unsigned int)0x0002
107#define ENGINE_METHOD_DH (unsigned int)0x0004 103#define ENGINE_METHOD_DH (unsigned int)0x0004
108#define ENGINE_METHOD_RAND (unsigned int)0x0008 104#define ENGINE_METHOD_RAND (unsigned int)0x0008
109#define ENGINE_METHOD_ECDH (unsigned int)0x0010
110#define ENGINE_METHOD_ECDSA (unsigned int)0x0020
111#define ENGINE_METHOD_CIPHERS (unsigned int)0x0040 105#define ENGINE_METHOD_CIPHERS (unsigned int)0x0040
112#define ENGINE_METHOD_DIGESTS (unsigned int)0x0080 106#define ENGINE_METHOD_DIGESTS (unsigned int)0x0080
113#define ENGINE_METHOD_STORE (unsigned int)0x0100
114/* Obvious all-or-nothing cases. */ 107/* Obvious all-or-nothing cases. */
115#define ENGINE_METHOD_ALL (unsigned int)0xFFFF 108#define ENGINE_METHOD_ALL (unsigned int)0xFFFF
116#define ENGINE_METHOD_NONE (unsigned int)0x0000 109#define ENGINE_METHOD_NONE (unsigned int)0x0000
@@ -180,15 +173,9 @@ extern "C" {
180 handles/connections etc. */ 173 handles/connections etc. */
181#define ENGINE_CTRL_SET_USER_INTERFACE 4 /* Alternative to callback */ 174#define ENGINE_CTRL_SET_USER_INTERFACE 4 /* Alternative to callback */
182#define ENGINE_CTRL_SET_CALLBACK_DATA 5 /* User-specific data, used 175#define ENGINE_CTRL_SET_CALLBACK_DATA 5 /* User-specific data, used
183 when calling the password 176 when calling the password
184 callback and the user 177 callback and the user
185 interface */ 178 interface */
186#define ENGINE_CTRL_LOAD_CONFIGURATION 6 /* Load a configuration, given
187 a string that represents a
188 file name or so */
189#define ENGINE_CTRL_LOAD_SECTION 7 /* Load data from a given
190 section in the already loaded
191 configuration */
192 179
193/* These control commands allow an application to deal with an arbitrary engine 180/* These control commands allow an application to deal with an arbitrary engine
194 * in a dynamic way. Warn: Negative return values indicate errors FOR THESE 181 * in a dynamic way. Warn: Negative return values indicate errors FOR THESE
@@ -235,7 +222,7 @@ extern "C" {
235 222
236/* ENGINE implementations should start the numbering of their own control 223/* ENGINE implementations should start the numbering of their own control
237 * commands from this value. (ie. ENGINE_CMD_BASE, ENGINE_CMD_BASE + 1, etc). */ 224 * commands from this value. (ie. ENGINE_CMD_BASE, ENGINE_CMD_BASE + 1, etc). */
238#define ENGINE_CMD_BASE 200 225#define ENGINE_CMD_BASE 200
239 226
240/* NB: These 2 nCipher "chil" control commands are deprecated, and their 227/* NB: These 2 nCipher "chil" control commands are deprecated, and their
241 * functionality is now available through ENGINE-specific control commands 228 * functionality is now available through ENGINE-specific control commands
@@ -270,11 +257,11 @@ typedef struct ENGINE_CMD_DEFN_st
270 } ENGINE_CMD_DEFN; 257 } ENGINE_CMD_DEFN;
271 258
272/* Generic function pointer */ 259/* Generic function pointer */
273typedef int (*ENGINE_GEN_FUNC_PTR)(void); 260typedef int (*ENGINE_GEN_FUNC_PTR)();
274/* Generic function pointer taking no arguments */ 261/* Generic function pointer taking no arguments */
275typedef int (*ENGINE_GEN_INT_FUNC_PTR)(ENGINE *); 262typedef int (*ENGINE_GEN_INT_FUNC_PTR)(ENGINE *);
276/* Specific control function pointer */ 263/* Specific control function pointer */
277typedef int (*ENGINE_CTRL_FUNC_PTR)(ENGINE *, int, long, void *, void (*f)(void)); 264typedef int (*ENGINE_CTRL_FUNC_PTR)(ENGINE *, int, long, void *, void (*f)());
278/* Generic load_key function pointer */ 265/* Generic load_key function pointer */
279typedef EVP_PKEY * (*ENGINE_LOAD_KEY_PTR)(ENGINE *, const char *, 266typedef EVP_PKEY * (*ENGINE_LOAD_KEY_PTR)(ENGINE *, const char *,
280 UI_METHOD *ui_method, void *callback_data); 267 UI_METHOD *ui_method, void *callback_data);
@@ -318,21 +305,15 @@ ENGINE *ENGINE_by_id(const char *id);
318/* Add all the built-in engines. */ 305/* Add all the built-in engines. */
319void ENGINE_load_openssl(void); 306void ENGINE_load_openssl(void);
320void ENGINE_load_dynamic(void); 307void ENGINE_load_dynamic(void);
321#ifndef OPENSSL_NO_STATIC_ENGINE
322void ENGINE_load_4758cca(void);
323void ENGINE_load_aep(void);
324void ENGINE_load_atalla(void);
325void ENGINE_load_chil(void);
326void ENGINE_load_cswift(void); 308void ENGINE_load_cswift(void);
327#ifndef OPENSSL_NO_GMP 309void ENGINE_load_chil(void);
328void ENGINE_load_gmp(void); 310void ENGINE_load_atalla(void);
329#endif
330void ENGINE_load_nuron(void); 311void ENGINE_load_nuron(void);
331void ENGINE_load_sureware(void);
332void ENGINE_load_ubsec(void); 312void ENGINE_load_ubsec(void);
333#endif 313void ENGINE_load_aep(void);
314void ENGINE_load_sureware(void);
315void ENGINE_load_4758cca(void);
334void ENGINE_load_cryptodev(void); 316void ENGINE_load_cryptodev(void);
335void ENGINE_load_padlock(void);
336void ENGINE_load_builtin_engines(void); 317void ENGINE_load_builtin_engines(void);
337 318
338/* Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation 319/* Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation
@@ -356,14 +337,6 @@ int ENGINE_register_DSA(ENGINE *e);
356void ENGINE_unregister_DSA(ENGINE *e); 337void ENGINE_unregister_DSA(ENGINE *e);
357void ENGINE_register_all_DSA(void); 338void ENGINE_register_all_DSA(void);
358 339
359int ENGINE_register_ECDH(ENGINE *e);
360void ENGINE_unregister_ECDH(ENGINE *e);
361void ENGINE_register_all_ECDH(void);
362
363int ENGINE_register_ECDSA(ENGINE *e);
364void ENGINE_unregister_ECDSA(ENGINE *e);
365void ENGINE_register_all_ECDSA(void);
366
367int ENGINE_register_DH(ENGINE *e); 340int ENGINE_register_DH(ENGINE *e);
368void ENGINE_unregister_DH(ENGINE *e); 341void ENGINE_unregister_DH(ENGINE *e);
369void ENGINE_register_all_DH(void); 342void ENGINE_register_all_DH(void);
@@ -372,10 +345,6 @@ int ENGINE_register_RAND(ENGINE *e);
372void ENGINE_unregister_RAND(ENGINE *e); 345void ENGINE_unregister_RAND(ENGINE *e);
373void ENGINE_register_all_RAND(void); 346void ENGINE_register_all_RAND(void);
374 347
375int ENGINE_register_STORE(ENGINE *e);
376void ENGINE_unregister_STORE(ENGINE *e);
377void ENGINE_register_all_STORE(void);
378
379int ENGINE_register_ciphers(ENGINE *e); 348int ENGINE_register_ciphers(ENGINE *e);
380void ENGINE_unregister_ciphers(ENGINE *e); 349void ENGINE_unregister_ciphers(ENGINE *e);
381void ENGINE_register_all_ciphers(void); 350void ENGINE_register_all_ciphers(void);
@@ -398,7 +367,7 @@ int ENGINE_register_all_complete(void);
398 * reference to an engine, but many control commands may require the engine be 367 * reference to an engine, but many control commands may require the engine be
399 * functional. The caller should be aware of trying commands that require an 368 * functional. The caller should be aware of trying commands that require an
400 * operational ENGINE, and only use functional references in such situations. */ 369 * operational ENGINE, and only use functional references in such situations. */
401int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void)); 370int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)());
402 371
403/* This function tests if an ENGINE-specific command is usable as a "setting". 372/* This function tests if an ENGINE-specific command is usable as a "setting".
404 * Eg. in an application's config file that gets processed through 373 * Eg. in an application's config file that gets processed through
@@ -411,7 +380,7 @@ int ENGINE_cmd_is_executable(ENGINE *e, int cmd);
411 * See the comment on ENGINE_ctrl_cmd_string() for an explanation on how to 380 * See the comment on ENGINE_ctrl_cmd_string() for an explanation on how to
412 * use the cmd_name and cmd_optional. */ 381 * use the cmd_name and cmd_optional. */
413int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name, 382int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name,
414 long i, void *p, void (*f)(void), int cmd_optional); 383 long i, void *p, void (*f)(), int cmd_optional);
415 384
416/* This function passes a command-name and argument to an ENGINE. The cmd_name 385/* This function passes a command-name and argument to an ENGINE. The cmd_name
417 * is converted to a command number and the control command is called using 386 * is converted to a command number and the control command is called using
@@ -448,11 +417,8 @@ int ENGINE_set_id(ENGINE *e, const char *id);
448int ENGINE_set_name(ENGINE *e, const char *name); 417int ENGINE_set_name(ENGINE *e, const char *name);
449int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth); 418int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth);
450int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth); 419int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth);
451int ENGINE_set_ECDH(ENGINE *e, const ECDH_METHOD *ecdh_meth);
452int ENGINE_set_ECDSA(ENGINE *e, const ECDSA_METHOD *ecdsa_meth);
453int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth); 420int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth);
454int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth); 421int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth);
455int ENGINE_set_STORE(ENGINE *e, const STORE_METHOD *store_meth);
456int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f); 422int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f);
457int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f); 423int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f);
458int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f); 424int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f);
@@ -463,11 +429,11 @@ int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f);
463int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f); 429int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f);
464int ENGINE_set_flags(ENGINE *e, int flags); 430int ENGINE_set_flags(ENGINE *e, int flags);
465int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns); 431int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns);
466/* These functions allow control over any per-structure ENGINE data. */ 432/* These functions (and the "get" function lower down) allow control over any
433 * per-structure ENGINE data. */
467int ENGINE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, 434int ENGINE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
468 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); 435 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
469int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg); 436int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg);
470void *ENGINE_get_ex_data(const ENGINE *e, int idx);
471 437
472/* This function cleans up anything that needs it. Eg. the ENGINE_add() function 438/* This function cleans up anything that needs it. Eg. the ENGINE_add() function
473 * automatically ensures the list cleanup function is registered to be called 439 * automatically ensures the list cleanup function is registered to be called
@@ -483,11 +449,8 @@ const char *ENGINE_get_id(const ENGINE *e);
483const char *ENGINE_get_name(const ENGINE *e); 449const char *ENGINE_get_name(const ENGINE *e);
484const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e); 450const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e);
485const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e); 451const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e);
486const ECDH_METHOD *ENGINE_get_ECDH(const ENGINE *e);
487const ECDSA_METHOD *ENGINE_get_ECDSA(const ENGINE *e);
488const DH_METHOD *ENGINE_get_DH(const ENGINE *e); 452const DH_METHOD *ENGINE_get_DH(const ENGINE *e);
489const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e); 453const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e);
490const STORE_METHOD *ENGINE_get_STORE(const ENGINE *e);
491ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e); 454ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e);
492ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e); 455ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e);
493ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e); 456ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e);
@@ -500,6 +463,7 @@ const EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid);
500const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid); 463const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid);
501const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e); 464const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e);
502int ENGINE_get_flags(const ENGINE *e); 465int ENGINE_get_flags(const ENGINE *e);
466void *ENGINE_get_ex_data(const ENGINE *e, int idx);
503 467
504/* FUNCTIONAL functions. These functions deal with ENGINE structures 468/* FUNCTIONAL functions. These functions deal with ENGINE structures
505 * that have (or will) be initialised for use. Broadly speaking, the 469 * that have (or will) be initialised for use. Broadly speaking, the
@@ -537,8 +501,6 @@ EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id,
537ENGINE *ENGINE_get_default_RSA(void); 501ENGINE *ENGINE_get_default_RSA(void);
538/* Same for the other "methods" */ 502/* Same for the other "methods" */
539ENGINE *ENGINE_get_default_DSA(void); 503ENGINE *ENGINE_get_default_DSA(void);
540ENGINE *ENGINE_get_default_ECDH(void);
541ENGINE *ENGINE_get_default_ECDSA(void);
542ENGINE *ENGINE_get_default_DH(void); 504ENGINE *ENGINE_get_default_DH(void);
543ENGINE *ENGINE_get_default_RAND(void); 505ENGINE *ENGINE_get_default_RAND(void);
544/* These functions can be used to get a functional reference to perform 506/* These functions can be used to get a functional reference to perform
@@ -554,8 +516,6 @@ int ENGINE_set_default_RSA(ENGINE *e);
554int ENGINE_set_default_string(ENGINE *e, const char *def_list); 516int ENGINE_set_default_string(ENGINE *e, const char *def_list);
555/* Same for the other "methods" */ 517/* Same for the other "methods" */
556int ENGINE_set_default_DSA(ENGINE *e); 518int ENGINE_set_default_DSA(ENGINE *e);
557int ENGINE_set_default_ECDH(ENGINE *e);
558int ENGINE_set_default_ECDSA(ENGINE *e);
559int ENGINE_set_default_DH(ENGINE *e); 519int ENGINE_set_default_DH(ENGINE *e);
560int ENGINE_set_default_RAND(ENGINE *e); 520int ENGINE_set_default_RAND(ENGINE *e);
561int ENGINE_set_default_ciphers(ENGINE *e); 521int ENGINE_set_default_ciphers(ENGINE *e);
@@ -578,20 +538,17 @@ void ENGINE_add_conf_module(void);
578/**************************/ 538/**************************/
579 539
580/* Binary/behaviour compatibility levels */ 540/* Binary/behaviour compatibility levels */
581#define OSSL_DYNAMIC_VERSION (unsigned long)0x00020000 541#define OSSL_DYNAMIC_VERSION (unsigned long)0x00010200
582/* Binary versions older than this are too old for us (whether we're a loader or 542/* Binary versions older than this are too old for us (whether we're a loader or
583 * a loadee) */ 543 * a loadee) */
584#define OSSL_DYNAMIC_OLDEST (unsigned long)0x00020000 544#define OSSL_DYNAMIC_OLDEST (unsigned long)0x00010200
585 545
586/* When compiling an ENGINE entirely as an external shared library, loadable by 546/* When compiling an ENGINE entirely as an external shared library, loadable by
587 * the "dynamic" ENGINE, these types are needed. The 'dynamic_fns' structure 547 * the "dynamic" ENGINE, these types are needed. The 'dynamic_fns' structure
588 * type provides the calling application's (or library's) error functionality 548 * type provides the calling application's (or library's) error functionality
589 * and memory management function pointers to the loaded library. These should 549 * and memory management function pointers to the loaded library. These should
590 * be used/set in the loaded library code so that the loading application's 550 * be used/set in the loaded library code so that the loading application's
591 * 'state' will be used/changed in all operations. The 'static_state' pointer 551 * 'state' will be used/changed in all operations. */
592 * allows the loaded library to know if it shares the same static data as the
593 * calling application (or library), and thus whether these callbacks need to be
594 * set or not. */
595typedef void *(*dyn_MEM_malloc_cb)(size_t); 552typedef void *(*dyn_MEM_malloc_cb)(size_t);
596typedef void *(*dyn_MEM_realloc_cb)(void *, size_t); 553typedef void *(*dyn_MEM_realloc_cb)(void *, size_t);
597typedef void (*dyn_MEM_free_cb)(void *); 554typedef void (*dyn_MEM_free_cb)(void *);
@@ -619,7 +576,6 @@ typedef struct st_dynamic_LOCK_fns {
619 } dynamic_LOCK_fns; 576 } dynamic_LOCK_fns;
620/* The top-level structure */ 577/* The top-level structure */
621typedef struct st_dynamic_fns { 578typedef struct st_dynamic_fns {
622 void *static_state;
623 const ERR_FNS *err_fns; 579 const ERR_FNS *err_fns;
624 const CRYPTO_EX_DATA_IMPL *ex_data_fns; 580 const CRYPTO_EX_DATA_IMPL *ex_data_fns;
625 dynamic_MEM_fns mem_fns; 581 dynamic_MEM_fns mem_fns;
@@ -637,7 +593,7 @@ typedef struct st_dynamic_fns {
637 * can be fully instantiated with IMPLEMENT_DYNAMIC_CHECK_FN(). */ 593 * can be fully instantiated with IMPLEMENT_DYNAMIC_CHECK_FN(). */
638typedef unsigned long (*dynamic_v_check_fn)(unsigned long ossl_version); 594typedef unsigned long (*dynamic_v_check_fn)(unsigned long ossl_version);
639#define IMPLEMENT_DYNAMIC_CHECK_FN() \ 595#define IMPLEMENT_DYNAMIC_CHECK_FN() \
640 OPENSSL_EXPORT unsigned long v_check(unsigned long v) { \ 596 unsigned long v_check(unsigned long v) { \
641 if(v >= OSSL_DYNAMIC_OLDEST) return OSSL_DYNAMIC_VERSION; \ 597 if(v >= OSSL_DYNAMIC_OLDEST) return OSSL_DYNAMIC_VERSION; \
642 return 0; } 598 return 0; }
643 599
@@ -659,35 +615,24 @@ typedef unsigned long (*dynamic_v_check_fn)(unsigned long ossl_version);
659typedef int (*dynamic_bind_engine)(ENGINE *e, const char *id, 615typedef int (*dynamic_bind_engine)(ENGINE *e, const char *id,
660 const dynamic_fns *fns); 616 const dynamic_fns *fns);
661#define IMPLEMENT_DYNAMIC_BIND_FN(fn) \ 617#define IMPLEMENT_DYNAMIC_BIND_FN(fn) \
662 OPENSSL_EXPORT \
663 int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) { \ 618 int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) { \
664 if(ENGINE_get_static_state() == fns->static_state) goto skip_cbs; \ 619 if (ERR_get_implementation() != fns->err_fns) \
665 if(!CRYPTO_set_mem_functions(fns->mem_fns.malloc_cb, \ 620 { \
666 fns->mem_fns.realloc_cb, fns->mem_fns.free_cb)) \ 621 if(!CRYPTO_set_mem_functions(fns->mem_fns.malloc_cb, \
667 return 0; \ 622 fns->mem_fns.realloc_cb, fns->mem_fns.free_cb)) \
668 CRYPTO_set_locking_callback(fns->lock_fns.lock_locking_cb); \ 623 return 0; \
669 CRYPTO_set_add_lock_callback(fns->lock_fns.lock_add_lock_cb); \ 624 CRYPTO_set_locking_callback(fns->lock_fns.lock_locking_cb); \
670 CRYPTO_set_dynlock_create_callback(fns->lock_fns.dynlock_create_cb); \ 625 CRYPTO_set_add_lock_callback(fns->lock_fns.lock_add_lock_cb); \
671 CRYPTO_set_dynlock_lock_callback(fns->lock_fns.dynlock_lock_cb); \ 626 CRYPTO_set_dynlock_create_callback(fns->lock_fns.dynlock_create_cb); \
672 CRYPTO_set_dynlock_destroy_callback(fns->lock_fns.dynlock_destroy_cb); \ 627 CRYPTO_set_dynlock_lock_callback(fns->lock_fns.dynlock_lock_cb); \
673 if(!CRYPTO_set_ex_data_implementation(fns->ex_data_fns)) \ 628 CRYPTO_set_dynlock_destroy_callback(fns->lock_fns.dynlock_destroy_cb); \
674 return 0; \ 629 if(!CRYPTO_set_ex_data_implementation(fns->ex_data_fns)) \
675 if(!ERR_set_implementation(fns->err_fns)) return 0; \ 630 return 0; \
676 skip_cbs: \ 631 if(!ERR_set_implementation(fns->err_fns)) return 0; \
632 } \
677 if(!fn(e,id)) return 0; \ 633 if(!fn(e,id)) return 0; \
678 return 1; } 634 return 1; }
679 635
680/* If the loading application (or library) and the loaded ENGINE library share
681 * the same static data (eg. they're both dynamically linked to the same
682 * libcrypto.so) we need a way to avoid trying to set system callbacks - this
683 * would fail, and for the same reason that it's unnecessary to try. If the
684 * loaded ENGINE has (or gets from through the loader) its own copy of the
685 * libcrypto static data, we will need to set the callbacks. The easiest way to
686 * detect this is to have a function that returns a pointer to some static data
687 * and let the loading application and loaded ENGINE compare their respective
688 * values. */
689void *ENGINE_get_static_state(void);
690
691#if defined(__OpenBSD__) || defined(__FreeBSD__) 636#if defined(__OpenBSD__) || defined(__FreeBSD__)
692void ENGINE_setup_bsd_cryptodev(void); 637void ENGINE_setup_bsd_cryptodev(void);
693#endif 638#endif
@@ -704,7 +649,6 @@ void ERR_load_ENGINE_strings(void);
704#define ENGINE_F_DYNAMIC_CTRL 180 649#define ENGINE_F_DYNAMIC_CTRL 180
705#define ENGINE_F_DYNAMIC_GET_DATA_CTX 181 650#define ENGINE_F_DYNAMIC_GET_DATA_CTX 181
706#define ENGINE_F_DYNAMIC_LOAD 182 651#define ENGINE_F_DYNAMIC_LOAD 182
707#define ENGINE_F_DYNAMIC_SET_DATA_CTX 183
708#define ENGINE_F_ENGINE_ADD 105 652#define ENGINE_F_ENGINE_ADD 105
709#define ENGINE_F_ENGINE_BY_ID 106 653#define ENGINE_F_ENGINE_BY_ID 106
710#define ENGINE_F_ENGINE_CMD_IS_EXECUTABLE 170 654#define ENGINE_F_ENGINE_CMD_IS_EXECUTABLE 170
@@ -712,7 +656,7 @@ void ERR_load_ENGINE_strings(void);
712#define ENGINE_F_ENGINE_CTRL_CMD 178 656#define ENGINE_F_ENGINE_CTRL_CMD 178
713#define ENGINE_F_ENGINE_CTRL_CMD_STRING 171 657#define ENGINE_F_ENGINE_CTRL_CMD_STRING 171
714#define ENGINE_F_ENGINE_FINISH 107 658#define ENGINE_F_ENGINE_FINISH 107
715#define ENGINE_F_ENGINE_FREE_UTIL 108 659#define ENGINE_F_ENGINE_FREE 108
716#define ENGINE_F_ENGINE_GET_CIPHER 185 660#define ENGINE_F_ENGINE_GET_CIPHER 185
717#define ENGINE_F_ENGINE_GET_DEFAULT_TYPE 177 661#define ENGINE_F_ENGINE_GET_DEFAULT_TYPE 177
718#define ENGINE_F_ENGINE_GET_DIGEST 186 662#define ENGINE_F_ENGINE_GET_DIGEST 186
@@ -723,6 +667,7 @@ void ERR_load_ENGINE_strings(void);
723#define ENGINE_F_ENGINE_LIST_REMOVE 121 667#define ENGINE_F_ENGINE_LIST_REMOVE 121
724#define ENGINE_F_ENGINE_LOAD_PRIVATE_KEY 150 668#define ENGINE_F_ENGINE_LOAD_PRIVATE_KEY 150
725#define ENGINE_F_ENGINE_LOAD_PUBLIC_KEY 151 669#define ENGINE_F_ENGINE_LOAD_PUBLIC_KEY 151
670#define ENGINE_F_ENGINE_MODULE_INIT 187
726#define ENGINE_F_ENGINE_NEW 122 671#define ENGINE_F_ENGINE_NEW 122
727#define ENGINE_F_ENGINE_REMOVE 123 672#define ENGINE_F_ENGINE_REMOVE 123
728#define ENGINE_F_ENGINE_SET_DEFAULT_STRING 189 673#define ENGINE_F_ENGINE_SET_DEFAULT_STRING 189
@@ -731,12 +676,11 @@ void ERR_load_ENGINE_strings(void);
731#define ENGINE_F_ENGINE_SET_NAME 130 676#define ENGINE_F_ENGINE_SET_NAME 130
732#define ENGINE_F_ENGINE_TABLE_REGISTER 184 677#define ENGINE_F_ENGINE_TABLE_REGISTER 184
733#define ENGINE_F_ENGINE_UNLOAD_KEY 152 678#define ENGINE_F_ENGINE_UNLOAD_KEY 152
734#define ENGINE_F_ENGINE_UNLOCKED_FINISH 191
735#define ENGINE_F_ENGINE_UP_REF 190 679#define ENGINE_F_ENGINE_UP_REF 190
736#define ENGINE_F_INT_CTRL_HELPER 172 680#define ENGINE_F_INT_CTRL_HELPER 172
737#define ENGINE_F_INT_ENGINE_CONFIGURE 188 681#define ENGINE_F_INT_ENGINE_CONFIGURE 188
738#define ENGINE_F_INT_ENGINE_MODULE_INIT 187
739#define ENGINE_F_LOG_MESSAGE 141 682#define ENGINE_F_LOG_MESSAGE 141
683#define ENGINE_F_SET_DATA_CTX 183
740 684
741/* Reason codes. */ 685/* Reason codes. */
742#define ENGINE_R_ALREADY_LOADED 100 686#define ENGINE_R_ALREADY_LOADED 100