[dovecot-cvs]
dovecot/src/auth mech-ntlm.c, 1.1, 1.2 passdb.c, 1.20,
1.21 passdb.h, 1.11, 1.12 password-scheme-ntlm.c, 1.1,
1.2 password-scheme.c, 1.11, 1.12 password-scheme.h, 1.5, 1.6
cras at dovecot.org
cras at dovecot.org
Fri Jul 30 04:43:23 EEST 2004
Update of /home/cvs/dovecot/src/auth
In directory talvi:/tmp/cvs-serv10552/auth
Modified Files:
mech-ntlm.c passdb.c passdb.h password-scheme-ntlm.c
password-scheme.c password-scheme.h
Log Message:
Added LANMAN password scheme. Patch by Andrey Panin
Index: mech-ntlm.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/mech-ntlm.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- mech-ntlm.c 28 Jul 2004 15:39:29 -0000 1.1
+++ mech-ntlm.c 30 Jul 2004 01:43:21 -0000 1.2
@@ -32,6 +32,36 @@
};
static void
+lm_credentials_callback(const char *credentials,
+ struct auth_request *auth_request)
+{
+ struct ntlm_auth_request *auth =
+ (struct ntlm_auth_request *)auth_request;
+ const unsigned char *client_response;
+ unsigned char lm_response[LM_RESPONSE_SIZE];
+ unsigned char hash[LM_HASH_SIZE];
+ buffer_t *hash_buffer;
+ int ret;
+
+ if (credentials == NULL) {
+ mech_auth_finish(auth_request, NULL, 0, FALSE);
+ return;
+ }
+
+ hash_buffer = buffer_create_data(auth_request->pool,
+ hash, sizeof(hash));
+ hex_to_binary(credentials, hash_buffer);
+
+ client_response = ntlmssp_buffer_data(auth->response, lm_response);
+
+ ntlmssp_v1_response(hash, auth->challenge, lm_response);
+
+ ret = memcmp(lm_response, client_response, LM_RESPONSE_SIZE) == 0;
+
+ mech_auth_finish(auth_request, NULL, 0, ret);
+}
+
+static void
ntlm_credentials_callback(const char *credentials,
struct auth_request *auth_request)
{
@@ -44,7 +74,9 @@
int ret;
if (credentials == NULL) {
- mech_auth_finish(auth_request, NULL, 0, FALSE);
+ passdb->lookup_credentials(auth_request,
+ PASSDB_CREDENTIALS_LANMAN,
+ lm_credentials_callback);
return;
}
Index: passdb.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/passdb.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- passdb.c 28 Jul 2004 15:39:29 -0000 1.20
+++ passdb.c 30 Jul 2004 01:43:21 -0000 1.21
@@ -28,6 +28,8 @@
return "HMAC-MD5";
case PASSDB_CREDENTIALS_DIGEST_MD5:
return "DIGEST-MD5";
+ case PASSDB_CREDENTIALS_LANMAN:
+ return "LANMAN";
case PASSDB_CREDENTIALS_NTLM:
return "NTLM";
}
Index: passdb.h
===================================================================
RCS file: /home/cvs/dovecot/src/auth/passdb.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- passdb.h 28 Jul 2004 15:39:29 -0000 1.11
+++ passdb.h 30 Jul 2004 01:43:21 -0000 1.12
@@ -13,6 +13,7 @@
PASSDB_CREDENTIALS_CRYPT,
PASSDB_CREDENTIALS_CRAM_MD5,
PASSDB_CREDENTIALS_DIGEST_MD5,
+ PASSDB_CREDENTIALS_LANMAN,
PASSDB_CREDENTIALS_NTLM
};
Index: password-scheme-ntlm.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/password-scheme-ntlm.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- password-scheme-ntlm.c 28 Jul 2004 15:39:29 -0000 1.1
+++ password-scheme-ntlm.c 30 Jul 2004 01:43:21 -0000 1.2
@@ -5,11 +5,20 @@
#include "ntlm.h"
-const char *password_generate_ntlm(const char *plaintext)
+const char *password_generate_lm(const char *pw)
{
- unsigned char hash[16];
+ unsigned char hash[LM_HASH_SIZE];
- ntlm_v1_hash(plaintext, hash);
+ lm_hash(pw, hash);
+
+ return binary_to_hex_ucase(hash, sizeof(hash));
+}
+
+const char *password_generate_ntlm(const char *pw)
+{
+ unsigned char hash[NTLMSSP_HASH_SIZE];
+
+ ntlm_v1_hash(pw, hash);
return binary_to_hex_ucase(hash, sizeof(hash));
}
Index: password-scheme.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/password-scheme.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- password-scheme.c 28 Jul 2004 15:39:29 -0000 1.11
+++ password-scheme.c 30 Jul 2004 01:43:21 -0000 1.12
@@ -400,10 +400,22 @@
return memcmp(md5_digest, data, 16) == 0;
}
+static int lm_verify(const char *plaintext, const char *password,
+ const char *user __attr_unused__)
+{
+ return strcasecmp(password, password_generate_lm(plaintext)) == 0;
+}
+
+static const char *lm_generate(const char *plaintext,
+ const char *user __attr_unused__)
+{
+ return password_generate_lm(plaintext);
+}
+
static int ntlm_verify(const char *plaintext, const char *password,
const char *user __attr_unused__)
{
- return strcmp(password, password_generate_ntlm(plaintext)) == 0;
+ return strcasecmp(password, password_generate_ntlm(plaintext)) == 0;
}
static const char *ntlm_generate(const char *plaintext,
@@ -425,6 +437,7 @@
{ "DIGEST-MD5", digest_md5_verify, digest_md5_generate },
{ "PLAIN-MD5", plain_md5_verify, plain_md5_generate },
{ "LDAP-MD5", ldap_md5_verify, ldap_md5_generate },
+ { "LANMAN", lm_verify, lm_generate },
{ "NTLM", ntlm_verify, ntlm_generate },
{ NULL, NULL, NULL }
};
Index: password-scheme.h
===================================================================
RCS file: /home/cvs/dovecot/src/auth/password-scheme.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- password-scheme.h 28 Jul 2004 15:39:29 -0000 1.5
+++ password-scheme.h 30 Jul 2004 01:43:21 -0000 1.6
@@ -30,6 +30,7 @@
/* INTERNAL: */
const char *password_generate_md5_crypt(const char *pw, const char *salt);
const char *password_generate_cram_md5(const char *pw);
+const char *password_generate_lm(const char *pw);
const char *password_generate_ntlm(const char *pw);
#endif
More information about the dovecot-cvs
mailing list