Psyduck - 可達鴨 之 鴨力山大2


Server : LiteSpeed
System : Linux premium217.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User : alloknri ( 880)
PHP Version : 8.1.34
Disable Function : NONE
Directory :  /usr/include/bind9/isc/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/include/bind9/isc/random.h
/*
 * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, you can obtain one at https://mozilla.org/MPL/2.0/.
 *
 * See the COPYRIGHT file distributed with this work for additional
 * information regarding copyright ownership.
 */

#ifndef ISC_RANDOM_H
#define ISC_RANDOM_H 1

#include <isc/lang.h>
#include <isc/types.h>
#include <isc/entropy.h>
#include <isc/mem.h>
#include <isc/mutex.h>

/*! \file isc/random.h
 * \brief Implements pseudo random number generators.
 *
 * Two pseudo-random number generators are implemented, in isc_random_*
 * and isc_rng_*. Neither one is very strong; they should not be used
 * in cryptography functions.
 *
 * isc_random_* is based on arc4random if it is available on the system.
 * Otherwise it is based on the posix srand() and rand() functions.
 * It is useful for jittering values a bit here and there, such as
 * timeouts, etc, but should not be relied upon to generate
 * unpredictable sequences (for example, when choosing transaction IDs).
  *
 * isc_rng_* is based on ChaCha20, and is seeded and stirred from the
 * system entropy source. It is stronger than isc_random_* and can
 * be used for generating unpredictable sequences. It is still not as
 * good as using system entropy directly (see entropy.h) and should not
 * be used for cryptographic functions such as key generation.
 */

ISC_LANG_BEGINDECLS

typedef struct isc_rng isc_rng_t;
/*%<
 * Opaque type
 */

void
isc_random_seed(uint32_t seed);
/*%<
 * Set the initial seed of the random state.
 */

void
isc_random_get(uint32_t *val);
/*%<
 * Get a random value.
 *
 * Requires:
 *	val != NULL.
 */

uint32_t
isc_random_jitter(uint32_t max, uint32_t jitter);
/*%<
 * Get a random value between (max - jitter) and (max).
 * This is useful for jittering timer values.
 */

isc_result_t
isc_rng_create(isc_mem_t *mctx, isc_entropy_t *entropy, isc_rng_t **rngp);
/*%<
 * Creates and initializes a pseudo random number generator. The
 * returned RNG can be used to generate pseudo random numbers.
 *
 * The reference count of the returned RNG is set to 1.
 *
 * Requires:
 * \li mctx is a pointer to a valid memory context.
 * \li entropy is an optional entopy source (can be NULL)
 * \li rngp != NULL && *rngp == NULL is where a pointer to the RNG is
 *     returned.
 *
 * Ensures:
 *\li	If result is ISC_R_SUCCESS:
 *		*rngp points to a valid RNG.
 *
 *\li	If result is failure:
 *		*rngp does not point to a valid RNG.
 *
 * Returns:
 *\li	#ISC_R_SUCCESS	Success
 *\li	#ISC_R_NOMEMORY Resource limit: Out of Memory
 */

void
isc_rng_attach(isc_rng_t *source, isc_rng_t **targetp);
/*%<
 * Increments a reference count on the passed RNG.
 *
 * Requires:
 * \li source the RNG struct to attach to (is refcount is incremented)
 * \li targetp != NULL && *targetp == NULL where a pointer to the
 *     reference incremented RNG is returned.
 */

void
isc_rng_detach(isc_rng_t **rngp);
/*%<
 * Decrements a reference count on the passed RNG. If the reference
 * count reaches 0, the RNG is destroyed.
 *
 * Requires:
 * \li rngp != NULL the RNG struct to decrement reference for
 */

uint16_t
isc_rng_random(isc_rng_t *rngctx);
/*%<
 * Returns a pseudo random 16-bit unsigned integer.
 */

uint16_t
isc_rng_uniformrandom(isc_rng_t *rngctx, uint16_t upper_bound);
/*%<
 * Returns a uniformly distributed pseudo-random 16-bit unsigned integer
 * less than 'upper_bound'.
 */

ISC_LANG_ENDDECLS

