Reduce header interdependencies, initially in engine.h (the rest of the
[openssl.git] / engines / e_atalla.c
index 3f7494c707d3d570a49751262f75d5b27c7eac78..82dae4586754cddce949b9e5850dc684b404ed29 100644 (file)
  */
 
 #include <stdio.h>
+#include <string.h>
 #include <openssl/crypto.h>
-#include "cryptlib.h"
+#include <openssl/buffer.h>
 #include <openssl/dso.h>
 #include <openssl/engine.h>
+#include <openssl/rsa.h>
+#include <openssl/dsa.h>
+#include <openssl/dh.h>
 
 #ifndef OPENSSL_NO_HW
 #ifndef OPENSSL_NO_HW_ATALLA
 #endif
 
 #define ATALLA_LIB_NAME "atalla engine"
-#include "hw_atalla_err.c"
+#include "e_atalla_err.c"
 
 static int atalla_destroy(ENGINE *e);
 static int atalla_init(ENGINE *e);
 static int atalla_finish(ENGINE *e);
-static int atalla_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)());
+static int atalla_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void));
 
 /* BIGNUM stuff */
 static int atalla_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
@@ -85,7 +89,7 @@ static int atalla_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
 
 #ifndef OPENSSL_NO_RSA
 /* RSA stuff */
-static int atalla_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa);
+static int atalla_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx);
 #endif
 /* This function is aliased to mod_exp (with the mont stuff dropped). */
 static int atalla_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
@@ -135,6 +139,7 @@ static RSA_METHOD atalla_rsa =
        0,
        NULL,
        NULL,
+       NULL,
        NULL
        };
 #endif
@@ -152,7 +157,9 @@ static DSA_METHOD atalla_dsa =
        NULL, /* init */
        NULL, /* finish */
        0, /* flags */
-       NULL /* app_data */
+       NULL, /* app_data */
+       NULL, /* dsa_paramgen */
+       NULL /* dsa_keygen */
        };
 #endif
 
@@ -167,6 +174,7 @@ static DH_METHOD atalla_dh =
        NULL,
        NULL,
        0,
+       NULL,
        NULL
        };
 #endif
@@ -242,6 +250,7 @@ static int bind_helper(ENGINE *e)
        return 1;
        }
 
+#ifdef OPENSSL_NO_DYNAMIC_ENGINE
 static ENGINE *engine_atalla(void)
        {
        ENGINE *ret = ENGINE_new();
@@ -264,6 +273,7 @@ void ENGINE_load_atalla(void)
        ENGINE_free(toadd);
        ERR_clear_error();
        }
+#endif
 
 /* This is a process-global DSO handle used for loading and unloading
  * the Atalla library. NB: This is only set (or unset) during an
@@ -399,7 +409,7 @@ static int atalla_finish(ENGINE *e)
        return 1;
        }
 
-static int atalla_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
+static int atalla_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void))
        {
        int initialised = ((atalla_dso == NULL) ? 0 : 1);
        switch(cmd)
@@ -495,9 +505,8 @@ err:
        }
 
 #ifndef OPENSSL_NO_RSA
-static int atalla_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
+static int atalla_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
        {
-       BN_CTX *ctx = NULL;
        int to_return = 0;
 
        if(!atalla_dso)
@@ -505,8 +514,6 @@ static int atalla_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
                ATALLAerr(ATALLA_F_ATALLA_RSA_MOD_EXP,ATALLA_R_NOT_LOADED);
                goto err;
                }
-       if((ctx = BN_CTX_new()) == NULL)
-               goto err;
        if(!rsa->d || !rsa->n)
                {
                ATALLAerr(ATALLA_F_ATALLA_RSA_MOD_EXP,ATALLA_R_MISSING_KEY_COMPONENTS);
@@ -514,8 +521,6 @@ static int atalla_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
                }
        to_return = atalla_mod_exp(r0, I, rsa->d, rsa->n, ctx);
 err:
-       if(ctx)
-               BN_CTX_free(ctx);
        return to_return;
        }
 #endif