diff options
author | Bob Beck <beck@cvs.openbsd.org> | 2000-12-15 02:58:48 +0000 |
---|---|---|
committer | Bob Beck <beck@cvs.openbsd.org> | 2000-12-15 02:58:48 +0000 |
commit | 01c37e03996dffeff1618614755c6cc676899acb (patch) | |
tree | 988002fb9b1d859c10890511aa5273cfb00662dc /lib/libcrypto/dsa | |
parent | 9865f3ff77de9cfef0c5c8b0470daf6faa2f14af (diff) |
openssl-engine-0.9.6 merge
Diffstat (limited to 'lib/libcrypto/dsa')
-rw-r--r-- | lib/libcrypto/dsa/Makefile.ssl | 127 | ||||
-rw-r--r-- | lib/libcrypto/dsa/dsa.h | 29 | ||||
-rw-r--r-- | lib/libcrypto/dsa/dsa_asn1.c | 14 | ||||
-rw-r--r-- | lib/libcrypto/dsa/dsa_key.c | 2 | ||||
-rw-r--r-- | lib/libcrypto/dsa/dsa_lib.c | 74 | ||||
-rw-r--r-- | lib/libcrypto/dsa/dsa_ossl.c | 7 | ||||
-rw-r--r-- | lib/libcrypto/dsa/dsa_sign.c | 5 | ||||
-rw-r--r-- | lib/libcrypto/dsa/dsa_vrf.c | 3 |
8 files changed, 186 insertions, 75 deletions
diff --git a/lib/libcrypto/dsa/Makefile.ssl b/lib/libcrypto/dsa/Makefile.ssl index b0bcf974fbf..dac582be00d 100644 --- a/lib/libcrypto/dsa/Makefile.ssl +++ b/lib/libcrypto/dsa/Makefile.ssl @@ -85,62 +85,105 @@ dsa_asn1.o: ../../include/openssl/bio.h ../../include/openssl/bn.h dsa_asn1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h dsa_asn1.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h dsa_asn1.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h -dsa_asn1.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h +dsa_asn1.o: ../../include/openssl/err.h ../../include/openssl/lhash.h +dsa_asn1.o: ../../include/openssl/opensslconf.h dsa_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h -dsa_asn1.o: ../../include/openssl/stack.h ../cryptlib.h -dsa_err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h -dsa_err.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h -dsa_err.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h +dsa_asn1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +dsa_asn1.o: ../cryptlib.h +dsa_err.o: ../../include/openssl/bio.h ../../include/openssl/bn.h +dsa_err.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h +dsa_err.o: ../../include/openssl/dsa.h ../../include/openssl/err.h +dsa_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h dsa_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h -dsa_err.o: ../../include/openssl/stack.h +dsa_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h dsa_gen.o: ../../include/openssl/bio.h ../../include/openssl/bn.h dsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h dsa_gen.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h dsa_gen.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h -dsa_gen.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h -dsa_gen.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h -dsa_gen.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h -dsa_gen.o: ../../include/openssl/stack.h ../cryptlib.h +dsa_gen.o: ../../include/openssl/err.h ../../include/openssl/lhash.h +dsa_gen.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h +dsa_gen.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h +dsa_gen.o: ../../include/openssl/sha.h ../../include/openssl/stack.h +dsa_gen.o: ../../include/openssl/symhacks.h ../cryptlib.h dsa_key.o: ../../include/openssl/bio.h ../../include/openssl/bn.h dsa_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h dsa_key.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h dsa_key.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h -dsa_key.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h -dsa_key.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h -dsa_key.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h -dsa_key.o: ../../include/openssl/stack.h ../cryptlib.h +dsa_key.o: ../../include/openssl/err.h ../../include/openssl/lhash.h +dsa_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h +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/opensslconf.h ../../include/openssl/opensslv.h -dsa_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.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/ripemd.h +dsa_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h +dsa_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h +dsa_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h dsa_ossl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h -dsa_ossl.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h -dsa_ossl.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h -dsa_ossl.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h -dsa_ossl.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h -dsa_ossl.o: ../../include/openssl/opensslconf.h +dsa_ossl.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h +dsa_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h +dsa_ossl.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +dsa_ossl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h +dsa_ossl.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h +dsa_ossl.o: ../../include/openssl/engine.h ../../include/openssl/err.h +dsa_ossl.o: ../../include/openssl/evp.h ../../include/openssl/idea.h +dsa_ossl.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h +dsa_ossl.o: ../../include/openssl/md4.h ../../include/openssl/md5.h +dsa_ossl.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h +dsa_ossl.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h dsa_ossl.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h -dsa_ossl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h -dsa_ossl.o: ../cryptlib.h +dsa_ossl.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h +dsa_ossl.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h +dsa_ossl.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h +dsa_ossl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h +dsa_ossl.o: ../../include/openssl/symhacks.h ../cryptlib.h dsa_sign.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h -dsa_sign.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h -dsa_sign.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h -dsa_sign.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h -dsa_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h -dsa_sign.o: ../../include/openssl/opensslconf.h +dsa_sign.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h +dsa_sign.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h +dsa_sign.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +dsa_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h +dsa_sign.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h +dsa_sign.o: ../../include/openssl/engine.h ../../include/openssl/err.h +dsa_sign.o: ../../include/openssl/evp.h ../../include/openssl/idea.h +dsa_sign.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h +dsa_sign.o: ../../include/openssl/md4.h ../../include/openssl/md5.h +dsa_sign.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h +dsa_sign.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h dsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h -dsa_sign.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h -dsa_sign.o: ../cryptlib.h +dsa_sign.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h +dsa_sign.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h +dsa_sign.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h +dsa_sign.o: ../../include/openssl/sha.h ../../include/openssl/stack.h +dsa_sign.o: ../../include/openssl/symhacks.h ../cryptlib.h dsa_vrf.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h -dsa_vrf.o: ../../include/openssl/bio.h ../../include/openssl/bn.h -dsa_vrf.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h -dsa_vrf.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h -dsa_vrf.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h -dsa_vrf.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h -dsa_vrf.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h -dsa_vrf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +dsa_vrf.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h +dsa_vrf.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h +dsa_vrf.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h +dsa_vrf.o: ../../include/openssl/des.h ../../include/openssl/dh.h +dsa_vrf.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h +dsa_vrf.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h +dsa_vrf.o: ../../include/openssl/err.h ../../include/openssl/evp.h +dsa_vrf.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h +dsa_vrf.o: ../../include/openssl/md2.h ../../include/openssl/md4.h +dsa_vrf.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h +dsa_vrf.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h +dsa_vrf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h +dsa_vrf.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h +dsa_vrf.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h +dsa_vrf.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h +dsa_vrf.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h +dsa_vrf.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h dsa_vrf.o: ../cryptlib.h diff --git a/lib/libcrypto/dsa/dsa.h b/lib/libcrypto/dsa/dsa.h index 68d9912cbc5..65689a34266 100644 --- a/lib/libcrypto/dsa/dsa.h +++ b/lib/libcrypto/dsa/dsa.h @@ -65,14 +65,13 @@ #ifndef HEADER_DSA_H #define HEADER_DSA_H -#ifdef __cplusplus -extern "C" { -#endif - #ifdef NO_DSA #error DSA is disabled. #endif +#ifndef NO_BIO +#include <openssl/bio.h> +#endif #include <openssl/bn.h> #include <openssl/crypto.h> #ifndef NO_DH @@ -81,6 +80,10 @@ extern "C" { #define DSA_FLAG_CACHE_MONT_P 0x01 +#ifdef __cplusplus +extern "C" { +#endif + typedef struct dsa_st DSA; typedef struct DSA_SIG_st @@ -130,7 +133,11 @@ struct dsa_st char *method_mont_p; int references; CRYPTO_EX_DATA ex_data; +#if 0 DSA_METHOD *meth; +#else + struct engine_st *engine; +#endif }; #define DSAparams_dup(x) (DSA *)ASN1_dup((int (*)())i2d_DSAparams, \ @@ -156,12 +163,20 @@ int DSA_do_verify(const unsigned char *dgst,int dgst_len, DSA_METHOD *DSA_OpenSSL(void); -void DSA_set_default_method(DSA_METHOD *); -DSA_METHOD *DSA_get_default_method(void); +void DSA_set_default_openssl_method(DSA_METHOD *); +DSA_METHOD *DSA_get_default_openssl_method(void); +#if 0 DSA_METHOD *DSA_set_method(DSA *dsa, DSA_METHOD *); +#else +int DSA_set_method(DSA *dsa, struct engine_st *engine); +#endif DSA * DSA_new(void); +#if 0 DSA * DSA_new_method(DSA_METHOD *meth); +#else +DSA * DSA_new_method(struct engine_st *engine); +#endif int DSA_size(DSA *); /* next 4 return -1 on error */ int DSA_sign_setup( DSA *dsa,BN_CTX *ctx_in,BIGNUM **kinvp,BIGNUM **rp); @@ -188,7 +203,7 @@ int i2d_DSAPublicKey(DSA *a, unsigned char **pp); int i2d_DSAPrivateKey(DSA *a, unsigned char **pp); int i2d_DSAparams(DSA *a,unsigned char **pp); -#ifdef HEADER_BIO_H +#ifndef NO_BIO int DSAparams_print(BIO *bp, DSA *x); int DSA_print(BIO *bp, DSA *x, int off); #endif diff --git a/lib/libcrypto/dsa/dsa_asn1.c b/lib/libcrypto/dsa/dsa_asn1.c index c9b32b4db78..a76c8f7c7eb 100644 --- a/lib/libcrypto/dsa/dsa_asn1.c +++ b/lib/libcrypto/dsa/dsa_asn1.c @@ -10,7 +10,7 @@ DSA_SIG *DSA_SIG_new(void) { DSA_SIG *ret; - ret = Malloc(sizeof(DSA_SIG)); + ret = OPENSSL_malloc(sizeof(DSA_SIG)); if (ret == NULL) { DSAerr(DSA_F_DSA_SIG_NEW,ERR_R_MALLOC_FAILURE); @@ -26,7 +26,7 @@ void DSA_SIG_free(DSA_SIG *r) if (r == NULL) return; if (r->r) BN_clear_free(r->r); if (r->s) BN_clear_free(r->s); - Free(r); + OPENSSL_free(r); } int i2d_DSA_SIG(DSA_SIG *v, unsigned char **pp) @@ -35,7 +35,7 @@ int i2d_DSA_SIG(DSA_SIG *v, unsigned char **pp) ASN1_INTEGER rbs,sbs; unsigned char *p; - rbs.data=Malloc(BN_num_bits(v->r)/8+1); + rbs.data=OPENSSL_malloc(BN_num_bits(v->r)/8+1); if (rbs.data == NULL) { DSAerr(DSA_F_I2D_DSA_SIG, ERR_R_MALLOC_FAILURE); @@ -43,10 +43,10 @@ int i2d_DSA_SIG(DSA_SIG *v, unsigned char **pp) } rbs.type=V_ASN1_INTEGER; rbs.length=BN_bn2bin(v->r,rbs.data); - sbs.data=Malloc(BN_num_bits(v->s)/8+1); + sbs.data=OPENSSL_malloc(BN_num_bits(v->s)/8+1); if (sbs.data == NULL) { - Free(rbs.data); + OPENSSL_free(rbs.data); DSAerr(DSA_F_I2D_DSA_SIG, ERR_R_MALLOC_FAILURE); return(0); } @@ -64,8 +64,8 @@ int i2d_DSA_SIG(DSA_SIG *v, unsigned char **pp) i2d_ASN1_INTEGER(&sbs,&p); } t=ASN1_object_size(1,len,V_ASN1_SEQUENCE); - Free(rbs.data); - Free(sbs.data); + OPENSSL_free(rbs.data); + OPENSSL_free(sbs.data); return(t); } diff --git a/lib/libcrypto/dsa/dsa_key.c b/lib/libcrypto/dsa/dsa_key.c index 5aef2d5fcff..af3c56d770e 100644 --- a/lib/libcrypto/dsa/dsa_key.c +++ b/lib/libcrypto/dsa/dsa_key.c @@ -84,7 +84,7 @@ int DSA_generate_key(DSA *dsa) i=BN_num_bits(dsa->q); for (;;) { - if (!BN_rand(priv_key,i,1,0)) + if (!BN_rand(priv_key,i,0,0)) goto err; if (BN_cmp(priv_key,dsa->q) >= 0) BN_sub(priv_key,priv_key,dsa->q); diff --git a/lib/libcrypto/dsa/dsa_lib.c b/lib/libcrypto/dsa/dsa_lib.c index 224e412afc4..b31b946ad3b 100644 --- a/lib/libcrypto/dsa/dsa_lib.c +++ b/lib/libcrypto/dsa/dsa_lib.c @@ -63,6 +63,7 @@ #include <openssl/bn.h> #include <openssl/dsa.h> #include <openssl/asn1.h> +#include <openssl/engine.h> const char *DSA_version="DSA" OPENSSL_VERSION_PTEXT; @@ -70,12 +71,26 @@ static DSA_METHOD *default_DSA_method; static int dsa_meth_num = 0; static STACK_OF(CRYPTO_EX_DATA_FUNCS) *dsa_meth = NULL; -void DSA_set_default_method(DSA_METHOD *meth) +void DSA_set_default_openssl_method(DSA_METHOD *meth) { - default_DSA_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_DSA_method != meth) + { + default_DSA_method = meth; + e = ENGINE_by_id("openssl"); + if(e) + { + ENGINE_set_DSA(e, meth); + ENGINE_free(e); + } + } } -DSA_METHOD *DSA_get_default_method(void) +DSA_METHOD *DSA_get_default_openssl_method(void) { if(!default_DSA_method) default_DSA_method = DSA_OpenSSL(); return default_DSA_method; @@ -86,6 +101,7 @@ DSA *DSA_new(void) return DSA_new_method(NULL); } +#if 0 DSA_METHOD *DSA_set_method(DSA *dsa, DSA_METHOD *meth) { DSA_METHOD *mtmp; @@ -95,21 +111,52 @@ DSA_METHOD *DSA_set_method(DSA *dsa, DSA_METHOD *meth) if (meth->init) meth->init(dsa); return mtmp; } +#else +int DSA_set_method(DSA *dsa, ENGINE *engine) + { + ENGINE *mtmp; + DSA_METHOD *meth; + mtmp = dsa->engine; + meth = ENGINE_get_DSA(mtmp); + if (!ENGINE_init(engine)) + return 0; + if (meth->finish) meth->finish(dsa); + dsa->engine = engine; + meth = ENGINE_get_DSA(engine); + if (meth->init) meth->init(dsa); + /* SHOULD ERROR CHECK THIS!!! */ + ENGINE_finish(mtmp); + return 1; + } +#endif +#if 0 DSA *DSA_new_method(DSA_METHOD *meth) +#else +DSA *DSA_new_method(ENGINE *engine) +#endif { + DSA_METHOD *meth; DSA *ret; - ret=(DSA *)Malloc(sizeof(DSA)); + ret=(DSA *)OPENSSL_malloc(sizeof(DSA)); if (ret == NULL) { DSAerr(DSA_F_DSA_NEW,ERR_R_MALLOC_FAILURE); return(NULL); } - if(!default_DSA_method) default_DSA_method = DSA_OpenSSL(); - if(meth) ret->meth = meth; - else ret->meth = default_DSA_method; + if(engine) + ret->engine = engine; + else + { + if((ret->engine=ENGINE_get_default_DSA()) == NULL) + { + OPENSSL_free(ret); + return NULL; + } + } + meth = ENGINE_get_DSA(ret->engine); ret->pad=0; ret->version=0; ret->write_params=1; @@ -125,10 +172,10 @@ DSA *DSA_new_method(DSA_METHOD *meth) 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)) { - Free(ret); + OPENSSL_free(ret); ret=NULL; } else @@ -139,6 +186,7 @@ DSA *DSA_new_method(DSA_METHOD *meth) void DSA_free(DSA *r) { + DSA_METHOD *meth; int i; if (r == NULL) return; @@ -158,7 +206,9 @@ void DSA_free(DSA *r) CRYPTO_free_ex_data(dsa_meth, r, &r->ex_data); - if(r->meth->finish) r->meth->finish(r); + meth = ENGINE_get_DSA(r->engine); + if(meth->finish) meth->finish(r); + ENGINE_finish(r->engine); if (r->p != NULL) BN_clear_free(r->p); if (r->q != NULL) BN_clear_free(r->q); @@ -167,7 +217,7 @@ void DSA_free(DSA *r) if (r->priv_key != NULL) BN_clear_free(r->priv_key); if (r->kinv != NULL) BN_clear_free(r->kinv); if (r->r != NULL) BN_clear_free(r->r); - Free(r); + OPENSSL_free(r); } int DSA_size(DSA *r) diff --git a/lib/libcrypto/dsa/dsa_ossl.c b/lib/libcrypto/dsa/dsa_ossl.c index b51cf6ad8d4..96295dc24f7 100644 --- a/lib/libcrypto/dsa/dsa_ossl.c +++ b/lib/libcrypto/dsa/dsa_ossl.c @@ -64,6 +64,7 @@ #include <openssl/dsa.h> #include <openssl/rand.h> #include <openssl/asn1.h> +#include <openssl/engine.h> static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa); static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp); @@ -181,7 +182,7 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) /* Get random k */ for (;;) { - if (!BN_rand(&k, BN_num_bits(dsa->q), 1, 0)) goto err; + if (!BN_rand(&k, BN_num_bits(dsa->q), 0, 0)) goto err; if (BN_cmp(&k,dsa->q) >= 0) BN_sub(&k,&k,dsa->q); if (!BN_is_zero(&k)) break; @@ -195,7 +196,7 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) } /* Compute r = (g^k mod p) mod q */ - if (!dsa->meth->bn_mod_exp(dsa, r,dsa->g,&k,dsa->p,ctx, + if (!ENGINE_get_DSA(dsa->engine)->bn_mod_exp(dsa, r,dsa->g,&k,dsa->p,ctx, (BN_MONT_CTX *)dsa->method_mont_p)) goto err; if (!BN_mod(r,r,dsa->q,ctx)) goto err; @@ -273,7 +274,7 @@ static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, if (!BN_mod(&u1,&u1,dsa->q,ctx)) goto err; #else { - if (!dsa->meth->dsa_mod_exp(dsa, &t1,dsa->g,&u1,dsa->pub_key,&u2, + if (!ENGINE_get_DSA(dsa->engine)->dsa_mod_exp(dsa, &t1,dsa->g,&u1,dsa->pub_key,&u2, dsa->p,ctx,mont)) goto err; /* BN_copy(&u1,&t1); */ /* let u1 = u1 mod q */ diff --git a/lib/libcrypto/dsa/dsa_sign.c b/lib/libcrypto/dsa/dsa_sign.c index 89205026f01..dfe27bae47a 100644 --- a/lib/libcrypto/dsa/dsa_sign.c +++ b/lib/libcrypto/dsa/dsa_sign.c @@ -64,10 +64,11 @@ #include <openssl/dsa.h> #include <openssl/rand.h> #include <openssl/asn1.h> +#include <openssl/engine.h> DSA_SIG * DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) { - return dsa->meth->dsa_do_sign(dgst, dlen, dsa); + return ENGINE_get_DSA(dsa->engine)->dsa_do_sign(dgst, dlen, dsa); } int DSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig, @@ -87,6 +88,6 @@ int DSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig, int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) { - return dsa->meth->dsa_sign_setup(dsa, ctx_in, kinvp, rp); + return ENGINE_get_DSA(dsa->engine)->dsa_sign_setup(dsa, ctx_in, kinvp, rp); } diff --git a/lib/libcrypto/dsa/dsa_vrf.c b/lib/libcrypto/dsa/dsa_vrf.c index 03277f80fdc..2e891ae491d 100644 --- a/lib/libcrypto/dsa/dsa_vrf.c +++ b/lib/libcrypto/dsa/dsa_vrf.c @@ -65,11 +65,12 @@ #include <openssl/rand.h> #include <openssl/asn1.h> #include <openssl/asn1_mac.h> +#include <openssl/engine.h> int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, DSA *dsa) { - return dsa->meth->dsa_do_verify(dgst, dgst_len, sig, dsa); + return ENGINE_get_DSA(dsa->engine)->dsa_do_verify(dgst, dgst_len, sig, dsa); } /* data has already been hashed (probably with SHA or SHA-1). */ |