cfb8: Fix decrypt path
[gd/nettle] / knuth-lfib.h
1 /* knuth-lfib.h
2
3    The "lagged fibonacci" pseudorandomness generator, described in
4    Knuth, TAoCP, 3.6
5
6    This file is part of GNU Nettle.
7
8    GNU Nettle is free software: you can redistribute it and/or
9    modify it under the terms of either:
10
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.
14
15    or
16
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.
20
21    or both in parallel, as here.
22
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.
27
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/.
31 */
32
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
38
39 #include "nettle-types.h"
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
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
50
51 #define _KNUTH_LFIB_KK 100
52
53 struct knuth_lfib_ctx
54 {
55   uint32_t x[_KNUTH_LFIB_KK];
56   unsigned index;
57 };
58
59 void
60 knuth_lfib_init(struct knuth_lfib_ctx *ctx, uint32_t seed);
61
62 /* Get's a single number in the range 0 ... 2^30-1 */
63 uint32_t
64 knuth_lfib_get(struct knuth_lfib_ctx *ctx);
65
66 /* Get an array of numbers */
67 void
68 knuth_lfib_get_array(struct knuth_lfib_ctx *ctx,
69                      size_t n, uint32_t *a);
70
71 /* Get an array of octets. */
72 void
73 knuth_lfib_random(struct knuth_lfib_ctx *ctx,
74                   size_t n, uint8_t *dst);
75
76 #ifdef __cplusplus
77 }
78 #endif
79
80 #endif /* NETTLE_KNUTH_LFIB_H_INCLUDED */