]> pd.if.org Git - zpackage/blob - libtomcrypt/src/misc/crypt/crypt_unregister_prng.c
commit files needed for zpm-fetchurl
[zpackage] / libtomcrypt / src / misc / crypt / crypt_unregister_prng.c
1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
2  *
3  * LibTomCrypt is a library that provides various cryptographic
4  * algorithms in a highly modular and flexible manner.
5  *
6  * The library is free for all purposes without any express
7  * guarantee it works.
8  */
9 #include "tomcrypt.h"
10
11 /**
12   @file crypt_unregister_prng.c
13   Unregister a PRNG, Tom St Denis
14 */
15
16 /**
17   Unregister a PRNG from the descriptor table
18   @param prng   The PRNG descriptor to remove
19   @return CRYPT_OK on success
20 */
21 int unregister_prng(const struct ltc_prng_descriptor *prng)
22 {
23    int x;
24
25    LTC_ARGCHK(prng != NULL);
26
27    /* is it already registered? */
28    LTC_MUTEX_LOCK(&ltc_prng_mutex);
29    for (x = 0; x < TAB_SIZE; x++) {
30        if (XMEMCMP(&prng_descriptor[x], prng, sizeof(struct ltc_prng_descriptor)) == 0) {
31           prng_descriptor[x].name = NULL;
32           LTC_MUTEX_UNLOCK(&ltc_prng_mutex);
33           return CRYPT_OK;
34        }
35    }
36    LTC_MUTEX_UNLOCK(&ltc_prng_mutex);
37    return CRYPT_ERROR;
38 }
39
40 /* ref:         $Format:%D$ */
41 /* git commit:  $Format:%H$ */
42 /* commit time: $Format:%ai$ */