1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */
2 /* SPDX-License-Identifier: Unlicense */
3 #include "tomcrypt_private.h"
4 
5 /**
6   @file crypt_find_hash_oid.c
7   Find a hash, Tom St Denis
8 */
9 
find_hash_oid(const unsigned long * ID,unsigned long IDlen)10 int find_hash_oid(const unsigned long *ID, unsigned long IDlen)
11 {
12    int x;
13    LTC_ARGCHK(ID != NULL);
14    LTC_MUTEX_LOCK(&ltc_hash_mutex);
15    for (x = 0; x < TAB_SIZE; x++) {
16        if (hash_descriptor[x] != NULL && hash_descriptor[x]->OIDlen == IDlen && !XMEMCMP(hash_descriptor[x]->OID, ID, sizeof(unsigned long) * IDlen)) {
17           LTC_MUTEX_UNLOCK(&ltc_hash_mutex);
18           return x;
19        }
20    }
21    LTC_MUTEX_UNLOCK(&ltc_hash_mutex);
22    return -1;
23 }
24