/*
** Copyright 2001 Double Precision, Inc. See COPYING for
** distribution information.
*/
#if HAVE_CONFIG_H
#include "courier_auth_config.h"
#endif
#include <string.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "sha1/sha1.h"
#include "auth.h"
static const char rcsid[]="$Id: checkpasswordsha1.c,v 1.4 2005/07/10 00:47:37 mrsam Exp $";
int authcheckpasswordsha1(const char *password, const char *encrypted_password)
{
if (strncasecmp(encrypted_password, "{SHA}", 5) == 0)
{
return (strcmp(encrypted_password+5, sha1_hash(password)));
}
if (strncasecmp(encrypted_password, "{SHA256}", 8) == 0)
{
return (strcmp(encrypted_password+8, sha256_hash(password)));
}
return (-1);
}
syntax highlighted by Code2HTML, v. 0.9.1