| 1 | /* |
| 2 | ** Copyright 1998 - 2007 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 "md5/md5.h" |
| 14 | #include "auth.h" |
| 15 | |
| 16 | static const char rcsid[]="$Id: checkpasswordmd5.c,v 1.8 2007/10/07 02:50:45 mrsam Exp $"; |
| 17 | |
| 18 | int authcheckpasswordmd5(const char *password, const char *encrypted_password) |
| 19 | { |
| 20 | if (strncmp(encrypted_password, "$1$", 3) == 0) |
| 21 | { |
| 22 | return (strcmp(encrypted_password, |
| 23 | md5_crypt(password, encrypted_password))); |
| 24 | } |
| 25 | |
| 26 | if (strncasecmp(encrypted_password, "{MD5}", 5) == 0) |
| 27 | { |
| 28 | return (strcmp(encrypted_password+5, md5_hash_courier(password))); |
| 29 | } |
| 30 | if (strncasecmp(encrypted_password, "{MD5RAW}", 8) == 0) |
| 31 | { |
| 32 | return (strcmp(encrypted_password+8, md5_hash_raw(password))); |
| 33 | } |
| 34 | |
| 35 | return (-1); |
| 36 | } |