The switch to having an (ENGINE *) handle inside each RSA structure rather
authorGeoff Thorpe <geoff@openssl.org>
Sun, 28 May 2000 22:54:51 +0000 (22:54 +0000)
committerGeoff Thorpe <geoff@openssl.org>
Sun, 28 May 2000 22:54:51 +0000 (22:54 +0000)
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.

crypto/rsa/rsa.h
crypto/rsa/rsa_lib.c

index 8bccf73c27a5c769bf8a02f9e6bf7a8b9e6491dd..ef3fd62757b137a22e6016ad4cb52bd5c189d1f1 100644 (file)
@@ -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 */
index 885fb0227f15ef2d8e3ab0bf265b2604cf63911e..e970b4c18870eba8a6c4aa765203f2bc2ce67ab4 100644 (file)
@@ -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