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/>.
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
{
48 struct gensec_security
;
49 struct gensec_target
{
50 const char *principal
;
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
67 #define GENSEC_EXPIRE_TIME_INFINITY (NTTIME)0x8000000000000000LL
76 struct auth_session_info
;
77 struct cli_credentials
;
78 struct gensec_settings
;
79 struct tevent_context
;
81 struct smb_krb5_context
;
82 struct tsocket_address
;
84 struct gensec_settings
{
85 struct loadparm_context
*lp_ctx
;
86 const char *target_hostname
;
88 /* this allows callers to specify a specific set of ops that
89 * should be used, rather than those loaded by the plugin
91 const struct gensec_security_ops
* const *backends
;
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
;
100 struct gensec_security_ops
;
101 struct gensec_security_ops_wrapper
;
103 #define GENSEC_INTERFACE_VERSION 0
105 /* this structure is used by backends to determine the size of some critical types */
106 struct gensec_critical_sizes
;
107 const struct gensec_critical_sizes
*gensec_interface_version(void);
111 struct gensec_security
;
112 struct auth4_context
;
113 struct auth_user_info_dc
;
115 struct loadparm_context
;
117 NTSTATUS
gensec_subcontext_start(TALLOC_CTX
*mem_ctx
,
118 struct gensec_security
*parent
,
119 struct gensec_security
**gensec_security
);
120 NTSTATUS
gensec_client_start(TALLOC_CTX
*mem_ctx
,
121 struct gensec_security
**gensec_security
,
122 struct gensec_settings
*settings
);
123 NTSTATUS
gensec_start_mech_by_ops(struct gensec_security
*gensec_security
,
124 const struct gensec_security_ops
*ops
);
125 NTSTATUS
gensec_start_mech_by_sasl_list(struct gensec_security
*gensec_security
,
126 const char **sasl_names
);
127 void gensec_set_max_update_size(struct gensec_security
*gensec_security
,
128 uint32_t max_update_size
);
129 size_t gensec_max_update_size(struct gensec_security
*gensec_security
);
130 NTSTATUS
gensec_update(struct gensec_security
*gensec_security
,
131 TALLOC_CTX
*out_mem_ctx
,
132 const DATA_BLOB in
, DATA_BLOB
*out
);
133 NTSTATUS
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
);
137 struct tevent_req
*gensec_update_send(TALLOC_CTX
*mem_ctx
,
138 struct tevent_context
*ev
,
139 struct gensec_security
*gensec_security
,
141 NTSTATUS
gensec_update_recv(struct tevent_req
*req
, TALLOC_CTX
*out_mem_ctx
, DATA_BLOB
*out
);
142 void gensec_want_feature(struct gensec_security
*gensec_security
,
144 bool gensec_have_feature(struct gensec_security
*gensec_security
,
146 NTTIME
gensec_expire_time(struct gensec_security
*gensec_security
);
147 NTSTATUS
gensec_set_credentials(struct gensec_security
*gensec_security
, struct cli_credentials
*credentials
);
148 NTSTATUS
gensec_set_target_service(struct gensec_security
*gensec_security
, const char *service
);
149 const char *gensec_get_target_service(struct gensec_security
*gensec_security
);
150 NTSTATUS
gensec_set_target_hostname(struct gensec_security
*gensec_security
, const char *hostname
);
151 const char *gensec_get_target_hostname(struct gensec_security
*gensec_security
);
152 NTSTATUS
gensec_session_key(struct gensec_security
*gensec_security
,
154 DATA_BLOB
*session_key
);
155 NTSTATUS
gensec_start_mech_by_oid(struct gensec_security
*gensec_security
,
156 const char *mech_oid
);
157 const char *gensec_get_name_by_oid(struct gensec_security
*gensec_security
, const char *oid_string
);
158 struct cli_credentials
*gensec_get_credentials(struct gensec_security
*gensec_security
);
159 NTSTATUS
gensec_init(void);
160 NTSTATUS
gensec_register(const struct gensec_security_ops
*ops
);
161 const struct gensec_security_ops
*gensec_security_by_oid(struct gensec_security
*gensec_security
,
162 const char *oid_string
);
163 const struct gensec_security_ops
*gensec_security_by_sasl_name(struct gensec_security
*gensec_security
,
164 const char *sasl_name
);
165 const struct gensec_security_ops
*gensec_security_by_auth_type(
166 struct gensec_security
*gensec_security
,
168 const struct gensec_security_ops
*gensec_security_by_name(struct gensec_security
*gensec_security
,
170 const struct gensec_security_ops
**gensec_security_mechs(struct gensec_security
*gensec_security
,
171 TALLOC_CTX
*mem_ctx
);
172 const struct gensec_security_ops_wrapper
*gensec_security_by_oid_list(
173 struct gensec_security
*gensec_security
,
175 const char * const *oid_strings
,
177 const char **gensec_security_oids(struct gensec_security
*gensec_security
,
180 const char **gensec_security_oids_from_ops_wrapped(TALLOC_CTX
*mem_ctx
,
181 const struct gensec_security_ops_wrapper
*wops
);
182 size_t gensec_max_input_size(struct gensec_security
*gensec_security
);
183 size_t gensec_max_wrapped_size(struct gensec_security
*gensec_security
);
184 NTSTATUS
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
);
188 NTSTATUS
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
);
192 size_t gensec_sig_size(struct gensec_security
*gensec_security
, size_t data_size
);
193 NTSTATUS
gensec_seal_packet(struct gensec_security
*gensec_security
,
195 uint8_t *data
, size_t length
,
196 const uint8_t *whole_pdu
, size_t pdu_length
,
198 NTSTATUS
gensec_sign_packet(struct gensec_security
*gensec_security
,
200 const uint8_t *data
, size_t length
,
201 const uint8_t *whole_pdu
, size_t pdu_length
,
203 NTSTATUS
gensec_start_mech(struct gensec_security
*gensec_security
);
204 NTSTATUS
gensec_start_mech_by_authtype(struct gensec_security
*gensec_security
,
205 uint8_t auth_type
, uint8_t auth_level
);
206 const char *gensec_get_name_by_authtype(struct gensec_security
*gensec_security
, uint8_t authtype
);
207 NTSTATUS
gensec_server_start(TALLOC_CTX
*mem_ctx
,
208 struct gensec_settings
*settings
,
209 struct auth4_context
*auth_context
,
210 struct gensec_security
**gensec_security
);
211 NTSTATUS
gensec_session_info(struct gensec_security
*gensec_security
,
213 struct auth_session_info
**session_info
);
215 NTSTATUS
gensec_set_local_address(struct gensec_security
*gensec_security
,
216 const struct tsocket_address
*local
);
217 NTSTATUS
gensec_set_remote_address(struct gensec_security
*gensec_security
,
218 const struct tsocket_address
*remote
);
219 const struct tsocket_address
*gensec_get_local_address(struct gensec_security
*gensec_security
);
220 const struct tsocket_address
*gensec_get_remote_address(struct gensec_security
*gensec_security
);
222 NTSTATUS
gensec_start_mech_by_name(struct gensec_security
*gensec_security
,
225 NTSTATUS
gensec_unwrap(struct gensec_security
*gensec_security
,
229 NTSTATUS
gensec_wrap(struct gensec_security
*gensec_security
,
234 const struct gensec_security_ops
* const *gensec_security_all(void);
235 bool gensec_security_ops_enabled(const struct gensec_security_ops
*ops
, struct gensec_security
*security
);
236 const 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
);
240 NTSTATUS
gensec_start_mech_by_sasl_name(struct gensec_security
*gensec_security
,
241 const char *sasl_name
);
243 int gensec_setting_int(struct gensec_settings
*settings
, const char *mechanism
, const char *name
, int default_value
);
244 bool gensec_setting_bool(struct gensec_settings
*settings
, const char *mechanism
, const char *name
, bool default_value
);
246 NTSTATUS
gensec_set_target_principal(struct gensec_security
*gensec_security
, const char *principal
);
247 const char *gensec_get_target_principal(struct gensec_security
*gensec_security
);
249 NTSTATUS
gensec_generate_session_info_pac(TALLOC_CTX
*mem_ctx
,
250 struct gensec_security
*gensec_security
,
251 struct smb_krb5_context
*smb_krb5_context
,
253 const char *principal_string
,
254 const struct tsocket_address
*remote_address
,
255 struct auth_session_info
**session_info
);
257 NTSTATUS
gensec_magic_check_krb5_oid(struct gensec_security
*unused
,
258 const DATA_BLOB
*blob
);
260 #endif /* __GENSEC_H__ */