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_find_hash_id.c
14   Find hash by ID, Tom St Denis
15 */
16 
17 /**
18    Find a hash by ID number
19    @param ID    The ID (not same as index) of the hash to find
20    @return >= 0 if found, -1 if not present
21 */
find_hash_id(unsigned char ID)22 int find_hash_id(unsigned char ID)
23 {
24    int x;
25    LTC_MUTEX_LOCK(&ltc_hash_mutex);
26    for (x = 0; x < TAB_SIZE; x++) {
27       if (hash_descriptor[x] && hash_descriptor[x]->ID == ID) {
28           LTC_MUTEX_UNLOCK(&ltc_hash_mutex);
29           return x;
30       }
31    }
32    LTC_MUTEX_UNLOCK(&ltc_hash_mutex);
33    return -1;
34 }
35 
36 /* ref:         $Format:%D$ */
37 /* git commit:  $Format:%H$ */
38 /* commit time: $Format:%ai$ */
39