~andreserl/ubuntu/lucid/bind9/bind9-apport-533601

« back to all changes in this revision

Viewing changes to lib/isc/include/isc/entropy.h

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones, LaMont Jones, Internet Software Consortium, Inc, localization folks
  • Date: 2008-08-02 14:20:20 UTC
  • mfrom: (1.2.1 upstream) (6.1.24 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080802142020-l1hon9jy8lbbjxmg
[LaMont Jones]

* default to using resolvconf if it is installed
* fix sonames and dependencies.  Closes: #149259, #492418
* Do not build-depend libcap2-dev on non-linux.  Closes: #493392
* drop unused query-loc manpage.  Closes: #492564
* lwresd: Deliver /etc/bind directory.  Closes: #490027
* fix query-source comment in default install

[Internet Software Consortium, Inc]

* 9.5.0-P2.  Closes: #492949

[localization folks]

* l10n: Spanish debconf translation.  Closes: #492425 (Ignacio Mondino)
* l10n: Swedish debconf templates.  Closes: #491369 (Martin Ågren)
* l10n: Japanese debconf translations.  Closes: #492048 (Hideki Yamane
  (Debian-JP))
* l10n: Finnish translation.  Closes: #490630 (Esko Arajärvi)
* l10n: Italian debconf translations.  Closes: #492587 (Alessandro Vietta)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
 
2
 * Copyright (C) 2004-2007  Internet Systems Consortium, Inc. ("ISC")
3
3
 * Copyright (C) 2000, 2001  Internet Software Consortium.
4
4
 *
5
 
 * Permission to use, copy, modify, and distribute this software for any
 
5
 * Permission to use, copy, modify, and/or distribute this software for any
6
6
 * purpose with or without fee is hereby granted, provided that the above
7
7
 * copyright notice and this permission notice appear in all copies.
8
8
 *
15
15
 * PERFORMANCE OF THIS SOFTWARE.
16
16
 */
17
17
 
18
 
/* $Id: entropy.h,v 1.23.2.1.10.1 2004/03/06 08:14:40 marka Exp $ */
 
18
/* $Id: entropy.h,v 1.32 2007/06/19 23:47:18 tbox Exp $ */
19
19
 
20
20
#ifndef ISC_ENTROPY_H
21
21
#define ISC_ENTROPY_H 1
24
24
 ***** Module Info
25
25
 *****/
26
26
 
27
 
/*
28
 
 * Entropy
29
 
 *
30
 
 * The entropy API
31
 
 *
32
 
 * MP:
 
27
/*! \file isc/entropy.h
 
28
 * \brief The entropy API
 
29
 *
 
30
 * \li MP:
33
31
 *      The entropy object is locked internally.  All callbacks into
34
32
 *      application-provided functions (for setup, gathering, and
35
33
 *      shutdown of sources) are guaranteed to be called with the
36
34
 *      entropy API lock held.  This means these functions are
37
35
 *      not permitted to call back into the entropy API.
38
36
 *
39
 
 * Reliability:
 
37
 * \li Reliability:
40
38
 *      No anticipated impact.
41
39
 *
42
 
 * Resources:
 
40
 * \li Resources:
43
41
 *      A buffer, used as an entropy pool.
44
42
 *
45
 
 * Security:
 
43
 * \li Security:
46
44
 *      While this code is believed to implement good entropy gathering
47
45
 *      and distribution, it has not been reviewed by a cryptographic
48
46
 *      expert.
49
 
 *
50
47
 *      Since the added entropy is only as good as the sources used,
51
48
 *      this module could hand out bad data and never know it.
52
49
 *
53
 
 * Standards:
 
50
 * \li Standards:
54
51
 *      None.
55
52
 */
56
53
 
63
60
#include <isc/lang.h>
64
61
#include <isc/types.h>
65
62
 
66
 
/*
67
 
 * Entropy callback function.
68
 
 */
 
63
/*@{*/
 
