Commit f156d549 authored by Geoff Thorpe's avatar Geoff Thorpe
Browse files

"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.
parent 96d7e0ec
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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);
+4 −4
Original line number Diff line number Diff line
@@ -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);
+12 −12
Original line number Diff line number Diff line
@@ -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);
+3 −3
Original line number Diff line number Diff line
@@ -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 */
+12 −12
Original line number Diff line number Diff line
@@ -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);
Loading