"handle", "h" and even "e" were probably not the best terms to use. The
authorGeoff Thorpe <geoff@openssl.org>
Mon, 29 May 2000 16:24:42 +0000 (16:24 +0000)
committerGeoff Thorpe <geoff@openssl.org>
Mon, 29 May 2000 16:24:42 +0000 (16:24 +0000)
original idea of "handle" was that it represented a functional reference
to an ENGINE (rather than just a pointer), but on reflection I think
this now looks a little more readable.

12 files changed:
crypto/dh/dh.h
crypto/dh/dh_key.c
crypto/dh/dh_lib.c
crypto/dsa/dsa.h
crypto/dsa/dsa_lib.c
crypto/dsa/dsa_ossl.c
crypto/dsa/dsa_sign.c
crypto/dsa/dsa_vrf.c
crypto/rsa/rsa.h
crypto/rsa/rsa_eay.c
crypto/rsa/rsa_lib.c
crypto/rsa/rsa_sign.c

index 8cad19e89b6b65912256219c8ed6f9fff84fcd23..85e66b09ef3e8426478cea86961b2cb34b9d1605 100644 (file)
@@ -115,7 +115,7 @@ struct dh_st
 #if 0
        DH_METHOD *meth;
 #else
-       struct engine_st *handle;
+       struct engine_st *engine;
 #endif
        };
 
@@ -157,8 +157,8 @@ DH_METHOD *DH_get_default_openssl_method(void);
 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 *h);
-DH *DH_new_method(struct engine_st *handle);
+int DH_set_method(DH *dh, struct engine_st *engine);
+DH *DH_new_method(struct engine_st *engine);
 #endif
 
 DH *   DH_new(void);
index d74441c1de6a5a6f0b2f8ef930f036e1ef4183d0..28817cb6306b881afd634314520feabc74feecab 100644 (file)
@@ -73,12 +73,12 @@ static int dh_finish(DH *dh);
 
 int DH_generate_key(DH *dh)
        {
-       return ENGINE_get_DH(dh->handle)->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 ENGINE_get_DH(dh->handle)->compute_key(key, pub_key, dh);
+       return ENGINE_get_DH(dh->engine)->compute_key(key, pub_key, dh);
        }
 
 static DH_METHOD dh_ossl = {
@@ -138,7 +138,7 @@ static int generate_key(DH *dh)
                }
        mont=(BN_MONT_CTX *)dh->method_mont_p;
 
-       if (!ENGINE_get_DH(dh->handle)->bn_mod_exp(dh, pub_key, dh->g,
+       if (!ENGINE_get_DH(dh->engine)->bn_mod_exp(dh, pub_key, dh->g,
                                priv_key,dh->p,&ctx,mont))
                goto err;
                
@@ -179,7 +179,7 @@ static int compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh)
                }
 
        mont=(BN_MONT_CTX *)dh->method_mont_p;
-       if (!ENGINE_get_DH(dh->handle)->bn_mod_exp(dh, tmp, pub_key,
+       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);
index 9a2462b943e05553fa71b4c159e2c17028ce85d3..d4f193c8f09647b3a0905b1157a0704aa7afb003 100644 (file)
@@ -104,17 +104,17 @@ DH_METHOD *DH_set_method(DH *dh, DH_METHOD *meth)
         return mtmp;
 }
 #else
