[OLEACC]
[reactos.git] / reactos / include / reactos / libs / gnutls / nettle / knuth-lfib.h
1 /* knuth-lfib.h
2 *
3 * A "lagged fibonacci" pseudorandomness generator.
4 *
5 * Described in Knuth, TAOCP, 3.6
6 */
7
8 /* nettle, low-level cryptographics library
9 *
10 * Copyright (C) 2002 Niels Möller
11 *
12 * The nettle library is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License as published by
14 * the Free Software Foundation; either version 2.1 of the License, or (at your
15 * option) any later version.
16 *
17 * The nettle library is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
20 * License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with the nettle library; see the file COPYING.LIB. If not, write to
24 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
25 * MA 02111-1301, USA.
26 */
27
28 /* NOTE: This generator is totally inappropriate for cryptographic
29 * applications. It is useful for generating deterministic but
30 * random-looking test data, and is used by the Nettle testsuite. */
31 #ifndef NETTLE_KNUTH_LFIB_H_INCLUDED
32 #define NETTLE_KNUTH_LFIB_H_INCLUDED
33
34 #include "nettle-types.h"
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 /* Namespace mangling */
41 #define knuth_lfib_init nettle_knuth_lfib_init
42 #define knuth_lfib_get nettle_knuth_lfib_get
43 #define knuth_lfib_get_array nettle_knuth_lfib_get_array
44 #define knuth_lfib_random nettle_knuth_lfib_random
45
46 #define _KNUTH_LFIB_KK 100
47
48 struct knuth_lfib_ctx {
49 uint32_t x[_KNUTH_LFIB_KK];
50 unsigned index;
51 };
52
53 void
54 knuth_lfib_init(struct knuth_lfib_ctx *ctx, uint32_t seed);
55
56 /* Get's a single number in the range 0 ... 2^30-1 */
57 uint32_t knuth_lfib_get(struct knuth_lfib_ctx *ctx);
58
59 /* Get an array of numbers */
60 void
61 knuth_lfib_get_array(struct knuth_lfib_ctx *ctx,
62 unsigned n, uint32_t * a);
63
64 /* Get an array of octets. */
65 void
66 knuth_lfib_random(struct knuth_lfib_ctx *ctx,
67 unsigned n, uint8_t * dst);
68
69 #ifdef __cplusplus
70 }
71 #endif
72 #endif /* NETTLE_KNUTH_LFIB_H_INCLUDED */