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_oid.c
14   Find a hash, Tom St Denis
15 */
16 
find_hash_oid(const unsigned long * ID,unsigned long IDlen)17 int find_hash_oid(const unsigned long *ID, unsigned long IDlen)
18 {
19    int x;
20    LTC_ARGCHK(ID != NULL);
21    LTC_MUTEX_LOCK(&ltc_hash_mutex);
22    for (x = 0; x < TAB_SIZE; x++) {
23        if (hash_descriptor[x] != NULL && hash_descriptor[x]->OIDlen == IDlen && !XMEMCMP(hash_descriptor[x]->OID, ID, sizeof(unsigned long) * IDlen)) {
24           LTC_MUTEX_UNLOCK(&ltc_hash_mutex);
25           return x;
26        }
27    }
28    LTC_MUTEX_UNLOCK(&ltc_hash_mutex);
29    return -1;
30 }
31 
32 /* ref:         $Format:%D$ */
33 /* git commit:  $Format:%H$ */
34 /* commit time: $Format:%ai$ */
35