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