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_prng_is_valid.c
14   Determine if PRNG is valid, Tom St Denis
15 */
16 
17 /*
18    Test if a PRNG index is valid
19    @param idx   The index of the PRNG to search for
20    @return CRYPT_OK if valid
21 */
prng_is_valid(int idx)22 int prng_is_valid(int idx)
23 {
24    LTC_MUTEX_LOCK(&ltc_prng_mutex);
25    if (idx < 0 || idx >= TAB_SIZE || prng_descriptor[idx] == NULL) {
26       LTC_MUTEX_UNLOCK(&ltc_prng_mutex);
27       return CRYPT_INVALID_PRNG;
28    }
29    LTC_MUTEX_UNLOCK(&ltc_prng_mutex);
30    return CRYPT_OK;
31 }
32 
33 /* ref:         $Format:%D$ */
34 /* git commit:  $Format:%H$ */
35 /* commit time: $Format:%ai$ */
36