Make the shared library name and function symbol for the "nuron" ENGINE
[openssl.git] / crypto / engine / hw_nuron.c
index d8a3e3f1fa7174356c63d27f1fe692f3e988230a..b5e63906c96503846cb2f3df86fcda890a552b2d 100644 (file)
 #include <openssl/dso.h>
 #include "engine_int.h"
 #include <openssl/engine.h>
-#include <dlfcn.h>
 
 
-#ifndef NO_HW
-#ifndef NO_HW_NURON
+#ifndef OPENSSL_NO_HW
+#ifndef OPENSSL_NO_HW_NURON
 
-typedef int tfnModExp(BIGNUM *r,BIGNUM *a,const BIGNUM *p,const BIGNUM *m);
+static const char *NURON_LIBNAME = "nuronssl";
+static const char *NURON_F1 = "nuron_mod_exp";
+
+typedef int tfnModExp(BIGNUM *r,const BIGNUM *a,const BIGNUM *p,const BIGNUM *m);
 static tfnModExp *pfnModExp = NULL;
 
 static DSO *pvDSOHandle = NULL;
 
-static int nuron_init()
+static int nuron_init(ENGINE *e)
        {
        if(pvDSOHandle != NULL)
                {
@@ -81,7 +83,7 @@ static int nuron_init()
                return 0;
                }
 
-       pvDSOHandle=DSO_load(NULL,"nuronssl",NULL,
+       pvDSOHandle=DSO_load(NULL, NURON_LIBNAME, NULL,
                DSO_FLAG_NAME_TRANSLATION_EXT_ONLY);
        if(!pvDSOHandle)
                {
@@ -89,7 +91,7 @@ static int nuron_init()
                return 0;
                }
 
-       pfnModExp=(tfnModExp *)DSO_bind_func(pvDSOHandle,"nuron_mod_exp");
+       pfnModExp=(tfnModExp *)DSO_bind_func(pvDSOHandle, NURON_F1);
        if(!pfnModExp)
                {
                ENGINEerr(ENGINE_F_NURON_INIT,ENGINE_R_DSO_FUNCTION_NOT_FOUND);
@@ -99,7 +101,7 @@ static int nuron_init()
        return 1;
        }
 
-static int nuron_finish()
+static int nuron_finish(ENGINE *e)
        {
        if(pvDSOHandle == NULL)
                {
@@ -116,7 +118,7 @@ static int nuron_finish()
        return 1;
        }
 
-static int nuron_mod_exp(BIGNUM *r,BIGNUM *a,const BIGNUM *p,
+static int nuron_mod_exp(BIGNUM *r,const BIGNUM *a,const BIGNUM *p,
                         const BIGNUM *m,BN_CTX *ctx)
        {
        if(!pvDSOHandle)
@@ -127,7 +129,7 @@ static int nuron_mod_exp(BIGNUM *r,BIGNUM *a,const BIGNUM *p,
        return pfnModExp(r,a,p,m);
        }
 
-static int nuron_rsa_mod_exp(BIGNUM *r0, BIGNUM *I, RSA *rsa)
+static int nuron_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
        {
        return nuron_mod_exp(r0,I,rsa->d,rsa->n,NULL);
        }
@@ -171,15 +173,16 @@ static int nuron_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,
        }
 
 /* This function is aliased to mod_exp (with the mont stuff dropped). */
-static int nuron_mod_exp_mont(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
+static int nuron_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
                              const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
        {
        return nuron_mod_exp(r, a, p, m, ctx);
        }
 
 /* This function is aliased to mod_exp (with the dh and mont dropped). */
-static int nuron_mod_exp_dh(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
-                           const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
+static int nuron_mod_exp_dh(const DH *dh, BIGNUM *r,
+               const BIGNUM *a, const BIGNUM *p,
+               const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
        {
        return nuron_mod_exp(r, a, p, m, ctx);
        }
@@ -251,9 +254,9 @@ static ENGINE engine_nuron =
  * (indeed - the lock will already be held by our caller!!!) */
 ENGINE *ENGINE_nuron()
        {
-       RSA_METHOD *meth1;
-       DSA_METHOD *meth2;
-       DH_METHOD *meth3;
+       const RSA_METHOD *meth1;
+       const DSA_METHOD *meth2;
+       const DH_METHOD *meth3;
 
        /* We know that the "PKCS1_SSLeay()" functions hook properly
         * to the nuron-specific mod_exp and mod_exp_crt so we use
@@ -282,5 +285,5 @@ ENGINE *ENGINE_nuron()
        return &engine_nuron;
        }
 
-#endif /* !NO_HW_NURON */
-#endif /* !NO_HW */
+#endif /* !OPENSSL_NO_HW_NURON */
+#endif /* !OPENSSL_NO_HW */