diff options
author | Richard Levitte <levitte@openssl.org> | 2000-10-26 21:07:28 +0000 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2000-10-26 21:07:28 +0000 |
commit | 5270e7025e11b2fd1a5bdf8d81feded1167b1c87 (patch) | |
tree | 3bb44c37f4bb6469f738a10127050b023e0d7fb5 /crypto | |
parent | 1df586bec20de86c3086181c565aaee7629bb0a2 (diff) |
Merge the engine branch into the main trunk. All conflicts resolved.
At the same time, add VMS support for Rijndael.
Diffstat (limited to 'crypto')
46 files changed, 6700 insertions, 366 deletions
diff --git a/crypto/Makefile.ssl b/crypto/Makefile.ssl index 72e3fe7fde..7bb2a5ca99 100644 --- a/crypto/Makefile.ssl +++ b/crypto/Makefile.ssl @@ -27,7 +27,7 @@ LIBS= SDIRS= md2 md5 sha mdc2 hmac ripemd \ des rc2 rc4 rc5 idea bf cast \ - bn rsa dsa dh dso \ + bn rsa dsa dh dso engine \ buffer bio stack lhash rand err objects \ evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp rijndael diff --git a/crypto/bn/bn_exp.c b/crypto/bn/bn_exp.c index 8117323766..d2c91628ac 100644 --- a/crypto/bn/bn_exp.c +++ b/crypto/bn/bn_exp.c @@ -113,13 +113,6 @@ #include <stdio.h> #include "cryptlib.h" #include "bn_lcl.h" -#ifdef ATALLA -# include <alloca.h> -# include <atasi.h> -# include <assert.h> -# include <dlfcn.h> -#endif - #define TABLE_SIZE 32 @@ -183,174 +176,6 @@ err: } -#ifdef ATALLA - -/* - * This routine will dynamically check for the existance of an Atalla AXL-200 - * SSL accelerator module. If one is found, the variable - * asi_accelerator_present is set to 1 and the function pointers - * ptr_ASI_xxxxxx above will be initialized to corresponding ASI API calls. - */ -typedef int tfnASI_GetPerformanceStatistics(int reset_flag, - unsigned int *ret_buf); -typedef int tfnASI_GetHardwareConfig(long card_num, unsigned int *ret_buf); -typedef int tfnASI_RSAPrivateKeyOpFn(RSAPrivateKey * rsaKey, - unsigned char *output, - unsigned char *input, - unsigned int modulus_len); - -static tfnASI_GetHardwareConfig *ptr_ASI_GetHardwareConfig; -static tfnASI_RSAPrivateKeyOpFn *ptr_ASI_RSAPrivateKeyOpFn; -static tfnASI_GetPerformanceStatistics *ptr_ASI_GetPerformanceStatistics; -static int asi_accelerator_present; -static int tried_atalla; - -void atalla_initialize_accelerator_handle(void) - { - void *dl_handle; - int status; - unsigned int config_buf[1024]; - static int tested; - - if(tested) - return; - - tested=1; - - bzero((void *)config_buf, 1024); - - /* - * Check to see if the library is present on the system - */ - dl_handle = dlopen("atasi.so", RTLD_NOW); - if (dl_handle == (void *) NULL) - { -/* printf("atasi.so library is not present on the system\n"); - printf("No HW acceleration available\n");*/ - return; - } - - /* - * The library is present. Now we'll check to insure that the - * LDM is up and running. First we'll get the address of the - * function in the atasi library that we need to see if the - * LDM is operating. - */ - - ptr_ASI_GetHardwareConfig = - (tfnASI_GetHardwareConfig *)dlsym(dl_handle,"ASI_GetHardwareConfig"); - - if (ptr_ASI_GetHardwareConfig) - { - /* - * We found the call, now we'll get our config - * status. If we get a non 0 result, the LDM is not - * running and we cannot use the Atalla ASI * - * library. - */ - status = (*ptr_ASI_GetHardwareConfig)(0L, config_buf); - if (status != 0) - { - printf("atasi.so library is present but not initialized\n"); - printf("No HW acceleration available\n"); - return; - } - } - else - { -/* printf("We found the library, but not the function. Very Strange!\n");*/ - return ; - } - - /* - * It looks like we have acceleration capabilities. Load up the - * pointers to our ASI API calls. - */ - ptr_ASI_RSAPrivateKeyOpFn= - (tfnASI_RSAPrivateKeyOpFn *)dlsym(dl_handle, "ASI_RSAPrivateKeyOpFn"); - if (ptr_ASI_RSAPrivateKeyOpFn == NULL) - { -/* printf("We found the library, but no RSA function. Very Strange!\n");*/ - return; - } - - ptr_ASI_GetPerformanceStatistics = - (tfnASI_GetPerformanceStatistics *)dlsym(dl_handle, "ASI_GetPerformanceStatistics"); - if (ptr_ASI_GetPerformanceStatistics == NULL) - { -/* printf("We found the library, but no stat function. Very Strange!\n");*/ - return; - } - - /* - * Indicate that acceleration is available - */ - asi_accelerator_present = 1; - -/* printf("This system has acceleration!\n");*/ - - return; - } - -/* make sure this only gets called once when bn_mod_exp calls bn_mod_exp_mont */ -int BN_mod_exp_atalla(BIGNUM *r, BIGNUM *a, const BIGNUM *p, const BIGNUM *m) - { - unsigned char *abin; - unsigned char *pbin; - unsigned char *mbin; - unsigned char *rbin; - int an,pn,mn,ret; - RSAPrivateKey keydata; - - atalla_initialize_accelerator_handle(); - if(!asi_accelerator_present) - return 0; - - -/* We should be able to run without size testing */ -# define ASIZE 128 - an=BN_num_bytes(a); - pn=BN_num_bytes(p); - mn=BN_num_bytes(m); - - if(an <= ASIZE && pn <= ASIZE && mn <= ASIZE) - { - int size=mn; - - assert(an <= mn); - abin=alloca(size); - memset(abin,'\0',mn); - BN_bn2bin(a,abin+size-an); - - pbin=alloca(pn); - BN_bn2bin(p,pbin); - - mbin=alloca(size); - memset(mbin,'\0',mn); - BN_bn2bin(m,mbin+size-mn); - - rbin=alloca(size); - - memset(&keydata,'\0',sizeof keydata); - keydata.privateExponent.data=pbin; - keydata.privateExponent.len=pn; - keydata.modulus.data=mbin; - keydata.modulus.len=size; - - ret=(*ptr_ASI_RSAPrivateKeyOpFn)(&keydata,rbin,abin,keydata.modulus.len); -/*fprintf(stderr,"!%s\n",BN_bn2hex(a));*/ - if(!ret) - { - BN_bin2bn(rbin,keydata.modulus.len,r); -/*fprintf(stderr,"?%s\n",BN_bn2hex(r));*/ - return 1; - } - } - return 0; - } -#endif /* def ATALLA */ - - int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx) { @@ -360,13 +185,6 @@ int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, const BIGNUM *m, bn_check_top(p); bn_check_top(m); -#ifdef ATALLA - if(BN_mod_exp_atalla(r,a,p,m)) - return 1; -/* If it fails, try the other methods (but don't try atalla again) */ - tried_atalla=1; -#endif - #ifdef MONT_MUL_MOD /* I have finally been able to take out this pre-condition of * the top bit being set. It was caused by an error in BN_div @@ -392,10 +210,6 @@ int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, const BIGNUM *m, { ret=BN_mod_exp_simple(r,a,p,m,ctx); } #endif -#ifdef ATALLA - tried_atalla=0; -#endif - return(ret); } @@ -525,12 +339,6 @@ int BN_mod_exp_mont(BIGNUM *rr, BIGNUM *a, const BIGNUM *p, bn_check_top(p); bn_check_top(m); -#ifdef ATALLA - if(!tried_atalla && BN_mod_exp_atalla(rr,a,p,m)) - return 1; -/* If it fails, try the other methods */ -#endif - if (!(m->d[0] & 1)) { BNerr(BN_F_BN_MOD_EXP_MONT,BN_R_CALLED_WITH_EVEN_MODULUS); @@ -693,19 +501,6 @@ int BN_mod_exp_mont_word(BIGNUM *rr, BN_ULONG a, const BIGNUM *p, t = BN_CTX_get(ctx); if (d == NULL || r == NULL || t == NULL) goto err; -#ifdef ATALLA - if (!tried_atalla) - { - BN_set_word(t, a); - if (BN_mod_exp_atalla(rr, t, p, m)) - { - BN_CTX_end(ctx); - return 1; - } - } -/* If it fails, try the other methods */ -#endif - if (in_mont != NULL) mont=in_mont; else diff --git a/crypto/cryptlib.c b/crypto/cryptlib.c index 070cf59690..9de60fd528 100644 --- a/crypto/cryptlib.c +++ b/crypto/cryptlib.c @@ -100,7 +100,8 @@ static const char* lock_names[CRYPTO_NUM_LOCKS] = "debug_malloc2", "dso", "dynlock", -#if CRYPTO_NUM_LOCKS != 28 + "engine", +#if CRYPTO_NUM_LOCKS != 29 # error "Inconsistency between crypto.h and cryptlib.c" #endif }; diff --git a/crypto/crypto-lib.com b/crypto/crypto-lib.com index edffeffde1..70e3c91b34 100644 --- a/crypto/crypto-lib.com +++ b/crypto/crypto-lib.com @@ -88,7 +88,7 @@ $! Define The Different Encryption Types. $! $ ENCRYPT_TYPES = "Basic,MD2,MD4,MD5,SHA,MDC2,HMAC,RIPEMD,"+ - "DES,RC2,RC4,RC5,IDEA,BF,CAST,"+ - - "BN,RSA,DSA,DH,DSO,"+ - + "BN,RSA,DSA,DH,DSO,ENGINE,RIJNDAEL,"+ - "BUFFER,BIO,STACK,LHASH,RAND,ERR,OBJECTS,"+ - "EVP,EVP_2,ASN1,ASN1_2,PEM,X509,X509V3,"+ - "CONF,TXT_DB,PKCS7,PKCS12,COMP" @@ -206,6 +206,9 @@ $ LIB_DSA = "dsa_gen,dsa_key,dsa_lib,dsa_asn1,dsa_vrf,dsa_sign,dsa_err,dsa_ossl" $ LIB_DH = "dh_gen,dh_key,dh_lib,dh_check,dh_err" $ LIB_DSO = "dso_dl,dso_dlfcn,dso_err,dso_lib,dso_null,"+ - "dso_openssl,dso_win32,dso_vms" +$ LIB_ENGINE = "engine_err,engine_lib,engine_list,engine_openssl,"+ - + "hw_atalla,hw_cswift,hw_ncipher" +$ LIB_RIJNDAEL = "rijndael-alg-fst" $ LIB_BUFFER = "buffer,buf_err" $ LIB_BIO = "bio_lib,bio_cb,bio_err,"+ - "bss_mem,bss_null,bss_fd,"+ - @@ -1194,7 +1197,9 @@ $ CC = "CC" $ IF ARCH.EQS."VAX" .AND. F$TRNLNM("DECC$CC_DEFAULT").NES."/DECC" - THEN CC = "CC/DECC" $ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/STANDARD=ANSI89" + - - "/NOLIST/PREFIX=ALL/INCLUDE=SYS$DISK:[]" + CCEXTRAFLAGS + "/NOLIST/PREFIX=ALL" + - + "/INCLUDE=(SYS$DISK:[],SYS$DISK:[.ENGINE.VENDOR_DEFNS])" + - + CCEXTRAFLAGS $! $! Define The Linker Options File Name. $! @@ -1226,7 +1231,8 @@ $ WRITE SYS$OUTPUT "There is no VAX C on Alpha!" $ EXIT $ ENDIF $ IF F$TRNLNM("DECC$CC_DEFAULT").EQS."/DECC" THEN CC = "CC/VAXC" -$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/NOLIST/INCLUDE=SYS$DISK:[]" + - +$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/NOLIST" + - + "/INCLUDE=(SYS$DISK:[],SYS$DISK:[.ENGINE.VENDOR_DEFNS])" + - CCEXTRAFLAGS $ CCDEFS = """VAXC""," + CCDEFS $! @@ -1258,7 +1264,8 @@ $! $! Use GNU C... $! $ CC = "GCC/NOCASE_HACK/''GCC_OPTIMIZE'/''DEBUGGER'/NOLIST" + - - "/INCLUDE=SYS$DISK:[]" + CCEXTRAFLAGS + "/INCLUDE=(SYS$DISK:[],SYS$DISK:[.ENGINE.VENDOR_DEFNS])" + - + CCEXTRAFLAGS $! $! Define The Linker Options File Name. $! diff --git a/crypto/crypto.h b/crypto/crypto.h index df6ccaff6d..52ee97b71a 100644 --- a/crypto/crypto.h +++ b/crypto/crypto.h @@ -122,7 +122,8 @@ extern "C" { #define CRYPTO_LOCK_MALLOC2 25 #define CRYPTO_LOCK_DSO 26 #define CRYPTO_LOCK_DYNLOCK 27 -#define CRYPTO_NUM_LOCKS 28 +#define CRYPTO_LOCK_ENGINE 28 +#define CRYPTO_NUM_LOCKS 29 #define CRYPTO_LOCK 1 #define CRYPTO_UNLOCK 2 diff --git a/crypto/dh/Makefile.ssl b/crypto/dh/Makefile.ssl index ccee00eeca..b9fed3a65e 100644 --- a/crypto/dh/Makefile.ssl +++ b/crypto/dh/Makefile.ssl @@ -101,19 +101,41 @@ dh_gen.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h dh_gen.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h dh_gen.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h dh_gen.o: ../cryptlib.h -dh_key.o: ../../include/openssl/bio.h ../../include/openssl/bn.h -dh_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h -dh_key.o: ../../include/openssl/dh.h ../../include/openssl/e_os.h -dh_key.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h -dh_key.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h +dh_key.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h +dh_key.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h +dh_key.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h +dh_key.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +dh_key.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h +dh_key.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h +dh_key.o: ../../include/openssl/engine.h ../../include/openssl/err.h +dh_key.o: ../../include/openssl/evp.h ../../include/openssl/idea.h +dh_key.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h +dh_key.o: ../../include/openssl/md4.h ../../include/openssl/md5.h +dh_key.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h +dh_key.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h dh_key.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h -dh_key.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +dh_key.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h +dh_key.o: ../../include/openssl/rc5.h ../../include/openssl/rijndael-alg-fst.h +dh_key.o: ../../include/openssl/rijndael.h ../../include/openssl/ripemd.h +dh_key.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h +dh_key.o: ../../include/openssl/sha.h ../../include/openssl/stack.h dh_key.o: ../../include/openssl/symhacks.h ../cryptlib.h -dh_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h -dh_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h -dh_lib.o: ../../include/openssl/dh.h ../../include/openssl/e_os.h -dh_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h -dh_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h -dh_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h -dh_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -dh_lib.o: ../cryptlib.h +dh_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h +dh_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h +dh_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h +dh_lib.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +dh_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h +dh_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h +dh_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h +dh_lib.o: ../../include/openssl/evp.h ../../include/openssl/idea.h +dh_lib.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h +dh_lib.o: ../../include/openssl/md4.h ../../include/openssl/md5.h +dh_lib.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h +dh_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h +dh_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h +dh_lib.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h +dh_lib.o: ../../include/openssl/rc5.h ../../include/openssl/rijndael-alg-fst.h +dh_lib.o: ../../include/openssl/rijndael.h ../../include/openssl/ripemd.h +dh_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h +dh_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h +dh_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h diff --git a/crypto/dh/dh.h b/crypto/dh/dh.h index a15fc1c65f..7a8d9f88c2 100644 --- a/crypto/dh/dh.h +++ b/crypto/dh/dh.h @@ -115,7 +115,11 @@ struct dh_st int references; CRYPTO_EX_DATA ex_data; +#if 0 DH_METHOD *meth; +#else + struct engine_st *engine; +#endif }; #define DH_GENERATOR_2 2 @@ -150,10 +154,15 @@ struct dh_st DH_METHOD *DH_OpenSSL(void); -void DH_set_default_method(DH_METHOD *meth); -DH_METHOD *DH_get_default_method(void); +void DH_set_default_openssl_method(DH_METHOD *meth); +DH_METHOD *DH_get_default_openssl_method(void); +#if 0 DH_METHOD *DH_set_method(DH *dh, DH_METHOD *meth); DH *DH_new_method(DH_METHOD *meth); +#else +int DH_set_method(DH *dh, struct engine_st *engine); +DH *DH_new_method(struct engine_st *engine); +#endif DH * DH_new(void); void DH_free(DH *dh); diff --git a/crypto/dh/dh_key.c b/crypto/dh/dh_key.c index 6f9426dd6f..6915d79dcc 100644 --- a/crypto/dh/dh_key.c +++ b/crypto/dh/dh_key.c @@ -61,6 +61,7 @@ #include <openssl/bn.h> #include <openssl/rand.h> #include <openssl/dh.h> +#include <openssl/engine.h> static int generate_key(DH *dh); static int compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh); @@ -72,12 +73,12 @@ static int dh_finish(DH *dh); int DH_generate_key(DH *dh) { - return dh->meth->generate_key(dh); + return ENGINE_get_DH(dh->engine)->generate_key(dh); } int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh) { - return dh->meth->compute_key(key, pub_key, dh); + return ENGINE_get_DH(dh->engine)->compute_key(key, pub_key, dh); } static DH_METHOD dh_ossl = { @@ -137,8 +138,9 @@ static int generate_key(DH *dh) } mont=(BN_MONT_CTX *)dh->method_mont_p; - if (!dh->meth->bn_mod_exp(dh, pub_key,dh->g,priv_key,dh->p,&ctx,mont)) - goto err; + if (!ENGINE_get_DH(dh->engine)->bn_mod_exp(dh, pub_key, dh->g, + priv_key,dh->p,&ctx,mont)) + goto err; dh->pub_key=pub_key; dh->priv_key=priv_key; @@ -177,7 +179,8 @@ static int compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh) } mont=(BN_MONT_CTX *)dh->method_mont_p; - if (!dh->meth->bn_mod_exp(dh, tmp,pub_key,dh->priv_key,dh->p,&ctx,mont)) + if (!ENGINE_get_DH(dh->engine)->bn_mod_exp(dh, tmp, pub_key, + dh->priv_key,dh->p,&ctx,mont)) { DHerr(DH_F_DH_COMPUTE_KEY,ERR_R_BN_LIB); goto err; diff --git a/crypto/dh/dh_lib.c b/crypto/dh/dh_lib.c index a8d5340bf4..66803b5565 100644 --- a/crypto/dh/dh_lib.c +++ b/crypto/dh/dh_lib.c @@ -60,6 +60,7 @@ #include "cryptlib.h" #include <openssl/bn.h> #include <openssl/dh.h> +#include <openssl/engine.h> const char *DH_version="Diffie-Hellman" OPENSSL_VERSION_PTEXT; @@ -67,17 +68,32 @@ static DH_METHOD *default_DH_method; static int dh_meth_num = 0; static STACK_OF(CRYPTO_EX_DATA_FUNCS) *dh_meth = NULL; -void DH_set_default_method(DH_METHOD *meth) +void DH_set_default_openssl_method(DH_METHOD *meth) { - default_DH_method = meth; + ENGINE *e; + /* We'll need to notify the "openssl" ENGINE of this + * change too. We won't bother locking things down at + * our end as there was never any locking in these + * functions! */ + if(default_DH_method != meth) + { + default_DH_method = meth; + e = ENGINE_by_id("openssl"); + if(e) + { + ENGINE_set_DH(e, meth); + ENGINE_free(e); + } + } } -DH_METHOD *DH_get_default_method(void) +DH_METHOD *DH_get_default_openssl_method(void) { if(!default_DH_method) default_DH_method = DH_OpenSSL(); return default_DH_method; } +#if 0 DH_METHOD *DH_set_method(DH *dh, DH_METHOD *meth) { DH_METHOD *mtmp; @@ -87,14 +103,37 @@ DH_METHOD *DH_set_method(DH *dh, DH_METHOD *meth) if (meth->init) meth->init(dh); return mtmp; } +#else +int DH_set_method(DH *dh, ENGINE *engine) +{ + ENGINE *mtmp; + DH_METHOD *meth; + mtmp = dh->engine; + meth = ENGINE_get_DH(mtmp); + if (!ENGINE_init(engine)) + return 0; + if (meth->finish) meth->finish(dh); + dh->engine= engine; + meth = ENGINE_get_DH(engine); + if (meth->init) meth->init(dh); + /* SHOULD ERROR CHECK THIS!!! */ + ENGINE_finish(mtmp); + return 1; +} +#endif DH *DH_new(void) { return DH_new_method(NULL); } +#if 0 DH *DH_new_method(DH_METHOD *meth) +#else +DH *DH_new_method(ENGINE *engine) +#endif { + DH_METHOD *meth; DH *ret; ret=(DH *)OPENSSL_malloc(sizeof(DH)); @@ -103,8 +142,17 @@ DH *DH_new_method(DH_METHOD *meth) DHerr(DH_F_DH_NEW,ERR_R_MALLOC_FAILURE); return(NULL); } - if(meth) ret->meth = meth; - else ret->meth = DH_get_default_method(); + if(engine) + ret->engine = engine; + else + { + if((ret->engine=ENGINE_get_default_DH()) == NULL) + { + OPENSSL_free(ret); + return NULL; + } + } + meth = ENGINE_get_DH(ret->engine); ret->pad=0; ret->version=0; ret->p=NULL; @@ -119,8 +167,8 @@ DH *DH_new_method(DH_METHOD *meth) ret->counter = NULL; ret->method_mont_p=NULL; ret->references = 1; - ret->flags=ret->meth->flags; - if ((ret->meth->init != NULL) && !ret->meth->init(ret)) + ret->flags=meth->flags; + if ((meth->init != NULL) && !meth->init(ret)) { OPENSSL_free(ret); ret=NULL; @@ -132,6 +180,7 @@ DH *DH_new_method(DH_METHOD *meth) void DH_free(DH *r) { + DH_METHOD *meth; int i; if(r == NULL) return; i = CRYPTO_add(&r->references, -1, CRYPTO_LOCK_DH); @@ -149,7 +198,9 @@ void DH_free(DH *r) CRYPTO_free_ex_data(dh_meth, r, &r->ex_data); - if(r->meth->finish) r->meth->finish(r); + meth = ENGINE_get_DH(r->engine); + if(meth->finish) meth->finish(r); + ENGINE_finish(r->engine); if (r->p != NULL) BN_clear_free(r->p); if (r->g != NULL) BN_clear_free(r->g); diff --git a/crypto/dsa/Makefile.ssl b/crypto/dsa/Makefile.ssl index 1dfdb2d769..f9a6dbbd45 100644 --- a/crypto/dsa/Makefile.ssl +++ b/crypto/dsa/Makefile.ssl @@ -116,39 +116,81 @@ dsa_key.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h dsa_key.o: ../../include/openssl/sha.h ../../include/openssl/stack.h dsa_key.o: ../../include/openssl/symhacks.h ../cryptlib.h dsa_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h -dsa_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h -dsa_lib.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h -dsa_lib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h -dsa_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h -dsa_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h -dsa_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h -dsa_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -dsa_lib.o: ../cryptlib.h +dsa_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h +dsa_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h +dsa_lib.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +dsa_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h +dsa_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h +dsa_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h +dsa_lib.o: ../../include/openssl/evp.h ../../include/openssl/idea.h +dsa_lib.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h +dsa_lib.o: ../../include/openssl/md4.h ../../include/openssl/md5.h +dsa_lib.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h +dsa_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h +dsa_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h +dsa_lib.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h +dsa_lib.o: ../../include/openssl/rc5.h ../../include/openssl/rijndael-alg-fst.h |