Mercurial > dropbear
comparison libtomcrypt/src/prngs/rng_make_prng.c @ 1478:3a933956437e coverity
update coverity
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 09 Feb 2018 23:49:22 +0800 |
parents | 6dba84798cd5 |
children |
comparison
equal
deleted
inserted
replaced
1439:8d24733026c5 | 1478:3a933956437e |
---|---|
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 | 10 |
13 /** | 11 #ifdef LTC_RNG_MAKE_PRNG |
12 /** | |
14 @file rng_make_prng.c | 13 @file rng_make_prng.c |
15 portable way to get secure random bits to feed a PRNG (Tom St Denis) | 14 portable way to get secure random bits to feed a PRNG (Tom St Denis) |
16 */ | 15 */ |
17 | 16 |
18 /** | 17 /** |
20 @param bits Number of bits of entropy desired (64 ... 1024) | 19 @param bits Number of bits of entropy desired (64 ... 1024) |
21 @param wprng Index of which PRNG to setup | 20 @param wprng Index of which PRNG to setup |
22 @param prng [out] PRNG state to initialize | 21 @param prng [out] PRNG state to initialize |
23 @param callback A pointer to a void function for when the RNG is slow, this can be NULL | 22 @param callback A pointer to a void function for when the RNG is slow, this can be NULL |
24 @return CRYPT_OK if successful | 23 @return CRYPT_OK if successful |
25 */ | 24 */ |
26 int rng_make_prng(int bits, int wprng, prng_state *prng, | 25 int rng_make_prng(int bits, int wprng, prng_state *prng, |
27 void (*callback)(void)) | 26 void (*callback)(void)) |
28 { | 27 { |
29 unsigned char buf[256]; | 28 unsigned char buf[256]; |
30 int err; | 29 int err; |
31 | 30 |
32 LTC_ARGCHK(prng != NULL); | 31 LTC_ARGCHK(prng != NULL); |
33 | 32 |
34 /* check parameter */ | 33 /* check parameter */ |
35 if ((err = prng_is_valid(wprng)) != CRYPT_OK) { | 34 if ((err = prng_is_valid(wprng)) != CRYPT_OK) { |
36 return err; | 35 return err; |
60 #ifdef LTC_CLEAN_STACK | 59 #ifdef LTC_CLEAN_STACK |
61 zeromem(buf, sizeof(buf)); | 60 zeromem(buf, sizeof(buf)); |
62 #endif | 61 #endif |
63 return CRYPT_OK; | 62 return CRYPT_OK; |
64 } | 63 } |
64 #endif /* #ifdef LTC_RNG_MAKE_PRNG */ | |
65 | 65 |
66 | 66 |
67 /* $Source$ */ | 67 /* ref: $Format:%D$ */ |
68 /* $Revision$ */ | 68 /* git commit: $Format:%H$ */ |
69 /* $Date$ */ | 69 /* commit time: $Format:%ai$ */ |