64
/*% Entropy callback function. */
69
65
typedef isc_result_t (*isc_entropystart_t)(isc_entropysource_t *source,
70
66
                                           void *arg, isc_boolean_t blocking);
71
67
typedef isc_result_t (*isc_entropyget_t)(isc_entropysource_t *source,
72
68
                                         void *arg, isc_boolean_t blocking);
73
69
typedef void (*isc_entropystop_t)(isc_entropysource_t *source, void *arg);
 
70
/*@}*/
74
71
 
75
72
/***
76
73
 *** Flags.
77
74
 ***/
78
75
 
79
 
/*
80
 
 * _GOODONLY
 
76
/*!
 
77
 * \brief 
81
78
 *      Extract only "good" data; return failure if there is not enough
82
79
 *      data available and there are no sources which we can poll to get
83
80
 *      data, or those sources are empty.
84
81
 *
85
 
 * _PARTIAL
 
82
 *
 
83
 */
 
84
#define ISC_ENTROPY_GOODONLY    0x00000001U
 
85
/*!
 
86
 * \brief
86
87
 *      Extract as much good data as possible, but if there isn't enough
87
88
 *      at hand, return what is available.  This flag only makes sense
88
89
 *      when used with _GOODONLY.
89
 
 *
90
 
 * _BLOCKING
 
90
 */
 
91
#define ISC_ENTROPY_PARTIAL     0x00000002U
 
92
/*!
 
93
 * \brief
91
94
 *      Block the task until data is available.  This is contrary to the
92
95
 *      ISC task system, where tasks should never block.  However, if
93
96
 *      this is a special purpose application where blocking a task is
95
98
 *      This flag only makes sense when used with _GOODONLY, and will
96
99
 *      block regardless of the setting for _PARTIAL.
97
100
 */
98
 
#define ISC_ENTROPY_GOODONLY    0x00000001U
99
 
#define ISC_ENTROPY_PARTIAL     0x00000002U
100
101
#define ISC_ENTROPY_BLOCKING    0x00000004U
101
102
 
102
 
/*
103
 
 * _ESTIMATE
 
103
/*!
 
104
 * \brief
104
105
 *      Estimate the amount of entropy contained in the sample pool.
105
106
 *      If this is not set, the source will be gathered and perodically
106
107
 *      mixed into the entropy pool, but no increment in contained entropy
110
111
 
111
112
/*
112
113
 * For use with isc_entropy_usebestsource().
113
 
 *
114
 
 * _KEYBOARDYES
 
114
 */
 
115
/*!
 
116
 * \brief 
115
117
 *      Use the keyboard as the only entropy source.
116
 
 * _KEYBOARDNO
 
118
 */
 
119
#define ISC_ENTROPY_KEYBOARDYES         1
 
120
/*!
 
121
 * \brief 
117
122
 *      Never use the keyboard as an entropy source.
118
 
 * _KEYBOARDMAYBE
 
123
 */
 
124
#define ISC_ENTROPY_KEYBOARDNO          2
 
125
/*!
 
126
 * \brief
119
127
 *      Use the keyboard as an entropy source only if opening the
120
128
 *      random device fails.
121
129
 */
122
 
#define ISC_ENTROPY_KEYBOARDYES         1
123
 
#define ISC_ENTROPY_KEYBOARDNO          2
124
130
#define ISC_ENTROPY_KEYBOARDMAYBE       3
125
131
 
126
132
ISC_LANG_BEGINDECLS
131
137
 
132
138
isc_result_t
133
139
isc_entropy_create(isc_mem_t *mctx, isc_entropy_t **entp);
134
 
/*
135
 
 * Create a new entropy object.
 
140
/*!<
 
141
 * \brief Create a new entropy object.
136
142
 */
137
143
 
138
144
void
139
145
isc_entropy_attach(isc_entropy_t *ent, isc_entropy_t **entp);
140
 
