2 Unix SMB/CIFS implementation.
3 SMB parameters and setup
4 Copyright (C) Andrew Tridgell 1992-1997
5 Copyright (C) Luke Kenneth Casson Leighton 1996-1997
6 Copyright (C) Paul Ashton 1997
7 Copyright (C) Andrew Bartlett 2010
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "../librpc/gen_ndr/ntlmssp.h"
32 /* NTLMSSP message types */
33 enum ntlmssp_message_type
35 NTLMSSP_INITIAL
= 0 /* samba internal state */,
36 NTLMSSP_NEGOTIATE
= 1,
37 NTLMSSP_CHALLENGE
= 2,
40 NTLMSSP_DONE
= 5 /* samba final state */
43 #define NTLMSSP_FEATURE_SESSION_KEY 0x00000001
44 #define NTLMSSP_FEATURE_SIGN 0x00000002
45 #define NTLMSSP_FEATURE_SEAL 0x00000004
46 #define NTLMSSP_FEATURE_CCACHE 0x00000008
48 union ntlmssp_crypt_state
;
52 enum ntlmssp_role role
;
53 uint32_t expected_state
;
58 bool use_nt_response
; /* Set to 'False' to debug what happens when the NT response is omited */
59 bool allow_lm_key
; /* The LM_KEY code is not very secure... */
67 const char *netbios_name
;
68 const char *netbios_domain
;
73 const char *netbios_name
;
74 const char *netbios_domain
;
76 const char *dns_domain
;
79 DATA_BLOB internal_chal
; /* Random challenge as supplied to the client for NTLM authentication */
81 DATA_BLOB chal
; /* Random challenge as input into the actual NTLM (or NTLM2) authentication */
84 DATA_BLOB session_key
;
86 uint32_t neg_flags
; /* the current state of negotiation with the NTLMSSP partner */
89 * Private data for the callback functions
91 void *callback_private
;
94 * Callback to get the 'challenge' used for NTLM authentication.
96 * @param ntlmssp_state This structure
97 * @return 8 bytes of challenge data, determined by the server to be the challenge for NTLM authentication
100 NTSTATUS (*get_challenge
)(const struct ntlmssp_state
*ntlmssp_state
,
101 uint8_t challenge
[8]);
104 * Callback to find if the challenge used by NTLM authentication may be modified
106 * The NTLM2 authentication scheme modifies the effective challenge, but this is not compatiable with the
107 * current 'security=server' implementation..
109 * @param ntlmssp_state This structure
110 * @return Can the challenge be set to arbitary values?
113 bool (*may_set_challenge
)(const struct ntlmssp_state
*ntlmssp_state
);
116 * Callback to set the 'challenge' used for NTLM authentication.
118 * The callback may use the void *auth_context to store state information, but the same value is always available
119 * from the DATA_BLOB chal on this structure.
121 * @param ntlmssp_state This structure
122 * @param challenge 8 bytes of data, agreed by the client and server to be the effective challenge for NTLM2 authentication
125 NTSTATUS (*set_challenge
)(struct ntlmssp_state
*ntlmssp_state
, DATA_BLOB
*challenge
);
128 * Callback to check the user's password.
130 * The callback must reads the feilds of this structure for the information it needs on the user
131 * @param ntlmssp_state This structure
132 * @param mem_ctx Talloc context for LM and NT session key to be returned on
133 * @param nt_session_key If an NT session key is returned by the authentication process, return it here
134 * @param lm_session_key If an LM session key is returned by the authentication process, return it here
137 NTSTATUS (*check_password
)(struct ntlmssp_state
*ntlmssp_state
, TALLOC_CTX
*mem_ctx
,
138 DATA_BLOB
*nt_session_key
, DATA_BLOB
*lm_session_key
);
140 union ntlmssp_crypt_state
*crypt
;
143 /* The following definitions come from libcli/auth/ntlmssp_sign.c */
145 NTSTATUS
ntlmssp_sign_packet(struct ntlmssp_state
*ntlmssp_state
,
146 TALLOC_CTX
*sig_mem_ctx
,
147 const uint8_t *data
, size_t length
,
148 const uint8_t *whole_pdu
, size_t pdu_length
,
150 NTSTATUS
ntlmssp_check_packet(struct ntlmssp_state
*ntlmssp_state
,
151 const uint8_t *data
, size_t length
,
152 const uint8_t *whole_pdu
, size_t pdu_length
,
153 const DATA_BLOB
*sig
) ;
154 NTSTATUS
ntlmssp_seal_packet(struct ntlmssp_state
*ntlmssp_state
,
155 TALLOC_CTX
*sig_mem_ctx
,
156 uint8_t *data
, size_t length
,
157 const uint8_t *whole_pdu
, size_t pdu_length
,
159 NTSTATUS
ntlmssp_unseal_packet(struct ntlmssp_state
*ntlmssp_state
,
160 uint8_t *data
, size_t length
,
161 const uint8_t *whole_pdu
, size_t pdu_length
,
162 const DATA_BLOB
*sig
);
163 NTSTATUS
ntlmssp_sign_init(struct ntlmssp_state
*ntlmssp_state
);