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.

The use of salt means that the attacker would have to produce a totally separate dictionary<br />

for every possible salt value. If the salt is big enough, it essentially makes dictionary<br />

attacks infeasible. However, the attacker can generally still try to guess every<br />

password without using a stronger protocol. For a discussion of various passwordbased<br />

authentication technologies, see Recipe 8.1.<br />

If the salt isn’t chosen at random, certain dictionaries will be more likely than others.<br />

For this reason, salt is generally expected to be random.<br />

Salt can be generated using the techniques discussed in Chapter 11.<br />

Nonces<br />

Nonces * are bits of data often input to cryptographic protocols and algorithms,<br />

including many message authentication codes and some encryption modes. Such values<br />

should only be used a single time with any particular cryptographic key. In fact,<br />

reuse generally isn’t prohibited, but the odds of reuse need to be exceptionally low.<br />

That is, if you have a nonce that is very large compared to the number of times you<br />

expect to use it (e.g., the nonce is 128 bits, and you don’t expect to use it more than<br />

232 times), it is sufficient to choose nonces using a cryptographically strong pseudorandom<br />

number generator.<br />

Sequential nonces have a few advantages over random nonces:<br />

• You can easily guarantee that nonces are not repeated. Note, though, that if the<br />

possible nonce space is large, this is not a big concern.<br />

• Many protocols already send a unique sequence number for each packet, so one<br />

can save space in transmitted messages.<br />

• The sequential ordering of nonces can be used to prevent replay attacks, but<br />

only if you actually check to ensure that the nonce is always incrementing. That<br />

is, if each message has a nonce attached to it, you can tell whether the message<br />

came in the right order, by looking at the nonce and making sure its value is<br />

always incrementing.<br />

However, randomness in a nonce helps prevent against classes of attacks that amortize<br />

work across multiple keys in the same system.<br />

We recommend that nonces have both a random portion and a sequential portion.<br />

Generally, the most significant bytes should be random, and the final 6 to 8 bytes<br />

should be sequential. An 8-byte counter can accommodate 264 messages without the<br />

counter’s repeating, which should be more than big enough for any system.<br />

If you use both a nonce and a salt, you can select a single random part for each key<br />

you use. The nonce on the whole has to be unique, but the salt can remain fixed for<br />

* In the UK, “nonce” is slang for a child sex offender. However, this term is widespread in the cryptographic<br />

world, so we use it.<br />

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