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.

from choosing insecure passwords. It exports a simple API, consisting of a single<br />

function, FascistCheck( ), which has the following signature:<br />

char *FascistCheck(char *pw, char *dictpath);<br />

This function has the following arguments:<br />

pw<br />

Buffer containing the password that the user is attempting to use.<br />

dictpath<br />

Buffer containing the name of a file that contains a list of dictionary words for<br />

CrackLib to use in its checks.<br />

The dictionary file used by CrackLib is a binary data file (actually, several of them)<br />

that is normally built as part of building CrackLib itself. A small utility built as part<br />

of CrackLib (but not normally installed) reads in a text file containing a list of words<br />

one per line, and builds the binary dictionary files that can be used by CrackLib.<br />

If the FascistCheck( ) function is unable to match the password against the words in<br />

the dictionary and its other tests, it will return NULL to indicate that the password is<br />

secure and may be used safely. Otherwise, an error message (rather than an error<br />

code) is returned; it is suitable for display to the user as a reason why the password<br />

could not be accepted.<br />

CrackLib is intended to be used on Unix systems. It relies on certain Unix-specific<br />

functions to obtain information about users. In addition, it requires a list of words (a<br />

dictionary). Porting CrackLib to Windows should not be too difficult, but we are not<br />

aware of any efforts to do so.<br />

See Also<br />

CrackLib by Alec Muffett: http://www.crypticide.org/users/alecm/<br />

8.7 Prompting for a Password<br />

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

You need to prompt an interactive user for a password.<br />

Solution<br />

On Unix systems, you can use the standard C runtime function getpass( ) if you can<br />

accept limiting passwords to _PASSWORD_LEN, which is typically defined to be 128<br />

characters. If you want to read longer passwords, you can use the function described<br />

in the following “Discussion” section.<br />

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