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