]> pd.if.org Git - zpackage/blob - libtomcrypt/src/misc/crypt/crypt_hash_is_valid.c
commit files needed for zpm-fetchurl
[zpackage] / libtomcrypt / src / misc / crypt / crypt_hash_is_valid.c
1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
2  *
3  * LibTomCrypt is a library that provides various cryptographic
4  * algorithms in a highly modular and flexible manner.
5  *
6  * The library is free for all purposes without any express
7  * guarantee it works.
8  */
9 #include "tomcrypt.h"
10
11 /**
12   @file crypt_hash_is_valid.c
13   Determine if hash is valid, Tom St Denis
14 */
15
16 /*
17    Test if a hash index is valid
18    @param idx   The index of the hash to search for
19    @return CRYPT_OK if valid
20 */
21 int hash_is_valid(int idx)
22 {
23    LTC_MUTEX_LOCK(&ltc_hash_mutex);
24    if (idx < 0 || idx >= TAB_SIZE || hash_descriptor[idx].name == NULL) {
25       LTC_MUTEX_UNLOCK(&ltc_hash_mutex);
26       return CRYPT_INVALID_HASH;
27    }
28    LTC_MUTEX_UNLOCK(&ltc_hash_mutex);
29    return CRYPT_OK;
30 }
31
32 /* ref:         $Format:%D$ */
33 /* git commit:  $Format:%H$ */
34 /* commit time: $Format:%ai$ */