1b91bbbb845c337c2b0f1b8d1f37e7fea9af8fd9
[sfrench/samba-autobuild/.git] / source4 / heimdal / lib / gssapi / gssapi / gssapi_krb5.h
1 /*
2  * Copyright (c) 1997 - 2006 Kungliga Tekniska Högskolan
3  * (Royal Institute of Technology, Stockholm, Sweden).
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * 3. Neither the name of the Institute nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  */
33
34 /* $Id$ */
35
36 #ifndef GSSAPI_KRB5_H_
37 #define GSSAPI_KRB5_H_
38
39 #include <gssapi.h>
40
41 GSSAPI_CPP_START
42
43 #if !defined(__GNUC__) && !defined(__attribute__)
44 #define __attribute__(x)
45 #endif
46
47 #ifndef GSSKRB5_FUNCTION_DEPRECATED
48 #define GSSKRB5_FUNCTION_DEPRECATED __attribute__((deprecated))
49 #endif
50
51
52 /*
53  * This is for kerberos5 names.
54  */
55
56 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_NT_PRINCIPAL_NAME;
57 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_NT_USER_NAME;
58 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_NT_MACHINE_UID_NAME;
59 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_NT_STRING_UID_NAME;
60
61 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_MECHANISM;
62
63 /* for compatibility with MIT api */
64
65 #define gss_mech_krb5 GSS_KRB5_MECHANISM
66 #define gss_krb5_nt_general_name GSS_KRB5_NT_PRINCIPAL_NAME
67
68 /* Extensions set contexts options */
69 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_COPY_CCACHE_X;
70 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_COMPAT_DES3_MIC_X;
71 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_REGISTER_ACCEPTOR_IDENTITY_X;
72 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_SET_DNS_CANONICALIZE_X;
73 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_SEND_TO_KDC_X;
74 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_SET_DEFAULT_REALM_X;
75 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_CCACHE_NAME_X;
76 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_SET_TIME_OFFSET_X;
77 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_GET_TIME_OFFSET_X;
78 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_PLUGIN_REGISTER_X;
79 /* Extensions inquire context */
80 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_GET_TKT_FLAGS_X;
81 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_EXTRACT_AUTHZ_DATA_FROM_SEC_CONTEXT_X;
82 extern GSSAPI_LIB_VARIABLE gss_OID GSS_C_PEER_HAS_UPDATED_SPNEGO;
83 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_EXPORT_LUCID_CONTEXT_X;
84 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_EXPORT_LUCID_CONTEXT_V1_X;
85 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_GET_SUBKEY_X;
86 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_GET_INITIATOR_SUBKEY_X;
87 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_GET_ACCEPTOR_SUBKEY_X;
88 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_GET_AUTHTIME_X;
89 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_GET_SERVICE_KEYBLOCK_X;
90 /* Extensions creds */
91 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_IMPORT_CRED_X;
92 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_SET_ALLOWABLE_ENCTYPES_X;
93 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_CRED_NO_CI_FLAGS_X;
94
95 /*
96  * kerberos mechanism specific functions
97  */
98
99 struct krb5_keytab_data;
100 struct krb5_ccache_data;
101 struct Principal;
102
103 OM_uint32 GSSAPI_LIB_FUNCTION
104 gss_krb5_ccache_name(OM_uint32 * /*minor_status*/,
105                      const char * /*name */,
106                      const char ** /*out_name */);
107
108 OM_uint32 GSSAPI_LIB_FUNCTION gsskrb5_register_acceptor_identity
109         (const char * /*identity*/);
110
111 OM_uint32 GSSAPI_LIB_FUNCTION krb5_gss_register_acceptor_identity
112         (const char * /*identity*/);
113
114 OM_uint32 GSSAPI_LIB_FUNCTION gss_krb5_copy_ccache
115         (OM_uint32 * /*minor*/,
116          gss_cred_id_t /*cred*/,
117          struct krb5_ccache_data * /*out*/);
118
119 OM_uint32 GSSAPI_LIB_FUNCTION
120 gss_krb5_import_cred(OM_uint32 * /*minor*/,
121                      struct krb5_ccache_data * /*in*/,
122                      struct Principal * /*keytab_principal*/,
123                      struct krb5_keytab_data * /*keytab*/,
124                      gss_cred_id_t * /*out*/);
125
126 OM_uint32 GSSAPI_LIB_FUNCTION gss_krb5_get_tkt_flags
127         (OM_uint32 * /*minor*/,
128          gss_ctx_id_t /*context_handle*/,
129          OM_uint32 * /*tkt_flags*/);
130
131 OM_uint32 GSSAPI_LIB_FUNCTION
132 gsskrb5_extract_authz_data_from_sec_context
133         (OM_uint32 * /*minor_status*/,
134          gss_ctx_id_t /*context_handle*/,
135          int /*ad_type*/,
136          gss_buffer_t /*ad_data*/);
137
138 OM_uint32 GSSAPI_LIB_FUNCTION
139 gsskrb5_set_dns_canonicalize(int);
140
141 struct gsskrb5_send_to_kdc {
142     void *func;
143     void *ptr;
144 };
145
146 OM_uint32 GSSAPI_LIB_FUNCTION
147 gsskrb5_set_send_to_kdc(struct gsskrb5_send_to_kdc *)
148     GSSKRB5_FUNCTION_DEPRECATED;
149
150 OM_uint32 GSSAPI_LIB_FUNCTION
151 gsskrb5_set_default_realm(const char *);
152
153 OM_uint32 GSSAPI_LIB_FUNCTION
154 gsskrb5_extract_authtime_from_sec_context(OM_uint32 *, gss_ctx_id_t, time_t *);
155
156 struct EncryptionKey;
157
158 OM_uint32 GSSAPI_LIB_FUNCTION
159 gsskrb5_extract_service_keyblock(OM_uint32 *minor_status,
160                                  gss_ctx_id_t context_handle,
161                                  struct EncryptionKey **out);
162 OM_uint32 GSSAPI_LIB_FUNCTION
163 gsskrb5_get_initiator_subkey(OM_uint32 *minor_status,
164                                  gss_ctx_id_t context_handle,
165                                  struct EncryptionKey **out);
166 OM_uint32 GSSAPI_LIB_FUNCTION
167 gsskrb5_get_subkey(OM_uint32 *minor_status,
168                    gss_ctx_id_t context_handle,
169                    struct EncryptionKey **out);
170
171 OM_uint32 GSSAPI_LIB_FUNCTION
172 gsskrb5_set_time_offset(int);
173
174 OM_uint32 GSSAPI_LIB_FUNCTION
175 gsskrb5_get_time_offset(int *);
176
177 struct gsskrb5_krb5_plugin {
178     int type;
179     char *name;
180     void *symbol;
181 };
182
183 OM_uint32 GSSAPI_LIB_FUNCTION
184 gsskrb5_plugin_register(struct gsskrb5_krb5_plugin *);
185
186
187 /*
188  * Lucid - NFSv4 interface to GSS-API KRB5 to expose key material to
189  * do GSS content token handling in-kernel.
190  */
191
192 typedef struct gss_krb5_lucid_key {
193         OM_uint32       type;
194         OM_uint32       length;
195         void *          data;
196 } gss_krb5_lucid_key_t;
197
198 typedef struct gss_krb5_rfc1964_keydata {
199         OM_uint32               sign_alg;
200         OM_uint32               seal_alg;
201         gss_krb5_lucid_key_t    ctx_key;
202 } gss_krb5_rfc1964_keydata_t;
203
204 typedef struct gss_krb5_cfx_keydata {
205         OM_uint32               have_acceptor_subkey;
206         gss_krb5_lucid_key_t    ctx_key;
207         gss_krb5_lucid_key_t    acceptor_subkey;
208 } gss_krb5_cfx_keydata_t;
209
210 typedef struct gss_krb5_lucid_context_v1 {
211         OM_uint32       version;
212         OM_uint32       initiate;
213         OM_uint32       endtime;
214         OM_uint64       send_seq;
215         OM_uint64       recv_seq;
216         OM_uint32       protocol;
217         gss_krb5_rfc1964_keydata_t rfc1964_kd;
218         gss_krb5_cfx_keydata_t     cfx_kd;
219 } gss_krb5_lucid_context_v1_t;
220
221 typedef struct gss_krb5_lucid_context_version {
222         OM_uint32       version;        /* Structure version number */
223 } gss_krb5_lucid_context_version_t;
224
225 /*
226  * Function declarations
227  */
228
229 OM_uint32 GSSAPI_LIB_FUNCTION
230 gss_krb5_export_lucid_sec_context(OM_uint32 *minor_status,
231                                   gss_ctx_id_t *context_handle,
232                                   OM_uint32 version,
233                                   void **kctx);
234
235
236 OM_uint32 GSSAPI_LIB_FUNCTION
237 gss_krb5_free_lucid_sec_context(OM_uint32 *minor_status,
238                                 void *kctx);
239
240
241 OM_uint32 GSSAPI_LIB_FUNCTION
242 gss_krb5_set_allowable_enctypes(OM_uint32 *minor_status,
243                                 gss_cred_id_t cred,
244                                 OM_uint32 num_enctypes,
245                                 int32_t *enctypes);
246
247 GSSAPI_CPP_END
248
249 #endif /* GSSAPI_SPNEGO_H_ */