Some more tweaks to ENGINE code.
[openssl.git] / crypto / engine / hw_ubsec.c
index 143efbd..a05211f 100644 (file)
@@ -62,7 +62,6 @@
 #include <openssl/crypto.h>
 #include "cryptlib.h"
 #include <openssl/dso.h>
-#include "engine_int.h"
 #include <openssl/engine.h>
 
 #ifndef OPENSSL_NO_HW
@@ -153,26 +152,9 @@ static DH_METHOD ubsec_dh =
        NULL
        };
 
-/* Our ENGINE structure. */
-static ENGINE engine_ubsec =
-        {
-       "ubsec",
-       "UBSEC hardware engine support",
-       &ubsec_rsa,
-       &ubsec_dsa,
-       &ubsec_dh,
-       NULL,
-       ubsec_mod_exp,
-       ubsec_mod_exp_crt,
-       ubsec_init,
-       ubsec_finish,
-       NULL, /* no ctrl() */
-       NULL, /* no load_privkey() */
-       NULL, /* no load_pubkey() */
-       0, /* no flags */
-       0, 0, /* no references */
-       NULL, NULL /* unlinked */
-        };
+/* Constants used when creating the ENGINE */
+static const char *engine_ubsec_id = "ubsec";
+static const char *engine_ubsec_name = "UBSEC hardware engine support";
 
 /* As this is only ever called once, there's no need for locking
  * (indeed - the lock will already be held by our caller!!!) */
@@ -182,6 +164,22 @@ ENGINE *ENGINE_ubsec()
 #ifndef HAVE_UBSEC_DH
        const DH_METHOD *meth3;
 #endif /* HAVE_UBSEC_DH */
+       ENGINE *ret = ENGINE_new();
+       if(!ret)
+               return NULL;
+       if(!ENGINE_set_id(ret, engine_ubsec_id) ||
+                       !ENGINE_set_name(ret, engine_ubsec_name) ||
+                       !ENGINE_set_RSA(ret, &ubsec_rsa) ||
+                       !ENGINE_set_DSA(ret, &ubsec_dsa) ||
+                       !ENGINE_set_DH(ret, &ubsec_dh) ||
+                       !ENGINE_set_BN_mod_exp(ret, ubsec_mod_exp) ||
+                       !ENGINE_set_BN_mod_exp_crt(ret, ubsec_mod_exp_crt) ||
+                       !ENGINE_set_init_function(ret, ubsec_init) ||
+                       !ENGINE_set_finish_function(ret, ubsec_finish))
+               {
+               ENGINE_free(ret);
+               return NULL;
+               }
 
        /* We know that the "PKCS1_SSLeay()" functions hook properly
         * to the Broadcom-specific mod_exp and mod_exp_crt so we use
@@ -203,7 +201,7 @@ ENGINE *ENGINE_ubsec()
        ubsec_dh.compute_key = meth3->compute_key;
 #endif /* HAVE_UBSEC_DH */
 
-       return &engine_ubsec;
+       return ret;
        }
 
 /* This is a process-global DSO handle used for loading and unloading