21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

0x00<br />

Query the amount of entropy believed to be available. This information is not at<br />

all useful, particularly because you cannot use it in any decision to read data<br />

without causing a race condition.<br />

0x01<br />

Read data if available. This command takes a single-byte argument specifying<br />

how many bytes of data should be read, if that much data is available. If not<br />

enough entropy is available, any available entropy may be immediately returned.<br />

The first byte of the result is the number of bytes being returned, so do not treat<br />

this information as entropy. Note that you can never request or receive more<br />

than 255 bytes of entropy at a time.<br />

0x02<br />

Read data when available. This command takes the same argument as the previous<br />

command. However, if not enough entropy is available, this command will<br />

block until the request can be fulfilled. In addition, the response for the command<br />

is simply the requested bytes; the initial byte is not the number of bytes<br />

being returned.<br />

0x03<br />

Write entropy to the internal collector. This command takes three arguments.<br />

The first is a two-byte value (most significant byte first) specifying how many<br />

bits of entropy are believed to be in the data. The second is a one-byte value<br />

specifying how many bytes of data are to be written. The third is the entropic<br />

data itself.<br />

0x04<br />

Get the process identifier of the EGD process. This returns a byte-long header<br />

that specifies how long the result is in bytes, followed by the actual process identifier,<br />

most significant byte first.<br />

In this recipe, we implement the randomness interface from Recipe 11.2. In addition,<br />

we provide a function called spc_rand_add_entropy( ), which provides an interface<br />

to the command for providing the server with entropy. That function does not<br />

allow the caller to specify an entropy estimate. We believe that user-level processes<br />

should be allowed to contribute data to be put into the mix but shouldn’t be trusted<br />

to estimate entropy, primarily because you may have just cause not to trust the estimates<br />

of other processes running on the same machine that might be adding entropy.<br />

That is, if you are using an entropy server that gathers entropy slowly, you do not<br />

want an attacker from another process adding a big known value to the entropy system<br />

and claiming that it has 1,000 bits of entropy.<br />

In part because untrusted programs can add bad entropy to the mix, we recommend<br />

using a highly conservative solution where such an attack is not likely to be effective.<br />

That means staying away from EGD, which will use estimates from any untrusted<br />

Using an Entropy Gathering Daemon–Compatible Solution | 595<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!