source: vendor/current/auth/gensec/gensec.h

Last change on this file was 988, checked in by Silvan Scherrer, 9 years ago

Samba Server: update vendor to version 4.4.3

File size: 10.5 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3
4 Generic Authentication Interface
5
6 Copyright (C) Andrew Tridgell 2003
7 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2004-2005
8
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.
13
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.
18
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/>.
21*/
22
23#ifndef __GENSEC_H__
24#define __GENSEC_H__
25
26#include "../lib/util/data_blob.h"
27#include "libcli/util/ntstatus.h"
28
29#define GENSEC_SASL_NAME_NTLMSSP "NTLM"
30
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"
36
37enum 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
46};
47
48struct gensec_security;
49struct gensec_target {
50 const char *principal;
51 const char *hostname;
52 const char *service;
53};
54
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
64#define GENSEC_FEATURE_NTLM_CCACHE 0x00000200
65#define GENSEC_FEATURE_LDAP_STYLE 0x00000400
66
67#define GENSEC_EXPIRE_TIME_INFINITY (NTTIME)0x8000000000000000LL
68
69/* GENSEC mode */
70enum gensec_role
71{
72 GENSEC_SERVER,
73 GENSEC_CLIENT
74};
75
76struct auth_session_info;
77struct cli_credentials;
78struct gensec_settings;
79struct tevent_context;
80struct tevent_req;
81struct smb_krb5_context;
82struct tsocket_address;
83
84struct gensec_settings {
85 struct loadparm_context *lp_ctx;
86 const char *target_hostname;
87
88 /* this allows callers to specify a specific set of ops that
89 * should be used, rather than those loaded by the plugin
90 * mechanism */
91 const struct gensec_security_ops * const *backends;
92
93 /* To fill in our own name in the NTLMSSP server */
94 const char *server_dns_domain;
95 const char *server_dns_name;
96 const char *server_netbios_domain;
97 const char *server_netbios_name;
98};
99
100struct gensec_security_ops;
101struct gensec_security_ops_wrapper;
102
103#define GENSEC_INTERFACE_VERSION 0
104
105/* this structure is used by backends to determine the size of some critical types */
106struct gensec_critical_sizes;
107const struct gensec_critical_sizes *gensec_interface_version(void);
108
109/* Socket wrapper */
110
111struct gensec_security;
112struct auth4_context;
113struct auth_user_info_dc;
114
115struct loadparm_context;
116
117NTSTATUS gensec_subcontext_start(TALLOC_CTX *mem_ctx,
118 struct gensec_security *parent,
119 struct gensec_security **gensec_security);
120NTSTATUS gensec_client_start(TALLOC_CTX *mem_ctx,
121 struct gensec_security **gensec_security,
122 struct gensec_settings *settings);
123NTSTATUS gensec_start_mech_by_ops(struct gensec_security *gensec_security,
124 const struct gensec_security_ops *ops);
125NTSTATUS gensec_start_mech_by_sasl_list(struct gensec_security *gensec_security,
126 const char **sasl_names);
127void gensec_set_max_update_size(struct gensec_security *gensec_security,
128 uint32_t max_update_size);
129size_t gensec_max_update_size(struct gensec_security *gensec_security);
130NTSTATUS gensec_update(struct gensec_security *gensec_security,
131 TALLOC_CTX *out_mem_ctx,
132 const DATA_BLOB in, DATA_BLOB *out);
133NTSTATUS gensec_update_ev(struct gensec_security *gensec_security,
134 TALLOC_CTX *out_mem_ctx,
135 struct tevent_context *ev,
136 const DATA_BLOB in, DATA_BLOB *out);
137struct tevent_req *gensec_update_send(TALLOC_CTX *mem_ctx,
138 struct tevent_context *ev,
139 struct gensec_security *gensec_security,
140 const DATA_BLOB in);
141NTSTATUS gensec_update_recv(struct tevent_req *req, TALLOC_CTX *out_mem_ctx, DATA_BLOB *out);
142void gensec_want_feature(struct gensec_security *gensec_security,
143 uint32_t feature);
144bool gensec_have_feature(struct gensec_security *gensec_security,
145 uint32_t feature);
146NTTIME gensec_expire_time(struct gensec_security *gensec_security);
147NTSTATUS gensec_set_credentials(struct gensec_security *gensec_security, struct cli_credentials *credentials);
148NTSTATUS gensec_set_target_service(struct gensec_security *gensec_security, const char *service);
149const char *gensec_get_target_service(struct gensec_security *gensec_security);
150NTSTATUS gensec_set_target_hostname(struct gensec_security *gensec_security, const char *hostname);
151const char *gensec_get_target_hostname(struct gensec_security *gensec_security);
152NTSTATUS gensec_session_key(struct gensec_security *gensec_security,
153 TALLOC_CTX *mem_ctx,
154 DATA_BLOB *session_key);
155NTSTATUS gensec_start_mech_by_oid(struct gensec_security *gensec_security,
156 const char *mech_oid);
157const char *gensec_get_name_by_oid(struct gensec_security *gensec_security, const char *oid_string);
158struct cli_credentials *gensec_get_credentials(struct gensec_security *gensec_security);
159NTSTATUS gensec_init(void);
160NTSTATUS gensec_register(const struct gensec_security_ops *ops);
161const struct gensec_security_ops *gensec_security_by_oid(struct gensec_security *gensec_security,
162 const char *oid_string);
163const struct gensec_security_ops *gensec_security_by_sasl_name(struct gensec_security *gensec_security,
164 const char *sasl_name);
165const struct gensec_security_ops *gensec_security_by_auth_type(
166 struct gensec_security *gensec_security,
167 uint32_t auth_type);
168const struct gensec_security_ops *gensec_security_by_name(struct gensec_security *gensec_security,
169 const char *name);
170const struct gensec_security_ops **gensec_security_mechs(struct gensec_security *gensec_security,
171 TALLOC_CTX *mem_ctx);
172const struct gensec_security_ops_wrapper *gensec_security_by_oid_list(
173 struct gensec_security *gensec_security,
174 TALLOC_CTX *mem_ctx,
175 const char * const *oid_strings,
176 const char *skip);
177const char **gensec_security_oids(struct gensec_security *gensec_security,
178 TALLOC_CTX *mem_ctx,
179 const char *skip);
180const char **gensec_security_oids_from_ops_wrapped(TALLOC_CTX *mem_ctx,
181 const struct gensec_security_ops_wrapper *wops);
182size_t gensec_max_input_size(struct gensec_security *gensec_security);
183size_t gensec_max_wrapped_size(struct gensec_security *gensec_security);
184NTSTATUS gensec_unseal_packet(struct gensec_security *gensec_security,
185 uint8_t *data, size_t length,
186 const uint8_t *whole_pdu, size_t pdu_length,
187 const DATA_BLOB *sig);
188NTSTATUS gensec_check_packet(struct gensec_security *gensec_security,
189 const uint8_t *data, size_t length,
190 const uint8_t *whole_pdu, size_t pdu_length,
191 const DATA_BLOB *sig);
192size_t gensec_sig_size(struct gensec_security *gensec_security, size_t data_size);
193NTSTATUS gensec_seal_packet(struct gensec_security *gensec_security,
194 TALLOC_CTX *mem_ctx,
195 uint8_t *data, size_t length,
196 const uint8_t *whole_pdu, size_t pdu_length,
197 DATA_BLOB *sig);
198NTSTATUS gensec_sign_packet(struct gensec_security *gensec_security,
199 TALLOC_CTX *mem_ctx,
200 const uint8_t *data, size_t length,
201 const uint8_t *whole_pdu, size_t pdu_length,
202 DATA_BLOB *sig);
203NTSTATUS gensec_start_mech(struct gensec_security *gensec_security);
204NTSTATUS gensec_start_mech_by_authtype(struct gensec_security *gensec_security,
205 uint8_t auth_type, uint8_t auth_level);
206const char *gensec_get_name_by_authtype(struct gensec_security *gensec_security, uint8_t authtype);
207NTSTATUS gensec_server_start(TALLOC_CTX *mem_ctx,
208 struct gensec_settings *settings,
209 struct auth4_context *auth_context,
210 struct gensec_security **gensec_security);
211NTSTATUS gensec_session_info(struct gensec_security *gensec_security,
212 TALLOC_CTX *mem_ctx,
213 struct auth_session_info **session_info);
214
215NTSTATUS gensec_set_local_address(struct gensec_security *gensec_security,
216 const struct tsocket_address *local);
217NTSTATUS gensec_set_remote_address(struct gensec_security *gensec_security,
218 const struct tsocket_address *remote);
219const struct tsocket_address *gensec_get_local_address(struct gensec_security *gensec_security);
220const struct tsocket_address *gensec_get_remote_address(struct gensec_security *gensec_security);
221
222NTSTATUS gensec_start_mech_by_name(struct gensec_security *gensec_security,
223 const char *name);
224
225NTSTATUS gensec_unwrap(struct gensec_security *gensec_security,
226 TALLOC_CTX *mem_ctx,
227 const DATA_BLOB *in,
228 DATA_BLOB *out);
229NTSTATUS gensec_wrap(struct gensec_security *gensec_security,
230 TALLOC_CTX *mem_ctx,
231 const DATA_BLOB *in,
232 DATA_BLOB *out);
233
234const struct gensec_security_ops * const *gensec_security_all(void);
235bool gensec_security_ops_enabled(const struct gensec_security_ops *ops, struct gensec_security *security);
236const struct gensec_security_ops **gensec_use_kerberos_mechs(TALLOC_CTX *mem_ctx,
237 const struct gensec_security_ops * const *old_gensec_list,
238 struct cli_credentials *creds);
239
240NTSTATUS gensec_start_mech_by_sasl_name(struct gensec_security *gensec_security,
241 const char *sasl_name);
242
243int gensec_setting_int(struct gensec_settings *settings, const char *mechanism, const char *name, int default_value);
244bool gensec_setting_bool(struct gensec_settings *settings, const char *mechanism, const char *name, bool default_value);
245
246NTSTATUS gensec_set_target_principal(struct gensec_security *gensec_security, const char *principal);
247const char *gensec_get_target_principal(struct gensec_security *gensec_security);
248
249NTSTATUS gensec_generate_session_info_pac(TALLOC_CTX *mem_ctx,
250 struct gensec_security *gensec_security,
251 struct smb_krb5_context *smb_krb5_context,
252 DATA_BLOB *pac_blob,
253 const char *principal_string,
254 const struct tsocket_address *remote_address,
255 struct auth_session_info **session_info);
256
257NTSTATUS gensec_magic_check_krb5_oid(struct gensec_security *unused,
258 const DATA_BLOB *blob);
259
260#endif /* __GENSEC_H__ */
Note: See TracBrowser for help on using the repository browser.