f1dc54a48474887a2673be9ad173a2b1ec708e01
[metze/samba/wip.git] / libcli / auth / ntlm_check.h
1 /* 
2    Unix SMB/CIFS implementation.
3    Password and authentication handling
4    Copyright (C) Andrew Bartlett <abartlet@samba.org> 2001-2004
5    Copyright (C) Gerald Carter                             2003
6    Copyright (C) Luke Kenneth Casson Leighton         1996-2000
7    
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 */
21 #ifndef __LIBCLI_AUTH_NTLM_CHECK_H__
22 #define __LIBCLI_AUTH_NTLM_CHECK_H__
23
24 /* mangled names options */
25 enum ntlm_auth_level {NTLM_AUTH_ON,
26                       NTLM_AUTH_NTLMV2_ONLY,
27                       NTLM_AUTH_MSCHAPv2_NTLMV2_ONLY};
28
29 struct samr_Password;
30
31 /**
32  * Compare password hashes against those from the SAM
33  *
34  * @param mem_ctx talloc context
35  * @param client_lanman LANMAN password hash, as supplied by the client
36  * @param client_nt NT (MD4) password hash, as supplied by the client
37  * @param username internal Samba username, for log messages
38  * @param client_username username the client used
39  * @param client_domain domain name the client used (may be mapped)
40  * @param stored_lanman LANMAN password hash, as stored on the SAM
41  * @param stored_nt NT (MD4) password hash, as stored on the SAM
42  * @param user_sess_key User session key
43  * @param lm_sess_key LM session key (first 8 bytes of the LM hash)
44  */
45
46 NTSTATUS hash_password_check(TALLOC_CTX *mem_ctx,
47                                  bool lanman_auth,
48                              const struct samr_Password *client_lanman,
49                              const struct samr_Password *client_nt,
50                              const char *username, 
51                              const struct samr_Password *stored_lanman, 
52                              const struct samr_Password *stored_nt);
53
54 /**
55  * Check a challenge-response password against the value of the NT or
56  * LM password hash.
57  *
58  * @param mem_ctx talloc context
59  * @param challenge 8-byte challenge.  If all zero, forces plaintext comparison
60  * @param nt_response 'unicode' NT response to the challenge, or unicode password
61  * @param lm_response ASCII or LANMAN response to the challenge, or password in DOS code page
62  * @param username internal Samba username, for log messages
63  * @param client_username username the client used
64  * @param client_domain domain name the client used (may be mapped)
65  * @param stored_lanman LANMAN ASCII password from our passdb or similar
66  * @param stored_nt MD4 unicode password from our passdb or similar
67  * @param user_sess_key User session key
68  * @param lm_sess_key LM session key (first 8 bytes of the LM hash)
69  */
70
71 NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
72                                  bool lanman_auth,
73                                  enum ntlm_auth_level ntlm_auth,
74                              uint32_t logon_parameters,
75                              const DATA_BLOB *challenge,
76                              const DATA_BLOB *lm_response,
77                              const DATA_BLOB *nt_response,
78                              const char *username, 
79                              const char *client_username, 
80                              const char *client_domain,
81                              const struct samr_Password *stored_lanman, 
82                              const struct samr_Password *stored_nt, 
83                              DATA_BLOB *user_sess_key, 
84                              DATA_BLOB *lm_sess_key);
85
86 #endif /* __LIBCLI_AUTH_NTLM_CHECK_H__ */