comparison libtomcrypt/src/prngs/rng_get_bytes.c @ 1437:871b18fd7065 fuzz

merge from main (libtommath/libtomcrypt/curve25510-donna updates)
author Matt Johnston <matt@ucc.asn.au>
date Sat, 24 Jun 2017 22:51:45 +0800
parents f849a5ca2efc
children 6dba84798cd5
comparison
equal deleted inserted replaced
1432:41dca1e5ea34 1437:871b18fd7065
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 * 8 *
9 * Tom St Denis, [email protected], http://libtomcrypt.com 9 * Tom St Denis, [email protected], http://libtom.org
10 */ 10 */
11 #include "tomcrypt.h" 11 #include "tomcrypt.h"
12 12
13 /** 13 /**
14 @file rng_get_bytes.c 14 @file rng_get_bytes.c
15 portable way to get secure random bits to feed a PRNG (Tom St Denis) 15 portable way to get secure random bits to feed a PRNG (Tom St Denis)
16 */ 16 */
17 17
18 #ifdef DEVRANDOM 18 #ifdef LTC_DEVRANDOM
19 /* on *NIX read /dev/random */ 19 /* on *NIX read /dev/random */
20 static unsigned long rng_nix(unsigned char *buf, unsigned long len, 20 static unsigned long rng_nix(unsigned char *buf, unsigned long len,
21 void (*callback)(void)) 21 void (*callback)(void))
22 { 22 {
23 #ifdef LTC_NO_FILE 23 #ifdef LTC_NO_FILE
45 fclose(f); 45 fclose(f);
46 return x; 46 return x;
47 #endif /* LTC_NO_FILE */ 47 #endif /* LTC_NO_FILE */
48 } 48 }
49 49
50 #endif /* DEVRANDOM */ 50 #endif /* LTC_DEVRANDOM */
51 51
52 /* on ANSI C platforms with 100 < CLOCKS_PER_SEC < 10000 */ 52 /* on ANSI C platforms with 100 < CLOCKS_PER_SEC < 10000 */
53 #if defined(CLOCKS_PER_SEC) && !defined(WINCE) 53 #if defined(CLOCKS_PER_SEC) && !defined(WINCE)
54 54
55 #define ANSI_RNG 55 #define ANSI_RNG
129 { 129 {
130 unsigned long x; 130 unsigned long x;
131 131
132 LTC_ARGCHK(out != NULL); 132 LTC_ARGCHK(out != NULL);
133 133
134 #if defined(DEVRANDOM) 134 #if defined(LTC_DEVRANDOM)
135 x = rng_nix(out, outlen, callback); if (x != 0) { return x; } 135 x = rng_nix(out, outlen, callback); if (x != 0) { return x; }
136 #endif 136 #endif
137 #ifdef WIN32 137 #ifdef WIN32
138 x = rng_win32(out, outlen, callback); if (x != 0) { return x; } 138 x = rng_win32(out, outlen, callback); if (x != 0) { return x; }
139 #endif 139 #endif
141 x = rng_ansic(out, outlen, callback); if (x != 0) { return x; } 141 x = rng_ansic(out, outlen, callback); if (x != 0) { return x; }
142 #endif 142 #endif
143 return 0; 143 return 0;
144 } 144 }
145 145
146 /* $Source: /cvs/libtom/libtomcrypt/src/prngs/rng_get_bytes.c,v $ */ 146 /* $Source$ */
147 /* $Revision: 1.5 $ */ 147 /* $Revision$ */
148 /* $Date: 2006/12/06 02:01:29 $ */ 148 /* $Date$ */