2 Unix SMB/Netbios implementation.
4 handle NLTMSSP, server side
6 Copyright (C) Andrew Tridgell 2001
7 Copyright (C) Andrew Bartlett 2001-2010
8 Copyright (C) Stefan Metzmacher 2005
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 "../auth/ntlmssp/ntlmssp.h"
26 #include "../auth/ntlmssp/ntlmssp_private.h"
27 #include "../libcli/auth/libcli_auth.h"
28 #include "../librpc/gen_ndr/ndr_ntlmssp.h"
29 #include "../auth/ntlmssp/ntlmssp_ndr.h"
30 #include "../lib/crypto/md5.h"
31 #include "../lib/crypto/arcfour.h"
32 #include "../lib/crypto/hmacmd5.h"
33 #include "../nsswitch/libwbclient/wbclient.h"
35 static NTSTATUS
ntlmssp3_client_initial(struct ntlmssp_state
*ntlmssp_state
,
36 TALLOC_CTX
*out_mem_ctx
,
37 DATA_BLOB reply
, DATA_BLOB
*next_request
);
38 static NTSTATUS
ntlmssp3_client_challenge(struct ntlmssp_state
*ntlmssp_state
,
39 TALLOC_CTX
*out_mem_ctx
, /* Unused at this time */
40 const DATA_BLOB reply
, DATA_BLOB
*next_request
);
42 * Callbacks for NTLMSSP - for both client and server operating modes
46 static const struct ntlmssp_callbacks
{
47 enum ntlmssp_role role
;
48 enum ntlmssp_message_type ntlmssp_command
;
49 NTSTATUS (*fn
)(struct ntlmssp_state
*ntlmssp_state
,
50 TALLOC_CTX
*out_mem_ctx
,
51 DATA_BLOB in
, DATA_BLOB
*out
);
52 } ntlmssp_callbacks
[] = {
53 {NTLMSSP_CLIENT
, NTLMSSP_INITIAL
, ntlmssp3_client_initial
},
54 {NTLMSSP_CLIENT
, NTLMSSP_CHALLENGE
, ntlmssp3_client_challenge
},
55 {NTLMSSP_CLIENT
, NTLMSSP_UNKNOWN
, NULL
},
56 {NTLMSSP_SERVER
, NTLMSSP_UNKNOWN
, NULL
}
60 * Set a username on an NTLMSSP context - ensures it is talloc()ed
64 NTSTATUS
ntlmssp_set_username(struct ntlmssp_state
*ntlmssp_state
, const char *user
)
66 ntlmssp_state
->user
= talloc_strdup(ntlmssp_state
, user
? user
: "" );
67 if (!ntlmssp_state
->user
) {
68 return NT_STATUS_NO_MEMORY
;
74 * Converts a password to the hashes on an NTLMSSP context.
77 NTSTATUS
ntlmssp_set_password(struct ntlmssp_state
*ntlmssp_state
, const char *password
)
82 TALLOC_FREE(ntlmssp_state
->lm_hash
);
83 TALLOC_FREE(ntlmssp_state
->nt_hash
);
85 if (password
== NULL
) {
89 if (E_deshash(password
, lm_hash
)) {
90 ntlmssp_state
->lm_hash
= (uint8_t *)
91 talloc_memdup(ntlmssp_state
, lm_hash
, 16);
92 if (!ntlmssp_state
->lm_hash
) {
93 return NT_STATUS_NO_MEMORY
;
97 E_md4hash(password
, nt_hash
);
99 ntlmssp_state
->nt_hash
= (uint8_t *)
100 talloc_memdup(ntlmssp_state
, nt_hash
, 16);
101 if (!ntlmssp_state
->nt_hash
) {
102 TALLOC_FREE(ntlmssp_state
->lm_hash
);
103 return NT_STATUS_NO_MEMORY
;
110 * Set a domain on an NTLMSSP context - ensures it is talloc()ed
113 NTSTATUS
ntlmssp_set_domain(struct ntlmssp_state
*ntlmssp_state
, const char *domain
)
115 ntlmssp_state
->domain
= talloc_strdup(ntlmssp_state
,
116 domain
? domain
: "" );
117 if (!ntlmssp_state
->domain
) {
118 return NT_STATUS_NO_MEMORY
;
124 * Request features for the NTLMSSP negotiation
126 * @param ntlmssp_state NTLMSSP state
127 * @param feature_list List of space seperated features requested from NTLMSSP.
129 void ntlmssp_want_feature_list(struct ntlmssp_state
*ntlmssp_state
, char *feature_list
)
132 * We need to set this to allow a later SetPassword
133 * via the SAMR pipe to succeed. Strange.... We could
134 * also add NTLMSSP_NEGOTIATE_SEAL here. JRA.
136 if (in_list("NTLMSSP_FEATURE_SESSION_KEY", feature_list
, True
)) {
137 ntlmssp_state
->neg_flags
|= NTLMSSP_NEGOTIATE_SIGN
;
139 if (in_list("NTLMSSP_FEATURE_SIGN", feature_list
, True
)) {
140 ntlmssp_state
->neg_flags
|= NTLMSSP_NEGOTIATE_SIGN
;
142 if(in_list("NTLMSSP_FEATURE_SEAL", feature_list
, True
)) {
143 ntlmssp_state
->neg_flags
|= NTLMSSP_NEGOTIATE_SEAL
;
145 if (in_list("NTLMSSP_FEATURE_CCACHE", feature_list
, true)) {
146 ntlmssp_state
->use_ccache
= true;
151 * Request a feature for the NTLMSSP negotiation
153 * @param ntlmssp_state NTLMSSP state
154 * @param feature Bit flag specifying the requested feature
156 void ntlmssp_want_feature(struct ntlmssp_state
*ntlmssp_state
, uint32_t feature
)
158 /* As per JRA's comment above */
159 if (feature
& NTLMSSP_FEATURE_SESSION_KEY
) {
160 ntlmssp_state
->neg_flags
|= NTLMSSP_NEGOTIATE_SIGN
;
162 if (feature
& NTLMSSP_FEATURE_SIGN
) {
163 ntlmssp_state
->neg_flags
|= NTLMSSP_NEGOTIATE_SIGN
;
165 if (feature
& NTLMSSP_FEATURE_SEAL
) {
166 ntlmssp_state
->neg_flags
|= NTLMSSP_NEGOTIATE_SIGN
;
167 ntlmssp_state
->neg_flags
|= NTLMSSP_NEGOTIATE_SEAL
;
169 if (feature
& NTLMSSP_FEATURE_CCACHE
) {
170 ntlmssp_state
->use_ccache
= true;
175 * Next state function for the NTLMSSP state machine
177 * @param ntlmssp_state NTLMSSP State
178 * @param in The packet in from the NTLMSSP partner, as a DATA_BLOB
179 * @param out The reply, as an allocated DATA_BLOB, caller to free.
180 * @return Errors, NT_STATUS_MORE_PROCESSING_REQUIRED or NT_STATUS_OK.
183 NTSTATUS
ntlmssp_update(struct ntlmssp_state
*ntlmssp_state
,
184 const DATA_BLOB input
, DATA_BLOB
*out
)
186 uint32_t ntlmssp_command
;
189 if (ntlmssp_state
->expected_state
== NTLMSSP_DONE
) {
190 /* Called update after negotiations finished. */
191 DEBUG(1, ("Called NTLMSSP after state machine was 'done'\n"));
192 return NT_STATUS_INVALID_PARAMETER
;
195 *out
= data_blob_null
;
198 switch (ntlmssp_state
->role
) {
200 ntlmssp_command
= NTLMSSP_INITIAL
;
203 /* 'datagram' mode - no neg packet */
204 ntlmssp_command
= NTLMSSP_NEGOTIATE
;
207 DEBUG(1, ("Invalid role: %d\n", ntlmssp_state
->role
));
208 return NT_STATUS_INVALID_PARAMETER
;
211 if (!msrpc_parse(ntlmssp_state
, &input
, "Cd",
214 DEBUG(1, ("Failed to parse NTLMSSP packet, could not extract NTLMSSP command\n"));
215 dump_data(2, input
.data
, input
.length
);
216 return NT_STATUS_INVALID_PARAMETER
;
220 if (ntlmssp_command
!= ntlmssp_state
->expected_state
) {
221 DEBUG(1, ("got NTLMSSP command %u, expected %u\n", ntlmssp_command
, ntlmssp_state
->expected_state
));
222 return NT_STATUS_INVALID_PARAMETER
;
225 for (i
=0; ntlmssp_callbacks
[i
].fn
; i
++) {
226 if (ntlmssp_callbacks
[i
].role
== ntlmssp_state
->role
227 && ntlmssp_callbacks
[i
].ntlmssp_command
== ntlmssp_command
) {
228 return ntlmssp_callbacks
[i
].fn(ntlmssp_state
, ntlmssp_state
, input
, out
);
232 DEBUG(1, ("failed to find NTLMSSP callback for NTLMSSP mode %u, command %u\n",
233 ntlmssp_state
->role
, ntlmssp_command
));
235 return NT_STATUS_INVALID_PARAMETER
;
238 /*********************************************************************
240 *********************************************************************/
243 * Next state function for the Initial packet
245 * @param ntlmssp_state NTLMSSP State
246 * @param request The request, as a DATA_BLOB. reply.data must be NULL
247 * @param request The reply, as an allocated DATA_BLOB, caller to free.
248 * @return Errors or NT_STATUS_OK.
251 static NTSTATUS
ntlmssp3_client_initial(struct ntlmssp_state
*ntlmssp_state
,
252 TALLOC_CTX
*out_mem_ctx
,
253 DATA_BLOB in
, DATA_BLOB
*out
)
255 const char *domain
= ntlmssp_state
->client
.netbios_domain
;
256 const char *workstation
= ntlmssp_state
->client
.netbios_name
;
259 /* These don't really matter in the initial packet, so don't panic if they are not set */
268 if (ntlmssp_state
->unicode
) {
269 ntlmssp_state
->neg_flags
|= NTLMSSP_NEGOTIATE_UNICODE
;
271 ntlmssp_state
->neg_flags
|= NTLMSSP_NEGOTIATE_OEM
;
274 if (ntlmssp_state
->use_ntlmv2
) {
275 ntlmssp_state
->neg_flags
|= NTLMSSP_NEGOTIATE_NTLM2
;
278 /* generate the ntlmssp negotiate packet */
279 status
= msrpc_gen(out_mem_ctx
,
283 ntlmssp_state
->neg_flags
,
287 if (!NT_STATUS_IS_OK(status
)) {
288 DEBUG(0, ("ntlmssp_client_initial: failed to generate "
289 "ntlmssp negotiate packet\n"));
293 if (DEBUGLEVEL
>= 10) {
294 struct NEGOTIATE_MESSAGE
*negotiate
= talloc(
295 talloc_tos(), struct NEGOTIATE_MESSAGE
);
296 if (negotiate
!= NULL
) {
297 status
= ntlmssp_pull_NEGOTIATE_MESSAGE(
298 out
, negotiate
, negotiate
);
299 if (NT_STATUS_IS_OK(status
)) {
300 NDR_PRINT_DEBUG(NEGOTIATE_MESSAGE
,
303 TALLOC_FREE(negotiate
);
307 ntlmssp_state
->expected_state
= NTLMSSP_CHALLENGE
;
309 return NT_STATUS_MORE_PROCESSING_REQUIRED
;
312 bool ntlmssp_is_anonymous(struct ntlmssp_state
*ntlmssp_state
)
314 const char *user
= ntlmssp_state
->user
;
320 if (strlen(user
) == 0) {
328 * Next state function for the Challenge Packet. Generate an auth packet.
330 * @param ntlmssp_state NTLMSSP State
331 * @param request The request, as a DATA_BLOB. reply.data must be NULL
332 * @param request The reply, as an allocated DATA_BLOB, caller to free.
333 * @return Errors or NT_STATUS_OK.
336 static NTSTATUS
ntlmssp3_client_challenge(struct ntlmssp_state
*ntlmssp_state
,
337 TALLOC_CTX
*out_mem_ctx
, /* Unused at this time */
338 const DATA_BLOB reply
, DATA_BLOB
*next_request
)
340 uint32_t chal_flags
, ntlmssp_command
, unkn1
, unkn2
;
341 DATA_BLOB server_domain_blob
;
342 DATA_BLOB challenge_blob
;
343 DATA_BLOB struct_blob
= data_blob_null
;
345 const char *chal_parse_string
;
346 const char *auth_gen_string
;
347 DATA_BLOB lm_response
= data_blob_null
;
348 DATA_BLOB nt_response
= data_blob_null
;
349 DATA_BLOB session_key
= data_blob_null
;
350 DATA_BLOB encrypted_session_key
= data_blob_null
;
351 NTSTATUS nt_status
= NT_STATUS_OK
;
352 bool anon
= ntlmssp_is_anonymous(ntlmssp_state
);
354 if (!anon
&& ntlmssp_state
->use_ccache
) {
355 struct wbcCredentialCacheParams params
;
356 struct wbcCredentialCacheInfo
*info
= NULL
;
357 struct wbcAuthErrorInfo
*error
= NULL
;
358 struct wbcNamedBlob auth_blob
;
359 struct wbcBlob
*wbc_next
= NULL
;
360 struct wbcBlob
*wbc_session_key
= NULL
;
364 params
.account_name
= ntlmssp_state
->user
;
365 params
.domain_name
= ntlmssp_state
->domain
;
366 params
.level
= WBC_CREDENTIAL_CACHE_LEVEL_NTLMSSP
;
368 auth_blob
.name
= "challenge_blob";
370 auth_blob
.blob
.data
= reply
.data
;
371 auth_blob
.blob
.length
= reply
.length
;
372 params
.num_blobs
= 1;
373 params
.blobs
= &auth_blob
;
375 wbc_status
= wbcCredentialCache(¶ms
, &info
, &error
);
376 wbcFreeMemory(error
);
377 if (!WBC_ERROR_IS_OK(wbc_status
)) {
381 for (i
=0; i
<info
->num_blobs
; i
++) {
382 if (strequal(info
->blobs
[i
].name
, "auth_blob")) {
383 wbc_next
= &info
->blobs
[i
].blob
;
385 if (strequal(info
->blobs
[i
].name
, "session_key")) {
386 wbc_session_key
= &info
->blobs
[i
].blob
;
389 if ((wbc_next
== NULL
) || (wbc_session_key
== NULL
)) {
394 *next_request
= data_blob(wbc_next
->data
, wbc_next
->length
);
395 ntlmssp_state
->session_key
= data_blob(
396 wbc_session_key
->data
, wbc_session_key
->length
);
404 if (!msrpc_parse(ntlmssp_state
, &reply
, "CdBd",
409 DEBUG(1, ("Failed to parse the NTLMSSP Challenge: (#1)\n"));
410 dump_data(2, reply
.data
, reply
.length
);
412 return NT_STATUS_INVALID_PARAMETER
;
415 if (DEBUGLEVEL
>= 10) {
416 struct CHALLENGE_MESSAGE
*challenge
= talloc(
417 talloc_tos(), struct CHALLENGE_MESSAGE
);
418 if (challenge
!= NULL
) {
420 challenge
->NegotiateFlags
= chal_flags
;
421 status
= ntlmssp_pull_CHALLENGE_MESSAGE(
422 &reply
, challenge
, challenge
);
423 if (NT_STATUS_IS_OK(status
)) {
424 NDR_PRINT_DEBUG(CHALLENGE_MESSAGE
,
427 TALLOC_FREE(challenge
);
431 data_blob_free(&server_domain_blob
);
433 DEBUG(3, ("Got challenge flags:\n"));
434 debug_ntlmssp_flags(chal_flags
);
436 ntlmssp_handle_neg_flags(ntlmssp_state
, chal_flags
, lp_client_lanman_auth());
438 if (ntlmssp_state
->unicode
) {
439 if (chal_flags
& NTLMSSP_NEGOTIATE_TARGET_INFO
) {
440 chal_parse_string
= "CdUdbddB";
442 chal_parse_string
= "CdUdbdd";
444 auth_gen_string
= "CdBBUUUBd";
446 if (chal_flags
& NTLMSSP_NEGOTIATE_TARGET_INFO
) {
447 chal_parse_string
= "CdAdbddB";
449 chal_parse_string
= "CdAdbdd";
452 auth_gen_string
= "CdBBAAABd";
455 DEBUG(3, ("NTLMSSP: Set final flags:\n"));
456 debug_ntlmssp_flags(ntlmssp_state
->neg_flags
);
458 if (!msrpc_parse(ntlmssp_state
, &reply
, chal_parse_string
,
466 DEBUG(1, ("Failed to parse the NTLMSSP Challenge: (#2)\n"));
467 dump_data(2, reply
.data
, reply
.length
);
468 return NT_STATUS_INVALID_PARAMETER
;
471 if (chal_flags
& NTLMSSP_TARGET_TYPE_SERVER
) {
472 ntlmssp_state
->server
.is_standalone
= true;
474 ntlmssp_state
->server
.is_standalone
= false;
476 /* TODO: parse struct_blob and fill in the rest */
477 ntlmssp_state
->server
.netbios_name
= "";
478 ntlmssp_state
->server
.netbios_domain
= server_domain
;
479 ntlmssp_state
->server
.dns_name
= "";
480 ntlmssp_state
->server
.dns_domain
= "";
482 if (challenge_blob
.length
!= 8) {
483 data_blob_free(&struct_blob
);
484 return NT_STATUS_INVALID_PARAMETER
;
487 if (anon
|| !ntlmssp_state
->nt_hash
) {
488 static const uint8_t zeros
[16] = {0, };
489 /* do nothing - blobs are zero length */
491 /* session key is all zeros */
492 session_key
= data_blob_talloc(ntlmssp_state
, zeros
, 16);
494 /* not doing NLTM2 without a password */
495 ntlmssp_state
->neg_flags
&= ~NTLMSSP_NEGOTIATE_NTLM2
;
496 } else if (ntlmssp_state
->use_ntlmv2
) {
497 if (!struct_blob
.length
) {
498 /* be lazy, match win2k - we can't do NTLMv2 without it */
499 DEBUG(1, ("Server did not provide 'target information', required for NTLMv2\n"));
500 return NT_STATUS_INVALID_PARAMETER
;
503 /* TODO: if the remote server is standalone, then we should replace 'domain'
504 with the server name as supplied above */
506 if (!SMBNTLMv2encrypt_hash(ntlmssp_state
,
508 ntlmssp_state
->domain
,
509 ntlmssp_state
->nt_hash
, &challenge_blob
,
511 &lm_response
, &nt_response
, NULL
,
513 data_blob_free(&challenge_blob
);
514 data_blob_free(&struct_blob
);
515 return NT_STATUS_NO_MEMORY
;
517 } else if (ntlmssp_state
->neg_flags
& NTLMSSP_NEGOTIATE_NTLM2
) {
518 struct MD5Context md5_session_nonce_ctx
;
519 uint8_t session_nonce
[16];
520 uint8_t session_nonce_hash
[16];
521 uint8_t user_session_key
[16];
523 lm_response
= data_blob_talloc(ntlmssp_state
, NULL
, 24);
524 generate_random_buffer(lm_response
.data
, 8);
525 memset(lm_response
.data
+8, 0, 16);
527 memcpy(session_nonce
, challenge_blob
.data
, 8);
528 memcpy(&session_nonce
[8], lm_response
.data
, 8);
530 MD5Init(&md5_session_nonce_ctx
);
531 MD5Update(&md5_session_nonce_ctx
, challenge_blob
.data
, 8);
532 MD5Update(&md5_session_nonce_ctx
, lm_response
.data
, 8);
533 MD5Final(session_nonce_hash
, &md5_session_nonce_ctx
);
535 DEBUG(5, ("NTLMSSP challenge set by NTLM2\n"));
536 DEBUG(5, ("challenge is: \n"));
537 dump_data(5, session_nonce_hash
, 8);
539 nt_response
= data_blob_talloc(ntlmssp_state
, NULL
, 24);
540 SMBNTencrypt_hash(ntlmssp_state
->nt_hash
,
544 session_key
= data_blob_talloc(ntlmssp_state
, NULL
, 16);
546 SMBsesskeygen_ntv1(ntlmssp_state
->nt_hash
, user_session_key
);
547 hmac_md5(user_session_key
, session_nonce
, sizeof(session_nonce
), session_key
.data
);
548 dump_data_pw("NTLM2 session key:\n", session_key
.data
, session_key
.length
);
550 /* lanman auth is insecure, it may be disabled */
551 if (lp_client_lanman_auth() && ntlmssp_state
->lm_hash
) {
552 lm_response
= data_blob_talloc(ntlmssp_state
,
554 SMBencrypt_hash(ntlmssp_state
->lm_hash
,challenge_blob
.data
,
558 nt_response
= data_blob_talloc(ntlmssp_state
, NULL
, 24);
559 SMBNTencrypt_hash(ntlmssp_state
->nt_hash
,challenge_blob
.data
,
562 session_key
= data_blob_talloc(ntlmssp_state
, NULL
, 16);
563 if ((ntlmssp_state
->neg_flags
& NTLMSSP_NEGOTIATE_LM_KEY
)
564 && lp_client_lanman_auth() && ntlmssp_state
->lm_hash
) {
565 SMBsesskeygen_lm_sess_key(ntlmssp_state
->lm_hash
, lm_response
.data
,
567 dump_data_pw("LM session key\n", session_key
.data
, session_key
.length
);
569 SMBsesskeygen_ntv1(ntlmssp_state
->nt_hash
, session_key
.data
);
570 dump_data_pw("NT session key:\n", session_key
.data
, session_key
.length
);
573 data_blob_free(&struct_blob
);
575 /* Key exchange encryptes a new client-generated session key with
576 the password-derived key */
577 if (ntlmssp_state
->neg_flags
& NTLMSSP_NEGOTIATE_KEY_EXCH
) {
578 /* Make up a new session key */
579 uint8_t client_session_key
[16];
580 generate_random_buffer(client_session_key
, sizeof(client_session_key
));
582 /* Encrypt the new session key with the old one */
583 encrypted_session_key
= data_blob(client_session_key
, sizeof(client_session_key
));
584 dump_data_pw("KEY_EXCH session key:\n", encrypted_session_key
.data
, encrypted_session_key
.length
);
585 arcfour_crypt_blob(encrypted_session_key
.data
, encrypted_session_key
.length
, &session_key
);
586 dump_data_pw("KEY_EXCH session key (enc):\n", encrypted_session_key
.data
, encrypted_session_key
.length
);
588 /* Mark the new session key as the 'real' session key */
589 data_blob_free(&session_key
);
590 session_key
= data_blob_talloc(ntlmssp_state
,
592 sizeof(client_session_key
));
595 /* this generates the actual auth packet */
596 nt_status
= msrpc_gen(ntlmssp_state
, next_request
, auth_gen_string
,
599 lm_response
.data
, lm_response
.length
,
600 nt_response
.data
, nt_response
.length
,
601 ntlmssp_state
->domain
,
603 ntlmssp_state
->client
.netbios_name
,
604 encrypted_session_key
.data
, encrypted_session_key
.length
,
605 ntlmssp_state
->neg_flags
);
607 if (!NT_STATUS_IS_OK(nt_status
)) {
608 return NT_STATUS_NO_MEMORY
;
611 if (DEBUGLEVEL
>= 10) {
612 struct AUTHENTICATE_MESSAGE
*authenticate
= talloc(
613 talloc_tos(), struct AUTHENTICATE_MESSAGE
);
614 if (authenticate
!= NULL
) {
616 authenticate
->NegotiateFlags
=
617 ntlmssp_state
->neg_flags
;
618 status
= ntlmssp_pull_AUTHENTICATE_MESSAGE(
619 next_request
, authenticate
, authenticate
);
620 if (NT_STATUS_IS_OK(status
)) {
621 NDR_PRINT_DEBUG(AUTHENTICATE_MESSAGE
,
624 TALLOC_FREE(authenticate
);
628 data_blob_free(&encrypted_session_key
);
630 data_blob_free(&ntlmssp_state
->chal
);
632 ntlmssp_state
->session_key
= session_key
;
634 ntlmssp_state
->chal
= challenge_blob
;
635 ntlmssp_state
->lm_resp
= lm_response
;
636 ntlmssp_state
->nt_resp
= nt_response
;
640 ntlmssp_state
->expected_state
= NTLMSSP_DONE
;
642 if (!NT_STATUS_IS_OK(nt_status
= ntlmssp_sign_init(ntlmssp_state
))) {
643 DEBUG(1, ("Could not setup NTLMSSP signing/sealing system (error was: %s)\n", nt_errstr(nt_status
)));
649 NTSTATUS
ntlmssp_client_start(TALLOC_CTX
*mem_ctx
,
650 const char *netbios_name
,
651 const char *netbios_domain
,
653 struct ntlmssp_state
**_ntlmssp_state
)
655 struct ntlmssp_state
*ntlmssp_state
;
661 if (!netbios_domain
) {
665 ntlmssp_state
= talloc_zero(mem_ctx
, struct ntlmssp_state
);
666 if (!ntlmssp_state
) {
667 return NT_STATUS_NO_MEMORY
;
670 ntlmssp_state
->role
= NTLMSSP_CLIENT
;
672 ntlmssp_state
->unicode
= True
;
674 ntlmssp_state
->use_ntlmv2
= use_ntlmv2
;
676 ntlmssp_state
->expected_state
= NTLMSSP_INITIAL
;
678 ntlmssp_state
->neg_flags
=
679 NTLMSSP_NEGOTIATE_128
|
680 NTLMSSP_NEGOTIATE_ALWAYS_SIGN
|
681 NTLMSSP_NEGOTIATE_NTLM
|
682 NTLMSSP_NEGOTIATE_NTLM2
|
683 NTLMSSP_NEGOTIATE_KEY_EXCH
|
684 NTLMSSP_REQUEST_TARGET
;
686 ntlmssp_state
->client
.netbios_name
= talloc_strdup(ntlmssp_state
, netbios_name
);
687 if (!ntlmssp_state
->client
.netbios_name
) {
688 talloc_free(ntlmssp_state
);
689 return NT_STATUS_NO_MEMORY
;
691 ntlmssp_state
->client
.netbios_domain
= talloc_strdup(ntlmssp_state
, netbios_domain
);
692 if (!ntlmssp_state
->client
.netbios_domain
) {
693 talloc_free(ntlmssp_state
);
694 return NT_STATUS_NO_MEMORY
;
697 *_ntlmssp_state
= ntlmssp_state
;