If an application supports static locks, it MUST support dynamic locks as
authorRichard Levitte <levitte@openssl.org>
Thu, 5 Dec 2002 00:57:41 +0000 (00:57 +0000)
committerRichard Levitte <levitte@openssl.org>
Thu, 5 Dec 2002 00:57:41 +0000 (00:57 +0000)
well to be able to use the CHIL engine.
PR: 281

crypto/engine/engine.h
crypto/engine/engine_err.c
crypto/engine/hw_ncipher.c

index f723ea9ee682ffe64fe1c1c982ae96a8cfb2e811..1efa88d0209e6c8f4b1dd6db373b810eac84ec1b 100644 (file)
@@ -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
index 395dca5a8dc165678680f91244af33a50e18ef3f..14fdc8a6d331ea794181c0edee05722938e92ef8 100644 (file)
@@ -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"},
index d6834d7a3439269632d80a11ad2e6ca1c7439eb6..6f2a9dedd5c664f39159dc008c2720e046d15ccb 100644 (file)
@@ -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