summaryrefslogtreecommitdiff
path: root/plugins/MirOTR/Libgcrypt/random/rand-internal.h
blob: 79b23acefe839cade2ae5d30a50a1bc370e18705 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/* rand-internal.h - header to glue the random functions
 *	Copyright (C) 1998, 2002 Free Software Foundation, Inc.
 *
 * This file is part of Libgcrypt.
 *
 * Libgcrypt is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser general Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * Libgcrypt is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program; if not, see <http://www.gnu.org/licenses/>.
 */

#ifndef G10_RAND_INTERNAL_H
#define G10_RAND_INTERNAL_H

#include "../src/cipher-proto.h"

/* Constants used to define the origin of random added to the pool.
   The code is sensitive to the order of the values.  */
enum random_origins
  {
    RANDOM_ORIGIN_INIT = 0,      /* Used only for initialization. */
    RANDOM_ORIGIN_EXTERNAL = 1,  /* Added from an external source.  */
    RANDOM_ORIGIN_FASTPOLL = 2,  /* Fast random poll function.  */
    RANDOM_ORIGIN_SLOWPOLL = 3,  /* Slow poll function.  */
    RANDOM_ORIGIN_EXTRAPOLL = 4  /* Used to mark an extra pool seed
                                    due to a GCRY_VERY_STRONG_RANDOM
                                    random request.  */
  };



/*-- random.c --*/
void _gcry_random_progress (const char *what, int printchar,
                            int current, int total);


/*-- random-csprng.c --*/
void _gcry_rngcsprng_initialize (int full);
void _gcry_rngcsprng_close_fds (void);
void _gcry_rngcsprng_dump_stats (void);
void _gcry_rngcsprng_secure_alloc (void);
void _gcry_rngcsprng_enable_quick_gen (void);
void _gcry_rngcsprng_set_daemon_socket (const char *socketname);
int  _gcry_rngcsprng_use_daemon (int onoff);
int  _gcry_rngcsprng_is_faked (void);
gcry_error_t _gcry_rngcsprng_add_bytes (const void *buf, size_t buflen,
                                        int quality);
void *_gcry_rngcsprng_get_bytes (size_t nbytes,
                                 enum gcry_random_level level);
void *_gcry_rngcsprng_get_bytes_secure (size_t nbytes,
                                        enum gcry_random_level level);
void _gcry_rngcsprng_randomize (void *buffer, size_t length,
                                enum gcry_random_level level);
void _gcry_rngcsprng_set_seed_file (const char *name);
void _gcry_rngcsprng_update_seed_file (void);
void _gcry_rngcsprng_fast_poll (void);

/*-- random-fips.c --*/
void _gcry_rngfips_initialize (int full);
void _gcry_rngfips_close_fds (void);
void _gcry_rngfips_dump_stats (void);
int  _gcry_rngfips_is_faked (void);
gcry_error_t _gcry_rngfips_add_bytes (const void *buf, size_t buflen,
                                        int quality);
void _gcry_rngfips_randomize (void *buffer, size_t length,
                                enum gcry_random_level level);
void _gcry_rngfips_create_nonce (void *buffer, size_t length);

gcry_error_t _gcry_rngfips_selftest (selftest_report_func_t report);

gcry_err_code_t _gcry_rngfips_init_external_test (void **r_context,
                                                  unsigned int flags,
                                                  const void *key,
                                                  size_t keylen,
                                                  const void *seed,
                                                  size_t seedlen,
                                                  const void *dt,
                                                  size_t dtlen);
gcry_err_code_t _gcry_rngfips_run_external_test (void *context,
                                                 char *buffer, size_t buflen);
void _gcry_rngfips_deinit_external_test (void *context);


/*-- random-system.c --*/
void _gcry_rngsystem_initialize (int full);
void _gcry_rngsystem_close_fds (void);
void _gcry_rngsystem_dump_stats (void);
int  _gcry_rngsystem_is_faked (void);
gcry_error_t _gcry_rngsystem_add_bytes (const void *buf, size_t buflen,
                                        int quality);
void _gcry_rngsystem_randomize (void *buffer, size_t length,
                                enum gcry_random_level level);



/*-- rndlinux.c --*/
int _gcry_rndlinux_gather_random (void (*add) (const void *, size_t,
                                               enum random_origins),
                                   enum random_origins origin,
                                  size_t length, int level);

/*-- rndunix.c --*/
int _gcry_rndunix_gather_random (void (*add) (const void *, size_t,
                                              enum random_origins),
                                 enum random_origins origin,
                                 size_t length, int level);

/*-- rndelg.c --*/
int _gcry_rndegd_gather_random (void (*add) (const void *, size_t,
                                             enum random_origins),
                                enum random_origins origin,
                                size_t length, int level);
int _gcry_rndegd_connect_socket (int nofail);

/*-- rndw32.c --*/
int _gcry_rndw32_gather_random (void (*add) (const void *, size_t,
                                             enum random_origins),
                                enum random_origins origin,
                                size_t length, int level);
void _gcry_rndw32_gather_random_fast (void (*add)(const void*, size_t,
                                                  enum random_origins),
                                      enum random_origins origin );

/*-- rndw32ce.c --*/
int _gcry_rndw32ce_gather_random (void (*add) (const void *, size_t,
                                               enum random_origins),
                                  enum random_origins origin,
                                  size_t length, int level);
void _gcry_rndw32ce_gather_random_fast (void (*add)(const void*, size_t,
                                                    enum random_origins),
                                        enum random_origins origin );

/*-- rndhw.c --*/
int _gcry_rndhw_failed_p (void);
void _gcry_rndhw_poll_fast (void (*add)(const void*, size_t,
                                        enum random_origins),
                            enum random_origins origin);
size_t _gcry_rndhw_poll_slow (void (*add)(const void*, size_t,
                                          enum random_origins),
                              enum random_origins origin);



#endif /*G10_RAND_INTERNAL_H*/