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.

Discussion<br />

FIPS 140 tests are useful for proving that a stream of random numbers<br />

are weak, but the tests don’t demonstrate at all when the numbers are<br />

good. In particular, it is incredibly easy to have a weak generator yet<br />

still pass FIPS tests by processing data with a cryptographic primitive<br />

like SHA1 before running the tests. FIPS 140 is only useful as a safety<br />

net, for when an entropy source you think is strong turns out not to be.<br />

FIPS 140 is a standard authored by the U.S. National Institute of Standards and<br />

Technology (NIST; see http://csrc.nist.gov/cryptval/). The standard details general<br />

security requirements for cryptographic software deployed in government systems<br />

(primarily cryptographic “providers”). There are many aspects to the FIPS 140 standard,<br />

one of which is a set of tests that all entropy harvesters and pseudo-random<br />

number generators must be able to run to achieve certification.<br />

FIPS 140-1 was the original standard and had several tests for random number<br />

sources; most of these occurred on startup, but one occurred continuously. Those<br />

tests only needed to be implemented for the two highest levels of FIPS compliance<br />

(Levels 3 and 4), which few applications sought.<br />

In FIPS 140-2, only a single test from FIPS 140-1 remains. This test is mandatory any<br />

time a random number generator or entropy source is used.<br />

Although the FIPS 140-1 standard is being obsoleted by 140-2, it is important to note<br />

that a module can routinely fail the FIPS 140-1 tests and still be FIPS 140-1 compliant.<br />

For Level 3 compliance, the user must be able to run the tests on command, and<br />

if the tests fail, the module must go into an error state. For Level 4 compliance, the<br />

module must comply with the requirements of Level 3, plus the tests must be run at<br />

“power-up.” A weak random number generator, such as the one implemented by the<br />

standard C library function rand( ), should be able to get Level 3 certification easily.<br />

FIPS 140-1 testing is a reasonable tool for ensuring that entropy sources are producing<br />

quality data, if those entropy sources are not using any cryptographic operations<br />

internally. If they are, the entropy source will almost certainly pass these tests, even if<br />

it is a very poor entropy source. For the same reason, this set of tests is not good for<br />

testing cryptographic PRNGs, because all such generators will pass these tests with<br />

ease, even if they are poor. For example, simply hashing an incrementing counter<br />

that starts at zero using MD5 will produce a data stream that passes these tests, even<br />

though the data in that stream is easily predictable.<br />

FIPS 140-2 testing generally is not very effective unless a failed hardware device starts<br />

producing a repeating pattern (e.g., a string of zero bits). The FIPS 140-2 test consists<br />

of comparing consecutive generator outputs (on a large boundary size; see the<br />

next section). If your “random number generator” consists only of an ever-incrementing<br />

128-bit counter, you will never fail this test.<br />

616 | 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!