diff options
author | Ralf S. Engelschall <rse@openssl.org> | 1998-12-21 10:52:47 +0000 |
---|---|---|
committer | Ralf S. Engelschall <rse@openssl.org> | 1998-12-21 10:52:47 +0000 |
commit | d02b48c63a58ea4367a0e905979f140b7d090f86 (patch) | |
tree | 504f62ed3d84799f785b9cd9fab255a21b0e1b0e /crypto/err | |
download | openssl-d02b48c63a58ea4367a0e905979f140b7d090f86.tar.gz |
Import of old SSLeay release: SSLeay 0.8.1b
Diffstat (limited to 'crypto/err')
-rw-r--r-- | crypto/err/Makefile.ssl | 80 | ||||
-rw-r--r-- | crypto/err/err.c | 550 | ||||
-rw-r--r-- | crypto/err/err.h | 265 | ||||
-rw-r--r-- | crypto/err/err_all.c | 115 | ||||
-rw-r--r-- | crypto/err/err_code.pl | 126 | ||||
-rw-r--r-- | crypto/err/err_genc.pl | 147 | ||||
-rw-r--r-- | crypto/err/err_prn.c | 102 | ||||
-rw-r--r-- | crypto/err/error.err | 13 |
8 files changed, 1398 insertions, 0 deletions
diff --git a/crypto/err/Makefile.ssl b/crypto/err/Makefile.ssl new file mode 100644 index 0000000000..9e1e451e59 --- /dev/null +++ b/crypto/err/Makefile.ssl @@ -0,0 +1,80 @@ +# +# SSLeay/crypto/err/Makefile +# + +DIR= error +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=err.c err_all.c err_prn.c +LIBOBJ=err.o err_all.o err_prn.o + +SRC= $(LIBSRC) + +EXHEADER= err.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/crypto/err/err.c b/crypto/err/err.c new file mode 100644 index 0000000000..6eec77a154 --- /dev/null +++ b/crypto/err/err.c @@ -0,0 +1,550 @@ +/* crypto/err/err.c */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * 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 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 acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS 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 AUTHOR OR 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. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include <stdio.h> +#include "lhash.h" +#include "crypto.h" +#include "cryptlib.h" +#include "buffer.h" +#include "err.h" +#include "crypto.h" + + +static LHASH *error_hash=NULL; +static LHASH *thread_hash=NULL; + +#ifndef NOPROTO +static unsigned long err_hash(ERR_STRING_DATA *a); +static int err_cmp(ERR_STRING_DATA *a, ERR_STRING_DATA *b); +static unsigned long pid_hash(ERR_STATE *pid); +static int pid_cmp(ERR_STATE *a,ERR_STATE *pid); +#else +static unsigned long err_hash(); +static int err_cmp(); +static unsigned long pid_hash(); +static int pid_cmp(); +#endif + +#ifndef NO_ERR +static ERR_STRING_DATA ERR_str_libraries[]= + { +{ERR_PACK(ERR_LIB_NONE,0,0) ,"unknown library"}, +{ERR_PACK(ERR_LIB_SYS,0,0) ,"system library"}, +{ERR_PACK(ERR_LIB_BN,0,0) ,"bignum routines"}, +{ERR_PACK(ERR_LIB_RSA,0,0) ,"rsa routines"}, +{ERR_PACK(ERR_LIB_DH,0,0) ,"Diffie-Hellman routines"}, +{ERR_PACK(ERR_LIB_EVP,0,0) ,"digital envelope routines"}, +{ERR_PACK(ERR_LIB_BUF,0,0) ,"memory buffer routines"}, +{ERR_PACK(ERR_LIB_BIO,0,0) ,"BIO routines"}, +{ERR_PACK(ERR_LIB_OBJ,0,0) ,"object identifier routines"}, +{ERR_PACK(ERR_LIB_PEM,0,0) ,"PEM routines"}, +{ERR_PACK(ERR_LIB_ASN1,0,0) ,"asn1 encoding routines"}, +{ERR_PACK(ERR_LIB_X509,0,0) ,"x509 certificate routines"}, +{ERR_PACK(ERR_LIB_CONF,0,0) ,"configuation file routines"}, +{ERR_PACK(ERR_LIB_METH,0,0) ,"X509 lookup 'method' routines"}, +{ERR_PACK(ERR_LIB_SSL,0,0) ,"SSL routines"}, +{ERR_PACK(ERR_LIB_RSAREF,0,0) ,"RSAref routines"}, +{ERR_PACK(ERR_LIB_PROXY,0,0) ,"Proxy routines"}, +{ERR_PACK(ERR_LIB_BIO,0,0) ,"BIO routines"}, +{ERR_PACK(ERR_LIB_PKCS7,0,0) ,"PKCS7 routines"}, +{0,NULL}, + }; + +static ERR_STRING_DATA ERR_str_functs[]= + { + {ERR_PACK(0,SYS_F_FOPEN,0), "fopen"}, + {ERR_PACK(0,SYS_F_CONNECT,0), "connect"}, + {ERR_PACK(0,SYS_F_GETSERVBYNAME,0), "getservbyname"}, + {ERR_PACK(0,SYS_F_SOCKET,0), "socket"}, + {ERR_PACK(0,SYS_F_IOCTLSOCKET,0), "ioctlsocket"}, + {ERR_PACK(0,SYS_F_BIND,0), "bind"}, + {ERR_PACK(0,SYS_F_LISTEN,0), "listen"}, + {ERR_PACK(0,SYS_F_ACCEPT,0), "accept"}, +#ifdef WINDOWS + {ERR_PACK(0,SYS_F_WSASTARTUP,0), "WSAstartup"}, +#endif + {0,NULL}, + }; + +static ERR_STRING_DATA ERR_str_reasons[]= + { +{ERR_R_FATAL ,"fatal"}, +{ERR_R_SYS_LIB ,"system lib"}, +{ERR_R_BN_LIB ,"BN lib"}, +{ERR_R_RSA_LIB ,"RSA lib"}, +{ERR_R_DH_LIB ,"DH lib"}, +{ERR_R_EVP_LIB ,"EVP lib"}, +{ERR_R_BUF_LIB ,"BUF lib"}, +{ERR_R_BIO_LIB ,"BIO lib"}, +{ERR_R_OBJ_LIB ,"OBJ lib"}, +{ERR_R_PEM_LIB ,"PEM lib"}, +{ERR_R_X509_LIB ,"X509 lib"}, +{ERR_R_METH_LIB ,"METH lib"}, +{ERR_R_ASN1_LIB ,"ASN1 lib"}, +{ERR_R_CONF_LIB ,"CONF lib"}, +{ERR_R_SSL_LIB ,"SSL lib"}, +{ERR_R_PROXY_LIB ,"PROXY lib"}, +{ERR_R_BIO_LIB ,"BIO lib"}, +{ERR_R_PKCS7_LIB ,"PKCS7 lib"}, +{ERR_R_MALLOC_FAILURE ,"Malloc failure"}, +{ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED ,"called a fuction you should not call"}, +{0,NULL}, + }; +#endif + +void ERR_load_ERR_strings() + { + static int init=1; + + if (init) + { + CRYPTO_w_lock(CRYPTO_LOCK_ERR); + if (init == 0) + { + CRYPTO_w_unlock(CRYPTO_LOCK_ERR); + return; + } + init=0; + CRYPTO_w_unlock(CRYPTO_LOCK_ERR); + +#ifndef NO_ERR + ERR_load_strings(0,ERR_str_libraries); + ERR_load_strings(0,ERR_str_reasons); + ERR_load_strings(ERR_LIB_SYS,ERR_str_functs); +#endif + } + } + +void ERR_load_strings(lib,str) +int lib; +ERR_STRING_DATA *str; + { + if (error_hash == NULL) + { + CRYPTO_w_lock(CRYPTO_LOCK_ERR_HASH); + error_hash=lh_new(err_hash,err_cmp); + if (error_hash == NULL) + { + CRYPTO_w_unlock(CRYPTO_LOCK_ERR_HASH); + return; + } + CRYPTO_w_unlock(CRYPTO_LOCK_ERR_HASH); + + ERR_load_ERR_strings(); + } + + CRYPTO_w_lock(CRYPTO_LOCK_ERR_HASH); + while (str->error) + { + str->error|=ERR_PACK(lib,0,0); + lh_insert(error_hash,(char *)str); + str++; + } + CRYPTO_w_unlock(CRYPTO_LOCK_ERR_HASH); + } + +void ERR_free_strings() + { + CRYPTO_w_lock(CRYPTO_LOCK_ERR); + + if (error_hash != NULL) + { + lh_free(error_hash); + error_hash=NULL; + } + + CRYPTO_w_unlock(CRYPTO_LOCK_ERR); + } + +void ERR_put_error(lib,func,reason,file,line) +int lib,func,reason; +char *file; +int line; + { + ERR_STATE *es; + + es=ERR_get_state(); + + es->top=(es->top+1)%ERR_NUM_ERRORS; + if (es->top == es->bottom) + es->bottom=(es->bottom+1)%ERR_NUM_ERRORS; + es->err_buffer[es->top]=ERR_PACK(lib,func,reason); + es->err_file[es->top]=file; + es->err_line[es->top]=line; + } + +void ERR_clear_error() + { + int i; + ERR_STATE *es; + + es=ERR_get_state(); + + for (i=0; i<ERR_NUM_ERRORS; i++) + { + es->err_buffer[i]=0; + es->err_file[i]=NULL; + es->err_line[i]= -1; + } + es->top=es->bottom=0; + } + +unsigned long ERR_peek_error() + { + int i; + ERR_STATE *es; + + /* should be fine since only one thread should ever be playing + * with the value returned from this call */ + es=ERR_get_state(); + + if (es->bottom == es->top) return(0); + i=(es->bottom+1)%ERR_NUM_ERRORS; + + + return(es->err_buffer[i]); + } + +unsigned long ERR_get_error() + { + int i; + unsigned long ret; + ERR_STATE *es; + + es=ERR_get_state(); + + if (es->bottom == es->top) return(0); + i=(es->bottom+1)%ERR_NUM_ERRORS; + es->bottom=i; + ret=es->err_buffer[i]; + es->err_buffer[i]=0; + + + return(ret); + } + +unsigned long ERR_peek_error_line(file,line) +char **file; +int *line; + { + int i=0; + ERR_STATE *es; + + es=ERR_get_state(); + + if (es->bottom == es->top) + { + return(0); + } + + i=(es->bottom+1)%ERR_NUM_ERRORS; + if (es->err_file[i] == NULL) + { + *file="NA"; + *line=0; + } + else + { + *file=es->err_file[i]; + *line=es->err_line[i]; + } + + return(es->err_buffer[i]); + } + +unsigned long ERR_get_error_line(file,line) +char **file; +int *line; + { + int i; + unsigned long ret; + ERR_STATE *es; + + es=ERR_get_state(); + + if (es->bottom == es->top) + return(0); + + i=(es->bottom+1)%ERR_NUM_ERRORS; + es->bottom=i; + ret= es->err_buffer[i]; + if (es->err_file[i] == NULL) + { + *file="NA"; + *line=0; + } + else + { + *file=es->err_file[i]; + *line=es->err_line[i]; + } + es->err_buffer[i]=0; + es->err_file[i]=NULL; + es->err_line[i]= -1; + + return(ret); + } + +/* BAD for multi-threaded, uses a local buffer if ret == NULL */ +char *ERR_error_string(e,ret) +unsigned long e; +char *ret; + { + static char buf[256]; + char *ls,*fs,*rs; + unsigned long l,f,r; + int i; + + l=ERR_GET_LIB(e); + f=ERR_GET_FUNC(e); + r=ERR_GET_REASON(e); + + ls=ERR_lib_error_string(e); + fs=ERR_func_error_string(e); + rs=ERR_reason_error_string(e); + + if (ret == NULL) ret=buf; + + sprintf(&(ret[0]),"error:%08lX:",e); + i=strlen(ret); + if (ls == NULL) + sprintf(&(ret[i]),":lib(%lu) ",l); + else sprintf(&(ret[i]),"%s",ls); + i=strlen(ret); + if (fs == NULL) + sprintf(&(ret[i]),":func(%lu) ",f); + else sprintf(&(ret[i]),":%s",fs); + i=strlen(ret); + if (rs == NULL) + sprintf(&(ret[i]),":reason(%lu)",r); + else sprintf(&(ret[i]),":%s",rs); + + return(ret); + } + +LHASH *ERR_get_string_table() + { + return(error_hash); + } + +LHASH *ERR_get_err_state_table() + { + return(thread_hash); + } + +char *ERR_lib_error_string(e) +unsigned long e; + { + ERR_STRING_DATA d,*p=NULL; + unsigned long l; + + l=ERR_GET_LIB(e); + + CRYPTO_r_lock(CRYPTO_LOCK_ERR_HASH); + + if (error_hash != NULL) + { + d.error=ERR_PACK(l,0,0); + p=(ERR_STRING_DATA *)lh_retrieve(error_hash,(char *)&d); + } + + CRYPTO_r_unlock(CRYPTO_LOCK_ERR_HASH); + + return((p == NULL)?NULL:p->string); + } + +char *ERR_func_error_string(e) +unsigned long e; + { + ERR_STRING_DATA d,*p=NULL; + unsigned long l,f; + + l=ERR_GET_LIB(e); + f=ERR_GET_FUNC(e); + + CRYPTO_r_lock(CRYPTO_LOCK_ERR_HASH); + + if (error_hash != NULL) + { + d.error=ERR_PACK(l,f,0); + p=(ERR_STRING_DATA *)lh_retrieve(error_hash,(char *)&d); + } + + CRYPTO_r_unlock(CRYPTO_LOCK_ERR_HASH); + + return((p == NULL)?NULL:p->string); + } + +char *ERR_reason_error_string(e) +unsigned long e; + { + ERR_STRING_DATA d,*p=NULL; + unsigned long l,r; + + l=ERR_GET_LIB(e); + r=ERR_GET_REASON(e); + + CRYPTO_r_lock(CRYPTO_LOCK_ERR_HASH); + + if (error_hash != NULL) + { + d.error=ERR_PACK(l,0,r); + p=(ERR_STRING_DATA *)lh_retrieve(error_hash,(char *)&d); + if (p == NULL) + { + d.error=ERR_PACK(0,0,r); + p=(ERR_STRING_DATA *)lh_retrieve(error_hash, + (char *)&d); + } + } + + CRYPTO_r_unlock(CRYPTO_LOCK_ERR_HASH); + + return((p == NULL)?NULL:p->string); + } + +static unsigned long err_hash(a) +ERR_STRING_DATA *a; + { + unsigned long ret,l; + + l=a->error; + ret=l^ERR_GET_LIB(l)^ERR_GET_FUNC(l); + return(ret^ret%19*13); + } + +static int err_cmp(a,b) +ERR_STRING_DATA *a,*b; + { + return((int)(a->error-b->error)); + } + +static unsigned long pid_hash(a) +ERR_STATE *a; + { + return(a->pid*13); + } + +static int pid_cmp(a,b) +ERR_STATE *a,*b; + { + return((int)((long)a->pid - (long)b->pid)); + } + +void ERR_remove_state(pid) +unsigned long pid; + { + ERR_STATE *p,tmp; + + if (thread_hash == NULL) + return; + if (pid == 0) + pid=(unsigned long)CRYPTO_thread_id(); + tmp.pid=pid; + CRYPTO_w_lock(CRYPTO_LOCK_ERR); + p=(ERR_STATE *)lh_delete(thread_hash,(char *)&tmp); + if (p != NULL) Free(p); + CRYPTO_w_unlock(CRYPTO_LOCK_ERR); + } + +ERR_STATE *ERR_get_state() + { + static ERR_STATE fallback; + ERR_STATE *ret=NULL,tmp,*tmpp; + unsigned long pid; + + pid=(unsigned long)CRYPTO_thread_id(); + + CRYPTO_r_lock(CRYPTO_LOCK_ERR); + if (thread_hash == NULL) + { + CRYPTO_r_unlock(CRYPTO_LOCK_ERR); + CRYPTO_w_lock(CRYPTO_LOCK_ERR); + if (thread_hash == NULL) + { + thread_hash=lh_new(pid_hash,pid_cmp); + CRYPTO_w_unlock(CRYPTO_LOCK_ERR); + if (thread_hash == NULL) return(&fallback); + } + else + CRYPTO_w_unlock(CRYPTO_LOCK_ERR); + } + else + { + tmp.pid=pid; + ret=(ERR_STATE *)lh_retrieve(thread_hash,(char *)&tmp); + CRYPTO_r_unlock(CRYPTO_LOCK_ERR); + } + + /* ret == the error state, if NULL, make a new one */ + if (ret == NULL) + { + ret=(ERR_STATE *)Malloc(sizeof(ERR_STATE)); + if (ret == NULL) return(&fallback); + ret->pid=pid; + ret->top=0; + ret->bottom=0; + CRYPTO_w_lock(CRYPTO_LOCK_ERR); + tmpp=(ERR_STATE *)lh_insert(thread_hash,(char *)ret); + CRYPTO_w_unlock(CRYPTO_LOCK_ERR); + if (tmpp != NULL) /* old entry - should not happen */ + Free(tmpp); + } + return(ret); + } + diff --git a/crypto/err/err.h b/crypto/err/err.h new file mode 100644 index 0000000000..aa3354e2dd --- /dev/null +++ b/crypto/err/err.h @@ -0,0 +1,265 @@ +/* crypto/err/err.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * 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 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 acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS 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 AUTHOR OR 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. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_ERR_H +#define HEADER_ERR_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* The following is a bit of a trick to help the object files only contain + * the 'name of the file' string once. Since 'err.h' is protected by the + * HEADER_ERR_H stuff, this should be included only once per file. */ + +#define ERR_file_name __FILE__ + +#ifndef NO_ERR +#define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,d,e) +#else +#define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,NULL,0) +#endif + +#include <errno.h> + +#define ERR_NUM_ERRORS 10 +typedef struct err_state_st + { + unsigned long pid; + unsigned long err_buffer[ERR_NUM_ERRORS]; + char *err_file[ERR_NUM_ERRORS]; + int err_line[ERR_NUM_ERRORS]; + int top,bottom; + } ERR_STATE; + +/* library */ +#define ERR_LIB_NONE 1 +#define ERR_LIB_SYS 2 +#define ERR_LIB_BN 3 +#define ERR_LIB_RSA 4 +#define ERR_LIB_DH 5 +#define ERR_LIB_EVP 6 +#define ERR_LIB_BUF 7 +#define ERR_LIB_OBJ 8 +#define ERR_LIB_PEM 9 +#define ERR_LIB_DSA 10 +#define ERR_LIB_X509 11 +#define ERR_LIB_METH 12 +#define ERR_LIB_ASN1 13 +#define ERR_LIB_CONF 14 +#define ERR_LIB_SSL 20 +#define ERR_LIB_SSL23 21 +#define ERR_LIB_SSL2 22 +#define ERR_LIB_SSL3 23 +#define ERR_LIB_RSAREF 30 +#define ERR_LIB_PROXY 31 +#define ERR_LIB_BIO 32 +#define ERR_LIB_PKCS7 33 + +#define ERR_LIB_USER 128 + +#define SYSerr(f,r) ERR_PUT_error(ERR_LIB_SYS,(f),(r),ERR_file_name,__LINE__) +#define BNerr(f,r) ERR_PUT_error(ERR_LIB_BN,(f),(r),ERR_file_name,__LINE__) +#define RSAerr(f,r) ERR_PUT_error(ERR_LIB_RSA,(f),(r),ERR_file_name,__LINE__) +#define DHerr(f,r) ERR_PUT_error(ERR_LIB_DH,(f),(r),ERR_file_name,__LINE__) +#define EVPerr(f,r) ERR_PUT_error(ERR_LIB_EVP,(f),(r),ERR_file_name,__LINE__) +#define BUFerr(f,r) ERR_PUT_error(ERR_LIB_BUF,(f),(r),ERR_file_name,__LINE__) +#define BIOerr(f,r) ERR_PUT_error(ERR_LIB_BIO,(f),(r),ERR_file_name,__LINE__) +#define OBJerr(f,r) ERR_PUT_error(ERR_LIB_OBJ,(f),(r),ERR_file_name,__LINE__) +#define PEMerr(f,r) ERR_PUT_error(ERR_LIB_PEM,(f),(r),ERR_file_name,__LINE__) +#define DSAerr(f,r) ERR_PUT_error(ERR_LIB_DSA,(f),(r),ERR_file_name,__LINE__) +#define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),ERR_file_name,__LINE__) +#define METHerr(f,r) ERR_PUT_error(ERR_LIB_METH,(f),(r),ERR_file_name,__LINE__) +#define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),ERR_file_name,__LINE__) +#define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),ERR_file_name,__LINE__) +#define SSLerr(f,r) ERR_PUT_error(ERR_LIB_SSL,(f),(r),ERR_file_name,__LINE__) +#define SSL23err(f,r) ERR_PUT_error(ERR_LIB_SSL23,(f),(r),ERR_file_name,__LINE__) +#define SSL2err(f,r) ERR_PUT_error(ERR_LIB_SSL2,(f),(r),ERR_file_name,__LINE__) +#define SSL3err(f,r) ERR_PUT_error(ERR_LIB_SSL3,(f),(r),ERR_file_name,__LINE__) +#define RSAREFerr(f,r) ERR_PUT_error(ERR_LIB_RSAREF,(f),(r),ERR_file_name,__LINE__) +#define PROXYerr(f,r) ERR_PUT_error(ERR_LIB_PROXY,(f),(r),ERR_file_name,__LINE__) +#define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),ERR_file_name,__LINE__) + +/* Borland C seems too stupid to be able to shift and do longs in + * the pre-processor :-( */ +#define ERR_PACK(l,f,r) (((((unsigned long)l)&0xffL)*0x1000000)| \ + ((((unsigned long)f)&0xfffL)*0x1000)| \ + ((((unsigned long)r)&0xfffL))) +#define ERR_GET_LIB(l) (int)((((unsigned long)l)>>24L)&0xffL) +#define ERR_GET_FUNC(l) (int)((((unsigned long)l)>>12L)&0xfffL) +#define ERR_GET_REASON(l) (int)((l)&0xfffL) +#define ERR_FATAL_ERROR(l) (int)((l)&ERR_R_FATAL) + +/* OS fuctions */ +#define SYS_F_FOPEN 1 +#define SYS_F_CONNECT 2 +#define SYS_F_GETSERVBYNAME 3 +#define SYS_F_SOCKET 4 +#define SYS_F_IOCTLSOCKET 5 +#define SYS_F_BIND 6 +#define SYS_F_LISTEN 7 +#define SYS_F_ACCEPT 8 +#define SYS_F_WSASTARTUP 9 /* Winsock stuff */ + +#define ERR_R_FATAL 32 +/* reasons */ +#define ERR_R_SYS_LIB ERR_LIB_SYS +#define ERR_R_BN_LIB ERR_LIB_BN +#define ERR_R_RSA_LIB ERR_LIB_RSA +#define ERR_R_DSA_LIB ERR_LIB_DSA +#define ERR_R_DH_LIB ERR_LIB_DH +#define ERR_R_EVP_LIB ERR_LIB_EVP +#define ERR_R_BUF_LIB ERR_LIB_BUF +#define ERR_R_BIO_LIB ERR_LIB_BIO +#define ERR_R_OBJ_LIB ERR_LIB_OBJ +#define ERR_R_PEM_LIB ERR_LIB_PEM +#define ERR_R_X509_LIB ERR_LIB_X509 +#define ERR_R_METH_LIB ERR_LIB_METH +#define ERR_R_ASN1_LIB ERR_LIB_ASN1 +#define ERR_R_CONF_LIB ERR_LIB_CONF +#define ERR_R_SSL_LIB ERR_LIB_SSL +#define ERR_R_SSL23_LIB ERR_LIB_SSL23 +#define ERR_R_SSL2_LIB ERR_LIB_SSL2 +#define ERR_R_SSL3_LIB ERR_LIB_SSL3 +#define ERR_R_PROXY_LIB ERR_LIB_PROXY +#define ERR_R_BIO_LIB ERR_LIB_BIO +#define ERR_R_PKCS7_LIB ERR_LIB_PKCS7 + +/* fatal error */ +#define ERR_R_MALLOC_FAILURE (1|ERR_R_FATAL) +#define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED (2|ERR_R_FATAL) +#define ERR_R_PASSED_NULL_PARAMETER (3|ERR_R_FATAL) + +typedef struct ERR_string_data_st + { + unsigned long error; + char *string; + } ERR_STRING_DATA; + +#ifndef NOPROTO +void ERR_put_error(int lib, int func,int reason,char *file,int line); +unsigned long ERR_get_error(void ); +unsigned long ERR_get_error_line(char **file,int *line); +unsigned long ERR_peek_error(void ); +unsigned long ERR_peek_error_line(char **file,int *line); +void ERR_clear_error(void ); +char *ERR_error_string(unsigned long e,char *buf); +char *ERR_lib_error_string(unsigned long e); +char *ERR_func_error_string(unsigned long e); +char *ERR_reason_error_string(unsigned long e); +#ifndef WIN16 +void ERR_print_errors_fp(FILE *fp); +#endif +#ifdef HEADER_BIO_H +void ERR_print_errors(BIO *bp); +#endif +void ERR_load_strings(int lib,ERR_STRING_DATA str[]); +void ERR_load_ERR_strings(void ); +void ERR_load_crypto_strings(void ); +void ERR_free_strings(void ); + +void ERR_remove_state(unsigned long pid); /* if zero we look it up */ +ERR_STATE *ERR_get_state(void); + +#ifdef HEADER_LHASH_H +LHASH *ERR_get_string_table(void ); +LHASH *ERR_get_err_state_table(void ); +#else +char *ERR_get_string_table(void ); +char *ERR_get_err_state_table(void ); +#endif + +#else + +void ERR_put_error(); +unsigned long ERR_get_error(); +unsigned long ERR_get_error_line(); +unsigned long ERR_peek_error(); +unsigned long ERR_peek_error_line(); +void ERR_clear_error(); +char *ERR_error_string(); +char *ERR_lib_error_string(); +char *ERR_func_error_string(); +char *ERR_reason_error_string(); +#ifndef WIN16 +void ERR_print_errors_fp(); +#endif +void ERR_print_errors(); +void ERR_load_strings(); +void ERR_load_ERR_strings(); +void ERR_load_crypto_strings(); +void ERR_free_strings(); + +void ERR_remove_state(); +ERR_STATE *ERR_get_state(); + +#ifdef HEADER_LHASH_H +LHASH *ERR_get_string_table(); +LHASH *ERR_get_err_state_table(); +#else +char *ERR_get_string_table(); +char *ERR_get_err_state_table(); +#endif + +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/crypto/err/err_all.c b/crypto/err/err_all.c new file mode 100644 index 0000000000..d6d8109ea0 --- /dev/null +++ b/crypto/err/err_all.c @@ -0,0 +1,115 @@ +/* crypto/err/err_all.c */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * 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 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 acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS 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 AUTHOR OR 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. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include <stdio.h> +#include "asn1.h" +#include "bn.h" +#include "buffer.h" +#include "bio.h" +#ifndef NO_RSA +#include "rsa.h" +#endif +#ifdef RSAref +#include "rsaref.h" +#endif +#ifndef NO_DH +#include "dh.h" +#endif +#ifndef NO_DSA +#include "dsa.h" +#endif +#include "evp.h" +#include "objects.h" +#include "pem.h" +#include "x509.h" +#include "conf.h" +#include "err.h" + +void ERR_load_crypto_strings() + { + static int done=0; + + if (done) return; + done=1; +#ifndef NO_ERR + ERR_load_ASN1_strings(); + ERR_load_BN_strings(); + ERR_load_BUF_strings(); + ERR_load_BIO_strings(); + ERR_load_CONF_strings(); +#ifndef NO_RSA +#ifdef RSAref + ERR_load_RSAREF_strings(); +#else + ERR_load_RSA_strings(); +#endif +#endif +#ifndef NO_DH + ERR_load_DH_strings(); +#endif +#ifndef NO_DSA + ERR_load_DSA_strings(); +#endif + ERR_load_ERR_strings(); + ERR_load_EVP_strings(); + ERR_load_OBJ_strings(); + ERR_load_PEM_strings(); + ERR_load_X509_strings(); + ERR_load_PKCS7_strings(); +#endif + } diff --git a/crypto/err/err_code.pl b/crypto/err/err_code.pl new file mode 100644 index 0000000000..5b893001c6 --- /dev/null +++ b/crypto/err/err_code.pl @@ -0,0 +1,126 @@ +#!/usr/local/bin/perl + +%errfile=( + "ERR", "NONE", + "BN", "bn/bn.err", + "RSA", "rsa/rsa.err", + "DSA", "dsa/dsa.err", + "DH", "dh/dh.err", + "EVP", "evp/evp.err", + "BUF", "buffer/buffer.err", + "BIO", "bio/bio.err", + "OBJ", "objects/objects.err", + "PEM", "pem/pem.err", + "X509", "x509/x509.err", + "METH", "meth/meth.err", + "ASN1", "asn1/asn1.err", + "CONF", "conf/conf.err", + "PROXY","proxy/proxy.err", + "PKCS7","pkcs7/pkcs7.err", + "RSAREF","../rsaref/rsaref.err", + "SSL", "../ssl/ssl.err", + "SSL2", "../ssl/ssl2.err", + "SSL3", "../ssl/ssl3.err", + "SSL23","../ssl/ssl23.err", + ); + +$function{'RSAREF_F_RSA_BN2BIN'}=1; +$function{'RSAREF_F_RSA_PRIVATE_DECRYPT'}=1; +$function{'RSAREF_F_RSA_PRIVATE_ENCRYPT'}=1; +$function{'RSAREF_F_RSA_PUBLIC_DECRYPT'}=1; +$function{'RSAREF_F_RSA_PUBLIC_ENCRYPT'}=1; +$function{'SSL_F_CLIENT_CERTIFICATE'}=1; + +$r_value{'SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE'}= 1010; +$r_value{'SSL_R_SSLV3_ALERT_BAD_RECORD_MAC'}= 1020; +$r_value{'SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE'}=1030; +$r_value{'SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE'}= 1040; +$r_value{'SSL_R_SSLV3_ALERT_NO_CERTIFICATE'}= 1041; +$r_value{'SSL_R_SSLV3_ALERT_BAD_CERTIFICATE'}= 1042; +$r_value{'SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE'}=1043; +$r_value{'SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED'}= 1044; +$r_value{'SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED'}= 1045; +$r_value{'SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN'}= 1046; +$r_value{'SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER'}= 1047; + +$r_value{'RSAREF_R_CONTENT_ENCODING'}= 0x0400; +$r_value{'RSAREF_R_DATA'}= 0x0401; +$r_value{'RSAREF_R_DIGEST_ALGORITHM'}= 0x0402; +$r_value{'RSAREF_R_ENCODING'}= 0x0403; +$r_value{'RSAREF_R_KEY'}= 0x0404; +$r_value{'RSAREF_R_KEY_ENCODING'}= 0x0405; +$r_value{'RSAREF_R_LEN'}= 0x0406; +$r_value{'RSAREF_R_MODULUS_LEN'}= 0x0407; +$r_value{'RSAREF_R_NEED_RANDOM'}= 0x0408; +$r_value{'RSAREF_R_PRIVATE_KEY'}= 0x0409; +$r_value{'RSAREF_R_PUBLIC_KEY'}= 0x040a; +$r_value{'RSAREF_R_SIGNATURE'}= 0x040b; +$r_value{'RSAREF_R_SIGNATURE_ENCODING'}=0x040c; +$r_value{'RSAREF_R_ENCRYPTION_ALGORITHM'}=0x040d; + +$last=""; +while (<>) + { + if (/err\(([A-Z0-9]+_F_[0-9A-Z_]+)\s*,\s*([0-9A-Z]+_R_[0-9A-Z_]+)\s*\)/) + { + if ($1 != $last) + { + if ($function{$1} == 0) + { + printf STDERR "$. $1 is bad\n"; + } + } + $function{$1}++; + $last=$1; + $reason{$2}++; + } + } + +foreach (keys %function,keys %reason) + { + /^([A-Z0-9]+)_/; + $prefix{$1}++; + } + +@F=sort keys %function; +@R=sort keys %reason; +foreach $j (sort keys %prefix) + { + next if $errfile{$j} eq "NONE"; + printf STDERR "doing %-6s - ",$j; + open(OUT,">$errfile{$j}") || die "unable to open '$errfile{$j}':$!\n"; + @f=grep(/^${j}_/,@F); + @r=grep(/^${j}_/,@R); + $num=100; + print OUT "/* Error codes for the $j functions. */\n\n"; + print OUT "/* Function codes. */\n"; + $f_count=0; + foreach $i (@f) + { + $z=6-int(length($i)/8); + printf OUT "#define $i%s $num\n","\t" x $z; + $num++; + $f_count++; + } + $num=100; + print OUT "\n/* Reason codes. */\n"; + $r_count=0; + foreach $i (@r) + { + $z=6-int(length($i)/8); + if (defined($r_value{$i})) + { + printf OUT "#define $i%s $r_value{$i}\n","\t" x $z; + } + else + { + printf OUT "#define $i%s $num\n","\t" x $z; + $num++; + } + $r_count++; + } + close(OUT); + + printf STDERR "%3d functions, %3d reasons\n",$f_count,$r_count; + } + diff --git a/crypto/err/err_genc.pl b/crypto/err/err_genc.pl new file mode 100644 index 0000000000..6733cfe574 --- /dev/null +++ b/crypto/err/err_genc.pl @@ -0,0 +1,147 @@ +#!/usr/local/bin/perl + +($#ARGV == 1) || die "usage: $0 <header file> <output C file>\n"; +open(IN,"<$ARGV[0]") || die "unable to open $ARGV[0]:$!\n"; +open(STDOUT,">$ARGV[1]") || die "unable to open $ARGV[1]:$!\n"; + +$Func=0; +$Reas=0; +$fuction{'FOPEN'}='fopen'; +while (<IN>) + { + if (/(\S+)\s*\(\);/) + { + $t=$1; + $t =~ s/\*//; + ($upper=$t) =~ tr/a-z/A-Z/; + $fuction{$upper}=$t; + } + next unless (/^#define\s+(\S+)\s/); + + $o=$1; + if ($o =~ /^([^_]+)_F_(.*)/) + { + $type=$1; + $Func++; + $n=$2; + $n=$fuction{$n} if (defined($fuction{$n})); + $out{$1."_str_functs"}.= + sprintf("{ERR_PACK(0,%s,0),\t\"$n\"},\n",$o); + } + elsif ($o =~ /^([^_]+)_R_(.*)/) + { + $type=$1; + $Reas++; + $r=$2; + $r =~ tr/A-Z_/a-z /; + $pkg{$type."_str_reasons"}=$type; + $out{$type."_str_reasons"}.=sprintf("{%-40s,\"$r\"},\n",$o); + } + elsif ($ARGV[0] =~ /rsaref/ && $o =~ /^RE_(.*)/) + { + $type="RSAREF"; + $Reas++; + $r=$1; + $r =~ tr/A-Z_/a-z /; + $pkg{$type."_str_reasons"}=$type; + $out{$type."_str_reasons"}.=sprintf("{%-40s,\"$r\"},\n",$o); + } + } +close(IN); + +&header($type,$ARGV[0]); + +foreach (sort keys %out) + { + print "static ERR_STRING_DATA ${_}[]=\n\t{\n"; + print $out{$_}; + print "{0,NULL},\n"; + print "\t};\n\n"; + } + +print "void ERR_load_${type}_strings()\n"; +print "\t{\n"; +print "\tstatic int init=1;\n\n"; +print "\tif (init)\n"; +print "\t\t{\n"; +print "\t\tinit=0;\n"; +print "\t\tERR_load_strings(ERR_LIB_$type,${type}_str_functs);\n" + if $Func; +print "\t\tERR_load_strings(ERR_LIB_$type,${type}_str_reasons);\n" + if $Reas; +print "\t\t}\n"; +print "\t}\n"; + +sub header + { + ($type,$header)=@_; + + ($lc=$type) =~ tr/A-Z/a-z/; + $header =~ s/^.*\///; + + print "/* lib/$lc/${lc}\_err.c */\n"; + print <<'EOF'; +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * 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 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 acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS 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 AUTHOR OR 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. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +EOF + + print "#include <stdio.h>\n"; + print "#include \"err.h\"\n"; + print "#include \"$header\"\n"; + print "\n/* BEGIN ERROR CODES */\n"; + } + diff --git a/crypto/err/err_prn.c b/crypto/err/err_prn.c new file mode 100644 index 0000000000..16e313879d --- /dev/null +++ b/crypto/err/err_prn.c @@ -0,0 +1,102 @@ +/* crypto/err/err_prn.c */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * 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 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 acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS 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 AUTHOR OR 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. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include <stdio.h> +#include "lhash.h" +#include "crypto.h" +#include "cryptlib.h" +#include "buffer.h" +#include "err.h" +#include "crypto.h" + +#ifndef WIN16 +void ERR_print_errors_fp(fp) +FILE *fp; + { + unsigned long l; + char buf[200]; + char *file; + int line; + unsigned long es; + + es=CRYPTO_thread_id(); + while ((l=ERR_get_error_line(&file,&line)) != 0) + fprintf(fp,"%lu:%s:%s:%d\n",es,ERR_error_string(l,buf), + file,line); + } +#endif + +void ERR_print_errors(bp) +BIO *bp; + { + unsigned long l; + char buf[256]; + char buf2[256]; + char *file; + int line; + unsigned long es; + + es=CRYPTO_thread_id(); + while ((l=ERR_get_error_line(&file,&line)) != 0) + { + sprintf(buf2,"%lu:%s:%s:%d\n",es,ERR_error_string(l,buf), + file,line); + BIO_write(bp,buf2,strlen(buf2)); + } + } + diff --git a/crypto/err/error.err b/crypto/err/error.err new file mode 100644 index 0000000000..f09557d8d9 --- /dev/null +++ b/crypto/err/error.err @@ -0,0 +1,13 @@ +/* Error codes for the ERR functions. */ + +/* Function codes. */ + +/* Reason codes. */ +#define ERR_R_BN_LIB 100 +#define ERR_R_DER_LIB 101 +#define ERR_R_MALLOC_FAILURE 102 +#define ERR_R_PEM_LIB 103 +#define ERR_R_RSA_LIB 104 +#define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED 105 +#define ERR_R_SYS_LIB 106 +#define ERR_R_X509_LIB 107 |