2 * Unix SMB/CIFS implementation.
4 * NTLMSSP Signing routines
5 * Copyright (C) Andrew Bartlett 2003-2005
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/>.
21 /* For structures internal to the NTLMSSP implementation that should not be exposed */
23 #include "../lib/crypto/arcfour.h"
25 struct auth_session_info;
27 struct ntlmssp_crypt_direction {
30 struct arcfour_state seal_state;
33 union ntlmssp_crypt_state {
35 struct ntlmssp_crypt_direction ntlm;
39 struct ntlmssp_crypt_direction sending;
40 struct ntlmssp_crypt_direction receiving;
44 /* The following definitions come from auth/ntlmssp.c */
46 void debug_ntlmssp_flags(uint32_t neg_flags);
47 void ntlmssp_handle_neg_flags(struct ntlmssp_state *ntlmssp_state,
48 uint32_t neg_flags, bool allow_lm);
50 /* The following definitions come from auth/ntlmssp_server.c */
52 const char *ntlmssp_target_name(struct ntlmssp_state *ntlmssp_state,
53 uint32_t neg_flags, uint32_t *chal_flags);
54 NTSTATUS ntlmssp_server_negotiate(struct ntlmssp_state *ntlmssp_state,
55 TALLOC_CTX *out_mem_ctx,
56 const DATA_BLOB in, DATA_BLOB *out);
57 NTSTATUS ntlmssp_server_auth(struct ntlmssp_state *ntlmssp_state,
58 TALLOC_CTX *out_mem_ctx,
59 const DATA_BLOB request, DATA_BLOB *reply);
60 /* The following definitions come from auth/ntlmssp/ntlmssp_client.c */
64 * Next state function for the Initial packet
66 * @param ntlmssp_state NTLMSSP State
67 * @param out_mem_ctx The DATA_BLOB *out will be allocated on this context
68 * @param in A NULL data blob (input ignored)
69 * @param out The initial negotiate request to the server, as an talloc()ed DATA_BLOB, on out_mem_ctx
70 * @return Errors or NT_STATUS_OK.
72 NTSTATUS ntlmssp_client_initial(struct gensec_security *gensec_security,
73 TALLOC_CTX *out_mem_ctx,
74 DATA_BLOB in, DATA_BLOB *out) ;
77 * Next state function for the Challenge Packet. Generate an auth packet.
79 * @param gensec_security GENSEC state
80 * @param out_mem_ctx Memory context for *out
81 * @param in The server challnege, as a DATA_BLOB. reply.data must be NULL
82 * @param out The next request (auth packet) to the server, as an allocated DATA_BLOB, on the out_mem_ctx context
83 * @return Errors or NT_STATUS_OK.
85 NTSTATUS ntlmssp_client_challenge(struct gensec_security *gensec_security,
86 TALLOC_CTX *out_mem_ctx,
87 const DATA_BLOB in, DATA_BLOB *out) ;
88 NTSTATUS gensec_ntlmssp_client_start(struct gensec_security *gensec_security);
90 /* The following definitions come from auth/ntlmssp/ntlmssp_server.c */
94 * Next state function for the Negotiate packet (GENSEC wrapper)
96 * @param gensec_security GENSEC state
97 * @param out_mem_ctx Memory context for *out
98 * @param in The request, as a DATA_BLOB. reply.data must be NULL
99 * @param out The reply, as an allocated DATA_BLOB, caller to free.
100 * @return Errors or MORE_PROCESSING_REQUIRED if (normal) a reply is required.
102 NTSTATUS gensec_ntlmssp_server_negotiate(struct gensec_security *gensec_security,
103 TALLOC_CTX *out_mem_ctx,
104 const DATA_BLOB request, DATA_BLOB *reply);
107 * Next state function for the Authenticate packet (GENSEC wrapper)
109 * @param gensec_security GENSEC state
110 * @param out_mem_ctx Memory context for *out
111 * @param in The request, as a DATA_BLOB. reply.data must be NULL
112 * @param out The reply, as an allocated DATA_BLOB, caller to free.
113 * @return Errors or NT_STATUS_OK if authentication sucessful
115 NTSTATUS gensec_ntlmssp_server_auth(struct gensec_security *gensec_security,
116 TALLOC_CTX *out_mem_ctx,
117 const DATA_BLOB in, DATA_BLOB *out);
120 * Return the credentials of a logged on user, including session keys
123 * Only valid after a successful authentication
125 * May only be called once per authentication.
128 NTSTATUS gensec_ntlmssp_session_info(struct gensec_security *gensec_security,
130 struct auth_session_info **session_info) ;
133 * Start NTLMSSP on the server side
136 NTSTATUS gensec_ntlmssp_server_start(struct gensec_security *gensec_security);
139 * Return the challenge as determined by the authentication subsystem
140 * @return an 8 byte random challenge
143 NTSTATUS auth_ntlmssp_get_challenge(const struct ntlmssp_state *ntlmssp_state,
147 * Some authentication methods 'fix' the challenge, so we may not be able to set it
149 * @return If the effective challenge used by the auth subsystem may be modified
151 bool auth_ntlmssp_may_set_challenge(const struct ntlmssp_state *ntlmssp_state);
154 * NTLM2 authentication modifies the effective challenge,
155 * @param challenge The new challenge value
157 NTSTATUS auth_ntlmssp_set_challenge(struct ntlmssp_state *ntlmssp_state, DATA_BLOB *challenge);
160 * Check the password on an NTLMSSP login.
162 * Return the session keys used on the connection.
165 NTSTATUS auth_ntlmssp_check_password(struct ntlmssp_state *ntlmssp_state,
167 DATA_BLOB *user_session_key, DATA_BLOB *lm_session_key);