#include "engine_int.h"
#include <openssl/engine.h>
-#ifndef NO_HW
-#ifndef NO_HW_ATALLA
+#ifndef OPENSSL_NO_HW
+#ifndef OPENSSL_NO_HW_ATALLA
#ifdef FLAT_INC
#include "atalla.h"
#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,
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)
{
goto err;
}
/* Prepare the params */
+ BN_CTX_start(ctx);
modulus = BN_CTX_get(ctx);
exponent = BN_CTX_get(ctx);
argument = BN_CTX_get(ctx);
result = BN_CTX_get(ctx);
- if(!modulus || !exponent || !argument || !result)
+ if (!result)
{
ENGINEerr(ENGINE_F_ATALLA_MOD_EXP,ENGINE_R_BN_CTX_FULL);
goto err;
BN_bin2bn((unsigned char *)result->d, numbytes, r);
to_return = 1;
err:
- if(modulus) ctx->tos--;
- if(exponent) ctx->tos--;
- if(argument) ctx->tos--;
- if(result) ctx->tos--;
+ BN_CTX_end(ctx);
return to_return;
}
return atalla_mod_exp(r, a, p, m, ctx);
}
-#endif /* !NO_HW_ATALLA */
-#endif /* !NO_HW */
+#endif /* !OPENSSL_NO_HW_ATALLA */
+#endif /* !OPENSSL_NO_HW */