xref: /illumos-gate/usr/src/uts/common/rpc/rpcsec_defs.h (revision 42b53e0fbc5c05289c3d334bb864b784fafe5ce4)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1996,1997-1998 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef	_RPCSEC_DEFS_H
28 #define	_RPCSEC_DEFS_H
29 
30 /*
31  * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved.
32  *
33  * $Id: auth_gssapi.h,v 1.11 1994/10/27 12:39:14 jik Exp $
34  */
35 
36 #ifndef _KERNEL
37 #include <libintl.h>
38 #include <locale.h>
39 #endif
40 #include <gssapi/gssapi.h>
41 #include <rpc/types.h>
42 
43 #ifdef	__cplusplus
44 extern "C" {
45 #endif
46 
47 #ifdef _KERNEL
48 
49 #if defined(DEBUG) && !defined(RPCGSS_DEBUG)
50 #define	RPCGSS_DEBUG
51 #endif
52 
53 #ifdef RPCGSS_DEBUG
54 extern uint_t rpcgss_log;
55 
56 #define	RPCGSS_LOG1(A, B, C, D) \
57 	((void)((rpcgss_log) && (rpcgss_log & (A)) && (printf((B), \
58 	    (C), (D)), TRUE)))
59 #define	RPCGSS_LOG(A, B, C) \
60 	((void)((rpcgss_log) && (rpcgss_log & (A)) && (printf((B), (C)), TRUE)))
61 #define	RPCGSS_LOG0(A, B)   \
62 	((void)((rpcgss_log) && (rpcgss_log & (A)) && (printf(B), TRUE)))
63 #else
64 #define	RPCGSS_LOG1(A, B, C, D)
65 #define	RPCGSS_LOG(A, B, C)
66 #define	RPCGSS_LOG0(A, B)
67 #endif
68 
69 #else /* _KERNEL */
70 
71 extern bool_t locale_set;
72 #if !defined(TEXT_DOMAIN)
73 #define	TEXT_DOMAIN "SUNW_OST_OSCMD"
74 #endif
75 
76 #endif /* _KERNEL */
77 
78 
79 typedef struct _rpc_gss_creds {
80 	uint_t version;
81 	uint_t gss_proc;
82 	uint_t seq_num;
83 	rpc_gss_service_t service;
84 	gss_buffer_desc ctx_handle;
85 } rpc_gss_creds;
86 
87 typedef gss_buffer_desc rpc_gss_init_arg;
88 
89 typedef struct _rpc_gss_init_res {
90 	gss_buffer_desc ctx_handle;
91 	OM_uint32 gss_major, gss_minor;
92 	OM_uint32 seq_window;
93 	gss_buffer_desc token;
94 } rpc_gss_init_res;
95 
96 
97 /*
98  * Convenience macros.
99  */
100 
101 #define	GSS_COPY_BUFFER(dest, src) { \
102 	(dest).length = (src).length; \
103 	(dest).value = (src).value; }
104 
105 #define	GSS_DUP_BUFFER(dest, src) { \
106 	(dest).length = (src).length; \
107 	(dest).value = (void *) mem_alloc((dest).length); \
108 	bcopy((src).value, (dest).value, (dest).length); }
109 
110 #define	GSS_BUFFERS_EQUAL(b1, b2) (((b1).length == (b2).length) && \
111 			(bcmp((b1).value, (b2).value, (b1.length)) == 0))
112 
113 #define	GSS_OIDS_EQUAL(o1, o2) \
114 	((((gss_OID)(o1))->length == ((gss_OID)(o2))->length) && \
115 		(bcmp(((gss_OID)(o1))->elements, ((gss_OID)(o2))->elements, \
116 			((gss_OID)(o1))->length) == 0))
117 
118 #define	MAX_GSS_NAME			128
119 
120 /*
121  * Private interfaces for user and kernel space.
122  */
123 bool_t __xdr_gss_buf();
124 bool_t __xdr_rpc_gss_creds();
125 bool_t __xdr_rpc_gss_init_arg();
126 bool_t __xdr_rpc_gss_init_res();
127 
128 bool_t __rpc_gss_wrap_data();
129 bool_t __rpc_gss_unwrap_data();
130 
131 #ifdef	_KERNEL
132 /*
133  * kernel-level RPCSEC_GSS definitions.
134  */
135 
136 void __rpc_gss_dup_oid(gss_OID, gss_OID *);
137 bool_t __rpc_gss_oids_equal(gss_OID oid1, gss_OID oid2);
138 void rpc_gss_display_status(OM_uint32 major, OM_uint32 minor,
139 			    rpc_gss_OID mechanism, uid_t uid,
140 			    char *function_name);
141 #else
142 /*
143  * user-level RPCSEC_GSS definitions.
144  */
145 
146 #define	MAX_MECH_OID_PAIRS		32
147 
148 typedef struct _rpc_gss_name {
149 	char *name;
150 	rpc_gss_OID type;
151 } rpc_gss_name;
152 
153 #ifdef	_REENTRANT
154 extern rpc_gss_error_t	*__rpc_gss_err();
155 #define	rpc_gss_err	(*(__rpc_gss_err()))
156 #else
157 extern rpc_gss_error_t rpc_gss_err;
158 #endif	/* _REENTRANT */
159 
160 /*
161  * Private interfaces in user space.
162  */
163 bool_t __rpc_gss_qop_to_num();
164 char *__rpc_gss_num_to_qop();
165 bool_t __rpc_gss_mech_to_oid();
166 char *__rpc_gss_oid_to_mech();
167 bool_t __rpc_gss_svc_to_num();
168 char *__rpc_gss_num_to_svc();
169 
170 void __rpc_gss_xdrdynamic_create();
171 caddr_t __rpc_gss_xdrdynamic_getdata();
172 
173 bool_t __rpcsec_init();
174 rpc_gss_OID __get_gss_oid();
175 void __rpc_gss_bind_error();
176 int __find_max_data_length(rpc_gss_service_t service, gss_ctx_id_t context,
177 	OM_uint32 qop, int max_tp_unit_len);
178 
179 #endif /* _KERNEL */
180 
181 #ifdef	__cplusplus
182 }
183 #endif
184 
185 #endif	/* _RPCSEC_DEFS_H */
186