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

The switch to having an (ENGINE *) handle inside each RSA structure rather

than (RSA_METHOD *) required a couple of functions to change shape. I
didn't really pick the best shape to change RSA_set_method into though. :-)

There's nothing really appropriate to return from RSA_set_method; the
temptation to return an "old handle" fails when you consider that the
caller might ignore the return value and so botch up the reference
counting, this wasn't an issue before because there was no reference
counting.
parent bb51f217
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -197,7 +197,7 @@ RSA_METHOD *RSA_get_method(RSA *rsa);
#if 0
RSA_METHOD *RSA_set_method(RSA *rsa, RSA_METHOD *meth);
#else
RSA_METHOD *RSA_set_method(RSA *rsa, struct engine_st *h);
int RSA_set_method(RSA *rsa, struct engine_st *h);
#endif

/* This function needs the memory locking malloc callbacks to be installed */
+6 −6
Original line number Diff line number Diff line
@@ -128,21 +128,21 @@ RSA_METHOD *RSA_set_method(RSA *rsa, RSA_METHOD *meth)
	return mtmp;
}
#else
RSA_METHOD *RSA_set_method(RSA *rsa, ENGINE *h)
int RSA_set_method(RSA *rsa, ENGINE *h)
{
	ENGINE *mtmp;
	RSA_METHOD *meth, *old_meth;
	RSA_METHOD *meth;
	mtmp = rsa->handle;
	old_meth = ENGINE_get_RSA(mtmp);
	meth = ENGINE_get_RSA(mtmp);
	if (!ENGINE_init(h))
		return NULL;
	if (old_meth->finish) old_meth->finish(rsa);
		return 0;
	if (meth->finish) meth->finish(rsa);
	rsa->handle = h;
	meth = ENGINE_get_RSA(h);
	if (meth->init) meth->init(rsa);
	/* SHOULD ERROR CHECK THIS!!! */
	ENGINE_finish(mtmp);
	return old_meth;
	return 1;
}
#endif