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