3 The "lagged fibonacci" pseudorandomness generator, described in
6 This file is part of GNU Nettle.
8 GNU Nettle is free software: you can redistribute it and/or
9 modify it under the terms of either:
11 * the GNU Lesser General Public License as published by the Free
12 Software Foundation; either version 3 of the License, or (at your
13 option) any later version.
17 * the GNU General Public License as published by the Free
18 Software Foundation; either version 2 of the License, or (at your
19 option) any later version.
21 or both in parallel, as here.
23 GNU Nettle is distributed in the hope that it will be useful,
24 but WITHOUT ANY WARRANTY; without even the implied warranty of
25 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 General Public License for more details.
28 You should have received copies of the GNU General Public License and
29 the GNU Lesser General Public License along with this program. If
30 not, see http://www.gnu.org/licenses/.
33 /* NOTE: This generator is totally inappropriate for cryptographic
34 * applications. It is useful for generating deterministic but
35 * random-looking test data, and is used by the Nettle testsuite. */
36 #ifndef NETTLE_KNUTH_LFIB_H_INCLUDED
37 #define NETTLE_KNUTH_LFIB_H_INCLUDED
39 #include "nettle-types.h"
45 /* Namespace mangling */
46 #define knuth_lfib_init nettle_knuth_lfib_init
47 #define knuth_lfib_get nettle_knuth_lfib_get
48 #define knuth_lfib_get_array nettle_knuth_lfib_get_array
49 #define knuth_lfib_random nettle_knuth_lfib_random
51 #define _KNUTH_LFIB_KK 100
55 uint32_t x[_KNUTH_LFIB_KK];
60 knuth_lfib_init(struct knuth_lfib_ctx *ctx, uint32_t seed);
62 /* Get's a single number in the range 0 ... 2^30-1 */
64 knuth_lfib_get(struct knuth_lfib_ctx *ctx);
66 /* Get an array of numbers */
68 knuth_lfib_get_array(struct knuth_lfib_ctx *ctx,
69 size_t n, uint32_t *a);
71 /* Get an array of octets. */
73 knuth_lfib_random(struct knuth_lfib_ctx *ctx,
74 size_t n, uint8_t *dst);
80 #endif /* NETTLE_KNUTH_LFIB_H_INCLUDED */