sl@0: /* crypto/engine/eng_int.h */ sl@0: /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL sl@0: * project 2000. sl@0: */ sl@0: /* ==================================================================== sl@0: * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved. sl@0: * sl@0: * Redistribution and use in source and binary forms, with or without sl@0: * modification, are permitted provided that the following conditions sl@0: * are met: sl@0: * sl@0: * 1. Redistributions of source code must retain the above copyright sl@0: * notice, this list of conditions and the following disclaimer. sl@0: * sl@0: * 2. Redistributions in binary form must reproduce the above copyright sl@0: * notice, this list of conditions and the following disclaimer in sl@0: * the documentation and/or other materials provided with the sl@0: * distribution. sl@0: * sl@0: * 3. All advertising materials mentioning features or use of this sl@0: * software must display the following acknowledgment: sl@0: * "This product includes software developed by the OpenSSL Project sl@0: * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" sl@0: * sl@0: * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to sl@0: * endorse or promote products derived from this software without sl@0: * prior written permission. For written permission, please contact sl@0: * licensing@OpenSSL.org. sl@0: * sl@0: * 5. Products derived from this software may not be called "OpenSSL" sl@0: * nor may "OpenSSL" appear in their names without prior written sl@0: * permission of the OpenSSL Project. sl@0: * sl@0: * 6. Redistributions of any form whatsoever must retain the following sl@0: * acknowledgment: sl@0: * "This product includes software developed by the OpenSSL Project sl@0: * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" sl@0: * sl@0: * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY sl@0: * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE sl@0: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR sl@0: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR sl@0: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, sl@0: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT sl@0: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; sl@0: * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) sl@0: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, sl@0: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) sl@0: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED sl@0: * OF THE POSSIBILITY OF SUCH DAMAGE. sl@0: * ==================================================================== sl@0: * sl@0: * This product includes cryptographic software written by Eric Young sl@0: * (eay@cryptsoft.com). This product includes software written by Tim sl@0: * Hudson (tjh@cryptsoft.com). sl@0: * sl@0: */ sl@0: /* ==================================================================== sl@0: * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. sl@0: * ECDH support in OpenSSL originally developed by sl@0: * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. sl@0: */ sl@0: sl@0: #ifndef HEADER_ENGINE_INT_H sl@0: #define HEADER_ENGINE_INT_H sl@0: sl@0: #include "cryptlib.h" sl@0: /* Take public definitions from engine.h */ sl@0: #include <openssl/engine.h> sl@0: sl@0: #ifdef __cplusplus sl@0: extern "C" { sl@0: #endif sl@0: sl@0: /* If we compile with this symbol defined, then both reference counts in the sl@0: * ENGINE structure will be monitored with a line of output on stderr for each sl@0: * change. This prints the engine's pointer address (truncated to unsigned int), sl@0: * "struct" or "funct" to indicate the reference type, the before and after sl@0: * reference count, and the file:line-number pair. The "engine_ref_debug" sl@0: * statements must come *after* the change. */ sl@0: #ifdef ENGINE_REF_COUNT_DEBUG sl@0: sl@0: #define engine_ref_debug(e, isfunct, diff) \ sl@0: fprintf(stderr, "engine: %08x %s from %d to %d (%s:%d)\n", \ sl@0: (unsigned int)(e), (isfunct ? "funct" : "struct"), \ sl@0: ((isfunct) ? ((e)->funct_ref - (diff)) : ((e)->struct_ref - (diff))), \ sl@0: ((isfunct) ? (e)->funct_ref : (e)->struct_ref), \ sl@0: (__FILE__), (__LINE__)); sl@0: sl@0: #else sl@0: sl@0: #define engine_ref_debug(e, isfunct, diff) sl@0: sl@0: #endif sl@0: sl@0: /* Any code that will need cleanup operations should use these functions to sl@0: * register callbacks. ENGINE_cleanup() will call all registered callbacks in sl@0: * order. NB: both the "add" functions assume CRYPTO_LOCK_ENGINE to already be sl@0: * held (in "write" mode). */ sl@0: typedef void (ENGINE_CLEANUP_CB)(void); sl@0: typedef struct st_engine_cleanup_item sl@0: { sl@0: ENGINE_CLEANUP_CB *cb; sl@0: } ENGINE_CLEANUP_ITEM; sl@0: DECLARE_STACK_OF(ENGINE_CLEANUP_ITEM) sl@0: IMPORT_C void engine_cleanup_add_first(ENGINE_CLEANUP_CB *cb); sl@0: IMPORT_C void engine_cleanup_add_last(ENGINE_CLEANUP_CB *cb); sl@0: sl@0: /* We need stacks of ENGINEs for use in eng_table.c */ sl@0: DECLARE_STACK_OF(ENGINE) sl@0: sl@0: /* If this symbol is defined then engine_table_select(), the function that is sl@0: * used by RSA, DSA (etc) code to select registered ENGINEs, cache defaults and sl@0: * functional references (etc), will display debugging summaries to stderr. */ sl@0: /* #define ENGINE_TABLE_DEBUG */ sl@0: sl@0: /* This represents an implementation table. Dependent code should instantiate it sl@0: * as a (ENGINE_TABLE *) pointer value set initially to NULL. */ sl@0: typedef struct st_engine_table ENGINE_TABLE; sl@0: IMPORT_C int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup, sl@0: ENGINE *e, const int *nids, int num_nids, int setdefault); sl@0: IMPORT_C void engine_table_unregister(ENGINE_TABLE **table, ENGINE *e); sl@0: IMPORT_C void engine_table_cleanup(ENGINE_TABLE **table); sl@0: #ifndef ENGINE_TABLE_DEBUG sl@0: IMPORT_C ENGINE *engine_table_select(ENGINE_TABLE **table, int nid); sl@0: #else sl@0: ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f, int l); sl@0: #define engine_table_select(t,n) engine_table_select_tmp(t,n,__FILE__,__LINE__) sl@0: #endif sl@0: sl@0: /* Internal versions of API functions that have control over locking. These are sl@0: * used between C files when functionality needs to be shared but the caller may sl@0: * already be controlling of the CRYPTO_LOCK_ENGINE lock. */ sl@0: IMPORT_C int engine_unlocked_init(ENGINE *e); sl@0: IMPORT_C int engine_unlocked_finish(ENGINE *e, int unlock_for_handlers); sl@0: IMPORT_C int engine_free_util(ENGINE *e, int locked); sl@0: sl@0: /* This function will reset all "set"able values in an ENGINE to NULL. This sl@0: * won't touch reference counts or ex_data, but is equivalent to calling all the sl@0: * ENGINE_set_***() functions with a NULL value. */ sl@0: IMPORT_C void engine_set_all_null(ENGINE *e); sl@0: sl@0: /* NB: Bitwise OR-able values for the "flags" variable in ENGINE are now exposed sl@0: * in engine.h. */ sl@0: sl@0: /* This is a structure for storing implementations of various crypto sl@0: * algorithms and functions. */ sl@0: struct engine_st sl@0: { sl@0: const char *id; sl@0: const char *name; sl@0: const RSA_METHOD *rsa_meth; sl@0: const DSA_METHOD *dsa_meth; sl@0: const DH_METHOD *dh_meth; sl@0: const ECDH_METHOD *ecdh_meth; sl@0: const ECDSA_METHOD *ecdsa_meth; sl@0: const RAND_METHOD *rand_meth; sl@0: const STORE_METHOD *store_meth; sl@0: /* Cipher handling is via this callback */ sl@0: ENGINE_CIPHERS_PTR ciphers; sl@0: /* Digest handling is via this callback */ sl@0: ENGINE_DIGESTS_PTR digests; sl@0: sl@0: sl@0: ENGINE_GEN_INT_FUNC_PTR destroy; sl@0: sl@0: ENGINE_GEN_INT_FUNC_PTR init; sl@0: ENGINE_GEN_INT_FUNC_PTR finish; sl@0: ENGINE_CTRL_FUNC_PTR ctrl; sl@0: ENGINE_LOAD_KEY_PTR load_privkey; sl@0: ENGINE_LOAD_KEY_PTR load_pubkey; sl@0: sl@0: const ENGINE_CMD_DEFN *cmd_defns; sl@0: int flags; sl@0: /* reference count on the structure itself */ sl@0: int struct_ref; sl@0: /* reference count on usability of the engine type. NB: This sl@0: * controls the loading and initialisation of any functionlity sl@0: * required by this engine, whereas the previous count is sl@0: * simply to cope with (de)allocation of this structure. Hence, sl@0: * running_ref <= struct_ref at all times. */ sl@0: int funct_ref; sl@0: /* A place to store per-ENGINE data */ sl@0: CRYPTO_EX_DATA ex_data; sl@0: /* Used to maintain the linked-list of engines. */ sl@0: struct engine_st *prev; sl@0: struct engine_st *next; sl@0: }; sl@0: sl@0: #ifdef __cplusplus sl@0: } sl@0: #endif sl@0: sl@0: #endif /* HEADER_ENGINE_INT_H */