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.

See Also<br />

Recipe 13.2<br />

4.2 Generating Random Symmetric Keys<br />

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

You want to generate a secure symmetric key. You already have some mechanism for<br />

securely transporting the key to anyone who needs it. You need the key to be as<br />

strong as the cipher you’re using, and you want the key to be absolutely independent<br />

of any other data in your system.<br />

Solution<br />

Use one of the recipes in Chapter 11 to collect a byte array of the necessary length<br />

filled with entropy.<br />

When you’re done using a key, you should delete it securely to prevent local attackers<br />

from recovering it from memory. This is discussed in Recipe 13.2.<br />

Discussion<br />

In Recipe 11.2, we present APIs for getting random data, including key material. We<br />

recommend using the spc_keygen( ) function from that API. See that recipe for considerations<br />

on which function to use.<br />

To actually implement spc_keygen( ), use one of the techniques from Chapter 11.<br />

For example, you may want to use the randomness infrastructure that is built into<br />

the operating system (see Recipes 11.3 and 11.4), or you may want to collect your<br />

own entropy, particularly on an embedded platform where the operating system provides<br />

no such services (see Recipes 11.19 through 11.23).<br />

In many cases, you may want to derive short-term keys from a single “master” key.<br />

See Recipe 4.11 for a discussion of how to do so.<br />

Be conservative when choosing a symmetric key length. We recommend 128-bit<br />

symmetric keys. (See Recipe 5.3.)<br />

See Also<br />

Recipes 4.11, 5.3, 11.2, 11.3, 11.4, 11.19, 11.20, 11.21, 11.22, 11.23, 13.2<br />

Generating Random Symmetric Keys | 119<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!