summaryrefslogtreecommitdiff
path: root/utils/tomcrypt/src/misc/crypt/crypt_cipher_is_valid.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils/tomcrypt/src/misc/crypt/crypt_cipher_is_valid.c')
-rw-r--r--utils/tomcrypt/src/misc/crypt/crypt_cipher_is_valid.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/utils/tomcrypt/src/misc/crypt/crypt_cipher_is_valid.c b/utils/tomcrypt/src/misc/crypt/crypt_cipher_is_valid.c
new file mode 100644
index 0000000000..2ba32bf5e8
--- /dev/null
+++ b/utils/tomcrypt/src/misc/crypt/crypt_cipher_is_valid.c
@@ -0,0 +1,34 @@
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_cipher_is_valid.c
13 Determine if cipher is valid, Tom St Denis
14*/
15
16/*
17 Test if a cipher index is valid
18 @param idx The index of the cipher to search for
19 @return CRYPT_OK if valid
20*/
21int cipher_is_valid(int idx)
22{
23 LTC_MUTEX_LOCK(&ltc_cipher_mutex);
24 if (idx < 0 || idx >= TAB_SIZE || cipher_descriptor[idx].name == NULL) {
25 LTC_MUTEX_UNLOCK(&ltc_cipher_mutex);
26 return CRYPT_INVALID_CIPHER;
27 }
28 LTC_MUTEX_UNLOCK(&ltc_cipher_mutex);
29 return CRYPT_OK;
30}
31
32/* ref: HEAD -> master, tag: v1.18.2 */
33/* git commit: 7e7eb695d581782f04b24dc444cbfde86af59853 */
34/* commit time: 2018-07-01 22:49:01 +0200 */