Coverage Report

Created: 2024-11-21 07:03

/src/libtomcrypt/src/misc/crypt/crypt_find_hash.c
Line
Count
Source (jump to first uncovered line)
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.c
7
  Find a hash, Tom St Denis
8
*/
9
10
/**
11
   Find a registered hash by name
12
   @param name   The name of the hash to look for
13
   @return >= 0 if found, -1 if not present
14
*/
15
int find_hash(const char *name)
16
817
{
17
817
   int x;
18
817
   LTC_ARGCHK(name != NULL);
19
817
   LTC_MUTEX_LOCK(&ltc_hash_mutex);
20
6.17k
   for (x = 0; x < TAB_SIZE; x++) {
21
6.17k
       if (hash_descriptor[x].name != NULL && XSTRCMP(hash_descriptor[x].name, name) == 0) {
22
817
          LTC_MUTEX_UNLOCK(&ltc_hash_mutex);
23
817
          return x;
24
817
       }
25
6.17k
   }
26
0
   LTC_MUTEX_UNLOCK(&ltc_hash_mutex);
27
0
   return -1;
28
817
}