This moves string constants out of vendor headers and into C files.
[openssl.git] / crypto / engine / hw_atalla.c
index 9cd9bac5d30a513f4dfa4f52bf0a27dbfc768e6e..37066eb8083074590f63265681a6afeeb08c87c2 100644 (file)
@@ -215,6 +215,19 @@ static tfnASI_GetHardwareConfig *p_Atalla_GetHardwareConfig = NULL;
 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)
        {
@@ -318,11 +331,12 @@ static int atalla_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
                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;
@@ -360,10 +374,7 @@ static int atalla_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
        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;
        }