diff options
Diffstat (limited to 'src/lib/libcrypto/engine')
-rw-r--r-- | src/lib/libcrypto/engine/hw_4758_cca.c | 29 | ||||
-rw-r--r-- | src/lib/libcrypto/engine/hw_aep.c | 28 | ||||
-rw-r--r-- | src/lib/libcrypto/engine/hw_atalla.c | 27 | ||||
-rw-r--r-- | src/lib/libcrypto/engine/hw_cswift.c | 43 | ||||
-rw-r--r-- | src/lib/libcrypto/engine/hw_ncipher.c | 33 | ||||
-rw-r--r-- | src/lib/libcrypto/engine/hw_nuron.c | 27 | ||||
-rw-r--r-- | src/lib/libcrypto/engine/hw_ubsec.c | 26 |
7 files changed, 169 insertions, 44 deletions
diff --git a/src/lib/libcrypto/engine/hw_4758_cca.c b/src/lib/libcrypto/engine/hw_4758_cca.c index 77d3d2ffdf..1053c52082 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 | } |
diff --git a/src/lib/libcrypto/engine/hw_aep.c b/src/lib/libcrypto/engine/hw_aep.c index cf4507cff1..8b8380a582 100644 --- a/src/lib/libcrypto/engine/hw_aep.c +++ b/src/lib/libcrypto/engine/hw_aep.c | |||
@@ -60,7 +60,7 @@ | |||
60 | #include <string.h> | 60 | #include <string.h> |
61 | 61 | ||
62 | #include <openssl/e_os2.h> | 62 | #include <openssl/e_os2.h> |
63 | #ifndef OPENSSL_SYS_MSDOS | 63 | #if !defined(OPENSSL_SYS_MSDOS) || defined(__DJGPP__) |
64 | #include <sys/types.h> | 64 | #include <sys/types.h> |
65 | #include <unistd.h> | 65 | #include <unistd.h> |
66 | #else | 66 | #else |
@@ -71,6 +71,7 @@ typedef int pid_t; | |||
71 | #include <openssl/crypto.h> | 71 | #include <openssl/crypto.h> |
72 | #include <openssl/dso.h> | 72 | #include <openssl/dso.h> |
73 | #include <openssl/engine.h> | 73 | #include <openssl/engine.h> |
74 | #include <openssl/buffer.h> | ||
74 | 75 | ||
75 | #ifndef OPENSSL_NO_HW | 76 | #ifndef OPENSSL_NO_HW |
76 | #ifndef OPENSSL_NO_HW_AEP | 77 | #ifndef OPENSSL_NO_HW_AEP |
@@ -363,7 +364,24 @@ static DSO *aep_dso = NULL; | |||
363 | /* These are the static string constants for the DSO file name and the function | 364 | /* These are the static string constants for the DSO file name and the function |
364 | * symbol names to bind to. | 365 | * symbol names to bind to. |
365 | */ | 366 | */ |
366 | static const char *AEP_LIBNAME = "aep"; | 367 | static const char *AEP_LIBNAME = NULL; |
368 | static const char *get_AEP_LIBNAME(void) | ||
369 | { | ||
370 | if(AEP_LIBNAME) | ||
371 | return AEP_LIBNAME; | ||
372 | return "aep"; | ||
373 | } | ||
374 | static void free_AEP_LIBNAME(void) | ||
375 | { | ||
376 | if(AEP_LIBNAME) | ||
377 | OPENSSL_free((void*)AEP_LIBNAME); | ||
378 | AEP_LIBNAME = NULL; | ||
379 | } | ||
380 | static long set_AEP_LIBNAME(const char *name) | ||
381 | { | ||
382 | free_AEP_LIBNAME(); | ||
383 | return ((AEP_LIBNAME = BUF_strdup(name)) != NULL ? 1 : 0); | ||
384 | } | ||
367 | 385 | ||
368 | static const char *AEP_F1 = "AEP_ModExp"; | 386 | static const char *AEP_F1 = "AEP_ModExp"; |
369 | static const char *AEP_F2 = "AEP_ModExpCrt"; | 387 | static const char *AEP_F2 = "AEP_ModExpCrt"; |
@@ -412,7 +430,7 @@ static int aep_init(ENGINE *e) | |||
412 | } | 430 | } |
413 | /* Attempt to load libaep.so. */ | 431 | /* Attempt to load libaep.so. */ |
414 | 432 | ||
415 | aep_dso = DSO_load(NULL, AEP_LIBNAME, NULL, 0); | 433 | aep_dso = DSO_load(NULL, get_AEP_LIBNAME(), NULL, 0); |
416 | 434 | ||
417 | if(aep_dso == NULL) | 435 | if(aep_dso == NULL) |
418 | { | 436 | { |
@@ -474,6 +492,7 @@ static int aep_init(ENGINE *e) | |||
474 | /* Destructor (complements the "ENGINE_aep()" constructor) */ | 492 | /* Destructor (complements the "ENGINE_aep()" constructor) */ |
475 | static int aep_destroy(ENGINE *e) | 493 | static int aep_destroy(ENGINE *e) |
476 | { | 494 | { |
495 | free_AEP_LIBNAME(); | ||
477 | ERR_unload_AEPHK_strings(); | 496 | ERR_unload_AEPHK_strings(); |
478 | return 1; | 497 | return 1; |
479 | } | 498 | } |
@@ -549,8 +568,7 @@ static int aep_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)()) | |||
549 | AEPHK_R_ALREADY_LOADED); | 568 | AEPHK_R_ALREADY_LOADED); |
550 | return 0; | 569 | return 0; |
551 | } | 570 | } |
552 | AEP_LIBNAME = (const char *)p; | 571 | return set_AEP_LIBNAME((const char*)p); |
553 | return 1; | ||
554 | default: | 572 | default: |
555 | break; | 573 | break; |
556 | } | 574 | } |
diff --git a/src/lib/libcrypto/engine/hw_atalla.c b/src/lib/libcrypto/engine/hw_atalla.c index 696cfcf156..6151c46902 100644 --- a/src/lib/libcrypto/engine/hw_atalla.c +++ b/src/lib/libcrypto/engine/hw_atalla.c | |||
@@ -286,8 +286,24 @@ static tfnASI_GetPerformanceStatistics *p_Atalla_GetPerformanceStatistics = NULL | |||
286 | * atasi.dll on win32). For the purposes of testing, I have created a symbollic | 286 | * atasi.dll on win32). For the purposes of testing, I have created a symbollic |
287 | * link called "libatasi.so" so that we can use native name-translation - a | 287 | * link called "libatasi.so" so that we can use native name-translation - a |
288 | * better solution will be needed. */ | 288 | * better solution will be needed. */ |
289 | static const char def_ATALLA_LIBNAME[] = "atasi"; | 289 | static const char *ATALLA_LIBNAME = NULL; |
290 | static const char *ATALLA_LIBNAME = def_ATALLA_LIBNAME; | 290 | static const char *get_ATALLA_LIBNAME(void) |
291 | { | ||
292 | if(ATALLA_LIBNAME) | ||
293 | return ATALLA_LIBNAME; | ||
294 | return "atasi"; | ||
295 | } | ||
296 | static void free_ATALLA_LIBNAME(void) | ||
297 | { | ||
298 | if(ATALLA_LIBNAME) | ||
299 | OPENSSL_free((void*)ATALLA_LIBNAME); | ||
300 | ATALLA_LIBNAME = NULL; | ||
301 | } | ||
302 | static long set_ATALLA_LIBNAME(const char *name) | ||
303 | { | ||
304 | free_ATALLA_LIBNAME(); | ||
305 | return (((ATALLA_LIBNAME = BUF_strdup(name)) != NULL) ? 1 : 0); | ||
306 | } | ||
291 | static const char *ATALLA_F1 = "ASI_GetHardwareConfig"; | 307 | static const char *ATALLA_F1 = "ASI_GetHardwareConfig"; |
292 | static const char *ATALLA_F2 = "ASI_RSAPrivateKeyOpFn"; | 308 | static const char *ATALLA_F2 = "ASI_RSAPrivateKeyOpFn"; |
293 | static const char *ATALLA_F3 = "ASI_GetPerformanceStatistics"; | 309 | static const char *ATALLA_F3 = "ASI_GetPerformanceStatistics"; |
@@ -295,6 +311,7 @@ static const char *ATALLA_F3 = "ASI_GetPerformanceStatistics"; | |||
295 | /* Destructor (complements the "ENGINE_atalla()" constructor) */ | 311 | /* Destructor (complements the "ENGINE_atalla()" constructor) */ |
296 | static int atalla_destroy(ENGINE *e) | 312 | static int atalla_destroy(ENGINE *e) |
297 | { | 313 | { |
314 | free_ATALLA_LIBNAME(); | ||
298 | /* Unload the atalla error strings so any error state including our | 315 | /* Unload the atalla error strings so any error state including our |
299 | * functs or reasons won't lead to a segfault (they simply get displayed | 316 | * functs or reasons won't lead to a segfault (they simply get displayed |
300 | * without corresponding string data because none will be found). */ | 317 | * without corresponding string data because none will be found). */ |
@@ -324,7 +341,7 @@ static int atalla_init(ENGINE *e) | |||
324 | * drivers really use - for now a symbollic link needs to be | 341 | * drivers really use - for now a symbollic link needs to be |
325 | * created on the host system from libatasi.so to atasi.so on | 342 | * created on the host system from libatasi.so to atasi.so on |
326 | * unix variants. */ | 343 | * unix variants. */ |
327 | atalla_dso = DSO_load(NULL, ATALLA_LIBNAME, NULL, 0); | 344 | atalla_dso = DSO_load(NULL, get_ATALLA_LIBNAME(), NULL, 0); |
328 | if(atalla_dso == NULL) | 345 | if(atalla_dso == NULL) |
329 | { | 346 | { |
330 | ATALLAerr(ATALLA_F_ATALLA_INIT,ATALLA_R_NOT_LOADED); | 347 | ATALLAerr(ATALLA_F_ATALLA_INIT,ATALLA_R_NOT_LOADED); |
@@ -364,6 +381,7 @@ err: | |||
364 | 381 | ||
365 | static int atalla_finish(ENGINE *e) | 382 | static int atalla_finish(ENGINE *e) |
366 | { | 383 | { |
384 | free_ATALLA_LIBNAME(); | ||
367 | if(atalla_dso == NULL) | 385 | if(atalla_dso == NULL) |
368 | { | 386 | { |
369 | ATALLAerr(ATALLA_F_ATALLA_FINISH,ATALLA_R_NOT_LOADED); | 387 | ATALLAerr(ATALLA_F_ATALLA_FINISH,ATALLA_R_NOT_LOADED); |
@@ -397,8 +415,7 @@ static int atalla_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)()) | |||
397 | ATALLAerr(ATALLA_F_ATALLA_CTRL,ATALLA_R_ALREADY_LOADED); | 415 | ATALLAerr(ATALLA_F_ATALLA_CTRL,ATALLA_R_ALREADY_LOADED); |
398 | return 0; | 416 | return 0; |
399 | } | 417 | } |
400 | ATALLA_LIBNAME = (const char *)p; | 418 | return set_ATALLA_LIBNAME((const char *)p); |
401 | return 1; | ||
402 | default: | 419 | default: |
403 | break; | 420 | break; |
404 | } | 421 | } |
diff --git a/src/lib/libcrypto/engine/hw_cswift.c b/src/lib/libcrypto/engine/hw_cswift.c index d8b380550f..f5c897bdbb 100644 --- a/src/lib/libcrypto/engine/hw_cswift.c +++ b/src/lib/libcrypto/engine/hw_cswift.c | |||
@@ -280,8 +280,24 @@ t_swSimpleRequest *p_CSwift_SimpleRequest = NULL; | |||
280 | t_swReleaseAccContext *p_CSwift_ReleaseAccContext = NULL; | 280 | t_swReleaseAccContext *p_CSwift_ReleaseAccContext = NULL; |
281 | 281 | ||
282 | /* Used in the DSO operations. */ | 282 | /* Used in the DSO operations. */ |
283 | static const char def_CSWIFT_LIBNAME[] = "swift"; | 283 | static const char *CSWIFT_LIBNAME = NULL; |
284 | static const char *CSWIFT_LIBNAME = def_CSWIFT_LIBNAME; | 284 | static const char *get_CSWIFT_LIBNAME(void) |
285 | { | ||
286 | if(CSWIFT_LIBNAME) | ||
287 | return CSWIFT_LIBNAME; | ||
288 | return "swift"; | ||
289 | } | ||
290 | static void free_CSWIFT_LIBNAME(void) | ||
291 | { | ||
292 | if(CSWIFT_LIBNAME) | ||
293 | OPENSSL_free((void*)CSWIFT_LIBNAME); | ||
294 | CSWIFT_LIBNAME = NULL; | ||
295 | } | ||
296 | static long set_CSWIFT_LIBNAME(const char *name) | ||
297 | { | ||
298 | free_CSWIFT_LIBNAME(); | ||
299 | return (((CSWIFT_LIBNAME = BUF_strdup(name)) != NULL) ? 1 : 0); | ||
300 | } | ||
285 | static const char *CSWIFT_F1 = "swAcquireAccContext"; | 301 | static const char *CSWIFT_F1 = "swAcquireAccContext"; |
286 | static const char *CSWIFT_F2 = "swAttachKeyParam"; | 302 | static const char *CSWIFT_F2 = "swAttachKeyParam"; |
287 | static const char *CSWIFT_F3 = "swSimpleRequest"; | 303 | static const char *CSWIFT_F3 = "swSimpleRequest"; |
@@ -313,6 +329,7 @@ static void release_context(SW_CONTEXT_HANDLE hac) | |||
313 | /* Destructor (complements the "ENGINE_cswift()" constructor) */ | 329 | /* Destructor (complements the "ENGINE_cswift()" constructor) */ |
314 | static int cswift_destroy(ENGINE *e) | 330 | static int cswift_destroy(ENGINE *e) |
315 | { | 331 | { |
332 | free_CSWIFT_LIBNAME(); | ||
316 | ERR_unload_CSWIFT_strings(); | 333 | ERR_unload_CSWIFT_strings(); |
317 | return 1; | 334 | return 1; |
318 | } | 335 | } |
@@ -332,7 +349,7 @@ static int cswift_init(ENGINE *e) | |||
332 | goto err; | 349 | goto err; |
333 | } | 350 | } |
334 | /* Attempt to load libswift.so/swift.dll/whatever. */ | 351 | /* Attempt to load libswift.so/swift.dll/whatever. */ |
335 | cswift_dso = DSO_load(NULL, CSWIFT_LIBNAME, NULL, 0); | 352 | cswift_dso = DSO_load(NULL, get_CSWIFT_LIBNAME(), NULL, 0); |
336 | if(cswift_dso == NULL) | 353 | if(cswift_dso == NULL) |
337 | { | 354 | { |
338 | CSWIFTerr(CSWIFT_F_CSWIFT_INIT,CSWIFT_R_NOT_LOADED); | 355 | CSWIFTerr(CSWIFT_F_CSWIFT_INIT,CSWIFT_R_NOT_LOADED); |
@@ -377,6 +394,7 @@ err: | |||
377 | 394 | ||
378 | static int cswift_finish(ENGINE *e) | 395 | static int cswift_finish(ENGINE *e) |
379 | { | 396 | { |
397 | free_CSWIFT_LIBNAME(); | ||
380 | if(cswift_dso == NULL) | 398 | if(cswift_dso == NULL) |
381 | { | 399 | { |
382 | CSWIFTerr(CSWIFT_F_CSWIFT_FINISH,CSWIFT_R_NOT_LOADED); | 400 | CSWIFTerr(CSWIFT_F_CSWIFT_FINISH,CSWIFT_R_NOT_LOADED); |
@@ -411,8 +429,7 @@ static int cswift_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)()) | |||
411 | CSWIFTerr(CSWIFT_F_CSWIFT_CTRL,CSWIFT_R_ALREADY_LOADED); | 429 | CSWIFTerr(CSWIFT_F_CSWIFT_CTRL,CSWIFT_R_ALREADY_LOADED); |
412 | return 0; | 430 | return 0; |
413 | } | 431 | } |
414 | CSWIFT_LIBNAME = (const char *)p; | 432 | return set_CSWIFT_LIBNAME((const char *)p); |
415 | return 1; | ||
416 | default: | 433 | default: |
417 | break; | 434 | break; |
418 | } | 435 | } |
@@ -484,7 +501,7 @@ static int cswift_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, | |||
484 | goto err; | 501 | goto err; |
485 | default: | 502 | default: |
486 | { | 503 | { |
487 | char tmpbuf[20]; | 504 | char tmpbuf[DECIMAL_SIZE(sw_status)+1]; |
488 | CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP,CSWIFT_R_REQUEST_FAILED); | 505 | CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP,CSWIFT_R_REQUEST_FAILED); |
489 | sprintf(tmpbuf, "%ld", sw_status); | 506 | sprintf(tmpbuf, "%ld", sw_status); |
490 | ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf); | 507 | ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf); |
@@ -501,7 +518,7 @@ static int cswift_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, | |||
501 | if((sw_status = p_CSwift_SimpleRequest(hac, SW_CMD_MODEXP, &arg, 1, | 518 | if((sw_status = p_CSwift_SimpleRequest(hac, SW_CMD_MODEXP, &arg, 1, |
502 | &res, 1)) != SW_OK) | 519 | &res, 1)) != SW_OK) |
503 | { | 520 | { |
504 | char tmpbuf[20]; | 521 | char tmpbuf[DECIMAL_SIZE(sw_status)+1]; |
505 | CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP,CSWIFT_R_REQUEST_FAILED); | 522 | CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP,CSWIFT_R_REQUEST_FAILED); |
506 | sprintf(tmpbuf, "%ld", sw_status); | 523 | sprintf(tmpbuf, "%ld", sw_status); |
507 | ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf); | 524 | ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf); |
@@ -591,7 +608,7 @@ static int cswift_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, | |||
591 | goto err; | 608 | goto err; |
592 | default: | 609 | default: |
593 | { | 610 | { |
594 | char tmpbuf[20]; | 611 | char tmpbuf[DECIMAL_SIZE(sw_status)+1]; |
595 | CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_REQUEST_FAILED); | 612 | CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_REQUEST_FAILED); |
596 | sprintf(tmpbuf, "%ld", sw_status); | 613 | sprintf(tmpbuf, "%ld", sw_status); |
597 | ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf); | 614 | ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf); |
@@ -608,7 +625,7 @@ static int cswift_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, | |||
608 | if((sw_status = p_CSwift_SimpleRequest(hac, SW_CMD_MODEXP_CRT, &arg, 1, | 625 | if((sw_status = p_CSwift_SimpleRequest(hac, SW_CMD_MODEXP_CRT, &arg, 1, |
609 | &res, 1)) != SW_OK) | 626 | &res, 1)) != SW_OK) |
610 | { | 627 | { |
611 | char tmpbuf[20]; | 628 | char tmpbuf[DECIMAL_SIZE(sw_status)+1]; |
612 | CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_REQUEST_FAILED); | 629 | CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_REQUEST_FAILED); |
613 | sprintf(tmpbuf, "%ld", sw_status); | 630 | sprintf(tmpbuf, "%ld", sw_status); |
614 | ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf); | 631 | ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf); |
@@ -723,7 +740,7 @@ static DSA_SIG *cswift_dsa_sign(const unsigned char *dgst, int dlen, DSA *dsa) | |||
723 | goto err; | 740 | goto err; |
724 | default: | 741 | default: |
725 | { | 742 | { |
726 | char tmpbuf[20]; | 743 | char tmpbuf[DECIMAL_SIZE(sw_status)+1]; |
727 | CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN,CSWIFT_R_REQUEST_FAILED); | 744 | CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN,CSWIFT_R_REQUEST_FAILED); |
728 | sprintf(tmpbuf, "%ld", sw_status); | 745 | sprintf(tmpbuf, "%ld", sw_status); |
729 | ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf); | 746 | ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf); |
@@ -741,7 +758,7 @@ static DSA_SIG *cswift_dsa_sign(const unsigned char *dgst, int dlen, DSA *dsa) | |||
741 | &res, 1); | 758 | &res, 1); |
742 | if(sw_status != SW_OK) | 759 | if(sw_status != SW_OK) |
743 | { | 760 | { |
744 | char tmpbuf[20]; | 761 | char tmpbuf[DECIMAL_SIZE(sw_status)+1]; |
745 | CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN,CSWIFT_R_REQUEST_FAILED); | 762 | CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN,CSWIFT_R_REQUEST_FAILED); |
746 | sprintf(tmpbuf, "%ld", sw_status); | 763 | sprintf(tmpbuf, "%ld", sw_status); |
747 | ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf); | 764 | ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf); |
@@ -835,7 +852,7 @@ static int cswift_dsa_verify(const unsigned char *dgst, int dgst_len, | |||
835 | goto err; | 852 | goto err; |
836 | default: | 853 | default: |
837 | { | 854 | { |
838 | char tmpbuf[20]; | 855 | char tmpbuf[DECIMAL_SIZE(sw_status)+1]; |
839 | CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY,CSWIFT_R_REQUEST_FAILED); | 856 | CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY,CSWIFT_R_REQUEST_FAILED); |
840 | sprintf(tmpbuf, "%ld", sw_status); | 857 | sprintf(tmpbuf, "%ld", sw_status); |
841 | ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf); | 858 | ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf); |
@@ -857,7 +874,7 @@ static int cswift_dsa_verify(const unsigned char *dgst, int dgst_len, | |||
857 | &res, 1); | 874 | &res, 1); |
858 | if(sw_status != SW_OK) | 875 | if(sw_status != SW_OK) |
859 | { | 876 | { |
860 | char tmpbuf[20]; | 877 | char tmpbuf[DECIMAL_SIZE(sw_status)+1]; |
861 | CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY,CSWIFT_R_REQUEST_FAILED); | 878 | CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY,CSWIFT_R_REQUEST_FAILED); |
862 | sprintf(tmpbuf, "%ld", sw_status); | 879 | sprintf(tmpbuf, "%ld", sw_status); |
863 | ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf); | 880 | ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf); |
diff --git a/src/lib/libcrypto/engine/hw_ncipher.c b/src/lib/libcrypto/engine/hw_ncipher.c index 4762a54e3d..a43d4360f2 100644 --- a/src/lib/libcrypto/engine/hw_ncipher.c +++ b/src/lib/libcrypto/engine/hw_ncipher.c | |||
@@ -59,9 +59,9 @@ | |||
59 | 59 | ||
60 | #include <stdio.h> | 60 | #include <stdio.h> |
61 | #include <string.h> | 61 | #include <string.h> |
62 | #include "cryptlib.h" | ||
62 | #include <openssl/crypto.h> | 63 | #include <openssl/crypto.h> |
63 | #include <openssl/pem.h> | 64 | #include <openssl/pem.h> |
64 | #include "cryptlib.h" | ||
65 | #include <openssl/dso.h> | 65 | #include <openssl/dso.h> |
66 | #include <openssl/engine.h> | 66 | #include <openssl/engine.h> |
67 | #include <openssl/ui.h> | 67 | #include <openssl/ui.h> |
@@ -109,11 +109,13 @@ static int hwcrhk_rsa_mod_exp(BIGNUM *r, const BIGNUM *I, RSA *rsa); | |||
109 | static int hwcrhk_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, | 109 | static int hwcrhk_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, |
110 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); | 110 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); |
111 | 111 | ||
112 | #ifndef OPENSSL_NO_DH | ||
112 | /* DH stuff */ | 113 | /* DH stuff */ |
113 | /* This function is alised to mod_exp (with the DH and mont dropped). */ | 114 | /* This function is alised to mod_exp (with the DH and mont dropped). */ |
114 | static int hwcrhk_mod_exp_dh(const DH *dh, BIGNUM *r, | 115 | static int hwcrhk_mod_exp_dh(const DH *dh, BIGNUM *r, |
115 | const BIGNUM *a, const BIGNUM *p, | 116 | const BIGNUM *a, const BIGNUM *p, |
116 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); | 117 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); |
118 | #endif | ||
117 | 119 | ||
118 | /* RAND stuff */ | 120 | /* RAND stuff */ |
119 | static int hwcrhk_rand_bytes(unsigned char *buf, int num); | 121 | static int hwcrhk_rand_bytes(unsigned char *buf, int num); |
@@ -422,8 +424,24 @@ static HWCryptoHook_RSAUnloadKey_t *p_hwcrhk_RSAUnloadKey = NULL; | |||
422 | static HWCryptoHook_ModExpCRT_t *p_hwcrhk_ModExpCRT = NULL; | 424 | static HWCryptoHook_ModExpCRT_t *p_hwcrhk_ModExpCRT = NULL; |
423 | 425 | ||
424 | /* Used in the DSO operations. */ | 426 | /* Used in the DSO operations. */ |
425 | static const char def_HWCRHK_LIBNAME[] = "nfhwcrhk"; | 427 | static const char *HWCRHK_LIBNAME = NULL; |
426 | static const char *HWCRHK_LIBNAME = def_HWCRHK_LIBNAME; | 428 | static void free_HWCRHK_LIBNAME(void) |
429 | { | ||
430 | if(HWCRHK_LIBNAME) | ||
431 | OPENSSL_free((void*)HWCRHK_LIBNAME); | ||
432 | HWCRHK_LIBNAME = NULL; | ||
433 | } | ||
434 | static const char *get_HWCRHK_LIBNAME(void) | ||
435 | { | ||
436 | if(HWCRHK_LIBNAME) | ||
437 | return HWCRHK_LIBNAME; | ||
438 | return "nfhwcrhk"; | ||
439 | } | ||
440 | static long set_HWCRHK_LIBNAME(const char *name) | ||
441 | { | ||
442 | free_HWCRHK_LIBNAME(); | ||
443 | return (((HWCRHK_LIBNAME = BUF_strdup(name)) != NULL) ? 1 : 0); | ||
444 | } | ||
427 | static const char *n_hwcrhk_Init = "HWCryptoHook_Init"; | 445 | static const char *n_hwcrhk_Init = "HWCryptoHook_Init"; |
428 | static const char *n_hwcrhk_Finish = "HWCryptoHook_Finish"; | 446 | static const char *n_hwcrhk_Finish = "HWCryptoHook_Finish"; |
429 | static const char *n_hwcrhk_ModExp = "HWCryptoHook_ModExp"; | 447 | static const char *n_hwcrhk_ModExp = "HWCryptoHook_ModExp"; |
@@ -469,6 +487,7 @@ static void release_context(HWCryptoHook_ContextHandle hac) | |||
469 | /* Destructor (complements the "ENGINE_ncipher()" constructor) */ | 487 | /* Destructor (complements the "ENGINE_ncipher()" constructor) */ |
470 | static int hwcrhk_destroy(ENGINE *e) | 488 | static int hwcrhk_destroy(ENGINE *e) |
471 | { | 489 | { |
490 | free_HWCRHK_LIBNAME(); | ||
472 | ERR_unload_HWCRHK_strings(); | 491 | ERR_unload_HWCRHK_strings(); |
473 | return 1; | 492 | return 1; |
474 | } | 493 | } |
@@ -494,7 +513,7 @@ static int hwcrhk_init(ENGINE *e) | |||
494 | goto err; | 513 | goto err; |
495 | } | 514 | } |
496 | /* Attempt to load libnfhwcrhk.so/nfhwcrhk.dll/whatever. */ | 515 | /* Attempt to load libnfhwcrhk.so/nfhwcrhk.dll/whatever. */ |
497 | hwcrhk_dso = DSO_load(NULL, HWCRHK_LIBNAME, NULL, 0); | 516 | hwcrhk_dso = DSO_load(NULL, get_HWCRHK_LIBNAME(), NULL, 0); |
498 | if(hwcrhk_dso == NULL) | 517 | if(hwcrhk_dso == NULL) |
499 | { | 518 | { |
500 | HWCRHKerr(HWCRHK_F_HWCRHK_INIT,HWCRHK_R_DSO_FAILURE); | 519 | HWCRHKerr(HWCRHK_F_HWCRHK_INIT,HWCRHK_R_DSO_FAILURE); |
@@ -586,6 +605,7 @@ err: | |||
586 | static int hwcrhk_finish(ENGINE *e) | 605 | static int hwcrhk_finish(ENGINE *e) |
587 | { | 606 | { |
588 | int to_return = 1; | 607 | int to_return = 1; |
608 | free_HWCRHK_LIBNAME(); | ||
589 | if(hwcrhk_dso == NULL) | 609 | if(hwcrhk_dso == NULL) |
590 | { | 610 | { |
591 | HWCRHKerr(HWCRHK_F_HWCRHK_FINISH,HWCRHK_R_NOT_LOADED); | 611 | HWCRHKerr(HWCRHK_F_HWCRHK_FINISH,HWCRHK_R_NOT_LOADED); |
@@ -634,8 +654,7 @@ static int hwcrhk_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)()) | |||
634 | HWCRHKerr(HWCRHK_F_HWCRHK_CTRL,ERR_R_PASSED_NULL_PARAMETER); | 654 | HWCRHKerr(HWCRHK_F_HWCRHK_CTRL,ERR_R_PASSED_NULL_PARAMETER); |
635 | return 0; | 655 | return 0; |
636 | } | 656 | } |
637 | HWCRHK_LIBNAME = (const char *)p; | 657 | return set_HWCRHK_LIBNAME((const char *)p); |
638 | return 1; | ||
639 | case ENGINE_CTRL_SET_LOGSTREAM: | 658 | case ENGINE_CTRL_SET_LOGSTREAM: |
640 | { | 659 | { |
641 | BIO *bio = (BIO *)p; | 660 | BIO *bio = (BIO *)p; |
@@ -1040,6 +1059,7 @@ static int hwcrhk_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, | |||
1040 | return hwcrhk_mod_exp(r, a, p, m, ctx); | 1059 | return hwcrhk_mod_exp(r, a, p, m, ctx); |
1041 | } | 1060 | } |
1042 | 1061 | ||
1062 | #ifndef OPENSSL_NO_DH | ||
1043 | /* This function is aliased to mod_exp (with the dh and mont dropped). */ | 1063 | /* This function is aliased to mod_exp (with the dh and mont dropped). */ |
1044 | static int hwcrhk_mod_exp_dh(const DH *dh, BIGNUM *r, | 1064 | static int hwcrhk_mod_exp_dh(const DH *dh, BIGNUM *r, |
1045 | const BIGNUM *a, const BIGNUM *p, | 1065 | const BIGNUM *a, const BIGNUM *p, |
@@ -1047,6 +1067,7 @@ static int hwcrhk_mod_exp_dh(const DH *dh, BIGNUM *r, | |||
1047 | { | 1067 | { |
1048 | return hwcrhk_mod_exp(r, a, p, m, ctx); | 1068 | return hwcrhk_mod_exp(r, a, p, m, ctx); |
1049 | } | 1069 | } |
1070 | #endif | ||
1050 | 1071 | ||
1051 | /* Random bytes are good */ | 1072 | /* Random bytes are good */ |
1052 | static int hwcrhk_rand_bytes(unsigned char *buf, int num) | 1073 | static int hwcrhk_rand_bytes(unsigned char *buf, int num) |
diff --git a/src/lib/libcrypto/engine/hw_nuron.c b/src/lib/libcrypto/engine/hw_nuron.c index 2672012154..130b6d8b40 100644 --- a/src/lib/libcrypto/engine/hw_nuron.c +++ b/src/lib/libcrypto/engine/hw_nuron.c | |||
@@ -69,8 +69,24 @@ | |||
69 | #define NURON_LIB_NAME "nuron engine" | 69 | #define NURON_LIB_NAME "nuron engine" |
70 | #include "hw_nuron_err.c" | 70 | #include "hw_nuron_err.c" |
71 | 71 | ||
72 | static const char def_NURON_LIBNAME[] = "nuronssl"; | 72 | static const char *NURON_LIBNAME = NULL; |
73 | static const char *NURON_LIBNAME = def_NURON_LIBNAME; | 73 | static const char *get_NURON_LIBNAME(void) |
74 | { | ||
75 | if(NURON_LIBNAME) | ||
76 | return NURON_LIBNAME; | ||
77 | return "nuronssl"; | ||
78 | } | ||
79 | static void free_NURON_LIBNAME(void) | ||
80 | { | ||
81 | if(NURON_LIBNAME) | ||
82 | OPENSSL_free((void*)NURON_LIBNAME); | ||
83 | NURON_LIBNAME = NULL; | ||
84 | } | ||
85 | static long set_NURON_LIBNAME(const char *name) | ||
86 | { | ||
87 | free_NURON_LIBNAME(); | ||
88 | return (((NURON_LIBNAME = BUF_strdup(name)) != NULL) ? 1 : 0); | ||
89 | } | ||
74 | static const char *NURON_F1 = "nuron_mod_exp"; | 90 | static const char *NURON_F1 = "nuron_mod_exp"; |
75 | 91 | ||
76 | /* The definitions for control commands specific to this engine */ | 92 | /* The definitions for control commands specific to this engine */ |
@@ -90,6 +106,7 @@ static DSO *pvDSOHandle = NULL; | |||
90 | 106 | ||
91 | static int nuron_destroy(ENGINE *e) | 107 | static int nuron_destroy(ENGINE *e) |
92 | { | 108 | { |
109 | free_NURON_LIBNAME(); | ||
93 | ERR_unload_NURON_strings(); | 110 | ERR_unload_NURON_strings(); |
94 | return 1; | 111 | return 1; |
95 | } | 112 | } |
@@ -102,7 +119,7 @@ static int nuron_init(ENGINE *e) | |||
102 | return 0; | 119 | return 0; |
103 | } | 120 | } |
104 | 121 | ||
105 | pvDSOHandle = DSO_load(NULL, NURON_LIBNAME, NULL, | 122 | pvDSOHandle = DSO_load(NULL, get_NURON_LIBNAME(), NULL, |
106 | DSO_FLAG_NAME_TRANSLATION_EXT_ONLY); | 123 | DSO_FLAG_NAME_TRANSLATION_EXT_ONLY); |
107 | if(!pvDSOHandle) | 124 | if(!pvDSOHandle) |
108 | { | 125 | { |
@@ -122,6 +139,7 @@ static int nuron_init(ENGINE *e) | |||
122 | 139 | ||
123 | static int nuron_finish(ENGINE *e) | 140 | static int nuron_finish(ENGINE *e) |
124 | { | 141 | { |
142 | free_NURON_LIBNAME(); | ||
125 | if(pvDSOHandle == NULL) | 143 | if(pvDSOHandle == NULL) |
126 | { | 144 | { |
127 | NURONerr(NURON_F_NURON_FINISH,NURON_R_NOT_LOADED); | 145 | NURONerr(NURON_F_NURON_FINISH,NURON_R_NOT_LOADED); |
@@ -153,8 +171,7 @@ static int nuron_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)()) | |||
153 | NURONerr(NURON_F_NURON_CTRL,NURON_R_ALREADY_LOADED); | 171 | NURONerr(NURON_F_NURON_CTRL,NURON_R_ALREADY_LOADED); |
154 | return 0; | 172 | return 0; |
155 | } | 173 | } |
156 | NURON_LIBNAME = (const char *)p; | 174 | return set_NURON_LIBNAME((const char *)p); |
157 | return 1; | ||
158 | default: | 175 | default: |
159 | break; | 176 | break; |
160 | } | 177 | } |
diff --git a/src/lib/libcrypto/engine/hw_ubsec.c b/src/lib/libcrypto/engine/hw_ubsec.c index 743c06043c..63397f868c 100644 --- a/src/lib/libcrypto/engine/hw_ubsec.c +++ b/src/lib/libcrypto/engine/hw_ubsec.c | |||
@@ -304,7 +304,24 @@ static int max_key_len = 1024; /* ??? */ | |||
304 | * symbol names to bind to. | 304 | * symbol names to bind to. |
305 | */ | 305 | */ |
306 | 306 | ||
307 | static const char *UBSEC_LIBNAME = "ubsec"; | 307 | static const char *UBSEC_LIBNAME = NULL; |
308 | static const char *get_UBSEC_LIBNAME(void) | ||
309 | { | ||
310 | if(UBSEC_LIBNAME) | ||
311 | return UBSEC_LIBNAME; | ||
312 | return "ubsec"; | ||
313 | } | ||
314 | static void free_UBSEC_LIBNAME(void) | ||
315 | { | ||
316 | if(UBSEC_LIBNAME) | ||
317 | OPENSSL_free((void*)UBSEC_LIBNAME); | ||
318 | UBSEC_LIBNAME = NULL; | ||
319 | } | ||
320 | static long set_UBSEC_LIBNAME(const char *name) | ||
321 | { | ||
322 | free_UBSEC_LIBNAME(); | ||
323 | return (((UBSEC_LIBNAME = BUF_strdup(name)) != NULL) ? 1 : 0); | ||
324 | } | ||
308 | static const char *UBSEC_F1 = "ubsec_bytes_to_bits"; | 325 | static const char *UBSEC_F1 = "ubsec_bytes_to_bits"; |
309 | static const char *UBSEC_F2 = "ubsec_bits_to_bytes"; | 326 | static const char *UBSEC_F2 = "ubsec_bits_to_bytes"; |
310 | static const char *UBSEC_F3 = "ubsec_open"; | 327 | static const char *UBSEC_F3 = "ubsec_open"; |
@@ -328,6 +345,7 @@ static const char *UBSEC_F13 = "ubsec_max_key_len_ioctl"; | |||
328 | /* Destructor (complements the "ENGINE_ubsec()" constructor) */ | 345 | /* Destructor (complements the "ENGINE_ubsec()" constructor) */ |
329 | static int ubsec_destroy(ENGINE *e) | 346 | static int ubsec_destroy(ENGINE *e) |
330 | { | 347 | { |
348 | free_UBSEC_LIBNAME(); | ||
331 | ERR_unload_UBSEC_strings(); | 349 | ERR_unload_UBSEC_strings(); |
332 | return 1; | 350 | return 1; |
333 | } | 351 | } |
@@ -364,7 +382,7 @@ static int ubsec_init(ENGINE *e) | |||
364 | /* | 382 | /* |
365 | * Attempt to load libubsec.so/ubsec.dll/whatever. | 383 | * Attempt to load libubsec.so/ubsec.dll/whatever. |
366 | */ | 384 | */ |
367 | ubsec_dso = DSO_load(NULL, UBSEC_LIBNAME, NULL, 0); | 385 | ubsec_dso = DSO_load(NULL, get_UBSEC_LIBNAME(), NULL, 0); |
368 | if(ubsec_dso == NULL) | 386 | if(ubsec_dso == NULL) |
369 | { | 387 | { |
370 | UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_DSO_FAILURE); | 388 | UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_DSO_FAILURE); |
@@ -459,6 +477,7 @@ err: | |||
459 | 477 | ||
460 | static int ubsec_finish(ENGINE *e) | 478 | static int ubsec_finish(ENGINE *e) |
461 | { | 479 | { |
480 | free_UBSEC_LIBNAME(); | ||
462 | if(ubsec_dso == NULL) | 481 | if(ubsec_dso == NULL) |
463 | { | 482 | { |
464 | UBSECerr(UBSEC_F_UBSEC_FINISH, UBSEC_R_NOT_LOADED); | 483 | 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)()) | |||
508 | UBSECerr(UBSEC_F_UBSEC_CTRL,UBSEC_R_ALREADY_LOADED); | 527 | UBSECerr(UBSEC_F_UBSEC_CTRL,UBSEC_R_ALREADY_LOADED); |
509 | return 0; | 528 | return 0; |
510 | } | 529 | } |
511 | UBSEC_LIBNAME = (const char *)p; | 530 | return set_UBSEC_LIBNAME((const char *)p); |
512 | return 1; | ||
513 | default: | 531 | default: |
514 | break; | 532 | break; |
515 | } | 533 | } |