Mercurial > dropbear
comparison libtomcrypt/src/misc/crypt/crypt_find_cipher_any.c @ 1511:5916af64acd4 fuzz
merge from main
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 17 Feb 2018 19:29:51 +0800 |
parents | 6dba84798cd5 |
children |
comparison
equal
deleted
inserted
replaced
1457:32f990cc96b1 | 1511:5916af64acd4 |
---|---|
3 * LibTomCrypt is a library that provides various cryptographic | 3 * LibTomCrypt is a library that provides various cryptographic |
4 * algorithms in a highly modular and flexible manner. | 4 * algorithms in a highly modular and flexible manner. |
5 * | 5 * |
6 * The library is free for all purposes without any express | 6 * The library is free for all purposes without any express |
7 * guarantee it works. | 7 * guarantee it works. |
8 * | |
9 * Tom St Denis, [email protected], http://libtom.org | |
10 */ | 8 */ |
11 #include "tomcrypt.h" | 9 #include "tomcrypt.h" |
12 | 10 |
13 /** | 11 /** |
14 @file crypt_find_cipher_any.c | 12 @file crypt_find_cipher_any.c |
15 Find a cipher in the descriptor tables, Tom St Denis | 13 Find a cipher in the descriptor tables, Tom St Denis |
16 */ | 14 */ |
17 | 15 |
18 /** | 16 /** |
19 Find a cipher flexibly. First by name then if not present by block and key size | 17 Find a cipher flexibly. First by name then if not present by block and key size |
20 @param name The name of the cipher desired | 18 @param name The name of the cipher desired |
21 @param blocklen The minimum length of the block cipher desired (octets) | 19 @param blocklen The minimum length of the block cipher desired (octets) |
22 @param keylen The minimum length of the key size desired (octets) | 20 @param keylen The minimum length of the key size desired (octets) |
23 @return >= 0 if found, -1 if not present | 21 @return >= 0 if found, -1 if not present |
24 */ | 22 */ |
25 int find_cipher_any(const char *name, int blocklen, int keylen) | 23 int find_cipher_any(const char *name, int blocklen, int keylen) |
26 { | 24 { |
27 int x; | 25 int x; |
28 | 26 |
29 LTC_ARGCHK(name != NULL); | 27 if(name != NULL) { |
30 | 28 x = find_cipher(name); |
31 x = find_cipher(name); | 29 if (x != -1) return x; |
32 if (x != -1) return x; | 30 } |
33 | 31 |
34 LTC_MUTEX_LOCK(<c_cipher_mutex); | 32 LTC_MUTEX_LOCK(<c_cipher_mutex); |
35 for (x = 0; x < TAB_SIZE; x++) { | 33 for (x = 0; x < TAB_SIZE; x++) { |
36 if (cipher_descriptor[x].name == NULL) { | 34 if (cipher_descriptor[x].name == NULL) { |
37 continue; | 35 continue; |
43 } | 41 } |
44 LTC_MUTEX_UNLOCK(<c_cipher_mutex); | 42 LTC_MUTEX_UNLOCK(<c_cipher_mutex); |
45 return -1; | 43 return -1; |
46 } | 44 } |
47 | 45 |
48 /* $Source$ */ | 46 /* ref: $Format:%D$ */ |
49 /* $Revision$ */ | 47 /* git commit: $Format:%H$ */ |
50 /* $Date$ */ | 48 /* commit time: $Format:%ai$ */ |