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