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