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.

4.9 Using Salts, Nonces, and Initialization<br />

Vectors<br />

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

You want to use an algorithm that requires a salt, a nonce or an initialization vector<br />

(IV). You need to understand the differences among these three things and figure out<br />

how to select good specimens of each.<br />

Solution<br />

There’s a lot of terminology confusion, and the following “Discussion” section contains<br />

our take on it. Basically, salts and IVs should be random, and nonces are usually<br />

sequential, potentially with a random salt as a component, if there is room. With<br />

sequential nonces, you need to ensure that you never repeat a single {key, nonce}<br />

pairing.<br />

To get good random values, use a well-seeded, cryptographically strong pseudo-random<br />

number generator (see the appropriate recipes in Chapter 11). Using that, get<br />

the necessary number of bits. For salt, 64 bits is sufficient. For an IV, get one of the<br />

requisite size.<br />

Discussion<br />

Salts, nonces, and IVs are all one-time values used in cryptography that don’t need to<br />

be secret, but still lead to additional security. It is generally assumed that these values<br />

are visible to attackers, even if it is sometimes possible to hide them. At the very<br />

least, the security of cryptographic algorithms and protocols should not depend on<br />

the secrecy of such values.<br />

We try to be consistent with respect to this terminology in the book.<br />

However, in the real world, even among cryptographers there’s a lot of<br />

inconsistency. Therefore, be sure to follow the directions in the documentation<br />

for whatever primitive you’re using.<br />

Salts<br />

Salt is random data that helps protect against dictionary and other precomputation<br />

attacks. Generally, salt is used in password-based systems and is concatenated to the<br />

front of a password before processing. Password systems often use a one-way hash<br />

function to turn a password into an “authenticator.” In the simplest such system, if<br />

there were no salt, an attacker could build a dictionary of common passwords and<br />

just look up the original password by authenticator.<br />

Using Salts, Nonces, and Initialization Vectors | 133<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!