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.

char *spc_generate_password(char *buf, size_t bufsz) {<br />

size_t choices, i;<br />

choices = strlen(spc_password_characters) - 1;<br />

for (i = 0; i < bufsz - 1; i++) /* leave room for NULL terminator */<br />

buf[i] = spc_password_characters[spc_rand_range(0, choices)];<br />

buf[bufsz - 1] = 0;<br />

return buf;<br />

}<br />

Although there is no conceptual difference between a password and a passphrase,<br />

each has different connotations to users:<br />

Password<br />

Typically one word, short or medium in length (usually under 10 characters, and<br />

rarely longer than 15).<br />

Passphrases<br />

Usually short sentences, or a number of unrelated words grouped together with<br />

no coherent meaning.<br />

While a passphrase can be a long string of random characters and a password can be<br />

multiple words, the typical passphrase is a sentence that the user picks, usually<br />

because it is related to something that is easily remembered. Even though their<br />

length and freeform nature make passphrases much harder to run something such as<br />

the Crack program on, they are still subject to guessing.<br />

For example, if you are trying to guess someone’s passphrase, and you know that<br />

person’s favorite song, trying some lyrics from that song may prove to be a very good<br />

strategy for discovering what the passphrase is. It is important to choose a passphrase<br />

carefully. It should be something easy to remember, but it should not be<br />

something that someone who knows a little bit about you will be able to guess<br />

quickly.<br />

As with passwords, there are times when a randomly generated passphrase is needed.<br />

The strategy for randomly generating a passphrase is not altogether different from<br />

randomly generating a password. Instead of using single characters, whole words are<br />

used, separated by spaces.<br />

The function spc_generate_passphrase( ) uses a data file to obtain the list of words<br />

from which to choose. The words in the file should be ordered one per line, and they<br />

should not be related in any way. In addition, the selection of words should be sufficiently<br />

large that a brute-force attack on generated passphrases is not feasible. Most<br />

Unix systems have a file, /usr/share/dict/words, that contains a large number of words<br />

from the English dictionary.<br />

This implementation of spc_generate_passphrase( ) keeps the word data file open<br />

and builds an in-memory list of the offsets into the file for the beginning of each<br />

word. The function keeps offsets instead of the whole words as a memory-saving<br />

measure, although with a large enough list of words, the amount of memory required<br />

388 | Chapter 8: Authentication and Key Exchange<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!