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 #include <stdarg.h>
12 
13 /**
14   @file crypt_fsa.c
15   LibTomCrypt FULL SPEED AHEAD!, Tom St Denis
16 */
17 
18 /* format is ltc_mp, cipher_desc, [cipher_desc], NULL, hash_desc, [hash_desc], NULL, prng_desc, [prng_desc], NULL */
crypt_fsa(void * mp,...)19 int crypt_fsa(void *mp, ...)
20 {
21    va_list  args;
22    void     *p;
23 
24    va_start(args, mp);
25    if (mp != NULL) {
26       XMEMCPY(&ltc_mp, mp, sizeof(ltc_mp));
27    }
28 
29    while ((p = va_arg(args, void*)) != NULL) {
30       if (register_cipher(p) == -1) {
31          va_end(args);
32          return CRYPT_INVALID_CIPHER;
33       }
34    }
35 
36    while ((p = va_arg(args, void*)) != NULL) {
37       if (register_hash(p) == -1) {
38          va_end(args);
39          return CRYPT_INVALID_HASH;
40       }
41    }
42 
43    while ((p = va_arg(args, void*)) != NULL) {
44       if (register_prng(p) == -1) {
45          va_end(args);
46          return CRYPT_INVALID_PRNG;
47       }
48    }
49 
50    va_end(args);
51    return CRYPT_OK;
52 }
53 
54 
55 /* ref:         $Format:%D$ */
56 /* git commit:  $Format:%H$ */
57 /* commit time: $Format:%ai$ */
58