Hi,

The flak blog just had an interesting post about why the old crypt() interface
should be replaced, and on the new crypt_newhash() and crypt_checkpass() that
were added to OpenBSD. I would like to see this API become portable and perhaps
standardized, but crypt_newhash is currently tied to login_cap_t, which is not a
portable abstraction. The current synopsis is:

#include <login_cap.h>
int crypt_newhash(const char *pass, login_cap_t *lc, char *hash, size_t 
hashlen);

The purpose of the lc parameter is to determine which algorithm to use: The
implementation merely does a login_getcapstr(lc, "localcipher", NULL, NULL) call
to convert that into a string telling what algorithm to use. If lc is NULL, then
it defaults to a reasonable algorithm.

It would be superior to move the login_getcapstr call to the caller and instead
have a string parameter. This removes the association with login_cap and it can
be moved to <unistd.h> or <pwd.h> alongside the other functions. It also becomes
more like crypt (where various algorithms can be requested) and thus more
reusable in other situations than local-user authentication (like a web-server).

Jonas

Reply via email to