The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
rand.h
Go to the documentation of this file.
1#pragma once
2/*
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16 */
17
18/** Functions to get randomness
19 *
20 * @file src/lib/util/rand.h
21 *
22 * @copyright 1999-2017 The FreeRADIUS server project
23 */
24RCSIDH(rand_h, "$Id: ab20de60ada0a887443803d944e823eafd1c35d4 $")
25
26#include <freeradius-devel/build.h>
27#include <freeradius-devel/missing.h>
28
29#include <stddef.h>
30#include <stdint.h>
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36/* random numbers in isaac.c */
37/* context of random number generator */
46
47/** Smaller fast random number generator.
48 *
49 * From George Marsaglia's Multiply with Carry (MWC) algorithm.
50 *
51 * The two seeds here should be initialized by calling fr_rand(),
52 * or for tests, via some static values.
53 */
54typedef struct {
57
58void fr_isaac(fr_randctx *ctx);
59void fr_isaac_init(fr_randctx *ctx, int flag);
60/** @hidecallergraph */
61uint32_t fr_rand(void); /* like rand(), but better. */
62
63void fr_rand_init(void);
64void fr_rand_buffer(void *start, size_t length) CC_HINT(nonnull);
65void fr_rand_str(uint8_t *out, size_t len, char class);
66void fr_rand_mixin(void const *, size_t ) CC_HINT(nonnull);
68
69#ifdef __cplusplus
70}
71#endif
#define RCSIDH(h, id)
Definition build.h:484
unsigned int uint32_t
unsigned char uint8_t
void fr_rand_mixin(void const *, size_t)
Mix data into the random number generator.
Definition rand.c:79
uint32_t randb
Definition rand.h:43
uint32_t fr_fast_rand(fr_fast_rand_t *ctx)
Definition rand.c:279
void fr_isaac_init(fr_randctx *ctx, int flag)
Definition isaac.c:85
void fr_rand_init(void)
Definition rand.c:34
void fr_isaac(fr_randctx *ctx)
Definition isaac.c:46
uint32_t randc
Definition rand.h:44
void fr_rand_str(uint8_t *out, size_t len, char class)
Generate a random string.
Definition rand.c:163
uint32_t randcnt
Definition rand.h:39
uint32_t fr_rand(void)
Return a 32-bit random number.
Definition rand.c:105
void fr_rand_buffer(void *start, size_t length)
Definition rand.c:125
uint32_t randa
Definition rand.h:42
uint32_t a
Definition rand.h:55
Smaller fast random number generator.
Definition rand.h:54
int nonnull(2, 5))
static size_t char ** out
Definition value.h:997