1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */
2 /* SPDX-License-Identifier: Unlicense */
3 #include "tomcrypt_private.h"
4 
5 /**
6   @file crypt_find_prng.c
7   Find a PRNG, Tom St Denis
8 */
9 
10 /**
11    Find a registered PRNG by name
12    @param name   The name of the PRNG to look for
13    @return >= 0 if found, -1 if not present
14 */
find_prng(const char * name)15 int find_prng(const char *name)
16 {
17    int x;
18    LTC_ARGCHK(name != NULL);
19    LTC_MUTEX_LOCK(&ltc_prng_mutex);
20    for (x = 0; x < TAB_SIZE; x++) {
21        if ((prng_descriptor[x].name != NULL) && XSTRCMP(prng_descriptor[x].name, name) == 0) {
22           LTC_MUTEX_UNLOCK(&ltc_prng_mutex);
23           return x;
24        }
25    }
26    LTC_MUTEX_UNLOCK(&ltc_prng_mutex);
27    return -1;
28 }
29 
30