nsprpub/pr/include/prrng.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/nsprpub/pr/include/prrng.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,75 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +
    1.10 +/*
    1.11 +** prrng.h -- NSPR Random Number Generator
    1.12 +** 
    1.13 +**
    1.14 +** lth. 29-Oct-1999.
    1.15 +*/
    1.16 +
    1.17 +#ifndef prrng_h___ 
    1.18 +#define prrng_h___
    1.19 +
    1.20 +#include "prtypes.h"
    1.21 +
    1.22 +PR_BEGIN_EXTERN_C
    1.23 +
    1.24 +/*
    1.25 +** PR_GetRandomNoise() -- Get random noise from the host platform
    1.26 +**
    1.27 +** Description:
    1.28 +** PR_GetRandomNoise() provides, depending on platform, a random value.
    1.29 +** The length of the random value is dependent on platform and the
    1.30 +** platform's ability to provide a random value at that moment.
    1.31 +**
    1.32 +** The intent of PR_GetRandomNoise() is to provide a "seed" value for a
    1.33 +** another random number generator that may be suitable for
    1.34 +** cryptographic operations. This implies that the random value
    1.35 +** provided may not be, by itself, cryptographically secure. The value
    1.36 +** generated by PR_GetRandomNoise() is at best, extremely difficult to
    1.37 +** predict and is as non-deterministic as the underlying platfrom can
    1.38 +** provide.
    1.39 +**
    1.40 +** Inputs:
    1.41 +**   buf -- pointer to a caller supplied buffer to contain the
    1.42 +**          generated random number. buf must be at least as large as
    1.43 +**          is specified in the 'size' argument.
    1.44 +**
    1.45 +**   size -- the requested size of the generated random number
    1.46 +**
    1.47 +** Outputs:
    1.48 +**   a random number provided in 'buf'.
    1.49 +**
    1.50 +** Returns:
    1.51 +**   PRSize value equal to the size of the random number actually
    1.52 +**   generated, or zero. The generated size may be less than the size
    1.53 +**   requested. A return value of zero means that PR_GetRandomNoise() is
    1.54 +**   not implemented on this platform, or there is no available noise
    1.55 +**   available to be returned at the time of the call.
    1.56 +**
    1.57 +** Restrictions:
    1.58 +**   Calls to PR_GetRandomNoise() may use a lot of CPU on some platforms.
    1.59 +**   Some platforms may block for up to a few seconds while they
    1.60 +**   accumulate some noise. Busy machines generate lots of noise, but
    1.61 +**   care is advised when using PR_GetRandomNoise() frequently in your
    1.62 +**   application.
    1.63 +**
    1.64 +** History:
    1.65 +**   Parts of the model dependent implementation for PR_GetRandomNoise()
    1.66 +**   were taken in whole or part from code previously in Netscape's NSS
    1.67 +**   component.
    1.68 +**
    1.69 +*/
    1.70 +NSPR_API(PRSize) PR_GetRandomNoise( 
    1.71 +    void    *buf,
    1.72 +    PRSize  size
    1.73 +);
    1.74 +
    1.75 +PR_END_EXTERN_C
    1.76 +
    1.77 +#endif /* prrng_h___ */
    1.78 +/* end prrng.h */

mercurial