-int DH_set_method(DH *dh, ENGINE *h)
+int DH_set_method(DH *dh, ENGINE *engine)
 {
        ENGINE *mtmp;
        DH_METHOD *meth;
-       mtmp = dh->handle;
+       mtmp = dh->engine;
        meth = ENGINE_get_DH(mtmp);
-       if (!ENGINE_init(h))
+       if (!ENGINE_init(engine))
                return 0;
        if (meth->finish) meth->finish(dh);
-       dh->handle = h;
-       meth = ENGINE_get_DH(h);
+       dh->engine= engine;
+       meth = ENGINE_get_DH(engine);
        if (meth->init) meth->init(dh);
        /* SHOULD ERROR CHECK THIS!!! */
        ENGINE_finish(mtmp);
@@ -130,7 +130,7 @@ DH *DH_new(void)
 #if 0
 DH *DH_new_method(DH_METHOD *meth)
 #else
-DH *DH_new_method(ENGINE *handle)
+DH *DH_new_method(ENGINE *engine)
 #endif
        {
        DH_METHOD *meth;
@@ -142,17 +142,17 @@ DH *DH_new_method(ENGINE *handle)
                DHerr(DH_F_DH_NEW,ERR_R_MALLOC_FAILURE);
                return(NULL);
                }
-       if(handle)
-               ret->handle = handle;
+       if(engine)
+               ret->engine = engine;
        else
                {
-               if((ret->handle=ENGINE_get_default_DH()) == NULL)
+               if((ret->engine=ENGINE_get_default_DH()) == NULL)
                        {
                        Free(ret);
                        return NULL;
                        }
                }
-       meth = ENGINE_get_DH(ret->handle);
+       meth = ENGINE_get_DH(ret->engine);
        ret->pad=0;
        ret->version=0;
        ret->p=NULL;
@@ -198,9 +198,9 @@ void DH_free(DH *r)
 
        CRYPTO_free_ex_data(dh_meth, r, &r->ex_data);
 
-       meth = ENGINE_get_DH(r->handle);
+       meth = ENGINE_get_DH(r->engine);
        if(meth->finish) meth->finish(r);
-       ENGINE_finish(r->handle);
+       ENGINE_finish(r->engine);
 
        if (r->p != NULL) BN_clear_free(r->p);
        if (r->g != NULL) BN_clear_free(r->g);
index 4339d6adaca130fdc126d42a0832725f0b8a22e8..9aa2480d90af15834ad07e32d0821034d10e16b5 100644 (file)
@@ -133,7 +133,7 @@ struct dsa_st
 #if 0
        DSA_METHOD *meth;
 #else
-       struct engine_st *handle;
+       struct engine_st *engine;
 #endif
        };
 
@@ -165,14 +165,14 @@ 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 *);
+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 *handle);
+DSA *  DSA_new_method(struct engine_st *engine);
 #endif
 int    DSA_size(DSA *);
        /* next 4 return -1 on error */
index a7113c828c72a1a4af6833ca273d8075503544cc..fd33461bcfd45faa4b64227029cd26f4f9b88cf0 100644 (file)
@@ -112,17 +112,17 @@ DSA_METHOD *DSA_set_method(DSA *dsa, DSA_METHOD *meth)
         return mtmp;
 }
 #else
