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