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