diff options
author | Richard Levitte <levitte@openssl.org> | 2002-02-07 20:02:49 +0000 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2002-02-07 20:02:49 +0000 |
commit | 9074521458c806464df2ffd185ab2bad7e3bfa2d (patch) | |
tree | 6821b8d113da9519535b42e4b3c8b9f25fc32676 | |
parent | f924200e1b211e4f1012455dcd893de06b5df4bb (diff) |
Generate the individual engines' error strings and macros
automatically.
-rw-r--r-- | Makefile.org | 1 | ||||
-rw-r--r-- | crypto/engine/Makefile.ssl | 22 | ||||
-rw-r--r-- | crypto/engine/hw.ec | 5 | ||||
-rw-r--r-- | crypto/engine/hw_atalla.c | 69 | ||||
-rw-r--r-- | crypto/engine/hw_atalla_err.c | 145 | ||||
-rw-r--r-- | crypto/engine/hw_atalla_err.h | 89 | ||||
-rw-r--r-- | crypto/engine/hw_cswift.c | 78 | ||||
-rw-r--r-- | crypto/engine/hw_cswift_err.c | 149 | ||||
-rw-r--r-- | crypto/engine/hw_cswift_err.h | 93 | ||||
-rw-r--r-- | crypto/engine/hw_ncipher.c | 92 | ||||
-rw-r--r-- | crypto/engine/hw_ncipher_err.c | 156 | ||||
-rw-r--r-- | crypto/engine/hw_ncipher_err.h | 100 | ||||
-rw-r--r-- | crypto/engine/hw_nuron.c | 64 | ||||
-rw-r--r-- | crypto/engine/hw_nuron_err.c | 142 | ||||
-rw-r--r-- | crypto/engine/hw_nuron_err.h | 86 | ||||
-rw-r--r-- | crypto/engine/hw_ubsec.c | 80 | ||||
-rw-r--r-- | crypto/engine/hw_ubsec_err.c | 151 | ||||
-rw-r--r-- | crypto/engine/hw_ubsec_err.h | 95 |
18 files changed, 1252 insertions, 365 deletions
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 <stdio.h> +#include <openssl/err.h> +#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 <stdio.h> +#include <openssl/err.h> +#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 |