| 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 static size_t rng_systemFromNoise(unsigned char *dest, size_t maxLen); | |
| 12 | |
| 13 #if defined(XP_UNIX) || defined(XP_BEOS) | |
| 14 #include "unix_rand.c" | |
| 15 #endif | |
| 16 #ifdef XP_WIN | |
| 17 #include "win_rand.c" | |
| 18 #endif | |
| 19 #ifdef XP_OS2 | |
| 20 #include "os2_rand.c" | |
| 21 #endif | |
| 22 | |
| 23 /* | |
| 24 * Normal RNG_SystemRNG() isn't available, use the system noise to collect | |
| 25 * the required amount of entropy. | |
| 26 */ | |
| 27 static size_t | |
| 28 rng_systemFromNoise(unsigned char *dest, size_t maxLen) | |
| 29 { | |
| 30 size_t retBytes = maxLen; | |
| 31 | |
| 32 while (maxLen) { | |
| 33 size_t nbytes = RNG_GetNoise(dest, maxLen); | |
| 34 | |
| 35 PORT_Assert(nbytes != 0); | |
| 36 | |
| 37 dest += nbytes; | |
| 38 maxLen -= nbytes; | |
| 39 | |
| 40 /* some hw op to try to introduce more entropy into the next | |
| 41 * RNG_GetNoise call */ | |
| 42 rng_systemJitter(); | |
| 43 } | |
| 44 return retBytes; | |
| 45 } | |
| 46 | |
| OLD | NEW |