* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: dnssectool.c,v 1.31 2001/07/22 06:09:42 mayer Exp $ */
+/* $Id: dnssectool.c,v 1.31.2.1 2001/09/06 00:14:15 gson Exp $ */
#include <config.h>
#include <isc/buffer.h>
#include <isc/entropy.h>
-#include <isc/keyboard.h>
#include <isc/string.h>
#include <isc/time.h>
#include <isc/util.h>
void
setup_entropy(isc_mem_t *mctx, const char *randomfile, isc_entropy_t **ectx) {
isc_result_t result;
+ int usekeyboard = ISC_ENTROPY_KEYBOARDMAYBE;
- result = isc_entropy_create(mctx, ectx);
- if (result != ISC_R_SUCCESS)
- fatal("could not create entropy object");
+ REQUIRE(ectx != NULL);
+
+ if (*ectx == NULL) {
+ result = isc_entropy_create(mctx, ectx);
+ if (result != ISC_R_SUCCESS)
+ fatal("could not create entropy object");
+ }
+
+ if (randomfile != NULL && strcmp(randomfile, "keyboard") == 0) {
+ usekeyboard = ISC_ENTROPY_KEYBOARDYES;
+ randomfile = NULL;
+ }
result = isc_entropy_usebestsource(*ectx, &source, randomfile,
- ISC_ENTROPY_KEYBOARDMAYBE);
+ usekeyboard);
if (result != ISC_R_SUCCESS)
fatal("could not initialize entropy source: %s",
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: rndc-confgen.c,v 1.9 2001/08/27 23:55:16 gson Exp $ */
+/* $Id: rndc-confgen.c,v 1.9.2.1 2001/09/06 00:14:16 gson Exp $ */
#include <config.h>
DO("create entropy context", isc_entropy_create(mctx, &ectx));
+ if (randomfile != NULL && strcmp(randomfile, "keyboard") == 0) {
+ randomfile = NULL;
+ open_keyboard = ISC_ENTROPY_KEYBOARDYES;
+ }
DO("start entropy source", isc_entropy_usebestsource(ectx,
&entropy_source,
randomfile,
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: entropy.c,v 1.3 2001/08/28 03:58:26 marka Exp $ */
+/* $Id: entropy.c,v 1.3.2.1 2001/09/06 00:14:17 gson Exp $ */
/*
* This is the system independent part of the entropy module. It is
{
isc_result_t result;
isc_result_t final_result = ISC_R_NOENTROPY;
+ isc_boolean_t userfile = ISC_TRUE;
REQUIRE(VALID_ENTROPY(ectx));
REQUIRE(source != NULL && *source == NULL);
use_keyboard == ISC_ENTROPY_KEYBOARDMAYBE);
#ifdef PATH_RANDOMDEV
- if (randomfile == NULL)
+ if (randomfile == NULL) {
randomfile = PATH_RANDOMDEV;
+ userfile = ISC_FALSE;
+ }
#endif
- if (randomfile != NULL) {
+ if (randomfile != NULL && use_keyboard != ISC_ENTROPY_KEYBOARDYES) {
result = isc_entropy_createfilesource(ectx, randomfile);
if (result == ISC_R_SUCCESS &&
use_keyboard == ISC_ENTROPY_KEYBOARDMAYBE)
use_keyboard = ISC_ENTROPY_KEYBOARDNO;
+ if (result != ISC_R_SUCCESS && userfile)
+ return (result);
final_result = result;
}
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: entropy.h,v 1.23 2001/06/22 17:05:53 tale Exp $ */
+/* $Id: entropy.h,v 1.23.2.1 2001/09/06 00:14:18 gson Exp $ */
#ifndef ISC_ENTROPY_H
#define ISC_ENTROPY_H 1
* For use with isc_entropy_usebestsource().
*
* _KEYBOARDYES
- * Always use the keyboard as an entropy source.
+ * Use the keyboard as the only entropy source.
* _KEYBOARDNO
* Never use the keyboard as an entropy source.
* _KEYBOARDMAYBE
* Use the keyboard as an entropy source only if opening the
- * random device or supplied filename fails.
+ * random device fails.
*/
#define ISC_ENTROPY_KEYBOARDYES 1
#define ISC_ENTROPY_KEYBOARDNO 2