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.

Distinguisher Selection<br />

The basic idea behind a distinguisher is that it must be unique.<br />

If you want to create a particular derived key, we recommend that you string together<br />

in a predetermined order any interesting information about that key, separating data<br />

items with a unique separation character (i.e., not a character that would be valid in<br />

one of the data items). You can use alternate formats, as long as your data representation<br />

is unambiguous, in that each possible distinguisher is generated by a single,<br />

unique set of information.<br />

As an example, let’s say you want to have a different session key that you change once<br />

a day. You could then use the date as a unique distinguisher. If you want to change keys<br />

every time there’s a connection, the date is no longer unique. However, you could use<br />

the date concatenated with the number of times a connection has been established on<br />

that date. The two together constitute a unique value.<br />

There are many potential data items you might want to include in a distinguisher, and<br />

they do not have to be unique to be useful, as long as there is a guarantee that the distinguisher<br />

itself is unique. Here is a list of some common data items you could use:<br />

• The encryption algorithm and any parameters for which the derived key will be<br />

used<br />

• The number of times the base key has been used, either overall or in the context<br />

of other interesting data items<br />

• A unique identifier corresponding to an entity in the system, such as a username<br />

or email address<br />

• The IP addresses of communicating parties<br />

• A timestamp, or at least the current date<br />

• The MAC address associated with the network interface being used<br />

• Any other session-specific information<br />

In addition, to prevent against any possible offline precomputation attacks, we recommend<br />

you add to your differentiator a random salt of at least 64 bits, which you then<br />

communicate to any other party that needs to derive the same key.<br />

Here is an example implementation of a PRF based on HMAC-SHA1, using the<br />

OpenSSL API for HMAC (discussed in Recipe 6.10):<br />

#include <br />

#include <br />

#include <br />

#include <br />

#include <br />

#define HMAC_OUT_LEN 20 /* SHA1 specific */<br />

void spc_make_derived_key(unsigned char *base, size_t bl, unsigned char *dist,<br />

size_t dl, unsigned char *out, size_t ol) {<br />

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