xref: /titanic_44/usr/src/uts/common/rpc/rpcsec_defs.h (revision c7e4935f5b755b4bbeaec416f1ad24337aeac7a4)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved.
34  *
35  * $Id: auth_gssapi.h,v 1.11 1994/10/27 12:39:14 jik Exp $
36  */
37 
38 #ifndef _KERNEL
39 #include <libintl.h>
40 #include <locale.h>
41 #endif
42 #include <gssapi/gssapi.h>
43 #include <rpc/types.h>
44 
45 #ifdef	__cplusplus
46 extern "C" {
47 #endif
48 
49 #ifdef _KERNEL
50 
51 #if defined(DEBUG) && !defined(RPCGSS_DEBUG)
52 #define	RPCGSS_DEBUG
53 #endif
54 
55 #ifdef RPCGSS_DEBUG
56 extern uint_t rpcgss_log;
57 
58 #define	RPCGSS_LOG1(A, B, C, D) \
59 	((void)((rpcgss_log) && (rpcgss_log & (A)) && (printf((B), \
60 	    (C), (D)), TRUE)))
61 #define	RPCGSS_LOG(A, B, C) \
62 	((void)((rpcgss_log) && (rpcgss_log & (A)) && (printf((B), (C)), TRUE)))
63 #define	RPCGSS_LOG0(A, B)   \
64 	((void)((rpcgss_log) && (rpcgss_log & (A)) && (printf(B), TRUE)))
65 #else
66 #define	RPCGSS_LOG1(A, B, C, D)
67 #define	RPCGSS_LOG(A, B, C)
68 #define	RPCGSS_LOG0(A, B)
69 #endif
70 
71 #else /* _KERNEL */
72 
73 extern bool_t locale_set;
74 #if !defined(TEXT_DOMAIN)
75 #define	TEXT_DOMAIN "SUNW_OST_OSCMD"
76 #endif
77 
78 #endif /* _KERNEL */
79 
80 
81 typedef struct _rpc_gss_creds {
82 	uint_t version;
83 	uint_t gss_proc;
84 	uint_t seq_num;
85 	rpc_gss_service_t service;
86 	gss_buffer_desc ctx_handle;
87 } rpc_gss_creds;
88 
89 typedef gss_buffer_desc rpc_gss_init_arg;
90 
91 typedef struct _rpc_gss_init_res {
92 	gss_buffer_desc ctx_handle;
93 	OM_uint32 gss_major, gss_minor;
94 	OM_uint32 seq_window;
95 	gss_buffer_desc token;
96 } rpc_gss_init_res;
97 
98 
99 /*
100  * Convenience macros.
101  */
102 
103 #define	GSS_COPY_BUFFER(dest, src) { \
104 	(dest).length = (src).length; \
105 	(dest).value = (src).value; }
106 
107 #define	GSS_DUP_BUFFER(dest, src) { \
108 	(dest).length = (src).length; \
109 	(dest).value = (void *) mem_alloc((dest).length); \
110 	bcopy((src).value, (dest).value, (dest).length); }
111 
112 #define	GSS_BUFFERS_EQUAL(b1, b2) (((b1).length == (b2).length) && \
113 			(bcmp((b1).value, (b2).value, (b1.length)) == 0))
114 
115 #define	GSS_OIDS_EQUAL(o1, o2) \
116 	((((gss_OID)(o1))->length == ((gss_OID)(o2))->length) && \
117 		(bcmp(((gss_OID)(o1))->elements, ((gss_OID)(o2))->elements, \
118 			((gss_OID)(o1))->length) == 0))
119 
120 #define	MAX_GSS_NAME			128
121 
122 /*
123  * Private interfaces for user and kernel space.
124  */
125 bool_t __xdr_gss_buf();
126 bool_t __xdr_rpc_gss_creds();
127 bool_t __xdr_rpc_gss_init_arg();
128 bool_t __xdr_rpc_gss_init_res();
129 
130 bool_t __rpc_gss_wrap_data();
131 bool_t __rpc_gss_unwrap_data();
132 
133 #ifdef	_KERNEL
134 /*
135  * kernel-level RPCSEC_GSS definitions.
136  */
137 
138 void __rpc_gss_dup_oid(gss_OID, gss_OID *);
139 bool_t __rpc_gss_oids_equal(gss_OID oid1, gss_OID oid2);
140 void rpc_gss_display_status(OM_uint32 major, OM_uint32 minor,
141 			    rpc_gss_OID mechanism, uid_t uid,
142 			    char *function_name);
143 #else
144 /*
145  * user-level RPCSEC_GSS definitions.
146  */
147 
148 #define	MAX_MECH_OID_PAIRS		32
149 
150 typedef struct _rpc_gss_name {
151 	char *name;
152 	rpc_gss_OID type;
153 } rpc_gss_name;
154 
155 #ifdef	_REENTRANT
156 extern rpc_gss_error_t	*__rpc_gss_err();
157 #define	rpc_gss_err	(*(__rpc_gss_err()))
158 #else
159 extern rpc_gss_error_t rpc_gss_err;
160 #endif	/* _REENTRANT */
161 
162 /*
163  * Private interfaces in user space.
164  */
165 bool_t __rpc_gss_qop_to_num();
166 char *__rpc_gss_num_to_qop();
167 bool_t __rpc_gss_mech_to_oid();
168 char *__rpc_gss_oid_to_mech();
169 bool_t __rpc_gss_svc_to_num();
170 char *__rpc_gss_num_to_svc();
171 
172 void __rpc_gss_xdrdynamic_create();
173 caddr_t __rpc_gss_xdrdynamic_getdata();
174 
175 bool_t __rpcsec_init();
176 rpc_gss_OID __get_gss_oid();
177 void __rpc_gss_bind_error();
178 int __find_max_data_length(rpc_gss_service_t service, gss_ctx_id_t context,
179 	OM_uint32 qop, int max_tp_unit_len);
180 
181 #endif /* _KERNEL */
182 
183 #ifdef	__cplusplus
184 }
185 #endif
186 
187 #endif	/* _RPCSEC_DEFS_H */
188