From: Richard Levitte Date: Thu, 5 Dec 2002 00:57:41 +0000 (+0000) Subject: If an application supports static locks, it MUST support dynamic locks as X-Git-Tag: OpenSSL-engine-0_9_6h~3 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=322f190a1867d692626eaf7e80905e16811cdb59;p=oweals%2Fopenssl.git If an application supports static locks, it MUST support dynamic locks as well to be able to use the CHIL engine. PR: 281 --- diff --git a/crypto/engine/engine.h b/crypto/engine/engine.h index f723ea9ee6..1efa88d020 100644 --- a/crypto/engine/engine.h +++ b/crypto/engine/engine.h @@ -431,6 +431,7 @@ void ERR_load_ENGINE_strings(void); #define ENGINE_R_INTERNAL_LIST_ERROR 110 #define ENGINE_R_INVALID_PADDING 137 #define ENGINE_R_KEY_TOO_LARGE 138 +#define ENGINE_R_LOCKING_MISSING 143 #define ENGINE_R_MISSING_KEY_COMPONENTS 111 #define ENGINE_R_MOD_EXP_CRT_FAILED 134 #define ENGINE_R_MOD_EXP_FAILED 131 diff --git a/crypto/engine/engine_err.c b/crypto/engine/engine_err.c index 395dca5a8d..14fdc8a6d3 100644 --- a/crypto/engine/engine_err.c +++ b/crypto/engine/engine_err.c @@ -1,6 +1,6 @@ /* crypto/engine/engine_err.c */ /* ==================================================================== - * Copyright (c) 1999 The OpenSSL Project. All rights reserved. + * Copyright (c) 1999-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -205,6 +205,7 @@ static ERR_STRING_DATA ENGINE_str_reasons[]= {ENGINE_R_INTERNAL_LIST_ERROR ,"internal list error"}, {ENGINE_R_INVALID_PADDING ,"invalid padding"}, {ENGINE_R_KEY_TOO_LARGE ,"key too large"}, +{ENGINE_R_LOCKING_MISSING ,"locking missing"}, {ENGINE_R_MISSING_KEY_COMPONENTS ,"missing key components"}, {ENGINE_R_MOD_EXP_CRT_FAILED ,"mod exp crt failed"}, {ENGINE_R_MOD_EXP_FAILED ,"mod exp failed"}, diff --git a/crypto/engine/hw_ncipher.c b/crypto/engine/hw_ncipher.c index d6834d7a34..6f2a9dedd5 100644 --- a/crypto/engine/hw_ncipher.c +++ b/crypto/engine/hw_ncipher.c @@ -435,15 +435,23 @@ static int hwcrhk_init() /* Check if the application decided to support dynamic locks, and if it does, use them. */ - if (disable_mutex_callbacks == 0 && - CRYPTO_get_dynlock_create_callback() != NULL && - CRYPTO_get_dynlock_lock_callback() != NULL && - CRYPTO_get_dynlock_destroy_callback() != NULL) + if (disable_mutex_callbacks == 0) { - hwcrhk_globals.mutex_init = hwcrhk_mutex_init; - hwcrhk_globals.mutex_acquire = hwcrhk_mutex_lock; - hwcrhk_globals.mutex_release = hwcrhk_mutex_unlock; - hwcrhk_globals.mutex_destroy = hwcrhk_mutex_destroy; + if (CRYPTO_get_dynlock_create_callback() != NULL && + CRYPTO_get_dynlock_lock_callback() != NULL && + CRYPTO_get_dynlock_destroy_callback() != NULL) + { + hwcrhk_globals.mutex_init = hwcrhk_mutex_init; + hwcrhk_globals.mutex_acquire = hwcrhk_mutex_lock; + hwcrhk_globals.mutex_release = hwcrhk_mutex_unlock; + hwcrhk_globals.mutex_destroy = hwcrhk_mutex_destroy; + } + else if (CRYPTO_get_locking_callback() != NULL) + { + ENGINEerr(ENGINE_F_HWCRHK_INIT,ENGINE_R_LOCKING_MISSING); + ERR_add_error_data(1,"You HAVE to add dynamic locking callbacks via CRYPTO_set_dynlock_{create,lock,destroy}_callback()"); + goto err; + } } /* Try and get a context - if not, we may have a DSO but no