xref: /minix3/external/bsd/bind/dist/lib/isc/include/isc/random.h (revision 00b67f09dd46474d133c95011a48590a8e8f94c7)
1 /*	$NetBSD: random.h,v 1.4 2014/12/10 04:38:00 christos Exp $	*/
2 
3 /*
4  * Copyright (C) 2004-2007, 2009  Internet Systems Consortium, Inc. ("ISC")
5  * Copyright (C) 1999-2001  Internet Software Consortium.
6  *
7  * Permission to use, copy, modify, and/or distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
12  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
16  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /* Id: random.h,v 1.20 2009/01/17 23:47:43 tbox Exp  */
21 
22 #ifndef ISC_RANDOM_H
23 #define ISC_RANDOM_H 1
24 
25 #include <isc/lang.h>
26 #include <isc/types.h>
27 
28 /*! \file isc/random.h
29  * \brief Implements a random state pool which will let the caller return a
30  * series of possibly non-reproducible random values.
31  *
32  * Note that the
33  * strength of these numbers is not all that high, and should not be
34  * used in cryptography functions.  It is useful for jittering values
35  * a bit here and there, such as timeouts, etc.
36  */
37 
38 ISC_LANG_BEGINDECLS
39 
40 void
41 isc_random_seed(isc_uint32_t seed);
42 /*%<
43  * Set the initial seed of the random state.
44  */
45 
46 void
47 isc_random_get(isc_uint32_t *val);
48 /*%<
49  * Get a random value.
50  *
51  * Requires:
52  *	val != NULL.
53  */
54 
55 isc_uint32_t
56 isc_random_jitter(isc_uint32_t max, isc_uint32_t jitter);
57 /*%<
58  * Get a random value between (max - jitter) and (max).
59  * This is useful for jittering timer values.
60  */
61 
62 ISC_LANG_ENDDECLS
63 
64 #endif /* ISC_RANDOM_H */
65