1 // SPDX-License-Identifier: BSD-2-Clause
2 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
3  *
4  * LibTomCrypt is a library that provides various cryptographic
5  * algorithms in a highly modular and flexible manner.
6  *
7  * The library is free for all purposes without any express
8  * guarantee it works.
9  */
10 #include "tomcrypt_private.h"
11 
12 /**
13   @file crypt_unregister_hash.c
14   Unregister a hash, Tom St Denis
15 */
16 
17 /**
18   Unregister a hash from the descriptor table
19   @param hash   The hash descriptor to remove
20   @return CRYPT_OK on success
21 */
unregister_hash(const struct ltc_hash_descriptor * hash)22 int unregister_hash(const struct ltc_hash_descriptor *hash)
23 {
24    int x;
25 
26    LTC_ARGCHK(hash != NULL);
27 
28    /* is it already registered? */
29    LTC_MUTEX_LOCK(&ltc_hash_mutex);
30    for (x = 0; x < TAB_SIZE; x++) {
31        if (hash_descriptor[x] == hash) {
32           hash_descriptor[x] = NULL;
33           LTC_MUTEX_UNLOCK(&ltc_hash_mutex);
34           return CRYPT_OK;
35        }
36    }
37    LTC_MUTEX_UNLOCK(&ltc_hash_mutex);
38    return CRYPT_ERROR;
39 }
40 
41 /* ref:         $Format:%D$ */
42 /* git commit:  $Format:%H$ */
43 /* commit time: $Format:%ai$ */
44