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/>.
26 #include "../libcli/auth/libcli_auth.h"
27 #include "../librpc/gen_ndr/ndr_ntlmssp.h"
28 #include "../libcli/auth/ntlmssp_ndr.h"
30 static NTSTATUS ntlmssp_client_initial(struct ntlmssp_state *ntlmssp_state,
31 DATA_BLOB reply, DATA_BLOB *next_request);
32 static NTSTATUS ntlmssp_server_negotiate(struct ntlmssp_state *ntlmssp_state,
33 const DATA_BLOB in, DATA_BLOB *out);
34 static NTSTATUS ntlmssp_client_challenge(struct ntlmssp_state *ntlmssp_state,
35 const DATA_BLOB reply, DATA_BLOB *next_request);
36 static NTSTATUS ntlmssp_server_auth(struct ntlmssp_state *ntlmssp_state,
37 const DATA_BLOB request, DATA_BLOB *reply);
40 * Callbacks for NTLMSSP - for both client and server operating modes
44 static const struct ntlmssp_callbacks {
45 enum ntlmssp_role role;
46 enum ntlmssp_message_type ntlmssp_command;
47 NTSTATUS (*fn)(struct ntlmssp_state *ntlmssp_state,
48 DATA_BLOB in, DATA_BLOB *out);
49 } ntlmssp_callbacks[] = {
50 {NTLMSSP_CLIENT, NTLMSSP_INITIAL, ntlmssp_client_initial},
51 {NTLMSSP_SERVER, NTLMSSP_NEGOTIATE, ntlmssp_server_negotiate},
52 {NTLMSSP_CLIENT, NTLMSSP_CHALLENGE, ntlmssp_client_challenge},
53 {NTLMSSP_SERVER, NTLMSSP_AUTH, ntlmssp_server_auth},
54 {NTLMSSP_CLIENT, NTLMSSP_UNKNOWN, NULL},
55 {NTLMSSP_SERVER, NTLMSSP_UNKNOWN, NULL}
60 * Print out the NTLMSSP flags for debugging
61 * @param neg_flags The flags from the packet
64 void debug_ntlmssp_flags(uint32 neg_flags)
66 DEBUG(3,("Got NTLMSSP neg_flags=0x%08x\n", neg_flags));
68 if (neg_flags & NTLMSSP_NEGOTIATE_UNICODE)
69 DEBUGADD(4, (" NTLMSSP_NEGOTIATE_UNICODE\n"));
70 if (neg_flags & NTLMSSP_NEGOTIATE_OEM)
71 DEBUGADD(4, (" NTLMSSP_NEGOTIATE_OEM\n"));
72 if (neg_flags & NTLMSSP_REQUEST_TARGET)
73 DEBUGADD(4, (" NTLMSSP_REQUEST_TARGET\n"));
74 if (neg_flags & NTLMSSP_NEGOTIATE_SIGN)
75 DEBUGADD(4, (" NTLMSSP_NEGOTIATE_SIGN\n"));
76 if (neg_flags & NTLMSSP_NEGOTIATE_SEAL)
77 DEBUGADD(4, (" NTLMSSP_NEGOTIATE_SEAL\n"));
78 if (neg_flags & NTLMSSP_NEGOTIATE_DATAGRAM)
79 DEBUGADD(4, (" NTLMSSP_NEGOTIATE_DATAGRAM\n"));
80 if (neg_flags & NTLMSSP_NEGOTIATE_LM_KEY)
81 DEBUGADD(4, (" NTLMSSP_NEGOTIATE_LM_KEY\n"));
82 if (neg_flags & NTLMSSP_NEGOTIATE_NETWARE)
83 DEBUGADD(4, (" NTLMSSP_NEGOTIATE_NETWARE\n"));
84 if (neg_flags & NTLMSSP_NEGOTIATE_NTLM)
85 DEBUGADD(4, (" NTLMSSP_NEGOTIATE_NTLM\n"));
86 if (neg_flags & NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED)
87 DEBUGADD(4, (" NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED\n"));
88 if (neg_flags & NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED)
89 DEBUGADD(4, (" NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED\n"));
90 if (neg_flags & NTLMSSP_NEGOTIATE_THIS_IS_LOCAL_CALL)
91 DEBUGADD(4, (" NTLMSSP_NEGOTIATE_THIS_IS_LOCAL_CALL\n"));
92 if (neg_flags & NTLMSSP_NEGOTIATE_ALWAYS_SIGN)
93 DEBUGADD(4, (" NTLMSSP_NEGOTIATE_ALWAYS_SIGN\n"));
94 if (neg_flags & NTLMSSP_REQUEST_NON_NT_SESSION_KEY)
95 DEBUGADD(4, (" NTLMSSP_REQUEST_NON_NT_SESSION_KEY\n"));
96 if (neg_flags & NTLMSSP_NEGOTIATE_NTLM2)
97 DEBUGADD(4, (" NTLMSSP_NEGOTIATE_NTLM2\n"));
98 if (neg_flags & NTLMSSP_NEGOTIATE_TARGET_INFO)
99 DEBUGADD(4, (" NTLMSSP_NEGOTIATE_TARGET_INFO\n"));
100 if (neg_flags & NTLMSSP_NEGOTIATE_VERSION)
101 DEBUGADD(4, (" NTLMSSP_NEGOTIATE_VERSION\n"));
102 if (neg_flags & NTLMSSP_NEGOTIATE_128)
103 DEBUGADD(4, (" NTLMSSP_NEGOTIATE_128\n"));
104 if (neg_flags & NTLMSSP_NEGOTIATE_KEY_EXCH)
105 DEBUGADD(4, (" NTLMSSP_NEGOTIATE_KEY_EXCH\n"));
106 if (neg_flags & NTLMSSP_NEGOTIATE_56)
107 DEBUGADD(4, (" NTLMSSP_NEGOTIATE_56\n"));
111 * Default challenge generation code.
115 static NTSTATUS get_challenge(const struct ntlmssp_state *ntlmssp_state,
118 generate_random_buffer(chal, 8);
123 * Default 'we can set the challenge to anything we like' implementation
127 static bool may_set_challenge(const struct ntlmssp_state *ntlmssp_state)
133 * Default 'we can set the challenge to anything we like' implementation
135 * Does not actually do anything, as the value is always in the structure anyway.
139 static NTSTATUS set_challenge(struct ntlmssp_state *ntlmssp_state, DATA_BLOB *challenge)
141 SMB_ASSERT(challenge->length == 8);
146 * Set a username on an NTLMSSP context - ensures it is talloc()ed
150 NTSTATUS ntlmssp_set_username(struct ntlmssp_state *ntlmssp_state, const char *user)
152 ntlmssp_state->user = talloc_strdup(ntlmssp_state, user ? user : "" );
153 if (!ntlmssp_state->user) {
154 return NT_STATUS_NO_MEMORY;
160 * Store NT and LM hashes on an NTLMSSP context - ensures they are talloc()ed
163 NTSTATUS ntlmssp_set_hashes(struct ntlmssp_state *ntlmssp_state,
164 const unsigned char lm_hash[16],
165 const unsigned char nt_hash[16])
167 ntlmssp_state->lm_hash = (unsigned char *)
168 TALLOC_MEMDUP(ntlmssp_state, lm_hash, 16);
169 ntlmssp_state->nt_hash = (unsigned char *)
170 TALLOC_MEMDUP(ntlmssp_state, nt_hash, 16);
171 if (!ntlmssp_state->lm_hash || !ntlmssp_state->nt_hash) {
172 TALLOC_FREE(ntlmssp_state->lm_hash);
173 TALLOC_FREE(ntlmssp_state->nt_hash);
174 return NT_STATUS_NO_MEMORY;
180 * Converts a password to the hashes on an NTLMSSP context.
183 NTSTATUS ntlmssp_set_password(struct ntlmssp_state *ntlmssp_state, const char *password)
186 ntlmssp_state->lm_hash = NULL;
187 ntlmssp_state->nt_hash = NULL;
189 unsigned char lm_hash[16];
190 unsigned char nt_hash[16];
192 E_deshash(password, lm_hash);
193 E_md4hash(password, nt_hash);
194 return ntlmssp_set_hashes(ntlmssp_state, lm_hash, nt_hash);
200 * Set a domain on an NTLMSSP context - ensures it is talloc()ed
203 NTSTATUS ntlmssp_set_domain(struct ntlmssp_state *ntlmssp_state, const char *domain)
205 ntlmssp_state->domain = talloc_strdup(ntlmssp_state,
206 domain ? domain : "" );
207 if (!ntlmssp_state->domain) {
208 return NT_STATUS_NO_MEMORY;
214 * Request features for the NTLMSSP negotiation
216 * @param ntlmssp_state NTLMSSP state
217 * @param feature_list List of space seperated features requested from NTLMSSP.
219 void ntlmssp_want_feature_list(struct ntlmssp_state *ntlmssp_state, char *feature_list)
222 * We need to set this to allow a later SetPassword
223 * via the SAMR pipe to succeed. Strange.... We could
224 * also add NTLMSSP_NEGOTIATE_SEAL here. JRA.
226 if (in_list("NTLMSSP_FEATURE_SESSION_KEY", feature_list, True)) {
227 ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_SIGN;
229 if (in_list("NTLMSSP_FEATURE_SIGN", feature_list, True)) {
230 ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_SIGN;
232 if(in_list("NTLMSSP_FEATURE_SEAL", feature_list, True)) {
233 ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_SEAL;
235 if (in_list("NTLMSSP_FEATURE_CCACHE", feature_list, true)) {
236 ntlmssp_state->use_ccache = true;
241 * Request a feature for the NTLMSSP negotiation
243 * @param ntlmssp_state NTLMSSP state
244 * @param feature Bit flag specifying the requested feature
246 void ntlmssp_want_feature(struct ntlmssp_state *ntlmssp_state, uint32 feature)
248 /* As per JRA's comment above */
249 if (feature & NTLMSSP_FEATURE_SESSION_KEY) {
250 ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_SIGN;
252 if (feature & NTLMSSP_FEATURE_SIGN) {
253 ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_SIGN;
255 if (feature & NTLMSSP_FEATURE_SEAL) {
256 ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_SEAL;
258 if (feature & NTLMSSP_FEATURE_CCACHE) {
259 ntlmssp_state->use_ccache = true;
264 * Next state function for the NTLMSSP state machine
266 * @param ntlmssp_state NTLMSSP State
267 * @param in The packet in from the NTLMSSP partner, as a DATA_BLOB
268 * @param out The reply, as an allocated DATA_BLOB, caller to free.
269 * @return Errors, NT_STATUS_MORE_PROCESSING_REQUIRED or NT_STATUS_OK.
272 NTSTATUS ntlmssp_update(struct ntlmssp_state *ntlmssp_state,
273 const DATA_BLOB input, DATA_BLOB *out)
275 uint32 ntlmssp_command;
278 if (ntlmssp_state->expected_state == NTLMSSP_DONE) {
279 /* Called update after negotiations finished. */
280 DEBUG(1, ("Called NTLMSSP after state machine was 'done'\n"));
281 return NT_STATUS_INVALID_PARAMETER;
284 *out = data_blob_null;
287 switch (ntlmssp_state->role) {
289 ntlmssp_command = NTLMSSP_INITIAL;
292 /* 'datagram' mode - no neg packet */
293 ntlmssp_command = NTLMSSP_NEGOTIATE;
297 if (!msrpc_parse(ntlmssp_state, &input, "Cd",
300 DEBUG(1, ("Failed to parse NTLMSSP packet, could not extract NTLMSSP command\n"));
301 dump_data(2, input.data, input.length);
302 return NT_STATUS_INVALID_PARAMETER;
306 if (ntlmssp_command != ntlmssp_state->expected_state) {
307 DEBUG(1, ("got NTLMSSP command %u, expected %u\n", ntlmssp_command, ntlmssp_state->expected_state));
308 return NT_STATUS_INVALID_PARAMETER;
311 for (i=0; ntlmssp_callbacks[i].fn; i++) {
312 if (ntlmssp_callbacks[i].role == ntlmssp_state->role
313 && ntlmssp_callbacks[i].ntlmssp_command == ntlmssp_command) {
314 return ntlmssp_callbacks[i].fn(ntlmssp_state, input, out);
318 DEBUG(1, ("failed to find NTLMSSP callback for NTLMSSP mode %u, command %u\n",
319 ntlmssp_state->role, ntlmssp_command));
321 return NT_STATUS_INVALID_PARAMETER;
325 * End an NTLMSSP state machine
327 * @param ntlmssp_state NTLMSSP State, free()ed by this function
330 void ntlmssp_end(struct ntlmssp_state **ntlmssp_state)
332 data_blob_free(&(*ntlmssp_state)->chal);
333 data_blob_free(&(*ntlmssp_state)->lm_resp);
334 data_blob_free(&(*ntlmssp_state)->nt_resp);
335 TALLOC_FREE(*ntlmssp_state);
337 *ntlmssp_state = NULL;
342 * Determine correct target name flags for reply, given server role
343 * and negotiated flags
345 * @param ntlmssp_state NTLMSSP State
346 * @param neg_flags The flags from the packet
347 * @param chal_flags The flags to be set in the reply packet
348 * @return The 'target name' string.
351 static const char *ntlmssp_target_name(struct ntlmssp_state *ntlmssp_state,
352 uint32 neg_flags, uint32 *chal_flags)
354 if (neg_flags & NTLMSSP_REQUEST_TARGET) {
355 *chal_flags |= NTLMSSP_NEGOTIATE_TARGET_INFO;
356 *chal_flags |= NTLMSSP_REQUEST_TARGET;
357 if (ntlmssp_state->server.is_standalone) {
358 *chal_flags |= NTLMSSP_TARGET_TYPE_SERVER;
359 return ntlmssp_state->server.netbios_name;
361 *chal_flags |= NTLMSSP_TARGET_TYPE_DOMAIN;
362 return ntlmssp_state->server.netbios_domain;
369 static void ntlmssp_handle_neg_flags(struct ntlmssp_state *ntlmssp_state,
370 uint32 neg_flags, bool allow_lm) {
371 if (neg_flags & NTLMSSP_NEGOTIATE_UNICODE) {
372 ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_UNICODE;
373 ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_OEM;
374 ntlmssp_state->unicode = True;
376 ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_UNICODE;
377 ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_OEM;
378 ntlmssp_state->unicode = False;
381 if ((neg_flags & NTLMSSP_NEGOTIATE_LM_KEY) && allow_lm) {
382 /* other end forcing us to use LM */
383 ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_LM_KEY;
384 ntlmssp_state->use_ntlmv2 = False;
386 ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_LM_KEY;
389 if (!(neg_flags & NTLMSSP_NEGOTIATE_ALWAYS_SIGN)) {
390 ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_ALWAYS_SIGN;
393 if (!(neg_flags & NTLMSSP_NEGOTIATE_NTLM2)) {
394 ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_NTLM2;
397 if (!(neg_flags & NTLMSSP_NEGOTIATE_128)) {
398 ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_128;
401 if (!(neg_flags & NTLMSSP_NEGOTIATE_56)) {
402 ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_56;
405 if (!(neg_flags & NTLMSSP_NEGOTIATE_KEY_EXCH)) {
406 ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_KEY_EXCH;
409 if (!(neg_flags & NTLMSSP_NEGOTIATE_SIGN)) {
410 ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_SIGN;
413 if (!(neg_flags & NTLMSSP_NEGOTIATE_SEAL)) {
414 ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_SEAL;
417 /* Woop Woop - unknown flag for Windows compatibility...
418 What does this really do ? JRA. */
419 if (!(neg_flags & NTLMSSP_NEGOTIATE_VERSION)) {
420 ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_VERSION;
423 if ((neg_flags & NTLMSSP_REQUEST_TARGET)) {
424 ntlmssp_state->neg_flags |= NTLMSSP_REQUEST_TARGET;
429 * Next state function for the Negotiate packet
431 * @param ntlmssp_state NTLMSSP State
432 * @param request The request, as a DATA_BLOB
433 * @param request The reply, as an allocated DATA_BLOB, caller to free.
434 * @return Errors or MORE_PROCESSING_REQUIRED if a reply is sent.
437 static NTSTATUS ntlmssp_server_negotiate(struct ntlmssp_state *ntlmssp_state,
438 const DATA_BLOB request, DATA_BLOB *reply)
440 DATA_BLOB struct_blob;
441 uint32 neg_flags = 0;
442 uint32 ntlmssp_command, chal_flags;
444 const char *target_name;
445 struct NEGOTIATE_MESSAGE negotiate;
446 struct CHALLENGE_MESSAGE challenge;
449 /* parse the NTLMSSP packet */
451 file_save("ntlmssp_negotiate.dat", request.data, request.length);
454 if (request.length) {
455 if ((request.length < 16) || !msrpc_parse(ntlmssp_state, &request, "Cdd",
459 DEBUG(1, ("ntlmssp_server_negotiate: failed to parse NTLMSSP Negotiate of length %u\n",
460 (unsigned int)request.length));
461 dump_data(2, request.data, request.length);
462 return NT_STATUS_INVALID_PARAMETER;
464 debug_ntlmssp_flags(neg_flags);
466 if (DEBUGLEVEL >= 10) {
467 if (NT_STATUS_IS_OK(ntlmssp_pull_NEGOTIATE_MESSAGE(&request,
472 NDR_PRINT_DEBUG(NEGOTIATE_MESSAGE, &negotiate);
477 ntlmssp_handle_neg_flags(ntlmssp_state, neg_flags, lp_lanman_auth());
479 /* Ask our caller what challenge they would like in the packet */
480 status = ntlmssp_state->get_challenge(ntlmssp_state, cryptkey);
481 if (!NT_STATUS_IS_OK(status)) {
485 /* Check if we may set the challenge */
486 if (!ntlmssp_state->may_set_challenge(ntlmssp_state)) {
487 ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_NTLM2;
490 /* The flags we send back are not just the negotiated flags,
491 * they are also 'what is in this packet'. Therfore, we
492 * operate on 'chal_flags' from here on
495 chal_flags = ntlmssp_state->neg_flags;
497 /* get the right name to fill in as 'target' */
498 target_name = ntlmssp_target_name(ntlmssp_state,
499 neg_flags, &chal_flags);
500 if (target_name == NULL)
501 return NT_STATUS_INVALID_PARAMETER;
503 ntlmssp_state->chal = data_blob_talloc(ntlmssp_state, cryptkey, 8);
504 ntlmssp_state->internal_chal = data_blob_talloc(ntlmssp_state,
507 /* This creates the 'blob' of names that appears at the end of the packet */
508 if (chal_flags & NTLMSSP_NEGOTIATE_TARGET_INFO)
510 msrpc_gen(ntlmssp_state, &struct_blob, "aaaaa",
511 MsvAvNbDomainName, target_name,
512 MsvAvNbComputerName, ntlmssp_state->server.netbios_name,
513 MsvAvDnsDomainName, ntlmssp_state->server.dns_domain,
514 MsvAvDnsComputerName, ntlmssp_state->server.dns_name,
517 struct_blob = data_blob_null;
521 /* Marshel the packet in the right format, be it unicode or ASCII */
522 const char *gen_string;
523 if (ntlmssp_state->unicode) {
524 gen_string = "CdUdbddB";
526 gen_string = "CdAdbddB";
529 msrpc_gen(ntlmssp_state, reply, gen_string,
536 struct_blob.data, struct_blob.length);
538 if (DEBUGLEVEL >= 10) {
539 if (NT_STATUS_IS_OK(ntlmssp_pull_CHALLENGE_MESSAGE(reply,
544 NDR_PRINT_DEBUG(CHALLENGE_MESSAGE, &challenge);
549 data_blob_free(&struct_blob);
551 ntlmssp_state->expected_state = NTLMSSP_AUTH;
553 return NT_STATUS_MORE_PROCESSING_REQUIRED;
557 * Next state function for the Authenticate packet
559 * @param ntlmssp_state NTLMSSP State
560 * @param request The request, as a DATA_BLOB
561 * @param request The reply, as an allocated DATA_BLOB, caller to free.
562 * @return Errors or NT_STATUS_OK.
565 static NTSTATUS ntlmssp_server_auth(struct ntlmssp_state *ntlmssp_state,
566 const DATA_BLOB request, DATA_BLOB *reply)
568 DATA_BLOB encrypted_session_key = data_blob_null;
569 DATA_BLOB user_session_key = data_blob_null;
570 DATA_BLOB lm_session_key = data_blob_null;
571 DATA_BLOB session_key = data_blob_null;
572 uint32 ntlmssp_command, auth_flags;
573 NTSTATUS nt_status = NT_STATUS_OK;
574 struct AUTHENTICATE_MESSAGE authenticate;
577 bool doing_ntlm2 = False;
579 uchar session_nonce[16];
580 uchar session_nonce_hash[16];
582 const char *parse_string;
584 /* parse the NTLMSSP packet */
585 *reply = data_blob_null;
588 file_save("ntlmssp_auth.dat", request.data, request.length);
591 if (ntlmssp_state->unicode) {
592 parse_string = "CdBBUUUBd";
594 parse_string = "CdBBAAABd";
597 data_blob_free(&ntlmssp_state->lm_resp);
598 data_blob_free(&ntlmssp_state->nt_resp);
600 ntlmssp_state->user = NULL;
601 ntlmssp_state->domain = NULL;
603 /* now the NTLMSSP encoded auth hashes */
604 if (!msrpc_parse(ntlmssp_state, &request, parse_string,
607 &ntlmssp_state->lm_resp,
608 &ntlmssp_state->nt_resp,
609 &ntlmssp_state->domain,
610 &ntlmssp_state->user,
611 &ntlmssp_state->client.netbios_name,
612 &encrypted_session_key,
616 /* Try again with a shorter string (Win9X truncates this packet) */
617 if (ntlmssp_state->unicode) {
618 parse_string = "CdBBUUU";
620 parse_string = "CdBBAAA";
623 /* now the NTLMSSP encoded auth hashes */
624 if (!msrpc_parse(ntlmssp_state, &request, parse_string,
627 &ntlmssp_state->lm_resp,
628 &ntlmssp_state->nt_resp,
629 &ntlmssp_state->domain,
630 &ntlmssp_state->user,
631 &ntlmssp_state->client.netbios_name)) {
632 DEBUG(1, ("ntlmssp_server_auth: failed to parse NTLMSSP (tried both formats):\n"));
633 dump_data(2, request.data, request.length);
635 return NT_STATUS_INVALID_PARAMETER;
640 ntlmssp_handle_neg_flags(ntlmssp_state, auth_flags, lp_lanman_auth());
642 if (DEBUGLEVEL >= 10) {
643 if (NT_STATUS_IS_OK(ntlmssp_pull_AUTHENTICATE_MESSAGE(&request,
648 NDR_PRINT_DEBUG(AUTHENTICATE_MESSAGE, &authenticate);
652 DEBUG(3,("Got user=[%s] domain=[%s] workstation=[%s] len1=%lu len2=%lu\n",
653 ntlmssp_state->user, ntlmssp_state->domain,
654 ntlmssp_state->client.netbios_name,
655 (unsigned long)ntlmssp_state->lm_resp.length,
656 (unsigned long)ntlmssp_state->nt_resp.length));
659 file_save("nthash1.dat", &ntlmssp_state->nt_resp.data, &ntlmssp_state->nt_resp.length);
660 file_save("lmhash1.dat", &ntlmssp_state->lm_resp.data, &ntlmssp_state->lm_resp.length);
663 /* NTLM2 uses a 'challenge' that is made of up both the server challenge, and a
666 However, the NTLM2 flag may still be set for the real NTLMv2 logins, be careful.
668 if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_NTLM2) {
669 if (ntlmssp_state->nt_resp.length == 24 && ntlmssp_state->lm_resp.length == 24) {
670 struct MD5Context md5_session_nonce_ctx;
671 SMB_ASSERT(ntlmssp_state->internal_chal.data && ntlmssp_state->internal_chal.length == 8);
675 memcpy(session_nonce, ntlmssp_state->internal_chal.data, 8);
676 memcpy(&session_nonce[8], ntlmssp_state->lm_resp.data, 8);
678 MD5Init(&md5_session_nonce_ctx);
679 MD5Update(&md5_session_nonce_ctx, session_nonce, 16);
680 MD5Final(session_nonce_hash, &md5_session_nonce_ctx);
682 ntlmssp_state->chal = data_blob_talloc(
683 ntlmssp_state, session_nonce_hash, 8);
685 /* LM response is no longer useful */
686 data_blob_free(&ntlmssp_state->lm_resp);
688 /* We changed the effective challenge - set it */
689 if (!NT_STATUS_IS_OK(nt_status = ntlmssp_state->set_challenge(ntlmssp_state, &ntlmssp_state->chal))) {
690 data_blob_free(&encrypted_session_key);
694 /* LM Key is incompatible. */
695 ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_LM_KEY;
700 * Note we don't check here for NTLMv2 auth settings. If NTLMv2 auth
701 * is required (by "ntlm auth = no" and "lm auth = no" being set in the
702 * smb.conf file) and no NTLMv2 response was sent then the password check
703 * will fail here. JRA.
706 /* Finally, actually ask if the password is OK */
708 if (!NT_STATUS_IS_OK(nt_status = ntlmssp_state->check_password(ntlmssp_state,
709 &user_session_key, &lm_session_key))) {
710 data_blob_free(&encrypted_session_key);
714 dump_data_pw("NT session key:\n", user_session_key.data, user_session_key.length);
715 dump_data_pw("LM first-8:\n", lm_session_key.data, lm_session_key.length);
717 /* Handle the different session key derivation for NTLM2 */
719 if (user_session_key.data && user_session_key.length == 16) {
720 session_key = data_blob_talloc(ntlmssp_state,
722 hmac_md5(user_session_key.data, session_nonce,
723 sizeof(session_nonce), session_key.data);
724 DEBUG(10,("ntlmssp_server_auth: Created NTLM2 session key.\n"));
725 dump_data_pw("NTLM2 session key:\n", session_key.data, session_key.length);
728 DEBUG(10,("ntlmssp_server_auth: Failed to create NTLM2 session key.\n"));
729 session_key = data_blob_null;
731 } else if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_LM_KEY) {
732 if (lm_session_key.data && lm_session_key.length >= 8) {
733 if (ntlmssp_state->lm_resp.data && ntlmssp_state->lm_resp.length == 24) {
734 session_key = data_blob_talloc(ntlmssp_state,
736 if (session_key.data == NULL) {
737 return NT_STATUS_NO_MEMORY;
739 SMBsesskeygen_lm_sess_key(lm_session_key.data, ntlmssp_state->lm_resp.data,
741 DEBUG(10,("ntlmssp_server_auth: Created NTLM session key.\n"));
743 static const uint8 zeros[24] = {0, };
744 session_key = data_blob_talloc(
745 ntlmssp_state, NULL, 16);
746 if (session_key.data == NULL) {
747 return NT_STATUS_NO_MEMORY;
749 SMBsesskeygen_lm_sess_key(
750 lm_session_key.data, zeros,
753 dump_data_pw("LM session key:\n", session_key.data,
756 DEBUG(10,("ntlmssp_server_auth: Failed to create NTLM session key.\n"));
757 session_key = data_blob_null;
759 } else if (user_session_key.data) {
760 session_key = user_session_key;
761 DEBUG(10,("ntlmssp_server_auth: Using unmodified nt session key.\n"));
762 dump_data_pw("unmodified session key:\n", session_key.data, session_key.length);
763 } else if (lm_session_key.data) {
764 session_key = lm_session_key;
765 DEBUG(10,("ntlmssp_server_auth: Using unmodified lm session key.\n"));
766 dump_data_pw("unmodified session key:\n", session_key.data, session_key.length);
768 DEBUG(10,("ntlmssp_server_auth: Failed to create unmodified session key.\n"));
769 session_key = data_blob_null;
772 /* With KEY_EXCH, the client supplies the proposed session key,
773 but encrypts it with the long-term key */
774 if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_KEY_EXCH) {
775 if (!encrypted_session_key.data || encrypted_session_key.length != 16) {
776 data_blob_free(&encrypted_session_key);
777 DEBUG(1, ("Client-supplied KEY_EXCH session key was of invalid length (%u)!\n",
778 (unsigned int)encrypted_session_key.length));
779 return NT_STATUS_INVALID_PARAMETER;
780 } else if (!session_key.data || session_key.length != 16) {
781 DEBUG(5, ("server session key is invalid (len == %u), cannot do KEY_EXCH!\n",
782 (unsigned int)session_key.length));
783 ntlmssp_state->session_key = session_key;
785 dump_data_pw("KEY_EXCH session key (enc):\n", encrypted_session_key.data, encrypted_session_key.length);
786 arcfour_crypt_blob(encrypted_session_key.data,
787 encrypted_session_key.length,
789 ntlmssp_state->session_key = data_blob_talloc(
790 ntlmssp_state, encrypted_session_key.data,
791 encrypted_session_key.length);
792 dump_data_pw("KEY_EXCH session key:\n", encrypted_session_key.data,
793 encrypted_session_key.length);
796 ntlmssp_state->session_key = session_key;
799 if (!NT_STATUS_IS_OK(nt_status)) {
800 ntlmssp_state->session_key = data_blob_null;
801 } else if (ntlmssp_state->session_key.length) {
802 nt_status = ntlmssp_sign_init(ntlmssp_state);
805 data_blob_free(&encrypted_session_key);
807 /* Only one authentication allowed per server state. */
808 ntlmssp_state->expected_state = NTLMSSP_DONE;
814 * Create an NTLMSSP state machine
816 * @param ntlmssp_state NTLMSSP State, allocated by this function
819 NTSTATUS ntlmssp_server_start(TALLOC_CTX *mem_ctx,
821 const char *netbios_name,
822 const char *netbios_domain,
823 const char *dns_name,
824 const char *dns_domain,
825 struct ntlmssp_state **_ntlmssp_state)
827 struct ntlmssp_state *ntlmssp_state;
833 if (!netbios_domain) {
845 ntlmssp_state = talloc_zero(mem_ctx, struct ntlmssp_state);
846 if (!ntlmssp_state) {
847 return NT_STATUS_NO_MEMORY;
850 ntlmssp_state->role = NTLMSSP_SERVER;
852 ntlmssp_state->get_challenge = get_challenge;
853 ntlmssp_state->set_challenge = set_challenge;
854 ntlmssp_state->may_set_challenge = may_set_challenge;
856 ntlmssp_state->server.is_standalone = is_standalone;
858 ntlmssp_state->expected_state = NTLMSSP_NEGOTIATE;
860 ntlmssp_state->neg_flags =
861 NTLMSSP_NEGOTIATE_128 |
862 NTLMSSP_NEGOTIATE_56 |
863 NTLMSSP_NEGOTIATE_VERSION |
864 NTLMSSP_NEGOTIATE_ALWAYS_SIGN |
865 NTLMSSP_NEGOTIATE_NTLM |
866 NTLMSSP_NEGOTIATE_NTLM2 |
867 NTLMSSP_NEGOTIATE_KEY_EXCH |
868 NTLMSSP_NEGOTIATE_SIGN |
869 NTLMSSP_NEGOTIATE_SEAL;
871 ntlmssp_state->server.netbios_name = talloc_strdup(ntlmssp_state, netbios_name);
872 if (!ntlmssp_state->server.netbios_name) {
873 talloc_free(ntlmssp_state);
874 return NT_STATUS_NO_MEMORY;
876 ntlmssp_state->server.netbios_domain = talloc_strdup(ntlmssp_state, netbios_domain);
877 if (!ntlmssp_state->server.netbios_domain) {
878 talloc_free(ntlmssp_state);
879 return NT_STATUS_NO_MEMORY;
881 ntlmssp_state->server.dns_name = talloc_strdup(ntlmssp_state, dns_name);
882 if (!ntlmssp_state->server.dns_name) {
883 talloc_free(ntlmssp_state);
884 return NT_STATUS_NO_MEMORY;
886 ntlmssp_state->server.dns_domain = talloc_strdup(ntlmssp_state, dns_domain);
887 if (!ntlmssp_state->server.dns_domain) {
888 talloc_free(ntlmssp_state);
889 return NT_STATUS_NO_MEMORY;
892 *_ntlmssp_state = ntlmssp_state;
896 /*********************************************************************
898 *********************************************************************/
901 * Next state function for the Initial packet
903 * @param ntlmssp_state NTLMSSP State
904 * @param request The request, as a DATA_BLOB. reply.data must be NULL
905 * @param request The reply, as an allocated DATA_BLOB, caller to free.
906 * @return Errors or NT_STATUS_OK.
909 static NTSTATUS ntlmssp_client_initial(struct ntlmssp_state *ntlmssp_state,
910 DATA_BLOB reply, DATA_BLOB *next_request)
912 struct NEGOTIATE_MESSAGE negotiate;
914 if (ntlmssp_state->unicode) {
915 ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_UNICODE;
917 ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_OEM;
920 if (ntlmssp_state->use_ntlmv2) {
921 ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_NTLM2;
924 /* generate the ntlmssp negotiate packet */
925 msrpc_gen(ntlmssp_state, next_request, "CddAA",
928 ntlmssp_state->neg_flags,
929 ntlmssp_state->client.netbios_domain,
930 ntlmssp_state->client.netbios_name);
932 if (DEBUGLEVEL >= 10) {
933 if (NT_STATUS_IS_OK(ntlmssp_pull_NEGOTIATE_MESSAGE(next_request,
938 NDR_PRINT_DEBUG(NEGOTIATE_MESSAGE, &negotiate);
942 ntlmssp_state->expected_state = NTLMSSP_CHALLENGE;
944 return NT_STATUS_MORE_PROCESSING_REQUIRED;
948 * Next state function for the Challenge Packet. Generate an auth packet.
950 * @param ntlmssp_state NTLMSSP State
951 * @param request The request, as a DATA_BLOB. reply.data must be NULL
952 * @param request The reply, as an allocated DATA_BLOB, caller to free.
953 * @return Errors or NT_STATUS_OK.
956 static NTSTATUS ntlmssp_client_challenge(struct ntlmssp_state *ntlmssp_state,
957 const DATA_BLOB reply, DATA_BLOB *next_request)
959 uint32 chal_flags, ntlmssp_command, unkn1, unkn2;
960 DATA_BLOB server_domain_blob;
961 DATA_BLOB challenge_blob;
962 DATA_BLOB struct_blob = data_blob_null;
964 const char *chal_parse_string;
965 const char *auth_gen_string;
966 DATA_BLOB lm_response = data_blob_null;
967 DATA_BLOB nt_response = data_blob_null;
968 DATA_BLOB session_key = data_blob_null;
969 DATA_BLOB encrypted_session_key = data_blob_null;
970 NTSTATUS nt_status = NT_STATUS_OK;
971 struct CHALLENGE_MESSAGE challenge;
972 struct AUTHENTICATE_MESSAGE authenticate;
974 if (ntlmssp_state->use_ccache) {
975 struct wbcCredentialCacheParams params;
976 struct wbcCredentialCacheInfo *info = NULL;
977 struct wbcAuthErrorInfo *error = NULL;
978 struct wbcNamedBlob auth_blob;
979 struct wbcBlob *wbc_next = NULL;
980 struct wbcBlob *wbc_session_key = NULL;
984 params.account_name = ntlmssp_state->user;
985 params.domain_name = ntlmssp_state->domain;
986 params.level = WBC_CREDENTIAL_CACHE_LEVEL_NTLMSSP;
988 auth_blob.name = "challenge_blob";
990 auth_blob.blob.data = reply.data;
991 auth_blob.blob.length = reply.length;
992 params.num_blobs = 1;
993 params.blobs = &auth_blob;
995 wbc_status = wbcCredentialCache(¶ms, &info, &error);
997 wbcFreeMemory(error);
999 if (!WBC_ERROR_IS_OK(wbc_status)) {
1003 for (i=0; i<info->num_blobs; i++) {
1004 if (strequal(info->blobs[i].name, "auth_blob")) {
1005 wbc_next = &info->blobs[i].blob;
1007 if (strequal(info->blobs[i].name, "session_key")) {
1008 wbc_session_key = &info->blobs[i].blob;
1011 if ((wbc_next == NULL) || (wbc_session_key == NULL)) {
1012 wbcFreeMemory(info);
1016 *next_request = data_blob(wbc_next->data, wbc_next->length);
1017 ntlmssp_state->session_key = data_blob(
1018 wbc_session_key->data, wbc_session_key->length);
1020 wbcFreeMemory(info);
1026 if (!msrpc_parse(ntlmssp_state, &reply, "CdBd",
1029 &server_domain_blob,
1031 DEBUG(1, ("Failed to parse the NTLMSSP Challenge: (#1)\n"));
1032 dump_data(2, reply.data, reply.length);
1034 return NT_STATUS_INVALID_PARAMETER;
1037 if (DEBUGLEVEL >= 10) {
1038 if (NT_STATUS_IS_OK(ntlmssp_pull_CHALLENGE_MESSAGE(&reply,
1043 NDR_PRINT_DEBUG(CHALLENGE_MESSAGE, &challenge);
1047 data_blob_free(&server_domain_blob);
1049 DEBUG(3, ("Got challenge flags:\n"));
1050 debug_ntlmssp_flags(chal_flags);
1052 ntlmssp_handle_neg_flags(ntlmssp_state, chal_flags, lp_client_lanman_auth());
1054 if (ntlmssp_state->unicode) {
1055 if (chal_flags & NTLMSSP_NEGOTIATE_TARGET_INFO) {
1056 chal_parse_string = "CdUdbddB";
1058 chal_parse_string = "CdUdbdd";
1060 auth_gen_string = "CdBBUUUBd";
1062 if (chal_flags & NTLMSSP_NEGOTIATE_TARGET_INFO) {
1063 chal_parse_string = "CdAdbddB";
1065 chal_parse_string = "CdAdbdd";
1068 auth_gen_string = "CdBBAAABd";
1071 DEBUG(3, ("NTLMSSP: Set final flags:\n"));
1072 debug_ntlmssp_flags(ntlmssp_state->neg_flags);
1074 if (!msrpc_parse(ntlmssp_state, &reply, chal_parse_string,
1082 DEBUG(1, ("Failed to parse the NTLMSSP Challenge: (#2)\n"));
1083 dump_data(2, reply.data, reply.length);
1084 return NT_STATUS_INVALID_PARAMETER;
1087 if (chal_flags & NTLMSSP_TARGET_TYPE_SERVER) {
1088 ntlmssp_state->server.is_standalone = true;
1090 ntlmssp_state->server.is_standalone = false;
1092 /* TODO: parse struct_blob and fill in the rest */
1093 ntlmssp_state->server.netbios_name = "";
1094 ntlmssp_state->server.netbios_domain = server_domain;
1095 ntlmssp_state->server.dns_name = "";
1096 ntlmssp_state->server.dns_domain = "";
1098 if (challenge_blob.length != 8) {
1099 data_blob_free(&struct_blob);
1100 return NT_STATUS_INVALID_PARAMETER;
1103 if (!ntlmssp_state->nt_hash || !ntlmssp_state->lm_hash) {
1104 static const uint8_t zeros[16] = {0, };
1105 /* do nothing - blobs are zero length */
1107 /* session key is all zeros */
1108 session_key = data_blob_talloc(ntlmssp_state, zeros, 16);
1110 /* not doing NLTM2 without a password */
1111 ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_NTLM2;
1112 } else if (ntlmssp_state->use_ntlmv2) {
1113 if (!struct_blob.length) {
1114 /* be lazy, match win2k - we can't do NTLMv2 without it */
1115 DEBUG(1, ("Server did not provide 'target information', required for NTLMv2\n"));
1116 return NT_STATUS_INVALID_PARAMETER;
1119 /* TODO: if the remote server is standalone, then we should replace 'domain'
1120 with the server name as supplied above */
1122 if (!SMBNTLMv2encrypt_hash(ntlmssp_state,
1123 ntlmssp_state->user,
1124 ntlmssp_state->domain,
1125 ntlmssp_state->nt_hash, &challenge_blob,
1127 &lm_response, &nt_response, NULL,
1129 data_blob_free(&challenge_blob);
1130 data_blob_free(&struct_blob);
1131 return NT_STATUS_NO_MEMORY;
1133 } else if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_NTLM2) {
1134 struct MD5Context md5_session_nonce_ctx;
1135 uchar session_nonce[16];
1136 uchar session_nonce_hash[16];
1137 uchar user_session_key[16];
1139 lm_response = data_blob_talloc(ntlmssp_state, NULL, 24);
1140 generate_random_buffer(lm_response.data, 8);
1141 memset(lm_response.data+8, 0, 16);
1143 memcpy(session_nonce, challenge_blob.data, 8);
1144 memcpy(&session_nonce[8], lm_response.data, 8);
1146 MD5Init(&md5_session_nonce_ctx);
1147 MD5Update(&md5_session_nonce_ctx, challenge_blob.data, 8);
1148 MD5Update(&md5_session_nonce_ctx, lm_response.data, 8);
1149 MD5Final(session_nonce_hash, &md5_session_nonce_ctx);
1151 DEBUG(5, ("NTLMSSP challenge set by NTLM2\n"));
1152 DEBUG(5, ("challenge is: \n"));
1153 dump_data(5, session_nonce_hash, 8);
1155 nt_response = data_blob_talloc(ntlmssp_state, NULL, 24);
1156 SMBNTencrypt_hash(ntlmssp_state->nt_hash,
1160 session_key = data_blob_talloc(ntlmssp_state, NULL, 16);
1162 SMBsesskeygen_ntv1(ntlmssp_state->nt_hash, user_session_key);
1163 hmac_md5(user_session_key, session_nonce, sizeof(session_nonce), session_key.data);
1164 dump_data_pw("NTLM2 session key:\n", session_key.data, session_key.length);
1166 /* lanman auth is insecure, it may be disabled */
1167 if (lp_client_lanman_auth()) {
1168 lm_response = data_blob_talloc(ntlmssp_state,
1170 SMBencrypt_hash(ntlmssp_state->lm_hash,challenge_blob.data,
1174 nt_response = data_blob_talloc(ntlmssp_state, NULL, 24);
1175 SMBNTencrypt_hash(ntlmssp_state->nt_hash,challenge_blob.data,
1178 session_key = data_blob_talloc(ntlmssp_state, NULL, 16);
1179 if ((ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_LM_KEY)
1180 && lp_client_lanman_auth()) {
1181 SMBsesskeygen_lm_sess_key(ntlmssp_state->lm_hash, lm_response.data,
1183 dump_data_pw("LM session key\n", session_key.data, session_key.length);
1185 SMBsesskeygen_ntv1(ntlmssp_state->nt_hash, session_key.data);
1186 dump_data_pw("NT session key:\n", session_key.data, session_key.length);
1189 data_blob_free(&struct_blob);
1191 /* Key exchange encryptes a new client-generated session key with
1192 the password-derived key */
1193 if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_KEY_EXCH) {
1194 /* Make up a new session key */
1195 uint8 client_session_key[16];
1196 generate_random_buffer(client_session_key, sizeof(client_session_key));
1198 /* Encrypt the new session key with the old one */
1199 encrypted_session_key = data_blob(client_session_key, sizeof(client_session_key));
1200 dump_data_pw("KEY_EXCH session key:\n", encrypted_session_key.data, encrypted_session_key.length);
1201 arcfour_crypt_blob(encrypted_session_key.data, encrypted_session_key.length, &session_key);
1202 dump_data_pw("KEY_EXCH session key (enc):\n", encrypted_session_key.data, encrypted_session_key.length);
1204 /* Mark the new session key as the 'real' session key */
1205 data_blob_free(&session_key);
1206 session_key = data_blob_talloc(ntlmssp_state,
1208 sizeof(client_session_key));
1211 /* this generates the actual auth packet */
1212 if (!msrpc_gen(ntlmssp_state, next_request, auth_gen_string,
1215 lm_response.data, lm_response.length,
1216 nt_response.data, nt_response.length,
1217 ntlmssp_state->domain,
1218 ntlmssp_state->user,
1219 ntlmssp_state->client.netbios_name,
1220 encrypted_session_key.data, encrypted_session_key.length,
1221 ntlmssp_state->neg_flags)) {
1223 return NT_STATUS_NO_MEMORY;
1226 if (DEBUGLEVEL >= 10) {
1227 if (NT_STATUS_IS_OK(ntlmssp_pull_AUTHENTICATE_MESSAGE(next_request,
1232 NDR_PRINT_DEBUG(AUTHENTICATE_MESSAGE, &authenticate);
1236 data_blob_free(&encrypted_session_key);
1238 data_blob_free(&ntlmssp_state->chal);
1240 ntlmssp_state->session_key = session_key;
1242 ntlmssp_state->chal = challenge_blob;
1243 ntlmssp_state->lm_resp = lm_response;
1244 ntlmssp_state->nt_resp = nt_response;
1248 ntlmssp_state->expected_state = NTLMSSP_DONE;
1250 if (!NT_STATUS_IS_OK(nt_status = ntlmssp_sign_init(ntlmssp_state))) {
1251 DEBUG(1, ("Could not setup NTLMSSP signing/sealing system (error was: %s)\n", nt_errstr(nt_status)));
1257 NTSTATUS ntlmssp_client_start(TALLOC_CTX *mem_ctx,
1258 const char *netbios_name,
1259 const char *netbios_domain,
1261 struct ntlmssp_state **_ntlmssp_state)
1263 struct ntlmssp_state *ntlmssp_state;
1265 if (!netbios_name) {
1269 if (!netbios_domain) {
1270 netbios_domain = "";
1273 ntlmssp_state = talloc_zero(mem_ctx, struct ntlmssp_state);
1274 if (!ntlmssp_state) {
1275 return NT_STATUS_NO_MEMORY;
1278 ntlmssp_state->role = NTLMSSP_CLIENT;
1280 ntlmssp_state->unicode = True;
1282 ntlmssp_state->use_ntlmv2 = use_ntlmv2;
1284 ntlmssp_state->expected_state = NTLMSSP_INITIAL;
1286 ntlmssp_state->neg_flags =
1287 NTLMSSP_NEGOTIATE_128 |
1288 NTLMSSP_NEGOTIATE_ALWAYS_SIGN |
1289 NTLMSSP_NEGOTIATE_NTLM |
1290 NTLMSSP_NEGOTIATE_NTLM2 |
1291 NTLMSSP_NEGOTIATE_KEY_EXCH |
1292 NTLMSSP_REQUEST_TARGET;
1294 ntlmssp_state->client.netbios_name = talloc_strdup(ntlmssp_state, netbios_name);
1295 if (!ntlmssp_state->client.netbios_name) {
1296 talloc_free(ntlmssp_state);
1297 return NT_STATUS_NO_MEMORY;
1299 ntlmssp_state->client.netbios_domain = talloc_strdup(ntlmssp_state, netbios_domain);
1300 if (!ntlmssp_state->client.netbios_domain) {
1301 talloc_free(ntlmssp_state);
1302 return NT_STATUS_NO_MEMORY;
1305 *_ntlmssp_state = ntlmssp_state;
1306 return NT_STATUS_OK;