2 Unix SMB/Netbios implementation.
4 handle NLTMSSP, server side
6 Copyright (C) Andrew Tridgell 2001
7 Copyright (C) Andrew Bartlett 2001-2003
8 Copyright (C) Andrew Bartlett 2005 (Updated from gensec).
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #include "../libcli/auth/ntlmssp.h"
26 #include "../libcli/auth/ntlmssp_private.h"
27 #include "../libcli/auth/libcli_auth.h"
28 #include "../librpc/gen_ndr/ndr_ntlmssp.h"
29 #include "../libcli/auth/ntlmssp_ndr.h"
30 #include "../lib/crypto/md5.h"
31 #include "../lib/crypto/arcfour.h"
32 #include "../lib/crypto/hmacmd5.h"
34 static NTSTATUS
ntlmssp_client_initial(struct ntlmssp_state
*ntlmssp_state
,
35 DATA_BLOB reply
, DATA_BLOB
*next_request
);
36 static NTSTATUS
ntlmssp_server_negotiate(struct ntlmssp_state
*ntlmssp_state
,
37 const DATA_BLOB in
, DATA_BLOB
*out
);
38 static NTSTATUS
ntlmssp_client_challenge(struct ntlmssp_state
*ntlmssp_state
,
39 const DATA_BLOB reply
, DATA_BLOB
*next_request
);
40 static NTSTATUS
ntlmssp_server_auth(struct ntlmssp_state
*ntlmssp_state
,
41 const DATA_BLOB request
, DATA_BLOB
*reply
);
44 * Callbacks for NTLMSSP - for both client and server operating modes
48 static const struct ntlmssp_callbacks
{
49 enum ntlmssp_role role
;
50 enum ntlmssp_message_type ntlmssp_command
;
51 NTSTATUS (*fn
)(struct ntlmssp_state
*ntlmssp_state
,
52 DATA_BLOB in
, DATA_BLOB
*out
);
53 } ntlmssp_callbacks
[] = {
54 {NTLMSSP_CLIENT
, NTLMSSP_INITIAL
, ntlmssp_client_initial
},
55 {NTLMSSP_SERVER
, NTLMSSP_NEGOTIATE
, ntlmssp_server_negotiate
},
56 {NTLMSSP_CLIENT
, NTLMSSP_CHALLENGE
, ntlmssp_client_challenge
},
57 {NTLMSSP_SERVER
, NTLMSSP_AUTH
, ntlmssp_server_auth
},
58 {NTLMSSP_CLIENT
, NTLMSSP_UNKNOWN
, NULL
},
59 {NTLMSSP_SERVER
, NTLMSSP_UNKNOWN
, NULL
}
64 * Default challenge generation code.
68 static NTSTATUS
get_challenge(const struct ntlmssp_state
*ntlmssp_state
,
71 generate_random_buffer(chal
, 8);
76 * Default 'we can set the challenge to anything we like' implementation
80 static bool may_set_challenge(const struct ntlmssp_state
*ntlmssp_state
)
86 * Default 'we can set the challenge to anything we like' implementation
88 * Does not actually do anything, as the value is always in the structure anyway.
92 static NTSTATUS
set_challenge(struct ntlmssp_state
*ntlmssp_state
, DATA_BLOB
*challenge
)
94 SMB_ASSERT(challenge
->length
== 8);
99 * Set a username on an NTLMSSP context - ensures it is talloc()ed
103 NTSTATUS
ntlmssp_set_username(struct ntlmssp_state
*ntlmssp_state
, const char *user
)
105 ntlmssp_state
->user
= talloc_strdup(ntlmssp_state
, user
? user
: "" );
106 if (!ntlmssp_state
->user
) {
107 return NT_STATUS_NO_MEMORY
;
113 * Store NT and LM hashes on an NTLMSSP context - ensures they are talloc()ed
116 NTSTATUS
ntlmssp_set_hashes(struct ntlmssp_state
*ntlmssp_state
,
117 const uint8_t lm_hash
[16],
118 const uint8_t nt_hash
[16])
120 ntlmssp_state
->lm_hash
= (uint8_t *)
121 TALLOC_MEMDUP(ntlmssp_state
, lm_hash
, 16);
122 ntlmssp_state
->nt_hash
= (uint8_t *)
123 TALLOC_MEMDUP(ntlmssp_state
, nt_hash
, 16);
124 if (!ntlmssp_state
->lm_hash
|| !ntlmssp_state
->nt_hash
) {
125 TALLOC_FREE(ntlmssp_state
->lm_hash
);
126 TALLOC_FREE(ntlmssp_state
->nt_hash
);
127 return NT_STATUS_NO_MEMORY
;
133 * Converts a password to the hashes on an NTLMSSP context.
136 NTSTATUS
ntlmssp_set_password(struct ntlmssp_state
*ntlmssp_state
, const char *password
)
139 ntlmssp_state
->lm_hash
= NULL
;
140 ntlmssp_state
->nt_hash
= NULL
;
145 E_deshash(password
, lm_hash
);
146 E_md4hash(password
, nt_hash
);
147 return ntlmssp_set_hashes(ntlmssp_state
, lm_hash
, nt_hash
);
153 * Set a domain on an NTLMSSP context - ensures it is talloc()ed
156 NTSTATUS
ntlmssp_set_domain(struct ntlmssp_state
*ntlmssp_state
, const char *domain
)
158 ntlmssp_state
->domain
= talloc_strdup(ntlmssp_state
,
159 domain
? domain
: "" );
160 if (!ntlmssp_state
->domain
) {
161 return NT_STATUS_NO_MEMORY
;
167 * Request features for the NTLMSSP negotiation
169 * @param ntlmssp_state NTLMSSP state
170 * @param feature_list List of space seperated features requested from NTLMSSP.
172 void ntlmssp_want_feature_list(struct ntlmssp_state
*ntlmssp_state
, char *feature_list
)
175 * We need to set this to allow a later SetPassword
176 * via the SAMR pipe to succeed. Strange.... We could
177 * also add NTLMSSP_NEGOTIATE_SEAL here. JRA.
179 if (in_list("NTLMSSP_FEATURE_SESSION_KEY", feature_list
, True
)) {
180 ntlmssp_state
->neg_flags
|= NTLMSSP_NEGOTIATE_SIGN
;
182 if (in_list("NTLMSSP_FEATURE_SIGN", feature_list
, True
)) {
183 ntlmssp_state
->neg_flags
|= NTLMSSP_NEGOTIATE_SIGN
;
185 if(in_list("NTLMSSP_FEATURE_SEAL", feature_list
, True
)) {
186 ntlmssp_state
->neg_flags
|= NTLMSSP_NEGOTIATE_SEAL
;
188 if (in_list("NTLMSSP_FEATURE_CCACHE", feature_list
, true)) {
189 ntlmssp_state
->use_ccache
= true;
194 * Request a feature for the NTLMSSP negotiation
196 * @param ntlmssp_state NTLMSSP state
197 * @param feature Bit flag specifying the requested feature
199 void ntlmssp_want_feature(struct ntlmssp_state
*ntlmssp_state
, uint32_t feature
)
201 /* As per JRA's comment above */
202 if (feature
& NTLMSSP_FEATURE_SESSION_KEY
) {
203 ntlmssp_state
->neg_flags
|= NTLMSSP_NEGOTIATE_SIGN
;
205 if (feature
& NTLMSSP_FEATURE_SIGN
) {
206 ntlmssp_state
->neg_flags
|= NTLMSSP_NEGOTIATE_SIGN
;
208 if (feature
& NTLMSSP_FEATURE_SEAL
) {
209 ntlmssp_state
->neg_flags
|= NTLMSSP_NEGOTIATE_SEAL
;
211 if (feature
& NTLMSSP_FEATURE_CCACHE
) {
212 ntlmssp_state
->use_ccache
= true;
217 * Next state function for the NTLMSSP state machine
219 * @param ntlmssp_state NTLMSSP State
220 * @param in The packet in from the NTLMSSP partner, as a DATA_BLOB
221 * @param out The reply, as an allocated DATA_BLOB, caller to free.
222 * @return Errors, NT_STATUS_MORE_PROCESSING_REQUIRED or NT_STATUS_OK.
225 NTSTATUS
ntlmssp_update(struct ntlmssp_state
*ntlmssp_state
,
226 const DATA_BLOB input
, DATA_BLOB
*out
)
228 uint32_t ntlmssp_command
;
231 if (ntlmssp_state
->expected_state
== NTLMSSP_DONE
) {
232 /* Called update after negotiations finished. */
233 DEBUG(1, ("Called NTLMSSP after state machine was 'done'\n"));
234 return NT_STATUS_INVALID_PARAMETER
;
237 *out
= data_blob_null
;
240 switch (ntlmssp_state
->role
) {
242 ntlmssp_command
= NTLMSSP_INITIAL
;
245 /* 'datagram' mode - no neg packet */
246 ntlmssp_command
= NTLMSSP_NEGOTIATE
;
250 if (!msrpc_parse(ntlmssp_state
, &input
, "Cd",
253 DEBUG(1, ("Failed to parse NTLMSSP packet, could not extract NTLMSSP command\n"));
254 dump_data(2, input
.data
, input
.length
);
255 return NT_STATUS_INVALID_PARAMETER
;
259 if (ntlmssp_command
!= ntlmssp_state
->expected_state
) {
260 DEBUG(1, ("got NTLMSSP command %u, expected %u\n", ntlmssp_command
, ntlmssp_state
->expected_state
));
261 return NT_STATUS_INVALID_PARAMETER
;
264 for (i
=0; ntlmssp_callbacks
[i
].fn
; i
++) {
265 if (ntlmssp_callbacks
[i
].role
== ntlmssp_state
->role
266 && ntlmssp_callbacks
[i
].ntlmssp_command
== ntlmssp_command
) {
267 return ntlmssp_callbacks
[i
].fn(ntlmssp_state
, input
, out
);
271 DEBUG(1, ("failed to find NTLMSSP callback for NTLMSSP mode %u, command %u\n",
272 ntlmssp_state
->role
, ntlmssp_command
));
274 return NT_STATUS_INVALID_PARAMETER
;
278 * End an NTLMSSP state machine
280 * @param ntlmssp_state NTLMSSP State, free()ed by this function
283 void ntlmssp_end(struct ntlmssp_state
**ntlmssp_state
)
285 data_blob_free(&(*ntlmssp_state
)->chal
);
286 data_blob_free(&(*ntlmssp_state
)->lm_resp
);
287 data_blob_free(&(*ntlmssp_state
)->nt_resp
);
288 TALLOC_FREE(*ntlmssp_state
);
290 *ntlmssp_state
= NULL
;
295 * Determine correct target name flags for reply, given server role
296 * and negotiated flags
298 * @param ntlmssp_state NTLMSSP State
299 * @param neg_flags The flags from the packet
300 * @param chal_flags The flags to be set in the reply packet
301 * @return The 'target name' string.
304 static const char *ntlmssp_target_name(struct ntlmssp_state
*ntlmssp_state
,
305 uint32_t neg_flags
, uint32_t *chal_flags
)
307 if (neg_flags
& NTLMSSP_REQUEST_TARGET
) {
308 *chal_flags
|= NTLMSSP_NEGOTIATE_TARGET_INFO
;
309 *chal_flags
|= NTLMSSP_REQUEST_TARGET
;
310 if (ntlmssp_state
->server
.is_standalone
) {
311 *chal_flags
|= NTLMSSP_TARGET_TYPE_SERVER
;
312 return ntlmssp_state
->server
.netbios_name
;
314 *chal_flags
|= NTLMSSP_TARGET_TYPE_DOMAIN
;
315 return ntlmssp_state
->server
.netbios_domain
;
322 static void ntlmssp_handle_neg_flags(struct ntlmssp_state
*ntlmssp_state
,
323 uint32_t neg_flags
, bool allow_lm
) {
324 if (neg_flags
& NTLMSSP_NEGOTIATE_UNICODE
) {
325 ntlmssp_state
->neg_flags
|= NTLMSSP_NEGOTIATE_UNICODE
;
326 ntlmssp_state
->neg_flags
&= ~NTLMSSP_NEGOTIATE_OEM
;
327 ntlmssp_state
->unicode
= True
;
329 ntlmssp_state
->neg_flags
&= ~NTLMSSP_NEGOTIATE_UNICODE
;
330 ntlmssp_state
->neg_flags
|= NTLMSSP_NEGOTIATE_OEM
;
331 ntlmssp_state
->unicode
= False
;
334 if ((neg_flags
& NTLMSSP_NEGOTIATE_LM_KEY
) && allow_lm
) {
335 /* other end forcing us to use LM */
336 ntlmssp_state
->neg_flags
|= NTLMSSP_NEGOTIATE_LM_KEY
;
337 ntlmssp_state
->use_ntlmv2
= False
;
339 ntlmssp_state
->neg_flags
&= ~NTLMSSP_NEGOTIATE_LM_KEY
;
342 if (!(neg_flags
& NTLMSSP_NEGOTIATE_ALWAYS_SIGN
)) {
343 ntlmssp_state
->neg_flags
&= ~NTLMSSP_NEGOTIATE_ALWAYS_SIGN
;
346 if (!(neg_flags
& NTLMSSP_NEGOTIATE_NTLM2
)) {
347 ntlmssp_state
->neg_flags
&= ~NTLMSSP_NEGOTIATE_NTLM2
;
350 if (!(neg_flags
& NTLMSSP_NEGOTIATE_128
)) {
351 ntlmssp_state
->neg_flags
&= ~NTLMSSP_NEGOTIATE_128
;
354 if (!(neg_flags
& NTLMSSP_NEGOTIATE_56
)) {
355 ntlmssp_state
->neg_flags
&= ~NTLMSSP_NEGOTIATE_56
;
358 if (!(neg_flags
& NTLMSSP_NEGOTIATE_KEY_EXCH
)) {
359 ntlmssp_state
->neg_flags
&= ~NTLMSSP_NEGOTIATE_KEY_EXCH
;
362 if (!(neg_flags
& NTLMSSP_NEGOTIATE_SIGN
)) {
363 ntlmssp_state
->neg_flags
&= ~NTLMSSP_NEGOTIATE_SIGN
;
366 if (!(neg_flags
& NTLMSSP_NEGOTIATE_SEAL
)) {
367 ntlmssp_state
->neg_flags
&= ~NTLMSSP_NEGOTIATE_SEAL
;
370 /* Woop Woop - unknown flag for Windows compatibility...
371 What does this really do ? JRA. */
372 if (!(neg_flags
& NTLMSSP_NEGOTIATE_VERSION
)) {
373 ntlmssp_state
->neg_flags
&= ~NTLMSSP_NEGOTIATE_VERSION
;
376 if ((neg_flags
& NTLMSSP_REQUEST_TARGET
)) {
377 ntlmssp_state
->neg_flags
|= NTLMSSP_REQUEST_TARGET
;
382 * Next state function for the Negotiate packet
384 * @param ntlmssp_state NTLMSSP State
385 * @param request The request, as a DATA_BLOB
386 * @param request The reply, as an allocated DATA_BLOB, caller to free.
387 * @return Errors or MORE_PROCESSING_REQUIRED if a reply is sent.
390 static NTSTATUS
ntlmssp_server_negotiate(struct ntlmssp_state
*ntlmssp_state
,
391 const DATA_BLOB request
, DATA_BLOB
*reply
)
393 DATA_BLOB struct_blob
;
394 uint32_t neg_flags
= 0;
395 uint32_t ntlmssp_command
, chal_flags
;
397 const char *target_name
;
398 struct NEGOTIATE_MESSAGE negotiate
;
399 struct CHALLENGE_MESSAGE challenge
;
402 /* parse the NTLMSSP packet */
404 file_save("ntlmssp_negotiate.dat", request
.data
, request
.length
);
407 if (request
.length
) {
408 if ((request
.length
< 16) || !msrpc_parse(ntlmssp_state
, &request
, "Cdd",
412 DEBUG(1, ("ntlmssp_server_negotiate: failed to parse NTLMSSP Negotiate of length %u\n",
413 (unsigned int)request
.length
));
414 dump_data(2, request
.data
, request
.length
);
415 return NT_STATUS_INVALID_PARAMETER
;
417 debug_ntlmssp_flags(neg_flags
);
419 if (DEBUGLEVEL
>= 10) {
420 if (NT_STATUS_IS_OK(ntlmssp_pull_NEGOTIATE_MESSAGE(&request
,
424 NDR_PRINT_DEBUG(NEGOTIATE_MESSAGE
, &negotiate
);
429 ntlmssp_handle_neg_flags(ntlmssp_state
, neg_flags
, lp_lanman_auth());
431 /* Ask our caller what challenge they would like in the packet */
432 status
= ntlmssp_state
->get_challenge(ntlmssp_state
, cryptkey
);
433 if (!NT_STATUS_IS_OK(status
)) {
437 /* Check if we may set the challenge */
438 if (!ntlmssp_state
->may_set_challenge(ntlmssp_state
)) {
439 ntlmssp_state
->neg_flags
&= ~NTLMSSP_NEGOTIATE_NTLM2
;
442 /* The flags we send back are not just the negotiated flags,
443 * they are also 'what is in this packet'. Therfore, we
444 * operate on 'chal_flags' from here on
447 chal_flags
= ntlmssp_state
->neg_flags
;
449 /* get the right name to fill in as 'target' */
450 target_name
= ntlmssp_target_name(ntlmssp_state
,
451 neg_flags
, &chal_flags
);
452 if (target_name
== NULL
)
453 return NT_STATUS_INVALID_PARAMETER
;
455 ntlmssp_state
->chal
= data_blob_talloc(ntlmssp_state
, cryptkey
, 8);
456 ntlmssp_state
->internal_chal
= data_blob_talloc(ntlmssp_state
,
459 /* This creates the 'blob' of names that appears at the end of the packet */
460 if (chal_flags
& NTLMSSP_NEGOTIATE_TARGET_INFO
)
462 msrpc_gen(ntlmssp_state
, &struct_blob
, "aaaaa",
463 MsvAvNbDomainName
, target_name
,
464 MsvAvNbComputerName
, ntlmssp_state
->server
.netbios_name
,
465 MsvAvDnsDomainName
, ntlmssp_state
->server
.dns_domain
,
466 MsvAvDnsComputerName
, ntlmssp_state
->server
.dns_name
,
469 struct_blob
= data_blob_null
;
473 /* Marshal the packet in the right format, be it unicode or ASCII */
474 const char *gen_string
;
475 DATA_BLOB version_blob
= data_blob_null
;
477 if (chal_flags
& NTLMSSP_NEGOTIATE_VERSION
) {
478 enum ndr_err_code err
;
481 /* "What Windows returns" as a version number. */
483 vers
.ProductMajorVersion
= NTLMSSP_WINDOWS_MAJOR_VERSION_6
;
484 vers
.ProductMinorVersion
= NTLMSSP_WINDOWS_MINOR_VERSION_1
;
485 vers
.ProductBuild
= 0;
486 vers
.NTLMRevisionCurrent
= NTLMSSP_REVISION_W2K3
;
488 err
= ndr_push_struct_blob(&version_blob
,
491 (ndr_push_flags_fn_t
)ndr_push_VERSION
);
493 if (!NDR_ERR_CODE_IS_SUCCESS(err
)) {
494 return NT_STATUS_NO_MEMORY
;
498 if (ntlmssp_state
->unicode
) {
499 gen_string
= "CdUdbddBb";
501 gen_string
= "CdAdbddBb";
504 msrpc_gen(ntlmssp_state
, reply
, gen_string
,
511 struct_blob
.data
, struct_blob
.length
,
512 version_blob
.data
, version_blob
.length
);
514 data_blob_free(&version_blob
);
516 if (DEBUGLEVEL
>= 10) {
517 if (NT_STATUS_IS_OK(ntlmssp_pull_CHALLENGE_MESSAGE(reply
,
521 NDR_PRINT_DEBUG(CHALLENGE_MESSAGE
, &challenge
);
526 data_blob_free(&struct_blob
);
528 ntlmssp_state
->expected_state
= NTLMSSP_AUTH
;
530 return NT_STATUS_MORE_PROCESSING_REQUIRED
;
534 * Next state function for the Authenticate packet
536 * @param ntlmssp_state NTLMSSP State
537 * @param request The request, as a DATA_BLOB
538 * @param request The reply, as an allocated DATA_BLOB, caller to free.
539 * @return Errors or NT_STATUS_OK.
542 static NTSTATUS
ntlmssp_server_auth(struct ntlmssp_state
*ntlmssp_state
,
543 const DATA_BLOB request
, DATA_BLOB
*reply
)
545 DATA_BLOB encrypted_session_key
= data_blob_null
;
546 DATA_BLOB user_session_key
= data_blob_null
;
547 DATA_BLOB lm_session_key
= data_blob_null
;
548 DATA_BLOB session_key
= data_blob_null
;
549 uint32_t ntlmssp_command
, auth_flags
;
550 NTSTATUS nt_status
= NT_STATUS_OK
;
551 struct AUTHENTICATE_MESSAGE authenticate
;
554 bool doing_ntlm2
= False
;
556 uint8_t session_nonce
[16];
557 uint8_t session_nonce_hash
[16];
559 const char *parse_string
;
561 /* parse the NTLMSSP packet */
562 *reply
= data_blob_null
;
565 file_save("ntlmssp_auth.dat", request
.data
, request
.length
);
568 if (ntlmssp_state
->unicode
) {
569 parse_string
= "CdBBUUUBd";
571 parse_string
= "CdBBAAABd";
574 data_blob_free(&ntlmssp_state
->lm_resp
);
575 data_blob_free(&ntlmssp_state
->nt_resp
);
577 ntlmssp_state
->user
= NULL
;
578 ntlmssp_state
->domain
= NULL
;
580 /* now the NTLMSSP encoded auth hashes */
581 if (!msrpc_parse(ntlmssp_state
, &request
, parse_string
,
584 &ntlmssp_state
->lm_resp
,
585 &ntlmssp_state
->nt_resp
,
586 &ntlmssp_state
->domain
,
587 &ntlmssp_state
->user
,
588 &ntlmssp_state
->client
.netbios_name
,
589 &encrypted_session_key
,
593 /* Try again with a shorter string (Win9X truncates this packet) */
594 if (ntlmssp_state
->unicode
) {
595 parse_string
= "CdBBUUU";
597 parse_string
= "CdBBAAA";
600 /* now the NTLMSSP encoded auth hashes */
601 if (!msrpc_parse(ntlmssp_state
, &request
, parse_string
,
604 &ntlmssp_state
->lm_resp
,
605 &ntlmssp_state
->nt_resp
,
606 &ntlmssp_state
->domain
,
607 &ntlmssp_state
->user
,
608 &ntlmssp_state
->client
.netbios_name
)) {
609 DEBUG(1, ("ntlmssp_server_auth: failed to parse NTLMSSP (tried both formats):\n"));
610 dump_data(2, request
.data
, request
.length
);
612 return NT_STATUS_INVALID_PARAMETER
;
617 ntlmssp_handle_neg_flags(ntlmssp_state
, auth_flags
, lp_lanman_auth());
619 if (DEBUGLEVEL
>= 10) {
620 if (NT_STATUS_IS_OK(ntlmssp_pull_AUTHENTICATE_MESSAGE(&request
,
624 NDR_PRINT_DEBUG(AUTHENTICATE_MESSAGE
, &authenticate
);
628 DEBUG(3,("Got user=[%s] domain=[%s] workstation=[%s] len1=%lu len2=%lu\n",
629 ntlmssp_state
->user
, ntlmssp_state
->domain
,
630 ntlmssp_state
->client
.netbios_name
,
631 (unsigned long)ntlmssp_state
->lm_resp
.length
,
632 (unsigned long)ntlmssp_state
->nt_resp
.length
));
635 file_save("nthash1.dat", &ntlmssp_state
->nt_resp
.data
, &ntlmssp_state
->nt_resp
.length
);
636 file_save("lmhash1.dat", &ntlmssp_state
->lm_resp
.data
, &ntlmssp_state
->lm_resp
.length
);
639 /* NTLM2 uses a 'challenge' that is made of up both the server challenge, and a
642 However, the NTLM2 flag may still be set for the real NTLMv2 logins, be careful.
644 if (ntlmssp_state
->neg_flags
& NTLMSSP_NEGOTIATE_NTLM2
) {
645 if (ntlmssp_state
->nt_resp
.length
== 24 && ntlmssp_state
->lm_resp
.length
== 24) {
646 struct MD5Context md5_session_nonce_ctx
;
647 SMB_ASSERT(ntlmssp_state
->internal_chal
.data
&& ntlmssp_state
->internal_chal
.length
== 8);
651 memcpy(session_nonce
, ntlmssp_state
->internal_chal
.data
, 8);
652 memcpy(&session_nonce
[8], ntlmssp_state
->lm_resp
.data
, 8);
654 MD5Init(&md5_session_nonce_ctx
);
655 MD5Update(&md5_session_nonce_ctx
, session_nonce
, 16);
656 MD5Final(session_nonce_hash
, &md5_session_nonce_ctx
);
658 ntlmssp_state
->chal
= data_blob_talloc(
659 ntlmssp_state
, session_nonce_hash
, 8);
661 /* LM response is no longer useful */
662 data_blob_free(&ntlmssp_state
->lm_resp
);
664 /* We changed the effective challenge - set it */
665 if (!NT_STATUS_IS_OK(nt_status
= ntlmssp_state
->set_challenge(ntlmssp_state
, &ntlmssp_state
->chal
))) {
666 data_blob_free(&encrypted_session_key
);
670 /* LM Key is incompatible. */
671 ntlmssp_state
->neg_flags
&= ~NTLMSSP_NEGOTIATE_LM_KEY
;
676 * Note we don't check here for NTLMv2 auth settings. If NTLMv2 auth
677 * is required (by "ntlm auth = no" and "lm auth = no" being set in the
678 * smb.conf file) and no NTLMv2 response was sent then the password check
679 * will fail here. JRA.
682 /* Finally, actually ask if the password is OK */
684 if (!NT_STATUS_IS_OK(nt_status
= ntlmssp_state
->check_password(ntlmssp_state
,
685 &user_session_key
, &lm_session_key
))) {
686 data_blob_free(&encrypted_session_key
);
690 dump_data_pw("NT session key:\n", user_session_key
.data
, user_session_key
.length
);
691 dump_data_pw("LM first-8:\n", lm_session_key
.data
, lm_session_key
.length
);
693 /* Handle the different session key derivation for NTLM2 */
695 if (user_session_key
.data
&& user_session_key
.length
== 16) {
696 session_key
= data_blob_talloc(ntlmssp_state
,
698 hmac_md5(user_session_key
.data
, session_nonce
,
699 sizeof(session_nonce
), session_key
.data
);
700 DEBUG(10,("ntlmssp_server_auth: Created NTLM2 session key.\n"));
701 dump_data_pw("NTLM2 session key:\n", session_key
.data
, session_key
.length
);
704 DEBUG(10,("ntlmssp_server_auth: Failed to create NTLM2 session key.\n"));
705 session_key
= data_blob_null
;
707 } else if (ntlmssp_state
->neg_flags
& NTLMSSP_NEGOTIATE_LM_KEY
) {
708 if (lm_session_key
.data
&& lm_session_key
.length
>= 8) {
709 if (ntlmssp_state
->lm_resp
.data
&& ntlmssp_state
->lm_resp
.length
== 24) {
710 session_key
= data_blob_talloc(ntlmssp_state
,
712 if (session_key
.data
== NULL
) {
713 return NT_STATUS_NO_MEMORY
;
715 SMBsesskeygen_lm_sess_key(lm_session_key
.data
, ntlmssp_state
->lm_resp
.data
,
717 DEBUG(10,("ntlmssp_server_auth: Created NTLM session key.\n"));
719 static const uint8_t zeros
[24] = {0, };
720 session_key
= data_blob_talloc(
721 ntlmssp_state
, NULL
, 16);
722 if (session_key
.data
== NULL
) {
723 return NT_STATUS_NO_MEMORY
;
725 SMBsesskeygen_lm_sess_key(
726 lm_session_key
.data
, zeros
,
729 dump_data_pw("LM session key:\n", session_key
.data
,
732 DEBUG(10,("ntlmssp_server_auth: Failed to create NTLM session key.\n"));
733 session_key
= data_blob_null
;
735 } else if (user_session_key
.data
) {
736 session_key
= user_session_key
;
737 DEBUG(10,("ntlmssp_server_auth: Using unmodified nt session key.\n"));
738 dump_data_pw("unmodified session key:\n", session_key
.data
, session_key
.length
);
739 } else if (lm_session_key
.data
) {
740 session_key
= lm_session_key
;
741 DEBUG(10,("ntlmssp_server_auth: Using unmodified lm session key.\n"));
742 dump_data_pw("unmodified session key:\n", session_key
.data
, session_key
.length
);
744 DEBUG(10,("ntlmssp_server_auth: Failed to create unmodified session key.\n"));
745 session_key
= data_blob_null
;
748 /* With KEY_EXCH, the client supplies the proposed session key,
749 but encrypts it with the long-term key */
750 if (ntlmssp_state
->neg_flags
& NTLMSSP_NEGOTIATE_KEY_EXCH
) {
751 if (!encrypted_session_key
.data
|| encrypted_session_key
.length
!= 16) {
752 data_blob_free(&encrypted_session_key
);
753 DEBUG(1, ("Client-supplied KEY_EXCH session key was of invalid length (%u)!\n",
754 (unsigned int)encrypted_session_key
.length
));
755 return NT_STATUS_INVALID_PARAMETER
;
756 } else if (!session_key
.data
|| session_key
.length
!= 16) {
757 DEBUG(5, ("server session key is invalid (len == %u), cannot do KEY_EXCH!\n",
758 (unsigned int)session_key
.length
));
759 ntlmssp_state
->session_key
= session_key
;
761 dump_data_pw("KEY_EXCH session key (enc):\n", encrypted_session_key
.data
, encrypted_session_key
.length
);
762 arcfour_crypt_blob(encrypted_session_key
.data
,
763 encrypted_session_key
.length
,
765 ntlmssp_state
->session_key
= data_blob_talloc(
766 ntlmssp_state
, encrypted_session_key
.data
,
767 encrypted_session_key
.length
);
768 dump_data_pw("KEY_EXCH session key:\n", encrypted_session_key
.data
,
769 encrypted_session_key
.length
);
772 ntlmssp_state
->session_key
= session_key
;
775 if (!NT_STATUS_IS_OK(nt_status
)) {
776 ntlmssp_state
->session_key
= data_blob_null
;
777 } else if (ntlmssp_state
->session_key
.length
) {
778 nt_status
= ntlmssp_sign_init(ntlmssp_state
);
781 data_blob_free(&encrypted_session_key
);
783 /* Only one authentication allowed per server state. */
784 ntlmssp_state
->expected_state
= NTLMSSP_DONE
;
790 * Create an NTLMSSP state machine
792 * @param ntlmssp_state NTLMSSP State, allocated by this function
795 NTSTATUS
ntlmssp_server_start(TALLOC_CTX
*mem_ctx
,
797 const char *netbios_name
,
798 const char *netbios_domain
,
799 const char *dns_name
,
800 const char *dns_domain
,
801 struct ntlmssp_state
**_ntlmssp_state
)
803 struct ntlmssp_state
*ntlmssp_state
;
809 if (!netbios_domain
) {
821 ntlmssp_state
= talloc_zero(mem_ctx
, struct ntlmssp_state
);
822 if (!ntlmssp_state
) {
823 return NT_STATUS_NO_MEMORY
;
826 ntlmssp_state
->role
= NTLMSSP_SERVER
;
828 ntlmssp_state
->get_challenge
= get_challenge
;
829 ntlmssp_state
->set_challenge
= set_challenge
;
830 ntlmssp_state
->may_set_challenge
= may_set_challenge
;
832 ntlmssp_state
->server
.is_standalone
= is_standalone
;
834 ntlmssp_state
->expected_state
= NTLMSSP_NEGOTIATE
;
836 ntlmssp_state
->neg_flags
=
837 NTLMSSP_NEGOTIATE_128
|
838 NTLMSSP_NEGOTIATE_56
|
839 NTLMSSP_NEGOTIATE_VERSION
|
840 NTLMSSP_NEGOTIATE_ALWAYS_SIGN
|
841 NTLMSSP_NEGOTIATE_NTLM
|
842 NTLMSSP_NEGOTIATE_NTLM2
|
843 NTLMSSP_NEGOTIATE_KEY_EXCH
|
844 NTLMSSP_NEGOTIATE_SIGN
|
845 NTLMSSP_NEGOTIATE_SEAL
;
847 ntlmssp_state
->server
.netbios_name
= talloc_strdup(ntlmssp_state
, netbios_name
);
848 if (!ntlmssp_state
->server
.netbios_name
) {
849 talloc_free(ntlmssp_state
);
850 return NT_STATUS_NO_MEMORY
;
852 ntlmssp_state
->server
.netbios_domain
= talloc_strdup(ntlmssp_state
, netbios_domain
);
853 if (!ntlmssp_state
->server
.netbios_domain
) {
854 talloc_free(ntlmssp_state
);
855 return NT_STATUS_NO_MEMORY
;
857 ntlmssp_state
->server
.dns_name
= talloc_strdup(ntlmssp_state
, dns_name
);
858 if (!ntlmssp_state
->server
.dns_name
) {
859 talloc_free(ntlmssp_state
);
860 return NT_STATUS_NO_MEMORY
;
862 ntlmssp_state
->server
.dns_domain
= talloc_strdup(ntlmssp_state
, dns_domain
);
863 if (!ntlmssp_state
->server
.dns_domain
) {
864 talloc_free(ntlmssp_state
);
865 return NT_STATUS_NO_MEMORY
;
868 *_ntlmssp_state
= ntlmssp_state
;
872 /*********************************************************************
874 *********************************************************************/
877 * Next state function for the Initial packet
879 * @param ntlmssp_state NTLMSSP State
880 * @param request The request, as a DATA_BLOB. reply.data must be NULL
881 * @param request The reply, as an allocated DATA_BLOB, caller to free.
882 * @return Errors or NT_STATUS_OK.
885 static NTSTATUS
ntlmssp_client_initial(struct ntlmssp_state
*ntlmssp_state
,
886 DATA_BLOB reply
, DATA_BLOB
*next_request
)
888 struct NEGOTIATE_MESSAGE negotiate
;
890 if (ntlmssp_state
->unicode
) {
891 ntlmssp_state
->neg_flags
|= NTLMSSP_NEGOTIATE_UNICODE
;
893 ntlmssp_state
->neg_flags
|= NTLMSSP_NEGOTIATE_OEM
;
896 if (ntlmssp_state
->use_ntlmv2
) {
897 ntlmssp_state
->neg_flags
|= NTLMSSP_NEGOTIATE_NTLM2
;
900 /* generate the ntlmssp negotiate packet */
901 msrpc_gen(ntlmssp_state
, next_request
, "CddAA",
904 ntlmssp_state
->neg_flags
,
905 ntlmssp_state
->client
.netbios_domain
,
906 ntlmssp_state
->client
.netbios_name
);
908 if (DEBUGLEVEL
>= 10) {
909 if (NT_STATUS_IS_OK(ntlmssp_pull_NEGOTIATE_MESSAGE(next_request
,
913 NDR_PRINT_DEBUG(NEGOTIATE_MESSAGE
, &negotiate
);
917 ntlmssp_state
->expected_state
= NTLMSSP_CHALLENGE
;
919 return NT_STATUS_MORE_PROCESSING_REQUIRED
;
923 * Next state function for the Challenge Packet. Generate an auth packet.
925 * @param ntlmssp_state NTLMSSP State
926 * @param request The request, as a DATA_BLOB. reply.data must be NULL
927 * @param request The reply, as an allocated DATA_BLOB, caller to free.
928 * @return Errors or NT_STATUS_OK.
931 static NTSTATUS
ntlmssp_client_challenge(struct ntlmssp_state
*ntlmssp_state
,
932 const DATA_BLOB reply
, DATA_BLOB
*next_request
)
934 uint32_t chal_flags
, ntlmssp_command
, unkn1
, unkn2
;
935 DATA_BLOB server_domain_blob
;
936 DATA_BLOB challenge_blob
;
937 DATA_BLOB struct_blob
= data_blob_null
;
939 const char *chal_parse_string
;
940 const char *auth_gen_string
;
941 DATA_BLOB lm_response
= data_blob_null
;
942 DATA_BLOB nt_response
= data_blob_null
;
943 DATA_BLOB session_key
= data_blob_null
;
944 DATA_BLOB encrypted_session_key
= data_blob_null
;
945 NTSTATUS nt_status
= NT_STATUS_OK
;
946 struct CHALLENGE_MESSAGE challenge
;
947 struct AUTHENTICATE_MESSAGE authenticate
;
949 if (ntlmssp_state
->use_ccache
) {
950 struct wbcCredentialCacheParams params
;
951 struct wbcCredentialCacheInfo
*info
= NULL
;
952 struct wbcAuthErrorInfo
*error
= NULL
;
953 struct wbcNamedBlob auth_blob
;
954 struct wbcBlob
*wbc_next
= NULL
;
955 struct wbcBlob
*wbc_session_key
= NULL
;
959 params
.account_name
= ntlmssp_state
->user
;
960 params
.domain_name
= ntlmssp_state
->domain
;
961 params
.level
= WBC_CREDENTIAL_CACHE_LEVEL_NTLMSSP
;
963 auth_blob
.name
= "challenge_blob";
965 auth_blob
.blob
.data
= reply
.data
;
966 auth_blob
.blob
.length
= reply
.length
;
967 params
.num_blobs
= 1;
968 params
.blobs
= &auth_blob
;
970 wbc_status
= wbcCredentialCache(¶ms
, &info
, &error
);
972 wbcFreeMemory(error
);
974 if (!WBC_ERROR_IS_OK(wbc_status
)) {
978 for (i
=0; i
<info
->num_blobs
; i
++) {
979 if (strequal(info
->blobs
[i
].name
, "auth_blob")) {
980 wbc_next
= &info
->blobs
[i
].blob
;
982 if (strequal(info
->blobs
[i
].name
, "session_key")) {
983 wbc_session_key
= &info
->blobs
[i
].blob
;
986 if ((wbc_next
== NULL
) || (wbc_session_key
== NULL
)) {
991 *next_request
= data_blob(wbc_next
->data
, wbc_next
->length
);
992 ntlmssp_state
->session_key
= data_blob(
993 wbc_session_key
->data
, wbc_session_key
->length
);
1001 if (!msrpc_parse(ntlmssp_state
, &reply
, "CdBd",
1004 &server_domain_blob
,
1006 DEBUG(1, ("Failed to parse the NTLMSSP Challenge: (#1)\n"));
1007 dump_data(2, reply
.data
, reply
.length
);
1009 return NT_STATUS_INVALID_PARAMETER
;
1012 if (DEBUGLEVEL
>= 10) {
1013 if (NT_STATUS_IS_OK(ntlmssp_pull_CHALLENGE_MESSAGE(&reply
,
1017 NDR_PRINT_DEBUG(CHALLENGE_MESSAGE
, &challenge
);
1021 data_blob_free(&server_domain_blob
);
1023 DEBUG(3, ("Got challenge flags:\n"));
1024 debug_ntlmssp_flags(chal_flags
);
1026 ntlmssp_handle_neg_flags(ntlmssp_state
, chal_flags
, lp_client_lanman_auth());
1028 if (ntlmssp_state
->unicode
) {
1029 if (chal_flags
& NTLMSSP_NEGOTIATE_TARGET_INFO
) {
1030 chal_parse_string
= "CdUdbddB";
1032 chal_parse_string
= "CdUdbdd";
1034 auth_gen_string
= "CdBBUUUBd";
1036 if (chal_flags
& NTLMSSP_NEGOTIATE_TARGET_INFO
) {
1037 chal_parse_string
= "CdAdbddB";
1039 chal_parse_string
= "CdAdbdd";
1042 auth_gen_string
= "CdBBAAABd";
1045 DEBUG(3, ("NTLMSSP: Set final flags:\n"));
1046 debug_ntlmssp_flags(ntlmssp_state
->neg_flags
);
1048 if (!msrpc_parse(ntlmssp_state
, &reply
, chal_parse_string
,
1056 DEBUG(1, ("Failed to parse the NTLMSSP Challenge: (#2)\n"));
1057 dump_data(2, reply
.data
, reply
.length
);
1058 return NT_STATUS_INVALID_PARAMETER
;
1061 if (chal_flags
& NTLMSSP_TARGET_TYPE_SERVER
) {
1062 ntlmssp_state
->server
.is_standalone
= true;
1064 ntlmssp_state
->server
.is_standalone
= false;
1066 /* TODO: parse struct_blob and fill in the rest */
1067 ntlmssp_state
->server
.netbios_name
= "";
1068 ntlmssp_state
->server
.netbios_domain
= server_domain
;
1069 ntlmssp_state
->server
.dns_name
= "";
1070 ntlmssp_state
->server
.dns_domain
= "";
1072 if (challenge_blob
.length
!= 8) {
1073 data_blob_free(&struct_blob
);
1074 return NT_STATUS_INVALID_PARAMETER
;
1077 if (!ntlmssp_state
->nt_hash
|| !ntlmssp_state
->lm_hash
) {
1078 static const uint8_t zeros
[16] = {0, };
1079 /* do nothing - blobs are zero length */
1081 /* session key is all zeros */
1082 session_key
= data_blob_talloc(ntlmssp_state
, zeros
, 16);
1084 /* not doing NLTM2 without a password */
1085 ntlmssp_state
->neg_flags
&= ~NTLMSSP_NEGOTIATE_NTLM2
;
1086 } else if (ntlmssp_state
->use_ntlmv2
) {
1087 if (!struct_blob
.length
) {
1088 /* be lazy, match win2k - we can't do NTLMv2 without it */
1089 DEBUG(1, ("Server did not provide 'target information', required for NTLMv2\n"));
1090 return NT_STATUS_INVALID_PARAMETER
;
1093 /* TODO: if the remote server is standalone, then we should replace 'domain'
1094 with the server name as supplied above */
1096 if (!SMBNTLMv2encrypt_hash(ntlmssp_state
,
1097 ntlmssp_state
->user
,
1098 ntlmssp_state
->domain
,
1099 ntlmssp_state
->nt_hash
, &challenge_blob
,
1101 &lm_response
, &nt_response
, NULL
,
1103 data_blob_free(&challenge_blob
);
1104 data_blob_free(&struct_blob
);
1105 return NT_STATUS_NO_MEMORY
;
1107 } else if (ntlmssp_state
->neg_flags
& NTLMSSP_NEGOTIATE_NTLM2
) {
1108 struct MD5Context md5_session_nonce_ctx
;
1109 uint8_t session_nonce
[16];
1110 uint8_t session_nonce_hash
[16];
1111 uint8_t user_session_key
[16];
1113 lm_response
= data_blob_talloc(ntlmssp_state
, NULL
, 24);
1114 generate_random_buffer(lm_response
.data
, 8);
1115 memset(lm_response
.data
+8, 0, 16);
1117 memcpy(session_nonce
, challenge_blob
.data
, 8);
1118 memcpy(&session_nonce
[8], lm_response
.data
, 8);
1120 MD5Init(&md5_session_nonce_ctx
);
1121 MD5Update(&md5_session_nonce_ctx
, challenge_blob
.data
, 8);
1122 MD5Update(&md5_session_nonce_ctx
, lm_response
.data
, 8);
1123 MD5Final(session_nonce_hash
, &md5_session_nonce_ctx
);
1125 DEBUG(5, ("NTLMSSP challenge set by NTLM2\n"));
1126 DEBUG(5, ("challenge is: \n"));
1127 dump_data(5, session_nonce_hash
, 8);
1129 nt_response
= data_blob_talloc(ntlmssp_state
, NULL
, 24);
1130 SMBNTencrypt_hash(ntlmssp_state
->nt_hash
,
1134 session_key
= data_blob_talloc(ntlmssp_state
, NULL
, 16);
1136 SMBsesskeygen_ntv1(ntlmssp_state
->nt_hash
, user_session_key
);
1137 hmac_md5(user_session_key
, session_nonce
, sizeof(session_nonce
), session_key
.data
);
1138 dump_data_pw("NTLM2 session key:\n", session_key
.data
, session_key
.length
);
1140 /* lanman auth is insecure, it may be disabled */
1141 if (lp_client_lanman_auth()) {
1142 lm_response
= data_blob_talloc(ntlmssp_state
,
1144 SMBencrypt_hash(ntlmssp_state
->lm_hash
,challenge_blob
.data
,
1148 nt_response
= data_blob_talloc(ntlmssp_state
, NULL
, 24);
1149 SMBNTencrypt_hash(ntlmssp_state
->nt_hash
,challenge_blob
.data
,
1152 session_key
= data_blob_talloc(ntlmssp_state
, NULL
, 16);
1153 if ((ntlmssp_state
->neg_flags
& NTLMSSP_NEGOTIATE_LM_KEY
)
1154 && lp_client_lanman_auth()) {
1155 SMBsesskeygen_lm_sess_key(ntlmssp_state
->lm_hash
, lm_response
.data
,
1157 dump_data_pw("LM session key\n", session_key
.data
, session_key
.length
);
1159 SMBsesskeygen_ntv1(ntlmssp_state
->nt_hash
, session_key
.data
);
1160 dump_data_pw("NT session key:\n", session_key
.data
, session_key
.length
);
1163 data_blob_free(&struct_blob
);
1165 /* Key exchange encryptes a new client-generated session key with
1166 the password-derived key */
1167 if (ntlmssp_state
->neg_flags
& NTLMSSP_NEGOTIATE_KEY_EXCH
) {
1168 /* Make up a new session key */
1169 uint8_t client_session_key
[16];
1170 generate_random_buffer(client_session_key
, sizeof(client_session_key
));
1172 /* Encrypt the new session key with the old one */
1173 encrypted_session_key
= data_blob(client_session_key
, sizeof(client_session_key
));
1174 dump_data_pw("KEY_EXCH session key:\n", encrypted_session_key
.data
, encrypted_session_key
.length
);
1175 arcfour_crypt_blob(encrypted_session_key
.data
, encrypted_session_key
.length
, &session_key
);
1176 dump_data_pw("KEY_EXCH session key (enc):\n", encrypted_session_key
.data
, encrypted_session_key
.length
);
1178 /* Mark the new session key as the 'real' session key */
1179 data_blob_free(&session_key
);
1180 session_key
= data_blob_talloc(ntlmssp_state
,
1182 sizeof(client_session_key
));
1185 /* this generates the actual auth packet */
1186 if (!msrpc_gen(ntlmssp_state
, next_request
, auth_gen_string
,
1189 lm_response
.data
, lm_response
.length
,
1190 nt_response
.data
, nt_response
.length
,
1191 ntlmssp_state
->domain
,
1192 ntlmssp_state
->user
,
1193 ntlmssp_state
->client
.netbios_name
,
1194 encrypted_session_key
.data
, encrypted_session_key
.length
,
1195 ntlmssp_state
->neg_flags
)) {
1197 return NT_STATUS_NO_MEMORY
;
1200 if (DEBUGLEVEL
>= 10) {
1201 if (NT_STATUS_IS_OK(ntlmssp_pull_AUTHENTICATE_MESSAGE(next_request
,
1205 NDR_PRINT_DEBUG(AUTHENTICATE_MESSAGE
, &authenticate
);
1209 data_blob_free(&encrypted_session_key
);
1211 data_blob_free(&ntlmssp_state
->chal
);
1213 ntlmssp_state
->session_key
= session_key
;
1215 ntlmssp_state
->chal
= challenge_blob
;
1216 ntlmssp_state
->lm_resp
= lm_response
;
1217 ntlmssp_state
->nt_resp
= nt_response
;
1221 ntlmssp_state
->expected_state
= NTLMSSP_DONE
;
1223 if (!NT_STATUS_IS_OK(nt_status
= ntlmssp_sign_init(ntlmssp_state
))) {
1224 DEBUG(1, ("Could not setup NTLMSSP signing/sealing system (error was: %s)\n", nt_errstr(nt_status
)));
1230 NTSTATUS
ntlmssp_client_start(TALLOC_CTX
*mem_ctx
,
1231 const char *netbios_name
,
1232 const char *netbios_domain
,
1234 struct ntlmssp_state
**_ntlmssp_state
)
1236 struct ntlmssp_state
*ntlmssp_state
;
1238 if (!netbios_name
) {
1242 if (!netbios_domain
) {
1243 netbios_domain
= "";
1246 ntlmssp_state
= talloc_zero(mem_ctx
, struct ntlmssp_state
);
1247 if (!ntlmssp_state
) {
1248 return NT_STATUS_NO_MEMORY
;
1251 ntlmssp_state
->role
= NTLMSSP_CLIENT
;
1253 ntlmssp_state
->unicode
= True
;
1255 ntlmssp_state
->use_ntlmv2
= use_ntlmv2
;
1257 ntlmssp_state
->expected_state
= NTLMSSP_INITIAL
;
1259 ntlmssp_state
->neg_flags
=
1260 NTLMSSP_NEGOTIATE_128
|
1261 NTLMSSP_NEGOTIATE_ALWAYS_SIGN
|
1262 NTLMSSP_NEGOTIATE_NTLM
|
1263 NTLMSSP_NEGOTIATE_NTLM2
|
1264 NTLMSSP_NEGOTIATE_KEY_EXCH
|
1265 NTLMSSP_REQUEST_TARGET
;
1267 ntlmssp_state
->client
.netbios_name
= talloc_strdup(ntlmssp_state
, netbios_name
);
1268 if (!ntlmssp_state
->client
.netbios_name
) {
1269 talloc_free(ntlmssp_state
);
1270 return NT_STATUS_NO_MEMORY
;
1272 ntlmssp_state
->client
.netbios_domain
= talloc_strdup(ntlmssp_state
, netbios_domain
);
1273 if (!ntlmssp_state
->client
.netbios_domain
) {
1274 talloc_free(ntlmssp_state
);
1275 return NT_STATUS_NO_MEMORY
;
1278 *_ntlmssp_state
= ntlmssp_state
;
1279 return NT_STATUS_OK
;