1
/* rand-internal.h - header to glue the random functions
2
* Copyright (C) 1998, 2002 Free Software Foundation, Inc.
4
* This file is part of Libgcrypt.
6
* Libgcrypt is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser general Public License as
8
* published by the Free Software Foundation; either version 2.1 of
9
* the License, or (at your option) any later version.
11
* Libgcrypt 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 Lesser General Public License for more details.
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with this program; if not, see <http://www.gnu.org/licenses/>.
20
#ifndef G10_RAND_INTERNAL_H
21
#define G10_RAND_INTERNAL_H
23
#include "../src/cipher-proto.h"
25
/* Constants used to define the origin of random added to the pool.
26
The code is sensitive to the order of the values. */
29
RANDOM_ORIGIN_INIT = 0, /* Used only for initialization. */
30
RANDOM_ORIGIN_EXTERNAL = 1, /* Added from an external source. */
31
RANDOM_ORIGIN_FASTPOLL = 2, /* Fast random poll function. */
32
RANDOM_ORIGIN_SLOWPOLL = 3, /* Slow poll function. */
33
RANDOM_ORIGIN_EXTRAPOLL = 4 /* Used to mark an extra pool seed
34
due to a GCRY_VERY_STRONG_RANDOM
41
void _gcry_random_progress (const char *what, int printchar,
42
int current, int total);
45
/*-- random-csprng.c --*/
46
void _gcry_rngcsprng_initialize (int full);
47
void _gcry_rngcsprng_dump_stats (void);
48
void _gcry_rngcsprng_secure_alloc (void);
49
void _gcry_rngcsprng_enable_quick_gen (void);
50
void _gcry_rngcsprng_set_daemon_socket (const char *socketname);
51
int _gcry_rngcsprng_use_daemon (int onoff);
52
int _gcry_rngcsprng_is_faked (void);
53
gcry_error_t _gcry_rngcsprng_add_bytes (const void *buf, size_t buflen,
55
void *_gcry_rngcsprng_get_bytes (size_t nbytes,
56
enum gcry_random_level level);
57
void *_gcry_rngcsprng_get_bytes_secure (size_t nbytes,
58
enum gcry_random_level level);
59
void _gcry_rngcsprng_randomize (void *buffer, size_t length,
60
enum gcry_random_level level);
61
void _gcry_rngcsprng_set_seed_file (const char *name);
62
void _gcry_rngcsprng_update_seed_file (void);
63
void _gcry_rngcsprng_fast_poll (void);
64
void _gcry_rngcsprng_create_nonce (void *buffer, size_t length);
66
/*-- random-rngcsprng.c --*/
67
void _gcry_rngfips_initialize (int full);
68
void _gcry_rngfips_dump_stats (void);
69
int _gcry_rngfips_is_faked (void);
70
gcry_error_t _gcry_rngfips_add_bytes (const void *buf, size_t buflen,
72
void *_gcry_rngfips_get_bytes (size_t nbytes,
73
enum gcry_random_level level);
74
void *_gcry_rngfips_get_bytes_secure (size_t nbytes,
75
enum gcry_random_level level);
76
void _gcry_rngfips_randomize (void *buffer, size_t length,
77
enum gcry_random_level level);
78
void _gcry_rngfips_create_nonce (void *buffer, size_t length);
80
gcry_error_t _gcry_rngfips_selftest (selftest_report_func_t report);
82
gcry_err_code_t _gcry_rngfips_init_external_test (void **r_context,
90
gcry_err_code_t _gcry_rngfips_run_external_test (void *context,
91
char *buffer, size_t buflen);
92
void _gcry_rngfips_deinit_external_test (void *context);
99
int _gcry_rndlinux_gather_random (void (*add) (const void *, size_t,
100
enum random_origins),
101
enum random_origins origin,
102
size_t length, int level);
105
int _gcry_rndunix_gather_random (void (*add) (const void *, size_t,
106
enum random_origins),
107
enum random_origins origin,
108
size_t length, int level);
111
int _gcry_rndegd_gather_random (void (*add) (const void *, size_t,
112
enum random_origins),
113
enum random_origins origin,
114
size_t length, int level);
115
int _gcry_rndegd_connect_socket (int nofail);
118
int _gcry_rndw32_gather_random (void (*add) (const void *, size_t,
119
enum random_origins),
120
enum random_origins origin,
121
size_t length, int level);
122
void _gcry_rndw32_gather_random_fast (void (*add)(const void*, size_t,
123
enum random_origins),
124
enum random_origins origin );
127
int _gcry_rndhw_failed_p (void);
128
void _gcry_rndhw_poll_fast (void (*add)(const void*, size_t,
129
enum random_origins),
130
enum random_origins origin);
131
size_t _gcry_rndhw_poll_slow (void (*add)(const void*, size_t,
132
enum random_origins),
133
enum random_origins origin);
137
#endif /*G10_RAND_INTERNAL_H*/