michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifdef FREEBL_NO_DEPEND michael@0: #include "stubs.h" michael@0: #endif michael@0: michael@0: #include "seccomon.h" michael@0: michael@0: #ifndef XP_WIN michael@0: static size_t rng_systemFromNoise(unsigned char *dest, size_t maxLen); michael@0: #endif michael@0: michael@0: #if defined(XP_UNIX) || defined(XP_BEOS) michael@0: #include "unix_rand.c" michael@0: #endif michael@0: #ifdef XP_WIN michael@0: #include "win_rand.c" michael@0: #endif michael@0: #ifdef XP_OS2 michael@0: #include "os2_rand.c" michael@0: #endif michael@0: michael@0: #ifndef XP_WIN michael@0: /* michael@0: * Normal RNG_SystemRNG() isn't available, use the system noise to collect michael@0: * the required amount of entropy. michael@0: */ michael@0: static size_t michael@0: rng_systemFromNoise(unsigned char *dest, size_t maxLen) michael@0: { michael@0: size_t retBytes = maxLen; michael@0: michael@0: while (maxLen) { michael@0: size_t nbytes = RNG_GetNoise(dest, maxLen); michael@0: michael@0: PORT_Assert(nbytes != 0); michael@0: michael@0: dest += nbytes; michael@0: maxLen -= nbytes; michael@0: michael@0: /* some hw op to try to introduce more entropy into the next michael@0: * RNG_GetNoise call */ michael@0: rng_systemJitter(); michael@0: } michael@0: return retBytes; michael@0: } michael@0: #endif