nsprpub/pr/include/prrng.h

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

michael@0 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6
michael@0 7 /*
michael@0 8 ** prrng.h -- NSPR Random Number Generator
michael@0 9 **
michael@0 10 **
michael@0 11 ** lth. 29-Oct-1999.
michael@0 12 */
michael@0 13
michael@0 14 #ifndef prrng_h___
michael@0 15 #define prrng_h___
michael@0 16
michael@0 17 #include "prtypes.h"
michael@0 18
michael@0 19 PR_BEGIN_EXTERN_C
michael@0 20
michael@0 21 /*
michael@0 22 ** PR_GetRandomNoise() -- Get random noise from the host platform
michael@0 23 **
michael@0 24 ** Description:
michael@0 25 ** PR_GetRandomNoise() provides, depending on platform, a random value.
michael@0 26 ** The length of the random value is dependent on platform and the
michael@0 27 ** platform's ability to provide a random value at that moment.
michael@0 28 **
michael@0 29 ** The intent of PR_GetRandomNoise() is to provide a "seed" value for a
michael@0 30 ** another random number generator that may be suitable for
michael@0 31 ** cryptographic operations. This implies that the random value
michael@0 32 ** provided may not be, by itself, cryptographically secure. The value
michael@0 33 ** generated by PR_GetRandomNoise() is at best, extremely difficult to
michael@0 34 ** predict and is as non-deterministic as the underlying platfrom can
michael@0 35 ** provide.
michael@0 36 **
michael@0 37 ** Inputs:
michael@0 38 ** buf -- pointer to a caller supplied buffer to contain the
michael@0 39 ** generated random number. buf must be at least as large as
michael@0 40 ** is specified in the 'size' argument.
michael@0 41 **
michael@0 42 ** size -- the requested size of the generated random number
michael@0 43 **
michael@0 44 ** Outputs:
michael@0 45 ** a random number provided in 'buf'.
michael@0 46 **
michael@0 47 ** Returns:
michael@0 48 ** PRSize value equal to the size of the random number actually
michael@0 49 ** generated, or zero. The generated size may be less than the size
michael@0 50 ** requested. A return value of zero means that PR_GetRandomNoise() is
michael@0 51 ** not implemented on this platform, or there is no available noise
michael@0 52 ** available to be returned at the time of the call.
michael@0 53 **
michael@0 54 ** Restrictions:
michael@0 55 ** Calls to PR_GetRandomNoise() may use a lot of CPU on some platforms.
michael@0 56 ** Some platforms may block for up to a few seconds while they
michael@0 57 ** accumulate some noise. Busy machines generate lots of noise, but
michael@0 58 ** care is advised when using PR_GetRandomNoise() frequently in your
michael@0 59 ** application.
michael@0 60 **
michael@0 61 ** History:
michael@0 62 ** Parts of the model dependent implementation for PR_GetRandomNoise()
michael@0 63 ** were taken in whole or part from code previously in Netscape's NSS
michael@0 64 ** component.
michael@0 65 **
michael@0 66 */
michael@0 67 NSPR_API(PRSize) PR_GetRandomNoise(
michael@0 68 void *buf,
michael@0 69 PRSize size
michael@0 70 );
michael@0 71
michael@0 72 PR_END_EXTERN_C
michael@0 73
michael@0 74 #endif /* prrng_h___ */
michael@0 75 /* end prrng.h */

mercurial