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.

from a password. If you make key derivation take a tenth of a second, the user won’t<br />

notice. However, if an attacker tries to carry out an exhaustive search of all possible<br />

passwords, she will have to spend a tenth of a second for each password she wants to<br />

try, which will make cracking even a weak password quite difficult. As we describe in<br />

the sidebar “How Many Iterations?”, we recommend an iteration count of 10,000.<br />

The actual specification of the key derivation function can be found in Version 2.0 of<br />

the PKCS #5 standards document. In brief, we use a pseudo-random function using<br />

the password and salt to get out as many bytes as we need, and we then take those<br />

outputs and feed them back into themselves for each iteration.<br />

There’s no need to use HMAC-SHA1 in PKCS #5. Instead, you could use the<br />

Advanced Encryption Standard (AES) as the underlying cryptographic primitive,<br />

substituting SHA1 for a hash function based on AES (see Recipes 6.15 and 6.16).<br />

See Also<br />

• RSA’s PKCS #5 page: http://www.rsasecurity.com/rsalabs/pkcs/pkcs-5/<br />

• Recipes 4.9, 4.11, 5.26, 6.15, 6.16<br />

4.11 Algorithmically Generating Symmetric Keys<br />

from One Base Secret<br />

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

You want to generate a key to use for a short time from a long-term secret (generally<br />

a key, but perhaps a password). If a short-term key is compromised, it should be<br />

impossible to recover the base secret. Multiple entities in the system should be able<br />

to compute the same derived key if they have the right base secret.<br />

For example, you might want to have a single long-term key and use it to create daily<br />

encryption keys or session-specific keys.<br />

Solution<br />

Mix a base secret and any unique information you have available, passing them<br />

through a pseudo-random function (PRF), as discussed in the following section.<br />

Discussion<br />

The basic idea behind secure key derivation is to take a base secret and a unique<br />

identifier that distinguishes the key to be derived (called a distinguisher) and pass<br />

those two items through a pseudo-random function. The PRF acts very much like a<br />

142 | Chapter 4: Symmetric Cryptography Fundamentals<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!