]> pd.if.org Git - zpackage/blob - libtomcrypt/src/misc/crypt/crypt_find_cipher_id.c
commit files needed for zpm-fetchurl
[zpackage] / libtomcrypt / src / misc / crypt / crypt_find_cipher_id.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_find_cipher_id.c
13   Find cipher by ID, Tom St Denis
14 */
15
16 /**
17    Find a cipher by ID number
18    @param ID    The ID (not same as index) of the cipher to find
19    @return >= 0 if found, -1 if not present
20 */
21 int find_cipher_id(unsigned char ID)
22 {
23    int x;
24    LTC_MUTEX_LOCK(&ltc_cipher_mutex);
25    for (x = 0; x < TAB_SIZE; x++) {
26        if (cipher_descriptor[x].ID == ID) {
27           x = (cipher_descriptor[x].name == NULL) ? -1 : x;
28           LTC_MUTEX_UNLOCK(&ltc_cipher_mutex);
29           return x;
30        }
31    }
32    LTC_MUTEX_UNLOCK(&ltc_cipher_mutex);
33    return -1;
34 }
35
36 /* ref:         $Format:%D$ */
37 /* git commit:  $Format:%H$ */
38 /* commit time: $Format:%ai$ */