tests: cksum: add incorrect data to verify --check & --strict
[coreutils.git] / gl / lib / rand-isaac.h
blob630c600fb3b0cf36b95fcb03376dddca2daac30b
1 /* Bob Jenkins's cryptographic random number generators, ISAAC and ISAAC64.
3 Copyright (C) 1999-2024 Free Software Foundation, Inc.
4 Copyright (C) 1997, 1998, 1999 Colin Plumb.
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <https://www.gnu.org/licenses/>.
19 Written by Colin Plumb and Paul Eggert. */
21 #ifndef _GL_RAND_ISAAC_H
22 #define _GL_RAND_ISAAC_H
24 #include <stddef.h>
25 #include <stdint.h>
27 /* Log base 2 of the number of useful bits in an ISAAC word. It must
28 be either 5 or 6. By default, this uses a value that should be
29 faster for this architecture. */
30 #ifndef ISAAC_BITS_LOG
31 #if SIZE_MAX >> 31 >> 31 < 3 /* SIZE_MAX < 2**64 - 1 */
32 #define ISAAC_BITS_LOG 5
33 #else
34 #define ISAAC_BITS_LOG 6
35 #endif
36 #endif
38 /* The number of bits in an ISAAC word. */
39 #define ISAAC_BITS (1 << ISAAC_BITS_LOG)
41 #if ISAAC_BITS == 32
42 typedef uint_least32_t isaac_word;
43 #else
44 typedef uint_least64_t isaac_word;
45 #endif
47 /* Size of the state tables to use. ISAAC_WORDS_LOG should be at least 3,
48 and smaller values give less security. */
49 #define ISAAC_WORDS_LOG 8
50 #define ISAAC_WORDS (1 << ISAAC_WORDS_LOG)
51 #define ISAAC_BYTES (ISAAC_WORDS * sizeof (isaac_word))
53 /* State variables for the random number generator. The M member
54 should be seeded with nonce data before calling isaac_seed. The
55 other members are private. */
56 struct isaac_state
58 isaac_word m[ISAAC_WORDS]; /* Main state array */
59 isaac_word a, b, c; /* Extra variables */
62 void isaac_seed (struct isaac_state *) _GL_ATTRIBUTE_NONNULL ();
63 void isaac_refill (struct isaac_state *, isaac_word[ISAAC_WORDS])
64 _GL_ATTRIBUTE_NONNULL ();
66 #endif