/*
-** Copyright 2001-2002 Double Precision, Inc. See COPYING for
+** Copyright 2001-2008 Double Precision, Inc. See COPYING for
** distribution information.
*/
#endif
#include "auth.h"
#include <sys/time.h>
+#include "md5/md5.h"
+#include "sha1/sha1.h"
-static const char rcsid[]="$Id: cryptpassword.c,v 1.9 2007/10/07 18:33:22 mrsam Exp $";
+static const char rcsid[]="$Id: cryptpassword.c,v 1.10 2008/07/10 02:43:55 mrsam Exp $";
#if HAVE_CRYPT
#if NEED_CRYPT_PROTOTYPE
#endif
#endif
-#if HAVE_MD5LIB
-#include "md5/md5.h"
-#endif
-
-#if HAVE_SHA1LIB
-#include "sha1/sha1.h"
-#endif
-
static const char crypt_salt[65]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./";
static const char *crypt_hash(const char *pw)
return (crypt(pw, salt));
}
-#if HAVE_MD5LIB
static const char *crypt_md5_wrapper(const char *pw)
{
struct timeval tv;
return (md5_crypt(pw, salt));
}
-#endif
char *authcryptpasswd(const char *password, const char *encryption_hint)
{
const char *p;
char *pp;
-#if HAVE_MD5LIB
-
if (!encryption_hint || strncmp(encryption_hint, "$1$", 3) == 0)
{
pfix="";
hash_func= &md5_hash_raw;
pfix="{MD5RAW}";
}
-#endif
-#if HAVE_SHA1LIB
if (!encryption_hint || strncasecmp(encryption_hint, "{SHA}", 5) == 0)
{
hash_func= &sha1_hash;
hash_func= &sha256_hash;
pfix="{SHA256}";
}
-#endif
if (!hash_func)
{