From 9074521458c806464df2ffd185ab2bad7e3bfa2d Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Thu, 7 Feb 2002 20:02:49 +0000 Subject: [PATCH] Generate the individual engines' error strings and macros automatically. --- Makefile.org | 1 + crypto/engine/Makefile.ssl | 22 +++-- crypto/engine/hw.ec | 5 ++ crypto/engine/hw_atalla.c | 69 ++------------- crypto/engine/hw_atalla_err.c | 145 ++++++++++++++++++++++++++++++ crypto/engine/hw_atalla_err.h | 89 +++++++++++++++++++ crypto/engine/hw_cswift.c | 78 ++--------------- crypto/engine/hw_cswift_err.c | 149 +++++++++++++++++++++++++++++++ crypto/engine/hw_cswift_err.h | 93 ++++++++++++++++++++ crypto/engine/hw_ncipher.c | 92 ++----------------- crypto/engine/hw_ncipher_err.c | 156 +++++++++++++++++++++++++++++++++ crypto/engine/hw_ncipher_err.h | 100 +++++++++++++++++++++ crypto/engine/hw_nuron.c | 64 ++------------ crypto/engine/hw_nuron_err.c | 142 ++++++++++++++++++++++++++++++ crypto/engine/hw_nuron_err.h | 86 ++++++++++++++++++ crypto/engine/hw_ubsec.c | 80 ++--------------- crypto/engine/hw_ubsec_err.c | 151 +++++++++++++++++++++++++++++++ crypto/engine/hw_ubsec_err.h | 95 ++++++++++++++++++++ 18 files changed, 1252 insertions(+), 365 deletions(-) create mode 100644 crypto/engine/hw.ec create mode 100644 crypto/engine/hw_atalla_err.c create mode 100644 crypto/engine/hw_atalla_err.h create mode 100644 crypto/engine/hw_cswift_err.c create mode 100644 crypto/engine/hw_cswift_err.h create mode 100644 crypto/engine/hw_ncipher_err.c create mode 100644 crypto/engine/hw_ncipher_err.h create mode 100644 crypto/engine/hw_nuron_err.c create mode 100644 crypto/engine/hw_nuron_err.h create mode 100644 crypto/engine/hw_ubsec_err.c create mode 100644 crypto/engine/hw_ubsec_err.h diff --git a/Makefile.org b/Makefile.org index 5e642036e5..1ca0b28368 100644 --- a/Makefile.org +++ b/Makefile.org @@ -608,6 +608,7 @@ tags: errors: $(PERL) util/mkerr.pl -recurse -write + (cd crypto/engine; $(MAKE) PERL=$(PERL) errors) stacks: $(PERL) util/mkstack.pl -write diff --git a/crypto/engine/Makefile.ssl b/crypto/engine/Makefile.ssl index 5f19fb0bf8..f256e11181 100644 --- a/crypto/engine/Makefile.ssl +++ b/crypto/engine/Makefile.ssl @@ -28,13 +28,13 @@ LIBSRC= eng_err.c eng_lib.c eng_list.c eng_init.c eng_ctrl.c \ tb_rsa.c tb_dsa.c tb_dh.c tb_rand.c tb_cipher.c tb_digest.c \ eng_openssl.c eng_dyn.c eng_cnf.c \ hw_atalla.c hw_cswift.c hw_ncipher.c hw_nuron.c hw_ubsec.c \ - hw_openbsd_dev_crypto.c + hw_openbsd_dev_crypto.c #hw_aep.c hw_sureware.c LIBOBJ= eng_err.o eng_lib.o eng_list.o eng_init.o eng_ctrl.o \ eng_table.o eng_pkey.o eng_fat.o eng_all.o \ tb_rsa.o tb_dsa.o tb_dh.o tb_rand.o tb_cipher.o tb_digest.o \ eng_openssl.o eng_dyn.o eng_cnf.o \ hw_atalla.o hw_cswift.o hw_ncipher.o hw_nuron.o hw_ubsec.o \ - hw_openbsd_dev_crypto.o + hw_openbsd_dev_crypto.o #hw_aep.o hw_sureware.o SRC= $(LIBSRC) @@ -72,6 +72,10 @@ install: tags: ctags $(SRC) +errors: + $(PERL) $(TOP)/util/mkerr.pl -conf hw.ec \ + -nostatic -staticloader -write hw_*.c; \ + tests: lint: @@ -243,7 +247,8 @@ hw_atalla.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h hw_atalla.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h hw_atalla.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h hw_atalla.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h -hw_atalla.o: ../cryptlib.h hw_atalla.c vendor_defns/atalla.h +hw_atalla.o: ../cryptlib.h hw_atalla.c hw_atalla_err.c hw_atalla_err.h +hw_atalla.o: vendor_defns/atalla.h hw_cswift.o: ../../e_os.h ../../include/openssl/asn1.h hw_cswift.o: ../../include/openssl/bio.h ../../include/openssl/bn.h hw_cswift.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h @@ -255,7 +260,8 @@ hw_cswift.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h hw_cswift.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h hw_cswift.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h hw_cswift.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h -hw_cswift.o: ../cryptlib.h hw_cswift.c vendor_defns/cswift.h +hw_cswift.o: ../cryptlib.h hw_cswift.c hw_cswift_err.c hw_cswift_err.h +hw_cswift.o: vendor_defns/cswift.h hw_ncipher.o: ../../e_os.h ../../include/openssl/asn1.h hw_ncipher.o: ../../include/openssl/bio.h ../../include/openssl/bn.h hw_ncipher.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h @@ -272,7 +278,8 @@ hw_ncipher.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h hw_ncipher.o: ../../include/openssl/sha.h ../../include/openssl/stack.h hw_ncipher.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h hw_ncipher.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h -hw_ncipher.o: ../cryptlib.h hw_ncipher.c vendor_defns/hwcryptohook.h +hw_ncipher.o: ../cryptlib.h hw_ncipher.c hw_ncipher_err.c hw_ncipher_err.h +hw_ncipher.o: vendor_defns/hwcryptohook.h hw_nuron.o: ../../e_os.h ../../include/openssl/asn1.h hw_nuron.o: ../../include/openssl/bio.h ../../include/openssl/bn.h hw_nuron.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h @@ -284,7 +291,7 @@ hw_nuron.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h hw_nuron.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h hw_nuron.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h hw_nuron.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h -hw_nuron.o: ../cryptlib.h hw_nuron.c +hw_nuron.o: ../cryptlib.h hw_nuron.c hw_nuron_err.c hw_nuron_err.h hw_openbsd_dev_crypto.o: ../../include/openssl/asn1.h hw_openbsd_dev_crypto.o: ../../include/openssl/bio.h ../../include/openssl/bn.h hw_openbsd_dev_crypto.o: ../../include/openssl/conf.h @@ -318,7 +325,8 @@ hw_ubsec.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h hw_ubsec.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h hw_ubsec.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h hw_ubsec.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h -hw_ubsec.o: ../cryptlib.h hw_ubsec.c vendor_defns/hw_ubsec.h +hw_ubsec.o: ../cryptlib.h hw_ubsec.c hw_ubsec_err.c hw_ubsec_err.h +hw_ubsec.o: vendor_defns/hw_ubsec.h tb_cipher.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h tb_cipher.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h tb_cipher.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h diff --git a/crypto/engine/hw.ec b/crypto/engine/hw.ec new file mode 100644 index 0000000000..f0832daf32 --- /dev/null +++ b/crypto/engine/hw.ec @@ -0,0 +1,5 @@ +L ATALLA hw_atalla_err.h hw_atalla_err.c +L CSWIFT hw_cswift_err.h hw_cswift_err.c +L HWCRHK hw_ncipher_err.h hw_ncipher_err.c +L NURON hw_nuron_err.h hw_nuron_err.c +L UBSEC hw_ubsec_err.h hw_ubsec_err.c diff --git a/crypto/engine/hw_atalla.c b/crypto/engine/hw_atalla.c index 030d5a908c..696cfcf156 100644 --- a/crypto/engine/hw_atalla.c +++ b/crypto/engine/hw_atalla.c @@ -71,6 +71,9 @@ #include "vendor_defns/atalla.h" #endif +#define ATALLA_LIB_NAME "atalla engine" +#include "hw_atalla_err.c" + static int atalla_destroy(ENGINE *e); static int atalla_init(ENGINE *e); static int atalla_finish(ENGINE *e); @@ -168,68 +171,6 @@ static DH_METHOD atalla_dh = }; #endif -#ifndef OPENSSL_NO_ERR -/* Error function codes for use in atalla operation */ -#define ATALLA_F_ATALLA_INIT 100 -#define ATALLA_F_ATALLA_FINISH 101 -#define ATALLA_F_ATALLA_CTRL 102 -#define ATALLA_F_ATALLA_MOD_EXP 103 -#define ATALLA_F_ATALLA_RSA_MOD_EXP 104 -/* Error reason codes */ -#define ATALLA_R_ALREADY_LOADED 105 -#define ATALLA_R_NOT_LOADED 106 -#define ATALLA_R_UNIT_FAILURE 107 -#define ATALLA_R_CTRL_COMMAND_NOT_IMPLEMENTED 108 -#define ATALLA_R_BN_CTX_FULL 109 -#define ATALLA_R_BN_EXPAND_FAIL 110 -#define ATALLA_R_REQUEST_FAILED 111 -#define ATALLA_R_MISSING_KEY_COMPONENTS 112 -static ERR_STRING_DATA atalla_str_functs[] = - { - /* This first element is changed to match the dynamic 'lib' number */ -{ERR_PACK(0,0,0), "atalla engine code"}, -{ERR_PACK(0,ATALLA_F_ATALLA_INIT,0), "atalla_init"}, -{ERR_PACK(0,ATALLA_F_ATALLA_FINISH,0), "atalla_finish"}, -{ERR_PACK(0,ATALLA_F_ATALLA_CTRL,0), "atalla_ctrl"}, -{ERR_PACK(0,ATALLA_F_ATALLA_MOD_EXP,0), "atalla_mod_exp"}, -{ERR_PACK(0,ATALLA_F_ATALLA_RSA_MOD_EXP,0),"atalla_rsa_mod_exp"}, -{ATALLA_R_ALREADY_LOADED ,"already loaded"}, -{ATALLA_R_UNIT_FAILURE ,"unit failure"}, -{ATALLA_R_NOT_LOADED, "not loaded"}, -{ATALLA_R_CTRL_COMMAND_NOT_IMPLEMENTED ,"control command not implemented"}, -{ATALLA_R_BN_CTX_FULL ,"BN_CTX full"}, -{ATALLA_R_BN_EXPAND_FAIL ,"BN_expand failed"}, -{ATALLA_R_REQUEST_FAILED ,"request failed"}, -{ATALLA_R_MISSING_KEY_COMPONENTS ,"missing key components"}, -{0,NULL} - }; -/* The library number we obtain dynamically from the ERR code */ -static int atalla_err_lib = -1; -#define ATALLAerr(f,r) ERR_PUT_error(atalla_err_lib,(f),(r),__FILE__,__LINE__) -static void atalla_load_error_strings(void) - { - if (atalla_err_lib < 0) - { - if((atalla_err_lib = ERR_get_next_error_library()) <= 0) - return; - atalla_str_functs[0].error = ERR_PACK(atalla_err_lib, 0, 0); - ERR_load_strings(atalla_err_lib,atalla_str_functs); - } - } -static void atalla_unload_error_strings(void) - { - if (atalla_err_lib >= 0) - { - ERR_unload_strings(atalla_err_lib,atalla_str_functs); - atalla_err_lib = -1; - } - } -#else -#define ATALLAerr(f,r) /* NOP */ -static void atalla_load_error_strings(void) { } /* NOP */ -static void atalla_unload_error_strings(void) { } /* NOP */ -#endif - /* Constants used when creating the ENGINE */ static const char *engine_atalla_id = "atalla"; static const char *engine_atalla_name = "Atalla hardware engine support"; @@ -297,7 +238,7 @@ static int bind_helper(ENGINE *e) #endif /* Ensure the atalla error handling is set up */ - atalla_load_error_strings(); + ERR_load_ATALLA_strings(); return 1; } @@ -357,7 +298,7 @@ static int atalla_destroy(ENGINE *e) /* Unload the atalla error strings so any error state including our * functs or reasons won't lead to a segfault (they simply get displayed * without corresponding string data because none will be found). */ - atalla_unload_error_strings(); + ERR_unload_ATALLA_strings(); return 1; } diff --git a/crypto/engine/hw_atalla_err.c b/crypto/engine/hw_atalla_err.c new file mode 100644 index 0000000000..1df9c4570c --- /dev/null +++ b/crypto/engine/hw_atalla_err.c @@ -0,0 +1,145 @@ +/* hw_atalla_err.c */ +/* ==================================================================== + * Copyright (c) 1999 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +/* NOTE: this file was auto generated by the mkerr.pl script: any changes + * made to it will be overwritten when the script next updates this file, + * only reason strings will be preserved. + */ + +#include +#include +#include "hw_atalla_err.h" + +/* BEGIN ERROR CODES */ +#ifndef OPENSSL_NO_ERR +static ERR_STRING_DATA ATALLA_str_functs[]= + { +{ERR_PACK(0,ATALLA_F_ATALLA_CTRL,0), "ATALLA_CTRL"}, +{ERR_PACK(0,ATALLA_F_ATALLA_FINISH,0), "ATALLA_FINISH"}, +{ERR_PACK(0,ATALLA_F_ATALLA_INIT,0), "ATALLA_INIT"}, +{ERR_PACK(0,ATALLA_F_ATALLA_MOD_EXP,0), "ATALLA_MOD_EXP"}, +{ERR_PACK(0,ATALLA_F_ATALLA_RSA_MOD_EXP,0), "ATALLA_RSA_MOD_EXP"}, +{0,NULL} + }; + +static ERR_STRING_DATA ATALLA_str_reasons[]= + { +{ATALLA_R_ALREADY_LOADED ,"already loaded"}, +{ATALLA_R_BN_CTX_FULL ,"bn ctx full"}, +{ATALLA_R_BN_EXPAND_FAIL ,"bn expand fail"}, +{ATALLA_R_CTRL_COMMAND_NOT_IMPLEMENTED ,"ctrl command not implemented"}, +{ATALLA_R_MISSING_KEY_COMPONENTS ,"missing key components"}, +{ATALLA_R_NOT_LOADED ,"not loaded"}, +{ATALLA_R_REQUEST_FAILED ,"request failed"}, +{ATALLA_R_UNIT_FAILURE ,"unit failure"}, +{0,NULL} + }; + +#endif + +#ifdef ATALLA_LIB_NAME +static ERR_STRING_DATA ATALLA_lib_name[]= + { +{0 ,ATALLA_LIB_NAME}, +{0,NULL} + }; +#endif + + +static int ATALLA_lib_error_code=0; +static int ATALLA_error_init=1; + +static void ERR_load_ATALLA_strings(void) + { + if (ATALLA_lib_error_code == 0) + ATALLA_lib_error_code=ERR_get_next_error_library(); + + if (ATALLA_error_init) + { + ATALLA_error_init=0; +#ifndef OPENSSL_NO_ERR + ERR_load_strings(ATALLA_lib_error_code,ATALLA_str_functs); + ERR_load_strings(ATALLA_lib_error_code,ATALLA_str_reasons); +#endif + +#ifdef ATALLA_LIB_NAME + ATALLA_lib_name->error = ERR_PACK(ATALLA_lib_error_code,0,0); + ERR_load_strings(0,ATALLA_lib_name); +#endif + } + } + +static void ERR_unload_ATALLA_strings(void) + { + if (ATALLA_error_init == 0) + { +#ifndef OPENSSL_NO_ERR + ERR_unload_strings(ATALLA_lib_error_code,ATALLA_str_functs); + ERR_unload_strings(ATALLA_lib_error_code,ATALLA_str_reasons); +#endif + +#ifdef ATALLA_LIB_NAME + ERR_unload_strings(0,ATALLA_lib_name); +#endif + ATALLA_error_init=1; + } + } + +static void ERR_ATALLA_error(int function, int reason, char *file, int line) + { + if (ATALLA_lib_error_code == 0) + ATALLA_lib_error_code=ERR_get_next_error_library(); + ERR_PUT_error(ATALLA_lib_error_code,function,reason,file,line); + } diff --git a/crypto/engine/hw_atalla_err.h b/crypto/engine/hw_atalla_err.h new file mode 100644 index 0000000000..cdac052d8c --- /dev/null +++ b/crypto/engine/hw_atalla_err.h @@ -0,0 +1,89 @@ +/* ==================================================================== + * Copyright (c) 2001 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_ATALLA_ERR_H +#define HEADER_ATALLA_ERR_H + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +static void ERR_load_ATALLA_strings(void); +static void ERR_unload_ATALLA_strings(void); +static void ERR_ATALLA_error(int function, int reason, char *file, int line); +#define ATALLAerr(f,r) ERR_ATALLA_error((f),(r),__FILE__,__LINE__) + +/* Error codes for the ATALLA functions. */ + +/* Function codes. */ +#define ATALLA_F_ATALLA_CTRL 100 +#define ATALLA_F_ATALLA_FINISH 101 +#define ATALLA_F_ATALLA_INIT 102 +#define ATALLA_F_ATALLA_MOD_EXP 103 +#define ATALLA_F_ATALLA_RSA_MOD_EXP 104 + +/* Reason codes. */ +#define ATALLA_R_ALREADY_LOADED 100 +#define ATALLA_R_BN_CTX_FULL 101 +#define ATALLA_R_BN_EXPAND_FAIL 102 +#define ATALLA_R_CTRL_COMMAND_NOT_IMPLEMENTED 103 +#define ATALLA_R_MISSING_KEY_COMPONENTS 104 +#define ATALLA_R_NOT_LOADED 105 +#define ATALLA_R_REQUEST_FAILED 106 +#define ATALLA_R_UNIT_FAILURE 107 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/crypto/engine/hw_cswift.c b/crypto/engine/hw_cswift.c index d32a832be5..d8b380550f 100644 --- a/crypto/engine/hw_cswift.c +++ b/crypto/engine/hw_cswift.c @@ -83,6 +83,9 @@ #include "vendor_defns/cswift.h" #endif +#define CSWIFT_LIB_NAME "cswift engine" +#include "hw_cswift_err.c" + static int cswift_destroy(ENGINE *e); static int cswift_init(ENGINE *e); static int cswift_finish(ENGINE *e); @@ -180,77 +183,6 @@ static DH_METHOD cswift_dh = }; #endif -#ifndef OPENSSL_NO_ERR -/* Error function codes for use in cswift operation */ -#define CSWIFT_F_CSWIFT_INIT 100 -#define CSWIFT_F_CSWIFT_FINISH 101 -#define CSWIFT_F_CSWIFT_CTRL 102 -#define CSWIFT_F_CSWIFT_MOD_EXP 103 -#define CSWIFT_F_CSWIFT_MOD_EXP_CRT 104 -#define CSWIFT_F_CSWIFT_RSA_MOD_EXP 105 -#define CSWIFT_F_CSWIFT_DSA_SIGN 106 -#define CSWIFT_F_CSWIFT_DSA_VERIFY 107 -/* Error reason codes */ -#define CSWIFT_R_ALREADY_LOADED 108 -#define CSWIFT_R_NOT_LOADED 109 -#define CSWIFT_R_UNIT_FAILURE 110 -#define CSWIFT_R_CTRL_COMMAND_NOT_IMPLEMENTED 113 -#define CSWIFT_R_BN_CTX_FULL 115 -#define CSWIFT_R_BN_EXPAND_FAIL 116 -#define CSWIFT_R_BAD_KEY_SIZE 117 -#define CSWIFT_R_REQUEST_FAILED 118 -#define CSWIFT_R_MISSING_KEY_COMPONENTS 120 -static ERR_STRING_DATA cswift_str_functs[] = - { - /* This first element is changed to match the dynamic 'lib' number */ -{ERR_PACK(0,0,0), "cswift engine code"}, -{ERR_PACK(0,CSWIFT_F_CSWIFT_INIT,0), "cswift_init"}, -{ERR_PACK(0,CSWIFT_F_CSWIFT_FINISH,0), "cswift_finish"}, -{ERR_PACK(0,CSWIFT_F_CSWIFT_CTRL,0), "cswift_ctrl"}, -{ERR_PACK(0,CSWIFT_F_CSWIFT_MOD_EXP,0), "cswift_mod_exp"}, -{ERR_PACK(0,CSWIFT_F_CSWIFT_MOD_EXP_CRT,0), "cswift_mod_exp_crt"}, -{ERR_PACK(0,CSWIFT_F_CSWIFT_RSA_MOD_EXP,0), "cswift_rsa_mod_exp"}, -{ERR_PACK(0,CSWIFT_F_CSWIFT_DSA_SIGN,0), "cswift_dsa_sign"}, -{ERR_PACK(0,CSWIFT_F_CSWIFT_DSA_VERIFY,0), "cswift_dsa_verify"}, -/* Error reason codes */ -{CSWIFT_R_ALREADY_LOADED ,"already loaded"}, -{CSWIFT_R_NOT_LOADED ,"not loaded"}, -{CSWIFT_R_UNIT_FAILURE ,"unit failure"}, -{CSWIFT_R_CTRL_COMMAND_NOT_IMPLEMENTED ,"ctrl command not implemented"}, -{CSWIFT_R_BN_CTX_FULL ,"BN_CTX full"}, -{CSWIFT_R_BN_EXPAND_FAIL ,"bn_expand fail"}, -{CSWIFT_R_BAD_KEY_SIZE ,"bad key size"}, -{CSWIFT_R_REQUEST_FAILED ,"request failed"}, -{CSWIFT_R_MISSING_KEY_COMPONENTS ,"missing key components"}, -{0,NULL} - }; -/* The library number we obtain dynamically from the ERR code */ -static int cswift_err_lib = -1; -#define CSWIFTerr(f,r) ERR_PUT_error(cswift_err_lib,(f),(r),__FILE__,__LINE__) -static void cswift_load_error_strings(void) - { - if(cswift_err_lib < 0) - { - if((cswift_err_lib = ERR_get_next_error_library()) <= 0) - return; - cswift_str_functs[0].error = ERR_PACK(cswift_err_lib,0,0); - ERR_load_strings(cswift_err_lib, cswift_str_functs); - } - } -static void cswift_unload_error_strings(void) - { - if(cswift_err_lib >= 0) - { - ERR_unload_strings(cswift_err_lib, cswift_str_functs); - cswift_err_lib = -1; - } - } -#else -#define CSWIFTerr(f,r) /* NOP */ -static void cswift_load_error_strings(void) { } /* NOP */ -static void cswift_unload_error_strings(void) { } /* NOP */ -#endif - /* Constants used when creating the ENGINE */ static const char *engine_cswift_id = "cswift"; static const char *engine_cswift_name = "CryptoSwift hardware engine support"; @@ -306,7 +238,7 @@ static int bind_helper(ENGINE *e) #endif /* Ensure the cswift error handling is set up */ - cswift_load_error_strings(); + ERR_load_CSWIFT_strings(); return 1; } @@ -381,7 +313,7 @@ static void release_context(SW_CONTEXT_HANDLE hac) /* Destructor (complements the "ENGINE_cswift()" constructor) */ static int cswift_destroy(ENGINE *e) { - cswift_unload_error_strings(); + ERR_unload_CSWIFT_strings(); return 1; } diff --git a/crypto/engine/hw_cswift_err.c b/crypto/engine/hw_cswift_err.c new file mode 100644 index 0000000000..684f53bf27 --- /dev/null +++ b/crypto/engine/hw_cswift_err.c @@ -0,0 +1,149 @@ +/* hw_cswift_err.c */ +/* ==================================================================== + * Copyright (c) 1999 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +/* NOTE: this file was auto generated by the mkerr.pl script: any changes + * made to it will be overwritten when the script next updates this file, + * only reason strings will be preserved. + */ + +#include +#include +#include "hw_cswift_err.h" + +/* BEGIN ERROR CODES */ +#ifndef OPENSSL_NO_ERR +static ERR_STRING_DATA CSWIFT_str_functs[]= + { +{ERR_PACK(0,CSWIFT_F_CSWIFT_CTRL,0), "CSWIFT_CTRL"}, +{ERR_PACK(0,CSWIFT_F_CSWIFT_DSA_SIGN,0), "CSWIFT_DSA_SIGN"}, +{ERR_PACK(0,CSWIFT_F_CSWIFT_DSA_VERIFY,0), "CSWIFT_DSA_VERIFY"}, +{ERR_PACK(0,CSWIFT_F_CSWIFT_FINISH,0), "CSWIFT_FINISH"}, +{ERR_PACK(0,CSWIFT_F_CSWIFT_INIT,0), "CSWIFT_INIT"}, +{ERR_PACK(0,CSWIFT_F_CSWIFT_MOD_EXP,0), "CSWIFT_MOD_EXP"}, +{ERR_PACK(0,CSWIFT_F_CSWIFT_MOD_EXP_CRT,0), "CSWIFT_MOD_EXP_CRT"}, +{ERR_PACK(0,CSWIFT_F_CSWIFT_RSA_MOD_EXP,0), "CSWIFT_RSA_MOD_EXP"}, +{0,NULL} + }; + +static ERR_STRING_DATA CSWIFT_str_reasons[]= + { +{CSWIFT_R_ALREADY_LOADED ,"already loaded"}, +{CSWIFT_R_BAD_KEY_SIZE ,"bad key size"}, +{CSWIFT_R_BN_CTX_FULL ,"bn ctx full"}, +{CSWIFT_R_BN_EXPAND_FAIL ,"bn expand fail"}, +{CSWIFT_R_CTRL_COMMAND_NOT_IMPLEMENTED ,"ctrl command not implemented"}, +{CSWIFT_R_MISSING_KEY_COMPONENTS ,"missing key components"}, +{CSWIFT_R_NOT_LOADED ,"not loaded"}, +{CSWIFT_R_REQUEST_FAILED ,"request failed"}, +{CSWIFT_R_UNIT_FAILURE ,"unit failure"}, +{0,NULL} + }; + +#endif + +#ifdef CSWIFT_LIB_NAME +static ERR_STRING_DATA CSWIFT_lib_name[]= + { +{0 ,CSWIFT_LIB_NAME}, +{0,NULL} + }; +#endif + + +static int CSWIFT_lib_error_code=0; +static int CSWIFT_error_init=1; + +static void ERR_load_CSWIFT_strings(void) + { + if (CSWIFT_lib_error_code == 0) + CSWIFT_lib_error_code=ERR_get_next_error_library(); + + if (CSWIFT_error_init) + { + CSWIFT_error_init=0; +#ifndef OPENSSL_NO_ERR + ERR_load_strings(CSWIFT_lib_error_code,CSWIFT_str_functs); + ERR_load_strings(CSWIFT_lib_error_code,CSWIFT_str_reasons); +#endif + +#ifdef CSWIFT_LIB_NAME + CSWIFT_lib_name->error = ERR_PACK(CSWIFT_lib_error_code,0,0); + ERR_load_strings(0,CSWIFT_lib_name); +#endif + } + } + +static void ERR_unload_CSWIFT_strings(void) + { + if (CSWIFT_error_init == 0) + { +#ifndef OPENSSL_NO_ERR + ERR_unload_strings(CSWIFT_lib_error_code,CSWIFT_str_functs); + ERR_unload_strings(CSWIFT_lib_error_code,CSWIFT_str_reasons); +#endif + +#ifdef CSWIFT_LIB_NAME + ERR_unload_strings(0,CSWIFT_lib_name); +#endif + CSWIFT_error_init=1; + } + } + +static void ERR_CSWIFT_error(int function, int reason, char *file, int line) + { + if (CSWIFT_lib_error_code == 0) + CSWIFT_lib_error_code=ERR_get_next_error_library(); + ERR_PUT_error(CSWIFT_lib_error_code,function,reason,file,line); + } diff --git a/crypto/engine/hw_cswift_err.h b/crypto/engine/hw_cswift_err.h new file mode 100644 index 0000000000..7120c3216f --- /dev/null +++ b/crypto/engine/hw_cswift_err.h @@ -0,0 +1,93 @@ +/* ==================================================================== + * Copyright (c) 2001 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_CSWIFT_ERR_H +#define HEADER_CSWIFT_ERR_H + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +static void ERR_load_CSWIFT_strings(void); +static void ERR_unload_CSWIFT_strings(void); +static void ERR_CSWIFT_error(int function, int reason, char *file, int line); +#define CSWIFTerr(f,r) ERR_CSWIFT_error((f),(r),__FILE__,__LINE__) + +/* Error codes for the CSWIFT functions. */ + +/* Function codes. */ +#define CSWIFT_F_CSWIFT_CTRL 100 +#define CSWIFT_F_CSWIFT_DSA_SIGN 101 +#define CSWIFT_F_CSWIFT_DSA_VERIFY 102 +#define CSWIFT_F_CSWIFT_FINISH 103 +#define CSWIFT_F_CSWIFT_INIT 104 +#define CSWIFT_F_CSWIFT_MOD_EXP 105 +#define CSWIFT_F_CSWIFT_MOD_EXP_CRT 106 +#define CSWIFT_F_CSWIFT_RSA_MOD_EXP 107 + +/* Reason codes. */ +#define CSWIFT_R_ALREADY_LOADED 100 +#define CSWIFT_R_BAD_KEY_SIZE 101 +#define CSWIFT_R_BN_CTX_FULL 102 +#define CSWIFT_R_BN_EXPAND_FAIL 103 +#define CSWIFT_R_CTRL_COMMAND_NOT_IMPLEMENTED 104 +#define CSWIFT_R_MISSING_KEY_COMPONENTS 105 +#define CSWIFT_R_NOT_LOADED 106 +#define CSWIFT_R_REQUEST_FAILED 107 +#define CSWIFT_R_UNIT_FAILURE 108 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/crypto/engine/hw_ncipher.c b/crypto/engine/hw_ncipher.c index 5f10c0826d..4762a54e3d 100644 --- a/crypto/engine/hw_ncipher.c +++ b/crypto/engine/hw_ncipher.c @@ -83,6 +83,9 @@ #include "vendor_defns/hwcryptohook.h" #endif +#define HWCRHK_LIB_NAME "hwcrhk engine" +#include "hw_ncipher_err.c" + static int hwcrhk_destroy(ENGINE *e); static int hwcrhk_init(ENGINE *e); static int hwcrhk_finish(ENGINE *e); @@ -211,91 +214,6 @@ static RAND_METHOD hwcrhk_rand = hwcrhk_rand_status, }; -#ifndef OPENSSL_NO_ERR -/* Error function codes for use in hwcrhk operation */ -#define HWCRHK_F_HWCRHK_INIT 100 -#define HWCRHK_F_HWCRHK_FINISH 101 -#define HWCRHK_F_HWCRHK_CTRL 102 -#define HWCRHK_F_HWCRHK_LOAD_PRIVKEY 103 -#define HWCRHK_F_HWCRHK_LOAD_PUBKEY 104 -#define HWCRHK_F_HWCRHK_MOD_EXP 105 -#define HWCRHK_F_HWCRHK_RSA_MOD_EXP 106 -#define HWCRHK_F_HWCRHK_RAND_BYTES 107 -#define HWCRHK_F_HWCRHK_GET_PASS 108 -#define HWCRHK_F_HWCRHK_INSERT_CARD 109 -/* Error reason codes */ -#define HWCRHK_R_ALREADY_LOADED 110 -#define HWCRHK_R_DSO_FAILURE 111 -#define HWCRHK_R_UNIT_FAILURE 112 -#define HWCRHK_R_NOT_LOADED 113 -#define HWCRHK_R_BIO_WAS_FREED 114 -#define HWCRHK_R_CTRL_COMMAND_NOT_IMPLEMENTED 115 -#define HWCRHK_R_NOT_INITIALISED 116 -#define HWCRHK_R_CHIL_ERROR 117 -#define HWCRHK_R_NO_KEY 118 -#define HWCRHK_R_PRIVATE_KEY_ALGORITHMS_DISABLED 119 -#define HWCRHK_R_REQUEST_FALLBACK 120 -#define HWCRHK_R_REQUEST_FAILED 121 -#define HWCRHK_R_MISSING_KEY_COMPONENTS 122 -#define HWCRHK_R_NO_CALLBACK 123 -static ERR_STRING_DATA hwcrhk_str_functs[] = - { - /* This first element is changed to match the dynamic 'lib' number */ -{ERR_PACK(0,0,0), "hwcrhk engine code"}, -{ERR_PACK(0,HWCRHK_F_HWCRHK_INIT,0), "hwcrhk_init"}, -{ERR_PACK(0,HWCRHK_F_HWCRHK_FINISH,0), ""}, -{ERR_PACK(0,HWCRHK_F_HWCRHK_CTRL,0), ""}, -{ERR_PACK(0,HWCRHK_F_HWCRHK_LOAD_PRIVKEY,0), ""}, -{ERR_PACK(0,HWCRHK_F_HWCRHK_LOAD_PUBKEY,0), ""}, -{ERR_PACK(0,HWCRHK_F_HWCRHK_MOD_EXP,0), ""}, -{ERR_PACK(0,HWCRHK_F_HWCRHK_RSA_MOD_EXP,0), ""}, -{ERR_PACK(0,HWCRHK_F_HWCRHK_RAND_BYTES,0), ""}, -{ERR_PACK(0,HWCRHK_F_HWCRHK_GET_PASS,0), ""}, -{ERR_PACK(0,HWCRHK_F_HWCRHK_INSERT_CARD,0), ""}, -/* Error reason codes */ -{HWCRHK_R_ALREADY_LOADED ,"already loaded"}, -{HWCRHK_R_DSO_FAILURE ,"DSO failure"}, -{HWCRHK_R_UNIT_FAILURE ,"unit failure"}, -{HWCRHK_R_NOT_LOADED ,"not loaded"}, -{HWCRHK_R_BIO_WAS_FREED ,"BIO was freed"}, -{HWCRHK_R_CTRL_COMMAND_NOT_IMPLEMENTED ,"ctrl command not implemented"}, -{HWCRHK_R_NOT_INITIALISED ,"not initialised"}, -{HWCRHK_R_CHIL_ERROR ,"'chil' error"}, -{HWCRHK_R_NO_KEY ,"no key"}, -{HWCRHK_R_PRIVATE_KEY_ALGORITHMS_DISABLED,"private key algorithms disabled"}, -{HWCRHK_R_REQUEST_FALLBACK ,"request fallback"}, -{HWCRHK_R_REQUEST_FAILED ,"request failed"}, -{HWCRHK_R_MISSING_KEY_COMPONENTS ,"missing key components"}, -{HWCRHK_R_NO_CALLBACK ,"no callback"}, -{0,NULL} - }; -/* The library number we obtain dynamically from the ERR code */ -static int hwcrhk_err_lib = -1; -#define HWCRHKerr(f,r) ERR_PUT_error(hwcrhk_err_lib,(f),(r),__FILE__,__LINE__) -static void hwcrhk_load_error_strings(void) - { - if(hwcrhk_err_lib < 0) - { - if((hwcrhk_err_lib = ERR_get_next_error_library()) <= 0) - return; - hwcrhk_str_functs[0].error = ERR_PACK(hwcrhk_err_lib,0,0); - ERR_load_strings(hwcrhk_err_lib, hwcrhk_str_functs); - } - } -static void hwcrhk_unload_error_strings(void) - { - if(hwcrhk_err_lib >= 0) - { - ERR_unload_strings(hwcrhk_err_lib, hwcrhk_str_functs); - hwcrhk_err_lib = -1; - } - } -#else -#define HWCRHKerr(f,r) /* NOP */ -static void hwcrhk_load_error_strings(void) { } /* NOP */ -static void hwcrhk_unload_error_strings(void) { } /* NOP */ -#endif - /* Constants used when creating the ENGINE */ static const char *engine_hwcrhk_id = "chil"; static const char *engine_hwcrhk_name = "nCipher hardware engine support"; @@ -449,7 +367,7 @@ static int bind_helper(ENGINE *e) #endif /* Ensure the hwcrhk error handling is set up */ - hwcrhk_load_error_strings(); + ERR_load_HWCRHK_strings(); return 1; } @@ -551,7 +469,7 @@ static void release_context(HWCryptoHook_ContextHandle hac) /* Destructor (complements the "ENGINE_ncipher()" constructor) */ static int hwcrhk_destroy(ENGINE *e) { - hwcrhk_unload_error_strings(); + ERR_unload_HWCRHK_strings(); return 1; } diff --git a/crypto/engine/hw_ncipher_err.c b/crypto/engine/hw_ncipher_err.c new file mode 100644 index 0000000000..24024cfc6f --- /dev/null +++ b/crypto/engine/hw_ncipher_err.c @@ -0,0 +1,156 @@ +/* hw_ncipher_err.c */ +/* ==================================================================== + * Copyright (c) 1999 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +/* NOTE: this file was auto generated by the mkerr.pl script: any changes + * made to it will be overwritten when the script next updates this file, + * only reason strings will be preserved. + */ + +#include +#include +#include "hw_ncipher_err.h" + +/* BEGIN ERROR CODES */ +#ifndef OPENSSL_NO_ERR +static ERR_STRING_DATA HWCRHK_str_functs[]= + { +{ERR_PACK(0,HWCRHK_F_HWCRHK_CTRL,0), "HWCRHK_CTRL"}, +{ERR_PACK(0,HWCRHK_F_HWCRHK_FINISH,0), "HWCRHK_FINISH"}, +{ERR_PACK(0,HWCRHK_F_HWCRHK_GET_PASS,0), "HWCRHK_GET_PASS"}, +{ERR_PACK(0,HWCRHK_F_HWCRHK_INIT,0), "HWCRHK_INIT"}, +{ERR_PACK(0,HWCRHK_F_HWCRHK_INSERT_CARD,0), "HWCRHK_INSERT_CARD"}, +{ERR_PACK(0,HWCRHK_F_HWCRHK_LOAD_PRIVKEY,0), "HWCRHK_LOAD_PRIVKEY"}, +{ERR_PACK(0,HWCRHK_F_HWCRHK_LOAD_PUBKEY,0), "HWCRHK_LOAD_PUBKEY"}, +{ERR_PACK(0,HWCRHK_F_HWCRHK_MOD_EXP,0), "HWCRHK_MOD_EXP"}, +{ERR_PACK(0,HWCRHK_F_HWCRHK_RAND_BYTES,0), "HWCRHK_RAND_BYTES"}, +{ERR_PACK(0,HWCRHK_F_HWCRHK_RSA_MOD_EXP,0), "HWCRHK_RSA_MOD_EXP"}, +{0,NULL} + }; + +static ERR_STRING_DATA HWCRHK_str_reasons[]= + { +{HWCRHK_R_ALREADY_LOADED ,"already loaded"}, +{HWCRHK_R_BIO_WAS_FREED ,"bio was freed"}, +{HWCRHK_R_CHIL_ERROR ,"chil error"}, +{HWCRHK_R_CTRL_COMMAND_NOT_IMPLEMENTED ,"ctrl command not implemented"}, +{HWCRHK_R_DSO_FAILURE ,"dso failure"}, +{HWCRHK_R_MISSING_KEY_COMPONENTS ,"missing key components"}, +{HWCRHK_R_NOT_INITIALISED ,"not initialised"}, +{HWCRHK_R_NOT_LOADED ,"not loaded"}, +{HWCRHK_R_NO_CALLBACK ,"no callback"}, +{HWCRHK_R_NO_KEY ,"no key"}, +{HWCRHK_R_PRIVATE_KEY_ALGORITHMS_DISABLED,"private key algorithms disabled"}, +{HWCRHK_R_REQUEST_FAILED ,"request failed"}, +{HWCRHK_R_REQUEST_FALLBACK ,"request fallback"}, +{HWCRHK_R_UNIT_FAILURE ,"unit failure"}, +{0,NULL} + }; + +#endif + +#ifdef HWCRHK_LIB_NAME +static ERR_STRING_DATA HWCRHK_lib_name[]= + { +{0 ,HWCRHK_LIB_NAME}, +{0,NULL} + }; +#endif + + +static int HWCRHK_lib_error_code=0; +static int HWCRHK_error_init=1; + +static void ERR_load_HWCRHK_strings(void) + { + if (HWCRHK_lib_error_code == 0) + HWCRHK_lib_error_code=ERR_get_next_error_library(); + + if (HWCRHK_error_init) + { + HWCRHK_error_init=0; +#ifndef OPENSSL_NO_ERR + ERR_load_strings(HWCRHK_lib_error_code,HWCRHK_str_functs); + ERR_load_strings(HWCRHK_lib_error_code,HWCRHK_str_reasons); +#endif + +#ifdef HWCRHK_LIB_NAME + HWCRHK_lib_name->error = ERR_PACK(HWCRHK_lib_error_code,0,0); + ERR_load_strings(0,HWCRHK_lib_name); +#endif + } + } + +static void ERR_unload_HWCRHK_strings(void) + { + if (HWCRHK_error_init == 0) + { +#ifndef OPENSSL_NO_ERR + ERR_unload_strings(HWCRHK_lib_error_code,HWCRHK_str_functs); + ERR_unload_strings(HWCRHK_lib_error_code,HWCRHK_str_reasons); +#endif + +#ifdef HWCRHK_LIB_NAME + ERR_unload_strings(0,HWCRHK_lib_name); +#endif + HWCRHK_error_init=1; + } + } + +static void ERR_HWCRHK_error(int function, int reason, char *file, int line) + { + if (HWCRHK_lib_error_code == 0) + HWCRHK_lib_error_code=ERR_get_next_error_library(); + ERR_PUT_error(HWCRHK_lib_error_code,function,reason,file,line); + } diff --git a/crypto/engine/hw_ncipher_err.h b/crypto/engine/hw_ncipher_err.h new file mode 100644 index 0000000000..4d65b1d470 --- /dev/null +++ b/crypto/engine/hw_ncipher_err.h @@ -0,0 +1,100 @@ +/* ==================================================================== + * Copyright (c) 2001 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_HWCRHK_ERR_H +#define HEADER_HWCRHK_ERR_H + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +static void ERR_load_HWCRHK_strings(void); +static void ERR_unload_HWCRHK_strings(void); +static void ERR_HWCRHK_error(int function, int reason, char *file, int line); +#define HWCRHKerr(f,r) ERR_HWCRHK_error((f),(r),__FILE__,__LINE__) + +/* Error codes for the HWCRHK functions. */ + +/* Function codes. */ +#define HWCRHK_F_HWCRHK_CTRL 100 +#define HWCRHK_F_HWCRHK_FINISH 101 +#define HWCRHK_F_HWCRHK_GET_PASS 102 +#define HWCRHK_F_HWCRHK_INIT 103 +#define HWCRHK_F_HWCRHK_INSERT_CARD 104 +#define HWCRHK_F_HWCRHK_LOAD_PRIVKEY 105 +#define HWCRHK_F_HWCRHK_LOAD_PUBKEY 106 +#define HWCRHK_F_HWCRHK_MOD_EXP 107 +#define HWCRHK_F_HWCRHK_RAND_BYTES 108 +#define HWCRHK_F_HWCRHK_RSA_MOD_EXP 109 + +/* Reason codes. */ +#define HWCRHK_R_ALREADY_LOADED 100 +#define HWCRHK_R_BIO_WAS_FREED 101 +#define HWCRHK_R_CHIL_ERROR 102 +#define HWCRHK_R_CTRL_COMMAND_NOT_IMPLEMENTED 103 +#define HWCRHK_R_DSO_FAILURE 104 +#define HWCRHK_R_MISSING_KEY_COMPONENTS 105 +#define HWCRHK_R_NOT_INITIALISED 106 +#define HWCRHK_R_NOT_LOADED 107 +#define HWCRHK_R_NO_CALLBACK 108 +#define HWCRHK_R_NO_KEY 109 +#define HWCRHK_R_PRIVATE_KEY_ALGORITHMS_DISABLED 110 +#define HWCRHK_R_REQUEST_FAILED 111 +#define HWCRHK_R_REQUEST_FALLBACK 112 +#define HWCRHK_R_UNIT_FAILURE 113 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/crypto/engine/hw_nuron.c b/crypto/engine/hw_nuron.c index 784c1a41f2..2672012154 100644 --- a/crypto/engine/hw_nuron.c +++ b/crypto/engine/hw_nuron.c @@ -66,6 +66,9 @@ #ifndef OPENSSL_NO_HW #ifndef OPENSSL_NO_HW_NURON +#define NURON_LIB_NAME "nuron engine" +#include "hw_nuron_err.c" + static const char def_NURON_LIBNAME[] = "nuronssl"; static const char *NURON_LIBNAME = def_NURON_LIBNAME; static const char *NURON_F1 = "nuron_mod_exp"; @@ -80,63 +83,6 @@ static const ENGINE_CMD_DEFN nuron_cmd_defns[] = { {0, NULL, NULL, 0} }; -#ifndef OPENSSL_NO_ERR -/* Error function codes for use in nuron operation */ -#define NURON_F_NURON_INIT 100 -#define NURON_F_NURON_FINISH 101 -#define NURON_F_NURON_CTRL 102 -#define NURON_F_NURON_MOD_EXP 103 -/* Error reason codes */ -#define NURON_R_ALREADY_LOADED 104 -#define NURON_R_DSO_NOT_FOUND 105 -#define NURON_R_DSO_FUNCTION_NOT_FOUND 106 -#define NURON_R_NOT_LOADED 107 -#define NURON_R_DSO_FAILURE 108 -#define NURON_R_CTRL_COMMAND_NOT_IMPLEMENTED 109 -static ERR_STRING_DATA nuron_str_functs[] = - { - /* This first element is changed to match the dynamic 'lib' number */ -{ERR_PACK(0,0,0), "nuron engine code"}, -{ERR_PACK(0,NURON_F_NURON_INIT,0), "nuron_init"}, -{ERR_PACK(0,NURON_F_NURON_FINISH,0), "nuron_finish"}, -{ERR_PACK(0,NURON_F_NURON_CTRL,0), "nuron_ctrl"}, -{ERR_PACK(0,NURON_F_NURON_MOD_EXP,0), "nuron_mod_exp"}, -/* Error reason codes */ -{NURON_R_ALREADY_LOADED ,"already loaded"}, -{NURON_R_DSO_NOT_FOUND ,"DSO not found"}, -{NURON_R_DSO_FUNCTION_NOT_FOUND ,"DSO function not found"}, -{NURON_R_NOT_LOADED ,"not loaded"}, -{NURON_R_DSO_FAILURE ,"DSO failure"}, -{NURON_R_CTRL_COMMAND_NOT_IMPLEMENTED ,"ctrl command not implemented"}, -{0,NULL} - }; -/* The library number we obtain dynamically from the ERR code */ -static int nuron_err_lib = -1; -#define NURONerr(f,r) ERR_PUT_error(nuron_err_lib,(f),(r),__FILE__,__LINE__) -static void nuron_load_error_strings(void) - { - if(nuron_err_lib < 0) - { - if((nuron_err_lib = ERR_get_next_error_library()) <= 0) - return; - nuron_str_functs[0].error = ERR_PACK(nuron_err_lib,0,0); - ERR_load_strings(nuron_err_lib, nuron_str_functs); - } - } -static void nuron_unload_error_strings(void) - { - if(nuron_err_lib >= 0) - { - ERR_unload_strings(nuron_err_lib, nuron_str_functs); - nuron_err_lib = -1; - } - } -#else -#define NURONerr(f,r) /* NOP */ -static void nuron_load_error_strings(void) { } /* NOP */ -static void nuron_unload_error_strings(void) { } /* NOP */ -#endif - typedef int tfnModExp(BIGNUM *r,const BIGNUM *a,const BIGNUM *p,const BIGNUM *m); static tfnModExp *pfnModExp = NULL; @@ -144,7 +90,7 @@ static DSO *pvDSOHandle = NULL; static int nuron_destroy(ENGINE *e) { - nuron_unload_error_strings(); + ERR_unload_NURON_strings(); return 1; } @@ -407,7 +353,7 @@ static int bind_helper(ENGINE *e) #endif /* Ensure the nuron error handling is set up */ - nuron_load_error_strings(); + ERR_load_NURON_strings(); return 1; } diff --git a/crypto/engine/hw_nuron_err.c b/crypto/engine/hw_nuron_err.c new file mode 100644 index 0000000000..df9d7bde76 --- /dev/null +++ b/crypto/engine/hw_nuron_err.c @@ -0,0 +1,142 @@ +/* hw_nuron_err.c */ +/* ==================================================================== + * Copyright (c) 1999 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +/* NOTE: this file was auto generated by the mkerr.pl script: any changes + * made to it will be overwritten when the script next updates this file, + * only reason strings will be preserved. + */ + +#include +#include +#include "hw_nuron_err.h" + +/* BEGIN ERROR CODES */ +#ifndef OPENSSL_NO_ERR +static ERR_STRING_DATA NURON_str_functs[]= + { +{ERR_PACK(0,NURON_F_NURON_CTRL,0), "NURON_CTRL"}, +{ERR_PACK(0,NURON_F_NURON_FINISH,0), "NURON_FINISH"}, +{ERR_PACK(0,NURON_F_NURON_INIT,0), "NURON_INIT"}, +{ERR_PACK(0,NURON_F_NURON_MOD_EXP,0), "NURON_MOD_EXP"}, +{0,NULL} + }; + +static ERR_STRING_DATA NURON_str_reasons[]= + { +{NURON_R_ALREADY_LOADED ,"already loaded"}, +{NURON_R_CTRL_COMMAND_NOT_IMPLEMENTED ,"ctrl command not implemented"}, +{NURON_R_DSO_FAILURE ,"dso failure"}, +{NURON_R_DSO_FUNCTION_NOT_FOUND ,"dso function not found"}, +{NURON_R_DSO_NOT_FOUND ,"dso not found"}, +{NURON_R_NOT_LOADED ,"not loaded"}, +{0,NULL} + }; + +#endif + +#ifdef NURON_LIB_NAME +static ERR_STRING_DATA NURON_lib_name[]= + { +{0 ,NURON_LIB_NAME}, +{0,NULL} + }; +#endif + + +static int NURON_lib_error_code=0; +static int NURON_error_init=1; + +static void ERR_load_NURON_strings(void) + { + if (NURON_lib_error_code == 0) + NURON_lib_error_code=ERR_get_next_error_library(); + + if (NURON_error_init) + { + NURON_error_init=0; +#ifndef OPENSSL_NO_ERR + ERR_load_strings(NURON_lib_error_code,NURON_str_functs); + ERR_load_strings(NURON_lib_error_code,NURON_str_reasons); +#endif + +#ifdef NURON_LIB_NAME + NURON_lib_name->error = ERR_PACK(NURON_lib_error_code,0,0); + ERR_load_strings(0,NURON_lib_name); +#endif + } + } + +static void ERR_unload_NURON_strings(void) + { + if (NURON_error_init == 0) + { +#ifndef OPENSSL_NO_ERR + ERR_unload_strings(NURON_lib_error_code,NURON_str_functs); + ERR_unload_strings(NURON_lib_error_code,NURON_str_reasons); +#endif + +#ifdef NURON_LIB_NAME + ERR_unload_strings(0,NURON_lib_name); +#endif + NURON_error_init=1; + } + } + +static void ERR_NURON_error(int function, int reason, char *file, int line) + { + if (NURON_lib_error_code == 0) + NURON_lib_error_code=ERR_get_next_error_library(); + ERR_PUT_error(NURON_lib_error_code,function,reason,file,line); + } diff --git a/crypto/engine/hw_nuron_err.h b/crypto/engine/hw_nuron_err.h new file mode 100644 index 0000000000..a56bfdf303 --- /dev/null +++ b/crypto/engine/hw_nuron_err.h @@ -0,0 +1,86 @@ +/* ==================================================================== + * Copyright (c) 2001 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_NURON_ERR_H +#define HEADER_NURON_ERR_H + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +static void ERR_load_NURON_strings(void); +static void ERR_unload_NURON_strings(void); +static void ERR_NURON_error(int function, int reason, char *file, int line); +#define NURONerr(f,r) ERR_NURON_error((f),(r),__FILE__,__LINE__) + +/* Error codes for the NURON functions. */ + +/* Function codes. */ +#define NURON_F_NURON_CTRL 100 +#define NURON_F_NURON_FINISH 101 +#define NURON_F_NURON_INIT 102 +#define NURON_F_NURON_MOD_EXP 103 + +/* Reason codes. */ +#define NURON_R_ALREADY_LOADED 100 +#define NURON_R_CTRL_COMMAND_NOT_IMPLEMENTED 101 +#define NURON_R_DSO_FAILURE 102 +#define NURON_R_DSO_FUNCTION_NOT_FOUND 103 +#define NURON_R_DSO_NOT_FOUND 104 +#define NURON_R_NOT_LOADED 105 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/crypto/engine/hw_ubsec.c b/crypto/engine/hw_ubsec.c index afdee37f0b..7557c950d0 100644 --- a/crypto/engine/hw_ubsec.c +++ b/crypto/engine/hw_ubsec.c @@ -73,6 +73,9 @@ #include "vendor_defns/hw_ubsec.h" #endif +#define UBSEC_LIB_NAME "ubsec engine" +#include "hw_ubsec_err.c" + #define FAIL_TO_SOFTWARE -15 static int ubsec_destroy(ENGINE *e); @@ -176,79 +179,6 @@ static DH_METHOD ubsec_dh = }; #endif -#ifndef OPENSSL_NO_ERR -/* Error function codes for use in ubsec operation */ -#define UBSEC_F_UBSEC_INIT 100 -#define UBSEC_F_UBSEC_FINISH 101 -#define UBSEC_F_UBSEC_CTRL 102 -#define UBSEC_F_UBSEC_MOD_EXP 103 -#define UBSEC_F_UBSEC_RSA_MOD_EXP 104 -#define UBSEC_F_UBSEC_RSA_MOD_EXP_CRT 105 -#define UBSEC_F_UBSEC_DSA_SIGN 106 -#define UBSEC_F_UBSEC_DSA_VERIFY 107 -#define UBSEC_F_UBSEC_DH_COMPUTE_KEY 117 -/* Error reason codes */ -#define UBSEC_R_ALREADY_LOADED 108 -#define UBSEC_R_DSO_FAILURE 109 -#define UBSEC_R_UNIT_FAILURE 110 -#define UBSEC_R_NOT_LOADED 111 -#define UBSEC_R_CTRL_COMMAND_NOT_IMPLEMENTED 112 -#define UBSEC_R_SIZE_TOO_LARGE_OR_TOO_SMALL 113 -#define UBSEC_R_BN_EXPAND_FAIL 114 -#define UBSEC_R_REQUEST_FAILED 115 -#define UBSEC_R_MISSING_KEY_COMPONENTS 116 - -static ERR_STRING_DATA ubsec_str_functs[] = - { - /* This first element is changed to match the dynamic 'lib' number */ -{ERR_PACK(0,0,0), "ubsec engine code"}, -{ERR_PACK(0,UBSEC_F_UBSEC_INIT,0), "ubsec_init"}, -{ERR_PACK(0,UBSEC_F_UBSEC_FINISH,0), "ubsec_finish"}, -{ERR_PACK(0,UBSEC_F_UBSEC_CTRL,0), "ubsec_ctrl"}, -{ERR_PACK(0,UBSEC_F_UBSEC_MOD_EXP,0), "ubsec_mod_exp"}, -{ERR_PACK(0,UBSEC_F_UBSEC_RSA_MOD_EXP,0), "ubsec_rsa_mod_exp"}, -{ERR_PACK(0,UBSEC_F_UBSEC_RSA_MOD_EXP_CRT,0), "ubsec_rsa_mod_exp_crt"}, -{ERR_PACK(0,UBSEC_F_UBSEC_DSA_SIGN,0), "ubsec_dsa_sign"}, -{ERR_PACK(0,UBSEC_F_UBSEC_DSA_VERIFY,0), "ubsec_dsa_verify"}, -/* Error reason codes */ -{UBSEC_R_ALREADY_LOADED ,"already loaded"}, -{UBSEC_R_DSO_FAILURE ,"DSO failure"}, -{UBSEC_R_UNIT_FAILURE ,"unit failure"}, -{UBSEC_R_NOT_LOADED ,"not loaded"}, -{UBSEC_R_CTRL_COMMAND_NOT_IMPLEMENTED ,"ctrl command not implemented"}, -{UBSEC_R_SIZE_TOO_LARGE_OR_TOO_SMALL ,"size too large or too small"}, -{UBSEC_R_BN_EXPAND_FAIL ,"bn_expand fail"}, -{UBSEC_R_REQUEST_FAILED ,"request failed"}, -{UBSEC_R_MISSING_KEY_COMPONENTS ,"missing key components"}, -{0,NULL} - }; -/* The library number we obtain dynamically from the ERR code */ -static int ubsec_err_lib = -1; -#define UBSECerr(f,r) ERR_PUT_error(ubsec_err_lib,(f),(r),__FILE__,__LINE__) -static void ubsec_load_error_strings(void) - { - if(ubsec_err_lib < 0) - { - if((ubsec_err_lib = ERR_get_next_error_library()) <= 0) - return; - ubsec_str_functs[0].error = ERR_PACK(ubsec_err_lib,0,0); - ERR_load_strings(ubsec_err_lib, ubsec_str_functs); - } - } -static void ubsec_unload_error_strings(void) - { - if(ubsec_err_lib >= 0) - { - ERR_unload_strings(ubsec_err_lib, ubsec_str_functs); - ubsec_err_lib = -1; - } - } -#else -#define UBSECerr(f,r) /* NOP */ -static void ubsec_load_error_strings(void) { } /* NOP */ -static void ubsec_unload_error_strings(void) { } /* NOP */ -#endif - /* Constants used when creating the ENGINE */ static const char *engine_ubsec_id = "ubsec"; static const char *engine_ubsec_name = "UBSEC hardware engine support"; @@ -308,7 +238,7 @@ static int bind_helper(ENGINE *e) #endif /* Ensure the ubsec error handling is set up */ - ubsec_load_error_strings(); + ERR_load_UBSEC_strings(); return 1; } @@ -398,7 +328,7 @@ static const char *UBSEC_F13 = "ubsec_max_key_len_ioctl"; /* Destructor (complements the "ENGINE_ubsec()" constructor) */ static int ubsec_destroy(ENGINE *e) { - ubsec_unload_error_strings(); + ERR_unload_UBSEC_strings(); return 1; } diff --git a/crypto/engine/hw_ubsec_err.c b/crypto/engine/hw_ubsec_err.c new file mode 100644 index 0000000000..d707331fc2 --- /dev/null +++ b/crypto/engine/hw_ubsec_err.c @@ -0,0 +1,151 @@ +/* hw_ubsec_err.c */ +/* ==================================================================== + * Copyright (c) 1999 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +/* NOTE: this file was auto generated by the mkerr.pl script: any changes + * made to it will be overwritten when the script next updates this file, + * only reason strings will be preserved. + */ + +#include +#include +#include "hw_ubsec_err.h" + +/* BEGIN ERROR CODES */ +#ifndef OPENSSL_NO_ERR +static ERR_STRING_DATA UBSEC_str_functs[]= + { +{ERR_PACK(0,UBSEC_F_UBSEC_CTRL,0), "UBSEC_CTRL"}, +{ERR_PACK(0,UBSEC_F_UBSEC_DH_COMPUTE_KEY,0), "UBSEC_DH_COMPUTE_KEY"}, +{ERR_PACK(0,UBSEC_F_UBSEC_DSA_SIGN,0), "UBSEC_DSA_SIGN"}, +{ERR_PACK(0,UBSEC_F_UBSEC_DSA_VERIFY,0), "UBSEC_DSA_VERIFY"}, +{ERR_PACK(0,UBSEC_F_UBSEC_FINISH,0), "UBSEC_FINISH"}, +{ERR_PACK(0,UBSEC_F_UBSEC_INIT,0), "UBSEC_INIT"}, +{ERR_PACK(0,UBSEC_F_UBSEC_MOD_EXP,0), "UBSEC_MOD_EXP"}, +{ERR_PACK(0,UBSEC_F_UBSEC_RNG_BYTES,0), "UBSEC_RNG_BYTES"}, +{ERR_PACK(0,UBSEC_F_UBSEC_RSA_MOD_EXP,0), "UBSEC_RSA_MOD_EXP"}, +{ERR_PACK(0,UBSEC_F_UBSEC_RSA_MOD_EXP_CRT,0), "UBSEC_RSA_MOD_EXP_CRT"}, +{0,NULL} + }; + +static ERR_STRING_DATA UBSEC_str_reasons[]= + { +{UBSEC_R_ALREADY_LOADED ,"already loaded"}, +{UBSEC_R_BN_EXPAND_FAIL ,"bn expand fail"}, +{UBSEC_R_CTRL_COMMAND_NOT_IMPLEMENTED ,"ctrl command not implemented"}, +{UBSEC_R_DSO_FAILURE ,"dso failure"}, +{UBSEC_R_MISSING_KEY_COMPONENTS ,"missing key components"}, +{UBSEC_R_NOT_LOADED ,"not loaded"}, +{UBSEC_R_REQUEST_FAILED ,"request failed"}, +{UBSEC_R_SIZE_TOO_LARGE_OR_TOO_SMALL ,"size too large or too small"}, +{UBSEC_R_UNIT_FAILURE ,"unit failure"}, +{0,NULL} + }; + +#endif + +#ifdef UBSEC_LIB_NAME +static ERR_STRING_DATA UBSEC_lib_name[]= + { +{0 ,UBSEC_LIB_NAME}, +{0,NULL} + }; +#endif + + +static int UBSEC_lib_error_code=0; +static int UBSEC_error_init=1; + +static void ERR_load_UBSEC_strings(void) + { + if (UBSEC_lib_error_code == 0) + UBSEC_lib_error_code=ERR_get_next_error_library(); + + if (UBSEC_error_init) + { + UBSEC_error_init=0; +#ifndef OPENSSL_NO_ERR + ERR_load_strings(UBSEC_lib_error_code,UBSEC_str_functs); + ERR_load_strings(UBSEC_lib_error_code,UBSEC_str_reasons); +#endif + +#ifdef UBSEC_LIB_NAME + UBSEC_lib_name->error = ERR_PACK(UBSEC_lib_error_code,0,0); + ERR_load_strings(0,UBSEC_lib_name); +#endif + } + } + +static void ERR_unload_UBSEC_strings(void) + { + if (UBSEC_error_init == 0) + { +#ifndef OPENSSL_NO_ERR + ERR_unload_strings(UBSEC_lib_error_code,UBSEC_str_functs); + ERR_unload_strings(UBSEC_lib_error_code,UBSEC_str_reasons); +#endif + +#ifdef UBSEC_LIB_NAME + ERR_unload_strings(0,UBSEC_lib_name); +#endif + UBSEC_error_init=1; + } + } + +static void ERR_UBSEC_error(int function, int reason, char *file, int line) + { + if (UBSEC_lib_error_code == 0) + UBSEC_lib_error_code=ERR_get_next_error_library(); + ERR_PUT_error(UBSEC_lib_error_code,function,reason,file,line); + } diff --git a/crypto/engine/hw_ubsec_err.h b/crypto/engine/hw_ubsec_err.h new file mode 100644 index 0000000000..023d3be771 --- /dev/null +++ b/crypto/engine/hw_ubsec_err.h @@ -0,0 +1,95 @@ +/* ==================================================================== + * Copyright (c) 2001 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_UBSEC_ERR_H +#define HEADER_UBSEC_ERR_H + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +static void ERR_load_UBSEC_strings(void); +static void ERR_unload_UBSEC_strings(void); +static void ERR_UBSEC_error(int function, int reason, char *file, int line); +#define UBSECerr(f,r) ERR_UBSEC_error((f),(r),__FILE__,__LINE__) + +/* Error codes for the UBSEC functions. */ + +/* Function codes. */ +#define UBSEC_F_UBSEC_CTRL 100 +#define UBSEC_F_UBSEC_DH_COMPUTE_KEY 101 +#define UBSEC_F_UBSEC_DSA_SIGN 102 +#define UBSEC_F_UBSEC_DSA_VERIFY 103 +#define UBSEC_F_UBSEC_FINISH 104 +#define UBSEC_F_UBSEC_INIT 105 +#define UBSEC_F_UBSEC_MOD_EXP 106 +#define UBSEC_F_UBSEC_RNG_BYTES 107 +#define UBSEC_F_UBSEC_RSA_MOD_EXP 108 +#define UBSEC_F_UBSEC_RSA_MOD_EXP_CRT 109 + +/* Reason codes. */ +#define UBSEC_R_ALREADY_LOADED 100 +#define UBSEC_R_BN_EXPAND_FAIL 101 +#define UBSEC_R_CTRL_COMMAND_NOT_IMPLEMENTED 102 +#define UBSEC_R_DSO_FAILURE 103 +#define UBSEC_R_MISSING_KEY_COMPONENTS 104 +#define UBSEC_R_NOT_LOADED 105 +#define UBSEC_R_REQUEST_FAILED 106 +#define UBSEC_R_SIZE_TOO_LARGE_OR_TOO_SMALL 107 +#define UBSEC_R_UNIT_FAILURE 108 + +#ifdef __cplusplus +} +#endif +#endif -- 2.25.1