Commit 90745214 authored by Richard Levitte's avatar Richard Levitte
Browse files

Generate the individual engines' error strings and macros

automatically.
parent f924200e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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
+15 −7
Original line number Diff line number Diff line
@@ -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

crypto/engine/hw.ec

0 → 100644
+5 −0
Original line number Diff line number Diff line
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
+5 −64
Original line number Diff line number Diff line
@@ -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;
	}

+145 −0
Original line number Diff line number Diff line
/* 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);
	}
Loading