-int DSA_set_method(DSA *dsa, ENGINE *h)
+int DSA_set_method(DSA *dsa, ENGINE *engine)
        {
        ENGINE *mtmp;
        DSA_METHOD *meth;
-       mtmp = dsa->handle;
+       mtmp = dsa->engine;
        meth = ENGINE_get_DSA(mtmp);
-       if (!ENGINE_init(h))
+       if (!ENGINE_init(engine))
                return 0;
        if (meth->finish) meth->finish(dsa);
-       dsa->handle = h;
-       meth = ENGINE_get_DSA(h);
+       dsa->engine = engine;
+       meth = ENGINE_get_DSA(engine);
        if (meth->init) meth->init(dsa);
        /* SHOULD ERROR CHECK THIS!!! */
        ENGINE_finish(mtmp);
@@ -134,7 +134,7 @@ int DSA_set_method(DSA *dsa, ENGINE *h)
 #if 0
 DSA *DSA_new_method(DSA_METHOD *meth)
 #else
-DSA *DSA_new_method(ENGINE *handle)
+DSA *DSA_new_method(ENGINE *engine)
 #endif
        {
        DSA_METHOD *meth;
@@ -146,17 +146,17 @@ DSA *DSA_new_method(ENGINE *handle)
                DSAerr(DSA_F_DSA_NEW,ERR_R_MALLOC_FAILURE);
                return(NULL);
                }
-       if(handle)
-               ret->handle = handle;
+       if(engine)
+               ret->engine = engine;
        else
                {
-               if((ret->handle=ENGINE_get_default_DSA()) == NULL)
+               if((ret->engine=ENGINE_get_default_DSA()) == NULL)
                        {
                        Free(ret);
                        return NULL;
                        }
                }
-       meth = ENGINE_get_DSA(ret->handle);
+       meth = ENGINE_get_DSA(ret->engine);
        ret->pad=0;
        ret->version=0;
        ret->write_params=1;
@@ -206,9 +206,9 @@ void DSA_free(DSA *r)
 
        CRYPTO_free_ex_data(dsa_meth, r, &r->ex_data);
 
-       meth = ENGINE_get_DSA(r->handle);
+       meth = ENGINE_get_DSA(r->engine);
        if(meth->finish) meth->finish(r);
-       ENGINE_finish(r->handle);
+       ENGINE_finish(r->engine);
 
        if (r->p != NULL) BN_clear_free(r->p);
        if (r->q != NULL) BN_clear_free(r->q);
index 64f5c12ab79309cd5f12e6889c7026d6c6e1e7de..533c17ece81f1c3bfb19ca4b9d48ee89deaf1408 100644 (file)
@@ -196,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 (!ENGINE_get_DSA(dsa->handle)->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;
 
@@ -274,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 (!ENGINE_get_DSA(dsa->handle)->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 */
index de909f88407f5fa164f01b43a73f29b4c36a91e7..dfe27bae47a316488119faa7d5cb6eafb3f66d13 100644 (file)
@@ -68,7 +68,7 @@
 
 DSA_SIG * DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
        {
-       return ENGINE_get_DSA(dsa->handle)->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,
@@ -88,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 ENGINE_get_DSA(dsa->handle)->dsa_sign_setup(dsa, ctx_in, kinvp, rp);
+       return ENGINE_get_DSA(dsa->engine)->dsa_sign_setup(dsa, ctx_in, kinvp, rp);
        }
 
index b82dd4421db8ebd28d4e5fff42c8cb1487aa9833..2e891ae491dfcc1aeace7838247520fc67a75bd7 100644 (file)
@@ -70,7 +70,7 @@
 int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,
                  DSA *dsa)
        {
-       return ENGINE_get_DSA(dsa->handle)->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). */
index ef3fd62757b137a22e6016ad4cb52bd5c189d1f1..9129e5d501ec8b660c67739b101bd4a4156bfc8b 100644 (file)
@@ -114,7 +114,7 @@ struct rsa_st
 #if 0
        RSA_METHOD *meth;
 #else
-       struct engine_st *handle;
+       struct engine_st *engine;
 #endif
        BIGNUM *n;
        BIGNUM *e;
@@ -172,7 +172,7 @@ RSA *       RSA_new(void);
 #if 0
 RSA *  RSA_new_method(RSA_METHOD *method);
 #else
-RSA *  RSA_new_method(struct engine_st *handle);
+RSA *  RSA_new_method(struct engine_st *engine);
 #endif
 int    RSA_size(RSA *);
 RSA *  RSA_generate_key(int bits, unsigned long e,void
@@ -197,7 +197,7 @@ RSA_METHOD *RSA_get_method(RSA *rsa);
 #if 0
 RSA_METHOD *RSA_set_method(RSA *rsa, RSA_METHOD *meth);
 #else
-int RSA_set_method(RSA *rsa, struct engine_st *h);
+int RSA_set_method(RSA *rsa, struct engine_st *engine);
 #endif
 
 /* This function needs the memory locking malloc callbacks to be installed */
index a8992afb6dc28cfa1cdc745b86d17d2301e420b3..8deb536cc6efdacb65692454bfbc1a3e9734fdb7 100644 (file)
@@ -104,7 +104,7 @@ static int RSA_eay_public_encrypt(int flen, unsigned char *from,
        unsigned char *buf=NULL;
        BN_CTX *ctx=NULL;
 
-       meth = ENGINE_get_RSA(rsa->handle);
+       meth = ENGINE_get_RSA(rsa->engine);
        BN_init(&f);
        BN_init(&ret);
        if ((ctx=BN_CTX_new()) == NULL) goto err;
@@ -178,7 +178,7 @@ static int RSA_eay_private_encrypt(int flen, unsigned char *from,
        unsigned char *buf=NULL;
        BN_CTX *ctx=NULL;
 
-       meth = ENGINE_get_RSA(rsa->handle);
+       meth = ENGINE_get_RSA(rsa->engine);
        BN_init(&f);
        BN_init(&ret);
 
@@ -257,7 +257,7 @@ static int RSA_eay_private_decrypt(int flen, unsigned char *from,
        unsigned char *buf=NULL;
        BN_CTX *ctx=NULL;
 
-       meth = ENGINE_get_RSA(rsa->handle);
+       meth = ENGINE_get_RSA(rsa->engine);
        BN_init(&f);
        BN_init(&ret);
        ctx=BN_CTX_new();
@@ -352,7 +352,7 @@ static int RSA_eay_public_decrypt(int flen, unsigned char *from,
        unsigned char *buf=NULL;
        BN_CTX *ctx=NULL;
 
-       meth = ENGINE_get_RSA(rsa->handle);
+       meth = ENGINE_get_RSA(rsa->engine);
        BN_init(&f);
        BN_init(&ret);
        ctx=BN_CTX_new();
@@ -423,7 +423,7 @@ static int RSA_eay_mod_exp(BIGNUM *r0, BIGNUM *I, RSA *rsa)
        int ret=0;
        BN_CTX *ctx;
 
-       meth = ENGINE_get_RSA(rsa->handle);
+       meth = ENGINE_get_RSA(rsa->engine);
        if ((ctx=BN_CTX_new()) == NULL) goto err;
        BN_init(&m1);
        BN_init(&r1);
index e970b4c18870eba8a6c4aa765203f2bc2ce67ab4..c7c93234e2f6c0dfc0d7da415bdc6b3942eca360 100644 (file)
@@ -114,7 +114,7 @@ RSA_METHOD *RSA_get_default_openssl_method(void)
 
 RSA_METHOD *RSA_get_method(RSA *rsa)
 {
-       return ENGINE_get_RSA(rsa->handle);
+       return ENGINE_get_RSA(rsa->engine);
 }
 
 #if 0
@@ -128,17 +128,17 @@ RSA_METHOD *RSA_set_method(RSA *rsa, RSA_METHOD *meth)
        return mtmp;
 }
 #else
-int RSA_set_method(RSA *rsa, ENGINE *h)
+int RSA_set_method(RSA *rsa, ENGINE *engine)
 {
        ENGINE *mtmp;
        RSA_METHOD *meth;
-       mtmp = rsa->handle;
+       mtmp = rsa->engine;
        meth = ENGINE_get_RSA(mtmp);
-       if (!ENGINE_init(h))
+       if (!ENGINE_init(engine))
                return 0;
        if (meth->finish) meth->finish(rsa);
-       rsa->handle = h;
-       meth = ENGINE_get_RSA(h);
+       rsa->engine = engine;
+       meth = ENGINE_get_RSA(engine);
        if (meth->init) meth->init(rsa);
        /* SHOULD ERROR CHECK THIS!!! */
        ENGINE_finish(mtmp);
@@ -149,7 +149,7 @@ int RSA_set_method(RSA *rsa, ENGINE *h)
 #if 0
 RSA *RSA_new_method(RSA_METHOD *meth)
 #else
-RSA *RSA_new_method(ENGINE *handle)
+RSA *RSA_new_method(ENGINE *engine)
 #endif
        {
        RSA_METHOD *meth;
@@ -162,17 +162,17 @@ RSA *RSA_new_method(ENGINE *handle)
                return(NULL);
                }
 
-       if (handle == NULL)
+       if (engine == NULL)
                {
-               if((ret->handle=ENGINE_get_default_RSA()) == NULL)
+               if((ret->engine=ENGINE_get_default_RSA()) == NULL)
                        {
                        Free(ret);
                        return NULL;
                        }
                }
        else
-               ret->handle=handle;
-       meth = ENGINE_get_RSA(ret->handle);
+               ret->engine=engine;
+       meth = ENGINE_get_RSA(ret->engine);
 
        ret->pad=0;
        ret->version=0;
@@ -223,10 +223,10 @@ void RSA_free(RSA *r)
 
        CRYPTO_free_ex_data(rsa_meth,r,&r->ex_data);
 
-       meth = ENGINE_get_RSA(r->handle);
+       meth = ENGINE_get_RSA(r->engine);
        if (meth->finish != NULL)
                meth->finish(r);
-       ENGINE_finish(r->handle);
+       ENGINE_finish(r->engine);
 
        if (r->n != NULL) BN_clear_free(r->n);
        if (r->e != NULL) BN_clear_free(r->e);
@@ -267,34 +267,34 @@ int RSA_size(RSA *r)
 int RSA_public_encrypt(int flen, unsigned char *from, unsigned char *to,
             RSA *rsa, int padding)
        {
-       return(ENGINE_get_RSA(rsa->handle)->rsa_pub_enc(flen,
+       return(ENGINE_get_RSA(rsa->engine)->rsa_pub_enc(flen,
                from, to, rsa, padding));
        }
 
 int RSA_private_encrypt(int flen, unsigned char *from, unsigned char *to,
             RSA *rsa, int padding)
        {
-       return(ENGINE_get_RSA(rsa->handle)->rsa_priv_enc(flen,
+       return(ENGINE_get_RSA(rsa->engine)->rsa_priv_enc(flen,
                from, to, rsa, padding));
        }
 
 int RSA_private_decrypt(int flen, unsigned char *from, unsigned char *to,
             RSA *rsa, int padding)
        {
-       return(ENGINE_get_RSA(rsa->handle)->rsa_priv_dec(flen,
+       return(ENGINE_get_RSA(rsa->engine)->rsa_priv_dec(flen,
                from, to, rsa, padding));
        }
 
 int RSA_public_decrypt(int flen, unsigned char *from, unsigned char *to,
             RSA *rsa, int padding)
        {
-       return(ENGINE_get_RSA(rsa->handle)->rsa_pub_dec(flen,
+       return(ENGINE_get_RSA(rsa->engine)->rsa_pub_dec(flen,
                from, to, rsa, padding));
        }
 
 int RSA_flags(RSA *r)
        {
-       return((r == NULL)?0:ENGINE_get_RSA(r->handle)->flags);
+       return((r == NULL)?0:ENGINE_get_RSA(r->engine)->flags);
        }
 
 void RSA_blinding_off(RSA *rsa)
@@ -328,7 +328,7 @@ int RSA_blinding_on(RSA *rsa, BN_CTX *p_ctx)
        if (!BN_rand(A,BN_num_bits(rsa->n)-1,1,0)) goto err;
        if ((Ai=BN_mod_inverse(NULL,A,rsa->n,ctx)) == NULL) goto err;
 
-       if (!ENGINE_get_RSA(rsa->handle)->bn_mod_exp(A,A,
+       if (!ENGINE_get_RSA(rsa->engine)->bn_mod_exp(A,A,
                rsa->e,rsa->n,ctx,rsa->_method_mod_n))
            goto err;
        rsa->blinding=BN_BLINDING_new(A,Ai,rsa->n);
index 4a23df1946b01437a6d77d740681ada1ada1ebb0..2b98348b38fbe108c4435d6442e1b56a108f326a 100644 (file)
@@ -77,7 +77,7 @@ int RSA_sign(int type, unsigned char *m, unsigned int m_len,
        X509_ALGOR algor;
        ASN1_OCTET_STRING digest;
        if(rsa->flags & RSA_FLAG_SIGN_VER)
-             return ENGINE_get_RSA(rsa->handle)->rsa_sign(type,
+             return ENGINE_get_RSA(rsa->engine)->rsa_sign(type,
                        m, m_len, sigret, siglen, rsa);
        /* Special case: SSL signature, just check the length */
        if(type == NID_md5_sha1) {
@@ -153,7 +153,7 @@ int RSA_verify(int dtype, unsigned char *m, unsigned int m_len,
                }
 
        if(rsa->flags & RSA_FLAG_SIGN_VER)
-           return ENGINE_get_RSA(rsa->handle)->rsa_verify(dtype,
+           return ENGINE_get_RSA(rsa->engine)->rsa_verify(dtype,
                        m, m_len, sigbuf, siglen, rsa);
 
        s=(unsigned char *)Malloc((unsigned int)siglen);