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