d9898ee8 |
1 | /* |
2 | ** Copyright 2001 Double Precision, Inc. See COPYING for |
3 | ** distribution information. |
4 | */ |
5 | |
6 | #if HAVE_CONFIG_H |
7 | #include "courier_auth_config.h" |
8 | #endif |
9 | #include <string.h> |
10 | #if HAVE_UNISTD_H |
11 | #include <unistd.h> |
12 | #endif |
13 | #include "sha1/sha1.h" |
14 | #include "auth.h" |
15 | |
16 | static const char rcsid[]="$Id: checkpasswordsha1.c,v 1.4 2005/07/10 00:47:37 mrsam Exp $"; |
17 | |
18 | int authcheckpasswordsha1(const char *password, const char *encrypted_password) |
19 | { |
20 | if (strncasecmp(encrypted_password, "{SHA}", 5) == 0) |
21 | { |
22 | return (strcmp(encrypted_password+5, sha1_hash(password))); |
23 | } |
24 | if (strncasecmp(encrypted_password, "{SHA256}", 8) == 0) |
25 | { |
26 | return (strcmp(encrypted_password+8, sha256_hash(password))); |
27 | } |
28 | return (-1); |
29 | } |