diff options
Diffstat (limited to '')
-rw-r--r-- | src/lib/libcrypto/engine/hw_4758_cca.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/lib/libcrypto/engine/hw_4758_cca.c b/src/lib/libcrypto/engine/hw_4758_cca.c index 0ca2f920dc..f404b1a3b8 100644 --- a/src/lib/libcrypto/engine/hw_4758_cca.c +++ b/src/lib/libcrypto/engine/hw_4758_cca.c | |||
@@ -124,8 +124,24 @@ static F_RANDOMNUMBERGENERATE randomNumberGenerate; | |||
124 | 124 | ||
125 | /* static variables */ | 125 | /* static variables */ |
126 | /*------------------*/ | 126 | /*------------------*/ |
127 | static const char def_CCA4758_LIB_NAME[] = CCA_LIB_NAME; | 127 | static const char *CCA4758_LIB_NAME = NULL; |
128 | static const char *CCA4758_LIB_NAME = def_CCA4758_LIB_NAME; | 128 | static const char *get_CCA4758_LIB_NAME(void) |
129 | { | ||
130 | if(CCA4758_LIB_NAME) | ||
131 | return CCA4758_LIB_NAME; | ||
132 | return CCA_LIB_NAME; | ||
133 | } | ||
134 | static void free_CCA4758_LIB_NAME(void) | ||
135 | { | ||
136 | if(CCA4758_LIB_NAME) | ||
137 | OPENSSL_free((void*)CCA4758_LIB_NAME); | ||
138 | CCA4758_LIB_NAME = NULL; | ||
139 | } | ||
140 | static long set_CCA4758_LIB_NAME(const char *name) | ||
141 | { | ||
142 | free_CCA4758_LIB_NAME(); | ||
143 | return (((CCA4758_LIB_NAME = BUF_strdup(name)) != NULL) ? 1 : 0); | ||
144 | } | ||
129 | #ifndef OPENSSL_NO_RSA | 145 | #ifndef OPENSSL_NO_RSA |
130 | static const char* n_keyRecordRead = CSNDKRR; | 146 | static const char* n_keyRecordRead = CSNDKRR; |
131 | static const char* n_digitalSignatureGenerate = CSNDDSG; | 147 | static const char* n_digitalSignatureGenerate = CSNDDSG; |
@@ -232,6 +248,7 @@ void ENGINE_load_4758cca(void) | |||
232 | static int ibm_4758_cca_destroy(ENGINE *e) | 248 | static int ibm_4758_cca_destroy(ENGINE *e) |
233 | { | 249 | { |
234 | ERR_unload_CCA4758_strings(); | 250 | ERR_unload_CCA4758_strings(); |
251 | free_CCA4758_LIB_NAME(); | ||
235 | return 1; | 252 | return 1; |
236 | } | 253 | } |
237 | 254 | ||
@@ -243,7 +260,7 @@ static int ibm_4758_cca_init(ENGINE *e) | |||
243 | goto err; | 260 | goto err; |
244 | } | 261 | } |
245 | 262 | ||
246 | dso = DSO_load(NULL, CCA4758_LIB_NAME , NULL, 0); | 263 | dso = DSO_load(NULL, get_CCA4758_LIB_NAME(), NULL, 0); |
247 | if(!dso) | 264 | if(!dso) |
248 | { | 265 | { |
249 | CCA4758err(CCA4758_F_IBM_4758_CCA_INIT,CCA4758_R_DSO_FAILURE); | 266 | CCA4758err(CCA4758_F_IBM_4758_CCA_INIT,CCA4758_R_DSO_FAILURE); |
@@ -299,7 +316,8 @@ err: | |||
299 | 316 | ||
300 | static int ibm_4758_cca_finish(ENGINE *e) | 317 | static int ibm_4758_cca_finish(ENGINE *e) |
301 | { | 318 | { |
302 | if(dso) | 319 | free_CCA4758_LIB_NAME(); |
320 | if(!dso) | ||
303 | { | 321 | { |
304 | CCA4758err(CCA4758_F_IBM_4758_CCA_FINISH, | 322 | CCA4758err(CCA4758_F_IBM_4758_CCA_FINISH, |
305 | CCA4758_R_NOT_LOADED); | 323 | CCA4758_R_NOT_LOADED); |
@@ -340,8 +358,7 @@ static int ibm_4758_cca_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)()) | |||
340 | CCA4758_R_ALREADY_LOADED); | 358 | CCA4758_R_ALREADY_LOADED); |
341 | return 0; | 359 | return 0; |
342 | } | 360 | } |
343 | CCA4758_LIB_NAME = (const char *)p; | 361 | return set_CCA4758_LIB_NAME((const char *)p); |
344 | return 1; | ||
345 | default: | 362 | default: |
346 | break; | 363 | break; |
347 | } | 364 | } |