21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

11.7 Using an Entropy Gathering<br />

Daemon–Compatible Solution<br />

<strong>Problem</strong><br />

Your application needs randomness, and you want it to be able to run on Unix-based<br />

platforms that lack the /dev/random and /dev/urandom devices discussed in Recipe<br />

11.3—for example, machines that need to support legacy operating systems.<br />

Solution<br />

Use a third-party software package that gathers and outputs entropy, such as the<br />

Entropy Gathering and Distribution System (EGADS). Then use the Entropy Gathering<br />

Daemon (EGD) interface to read entropy. EGD is a tool for entropy harvesting<br />

and was the first tool to export this API.<br />

When implementing our randomness API from Recipe 11.2, use entropy gathered<br />

over the EGD interface in places where entropy is needed; then, to implement the<br />

rest of the API, use data from that interface to seed an application-level cryptographic<br />

pseudo-random number generator (see Recipe 11.5).<br />

Discussion<br />

A few entropy collection systems exist as processes outside the kernel and distribute<br />

entropy through the EGD socket interface. Such systems set up a server process, listening<br />

on a Unix domain socket. To read entropy, you communicate over that interface<br />

using a simple protocol.<br />

One such system is EGADS (described in the next recipe and available from http://<br />

www.securesoftware.com/egads). Another system is EGD itself, which we do not recommend<br />

as of this writing for several reasons, primarily because we think its entropy<br />

estimates are too liberal.<br />

Such entropy collection systems usually are slow to collect good entropy. If you can<br />

interactively collect input from a user, you might want to use one of the techniques<br />

in Recipe 11.19 instead to force the user to add entropy to the system herself. That<br />

approach will avoid arbitrary hangs as you wait for crucial entropy from an EGDcompatible<br />

system.<br />

The EGD interface is more complex than the standard file interface you get when<br />

dealing with the /dev/random device. Traditionally, you would just read the data<br />

needed. With EGD, however, you must first write one of five commands to the<br />

socket. Each command is a single byte of data:<br />

594 | Chapter 11: Random Numbers<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!