/*
 
146
/*!<
141
147
 * Attaches to an entropy object.
142
148
 */
143
149
 
144
150
void
145
151
isc_entropy_detach(isc_entropy_t **entp);
146
 
/*
147
 
 * Detaches from an entropy object.
 
152
/*!<
 
153
 * \brief Detaches from an entropy object.
148
154
 */
149
155
 
150
156
isc_result_t
151
157
isc_entropy_createfilesource(isc_entropy_t *ent, const char *fname);
152
 
/*
153
 
 * Create a new entropy source from a file.
 
158
/*!<
 
159
 * \brief Create a new entropy source from a file.
154
160
 *
155
161
 * The file is assumed to contain good randomness, and will be mixed directly
156
162
 * into the pool with every byte adding 8 bits of entropy.
168
174
 
169
175
void
170
176
isc_entropy_destroysource(isc_entropysource_t **sourcep);
171
 
/*
172
 
 * Removes an entropy source from the entropy system.
 
177
/*!<
 
178
 * \brief Removes an entropy source from the entropy system.
173
179
 */
174
180
 
175
181
isc_result_t
176
182
isc_entropy_createsamplesource(isc_entropy_t *ent,
177
183
                               isc_entropysource_t **sourcep);
178
 
/*
179
 
 * Create an entropy source that consists of samples.  Each sample is added
 
184
/*!<
 
185
 * \brief Create an entropy source that consists of samples.  Each sample is added
180
186
 * to the source via isc_entropy_addsamples(), below.
181
187
 */
182
188
 
187
193
                                 isc_entropystop_t stop,
188
194
                                 void *arg,
189
195
                                 isc_entropysource_t **sourcep);
190
 
/*
191
 
 * Create an entropy source that is polled via a callback.  This would
 
196
/*!<
 
197
 * \brief Create an entropy source that is polled via a callback.  
 
198
 *
 
199
 * This would
192
200
 * be used when keyboard input is used, or a GUI input method.  It can
193
201
 * also be used to hook in any external entropy source.
194
202
 *
199
207
 
200
208
void
201
209
isc_entropy_stopcallbacksources(isc_entropy_t *ent);
202
 
/*
203
 
 * Call the stop functions for callback sources that have had their
 
210
/*!<
 
211
 * \brief Call the stop functions for callback sources that have had their
204
212
 * start functions called.
205
213
 */
206
214
 
 
215
/*@{*/
207
216
isc_result_t
208
217
isc_entropy_addcallbacksample(isc_entropysource_t *source, isc_uint32_t sample,
209
218
                              isc_uint32_t extra);
210
219
isc_result_t
211
220
isc_entropy_addsample(isc_entropysource_t *source, isc_uint32_t sample,
212
221
                      isc_uint32_t extra);
213
 
/*
214
 
 * Add a sample to the sample source.  The sample MUST be a timestamp
 
222
/*!<
 
223
 * \brief Add a sample to the sample source.  
 
224
 *
 
225
 * The sample MUST be a timestamp
215
226
 * that increases over time, with the exception of wrap-around for
216
227
 * extremely high resolution timers which will quickly wrap-around
217
228
 * a 32-bit integer.
222
233
 * When in an entropy API callback function, _addcallbacksource() must be
223
234
 * used.  At all other times, _addsample() must be used.
224
235
 */
 
236
/*@}*/
225
237
 
226
238
isc_result_t
227
239
isc_entropy_getdata(isc_entropy_t *ent, void *data, unsigned int length,
228
240
                    unsigned int *returned, unsigned int flags);
229
 
/*
230
 
 * Extract data from the entropy pool.  This may load the pool from various
 
241
/*!<
 
242
 * \brief Extract data from the entropy pool.  This may load the pool from various
231
243
 * sources.
 
244
 *
 
245
 * Do this by stiring the pool and returning a part of hash as randomness.
 
246
 * Note that no secrets are given away here since parts of the hash are
 
247
 * xored together before returned.
 
248
 *
 
249
 * Honor the request from the caller to only return good data, any data,
 
250
 * etc.
232
251
 */
