auth/gensec: introduce gensec_internal.h
[Samba/wip.git] / auth / gensec / gensec_internal.h
blob41b6f0d6efdff5a29f38c865709bbbbe5a044524
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_INTERNAL_H__
24 #define __GENSEC_INTERNAL_H__
26 struct gensec_security;
28 struct gensec_security_ops {
29 const char *name;
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);
35 /**
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 NTSTATUS (*update)(struct gensec_security *gensec_security, TALLOC_CTX *out_mem_ctx,
41 struct tevent_context *ev,
42 const DATA_BLOB in, DATA_BLOB *out);
43 NTSTATUS (*seal_packet)(struct gensec_security *gensec_security, TALLOC_CTX *sig_mem_ctx,
44 uint8_t *data, size_t length,
45 const uint8_t *whole_pdu, size_t pdu_length,
46 DATA_BLOB *sig);
47 NTSTATUS (*sign_packet)(struct gensec_security *gensec_security, TALLOC_CTX *sig_mem_ctx,
48 const uint8_t *data, size_t length,
49 const uint8_t *whole_pdu, size_t pdu_length,
50 DATA_BLOB *sig);
51 size_t (*sig_size)(struct gensec_security *gensec_security, size_t data_size);
52 size_t (*max_input_size)(struct gensec_security *gensec_security);
53 size_t (*max_wrapped_size)(struct gensec_security *gensec_security);
54 NTSTATUS (*check_packet)(struct gensec_security *gensec_security,
55 const uint8_t *data, size_t length,
56 const uint8_t *whole_pdu, size_t pdu_length,
57 const DATA_BLOB *sig);
58 NTSTATUS (*unseal_packet)(struct gensec_security *gensec_security,
59 uint8_t *data, size_t length,
60 const uint8_t *whole_pdu, size_t pdu_length,
61 const DATA_BLOB *sig);
62 NTSTATUS (*wrap)(struct gensec_security *gensec_security,
63 TALLOC_CTX *mem_ctx,
64 const DATA_BLOB *in,
65 DATA_BLOB *out);
66 NTSTATUS (*unwrap)(struct gensec_security *gensec_security,
67 TALLOC_CTX *mem_ctx,
68 const DATA_BLOB *in,
69 DATA_BLOB *out);
70 NTSTATUS (*wrap_packets)(struct gensec_security *gensec_security,
71 TALLOC_CTX *mem_ctx,
72 const DATA_BLOB *in,
73 DATA_BLOB *out,
74 size_t *len_processed);
75 NTSTATUS (*unwrap_packets)(struct gensec_security *gensec_security,
76 TALLOC_CTX *mem_ctx,
77 const DATA_BLOB *in,
78 DATA_BLOB *out,
79 size_t *len_processed);
80 NTSTATUS (*packet_full_request)(struct gensec_security *gensec_security,
81 DATA_BLOB blob, size_t *size);
82 NTSTATUS (*session_key)(struct gensec_security *gensec_security, TALLOC_CTX *mem_ctx,
83 DATA_BLOB *session_key);
84 NTSTATUS (*session_info)(struct gensec_security *gensec_security, TALLOC_CTX *mem_ctx,
85 struct auth_session_info **session_info);
86 void (*want_feature)(struct gensec_security *gensec_security,
87 uint32_t feature);
88 bool (*have_feature)(struct gensec_security *gensec_security,
89 uint32_t feature);
90 NTTIME (*expire_time)(struct gensec_security *gensec_security);
91 bool enabled;
92 bool kerberos;
93 enum gensec_priority priority;
96 struct gensec_security_ops_wrapper {
97 const struct gensec_security_ops *op;
98 const char *oid;
101 struct gensec_security {
102 const struct gensec_security_ops *ops;
103 void *private_data;
104 struct cli_credentials *credentials;
105 struct gensec_target target;
106 enum gensec_role gensec_role;
107 bool subcontext;
108 uint32_t want_features;
109 uint32_t max_update_size;
110 uint8_t dcerpc_auth_level;
111 struct tsocket_address *local_addr, *remote_addr;
112 struct gensec_settings *settings;
114 /* When we are a server, this may be filled in to provide an
115 * NTLM authentication backend, and user lookup (such as if no
116 * PAC is found) */
117 struct auth4_context *auth_context;
120 /* this structure is used by backends to determine the size of some critical types */
121 struct gensec_critical_sizes {
122 int interface_version;
123 int sizeof_gensec_security_ops;
124 int sizeof_gensec_security;
127 #endif /* __GENSEC_H__ */