static void do_dynlock(int mode, int type, const char *file, int line) { if (dynlock_lock_callback != NULL) { struct CRYPTO_dynlock_value *pointer = CRYPTO_get_dynlock_value(type); OPENSSL_assert(pointer != NULL); dynlock_lock_callback(mode, pointer, file, line); CRYPTO_destroy_dynlockid(type); } }
/* Destroy the context allocated with pkcs11_new() */ int pkcs11_destroy(ENGINE_CTX *ctx) { if (ctx) { pkcs11_finish(ctx); destroy_pin(ctx); OPENSSL_free(ctx->module); OPENSSL_free(ctx->init_args); #if OPENSSL_VERSION_NUMBER >= 0x10100004L CRYPTO_THREAD_lock_free(ctx->rwlock); #else if (ctx->rwlock) CRYPTO_destroy_dynlockid(ctx->rwlock); #endif OPENSSL_free(ctx); } return 1; }
void CRYPTO_lock(int mode, int type, const char *file, int line) { #ifdef LOCK_DEBUG { CRYPTO_THREADID id; char *rw_text,*operation_text; if (mode & CRYPTO_LOCK) operation_text="lock "; else if (mode & CRYPTO_UNLOCK) operation_text="unlock"; else operation_text="ERROR "; if (mode & CRYPTO_READ) rw_text="r"; else if (mode & CRYPTO_WRITE) rw_text="w"; else rw_text="ERROR"; CRYPTO_THREADID_current(&id); TINYCLR_SSL_FPRINTF(OPENSSL_TYPE__FILE_STDERR,"lock:%08lx:(%s)%s %-18s %s:%d\n", CRYPTO_THREADID_hash(&id), rw_text, operation_text, CRYPTO_get_lock_name(type), file, line); } #endif if (type < 0) { if (dynlock_lock_callback != NULL) { struct CRYPTO_dynlock_value *pointer = CRYPTO_get_dynlock_value(type); OPENSSL_assert(pointer != NULL); dynlock_lock_callback(mode, pointer, file, line); CRYPTO_destroy_dynlockid(type); } } else if (locking_callback != NULL) locking_callback(mode,type,file,line); }
void CRYPTO_lock(int mode, int type, const char *file, int line) { #ifdef LOCK_DEBUG { char *rw_text,*operation_text; if (mode & CRYPTO_LOCK) operation_text="lock "; else if (mode & CRYPTO_UNLOCK) operation_text="unlock"; else operation_text="ERROR "; if (mode & CRYPTO_READ) rw_text="r"; else if (mode & CRYPTO_WRITE) rw_text="w"; else rw_text="ERROR"; fprintf(stderr,"lock:%08lx:(%s)%s %-18s %s:%d\n", CRYPTO_thread_id(), rw_text, operation_text, CRYPTO_get_lock_name(type), file, line); } #endif if (type < 0) { if (dynlock_lock_callback != NULL) { struct CRYPTO_dynlock_value *pointer = CRYPTO_get_dynlock_value(type); OPENSSL_assert(pointer != NULL); dynlock_lock_callback(mode, pointer, file, line); CRYPTO_destroy_dynlockid(type); } } else if (locking_callback != NULL) locking_callback(mode,type,file,line); }
void pkcs11_release_slot(PKCS11_CTX * ctx, PKCS11_SLOT * slot) { PKCS11_SLOT_private *priv = PRIVSLOT(slot); if (priv) { if (priv->prev_pin) { OPENSSL_cleanse(priv->prev_pin, strlen(priv->prev_pin)); OPENSSL_free(priv->prev_pin); } CRYPTO_destroy_dynlockid(priv->lockid); CRYPTOKI_call(ctx, C_CloseAllSessions(priv->id)); } OPENSSL_free(slot->_private); OPENSSL_free(slot->description); OPENSSL_free(slot->manufacturer); if (slot->token) { pkcs11_destroy_token(slot->token); OPENSSL_free(slot->token); } memset(slot, 0, sizeof(*slot)); }
int pkcs11_finish(ENGINE_CTX *ctx) { if (ctx) { if (ctx->slot_list) { PKCS11_release_all_slots(ctx->pkcs11_ctx, ctx->slot_list, ctx->slot_count); } if (ctx->pkcs11_ctx) { PKCS11_CTX_unload(ctx->pkcs11_ctx); PKCS11_CTX_free(ctx->pkcs11_ctx); } destroy_pin(ctx); OPENSSL_free(ctx->module); OPENSSL_free(ctx->init_args); #if OPENSSL_VERSION_NUMBER >= 0x10100004L CRYPTO_THREAD_lock_free(ctx->rwlock); #else if (ctx->rwlock) CRYPTO_destroy_dynlockid(ctx->rwlock); #endif OPENSSL_free(ctx); } return 1; }
static void hwcrhk_mutex_destroy(HWCryptoHook_Mutex *mt) { CRYPTO_destroy_dynlockid(mt->lockid); }
void CRYPTO_THREAD_lock_free(int i) { if(i) CRYPTO_destroy_dynlockid(i); }