X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=engines%2Fe_cswift.c;h=b73126b0376bc928a7bf4b1109dd3f2c80370357;hp=1b4e4e876ecac0253d85a74b3a839efe8a8bd1f1;hb=3a87a9b9db07f8d3c6d9aa7f20e01f053007a703;hpb=5572f482e797a5f6eee34ef7f04a8defde7bdecf diff --git a/engines/e_cswift.c b/engines/e_cswift.c index 1b4e4e876e..b73126b037 100644 --- a/engines/e_cswift.c +++ b/engines/e_cswift.c @@ -57,10 +57,15 @@ */ #include +#include #include -#include "cryptlib.h" +#include #include #include +#include +#include +#include +#include #ifndef OPENSSL_NO_HW #ifndef OPENSSL_NO_HW_CSWIFT @@ -84,12 +89,14 @@ #endif #define CSWIFT_LIB_NAME "cswift engine" -#include "hw_cswift_err.c" +#include "e_cswift_err.c" + +#define DECIMAL_SIZE(type) ((sizeof(type)*8+2)/3+1) static int cswift_destroy(ENGINE *e); static int cswift_init(ENGINE *e); static int cswift_finish(ENGINE *e); -static int cswift_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)()); +static int cswift_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void)); /* BIGNUM stuff */ static int cswift_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, @@ -100,7 +107,7 @@ static int cswift_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, #ifndef OPENSSL_NO_RSA /* RSA stuff */ -static int cswift_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa); +static int cswift_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 cswift_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, @@ -151,6 +158,7 @@ static RSA_METHOD cswift_rsa = 0, NULL, NULL, + NULL, NULL }; #endif @@ -168,7 +176,9 @@ static DSA_METHOD cswift_dsa = NULL, /* init */ NULL, /* finish */ 0, /* flags */ - NULL /* app_data */ + NULL, /* app_data */ + NULL, /* dsa_paramgen */ + NULL /* dsa_keygen */ }; #endif @@ -183,6 +193,7 @@ static DH_METHOD cswift_dh = NULL, NULL, 0, + NULL, NULL }; #endif @@ -259,6 +270,7 @@ static int bind_helper(ENGINE *e) return 1; } +#ifdef OPENSSL_NO_DYNAMIC_ENGINE static ENGINE *engine_cswift(void) { ENGINE *ret = ENGINE_new(); @@ -281,6 +293,7 @@ void ENGINE_load_cswift(void) ENGINE_free(toadd); ERR_clear_error(); } +#endif /* This is a process-global DSO handle used for loading and unloading * the CryptoSwift library. NB: This is only set (or unset) during an @@ -430,7 +443,7 @@ static int cswift_finish(ENGINE *e) return 1; } -static int cswift_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)()) +static int cswift_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void)) { int initialised = ((cswift_dso == NULL) ? 0 : 1); switch(cmd) @@ -659,13 +672,10 @@ err: } #ifndef OPENSSL_NO_RSA -static int cswift_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa) +static int cswift_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx) { - BN_CTX *ctx; int to_return = 0; - if((ctx = BN_CTX_new()) == NULL) - goto err; if(!rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp) { CSWIFTerr(CSWIFT_F_CSWIFT_RSA_MOD_EXP,CSWIFT_R_MISSING_KEY_COMPONENTS); @@ -674,8 +684,6 @@ static int cswift_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa) to_return = cswift_mod_exp_crt(r0, I, rsa->p, rsa->q, rsa->dmp1, rsa->dmq1, rsa->iqmp, ctx); err: - if(ctx) - BN_CTX_free(ctx); return to_return; } #endif @@ -978,7 +986,7 @@ static int cswift_rand_status(void) /* 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_cswift_id) != 0)) @@ -989,7 +997,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_CSWIFT */ #endif /* !OPENSSL_NO_HW */