diff -urN SSLeay-0.9.0-clean/MINFO SSLeay-0.9.0/MINFO --- SSLeay-0.9.0-clean/MINFO Thu Apr 09 08:47:23 1998 +++ SSLeay-0.9.0/MINFO Thu Jul 02 02:21:09 1998 @@ -7,7 +7,7 @@ CC=cc CFLAG=-O -DNOPROTO DES_ENC=des_enc.o fcrypt_b.o -DIRS=crypto ssl rsaref apps test tools +DIRS=crypto ssl rsaref bsafe apps test tools EDIRS=times doc bugs util include certs ms shlib mt demos perl dep EXHEADER=e_os.h EX_LIBS= @@ -698,7 +698,7 @@ TOP=../.. RELATIVE_DIRECTORY= RELATIVE_DIRECTORY=crypto/asn1 -ALL=Makefile README a_object.c a_bitstr.c a_utctm.c a_int.c a_octet.c a_print.c a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c a_sign.c a_digest.c a_verify.c x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c x_name.c x_cinf.c x_x509.c x_crl.c x_info.c x_spki.c d2i_r_pr.c i2d_r_pr.c d2i_r_pu.c i2d_r_pu.c d2i_s_pr.c i2d_s_pr.c d2i_s_pu.c i2d_s_pu.c d2i_pu.c d2i_pr.c i2d_pu.c i2d_pr.c t_req.c t_x509.c t_pkey.c p7_i_s.c p7_signi.c p7_signd.c p7_recip.c p7_enc_c.c p7_evp.c p7_dgst.c p7_s_e.c p7_enc.c p7_lib.c f_int.c f_string.c i2d_dhp.c i2d_dsap.c d2i_dhp.c d2i_dsap.c n_pkey.c a_hdr.c x_pkey.c a_bool.c x_exten.c asn1_par.c asn1_lib.c asn1_err.c a_meth.c a_bytes.c evp_asn1.c asn1.h asn1_mac.h +ALL=Makefile README a_object.c a_bitstr.c a_utctm.c a_int.c a_octet.c a_print.c a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c a_sign.c a_digest.c a_verify.c x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c x_name.c x_cinf.c x_x509.c x_crl.c x_info.c x_spki.c d2i_r_pr.c i2d_r_pr.c d2i_r_pu.c i2d_r_pu.c d2i_s_pr.c i2d_s_pr.c d2i_s_pu.c i2d_s_pu.c d2i_pu.c d2i_pr.c i2d_pu.c i2d_pr.c t_req.c t_x509.c t_pkey.c p7_i_s.c p7_signi.c p7_signd.c p7_recip.c p7_enc_c.c p7_evp.c p7_dgst.c p7_s_e.c p7_enc.c p7_lib.c f_int.c f_string.c i2d_dhp.c i2d_dsap.c d2i_dhp.c d2i_dsap.c n_pkey.c a_hdr.c x_pkey.c x_privkey.c a_bool.c x_exten.c asn1_par.c asn1_lib.c asn1_err.c a_meth.c a_bytes.c evp_asn1.c asn1.h asn1_mac.h APPS= AR=ar r CC=cc @@ -713,12 +713,12 @@ INCLUDES=-I.. -I../../include INSTALLTOP=/usr/local/ssl LIB=../../libcrypto.a -LIBOBJ=a_object.o a_bitstr.o a_utctm.o a_int.o a_octet.o a_print.o a_type.o a_set.o a_dup.o a_d2i_fp.o a_i2d_fp.o a_sign.o a_digest.o a_verify.o x_algor.o x_val.o x_pubkey.o x_sig.o x_req.o x_attrib.o x_name.o x_cinf.o x_x509.o x_crl.o x_info.o x_spki.o d2i_r_pr.o i2d_r_pr.o d2i_r_pu.o i2d_r_pu.o d2i_s_pr.o i2d_s_pr.o d2i_s_pu.o i2d_s_pu.o d2i_pu.o d2i_pr.o i2d_pu.o i2d_pr.o t_req.o t_x509.o t_pkey.o p7_i_s.o p7_signi.o p7_signd.o p7_recip.o p7_enc_c.o p7_evp.o p7_dgst.o p7_s_e.o p7_enc.o p7_lib.o f_int.o f_string.o i2d_dhp.o i2d_dsap.o d2i_dhp.o d2i_dsap.o n_pkey.o a_hdr.o x_pkey.o a_bool.o x_exten.o asn1_par.o asn1_lib.o asn1_err.o a_meth.o a_bytes.o evp_asn1.o -LIBSRC=a_object.c a_bitstr.c a_utctm.c a_int.c a_octet.c a_print.c a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c a_sign.c a_digest.c a_verify.c x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c x_name.c x_cinf.c x_x509.c x_crl.c x_info.c x_spki.c d2i_r_pr.c i2d_r_pr.c d2i_r_pu.c i2d_r_pu.c d2i_s_pr.c i2d_s_pr.c d2i_s_pu.c i2d_s_pu.c d2i_pu.c d2i_pr.c i2d_pu.c i2d_pr.c t_req.c t_x509.c t_pkey.c p7_i_s.c p7_signi.c p7_signd.c p7_recip.c p7_enc_c.c p7_evp.c p7_dgst.c p7_s_e.c p7_enc.c p7_lib.c f_int.c f_string.c i2d_dhp.c i2d_dsap.c d2i_dhp.c d2i_dsap.c n_pkey.c a_hdr.c x_pkey.c a_bool.c x_exten.c asn1_par.c asn1_lib.c asn1_err.c a_meth.c a_bytes.c evp_asn1.c +LIBOBJ=a_object.o a_bitstr.o a_utctm.o a_int.o a_octet.o a_print.o a_type.o a_set.o a_dup.o a_d2i_fp.o a_i2d_fp.o a_sign.o a_digest.o a_verify.o x_algor.o x_val.o x_pubkey.o x_sig.o x_req.o x_attrib.o x_name.o x_cinf.o x_x509.o x_crl.o x_info.o x_spki.o d2i_r_pr.o i2d_r_pr.o d2i_r_pu.o i2d_r_pu.o d2i_s_pr.o i2d_s_pr.o d2i_s_pu.o i2d_s_pu.o d2i_pu.o d2i_pr.o i2d_pu.o i2d_pr.o t_req.o t_x509.o t_pkey.o p7_i_s.o p7_signi.o p7_signd.o p7_recip.o p7_enc_c.o p7_evp.o p7_dgst.o p7_s_e.o p7_enc.o p7_lib.o f_int.o f_string.o i2d_dhp.o i2d_dsap.o d2i_dhp.o d2i_dsap.o n_pkey.o a_hdr.o x_pkey.o x_privkey.o a_bool.o x_exten.o asn1_par.o asn1_lib.o asn1_err.o a_meth.o a_bytes.o evp_asn1.o +LIBSRC=a_object.c a_bitstr.c a_utctm.c a_int.c a_octet.c a_print.c a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c a_sign.c a_digest.c a_verify.c x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c x_name.c x_cinf.c x_x509.c x_crl.c x_info.c x_spki.c d2i_r_pr.c i2d_r_pr.c d2i_r_pu.c i2d_r_pu.c d2i_s_pr.c i2d_s_pr.c d2i_s_pu.c i2d_s_pu.c d2i_pu.c d2i_pr.c i2d_pu.c i2d_pr.c t_req.c t_x509.c t_pkey.c p7_i_s.c p7_signi.c p7_signd.c p7_recip.c p7_enc_c.c p7_evp.c p7_dgst.c p7_s_e.c p7_enc.c p7_lib.c f_int.c f_string.c i2d_dhp.c i2d_dsap.c d2i_dhp.c d2i_dsap.c n_pkey.c a_hdr.c x_pkey.c x_privkey.c a_bool.c x_exten.c asn1_par.c asn1_lib.c asn1_err.c a_meth.c a_bytes.c evp_asn1.c MAKE=make -f Makefile.ssl MAKEDEPEND=makedepend -f Makefile.ssl MAKEFILE=Makefile.ssl -SRC=a_object.c a_bitstr.c a_utctm.c a_int.c a_octet.c a_print.c a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c a_sign.c a_digest.c a_verify.c x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c x_name.c x_cinf.c x_x509.c x_crl.c x_info.c x_spki.c d2i_r_pr.c i2d_r_pr.c d2i_r_pu.c i2d_r_pu.c d2i_s_pr.c i2d_s_pr.c d2i_s_pu.c i2d_s_pu.c d2i_pu.c d2i_pr.c i2d_pu.c i2d_pr.c t_req.c t_x509.c t_pkey.c p7_i_s.c p7_signi.c p7_signd.c p7_recip.c p7_enc_c.c p7_evp.c p7_dgst.c p7_s_e.c p7_enc.c p7_lib.c f_int.c f_string.c i2d_dhp.c i2d_dsap.c d2i_dhp.c d2i_dsap.c n_pkey.c a_hdr.c x_pkey.c a_bool.c x_exten.c asn1_par.c asn1_lib.c asn1_err.c a_meth.c a_bytes.c evp_asn1.c +SRC=a_object.c a_bitstr.c a_utctm.c a_int.c a_octet.c a_print.c a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c a_sign.c a_digest.c a_verify.c x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c x_name.c x_cinf.c x_x509.c x_crl.c x_info.c x_spki.c d2i_r_pr.c i2d_r_pr.c d2i_r_pu.c i2d_r_pu.c d2i_s_pr.c i2d_s_pr.c d2i_s_pu.c i2d_s_pu.c d2i_pu.c d2i_pr.c i2d_pu.c i2d_pr.c t_req.c t_x509.c t_pkey.c p7_i_s.c p7_signi.c p7_signd.c p7_recip.c p7_enc_c.c p7_evp.c p7_dgst.c p7_s_e.c p7_enc.c p7_lib.c f_int.c f_string.c i2d_dhp.c i2d_dsap.c d2i_dhp.c d2i_dsap.c n_pkey.c a_hdr.c x_pkey.c x_privkey.c a_bool.c x_exten.c asn1_par.c asn1_lib.c asn1_err.c a_meth.c a_bytes.c evp_asn1.c TEST= TOP=../.. RELATIVE_DIRECTORY= @@ -843,6 +843,31 @@ MAKEFILE=Makefile.ssl SRC=s2_meth.c s2_srvr.c s2_clnt.c s2_lib.c s2_enc.c s2_pkt.c s3_meth.c s3_srvr.c s3_clnt.c s3_lib.c s3_enc.c s3_pkt.c s3_both.c s23_meth.c s23_srvr.c s23_clnt.c s23_lib.c s23_pkt.c t1_meth.c t1_srvr.c t1_clnt.c t1_lib.c t1_enc.c ssl_lib.c ssl_err2.c ssl_cert.c ssl_sess.c ssl_ciph.c ssl_stat.c ssl_rsa.c ssl_asn1.c ssl_txt.c ssl_algs.c bio_ssl.c ssl_err.c TEST=ssltest.c +TOP=.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=bsafe +ALL=Makefile bsafe.c bsaf_err.c bsafe_glue.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I../crypto -I../include -g +DIR=bsafe +ERR=bsafe +ERRC=bsaf_err +EXHEADER= +GENERAL=Makefile +HEADER= bsafe_glue.h +INCLUDES=-I../crypto -I../include -I../../bsafe +INSTALLTOP=/usr/local/ssl +LIB=../libBSAFEglue.a +LIBOBJ=bsafe.o bsaf_err.o tstdlib.o +LIBSRC=bsafe.c bsaf_err.c tstdlib.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=bsafe.c bsaf_err.c tstdlib.c +TEST=bsafetest.c TOP=.. RELATIVE_DIRECTORY= RELATIVE_DIRECTORY=rsaref diff -urN SSLeay-0.9.0-clean/Makefile.ssl SSLeay-0.9.0/Makefile.ssl --- SSLeay-0.9.0-clean/Makefile.ssl Thu Apr 09 08:47:13 1998 +++ SSLeay-0.9.0/Makefile.ssl Mon Jun 29 11:21:01 1998 @@ -30,6 +30,7 @@ # # NOCONST - Define for C compilers that don't like the const key word. # NOPROTO - Define in if your compiler does not support prototypes. +# BSAFE - Define if we are to link with BSAFE. # RSAref - Define if we are to link with RSAref. # NO_IDEA - Define to build without the IDEA algorithm # NO_RC4 - Define to build without the RC4 algorithm @@ -63,7 +64,10 @@ #CFLAG= -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -m486 -Wall -Wuninitialized -DMD5_ASM -DSHA1_ASM -DRMD160_ASM CFLAG= -O -DNOPROTO PEX_LIBS= -L. -L.. -L../.. -L../../.. -EX_LIBS= +BSAFE_CFLAGS=-DBSAFE -I../../bsafe/include -I../../../bsafe/include +BSAFE_LIBS=-L../../bsafe/lib -L../../../bsafe/lib -lBSAFEglue -lbsafe +EX_LIBS= $(BSAFE_LIBS) + AR=ar r # Set BN_MULW to bn_mulw.o if you want to use the C version @@ -147,7 +151,7 @@ #RMD160_ASM_OBJ= asm/rm86-out.o # a.out, FreeBSD #RMD160_ASM_OBJ= asm/rm86bsdi.o # bsdi -DIRS= crypto ssl rsaref apps test tools +DIRS= crypto ssl rsaref bsafe apps test tools # dirs in crypto to build SDIRS= \ md2 md5 sha mdc2 hmac ripemd \ diff -urN SSLeay-0.9.0-clean/bsafe/Makefile.ssl SSLeay-0.9.0/bsafe/Makefile.ssl --- SSLeay-0.9.0-clean/bsafe/Makefile.ssl Wed Dec 31 16:00:00 1969 +++ SSLeay-0.9.0/bsafe/Makefile.ssl Mon Jun 29 11:21:01 1998 @@ -0,0 +1,87 @@ +# +# SSLeay/bsafe/Makefile +# + +DIR= bsafe +TOP= .. +CC= cc +INCLUDES= -I../crypto -I../include -I../../bsafe/include -I../../../bsafe/include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -fMakefile.ssl +MAKEFILE= Makefile.ssl + +CFLAGS= $(INCLUDES) $(CFLAG) + +ERR=bsafe +ERRC=bsaf_err +GENERAL=Makefile +TEST= +APPS= + +LIB=$(TOP)/libBSAFEglue.a +LIBSRC= bsafe.c tstdlib.c $(ERRC).c +LIBOBJ= bsafe.o tstdlib.o $(ERRC).o + +SRC= $(LIBSRC) + +EXHEADER= +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ..; $(MAKE) DIRS=bsafe all) + +all: lib + +lib: $(LIBOBJ) + ar r $(LIB) $(LIBOBJ) + $(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: + sed -e '/^# DO NOT DELETE THIS LINE/ q' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .nfs* *.old *.bak fluff + +errors: + sed -e "/ERROR CODES/ r $(ERR).err" -e "/ERROR CODES/ q" \ + <$(ERR).h >$(ERR).new + mv $(ERR).h $(ERR).old + mv $(ERR).new $(ERR).h + perl ../crypto/error/err_genc.pl $(ERR).h $(ERRC).c >$(ERRC).c + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff -urN SSLeay-0.9.0-clean/bsafe/bsaf_err.c SSLeay-0.9.0/bsafe/bsaf_err.c --- SSLeay-0.9.0-clean/bsafe/bsaf_err.c Wed Dec 31 16:00:00 1969 +++ SSLeay-0.9.0/bsafe/bsaf_err.c Mon Jun 29 11:21:01 1998 @@ -0,0 +1,118 @@ +/* lib/bsafe/bsafe_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 +#include "cryptlib.h" +#include "bn.h" +#include "rsa.h" +#include "x509.h" +#include "err.h" +#include "bsafe_glue.h" + +/* BEGIN ERROR CODES */ +#ifndef NO_ERR +static ERR_STRING_DATA BSAFE_str_functs[]= + { +{ERR_PACK(0,BSAFE_F_BN_BSAFE_MOD_EXP,0), "BN_BSAFE_MOD_EXP"}, +{ERR_PACK(0,BSAFE_F_RSA_BN2BIN,0), "BSAFE_BN2BIN"}, +{ERR_PACK(0,BSAFE_F_RSA_PRIVATE_DECRYPT,0), "BSAFE_PRIVATE_DECRYPT"}, +{ERR_PACK(0,BSAFE_F_RSA_PRIVATE_ENCRYPT,0), "BSAFE_PRIVATE_ENCRYPT"}, +{ERR_PACK(0,BSAFE_F_RSA_PUBLIC_DECRYPT,0), "BSAFE_PUBLIC_DECRYPT"}, +{ERR_PACK(0,BSAFE_F_RSA_PUBLIC_ENCRYPT,0), "BSAFE_F_RSA_PUBLIC_ENCRYPT"}, +{ERR_PACK(0,BSAFE_F_PUBLIC_BSAFE_TO_EAY,0), "BSAFE_F_PUBLIC_BSAFE_TO_EAY"}, +{ERR_PACK(0,BSAFE_F_PUBLIC_EAY_TO_BSAFE,0), "BSAFE_F_PUBLIC_EAY_TO_BSAFE"}, +{ERR_PACK(0,BSAFE_F_PRIVATE_BSAFE_TO_EAY,0), "BSAFE_F_PRIVATE_BSAFE_TO_EAY"}, +{ERR_PACK(0,BSAFE_F_PRIVATE_EAY_TO_BSAFE,0), "BSAFE_F_PRIVATE_EAY_TO_BSAFE"}, +{ERR_PACK(0,BSAFE_F_BSAFE_MOD_EXP,0), "BSAFE_F_BSAFE_MOD_EXP"}, +{0,NULL}, + }; + +static ERR_STRING_DATA BSAFE_str_reasons[]= + { +{BSAFE_R_CONTENT_ENCODING ,"content encoding"}, +{BSAFE_R_DATA ,"data"}, +{BSAFE_R_DIGEST_ALGORITHM ,"digest algorithm"}, +{BSAFE_R_ENCODING ,"encoding"}, +{BSAFE_R_ENCRYPTION_ALGORITHM ,"encryption algorithm"}, +{BSAFE_R_KEY ,"key"}, +{BSAFE_R_KEY_ENCODING ,"key encoding"}, +{BSAFE_R_LEN ,"len"}, +{BSAFE_R_MODULUS_LEN ,"modulus len"}, +{BSAFE_R_NEED_RANDOM ,"need random"}, +{BSAFE_R_PRIVATE_KEY ,"private key"}, +{BSAFE_R_PUBLIC_KEY ,"public key"}, +{BSAFE_R_SIGNATURE ,"signature"}, +{BSAFE_R_SIGNATURE_ENCODING ,"signature encoding"}, +{0,NULL}, + }; + +#endif + +void ERR_load_BSAFE_strings() + { + static int init=1; + + if (init); + {; + init=0; +#ifndef NO_ERR + ERR_load_strings(ERR_LIB_BSAFE,BSAFE_str_functs); + ERR_load_strings(ERR_LIB_BSAFE,BSAFE_str_reasons); +#endif + + } + } diff -urN SSLeay-0.9.0-clean/bsafe/bsafe.c SSLeay-0.9.0/bsafe/bsafe.c --- SSLeay-0.9.0-clean/bsafe/bsafe.c Wed Dec 31 16:00:00 1969 +++ SSLeay-0.9.0/bsafe/bsafe.c Mon Jun 29 11:21:01 1998 @@ -0,0 +1,584 @@ +/* bsafe/bsafe.c */ +/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) + * All rights reserved. + * + * This file is part of an SSL implementation written + * by Eric Young (eay@mincom.oz.au). + * The implementation was written so as to conform with Netscapes SSL + * specification. This library and applications are + * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE + * as long as the following conditions are aheared to. + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. If this code is used in a product, + * Eric Young should be given attribution as the author of the parts 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 software developed by Eric Young (eay@mincom.oz.au) + * + * 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 +#include "cryptlib.h" +#include "bn.h" +#include "rsa.h" +#include "x509.h" +#include "rand.h" +#include "objects.h" +#include "bsafe_glue.h" + +/* + *---------------------------------------------------------------------- + * BSAFE_Private_bsafe2eay -- + * + * Convert a private key from BSAFE format to SSLeay format. + * The conversion may not be the most efficient, but it is + * the only way to do it with publically available info. + * I could check to see if the data is held in essentially + * the same format and then do a direct conversion. + *---------------------------------------------------------------------- + */ +int +BSAFE_Private_bsafe2eay(from,to) +B_KEY_OBJ from; +RSA **to; + { + X509_PRIVKEY *privkey=NULL; + ITEM *bsafeKeyBER=NULL; + int i; + int length; + unsigned char *p; + + if ((i=B_GetKeyInfo((POINTER *)&bsafeKeyBER, + from,KI_PKCS_RSAPrivateBER)) != 0) + { + BSAFEerr(BSAFE_F_PRIVATE_BSAFE_TO_EAY,i); + goto err; + } + p=bsafeKeyBER->data; + length=bsafeKeyBER->len; + + if (! d2i_X509_PRIVKEY(&privkey,&p,length)) + { + BSAFEerr(BSAFE_F_PRIVATE_BSAFE_TO_EAY,i); + goto err; + } + + p=privkey->privkey->data; + length=privkey->privkey->length; + if (! d2i_RSAPrivateKey(to,&p,length)) + { + BSAFEerr(BSAFE_F_PRIVATE_BSAFE_TO_EAY,ERR_R_BSAFE_LIB); + goto err; + } + X509_PRIVKEY_free(privkey); + return 1; + err: + if (privkey != NULL) X509_PRIVKEY_free(privkey); + return 0; + } + +int +BSAFE_Private_eay2bsafe(from,to) +RSA *from; +B_KEY_OBJ *to; + { + X509_PRIVKEY *privkey=NULL; + int length; + int i; + ITEM bsafeKeyBER; + unsigned char *p; + + if (from == NULL || to == NULL) return 0; + privkey=X509_PRIVKEY_new(); + if (privkey == NULL) return 0; + bsafeKeyBER.data=NULL; + ASN1_INTEGER_set(privkey->version,0); + ASN1_OBJECT_free(privkey->algor->algorithm); + privkey->algor->algorithm=OBJ_nid2obj(NID_rsaEncryption); + length=i2d_RSAPrivateKey(from,NULL); + privkey->privkey->length=length; + p=malloc(length); + if (p == NULL) + { + BSAFEerr(BSAFE_F_PRIVATE_EAY_TO_BSAFE,ERR_R_BSAFE_LIB); + goto err; + } + privkey->privkey->data=p; + i2d_RSAPrivateKey(from,&p); + + length=i2d_X509_PRIVKEY(privkey,NULL); + bsafeKeyBER.len=length; + p=malloc(length); + if (p == NULL) goto err; + bsafeKeyBER.data=p; + i2d_X509_PRIVKEY(privkey,&p); + + if (*to == NULL) + { + if ((i=B_CreateKeyObject(to)) != 0) + { + BSAFEerr(BSAFE_F_PRIVATE_EAY_TO_BSAFE,i); + goto err; + } + } + if ((i=B_SetKeyInfo(*to,KI_PKCS_RSAPrivateBER, + (POINTER)&bsafeKeyBER)) != 0) + { + BSAFEerr(BSAFE_F_PRIVATE_EAY_TO_BSAFE,i); + goto err; + } + X509_PRIVKEY_free(privkey); + free(bsafeKeyBER.data); + return(1); + err: + if (privkey != NULL) X509_PRIVKEY_free(privkey); + if (bsafeKeyBER.data != NULL) free(bsafeKeyBER.data); + return 0; + } + +int +BSAFE_Public_bsafe2eay(from,to) +B_KEY_OBJ from; +RSA **to; + { + X509_PUBKEY *pubkey=NULL; + ITEM *bsafeKeyBER=NULL; + int i; + int length; + unsigned char *p; + + if ((i=B_GetKeyInfo((POINTER *)&bsafeKeyBER, + from,KI_RSAPublicBER)) != 0) + { + BSAFEerr(BSAFE_F_PUBLIC_BSAFE_TO_EAY,i); + goto err; + } + p=bsafeKeyBER->data; + length=bsafeKeyBER->len; + + if (! d2i_X509_PUBKEY(&pubkey,&p,length)) + { + BSAFEerr(BSAFE_F_PUBLIC_BSAFE_TO_EAY,i); + goto err; + } + + p=pubkey->public_key->data; + length=pubkey->public_key->length; + if (! d2i_RSAPublicKey(to,&p,length)) + { + BSAFEerr(BSAFE_F_PUBLIC_BSAFE_TO_EAY,ERR_R_BSAFE_LIB); + goto err; + } + X509_PUBKEY_free(pubkey); + return 1; + err: + if (pubkey != NULL) X509_PUBKEY_free(pubkey); + return 0; + } + +int +BSAFE_Public_eay2bsafe(from,to) +RSA *from; +B_KEY_OBJ *to; + { + X509_PUBKEY *pubkey=NULL; + int length; + int i; + ITEM bsafeKeyBER; + unsigned char *p; + + if (from == NULL || to == NULL) return 0; + pubkey=X509_PUBKEY_new(); + if (pubkey == NULL) return 0; + bsafeKeyBER.data=NULL; + ASN1_OBJECT_free(pubkey->algor->algorithm); + pubkey->algor->algorithm=OBJ_nid2obj(NID_rsaEncryption); + length=i2d_RSAPublicKey(from,NULL); + pubkey->public_key->length=length; + p=malloc(length); + if (p == NULL) + { + BSAFEerr(BSAFE_F_PUBLIC_EAY_TO_BSAFE,ERR_R_BSAFE_LIB); + goto err; + } + pubkey->public_key->data=p; + i2d_RSAPublicKey(from,&p); + + length=i2d_X509_PUBKEY(pubkey,NULL); + bsafeKeyBER.len=length; + p=malloc(length); + if (p == NULL) goto err; + bsafeKeyBER.data=p; + i2d_X509_PUBKEY(pubkey,&p); + + if (*to == NULL) + { + if ((i=B_CreateKeyObject(to)) != 0) + { + BSAFEerr(BSAFE_F_PUBLIC_EAY_TO_BSAFE,i); + goto err; + } + } + if ((i=B_SetKeyInfo(*to,KI_RSAPublicBER, + (POINTER)&bsafeKeyBER)) != 0) + { + BSAFEerr(BSAFE_F_PUBLIC_EAY_TO_BSAFE,i); + goto err; + } + X509_PUBKEY_free(pubkey); + free(bsafeKeyBER.data); + return(1); + err: + if (pubkey != NULL) X509_PUBKEY_free(pubkey); + if (bsafeKeyBER.data != NULL) free(bsafeKeyBER.data); + return 0; + } + +int +BSAFE_private_decrypt(len,from,to,rsa,padding) +int len; +unsigned char *from,*to; +RSA *rsa; +int padding; + { + int i,outlen= -1; + int outlenUpdate=0; + int n; + B_KEY_OBJ RSAKey=NULL; + B_ALGORITHM_OBJ rsaDecryptor=NULL; + B_ALGORITHM_METHOD *RSA_CHOOSER[] = { &AM_RSA_DECRYPT, + &AM_RSA_CRT_DECRYPT, NULL }; + + if (!BSAFE_Private_eay2bsafe(rsa,&RSAKey)) + goto err; + + if ((i=B_CreateAlgorithmObject(&rsaDecryptor)) != 0) + { + BSAFEerr(BSAFE_F_RSA_PRIVATE_DECRYPT,i); + goto err; + } + if ((i=B_SetAlgorithmInfo(rsaDecryptor, AI_PKCS_RSAPrivate, NULL)) != 0) + { + BSAFEerr(BSAFE_F_RSA_PUBLIC_DECRYPT,i); + goto err; + } + if ((i=B_DecryptInit(rsaDecryptor,RSAKey,RSA_CHOOSER,NULL)) != 0) + { + BSAFEerr(BSAFE_F_RSA_PRIVATE_DECRYPT,i); + goto err; + } + n=RSA_size(rsa); + if ((i=B_DecryptUpdate(rsaDecryptor,to,&outlenUpdate,n, + from,len,NULL,NULL)) != 0) + { + BSAFEerr(BSAFE_F_RSA_PRIVATE_DECRYPT,i); + goto err; + } + if ((i=B_DecryptFinal(rsaDecryptor,to + outlenUpdate,&outlen, + n-outlenUpdate,NULL,NULL)) != 0) + { + BSAFEerr(BSAFE_F_RSA_PRIVATE_DECRYPT,i); + goto err; + } + outlen += outlenUpdate; +err: + /* memset(RSAKey,0,sizeof(RSAKey)); */ + if (rsaDecryptor) B_DestroyAlgorithmObject(&rsaDecryptor); + if (RSAKey) B_DestroyKeyObject(&RSAKey); + + return(outlen); + } + + +int +BSAFE_private_encrypt(len,from,to,rsa,padding) +int len; +unsigned char *from,*to; +RSA *rsa; +int padding; + { + int outlen= -1; + int outlenUpdate=0; + unsigned char buf[16]; + int i,n; + B_KEY_OBJ RSAKey=NULL; + B_ALGORITHM_OBJ randomAlg=NULL; + B_ALGORITHM_OBJ rsaEncryptor=NULL; + B_ALGORITHM_METHOD *RSA_CHOOSER[] = { &AM_RSA_ENCRYPT, + &AM_RSA_CRT_ENCRYPT, NULL }; + B_ALGORITHM_METHOD *RANDOM_CHOOSER[] = { &AM_MD5_RANDOM, NULL }; + + if (!BSAFE_Private_eay2bsafe(rsa,&RSAKey)) + goto err; + randomAlg=NULL; + if ((i=B_CreateAlgorithmObject(&randomAlg)) != 0) + { + BSAFEerr(BSAFE_F_RSA_PRIVATE_DECRYPT,i); + goto err; + } + if ((i=B_SetAlgorithmInfo(randomAlg,AI_MD5Random,NULL_PTR)) != 0) + { + BSAFEerr(BSAFE_F_RSA_PRIVATE_DECRYPT,i); + goto err; + } + if ((i=B_RandomInit(randomAlg,RANDOM_CHOOSER,NULL)) != 0) + { + BSAFEerr(BSAFE_F_RSA_PRIVATE_DECRYPT,i); + goto err; + } + + /* Throw in 256 bytes of random data */ + n=256; + while (n > 0) + { + RAND_bytes(buf,16); + if ((i=B_RandomUpdate(randomAlg,buf, + (unsigned int)((n>16)?16:n), NULL)) != 0) + { + BSAFEerr(BSAFE_F_RSA_PRIVATE_DECRYPT,i); + goto err; + } + n -= 16; + } + + if ((i=B_CreateAlgorithmObject(&rsaEncryptor)) != 0) + { + BSAFEerr(BSAFE_F_RSA_PRIVATE_ENCRYPT,i); + goto err; + } + if ((i=B_SetAlgorithmInfo(rsaEncryptor,AI_PKCS_RSAPrivate,NULL)) != 0) + { + BSAFEerr(BSAFE_F_RSA_PRIVATE_ENCRYPT,i); + goto err; + } + if ((i=B_EncryptInit(rsaEncryptor,RSAKey,RSA_CHOOSER,NULL)) != 0) + { + BSAFEerr(BSAFE_F_RSA_PRIVATE_ENCRYPT,i); + goto err; + } + n=RSA_size(rsa); + if ((i=B_EncryptUpdate(rsaEncryptor,to,&outlenUpdate,n,from,len, + randomAlg, NULL)) != 0) + { + BSAFEerr(BSAFE_F_RSA_PRIVATE_ENCRYPT,i); + goto err; + } + if ((i=B_EncryptFinal(rsaEncryptor,to + outlenUpdate,&outlen, + n-outlenUpdate,randomAlg,NULL)) != 0) + { + BSAFEerr(BSAFE_F_RSA_PRIVATE_ENCRYPT,i); + goto err; + } + outlen += outlenUpdate; +err: + B_DestroyAlgorithmObject(&randomAlg); + B_DestroyAlgorithmObject(&rsaEncryptor); + /* memset(&RSAKey,0,sizeof(RSAKey)); */ + B_DestroyKeyObject(&RSAKey); + return(outlen); + } + +int +BSAFE_public_decrypt(len,from,to,rsa,padding) +int len; +unsigned char *from,*to; +RSA *rsa; +int padding; + { + int i,outlen= -1; + int n; + int outlenUpdate=0; + B_KEY_OBJ RSAKey=NULL; + B_ALGORITHM_OBJ rsaDecryptor=NULL; + B_ALGORITHM_METHOD *RSA_CHOOSER[] = { &AM_RSA_DECRYPT, NULL }; + + if (!BSAFE_Public_eay2bsafe(rsa,&RSAKey)) + goto err; + + if ((i=B_CreateAlgorithmObject(&rsaDecryptor)) != 0) + { + BSAFEerr(BSAFE_F_RSA_PUBLIC_DECRYPT,i); + goto err; + } + if ((i=B_SetAlgorithmInfo(rsaDecryptor, AI_PKCS_RSAPublic, NULL)) != 0) + { + BSAFEerr(BSAFE_F_RSA_PUBLIC_DECRYPT,i); + goto err; + } + if ((i=B_DecryptInit(rsaDecryptor,RSAKey,RSA_CHOOSER,NULL)) != 0) + { + BSAFEerr(BSAFE_F_RSA_PUBLIC_DECRYPT,i); + goto err; + } + n=RSA_size(rsa); + if ((i=B_DecryptUpdate(rsaDecryptor,to,&outlenUpdate,n, + from,len,NULL,0)) != 0) + { + BSAFEerr(BSAFE_F_RSA_PUBLIC_DECRYPT,i); + goto err; + } + if ((i=B_DecryptFinal(rsaDecryptor,to + outlenUpdate,&outlen, + n-outlenUpdate,NULL, NULL)) != 0) + { + BSAFEerr(BSAFE_F_RSA_PUBLIC_DECRYPT,i); + goto err; + } + outlen += outlenUpdate; +err: + /* memset(RSAKey,0,sizeof(RSAKey)); */ + if (rsaDecryptor) B_DestroyAlgorithmObject(&rsaDecryptor); + if (RSAKey) B_DestroyKeyObject(&RSAKey); + + return(outlen); + } + +int +BSAFE_public_encrypt(len,from,to,rsa,padding) +int len; +unsigned char *from,*to; +RSA *rsa; +int padding; + { + int outlen= -1; + int outlenUpdate=0; + unsigned char buf[16]; + int i,n; + B_KEY_OBJ RSAKey=NULL; + B_ALGORITHM_OBJ randomAlg=NULL; + B_ALGORITHM_OBJ rsaEncryptor=NULL; + B_ALGORITHM_METHOD *RSA_CHOOSER[] = { &AM_RSA_ENCRYPT, NULL }; + B_ALGORITHM_METHOD *RANDOM_CHOOSER[] = { &AM_MD5_RANDOM, NULL }; + + if (!BSAFE_Public_eay2bsafe(rsa,&RSAKey)) + goto err; + randomAlg=NULL; + if ((i=B_CreateAlgorithmObject(&randomAlg)) != 0) + { + BSAFEerr(BSAFE_F_RSA_PUBLIC_DECRYPT,i); + goto err; + } + if ((i=B_SetAlgorithmInfo(randomAlg,AI_MD5Random,NULL_PTR)) != 0) + { + BSAFEerr(BSAFE_F_RSA_PUBLIC_DECRYPT,i); + goto err; + } + if ((i=B_RandomInit(randomAlg,RANDOM_CHOOSER,NULL)) != 0) + { + BSAFEerr(BSAFE_F_RSA_PUBLIC_DECRYPT,i); + goto err; + } + + /* Throw in 256 bytes of random data */ + n=256; + while (n > 0) + { + RAND_bytes(buf,16); + if ((i=B_RandomUpdate(randomAlg,buf, + (unsigned int)((n>16)?16:n), NULL)) != 0) + { + BSAFEerr(BSAFE_F_RSA_PUBLIC_DECRYPT,i); + goto err; + } + n-=16; + } + + if ((i=B_CreateAlgorithmObject(&rsaEncryptor)) != 0) + { + BSAFEerr(BSAFE_F_RSA_PUBLIC_ENCRYPT,i); + goto err; + } + if ((i=B_SetAlgorithmInfo(rsaEncryptor,AI_PKCS_RSAPublic,NULL)) != 0) + { + BSAFEerr(BSAFE_F_RSA_PUBLIC_ENCRYPT,i); + goto err; + } + if ((i=B_EncryptInit(rsaEncryptor,RSAKey,RSA_CHOOSER,NULL)) != 0) + { + BSAFEerr(BSAFE_F_RSA_PUBLIC_ENCRYPT,i); + goto err; + } + n=RSA_size(rsa); + if ((i=B_EncryptUpdate(rsaEncryptor,to,&outlenUpdate,n,from,len, + randomAlg, NULL)) != 0) + { + BSAFEerr(BSAFE_F_RSA_PUBLIC_ENCRYPT,i); + goto err; + } + if ((i=B_EncryptFinal(rsaEncryptor,to + outlenUpdate,&outlen, + n-outlenUpdate, randomAlg, NULL)) != 0) + { + BSAFEerr(BSAFE_F_RSA_PUBLIC_ENCRYPT,i); + goto err; + } +err: + B_DestroyAlgorithmObject(&randomAlg); + B_DestroyAlgorithmObject(&rsaEncryptor); + /* memset(&RSAKey,0,sizeof(RSAKey)); */ + B_DestroyKeyObject(&RSAKey); + return(outlen); + } + +static int BSAFE_mod_exp(r0, I, rsa) +BIGNUM *r0; +BIGNUM *I; +RSA *rsa; + { + RSAREFerr(BSAFE_F_BSAFE_MOD_EXP,ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return(0); + } + +static int BN_ref_mod_exp(r,a,p,m,ctx) +BIGNUM *r,*a,*p,*m; +BN_CTX *ctx; + { + RSAREFerr(BSAFE_F_BN_BSAFE_MOD_EXP,ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return(0); + } + +static RSA_METHOD rsa_pkcs1_bsafe_meth={ + "BSAFE PKCS#1 RSA", + BSAFE_public_encrypt, + BSAFE_public_decrypt, + BSAFE_private_encrypt, + BSAFE_private_decrypt, + BSAFE_mod_exp, + BN_ref_mod_exp, + NULL, + NULL, + 0, + NULL, + }; + +RSA_METHOD *RSA_PKCS1_BSAFE() + { + return(&rsa_pkcs1_bsafe_meth); + } + diff -urN SSLeay-0.9.0-clean/bsafe/bsafe.err SSLeay-0.9.0/bsafe/bsafe.err --- SSLeay-0.9.0-clean/bsafe/bsafe.err Wed Dec 31 16:00:00 1969 +++ SSLeay-0.9.0/bsafe/bsafe.err Mon Jun 29 11:21:01 1998 @@ -0,0 +1,29 @@ +/* Error codes for the BSAFE functions. */ + +/* Function codes. */ +#define BSAFE_F_BN_REF_MOD_EXP 100 +#define BSAFE_F_RSA_BN2BIN 101 +#define BSAFE_F_RSA_PRIVATE_DECRYPT 102 +#define BSAFE_F_RSA_PRIVATE_ENCRYPT 103 +#define BSAFE_F_RSA_PUBLIC_DECRYPT 104 +#define BSAFE_F_RSA_PUBLIC_ENCRYPT 105 +#define BSAFE_F_PUBLIC_BSAFE_TO_EAY 106 +#define BSAFE_F_PUBLIC_EAY_TO_BSAFE 107 +#define BSAFE_F_PRIVATE_BSAFE_TO_EAY 108 +#define BSAFE_F_PRIVATE_EAY_TO_BSAFE 109 + +/* Reason codes. */ +#define BSAFE_R_CONTENT_ENCODING 0x0400 +#define BSAFE_R_DATA 0x0401 +#define BSAFE_R_DIGEST_ALGORITHM 0x0402 +#define BSAFE_R_ENCODING 0x0403 +#define BSAFE_R_ENCRYPTION_ALGORITHM 0x040d +#define BSAFE_R_KEY 0x0404 +#define BSAFE_R_KEY_ENCODING 0x0405 +#define BSAFE_R_LEN 0x0406 +#define BSAFE_R_MODULUS_LEN 0x0407 +#define BSAFE_R_NEED_RANDOM 0x0408 +#define BSAFE_R_PRIVATE_KEY 0x0409 +#define BSAFE_R_PUBLIC_KEY 0x040a +#define BSAFE_R_SIGNATURE 0x040b +#define BSAFE_R_SIGNATURE_ENCODING 0x040c diff -urN SSLeay-0.9.0-clean/bsafe/bsafe_glue.h SSLeay-0.9.0/bsafe/bsafe_glue.h --- SSLeay-0.9.0-clean/bsafe/bsafe_glue.h Wed Dec 31 16:00:00 1969 +++ SSLeay-0.9.0/bsafe/bsafe_glue.h Mon Jun 29 11:21:01 1998 @@ -0,0 +1,99 @@ +/* bsafe/bsafe_glue.h */ +/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) + * All rights reserved. + * + * This file is part of an SSL implementation written + * by Eric Young (eay@mincom.oz.au). + * The implementation was written so as to conform with Netscapes SSL + * specification. This library and applications are + * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE + * as long as the following conditions are aheared to. + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. If this code is used in a product, + * Eric Young should be given attribution as the author of the parts 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 software developed by Eric Young (eay@mincom.oz.au) + * + * 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_BSAFE_GLUE_H +#define HEADER_BSAFE_GLUE_H + +#include +#include + +#ifndef NOPROTO +int BSAFE_Public_eay2bsafe(RSA * from, B_KEY_OBJ * to); +int BSAFE_Public_bsafe2eay(B_KEY_OBJ from, RSA ** to); +int BSAFE_Private_eay2bsafe(RSA * from, B_KEY_OBJ * to); +int BSAFE_Private_bsafe2eay(B_KEY_OBJ from, RSA ** to); +RSA_METHOD *RSA_PKCS1_RSAref(); +#else +int BSAFE_Public_eay2bsafe(); +int BSAFE_Public_bsafe2eay(); +int BSAFE_Private_eay2bsafe(); +int BSAFE_Private_bsafe2eay(); +RSA_METHOD *BSAFE_PKCS1_RSAref(); +#endif + +/* Error codes for the BSAFE functions. */ + +/* Function codes. */ +#define BSAFE_F_BN_BSAFE_MOD_EXP 100 +#define BSAFE_F_RSA_BN2BIN 101 +#define BSAFE_F_RSA_PRIVATE_DECRYPT 102 +#define BSAFE_F_RSA_PRIVATE_ENCRYPT 103 +#define BSAFE_F_RSA_PUBLIC_DECRYPT 104 +#define BSAFE_F_RSA_PUBLIC_ENCRYPT 105 +#define BSAFE_F_PUBLIC_BSAFE_TO_EAY 106 +#define BSAFE_F_PUBLIC_EAY_TO_BSAFE 107 +#define BSAFE_F_PRIVATE_BSAFE_TO_EAY 108 +#define BSAFE_F_PRIVATE_EAY_TO_BSAFE 109 +#define BSAFE_F_BSAFE_MOD_EXP 110 + +/* Reason codes. */ +#define BSAFE_R_CONTENT_ENCODING 0x0400 +#define BSAFE_R_DATA 0x0401 +#define BSAFE_R_DIGEST_ALGORITHM 0x0402 +#define BSAFE_R_ENCODING 0x0403 +#define BSAFE_R_ENCRYPTION_ALGORITHM 0x040d +#define BSAFE_R_KEY 0x0404 +#define BSAFE_R_KEY_ENCODING 0x0405 +#define BSAFE_R_LEN 0x0406 +#define BSAFE_R_MODULUS_LEN 0x0407 +#define BSAFE_R_NEED_RANDOM 0x0408 +#define BSAFE_R_PRIVATE_KEY 0x0409 +#define BSAFE_R_PUBLIC_KEY 0x040a +#define BSAFE_R_SIGNATURE 0x040b +#define BSAFE_R_SIGNATURE_ENCODING 0x040c + +#endif diff -urN SSLeay-0.9.0-clean/bsafe/bsafetest.c SSLeay-0.9.0/bsafe/bsafetest.c --- SSLeay-0.9.0-clean/bsafe/bsafetest.c Wed Dec 31 16:00:00 1969 +++ SSLeay-0.9.0/bsafe/bsafetest.c Mon Jun 29 11:21:01 1998 @@ -0,0 +1,307 @@ +/* Copyright (C) RSA Data Security, Inc. created 1993. + + This file is used to demonstrate how to interface to an + RSA Data Security, Inc. licensed development product. + + You have a royalty-free right to use, modify, reproduce and + distribute this demonstration file (including any modified + version), provided that you agree that RSA Data Security, + Inc. has no warranty, implied or otherwise, or liability + for this demonstration file or any modified version. + */ + +#include +#include +#include +#include "aglobal.h" +#include "bsafe.h" + +/* SSLeay includes */ +#include "bn.h" +#include "rsa.h" +#include "x509.h" + +/* This chooser selects the standard C implementations of the algorithm + methods. + */ +B_ALGORITHM_METHOD *DEMO_ALGORITHM_CHOOSER[] = { + &AM_DES_CBC_DECRYPT, + &AM_DES_CBC_ENCRYPT, + &AM_DH_KEY_AGREE, + &AM_DH_PARAM_GEN, + &AM_MD2, + &AM_MD2_RANDOM, + &AM_MD5, + &AM_MD5_RANDOM, + &AM_MD, + &AM_MAC, + &AM_SHA, + &AM_RC2_CBC_DECRYPT, + &AM_RC2_CBC_ENCRYPT, + &AM_RC5_CBC_DECRYPT, + &AM_RC5_CBC_ENCRYPT, + &AM_RC4_DECRYPT, + &AM_RC4_ENCRYPT, + &AM_RC4_WITH_MAC_DECRYPT, + &AM_RC4_WITH_MAC_ENCRYPT, + &AM_RSA_CRT_DECRYPT, + &AM_RSA_CRT_ENCRYPT, + &AM_RSA_DECRYPT, + &AM_RSA_ENCRYPT, + &AM_RSA_KEY_GEN, + &AM_DSA_PARAM_GEN, + &AM_DSA_KEY_GEN, + &AM_DSA_SIGN, + &AM_DSA_VERIFY, + (B_ALGORITHM_METHOD *)NULL_PTR +}; + +/* the public key encryption exponent Fermat 4 (F4) = 65537 */ +unsigned char EXPONENT_F4[3] = {0x1, 0x0, 0x1}; + +static unsigned char PUBLIC_KEY3_DATA[1024]; +static unsigned int PUBLIC_KEY3_LEN = 0; +static unsigned char PRIVATE_KEY3_DATA[2048]; +static unsigned int PRIVATE_KEY3_LEN = 0; + +/* define parameters for password-based encryption */ +#define PBE_ITERATION_COUNT 1000 + +/* define size calculation macros for RSA key and DH parameter generation */ + +#define MAX_OBJECT_ID_LEN 11 +#define MAX_PBE_PARAMETER_LEN (2 + MAX_OBJECT_ID_LEN + 18) +#define MAX_RSA_PARAMETER_LEN 8 + +#define MAX_RSA_ALGORITHM_ID_LEN \ + (2 + MAX_OBJECT_ID_LEN + MAX_RSA_PARAMETER_LEN) + +#define MAX_PASSWORD_PROTECT_DELTA 8 +#define PUB_KEY_BYTES(modBits) (23 + MAX_RSA_ALGORITHM_ID_LEN + (modBits / 8)) + +#define PP_PRIV_KEY_BYTES(modBits) \ + (59 + MAX_RSA_ALGORITHM_ID_LEN + 2 * (modBits / 8) \ + + 5 * ((modBits + 1) / 16) + MAX_PASSWORD_PROTECT_DELTA) + +#define DH_PARAMS_BYTES(pBits) \ + (3 + MAX_OBJECT_ID_LEN + 13 + 2 * ((pBits / 8) + 1)) + +/* define maximum output buffer size for Diffie-Hellman computation, + RSA signatures and RSA Envelopes + */ + +#define MAX_DH_PRIME_BITS 2048 +#define MAX_DH_OUTPUT_BYTES (MAX_DH_PRIME_BITS / 8 + 1) +#define MAX_RSA_MODULUS 2048 +#define MAX_RSA_OUTPUT_BYTES (MAX_RSA_MODULUS / 8 + 1) + + +int BSL_MakeRSAKeyPairFromSeed + (publicKey, publicKeyLen, ppPrivateKey, ppPrivateKeyLen, + pbeParams, pbeParamsLen, keySizeBits, seed, seedLen, password, passwordLen) +unsigned char *publicKey; +unsigned int *publicKeyLen; +unsigned char *ppPrivateKey; +unsigned int *ppPrivateKeyLen; +unsigned char *pbeParams; +unsigned int *pbeParamsLen; +unsigned int keySizeBits; +unsigned char *seed; +unsigned int seedLen; +unsigned char *password; +unsigned int passwordLen; +{ + A_RSA_KEY_GEN_PARAMS keyGenParams; + B_ALGORITHM_OBJ generateAlgorithmObj = NULL_PTR; + B_ALGORITHM_OBJ pbEncryptionAlgorithmObj = NULL_PTR; + B_ALGORITHM_OBJ randomAlgorithmObj = NULL_PTR; + B_ALGORITHM_OBJ saltDigestAlgorithmObj = NULL_PTR; + B_KEY_OBJ passwordKeyObj = NULL_PTR; + B_KEY_OBJ privateKeyObj = NULL_PTR; + B_KEY_OBJ publicKeyObj = NULL_PTR; + int status; + RSA *ssleayPublicKey=NULL; + RSA *ssleayPrivateKey=NULL; + B_KEY_OBJ bsafePublicKey=NULL; + B_KEY_OBJ bsafePrivateKey=NULL; + + unsigned char toPrivateEncrypt[32] = { + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, + 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; + unsigned char publicEncrypted[64] = {0}; + unsigned char publicDecrypted[64] = {0}; + + unsigned char toPublicEncrypt[32] = { + 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, + 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32}; + unsigned char privateEncrypted[64] = {0}; + unsigned char privateDecrypted[64] = {0}; + + extern int BSAFE_Public_eay2bsafe(RSA * from, B_KEY_OBJ * to); + extern int BSAFE_Public_bsafe2eay(B_KEY_OBJ from, RSA ** to); + extern int BSAFE_Private_eay2bsafe(RSA * from, B_KEY_OBJ * to); + extern int BSAFE_Private_bsafe2eay(B_KEY_OBJ from, RSA ** to); + + /* do {} while(0); provides convenient way to ensure cleanup upon error */ + do { + + /* create random algorithm objects and set algorithm info */ + status = B_CreateAlgorithmObject (&randomAlgorithmObj); + if (status != 0) + break; + + status = B_SetAlgorithmInfo (randomAlgorithmObj, AI_MD5Random, NULL_PTR); + if (status != 0) + break; + /****************************************************************** + NOTE: The choice of MD5 for hashing random numbers is arbitrary. + AI_MD5Random may also be used. See Internet RFC1319 and RFC1321. + ******************************************************************/ + + /* call random init, update with supplied seed bytes */ + status = B_RandomInit + (randomAlgorithmObj, DEMO_ALGORITHM_CHOOSER, + (A_SURRENDER_CTX *)NULL_PTR); + if (status != 0) + break; + + status = B_RandomUpdate + (randomAlgorithmObj, seed, seedLen, (A_SURRENDER_CTX *)NULL_PTR); + if (status != 0) + break; + + /* create generate algorithm object */ + status = B_CreateAlgorithmObject (&generateAlgorithmObj); + if (status != 0) + break; + + /* set up key generation parameters and set algorithm object */ + keyGenParams.modulusBits = keySizeBits; + keyGenParams.publicExponent.data = EXPONENT_F4; + keyGenParams.publicExponent.len = sizeof (EXPONENT_F4); + status = B_SetAlgorithmInfo + (generateAlgorithmObj, AI_RSAKeyGen, (POINTER)&keyGenParams); + if (status != 0) + break; + /****************************************************************** + NOTE: The choice of F4 (65537) for a public exponent is arbitrary. + The value 3 or other value may also be used. See PKCS #1. + ******************************************************************/ + + /* generate init */ + status = B_GenerateInit + (generateAlgorithmObj, DEMO_ALGORITHM_CHOOSER, + (A_SURRENDER_CTX *)NULL_PTR); + if (status != 0) + break; + + /* create private and public key objects */ + status = B_CreateKeyObject (&privateKeyObj); + if (status != 0) + break; + + status = B_CreateKeyObject (&publicKeyObj); + if (status != 0) + break; + + /* generate keys and store in key objects (may take a few moments) */ + printf("Creating key pair...\n"); fflush(stdout); + status = B_GenerateKeypair + (generateAlgorithmObj, publicKeyObj, privateKeyObj, + randomAlgorithmObj, (A_SURRENDER_CTX *)NULL_PTR); + if (status != 0) + break; + + printf("BSAFE to SSLeay public key..."); fflush(stdout); + if (! BSAFE_Public_bsafe2eay(publicKeyObj, &ssleayPublicKey)) { + printf(" Failed.\n"); fflush(stdout); + break; + } else { + printf(" OK.\n"); fflush(stdout); + } + printf("SSLeay to BSAFE public key..."); fflush(stdout); + if (! BSAFE_Public_eay2bsafe(ssleayPublicKey, &bsafePublicKey)) { + printf(" Failed.\n"); fflush(stdout); + break; + } else { + printf(" OK.\n"); fflush(stdout); + } + + printf("BSAFE to SSLeay private key..."); fflush(stdout); + if (! BSAFE_Private_bsafe2eay(privateKeyObj, &ssleayPrivateKey)) { + printf(" Failed.\n"); fflush(stdout); + break; + } else { + printf(" OK.\n"); fflush(stdout); + } + + printf("SSLeay to BSAFE private key..."); fflush(stdout); + if (! BSAFE_Private_eay2bsafe(ssleayPrivateKey, &bsafePrivateKey)) { + printf(" Failed.\n"); fflush(stdout); + break; + } else { + printf(" OK.\n"); fflush(stdout); + } + + printf("RSA Private Encrypt..."); fflush(stdout); + if (RSA_private_encrypt(sizeof(toPrivateEncrypt), toPrivateEncrypt, + privateEncrypted, ssleayPrivateKey,0) == -1) { + printf(" Failed.\n"); fflush(stdout); + } else { + printf(" OK.\n"); fflush(stdout); + } + + printf("RSA Public Decrypt..."); fflush(stdout); + if (RSA_public_decrypt(sizeof(privateEncrypted), privateEncrypted, + privateDecrypted, ssleayPublicKey,0) == -1) { + printf(" Failed.\n"); fflush(stdout); + } else { + printf(" OK.\n"); fflush(stdout); + } + + printf("RSA Public Encrypt..."); fflush(stdout); + if (RSA_public_encrypt(sizeof(toPublicEncrypt), toPublicEncrypt, + publicEncrypted, ssleayPublicKey,0) == -1) { + printf(" Failed.\n"); fflush(stdout); + } else { + printf(" OK.\n"); fflush(stdout); + } + printf("RSA Private Decrypt..."); fflush(stdout); + if (RSA_private_decrypt(sizeof(publicEncrypted), publicEncrypted, + publicDecrypted, ssleayPrivateKey,0) == -1) { + printf(" Failed.\n"); fflush(stdout); + } else { + printf(" OK.\n"); fflush(stdout); + } + + } while (0); + + /* cleanup objects */ + B_DestroyAlgorithmObject (&generateAlgorithmObj); + B_DestroyAlgorithmObject (&pbEncryptionAlgorithmObj); + B_DestroyAlgorithmObject (&randomAlgorithmObj); + B_DestroyAlgorithmObject (&saltDigestAlgorithmObj); + B_DestroyKeyObject (&passwordKeyObj); + B_DestroyKeyObject (&privateKeyObj); + B_DestroyKeyObject (&publicKeyObj); + + return (status); +} + +int +main() +{ + int status; + unsigned int modulusBits = 512; + unsigned char *seed = "adfabadfafeafdkj"; + + if ((status = BSL_MakeRSAKeyPairFromSeed + (PUBLIC_KEY3_DATA, &PUBLIC_KEY3_LEN, PRIVATE_KEY3_DATA, + &PRIVATE_KEY3_LEN, (unsigned char *)NULL_PTR, 0, + (unsigned int)modulusBits, (unsigned char *)seed, + (unsigned int)strlen (seed), (unsigned char *)NULL_PTR, 0)) != 0) { + fprintf (stderr, "Error generating keys: %d\n", status); + exit(1); + } + return 0; +} diff -urN SSLeay-0.9.0-clean/bsafe/tstdlib.c SSLeay-0.9.0/bsafe/tstdlib.c --- SSLeay-0.9.0-clean/bsafe/tstdlib.c Wed Dec 31 16:00:00 1969 +++ SSLeay-0.9.0/bsafe/tstdlib.c Mon Jun 29 11:21:01 1998 @@ -0,0 +1,111 @@ +/* Copyright (C) RSA Data Security, Inc. created 1992. + + This file is used to demonstrate how to interface to an + RSA Data Security, Inc. licensed development product. + + You have a royalty-free right to use, modify, reproduce and + distribute this demonstration file (including any modified + version), provided that you agree that RSA Data Security, + Inc. has no warranty, implied or otherwise, or liability + for this demonstration file or any modified version. + */ + +#include +#include +#include +#include "aglobal.h" +#include "bsafe.h" + +/* If the standard C library comes with a memmove() that correctly + handles overlapping buffers, MEMMOVE_PRESENT should be defined as + 1, else 0. + The following defines MEMMOVE_PRESENT as 1 if it has not already been + defined as 0 with C compiler flags. + */ +#ifndef MEMMOVE_PRESENT +#define MEMMOVE_PRESENT 1 +#endif + +#ifndef WIN32 +#ifndef CALL_CONV +#define CALL_CONV +#endif +#endif + +void CALL_CONV T_memset (p, c, count) +POINTER p; +int c; +unsigned int count; +{ + if (count != 0) + memset (p, c, count); +} + +void CALL_CONV T_memcpy (d, s, count) +POINTER d, s; +unsigned int count; +{ + if (count != 0) + memcpy (d, s, count); +} + +void CALL_CONV T_memmove (d, s, count) +POINTER d, s; +unsigned int count; +{ +#if MEMMOVE_PRESENT + if (count != 0) + memmove (d, s, count); +#else + unsigned int i; + + if ((char *)d == (char *)s) + return; + else if ((char *)d > (char *)s) { + for (i = count; i > 0; i--) + ((char *)d)[i-1] = ((char *)s)[i-1]; + } + else { + for (i = 0; i < count; i++) + ((char *)d)[i] = ((char *)s)[i]; + } +#endif +} + +int CALL_CONV T_memcmp (s1, s2, count) +POINTER s1, s2; +unsigned int count; +{ + if (count == 0) + return (0); + else + return (memcmp (s1, s2, count)); +} + +POINTER CALL_CONV T_malloc (size) +unsigned int size; +{ + return ((POINTER)malloc (size == 0 ? 1 : size)); +} + +POINTER CALL_CONV T_realloc (p, size) +POINTER p; +unsigned int size; +{ + POINTER result; + + if (p == NULL_PTR) + return (T_malloc (size)); + + if ((result = (POINTER)realloc (p, size == 0 ? 1 : size)) == NULL_PTR) + free (p); + return (result); +} + +void CALL_CONV T_free (p) +POINTER p; +{ + if (p != NULL_PTR) + free (p); +} + diff -urN SSLeay-0.9.0-clean/crypto/asn1/Makefile.ssl SSLeay-0.9.0/crypto/asn1/Makefile.ssl --- SSLeay-0.9.0-clean/crypto/asn1/Makefile.ssl Thu Apr 09 08:47:17 1998 +++ SSLeay-0.9.0/crypto/asn1/Makefile.ssl Mon Jun 29 11:21:01 1998 @@ -34,7 +34,7 @@ p7_i_s.c p7_signi.c p7_signd.c p7_recip.c p7_enc_c.c p7_evp.c \ p7_dgst.c p7_s_e.c p7_enc.c p7_lib.c \ f_int.c f_string.c i2d_dhp.c i2d_dsap.c d2i_dhp.c d2i_dsap.c n_pkey.c \ - a_hdr.c x_pkey.c a_bool.c x_exten.c \ + a_hdr.c x_pkey.c x_privkey.c a_bool.c x_exten.c \ asn1_par.c asn1_lib.c $(ERRC).c a_meth.c a_bytes.c \ evp_asn1.c LIBOBJ= a_object.o a_bitstr.o a_utctm.o a_int.o a_octet.o a_print.o \ @@ -49,7 +49,7 @@ p7_i_s.o p7_signi.o p7_signd.o p7_recip.o p7_enc_c.o p7_evp.o \ p7_dgst.o p7_s_e.o p7_enc.o p7_lib.o \ f_int.o f_string.o i2d_dhp.o i2d_dsap.o d2i_dhp.o d2i_dsap.o n_pkey.o \ - a_hdr.o x_pkey.o a_bool.o x_exten.o \ + a_hdr.o x_pkey.o x_privkey.o a_bool.o x_exten.o \ asn1_par.o asn1_lib.o $(ERRC).o a_meth.o a_bytes.o \ evp_asn1.o diff -urN SSLeay-0.9.0-clean/crypto/asn1/asn1.h SSLeay-0.9.0/crypto/asn1/asn1.h --- SSLeay-0.9.0-clean/crypto/asn1/asn1.h Thu Apr 09 05:11:05 1998 +++ SSLeay-0.9.0/crypto/asn1/asn1.h Mon Jun 29 11:21:01 1998 @@ -794,6 +794,8 @@ #define ASN1_F_X509_SIG_NEW 219 #define ASN1_F_X509_VAL_FREE 220 #define ASN1_F_X509_VAL_NEW 221 +#define ASN1_F_X509_PRIVKEY_NEW 222 +#define ASN1_F_D2I_X509_PRIVKEY 223 /* Reason codes. */ #define ASN1_R_BAD_CLASS 100 diff -urN SSLeay-0.9.0-clean/crypto/asn1/x_privkey.c SSLeay-0.9.0/crypto/asn1/x_privkey.c --- SSLeay-0.9.0-clean/crypto/asn1/x_privkey.c Wed Dec 31 16:00:00 1969 +++ SSLeay-0.9.0/crypto/asn1/x_privkey.c Mon Jun 29 11:21:01 1998 @@ -0,0 +1,122 @@ +/* lib/asn1/x_privkey.c */ +/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) + * All rights reserved. + * + * This file is part of an SSL implementation written + * by Eric Young (eay@mincom.oz.au). + * The implementation was written so as to conform with Netscapes SSL + * specification. This library and applications are + * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE + * as long as the following conditions are aheared to. + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. If this code is used in a product, + * Eric Young should be given attribution as the author of the parts 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 software developed by Eric Young (eay@mincom.oz.au) + * + * 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 +#include "cryptlib.h" +#include "asn1_mac.h" +#include "x509.h" +#include "objects.h" + +#ifdef BSAFE +/* + * ASN1err(ASN1_F_D2I_X509_KEYU,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_X509_KEY_NEW,ASN1_R_BAD_GET_OBJECT); + */ + +X509_PRIVKEY *X509_PRIVKEY_new() + { + X509_PRIVKEY *ret=NULL; + + M_ASN1_New_Malloc(ret,X509_PRIVKEY); + ret->type=NID_undef; + M_ASN1_New(ret->version,ASN1_INTEGER_new); + M_ASN1_New(ret->algor,X509_ALGOR_new); + M_ASN1_New(ret->privkey,ASN1_OCTET_STRING_new); + M_ASN1_New(ret->attributes,sk_new_null); + return(ret); + M_ASN1_New_Error(ASN1_F_X509_PRIVKEY_NEW); + } + +void X509_PRIVKEY_free(a) +X509_PRIVKEY *a; + { + if (a == NULL) return; + ASN1_INTEGER_free(a->version); + X509_ALGOR_free(a->algor); + ASN1_OCTET_STRING_free(a->privkey); + sk_pop_free(a->attributes,ASN1_STRING_free); + Free(a); + } + +int i2d_X509_PRIVKEY(a,pp) +X509_PRIVKEY *a; +unsigned char **pp; + { + M_ASN1_I2D_vars(a); + + M_ASN1_I2D_len(a->version, i2d_ASN1_INTEGER); + M_ASN1_I2D_len(a->algor, i2d_X509_ALGOR); + M_ASN1_I2D_len(a->privkey, i2d_ASN1_OCTET_STRING); + M_ASN1_I2D_len_IMP_set_opt(a->attributes, i2d_X509_ATTRIBUTE,0); + + M_ASN1_I2D_seq_total(); + + M_ASN1_I2D_put(a->version, i2d_ASN1_INTEGER); + M_ASN1_I2D_put(a->algor, i2d_X509_ALGOR); + M_ASN1_I2D_put(a->privkey, i2d_ASN1_OCTET_STRING); + M_ASN1_I2D_put_IMP_set_opt(a->attributes, i2d_X509_ATTRIBUTE,0); + + M_ASN1_I2D_finish(); + } + +X509_PRIVKEY *d2i_X509_PRIVKEY(a,pp,length) +X509_PRIVKEY **a; +unsigned char **pp; +long length; + { + M_ASN1_D2I_vars(a,X509_PRIVKEY *,X509_PRIVKEY_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(ret->version, d2i_ASN1_INTEGER); + M_ASN1_D2I_get(ret->algor, d2i_X509_ALGOR); + M_ASN1_D2I_get(ret->privkey, d2i_ASN1_OCTET_STRING); + M_ASN1_D2I_get_IMP_set_opt(ret->attributes, d2i_X509_ATTRIBUTE,0); + + M_ASN1_D2I_Finish(a,X509_PRIVKEY_free,ASN1_F_D2I_X509_PRIVKEY); + } +#endif /* BSAFE */ diff -urN SSLeay-0.9.0-clean/crypto/err/err.h SSLeay-0.9.0/crypto/err/err.h --- SSLeay-0.9.0-clean/crypto/err/err.h Thu Apr 09 04:59:27 1998 +++ SSLeay-0.9.0/crypto/err/err.h Mon Jun 29 11:21:03 1998 @@ -113,9 +113,10 @@ #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_BSAFE 31 +#define ERR_LIB_PROXY 32 +#define ERR_LIB_BIO 33 +#define ERR_LIB_PKCS7 34 #define ERR_LIB_USER 128 @@ -139,6 +140,7 @@ #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 BSAFEerr(f,r) ERR_PUT_error(ERR_LIB_BSAFE,(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__) @@ -187,6 +189,7 @@ #define ERR_R_PROXY_LIB ERR_LIB_PROXY #define ERR_R_BIO_LIB ERR_LIB_BIO #define ERR_R_PKCS7_LIB ERR_LIB_PKCS7 +#define ERR_R_BSAFE_LIB ERR_LIB_BSAFE /* fatal error */ #define ERR_R_MALLOC_FAILURE (1|ERR_R_FATAL) diff -urN SSLeay-0.9.0-clean/crypto/rsa/rsa.h SSLeay-0.9.0/crypto/rsa/rsa.h --- SSLeay-0.9.0-clean/crypto/rsa/rsa.h Thu Apr 09 05:11:05 1998 +++ SSLeay-0.9.0/crypto/rsa/rsa.h Mon Jun 29 11:21:03 1998 @@ -150,6 +150,9 @@ /* If you have RSAref compiled in. */ RSA_METHOD *RSA_PKCS1_RSAref(void); +/* If you are using BSAFE */ +RSA_METHOD *RSA_PKCS1_BSAFE(void); + /* these are the actual SSLeay RSA functions */ RSA_METHOD *RSA_PKCS1_SSLeay(void); diff -urN SSLeay-0.9.0-clean/crypto/rsa/rsa_lib.c SSLeay-0.9.0/crypto/rsa/rsa_lib.c --- SSLeay-0.9.0-clean/crypto/rsa/rsa_lib.c Thu Apr 09 08:47:13 1998 +++ SSLeay-0.9.0/crypto/rsa/rsa_lib.c Mon Jun 29 11:21:03 1998 @@ -89,6 +89,8 @@ { #ifdef RSAref default_RSA_meth=RSA_PKCS1_RSAref(); +#elif defined(BSAFE) + default_RSA_meth=RSA_PKCS1_BSAFE(); #else default_RSA_meth=RSA_PKCS1_SSLeay(); #endif diff -urN SSLeay-0.9.0-clean/crypto/x509/x509.h SSLeay-0.9.0/crypto/x509/x509.h --- SSLeay-0.9.0-clean/crypto/x509/x509.h Thu Apr 09 05:11:07 1998 +++ SSLeay-0.9.0/crypto/x509/x509.h Mon Jun 29 11:21:03 1998 @@ -127,6 +127,15 @@ struct evp_pkey_st /* EVP_PKEY*/ *pkey; } X509_PUBKEY; +typedef struct x509_privkey_st + { + int type; /* Encrypted type not implemented */ + ASN1_INTEGER *version; + X509_ALGOR *algor; + ASN1_OCTET_STRING *privkey; + STACK *attributes; + } X509_PRIVKEY; + typedef struct X509_sig_st { X509_ALGOR *algor; @@ -267,6 +276,22 @@ } value; } X509_ATTRIBUTE; +typedef struct x509_pkey_info + { + /* PrivateKeyInfo type */ + ASN1_INTEGER *version; + X509_ALGOR *pkey_algor; + ASN1_OCTET_STRING *pkey; + STACK /* X509_ATTRIBUTE */ *attrs; + } X509_PKEY_INFO; + +typedef struct x509_enc_pkey_info + { + /* EncryptedPrivateKeyInfo type */ + X509_ALGOR *enc_algor; + ASN1_OCTET_STRING *enc_pkey; /* encrypted pub key */ + } X509_ENC_PKEY_INFO; + typedef struct private_key_st { int version; @@ -573,6 +598,11 @@ EVP_PKEY * X509_PUBKEY_get(X509_PUBKEY *key); int X509_get_pubkey_parameters(EVP_PKEY *pkey, STACK *chain); +X509_PRIVKEY * X509_PRIVKEY_new(void ); +void X509_PRIVKEY_free(X509_PRIVKEY *a); +int i2d_X509_PRIVKEY(X509_PRIVKEY *a,unsigned char **pp); +X509_PRIVKEY * d2i_X509_PRIVKEY(X509_PRIVKEY **a,unsigned char **pp, + long length); X509_SIG * X509_SIG_new(void ); void X509_SIG_free(X509_SIG *a); @@ -894,6 +924,11 @@ EVP_PKEY * X509_PUBKEY_get(); int X509_get_pubkey_parameters(); +X509_PRIVKEY * X509_PRIVKEY_new(); +void X509_PRIVKEY_free(); +int i2d_X509_PRIVKEY(); +X509_PRIVKEY * d2i_X509_PRIVKEY(); + X509_SIG * X509_SIG_new(); void X509_SIG_free(); int i2d_X509_SIG(); @@ -929,7 +964,6 @@ int i2d_X509_NAME(); X509_NAME * d2i_X509_NAME(); int X509_NAME_set(); - X509_CINF * X509_CINF_new(); void X509_CINF_free(); diff -urN SSLeay-0.9.0-clean/dep/files SSLeay-0.9.0/dep/files --- SSLeay-0.9.0-clean/dep/files Wed Apr 08 21:13:27 1998 +++ SSLeay-0.9.0/dep/files Mon Jun 29 11:21:03 1998 @@ -510,6 +510,10 @@ ./rsaref/rsaref.h RSAREF ./rsaref/rsar_err.c RSAREF +./bsafe/bsafe.c BSAFE +./bsafe/bsafe_glue.h BSAFE +./bsafe/bsaf_err.c BSAFE + ./apps/apps.c APPS ./apps/apps.h APPS ./apps/asn1pars.c APPS diff -urN SSLeay-0.9.0-clean/ms/libeay32.def SSLeay-0.9.0/ms/libeay32.def --- SSLeay-0.9.0-clean/ms/libeay32.def Thu Apr 09 08:47:27 1998 +++ SSLeay-0.9.0/ms/libeay32.def Thu Jul 02 02:22:38 1998 @@ -1033,3 +1033,7 @@ sk_unshift @913 sk_zero @914 + X509_PRIVKEY_new @1100 + X509_PRIVKEY_free @1101 + d2i_X509_PRIVKEY @1102 + i2d_X509_PRIVKEY @1103 diff -urN SSLeay-0.9.0-clean/ms/ntdll.mak SSLeay-0.9.0/ms/ntdll.mak --- SSLeay-0.9.0-clean/ms/ntdll.mak Thu Apr 09 08:47:25 1998 +++ SSLeay-0.9.0/ms/ntdll.mak Fri Jul 17 10:41:34 1998 @@ -15,7 +15,7 @@ # Set your compiler options CC=cl -CFLAG= /MD /W3 /WX /G5 /Ox /O2 /Ob2 /Gs0 /GF /Gy /nologo -DWIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DBN_ASM -DMD5_ASM -DSHA1_ASM -DRMD160_ASM +CFLAG= /MDd /W3 /WX /Zi /Yd /Od /nologo -DWINDOWS -DWIN32 -D_DEBUG -DL_ENDIAN -DBN_ASM -DMD5_ASM -DSHA1_ASM -DRMD160_ASM -DBSAFE $(I_BSAFE) APP_CFLAG= LIB_CFLAG= /GD -D_WINDLL -D_DLL SHLIB_CFLAG= @@ -23,13 +23,13 @@ SHLIB_EX_OBJ= # add extra libraries to this define, for solaris -lsocket -lnsl would # be added -EX_LIBS=wsock32.lib user32.lib gdi32.lib +EX_LIBS=wsock32.lib user32.lib gdi32.lib $(L_BSAFE) $(O_BSAFEGLUE) # The SSLeay directory SRC_D=. LINK=link -LFLAGS=/nologo /subsystem:console /machine:I386 /opt:ref +LFLAGS=/nologo /subsystem:console /machine:I386 /opt:ref /debug BN_MULW_OBJ=crypto\bn\asm\bn-win32.obj BN_MULW_SRC=crypto\bn\asm\bn-win32.asm @@ -53,9 +53,9 @@ RMD160_ASM_SRC=crypto\ripemd\asm\rm-win32.asm # The output directory for everything intersting -OUT_D=out32dll +OUT_D=out32dll.dbg # The output directory for all the temporary muck -TMP_D=tmp32dll +TMP_D=tmp32dll.dbg # The output directory for the header files INC_D=inc32 @@ -64,8 +64,8 @@ RANLIB= MKDIR=mkdir MKLIB=lib -MLFLAGS= /nologo /subsystem:console /machine:I386 /opt:ref /dll -ASM=ml /Cp /coff /c /Cx +MLFLAGS= /debug /nologo /subsystem:console /machine:I386 /opt:ref /debug /dll +ASM=ml /Cp /coff /c /Cx /Zi ###################################################### # You should not need to touch anything below this point @@ -75,6 +75,7 @@ SSL=ssleay32 CRYPTO=libeay32 RSAGLUE=RSAglue +BSAFEGLUE=BSAFEglue # BIN_D - Binary output directory # TEST_D - Binary test file output directory @@ -91,10 +92,14 @@ O_SSL= $(LIB_D)\$(SSL).dll O_CRYPTO= $(LIB_D)\$(CRYPTO).dll O_RSAGLUE= $(LIB_D)\$(RSAGLUE).lib +O_BSAFEGLUE=$(LIB_D)\$(BSAFEGLUE).lib SO_SSL= $(SSL) SO_CRYPTO= $(CRYPTO) L_SSL= $(LIB_D)\$(SSL).lib L_CRYPTO= $(LIB_D)\$(CRYPTO).lib +L_BSAFE= ..\bsafe\lib\bsafe.lib +# The double separator is important here for when cversion.c gets compiled +I_BSAFE= -I..\\bsafe\\include L_LIBS= $(L_SSL) $(L_CRYPTO) #L_LIBS= $(O_SSL) $(O_RSAGLUE) -lrsaref $(O_CRYPTO) @@ -107,7 +112,7 @@ APP_CFLAGS=$(INC) $(CFLAG) $(APP_CFLAG) LIB_CFLAGS=$(INC) $(CFLAG) $(LIB_CFLAG) SHLIB_CFLAGS=$(INC) $(CFLAG) $(LIB_CFLAG) $(SHLIB_CFLAG) -LIBS_DEP=$(O_CRYPTO) $(O_RSAGLUE) $(O_SSL) +LIBS_DEP=$(O_BSAFEGLUE) $(O_CRYPTO) $(O_RSAGLUE) $(O_SSL) ############################################# HEADER=$(INCL_D)\cryptlib.h \ @@ -119,8 +124,9 @@ $(INCL_D)\bf_pi.h $(INCL_D)\bf_locl.h $(INCL_D)\cast_s.h \ $(INCL_D)\cast_lcl.h $(INCL_D)\bn_lcl.h $(INCL_D)\bn_prime.h \ $(INCL_D)\obj_dat.h $(INCL_D)\conf_lcl.h $(INCL_D)\ssl_locl.h \ - $(INCL_D)\rsaref.h $(INCL_D)\apps.h $(INCL_D)\progs.h \ - $(INCL_D)\s_apps.h $(INCL_D)\testdsa.h $(INCL_D)\testrsa.h + $(INCL_D)\bsafe_glue.h $(INCL_D)\rsaref.h $(INCL_D)\apps.h \ + $(INCL_D)\progs.h $(INCL_D)\s_apps.h $(INCL_D)\testdsa.h \ + $(INCL_D)\testrsa.h EXHEADER=$(INC_D)\e_os.h \ $(INC_D)\crypto.h $(INC_D)\cryptall.h $(INC_D)\md2.h \ @@ -145,7 +151,7 @@ $(OBJ_D)\rc5test.obj $(OBJ_D)\ideatest.obj $(OBJ_D)\bftest.obj \ $(OBJ_D)\casttest.obj $(OBJ_D)\bntest.obj $(OBJ_D)\exptest.obj \ $(OBJ_D)\dsatest.obj $(OBJ_D)\dhtest.obj $(OBJ_D)\randtest.obj \ - $(OBJ_D)\ssltest.obj + $(OBJ_D)\ssltest.obj $(OBJ_D)\bsafetest.obj E_OBJ=$(OBJ_D)\verify.obj \ $(OBJ_D)\asn1pars.obj $(OBJ_D)\req.obj $(OBJ_D)\dgst.obj \ @@ -247,18 +253,19 @@ $(OBJ_D)\f_int.obj $(OBJ_D)\f_string.obj $(OBJ_D)\i2d_dhp.obj \ $(OBJ_D)\i2d_dsap.obj $(OBJ_D)\d2i_dhp.obj $(OBJ_D)\d2i_dsap.obj \ $(OBJ_D)\n_pkey.obj $(OBJ_D)\a_hdr.obj $(OBJ_D)\x_pkey.obj \ - $(OBJ_D)\a_bool.obj $(OBJ_D)\x_exten.obj $(OBJ_D)\asn1_par.obj \ - $(OBJ_D)\asn1_lib.obj $(OBJ_D)\asn1_err.obj $(OBJ_D)\a_meth.obj \ - $(OBJ_D)\a_bytes.obj $(OBJ_D)\evp_asn1.obj $(OBJ_D)\x509_def.obj \ - $(OBJ_D)\x509_d2.obj $(OBJ_D)\x509_r2x.obj $(OBJ_D)\x509_cmp.obj \ - $(OBJ_D)\x509_obj.obj $(OBJ_D)\x509_req.obj $(OBJ_D)\x509_vfy.obj \ - $(OBJ_D)\x509_set.obj $(OBJ_D)\x509rset.obj $(OBJ_D)\x509_err.obj \ - $(OBJ_D)\x509name.obj $(OBJ_D)\x509_v3.obj $(OBJ_D)\x509_ext.obj \ - $(OBJ_D)\x509pack.obj $(OBJ_D)\x509type.obj $(OBJ_D)\x509_lu.obj \ - $(OBJ_D)\x_all.obj $(OBJ_D)\x509_txt.obj $(OBJ_D)\by_file.obj \ - $(OBJ_D)\by_dir.obj $(OBJ_D)\v3_net.obj $(OBJ_D)\v3_x509.obj \ - $(OBJ_D)\conf.obj $(OBJ_D)\conf_err.obj $(OBJ_D)\txt_db.obj \ - $(OBJ_D)\pk7_lib.obj $(OBJ_D)\pkcs7err.obj $(OBJ_D)\pk7_doit.obj + $(OBJ_D)\x_privkey.obj $(OBJ_D)\a_bool.obj $(OBJ_D)\x_exten.obj \ + $(OBJ_D)\asn1_par.obj $(OBJ_D)\asn1_lib.obj $(OBJ_D)\asn1_err.obj \ + $(OBJ_D)\a_meth.obj $(OBJ_D)\a_bytes.obj $(OBJ_D)\evp_asn1.obj \ + $(OBJ_D)\x509_def.obj $(OBJ_D)\x509_d2.obj $(OBJ_D)\x509_r2x.obj \ + $(OBJ_D)\x509_cmp.obj $(OBJ_D)\x509_obj.obj $(OBJ_D)\x509_req.obj \ + $(OBJ_D)\x509_vfy.obj $(OBJ_D)\x509_set.obj $(OBJ_D)\x509rset.obj \ + $(OBJ_D)\x509_err.obj $(OBJ_D)\x509name.obj $(OBJ_D)\x509_v3.obj \ + $(OBJ_D)\x509_ext.obj $(OBJ_D)\x509pack.obj $(OBJ_D)\x509type.obj \ + $(OBJ_D)\x509_lu.obj $(OBJ_D)\x_all.obj $(OBJ_D)\x509_txt.obj \ + $(OBJ_D)\by_file.obj $(OBJ_D)\by_dir.obj $(OBJ_D)\v3_net.obj \ + $(OBJ_D)\v3_x509.obj $(OBJ_D)\conf.obj $(OBJ_D)\conf_err.obj \ + $(OBJ_D)\txt_db.obj $(OBJ_D)\pk7_lib.obj $(OBJ_D)\pkcs7err.obj \ + $(OBJ_D)\pk7_doit.obj SSLOBJ=$(OBJ_D)\s2_meth.obj \ $(OBJ_D)\s2_srvr.obj $(OBJ_D)\s2_clnt.obj $(OBJ_D)\s2_lib.obj \ @@ -277,6 +284,9 @@ RSAGLUEOBJ=$(OBJ_D)\rsaref.obj \ $(OBJ_D)\rsar_err.obj +BSAFEGLUEOBJ=$(OBJ_D)\bsafe.obj \ + $(OBJ_D)\bsaf_err.obj $(OBJ_D)\tstdlib.obj + T_EXE=$(TEST_D)\md2test.exe \ $(TEST_D)\md5test.exe $(TEST_D)\shatest.exe $(TEST_D)\sha1test.exe \ $(TEST_D)\mdc2test.exe $(TEST_D)\hmactest.exe $(TEST_D)\rmdtest.exe \ @@ -284,7 +294,7 @@ $(TEST_D)\rc5test.exe $(TEST_D)\ideatest.exe $(TEST_D)\bftest.exe \ $(TEST_D)\casttest.exe $(TEST_D)\bntest.exe $(TEST_D)\exptest.exe \ $(TEST_D)\dsatest.exe $(TEST_D)\dhtest.exe $(TEST_D)\randtest.exe \ - $(TEST_D)\ssltest.exe + $(TEST_D)\ssltest.exe $(TEST_D)\bsafetest.exe ################################################################### all: banner $(TMP_D) $(BIN_D) $(TEST_D) $(LIB_D) $(INC_D) headers lib exe @@ -405,6 +415,9 @@ $(INCL_D)\ssl_locl.h: $(SRC_D)\ssl\ssl_locl.h $(CP) $(SRC_D)\ssl\ssl_locl.h $(INCL_D)\ssl_locl.h +$(INCL_D)\bsafe_glue.h: $(SRC_D)\bsafe\bsafe_glue.h + $(CP) $(SRC_D)\bsafe\bsafe_glue.h $(INCL_D)\bsafe_glue.h + $(INCL_D)\rsaref.h: $(SRC_D)\rsaref\rsaref.h $(CP) $(SRC_D)\rsaref\rsaref.h $(INCL_D)\rsaref.h @@ -609,6 +622,9 @@ $(OBJ_D)\ssltest.obj: $(SRC_D)\ssl\ssltest.c $(CC) /Fo$(OBJ_D)\ssltest.obj $(APP_CFLAGS) -c $(SRC_D)\ssl\ssltest.c +$(OBJ_D)\bsafetest.obj: $(SRC_D)\bsafe\bsafetest.c + $(CC) /Fo$(OBJ_D)\bsafetest.obj $(APP_CFLAGS) -c $(SRC_D)\bsafe\bsafetest.c + $(OBJ_D)\verify.obj: $(SRC_D)\apps\verify.c $(CC) /Fo$(OBJ_D)\verify.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\verify.c @@ -1512,6 +1528,9 @@ $(OBJ_D)\x_pkey.obj: $(SRC_D)\crypto\asn1\x_pkey.c $(CC) /Fo$(OBJ_D)\x_pkey.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_pkey.c +$(OBJ_D)\x_privkey.obj: $(SRC_D)\crypto\asn1\x_privkey.c + $(CC) /Fo$(OBJ_D)\x_privkey.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_privkey.c + $(OBJ_D)\a_bool.obj: $(SRC_D)\crypto\asn1\a_bool.c $(CC) /Fo$(OBJ_D)\a_bool.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_bool.c @@ -1731,6 +1750,15 @@ $(OBJ_D)\rsar_err.obj: $(SRC_D)\rsaref\rsar_err.c $(CC) /Fo$(OBJ_D)\rsar_err.obj $(LIB_CFLAGS) -c $(SRC_D)\rsaref\rsar_err.c +$(OBJ_D)\bsafe.obj: $(SRC_D)\bsafe\bsafe.c + $(CC) /Fo$(OBJ_D)\bsafe.obj $(SHLIB_CFLAGS) -c $(SRC_D)\bsafe\bsafe.c + +$(OBJ_D)\bsaf_err.obj: $(SRC_D)\bsafe\bsaf_err.c + $(CC) /Fo$(OBJ_D)\bsaf_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\bsafe\bsaf_err.c + +$(OBJ_D)\tstdlib.obj: $(SRC_D)\bsafe\tstdlib.c + $(CC) /Fo$(OBJ_D)\tstdlib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\bsafe\tstdlib.c + $(TEST_D)\md2test.exe: $(OBJ_D)\md2test.obj $(LIBS_DEP) $(LINK) $(LFLAGS) /out:$(TEST_D)\md2test.exe @<< $(APP_EX_OBJ) $(OBJ_D)\md2test.obj $(L_LIBS) $(EX_LIBS) @@ -1831,9 +1859,14 @@ $(APP_EX_OBJ) $(OBJ_D)\ssltest.obj $(L_LIBS) $(EX_LIBS) << +$(TEST_D)\bsafetest.exe: $(OBJ_D)\bsafetest.obj $(LIBS_DEP) + $(LINK) $(LFLAGS) /out:$(TEST_D)\bsafetest.exe @<< + $(APP_EX_OBJ) $(OBJ_D)\bsafetest.obj $(L_LIBS) $(EX_LIBS) +<< + $(O_SSL): $(SSLOBJ) $(LINK) $(MLFLAGS) /out:$(O_SSL) /def:ms/SSLEAY32.def @<< - $(SHLIB_EX_OBJ) $(SSLOBJ) $(L_CRYPTO) wsock32.lib gdi32.lib + $(SHLIB_EX_OBJ) $(SSLOBJ) $(L_CRYPTO) $(O_BSAFEGLUE) $(L_BSAFE) wsock32.lib gdi32.lib << $(O_RSAGLUE): $(RSAGLUEOBJ) @@ -1841,9 +1874,14 @@ $(RSAGLUEOBJ) << -$(O_CRYPTO): $(CRYPTOOBJ) +$(O_BSAFEGLUE): $(BSAFEGLUEOBJ) + $(MKLIB) /out:$(O_BSAFEGLUE) @<< + $(BSAFEGLUEOBJ) +<< + +$(O_CRYPTO): $(CRYPTOOBJ) $(O_BSAFEGLUE) $(LINK) $(MLFLAGS) /out:$(O_CRYPTO) /def:ms/LIBEAY32.def @<< - $(SHLIB_EX_OBJ) $(CRYPTOOBJ) wsock32.lib gdi32.lib + $(SHLIB_EX_OBJ) $(CRYPTOOBJ) $(O_BSAFEGLUE) $(L_BSAFE) wsock32.lib gdi32.lib << $(BIN_D)\$(E_EXE).exe: $(E_OBJ) $(LIBS_DEP) diff -urN SSLeay-0.9.0-clean/util/mk1mf.pl SSLeay-0.9.0/util/mk1mf.pl --- SSLeay-0.9.0-clean/util/mk1mf.pl Wed Apr 08 21:07:27 1998 +++ SSLeay-0.9.0/util/mk1mf.pl Thu Jul 02 02:23:11 1998 @@ -46,6 +46,7 @@ elsif (/^no-dsa$/) { $no_dsa=1; } elsif (/^no-dh$/) { $no_dh=1; } elsif (/^no-asm$/) { $no_asm=1; } + elsif (/^no-bsafe$/) { $no_bsafe=1; } elsif (/^no-ssl2$/) { $no_ssl2=1; } elsif (/^no-ssl3$/) { $no_ssl3=1; } elsif (/^no-err$/) { $no_err=1; } @@ -117,6 +118,7 @@ ($ssl,$crypto)=("ssl","crypto"); $RSAglue="RSAglue"; +$BSAFEglue="BSAFEglue"; $ranlib="echo ranlib"; $cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc'; @@ -195,6 +197,7 @@ $bin_dir=$bin_dir.$o unless ((substr($bin_dir,-1,1) eq $o) || ($bin_dir eq '')); +$cflags.=' -DBSAFE $(I_BSAFE)' if (! $no_bsafe); $cflags.=" -DNO_IDEA" if $no_idea; $cflags.=" -DNO_RC2" if $no_rc2; $cflags.=" -DNO_RC4" if $no_rc4; @@ -216,6 +219,7 @@ $cflags.=" -DNO_SSL3" if $no_ssl3; $cflags.=" -DNO_ERR" if $no_err; $cflags.=" -DRSAref" if $rsaref ne ""; +$ex_libs.=' $(L_BSAFE) $(O_BSAFEGLUE)' if (! $no_bsafe); if ($unix) { $cflags="$c_flags" if ($c_flags ne ""); } @@ -319,6 +323,7 @@ SSL=$ssl CRYPTO=$crypto RSAGLUE=$RSAglue +BSAFEGLUE=$BSAFEglue # BIN_D - Binary output directory # TEST_D - Binary test file output directory @@ -335,10 +340,14 @@ O_SSL= \$(LIB_D)$o$plib\$(SSL)$shlibp O_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$shlibp O_RSAGLUE= \$(LIB_D)$o$plib\$(RSAGLUE)$libp +O_BSAFEGLUE=\$(LIB_D)$o$plib\$(BSAFEGLUE)$libp SO_SSL= $plib\$(SSL)$so_shlibp SO_CRYPTO= $plib\$(CRYPTO)$so_shlibp L_SSL= \$(LIB_D)$o\$(SSL)$libp L_CRYPTO= \$(LIB_D)$o\$(CRYPTO)$libp +L_BSAFE= ..${o}bsafe${o}lib${o}${plib}bsafe${libp} +# The double separator is important here for when cversion.c gets compiled +I_BSAFE= -I..${o}${o}bsafe${o}${o}include L_LIBS= \$(L_SSL) \$(L_CRYPTO) #L_LIBS= \$(O_SSL) \$(O_RSAGLUE) -lrsaref \$(O_CRYPTO) @@ -351,7 +360,7 @@ APP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG) LIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) SHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG) -LIBS_DEP=\$(O_CRYPTO) \$(O_RSAGLUE) \$(O_SSL) +LIBS_DEP=\$(O_BSAFEGLUE) \$(O_CRYPTO) \$(O_RSAGLUE) \$(O_SSL) ############################################# EOF @@ -496,6 +505,12 @@ next; } + if (($_ eq "BSAFEGLUE") && $no_bsafe) + { + $rules.="\$(O_BSAFEGLUE):\n\n"; + next; + } + if (($bn_mulw_obj ne "") && ($_ eq "CRYPTO")) { $lib_obj =~ s/\s\S*\/bn_mulw\S*/ \$(BN_MULW_OBJ)/; @@ -558,6 +573,8 @@ $rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)"); $rules.= &do_lib_rule("\$(RSAGLUEOBJ)","\$(O_RSAGLUE)",$RSAglue,0,"") unless $no_rsa; +$rules.= &do_lib_rule("\$(BSAFEGLUEOBJ)","\$(O_BSAFEGLUE)",$BSAFEglue,0,"") + unless $no_bsafe; $rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)"); $rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)"); diff -urN SSLeay-0.9.0-clean/util/pl/VC-32.pl SSLeay-0.9.0/util/pl/VC-32.pl --- SSLeay-0.9.0-clean/util/pl/VC-32.pl Wed Apr 08 21:07:27 1998 +++ SSLeay-0.9.0/util/pl/VC-32.pl Fri Jul 17 10:41:24 1998 @@ -101,7 +101,11 @@ ($Name=$name) =~ tr/a-z/A-Z/; # $target="\$(LIB_D)$o$target"; - $ret.="$target: $objs\n"; + if (! $no_bsafe && $target eq '$(O_CRYPTO)') { + $ret.="$target: $objs \$(O_BSAFEGLUE)\n"; + } else { + $ret.="$target: $objs\n"; + } if (!$shlib) { # $ret.="\t\$(RM) \$(O_$Name)\n"; @@ -110,6 +114,7 @@ else { local($ex)=($target =~ /O_SSL/)?' $(L_CRYPTO)':''; + $ex.=' $(O_BSAFEGLUE) $(L_BSAFE)' if (! $no_bsafe); $ex.=' wsock32.lib gdi32.lib'; $ret.="\t\$(LINK) \$(MLFLAGS) $efile$target /def:ms/${Name}.def @<<\n \$(SHLIB_EX_OBJ) $objs $ex\n<<\n"; }