s4:heimdal: import lorikeet-heimdal-202201172009 (commit 5a0b45cd723628b3690ea848548b...
[samba.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 #include <gssapi/gssapi_oid.h>
41
42 GSSAPI_CPP_START
43
44 #if !defined(__GNUC__) && !defined(__attribute__)
45 #define __attribute__(x)
46 #endif
47
48 #ifndef GSSKRB5_FUNCTION_DEPRECATED
49 #define GSSKRB5_FUNCTION_DEPRECATED __attribute__((deprecated))
50 #endif
51
52
53 /*
54  * This is for kerberos5 names.
55  */
56
57 extern gss_OID_desc GSSAPI_LIB_VARIABLE __gss_krb5_nt_principal_name_oid_desc;
58 #define GSS_KRB5_NT_PRINCIPAL_NAME (&__gss_krb5_nt_principal_name_oid_desc)
59
60 #define GSS_KRB5_NT_USER_NAME (&__gss_c_nt_user_name_oid_desc)
61 #define GSS_KRB5_NT_MACHINE_UID_NAME (&__gss_c_nt_machine_uid_name_oid_desc)
62 #define GSS_KRB5_NT_STRING_UID_NAME (&__gss_c_nt_string_uid_name_oid_desc)
63
64 /* for compatibility with MIT api */
65
66 #define gss_mech_krb5 GSS_KRB5_MECHANISM
67 #define gss_krb5_nt_general_name GSS_KRB5_NT_PRINCIPAL_NAME
68
69 /*
70  * kerberos mechanism specific functions
71  */
72
73 struct krb5_keytab_data;
74 struct krb5_ccache_data;
75 struct Principal;
76
77 GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
78 gss_krb5_ccache_name(OM_uint32 * /*minor_status*/,
79                      const char * /*name */,
80                      const char ** /*out_name */);
81
82 GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gsskrb5_register_acceptor_identity
83         (const char * /*identity*/);
84
85 GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL krb5_gss_register_acceptor_identity
86         (const char * /*identity*/);
87
88 GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_krb5_copy_ccache
89         (OM_uint32 * /*minor*/,
90          gss_cred_id_t /*cred*/,
91          struct krb5_ccache_data * /*out*/);
92
93 GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
94 gss_krb5_import_cred(OM_uint32 * /*minor*/,
95                      struct krb5_ccache_data * /*in*/,
96                      struct Principal * /*keytab_principal*/,
97                      struct krb5_keytab_data * /*keytab*/,
98                      gss_cred_id_t * /*out*/);
99
100 GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_krb5_get_tkt_flags
101         (OM_uint32 * /*minor*/,
102          gss_ctx_id_t /*context_handle*/,
103          OM_uint32 * /*tkt_flags*/);
104
105 GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
106 gsskrb5_extract_authz_data_from_sec_context
107         (OM_uint32 * /*minor_status*/,
108          gss_ctx_id_t /*context_handle*/,
109          int /*ad_type*/,
110          gss_buffer_t /*ad_data*/);
111
112 GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
113 gsskrb5_set_dns_canonicalize(int);
114
115 struct gsskrb5_send_to_kdc {
116     void *func;
117     void *ptr;
118 };
119
120 GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
121 gsskrb5_set_send_to_kdc(struct gsskrb5_send_to_kdc *)
122     GSSKRB5_FUNCTION_DEPRECATED;
123
124 GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
125 gsskrb5_set_default_realm(const char *);
126
127 GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
128 gsskrb5_extract_authtime_from_sec_context(OM_uint32 *, gss_ctx_id_t, time_t *);
129
130 struct EncryptionKey;
131
132 GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
133 gsskrb5_extract_service_keyblock(OM_uint32 *minor_status,
134                                  gss_ctx_id_t context_handle,
135                                  struct EncryptionKey **out);
136 GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
137 gsskrb5_get_initiator_subkey(OM_uint32 *minor_status,
138                                  gss_ctx_id_t context_handle,
139                                  struct EncryptionKey **out);
140 GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
141 gsskrb5_get_subkey(OM_uint32 *minor_status,
142                    gss_ctx_id_t context_handle,
143                    struct EncryptionKey **out);
144
145 GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
146 gsskrb5_set_time_offset(int);
147
148 GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
149 gsskrb5_get_time_offset(int *);
150
151 struct gsskrb5_krb5_plugin {
152     int type;
153     char *name;
154     void *symbol;
155 };
156
157 GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
158 gsskrb5_plugin_register(struct gsskrb5_krb5_plugin *);
159
160
161 /*
162  * Lucid - NFSv4 interface to GSS-API KRB5 to expose key material to
163  * do GSS content token handling in-kernel.
164  */
165
166 typedef struct gss_krb5_lucid_key {
167         OM_uint32       type;
168         OM_uint32       length;
169         void *          data;
170 } gss_krb5_lucid_key_t;
171
172 typedef struct gss_krb5_rfc1964_keydata {
173         OM_uint32               sign_alg;
174         OM_uint32               seal_alg;
175         gss_krb5_lucid_key_t    ctx_key;
176 } gss_krb5_rfc1964_keydata_t;
177
178 typedef struct gss_krb5_cfx_keydata {
179         OM_uint32               have_acceptor_subkey;
180         gss_krb5_lucid_key_t    ctx_key;
181         gss_krb5_lucid_key_t    acceptor_subkey;
182 } gss_krb5_cfx_keydata_t;
183
184 typedef struct gss_krb5_lucid_context_v1 {
185         OM_uint32       version;
186         OM_uint32       initiate;
187         OM_uint32       endtime;
188         OM_uint64       send_seq;
189         OM_uint64       recv_seq;
190         OM_uint32       protocol;
191         gss_krb5_rfc1964_keydata_t rfc1964_kd;
192         gss_krb5_cfx_keydata_t     cfx_kd;
193 } gss_krb5_lucid_context_v1_t;
194
195 typedef struct gss_krb5_lucid_context_version {
196         OM_uint32       version;        /* Structure version number */
197 } gss_krb5_lucid_context_version_t;
198
199 /*
200  * Function declarations
201  */
202
203 GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
204 gss_krb5_export_lucid_sec_context(OM_uint32 *minor_status,
205                                   gss_ctx_id_t *context_handle,
206                                   OM_uint32 version,
207                                   void **kctx);
208
209
210 GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
211 gss_krb5_free_lucid_sec_context(OM_uint32 *minor_status,
212                                 void *kctx);
213
214
215 GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
216 gss_krb5_set_allowable_enctypes(OM_uint32 *minor_status,
217                                 gss_cred_id_t cred,
218                                 OM_uint32 num_enctypes,
219                                 int32_t *enctypes);
220
221 GSSAPI_CPP_END
222
223 #endif /* GSSAPI_SPNEGO_H_ */