X-Git-Url: https://git.openssl.org/gitweb/?a=blobdiff_plain;f=crypto%2Fengine%2Fhw_ubsec.c;h=ed8401ec162655ed0948b1caa4ae1efa08fe4a50;hb=ba8fb52183e6fad60125c9afe85566e86daf2aae;hp=743c06043c72a9ee647379fc34d51d59d45f418a;hpb=db0a1efcc99cfdb47a655d179134ff32b0dc7628;p=openssl.git diff --git a/crypto/engine/hw_ubsec.c b/crypto/engine/hw_ubsec.c index 743c06043c..ed8401ec16 100644 --- a/crypto/engine/hw_ubsec.c +++ b/crypto/engine/hw_ubsec.c @@ -93,7 +93,7 @@ static int ubsec_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa); static int ubsec_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); #ifndef OPENSSL_NO_DSA -#if NOT_USED +#ifdef NOT_USED static int ubsec_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont); @@ -113,7 +113,7 @@ static int ubsec_dh_compute_key(unsigned char *key,const BIGNUM *pub_key,DH *dh) static int ubsec_dh_generate_key(DH *dh); #endif -#if NOT_USED +#ifdef NOT_USED static int ubsec_rand_bytes(unsigned char *buf, int num); static int ubsec_rand_status(void); #endif @@ -304,7 +304,24 @@ static int max_key_len = 1024; /* ??? */ * symbol names to bind to. */ -static const char *UBSEC_LIBNAME = "ubsec"; +static const char *UBSEC_LIBNAME = NULL; +static const char *get_UBSEC_LIBNAME(void) + { + if(UBSEC_LIBNAME) + return UBSEC_LIBNAME; + return "ubsec"; + } +static void free_UBSEC_LIBNAME(void) + { + if(UBSEC_LIBNAME) + OPENSSL_free((void*)UBSEC_LIBNAME); + UBSEC_LIBNAME = NULL; + } +static long set_UBSEC_LIBNAME(const char *name) + { + free_UBSEC_LIBNAME(); + return (((UBSEC_LIBNAME = BUF_strdup(name)) != NULL) ? 1 : 0); + } static const char *UBSEC_F1 = "ubsec_bytes_to_bits"; static const char *UBSEC_F2 = "ubsec_bits_to_bytes"; static const char *UBSEC_F3 = "ubsec_open"; @@ -328,6 +345,7 @@ static const char *UBSEC_F13 = "ubsec_max_key_len_ioctl"; /* Destructor (complements the "ENGINE_ubsec()" constructor) */ static int ubsec_destroy(ENGINE *e) { + free_UBSEC_LIBNAME(); ERR_unload_UBSEC_strings(); return 1; } @@ -364,7 +382,7 @@ static int ubsec_init(ENGINE *e) /* * Attempt to load libubsec.so/ubsec.dll/whatever. */ - ubsec_dso = DSO_load(NULL, UBSEC_LIBNAME, NULL, 0); + ubsec_dso = DSO_load(NULL, get_UBSEC_LIBNAME(), NULL, 0); if(ubsec_dso == NULL) { UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_DSO_FAILURE); @@ -459,6 +477,7 @@ err: static int ubsec_finish(ENGINE *e) { + free_UBSEC_LIBNAME(); if(ubsec_dso == NULL) { UBSECerr(UBSEC_F_UBSEC_FINISH, UBSEC_R_NOT_LOADED); @@ -508,8 +527,7 @@ static int ubsec_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)()) UBSECerr(UBSEC_F_UBSEC_CTRL,UBSEC_R_ALREADY_LOADED); return 0; } - UBSEC_LIBNAME = (const char *)p; - return 1; + return set_UBSEC_LIBNAME((const char *)p); default: break; } @@ -645,7 +663,7 @@ static int ubsec_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, } #ifndef OPENSSL_NO_DSA -#if NOT_USED +#ifdef NOT_USED static int ubsec_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont) @@ -969,7 +987,7 @@ err: } #endif -#if NOT_USED +#ifdef NOT_USED static int ubsec_rand_bytes(unsigned char * buf, int num) {