"handle", "h" and even "e" were probably not the best terms to use. The

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.
This commit is contained in:
Geoff Thorpe
2000-05-29 16:24:42 +00:00
parent 96d7e0ece7
commit f156d5495d
12 changed files with 68 additions and 68 deletions

View 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);

View 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);

View 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);

View 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 */

View 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);

View 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 */

View 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);
}

View 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). */

View 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 */

View 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);

View 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);

View 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);