#endif /* ISC_RANDOM_H */
Name
Size
Permissions
Options
aes.h
1.055 KB
-rw-r--r--
app.h
10.232 KB
-rw-r--r--
assertions.h
2.839 KB
-rw-r--r--
atomic.h
4.07 KB
-rw-r--r--
backtrace.h
3.8 KB
-rw-r--r--
base32.h
4.349 KB
-rw-r--r--
base64.h
2.799 KB
-rw-r--r--
bind9.h
0.811 KB
-rw-r--r--
boolean.h
0.58 KB
-rw-r--r--
buffer.h
25.652 KB
-rw-r--r--
bufferlist.h
1.418 KB
-rw-r--r--
cmocka.h
1.351 KB
-rw-r--r--
commandline.h
1.673 KB
-rw-r--r--
condition.h
1.443 KB
-rw-r--r--
counter.h
1.881 KB
-rw-r--r--
crc64.h
0.975 KB
-rw-r--r--
deprecated.h
0.608 KB
-rw-r--r--
dir.h
1.561 KB
-rw-r--r--
endian.h
4.666 KB
-rw-r--r--
entropy.h
10.13 KB
-rw-r--r--
errno.h
0.644 KB
-rw-r--r--
errno2result.h
0.881 KB
-rw-r--r--
error.h
1.396 KB
-rw-r--r--
event.h
2.981 KB
-rw-r--r--
eventclass.h
1.349 KB
-rw-r--r--
file.h
11.394 KB
-rw-r--r--
formatcheck.h
0.872 KB
-rw-r--r--
fsaccess.h
7.268 KB
-rw-r--r--
hash.h
7.482 KB
-rw-r--r--
heap.h
5.141 KB
-rw-r--r--
hex.h
2.74 KB
-rw-r--r--
hmacmd5.h
1.745 KB
-rw-r--r--
hmacsha.h
4.405 KB
-rw-r--r--
ht.h
4.293 KB
-rw-r--r--
httpd.h
2.264 KB
-rw-r--r--
int.h
1.063 KB
-rw-r--r--
interfaceiter.h
3.047 KB
-rw-r--r--
iterated_hash.h
1.021 KB
-rw-r--r--
json.h
1.425 KB
-rw-r--r--
keyboard.h
0.966 KB
-rw-r--r--
lang.h
0.622 KB
-rw-r--r--
lex.h
9.542 KB
-rw-r--r--
lfsr.h
2.889 KB
-rw-r--r--
lib.h
1.043 KB
-rw-r--r--
likely.h
0.799 KB
-rw-r--r--
list.h
5.616 KB
-rw-r--r--
log.h
28.061 KB
-rw-r--r--
magic.h
0.971 KB
-rw-r--r--
md5.h
2.324 KB
-rw-r--r--
mem.h
20.615 KB
-rw-r--r--
meminfo.h
0.693 KB
-rw-r--r--
msgcat.h
2.662 KB
-rw-r--r--
msgs.h
8.225 KB
-rw-r--r--
mutex.h
3.441 KB
-rw-r--r--
mutexblock.h
1.343 KB
-rw-r--r--
net.h
10.287 KB
-rw-r--r--
netaddr.h
4.482 KB
-rw-r--r--
netdb.h
0.843 KB
-rw-r--r--
netscope.h
0.944 KB
-rw-r--r--
offset.h
0.684 KB
-rw-r--r--
once.h
0.96 KB
-rw-r--r--
ondestroy.h
2.733 KB
-rw-r--r--
os.h
0.655 KB
-rw-r--r--
parseint.h
1.506 KB
-rw-r--r--
platform.h
9.489 KB
-rw-r--r--
pool.h
3.42 KB
-rw-r--r--
portset.h
3.218 KB
-rw-r--r--
print.h
2.417 KB
-rw-r--r--
queue.h
5.082 KB
-rw-r--r--
quota.h
2.383 KB
-rw-r--r--
radix.h
6.339 KB
-rw-r--r--
random.h
3.498 KB
-rw-r--r--
ratelimiter.h
3.415 KB
-rw-r--r--
refcount.h
8.001 KB
-rw-r--r--
regex.h
0.749 KB
-rw-r--r--
region.h
1.986 KB
-rw-r--r--
resource.h
2.795 KB
-rw-r--r--
result.h
4.865 KB
-rw-r--r--
resultclass.h
1.562 KB
-rw-r--r--
rwlock.h
3.718 KB
-rw-r--r--
safe.h
1.32 KB
-rw-r--r--
serial.h
1.336 KB
-rw-r--r--
sha1.h
1.52 KB
-rw-r--r--
sha2.h
5.599 KB
-rw-r--r--
siphash.h
0.717 KB
-rw-r--r--
sockaddr.h
5.897 KB
-rw-r--r--
socket.h
35.796 KB
-rw-r--r--
stat.h
0.787 KB
-rw-r--r--
stats.h
3.622 KB
-rw-r--r--
stdatomic.h
5.127 KB
-rw-r--r--
stdio.h
1.745 KB
-rw-r--r--
stdlib.h
0.688 KB
-rw-r--r--
stdtime.h
1.04 KB
-rw-r--r--
strerror.h
0.759 KB
-rw-r--r--
string.h
5.878 KB
-rw-r--r--
symtab.h
4.225 KB
-rw-r--r--
syslog.h
0.824 KB
-rw-r--r--
task.h
21.039 KB
-rw-r--r--
taskpool.h
3.622 KB
-rw-r--r--
thread.h
1.471 KB
-rw-r--r--
time.h
8.668 KB
-rw-r--r--
timer.h
10.542 KB
-rw-r--r--
tm.h
0.874 KB
-rw-r--r--
types.h
5.645 KB
-rw-r--r--
utf8.h
0.906 KB
-rw-r--r--
util.h
10.29 KB
-rw-r--r--
version.h
0.673 KB
-rw-r--r--
xml.h
1.068 KB
-rw-r--r--