#include <openssl/crypto.h>
#include "cryptlib.h"
#include <openssl/dso.h>
-#include "engine_int.h"
#include <openssl/engine.h>
#ifndef OPENSSL_NO_HW
#include "vendor_defns/atalla.h"
#endif
-static int atalla_init(void);
-static int atalla_finish(void);
+static int atalla_init(ENGINE *e);
+static int atalla_finish(ENGINE *e);
/* BIGNUM stuff */
static int atalla_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
NULL
};
-/* Our ENGINE structure. */
-static ENGINE engine_atalla =
- {
- "atalla",
- "Atalla hardware engine support",
- &atalla_rsa,
- &atalla_dsa,
- &atalla_dh,
- NULL,
- atalla_mod_exp,
- NULL,
- atalla_init,
- atalla_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_atalla_id = "atalla";
+static const char *engine_atalla_name = "Atalla 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!!!) */
const RSA_METHOD *meth1;
const DSA_METHOD *meth2;
const DH_METHOD *meth3;
+ ENGINE *ret = ENGINE_new();
+ if(!ret)
+ return NULL;
+ if(!ENGINE_set_id(ret, engine_atalla_id) ||
+ !ENGINE_set_name(ret, engine_atalla_name) ||
+ !ENGINE_set_RSA(ret, &atalla_rsa) ||
+ !ENGINE_set_DSA(ret, &atalla_dsa) ||
+ !ENGINE_set_DH(ret, &atalla_dh) ||
+ !ENGINE_set_BN_mod_exp(ret, atalla_mod_exp) ||
+ !ENGINE_set_init_function(ret, atalla_init) ||
+ !ENGINE_set_finish_function(ret, atalla_finish))
+ {
+ ENGINE_free(ret);
+ return NULL;
+ }
/* We know that the "PKCS1_SSLeay()" functions hook properly
* to the atalla-specific mod_exp and mod_exp_crt so we use
meth3 = DH_OpenSSL();
atalla_dh.generate_key = meth3->generate_key;
atalla_dh.compute_key = meth3->compute_key;
- return &engine_atalla;
+ return ret;
}
/* This is a process-global DSO handle used for loading and unloading
static tfnASI_RSAPrivateKeyOpFn *p_Atalla_RSAPrivateKeyOpFn = NULL;
static tfnASI_GetPerformanceStatistics *p_Atalla_GetPerformanceStatistics = NULL;
+/* These are the static string constants for the DSO file name and the function
+ * symbol names to bind to. Regrettably, the DSO name on *nix appears to be
+ * "atasi.so" rather than something more consistent like "libatasi.so". At the
+ * time of writing, I'm not sure what the file name on win32 is but clearly
+ * native name translation is not possible (eg libatasi.so on *nix, and
+ * atasi.dll on win32). For the purposes of testing, I have created a symbollic
+ * link called "libatasi.so" so that we can use native name-translation - a
+ * better solution will be needed. */
+static const char *ATALLA_LIBNAME = "atasi";
+static const char *ATALLA_F1 = "ASI_GetHardwareConfig";
+static const char *ATALLA_F2 = "ASI_RSAPrivateKeyOpFn";
+static const char *ATALLA_F3 = "ASI_GetPerformanceStatistics";
+
/* (de)initialisation functions. */
-static int atalla_init(void)
+static int atalla_init(ENGINE *e)
{
tfnASI_GetHardwareConfig *p1;
tfnASI_RSAPrivateKeyOpFn *p2;
return 0;
}
-static int atalla_finish(void)
+static int atalla_finish(ENGINE *e)
{
if(atalla_dso == NULL)
{