4 Copyright (C) Andrew Tridgell 2001
5 Copyright (C) Andrew Bartlett 2001-2003
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "libcli/auth/ntlmssp.h"
23 #include "ntlmssp_wrap.h"
25 NTSTATUS auth_ntlmssp_sign_packet(struct auth_ntlmssp_state *ans,
26 TALLOC_CTX *sig_mem_ctx,
29 const uint8_t *whole_pdu,
33 return ntlmssp_sign_packet(ans->ntlmssp_state,
36 whole_pdu, pdu_length,
40 NTSTATUS auth_ntlmssp_check_packet(struct auth_ntlmssp_state *ans,
43 const uint8_t *whole_pdu,
47 return ntlmssp_check_packet(ans->ntlmssp_state,
49 whole_pdu, pdu_length,
53 NTSTATUS auth_ntlmssp_seal_packet(struct auth_ntlmssp_state *ans,
54 TALLOC_CTX *sig_mem_ctx,
57 const uint8_t *whole_pdu,
61 return ntlmssp_seal_packet(ans->ntlmssp_state,
64 whole_pdu, pdu_length,
68 NTSTATUS auth_ntlmssp_unseal_packet(struct auth_ntlmssp_state *ans,
71 const uint8_t *whole_pdu,
75 return ntlmssp_unseal_packet(ans->ntlmssp_state,
77 whole_pdu, pdu_length,
81 bool auth_ntlmssp_negotiated_sign(struct auth_ntlmssp_state *ans)
83 return ans->ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_SIGN;
86 bool auth_ntlmssp_negotiated_seal(struct auth_ntlmssp_state *ans)
88 return ans->ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_SEAL;
91 struct ntlmssp_state *auth_ntlmssp_get_ntlmssp_state(
92 struct auth_ntlmssp_state *ans)
94 return ans->ntlmssp_state;
97 /* Needed for 'smb username' processing */
98 const char *auth_ntlmssp_get_username(struct auth_ntlmssp_state *ans)
100 return ans->ntlmssp_state->user;
103 const uint8_t *auth_ntlmssp_get_nt_hash(struct auth_ntlmssp_state *ans)
105 return ans->ntlmssp_state->nt_hash;
108 NTSTATUS auth_ntlmssp_set_username(struct auth_ntlmssp_state *ans,
111 return ntlmssp_set_username(ans->ntlmssp_state, user);
114 NTSTATUS auth_ntlmssp_set_domain(struct auth_ntlmssp_state *ans,
117 return ntlmssp_set_domain(ans->ntlmssp_state, domain);
120 NTSTATUS auth_ntlmssp_set_password(struct auth_ntlmssp_state *ans,
121 const char *password)
123 return ntlmssp_set_password(ans->ntlmssp_state, password);
126 void auth_ntlmssp_and_flags(struct auth_ntlmssp_state *ans, uint32_t flags)
128 ans->ntlmssp_state->neg_flags &= flags;
131 void auth_ntlmssp_or_flags(struct auth_ntlmssp_state *ans, uint32_t flags)
133 ans->ntlmssp_state->neg_flags |= flags;
136 DATA_BLOB auth_ntlmssp_get_session_key(struct auth_ntlmssp_state *ans)
138 return ans->ntlmssp_state->session_key;
141 NTSTATUS auth_ntlmssp_update(struct auth_ntlmssp_state *ans,
142 const DATA_BLOB request, DATA_BLOB *reply)
144 return ntlmssp_update(ans->ntlmssp_state, request, reply);
147 NTSTATUS auth_ntlmssp_client_start(TALLOC_CTX *mem_ctx,
148 const char *netbios_name,
149 const char *netbios_domain,
151 struct auth_ntlmssp_state **_ans)
153 struct auth_ntlmssp_state *ans;
156 ans = talloc_zero(mem_ctx, struct auth_ntlmssp_state);
158 status = ntlmssp_client_start(ans,
159 netbios_name, netbios_domain,
160 use_ntlmv2, &ans->ntlmssp_state);
161 if (!NT_STATUS_IS_OK(status)) {