2 ** Copyright 2001-2008 Double Precision, Inc. See COPYING for
3 ** distribution information.
7 #include "courier_auth_config.h"
9 #include "courierauthsasl.h"
15 #include "sha1/sha1.h"
19 int authcheckpasswordsha1(const char *password
, const char *encrypted_password
)
21 if (strncasecmp(encrypted_password
, "{SHA}", 5) == 0)
23 return (strcmp(encrypted_password
+5, sha1_hash(password
)));
25 if (strncasecmp(encrypted_password
, "{SHA256}", 8) == 0)
27 return (strcmp(encrypted_password
+8, sha256_hash(password
)));
29 if (strncasecmp(encrypted_password
, "{SHA512}", 8) == 0)
31 return (strcmp(encrypted_password
+8, sha512_hash(password
)));
33 if (strncasecmp(encrypted_password
, "{SSHA}", 6) == 0)
39 code
= strdup(encrypted_password
+6);
46 i
= authsasl_frombase64(code
);
48 if(i
== -1 || i
< sizeof(SSHA_RAND
))
54 memcpy((char *)rand
, code
+i
-sizeof(SSHA_RAND
),
57 i
=strcmp(encrypted_password
+6, ssha_hash(password
, rand
));