1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
3 * LibTomCrypt is a library that provides various cryptographic
4 * algorithms in a highly modular and flexible manner.
6 * The library is free for all purposes without any express
9 * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
14 @file crypt_find_hash_any.c
15 Find a hash, Tom St Denis
19 Find a hash flexibly. First by name then if not present by digest size
20 @param name The name of the hash desired
21 @param digestlen The minimum length of the digest size (octets)
22 @return >= 0 if found, -1 if not present
23 */int find_hash_any(const char *name, int digestlen)
26 LTC_ARGCHK(name != NULL);
29 if (x != -1) return x;
31 LTC_MUTEX_LOCK(<c_hash_mutex);
34 for (x = 0; x < TAB_SIZE; x++) {
35 if (hash_descriptor[x].name == NULL) {
38 if ((int)hash_descriptor[x].hashsize >= digestlen && (int)hash_descriptor[x].hashsize < y) {
40 y = hash_descriptor[x].hashsize;
43 LTC_MUTEX_UNLOCK(<c_hash_mutex);
47 /* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_find_hash_any.c,v $ */
48 /* $Revision: 1.5 $ */
49 /* $Date: 2006/03/31 14:15:35 $ */