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_prng.c
14   Unregister a PRNG, Tom St Denis
15 */
16 
17 /**
18   Unregister a PRNG from the descriptor table
19   @param prng   The PRNG descriptor to remove
20   @return CRYPT_OK on success
21 */
unregister_prng(const struct ltc_prng_descriptor * prng)22 int unregister_prng(const struct ltc_prng_descriptor *prng)
23 {
24    int x;
25 
26    LTC_ARGCHK(prng != NULL);
27 
28    /* is it already registered? */
29    LTC_MUTEX_LOCK(&ltc_prng_mutex);
30    for (x = 0; x < TAB_SIZE; x++) {
31        if (prng_descriptor[x] == prng) {
32           prng_descriptor[x] = NULL;
33           LTC_MUTEX_UNLOCK(&ltc_prng_mutex);
34           return CRYPT_OK;
35        }
36    }
37    LTC_MUTEX_UNLOCK(&ltc_prng_mutex);
38    return CRYPT_ERROR;
39 }
40 
41 /* ref:         $Format:%D$ */
42 /* git commit:  $Format:%H$ */
43 /* commit time: $Format:%ai$ */
44