1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */
2 /* SPDX-License-Identifier: Unlicense */
3 #include "tomcrypt_private.h"
4 #include <stdarg.h>
5 
6 /**
7   @file crypt_fsa.c
8   LibTomCrypt FULL SPEED AHEAD!, Tom St Denis
9 */
10 
11 /* format is ltc_mp, cipher_desc, [cipher_desc], NULL, hash_desc, [hash_desc], NULL, prng_desc, [prng_desc], NULL */
crypt_fsa(void * mp,...)12 int crypt_fsa(void *mp, ...)
13 {
14    va_list  args;
15    void     *p;
16 
17    va_start(args, mp);
18    if (mp != NULL) {
19       XMEMCPY(&ltc_mp, mp, sizeof(ltc_mp));
20    }
21 
22    while ((p = va_arg(args, void*)) != NULL) {
23       if (register_cipher(p) == -1) {
24          va_end(args);
25          return CRYPT_INVALID_CIPHER;
26       }
27    }
28 
29    while ((p = va_arg(args, void*)) != NULL) {
30       if (register_hash(p) == -1) {
31          va_end(args);
32          return CRYPT_INVALID_HASH;
33       }
34    }
35 
36    while ((p = va_arg(args, void*)) != NULL) {
37       if (register_prng(p) == -1) {
38          va_end(args);
39          return CRYPT_INVALID_PRNG;
40       }
41    }
42 
43    va_end(args);
44    return CRYPT_OK;
45 }
46 
47