clitar: add error return to tar_create_skip_path()
[Samba.git] / auth / gensec / gensec.h
blob6974f8708b5088021b774ffd936a6797002e3ce4
1 /*
2 Unix SMB/CIFS implementation.
4 Generic Authentication Interface
6 Copyright (C) Andrew Tridgell 2003
7 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2004-2005
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #ifndef __GENSEC_H__
24 #define __GENSEC_H__
26 #include "../lib/util/data_blob.h"
27 #include "libcli/util/ntstatus.h"
29 #define GENSEC_SASL_NAME_NTLMSSP "NTLM"
31 #define GENSEC_OID_NTLMSSP "1.3.6.1.4.1.311.2.2.10"
32 #define GENSEC_OID_SPNEGO "1.3.6.1.5.5.2"
33 #define GENSEC_OID_KERBEROS5 "1.2.840.113554.1.2.2"
34 #define GENSEC_OID_KERBEROS5_OLD "1.2.840.48018.1.2.2"
35 #define GENSEC_OID_KERBEROS5_USER2USER "1.2.840.113554.1.2.2.3"
37 enum gensec_priority {
38 GENSEC_SPNEGO = 90,
39 GENSEC_GSSAPI = 80,
40 GENSEC_KRB5 = 70,
41 GENSEC_SCHANNEL = 60,
42 GENSEC_NTLMSSP = 50,
43 GENSEC_SASL = 20,
44 GENSEC_OTHER = 10,
45 GENSEC_EXTERNAL = 0
48 struct gensec_security;
49 struct gensec_target {
50 const char *principal;
51 const char *hostname;
52 const char *service;
55 #define GENSEC_FEATURE_SESSION_KEY 0x00000001
56 #define GENSEC_FEATURE_SIGN 0x00000002
57 #define GENSEC_FEATURE_SEAL 0x00000004
58 #define GENSEC_FEATURE_DCE_STYLE 0x00000008
59 #define GENSEC_FEATURE_ASYNC_REPLIES 0x00000010
60 #define GENSEC_FEATURE_DATAGRAM_MODE 0x00000020
61 #define GENSEC_FEATURE_SIGN_PKT_HEADER 0x00000040
62 #define GENSEC_FEATURE_NEW_SPNEGO 0x00000080
63 #define GENSEC_FEATURE_UNIX_TOKEN 0x00000100
65 #define GENSEC_EXPIRE_TIME_INFINITY (NTTIME)0x8000000000000000LL
67 /* GENSEC mode */
68 enum gensec_role
70 GENSEC_SERVER,
71 GENSEC_CLIENT
74 struct auth_session_info;
75 struct cli_credentials;
76 struct gensec_settings;
77 struct tevent_context;
78 struct tevent_req;
79 struct smb_krb5_context;
80 struct tsocket_address;
82 struct gensec_settings {
83 struct loadparm_context *lp_ctx;
84 const char *target_hostname;
86 /* this allows callers to specify a specific set of ops that
87 * should be used, rather than those loaded by the plugin
88 * mechanism */
89 const struct gensec_security_ops * const *backends;
91 /* To fill in our own name in the NTLMSSP server */
92 const char *server_dns_domain;
93 const char *server_dns_name;
94 const char *server_netbios_domain;
95 const char *server_netbios_name;
98 struct gensec_security_ops;
99 struct gensec_security_ops_wrapper;
101 #define GENSEC_INTERFACE_VERSION 0
103 /* this structure is used by backends to determine the size of some critical types */
104 struct gensec_critical_sizes;
105 const struct gensec_critical_sizes *gensec_interface_version(void);
107 /* Socket wrapper */
109 struct gensec_security;
110 struct socket_context;
111 struct auth4_context;
112 struct auth_user_info_dc;
114 /* These functions are for use here only (public because SPNEGO must
115 * use them for recursion) */
116 NTSTATUS gensec_wrap_packets(struct gensec_security *gensec_security,
117 TALLOC_CTX *mem_ctx,
118 const DATA_BLOB *in,
119 DATA_BLOB *out,
120 size_t *len_processed);
121 /* These functions are for use here only (public because SPNEGO must
122 * use them for recursion) */
123 NTSTATUS gensec_unwrap_packets(struct gensec_security *gensec_security,
124 TALLOC_CTX *mem_ctx,
125 const DATA_BLOB *in,
126 DATA_BLOB *out,
127 size_t *len_processed);
129 /* These functions are for use here only (public because SPNEGO must
130 * use them for recursion) */
131 NTSTATUS gensec_packet_full_request(struct gensec_security *gensec_security,
132 DATA_BLOB blob, size_t *size);
134 struct loadparm_context;
136 NTSTATUS gensec_subcontext_start(TALLOC_CTX *mem_ctx,
137 struct gensec_security *parent,
138 struct gensec_security **gensec_security);
139 NTSTATUS gensec_client_start(TALLOC_CTX *mem_ctx,
140 struct gensec_security **gensec_security,
141 struct gensec_settings *settings);
142 NTSTATUS gensec_start_mech_by_ops(struct gensec_security *gensec_security,
143 const struct gensec_security_ops *ops);
144 NTSTATUS gensec_start_mech_by_sasl_list(struct gensec_security *gensec_security,
145 const char **sasl_names);
146 void gensec_set_max_update_size(struct gensec_security *gensec_security,
147 uint32_t max_update_size);
148 size_t gensec_max_update_size(struct gensec_security *gensec_security);
149 NTSTATUS gensec_update(struct gensec_security *gensec_security, TALLOC_CTX *out_mem_ctx,
150 struct tevent_context *ev,
151 const DATA_BLOB in, DATA_BLOB *out);
152 struct tevent_req *gensec_update_send(TALLOC_CTX *mem_ctx,
153 struct tevent_context *ev,
154 struct gensec_security *gensec_security,
155 const DATA_BLOB in);
156 NTSTATUS gensec_update_recv(struct tevent_req *req, TALLOC_CTX *out_mem_ctx, DATA_BLOB *out);
157 void gensec_want_feature(struct gensec_security *gensec_security,
158 uint32_t feature);
159 bool gensec_have_feature(struct gensec_security *gensec_security,
160 uint32_t feature);
161 NTTIME gensec_expire_time(struct gensec_security *gensec_security);
162 NTSTATUS gensec_set_credentials(struct gensec_security *gensec_security, struct cli_credentials *credentials);
163 NTSTATUS gensec_set_target_service(struct gensec_security *gensec_security, const char *service);
164 const char *gensec_get_target_service(struct gensec_security *gensec_security);
165 NTSTATUS gensec_set_target_hostname(struct gensec_security *gensec_security, const char *hostname);
166 const char *gensec_get_target_hostname(struct gensec_security *gensec_security);
167 NTSTATUS gensec_session_key(struct gensec_security *gensec_security,
168 TALLOC_CTX *mem_ctx,
169 DATA_BLOB *session_key);
170 NTSTATUS gensec_start_mech_by_oid(struct gensec_security *gensec_security,
171 const char *mech_oid);
172 const char *gensec_get_name_by_oid(struct gensec_security *gensec_security, const char *oid_string);
173 struct cli_credentials *gensec_get_credentials(struct gensec_security *gensec_security);
174 NTSTATUS gensec_init(void);
175 NTSTATUS gensec_register(const struct gensec_security_ops *ops);
176 const struct gensec_security_ops *gensec_security_by_oid(struct gensec_security *gensec_security,
177 const char *oid_string);
178 const struct gensec_security_ops *gensec_security_by_sasl_name(struct gensec_security *gensec_security,
179 const char *sasl_name);
180 const struct gensec_security_ops *gensec_security_by_auth_type(
181 struct gensec_security *gensec_security,
182 uint32_t auth_type);
183 const struct gensec_security_ops **gensec_security_mechs(struct gensec_security *gensec_security,
184 TALLOC_CTX *mem_ctx);
185 const struct gensec_security_ops_wrapper *gensec_security_by_oid_list(
186 struct gensec_security *gensec_security,
187 TALLOC_CTX *mem_ctx,
188 const char * const *oid_strings,
189 const char *skip);
190 const char **gensec_security_oids(struct gensec_security *gensec_security,
191 TALLOC_CTX *mem_ctx,
192 const char *skip);
193 const char **gensec_security_oids_from_ops_wrapped(TALLOC_CTX *mem_ctx,
194 const struct gensec_security_ops_wrapper *wops);
195 size_t gensec_max_input_size(struct gensec_security *gensec_security);
196 size_t gensec_max_wrapped_size(struct gensec_security *gensec_security);
197 NTSTATUS gensec_unseal_packet(struct gensec_security *gensec_security,
198 uint8_t *data, size_t length,
199 const uint8_t *whole_pdu, size_t pdu_length,
200 const DATA_BLOB *sig);
201 NTSTATUS gensec_check_packet(struct gensec_security *gensec_security,
202 const uint8_t *data, size_t length,
203 const uint8_t *whole_pdu, size_t pdu_length,
204 const DATA_BLOB *sig);
205 size_t gensec_sig_size(struct gensec_security *gensec_security, size_t data_size);
206 NTSTATUS gensec_seal_packet(struct gensec_security *gensec_security,
207 TALLOC_CTX *mem_ctx,
208 uint8_t *data, size_t length,
209 const uint8_t *whole_pdu, size_t pdu_length,
210 DATA_BLOB *sig);
211 NTSTATUS gensec_sign_packet(struct gensec_security *gensec_security,
212 TALLOC_CTX *mem_ctx,
213 const uint8_t *data, size_t length,
214 const uint8_t *whole_pdu, size_t pdu_length,
215 DATA_BLOB *sig);
216 NTSTATUS gensec_start_mech(struct gensec_security *gensec_security);
217 NTSTATUS gensec_start_mech_by_authtype(struct gensec_security *gensec_security,
218 uint8_t auth_type, uint8_t auth_level);
219 const char *gensec_get_name_by_authtype(struct gensec_security *gensec_security, uint8_t authtype);
220 NTSTATUS gensec_server_start(TALLOC_CTX *mem_ctx,
221 struct gensec_settings *settings,
222 struct auth4_context *auth_context,
223 struct gensec_security **gensec_security);
224 NTSTATUS gensec_session_info(struct gensec_security *gensec_security,
225 TALLOC_CTX *mem_ctx,
226 struct auth_session_info **session_info);
228 NTSTATUS gensec_set_local_address(struct gensec_security *gensec_security,
229 const struct tsocket_address *local);
230 NTSTATUS gensec_set_remote_address(struct gensec_security *gensec_security,
231 const struct tsocket_address *remote);
232 const struct tsocket_address *gensec_get_local_address(struct gensec_security *gensec_security);
233 const struct tsocket_address *gensec_get_remote_address(struct gensec_security *gensec_security);
235 NTSTATUS gensec_start_mech_by_name(struct gensec_security *gensec_security,
236 const char *name);
238 NTSTATUS gensec_unwrap(struct gensec_security *gensec_security,
239 TALLOC_CTX *mem_ctx,
240 const DATA_BLOB *in,
241 DATA_BLOB *out);
242 NTSTATUS gensec_wrap(struct gensec_security *gensec_security,
243 TALLOC_CTX *mem_ctx,
244 const DATA_BLOB *in,
245 DATA_BLOB *out);
247 const struct gensec_security_ops * const *gensec_security_all(void);
248 bool gensec_security_ops_enabled(const struct gensec_security_ops *ops, struct gensec_security *security);
249 const struct gensec_security_ops **gensec_use_kerberos_mechs(TALLOC_CTX *mem_ctx,
250 const struct gensec_security_ops * const *old_gensec_list,
251 struct cli_credentials *creds);
253 NTSTATUS gensec_start_mech_by_sasl_name(struct gensec_security *gensec_security,
254 const char *sasl_name);
256 int gensec_setting_int(struct gensec_settings *settings, const char *mechanism, const char *name, int default_value);
257 bool gensec_setting_bool(struct gensec_settings *settings, const char *mechanism, const char *name, bool default_value);
259 NTSTATUS gensec_set_target_principal(struct gensec_security *gensec_security, const char *principal);
260 const char *gensec_get_target_principal(struct gensec_security *gensec_security);
262 NTSTATUS gensec_generate_session_info_pac(TALLOC_CTX *mem_ctx,
263 struct gensec_security *gensec_security,
264 struct smb_krb5_context *smb_krb5_context,
265 DATA_BLOB *pac_blob,
266 const char *principal_string,
267 const struct tsocket_address *remote_address,
268 struct auth_session_info **session_info);
270 NTSTATUS gensec_magic_check_krb5_oid(struct gensec_security *unused,
271 const DATA_BLOB *blob);
273 #endif /* __GENSEC_H__ */