diff --git a/ChangeLog b/ChangeLog index de84c7bb7..62760f988 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-12-09 Ludovic Marcotte + + * SoObject/SOGo/SQLSource.m - added SHA password + hash support for SQL authentication sources. + 2010-12-08 Francis Lachapelle * UI/WebServerResources/MailerUI.js (onMenuEmptyTrashCallback): diff --git a/Documentation/SOGo Installation Guide.odt b/Documentation/SOGo Installation Guide.odt index 08f4637ea..f6219c3c9 100644 Binary files a/Documentation/SOGo Installation Guide.odt and b/Documentation/SOGo Installation Guide.odt differ diff --git a/SoObjects/SOGo/SQLSource.m b/SoObjects/SOGo/SQLSource.m index 7d7f5a9a3..9996315e1 100644 --- a/SoObjects/SOGo/SQLSource.m +++ b/SoObjects/SOGo/SQLSource.m @@ -25,6 +25,7 @@ #include #include +#include #import #import @@ -50,7 +51,7 @@ * * c_uid - will be used for authentication - it's a username or username@domain.tld) * c_name - which can be identical to c_uid - will be used to uniquely identify entries) - * c_password - password of the user, plain-text or md5 encoded for now + * c_password - password of the user, plain-text, md5 or sha encoded for now * c_cn - the user's common name * mail - the user's mail address * @@ -170,6 +171,24 @@ s = [NSString stringWithUTF8String: buf]; return [s isEqualToString: encryptedPassword]; } + else if ([_userPasswordAlgorithm caseInsensitiveCompare: @"sha"] == NSOrderedSame) + { + NSString *s; + + unsigned char sha[SHA_DIGEST_LENGTH]; + char buf[80]; + int i; + + memset(sha, 0, SHA_DIGEST_LENGTH); + memset(buf, 0, 80); + + SHA1((const void *)[plainPassword UTF8String], strlen([plainPassword UTF8String]), sha); + for (i = 0; i < SHA_DIGEST_LENGTH; i++) + sprintf(&(buf[i*2]), "%02x", sha[i]); + + s = [NSString stringWithUTF8String: buf]; + return [s isEqualToString: encryptedPassword]; + } [self errorWithFormat: @"Unsupported user-password algorithm: %@", _userPasswordAlgorithm];