233
252
 
234
253
void
235
254
isc_entropy_putdata(isc_entropy_t *ent, void *data, unsigned int length,
236
255
                    isc_uint32_t entropy);
237
 
/*
238
 
 * Add "length" bytes in "data" to the entropy pool, incrementing the pool's
 
256
/*!<
 
257
 * \brief Add "length" bytes in "data" to the entropy pool, incrementing the pool's
239
258
 * entropy count by "entropy."
240
259
 *
241
260
 * These bytes will prime the pseudorandom portion even no entropy is actually
244
263
 
245
264
void
246
265
isc_entropy_stats(isc_entropy_t *ent, FILE *out);
 
266
/*!<
 
267
 * \brief Dump some (trivial) stats to the stdio stream "out".
 
268
 */
 
269
 
 
270
unsigned int
 
271
isc_entropy_status(isc_entropy_t *end);
247
272
/*
248
 
 * Dump some (trivial) stats to the stdio stream "out".
 
273
 * Returns the number of bits the pool currently contains.  This is just
 
274
 * an estimate.
249
275
 */
250
276
 
251
277
isc_result_t
252
278
isc_entropy_usebestsource(isc_entropy_t *ectx, isc_entropysource_t **source,
253
279
                          const char *randomfile, int use_keyboard);
254
 
/*
255
 
 * Use whatever source of entropy is best.
 
280
/*!<
 
281
 * \brief Use whatever source of entropy is best.
256
282
 *
257
283
 * Notes:
258
 
 *      If "randomfile" is not NULL, open it with
 
284
 *\li   If "randomfile" is not NULL, open it with
259
285
 *      isc_entropy_createfilesource(). 
260
286
 *
261
 
 *      If "randomfile" is NULL and the system's random device was detected
 
287
 *\li   If "randomfile" is NULL and the system's random device was detected
262
288
 *      when the program was configured and built, open that device with
263
289
 *      isc_entropy_createfilesource(). 
264
290
 *
265
 
 *      If "use_keyboard" is ISC_ENTROPY_KEYBOARDYES, then always open
 
291
 *\li   If "use_keyboard" is #ISC_ENTROPY_KEYBOARDYES, then always open
266
292
 *      the keyboard as an entropy source (possibly in addition to
267
293
 *      "randomfile" or the random device).
268
294
 *
269
 
 *      If "use_keyboard" is ISC_ENTROPY_KEYBOARDMAYBE, open the keyboard only
 
295
 *\li   If "use_keyboard" is #ISC_ENTROPY_KEYBOARDMAYBE, open the keyboard only
270
296
 *      if opening the random file/device fails.  A message will be
271
297
 *      printed describing the need for keyboard input.
272
298
 *
273
 
 *      If "use_keyboard" is ISC_ENTROPY_KEYBOARDNO, the keyboard will
 
299
 *\li   If "use_keyboard" is #ISC_ENTROPY_KEYBOARDNO, the keyboard will
274
300
 *      never be opened.
275
301
 *
276
302
 * Returns:
277
 
 *      ISC_R_SUCCESS if at least one source of entropy could be started.
 
303
 *\li   #ISC_R_SUCCESS if at least one source of entropy could be started.
278
304
 *
279
 
 *      ISC_R_NOENTROPY if use_keyboard is ISC_ENTROPY_KEYBOARDNO and
 
305
 *\li   #ISC_R_NOENTROPY if use_keyboard is #ISC_ENTROPY_KEYBOARDNO and
280
306
 *      there is no random device pathname compiled into the program.
281
307
 *
282
 
 *      A return code from isc_entropy_createfilesource() or
 
308
 *\li   A return code from isc_entropy_createfilesource() or
283
309
 *      isc_entropy_createcallbacksource().
284
310
 */
285
311