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_INTERNAL_H__
24 #define __GENSEC_INTERNAL_H__
26 struct gensec_security;
28 struct gensec_security_ops {
30 const char *sasl_name;
31 uint8_t auth_type; /* 0 if not offered on DCE-RPC */
32 const char **oid; /* NULL if not offered by SPNEGO */
33 NTSTATUS (*client_start)(struct gensec_security *gensec_security);
34 NTSTATUS (*server_start)(struct gensec_security *gensec_security);
36 Determine if a packet has the right 'magic' for this mechanism
38 NTSTATUS (*magic)(struct gensec_security *gensec_security,
39 const DATA_BLOB *first_packet);
40 struct tevent_req *(*update_send)(TALLOC_CTX *mem_ctx,
41 struct tevent_context *ev,
42 struct gensec_security *gensec_security,
44 NTSTATUS (*update_recv)(struct tevent_req *req,
45 TALLOC_CTX *out_mem_ctx,
47 NTSTATUS (*may_reset_crypto)(struct gensec_security *gensec_security,
49 NTSTATUS (*seal_packet)(struct gensec_security *gensec_security, TALLOC_CTX *sig_mem_ctx,
50 uint8_t *data, size_t length,
51 const uint8_t *whole_pdu, size_t pdu_length,
53 NTSTATUS (*sign_packet)(struct gensec_security *gensec_security, TALLOC_CTX *sig_mem_ctx,
54 const uint8_t *data, size_t length,
55 const uint8_t *whole_pdu, size_t pdu_length,
57 size_t (*sig_size)(struct gensec_security *gensec_security, size_t data_size);
58 size_t (*max_input_size)(struct gensec_security *gensec_security);
59 size_t (*max_wrapped_size)(struct gensec_security *gensec_security);
60 NTSTATUS (*check_packet)(struct gensec_security *gensec_security,
61 const uint8_t *data, size_t length,
62 const uint8_t *whole_pdu, size_t pdu_length,
63 const DATA_BLOB *sig);
64 NTSTATUS (*unseal_packet)(struct gensec_security *gensec_security,
65 uint8_t *data, size_t length,
66 const uint8_t *whole_pdu, size_t pdu_length,
67 const DATA_BLOB *sig);
68 NTSTATUS (*wrap)(struct gensec_security *gensec_security,
72 NTSTATUS (*unwrap)(struct gensec_security *gensec_security,
76 NTSTATUS (*session_key)(struct gensec_security *gensec_security, TALLOC_CTX *mem_ctx,
77 DATA_BLOB *session_key);
78 NTSTATUS (*session_info)(struct gensec_security *gensec_security, TALLOC_CTX *mem_ctx,
79 struct auth_session_info **session_info);
80 void (*want_feature)(struct gensec_security *gensec_security,
82 bool (*have_feature)(struct gensec_security *gensec_security,
84 NTTIME (*expire_time)(struct gensec_security *gensec_security);
85 const char *(*final_auth_type)(struct gensec_security *gensec_security);
88 enum gensec_priority priority;
92 struct gensec_security_ops_wrapper {
93 const struct gensec_security_ops *op;
97 struct gensec_security {
98 const struct gensec_security_ops *ops;
100 struct cli_credentials *credentials;
101 struct gensec_target target;
102 enum gensec_role gensec_role;
104 uint32_t want_features;
105 uint32_t max_update_size;
106 uint8_t dcerpc_auth_level;
107 struct tsocket_address *local_addr, *remote_addr;
108 struct gensec_settings *settings;
110 /* When we are a server, this may be filled in to provide an
111 * NTLM authentication backend, and user lookup (such as if no
113 struct auth4_context *auth_context;
115 struct gensec_security *parent_security;
116 struct gensec_security *child_security;
119 * This is used to mark the context as being
120 * busy in an async gensec_update_send().
122 struct gensec_security **update_busy_ptr;
125 /* this structure is used by backends to determine the size of some critical types */
126 struct gensec_critical_sizes {
127 int interface_version;
128 int sizeof_gensec_security_ops;
129 int sizeof_gensec_security;
132 NTSTATUS gensec_may_reset_crypto(struct gensec_security *gensec_security,
135 const char *gensec_final_auth_type(struct gensec_security *gensec_security);
137 NTSTATUS gensec_child_ready(struct gensec_security *parent,
138 struct gensec_security *child);
139 void gensec_child_want_feature(struct gensec_security *gensec_security,
141 bool gensec_child_have_feature(struct gensec_security *gensec_security,
143 NTSTATUS gensec_child_unseal_packet(struct gensec_security *gensec_security,
144 uint8_t *data, size_t length,
145 const uint8_t *whole_pdu, size_t pdu_length,
146 const DATA_BLOB *sig);
147 NTSTATUS gensec_child_check_packet(struct gensec_security *gensec_security,
148 const uint8_t *data, size_t length,
149 const uint8_t *whole_pdu, size_t pdu_length,
150 const DATA_BLOB *sig);
151 NTSTATUS gensec_child_seal_packet(struct gensec_security *gensec_security,
153 uint8_t *data, size_t length,
154 const uint8_t *whole_pdu, size_t pdu_length,
156 NTSTATUS gensec_child_sign_packet(struct gensec_security *gensec_security,
158 const uint8_t *data, size_t length,
159 const uint8_t *whole_pdu, size_t pdu_length,
161 NTSTATUS gensec_child_wrap(struct gensec_security *gensec_security,
165 NTSTATUS gensec_child_unwrap(struct gensec_security *gensec_security,
169 size_t gensec_child_sig_size(struct gensec_security *gensec_security,
171 size_t gensec_child_max_input_size(struct gensec_security *gensec_security);
172 size_t gensec_child_max_wrapped_size(struct gensec_security *gensec_security);
173 NTSTATUS gensec_child_session_key(struct gensec_security *gensec_security,
175 DATA_BLOB *session_key);
176 NTSTATUS gensec_child_session_info(struct gensec_security *gensec_security,
178 struct auth_session_info **session_info);
179 NTTIME gensec_child_expire_time(struct gensec_security *gensec_security);
180 const char *gensec_child_final_auth_type(struct gensec_security *gensec_security);
182 #endif /* __GENSEC_H__ */