1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 ** prrng.h -- NSPR Random Number Generator
22 ** PR_GetRandomNoise() -- Get random noise from the host platform
25 ** PR_GetRandomNoise() provides, depending on platform, a random value.
26 ** The length of the random value is dependent on platform and the
27 ** platform's ability to provide a random value at that moment.
29 ** The intent of PR_GetRandomNoise() is to provide a "seed" value for a
30 ** another random number generator that may be suitable for
31 ** cryptographic operations. This implies that the random value
32 ** provided may not be, by itself, cryptographically secure. The value
33 ** generated by PR_GetRandomNoise() is at best, extremely difficult to
34 ** predict and is as non-deterministic as the underlying platfrom can
38 ** buf -- pointer to a caller supplied buffer to contain the
39 ** generated random number. buf must be at least as large as
40 ** is specified in the 'size' argument.
42 ** size -- the requested size of the generated random number
45 ** a random number provided in 'buf'.
48 ** PRSize value equal to the size of the random number actually
49 ** generated, or zero. The generated size may be less than the size
50 ** requested. A return value of zero means that PR_GetRandomNoise() is
51 ** not implemented on this platform, or there is no available noise
52 ** available to be returned at the time of the call.
55 ** Calls to PR_GetRandomNoise() may use a lot of CPU on some platforms.
56 ** Some platforms may block for up to a few seconds while they
57 ** accumulate some noise. Busy machines generate lots of noise, but
58 ** care is advised when using PR_GetRandomNoise() frequently in your
62 ** Parts of the model dependent implementation for PR_GetRandomNoise()
63 ** were taken in whole or part from code previously in Netscape's NSS
67 NSPR_API(PRSize
) PR_GetRandomNoise(
74 #endif /* prrng_h___ */