OLD | NEW |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | 4 |
5 #ifdef FREEBL_NO_DEPEND | 5 #ifdef FREEBL_NO_DEPEND |
6 #include "stubs.h" | 6 #include "stubs.h" |
7 #endif | 7 #endif |
8 | 8 |
9 #include "seccomon.h" | 9 #include "seccomon.h" |
10 | 10 |
| 11 #ifndef XP_WIN |
11 static size_t rng_systemFromNoise(unsigned char *dest, size_t maxLen); | 12 static size_t rng_systemFromNoise(unsigned char *dest, size_t maxLen); |
| 13 #endif |
12 | 14 |
13 #if defined(XP_UNIX) || defined(XP_BEOS) | 15 #if defined(XP_UNIX) || defined(XP_BEOS) |
14 #include "unix_rand.c" | 16 #include "unix_rand.c" |
15 #endif | 17 #endif |
16 #ifdef XP_WIN | 18 #ifdef XP_WIN |
17 #include "win_rand.c" | 19 #include "win_rand.c" |
18 #endif | 20 #endif |
19 #ifdef XP_OS2 | 21 #ifdef XP_OS2 |
20 #include "os2_rand.c" | 22 #include "os2_rand.c" |
21 #endif | 23 #endif |
22 | 24 |
| 25 #ifndef XP_WIN |
23 /* | 26 /* |
24 * Normal RNG_SystemRNG() isn't available, use the system noise to collect | 27 * Normal RNG_SystemRNG() isn't available, use the system noise to collect |
25 * the required amount of entropy. | 28 * the required amount of entropy. |
26 */ | 29 */ |
27 static size_t | 30 static size_t |
28 rng_systemFromNoise(unsigned char *dest, size_t maxLen) | 31 rng_systemFromNoise(unsigned char *dest, size_t maxLen) |
29 { | 32 { |
30 size_t retBytes = maxLen; | 33 size_t retBytes = maxLen; |
31 | 34 |
32 while (maxLen) { | 35 while (maxLen) { |
33 size_t nbytes = RNG_GetNoise(dest, maxLen); | 36 size_t nbytes = RNG_GetNoise(dest, maxLen); |
34 | 37 |
35 PORT_Assert(nbytes != 0); | 38 PORT_Assert(nbytes != 0); |
36 | 39 |
37 dest += nbytes; | 40 dest += nbytes; |
38 maxLen -= nbytes; | 41 maxLen -= nbytes; |
39 | 42 |
40 /* some hw op to try to introduce more entropy into the next | 43 /* some hw op to try to introduce more entropy into the next |
41 * RNG_GetNoise call */ | 44 * RNG_GetNoise call */ |
42 rng_systemJitter(); | 45 rng_systemJitter(); |
43 } | 46 } |
44 return retBytes; | 47 return retBytes; |
45 } | 48 } |
46 | 49 #endif |
OLD | NEW |