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.

}<br />

CryptReleaseContext(hProvider, hKey);<br />

return bResult;<br />

The salt is used to prevent against a dictionary attack. Without salt, a malicious system<br />

administrator could easily figure out when a user has the same password as<br />

someone else, and he would be able to precompute a huge dictionary of common<br />

passwords and look to see if the user’s password is in that list.<br />

While salt is not expected to be private, it still must be chosen carefully. See Recipe<br />

4.9 for more on salt.<br />

How Many Iterations?<br />

To what value should you set the iteration count? The answer depends on the environment<br />

in which you expect your software to be deployed. The basic idea is to increase<br />

computational costs so that a brute-force attack with lots of high-end hardware is as<br />

expensive as possible, but not to cause too noticeable a delay on the lowest-end box on<br />

which you would wish to run legitimately.<br />

Often, password computations such as these occur on a server. However, there are still<br />

people out there who run servers on their 33 MHz machines. We personally believe<br />

that people running on that kind of hardware should be able to tolerate a one-second<br />

delay, at the very least when computing a password for a modern application. Usually,<br />

a human waiting on the other end will be willing to tolerate an even longer wait as long<br />

as they know why they are waiting. Two to three seconds isn’t so bad.<br />

With that guideline, we have timed our PKCS #5 implementation with some standard<br />

input. Based on those timings, we think that 10,000 is good for most applications,<br />

and 5,000 is the lowest iteration count you should consider in this day and age.<br />

On a 33 MHz machine, 10,000 iterations should take about 2.5 seconds to process.<br />

On a 1.67 GHz machine, they take a mere 0.045 seconds. Even if your computation<br />

occurs on an embedded processor, people will still be able to tolerate the delay.<br />

The good thing is that it would take a single 1.67 GHz machine more than 6 years to<br />

guess 232 passwords, when using PKCS #5 and 10,000 iterations. Therefore, if there<br />

really is at least 32 bits of entropy in your password (which is very rare), you probably<br />

won’t have to worry about any attacker who has fewer than a hundred high-end<br />

machines at his disposal, at least for a few years.<br />

Expect governments that want your password to put together a few thousand boxes<br />

complete with crypto acceleration, though!<br />

Even with salt, password-guessing attacks are still possible. To prevent against this<br />

kind of attack, PKCS #5 allows the specification of an iteration count, which basically<br />

causes an expensive portion of the key derivation function to loop the specified<br />

number of times. The idea is to slow down the time it takes to compute a single key<br />

Deriving Symmetric Keys from a Password | 141<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!