X-Git-Url: https://git.openssl.org/gitweb/?a=blobdiff_plain;f=engines%2Fe_atalla.c;h=fabaa86a5234072d4fe26317fdc4f73818c0c26e;hb=5b73c3609bffc86f4eb0852da44a0c20a957db97;hp=6151c469024b0698f7c63878e08c109b469c7661;hpb=5572f482e797a5f6eee34ef7f04a8defde7bdecf;p=openssl.git diff --git a/engines/e_atalla.c b/engines/e_atalla.c index 6151c46902..fabaa86a52 100644 --- a/engines/e_atalla.c +++ b/engines/e_atalla.c @@ -57,10 +57,21 @@ */ #include +#include #include -#include "cryptlib.h" +#include #include #include +#ifndef OPENSSL_NO_RSA +#include +#endif +#ifndef OPENSSL_NO_DSA +#include +#endif +#ifndef OPENSSL_NO_DH +#include +#endif +#include #ifndef OPENSSL_NO_HW #ifndef OPENSSL_NO_HW_ATALLA @@ -72,12 +83,12 @@ #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,11 +96,11 @@ 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); -#endif +static int atalla_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx); /* 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, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); +#endif #ifndef OPENSSL_NO_DSA /* DSA stuff */ @@ -135,6 +146,7 @@ static RSA_METHOD atalla_rsa = 0, NULL, NULL, + NULL, NULL }; #endif @@ -152,7 +164,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 +181,7 @@ static DH_METHOD atalla_dh = NULL, NULL, 0, + NULL, NULL }; #endif @@ -242,6 +257,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 +280,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 @@ -373,6 +390,7 @@ static int atalla_init(ENGINE *e) err: if(atalla_dso) DSO_free(atalla_dso); + atalla_dso = NULL; p_Atalla_GetHardwareConfig = NULL; p_Atalla_RSAPrivateKeyOpFn = NULL; p_Atalla_GetPerformanceStatistics = NULL; @@ -399,7 +417,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 +513,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 +522,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 +529,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 @@ -556,12 +569,14 @@ static int atalla_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a, } #endif +#ifndef OPENSSL_NO_RSA /* 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, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx) { return atalla_mod_exp(r, a, p, m, ctx); } +#endif #ifndef OPENSSL_NO_DH /* This function is aliased to mod_exp (with the dh and mont dropped). */ @@ -575,7 +590,7 @@ static int atalla_mod_exp_dh(const DH *dh, BIGNUM *r, /* This stuff is needed if this ENGINE is being compiled into a self-contained * shared-library. */ -#ifdef ENGINE_DYNAMIC_SUPPORT +#ifndef OPENSSL_NO_DYNAMIC_ENGINE static int bind_fn(ENGINE *e, const char *id) { if(id && (strcmp(id, engine_atalla_id) != 0)) @@ -586,7 +601,7 @@ static int bind_fn(ENGINE *e, const char *id) } IMPLEMENT_DYNAMIC_CHECK_FN() IMPLEMENT_DYNAMIC_BIND_FN(bind_fn) -#endif /* ENGINE_DYNAMIC_SUPPORT */ +#endif /* OPENSSL_NO_DYNAMIC_ENGINE */ #endif /* !OPENSSL_NO_HW_ATALLA */ #endif /* !OPENSSL_NO_HW */