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