xref: /titanic_41/usr/src/lib/libbc/inc/include/rpc/auth.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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
23*7c478bd9Sstevel@tonic-gate 
24*7c478bd9Sstevel@tonic-gate /*
25*7c478bd9Sstevel@tonic-gate  * auth.h, Authentication interface.
26*7c478bd9Sstevel@tonic-gate  *
27*7c478bd9Sstevel@tonic-gate  * Copyright (C) 1984, Sun Microsystems, Inc.
28*7c478bd9Sstevel@tonic-gate  *
29*7c478bd9Sstevel@tonic-gate  * The data structures are completely opaque to the client.  The client
30*7c478bd9Sstevel@tonic-gate  * is required to pass a AUTH * to routines that create rpc
31*7c478bd9Sstevel@tonic-gate  * "sessions".
32*7c478bd9Sstevel@tonic-gate  */
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate 
35*7c478bd9Sstevel@tonic-gate #ifndef _rpc_auth_h
36*7c478bd9Sstevel@tonic-gate #define	_rpc_auth_h
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate #define	MAX_AUTH_BYTES	400
39*7c478bd9Sstevel@tonic-gate #define	MAXNETNAMELEN	255	/* maximum length of network user's name */
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate /*
42*7c478bd9Sstevel@tonic-gate  * Status returned from authentication check
43*7c478bd9Sstevel@tonic-gate  */
44*7c478bd9Sstevel@tonic-gate enum auth_stat {
45*7c478bd9Sstevel@tonic-gate 	AUTH_OK=0,
46*7c478bd9Sstevel@tonic-gate 	/*
47*7c478bd9Sstevel@tonic-gate 	 * failed at remote end
48*7c478bd9Sstevel@tonic-gate 	 */
49*7c478bd9Sstevel@tonic-gate 	AUTH_BADCRED=1,			/* bogus credentials (seal broken) */
50*7c478bd9Sstevel@tonic-gate 	AUTH_REJECTEDCRED=2,		/* client should begin new session */
51*7c478bd9Sstevel@tonic-gate 	AUTH_BADVERF=3,			/* bogus verifier (seal broken) */
52*7c478bd9Sstevel@tonic-gate 	AUTH_REJECTEDVERF=4,		/* verifier expired or was replayed */
53*7c478bd9Sstevel@tonic-gate 	AUTH_TOOWEAK=5,			/* rejected due to security reasons */
54*7c478bd9Sstevel@tonic-gate 	/*
55*7c478bd9Sstevel@tonic-gate 	 * failed locally
56*7c478bd9Sstevel@tonic-gate 	*/
57*7c478bd9Sstevel@tonic-gate 	AUTH_INVALIDRESP=6,		/* bogus response verifier */
58*7c478bd9Sstevel@tonic-gate 	AUTH_FAILED=7			/* some unknown reason */
59*7c478bd9Sstevel@tonic-gate };
60*7c478bd9Sstevel@tonic-gate 
61*7c478bd9Sstevel@tonic-gate #if (mc68000 || sparc || vax || i386)
62*7c478bd9Sstevel@tonic-gate typedef u_long u_int32;	/* 32-bit unsigned integers */
63*7c478bd9Sstevel@tonic-gate #endif
64*7c478bd9Sstevel@tonic-gate 
65*7c478bd9Sstevel@tonic-gate union des_block {
66*7c478bd9Sstevel@tonic-gate 	struct {
67*7c478bd9Sstevel@tonic-gate 		u_int32 high;
68*7c478bd9Sstevel@tonic-gate 		u_int32 low;
69*7c478bd9Sstevel@tonic-gate 	} key;
70*7c478bd9Sstevel@tonic-gate 	char c[8];
71*7c478bd9Sstevel@tonic-gate };
72*7c478bd9Sstevel@tonic-gate typedef union des_block des_block;
73*7c478bd9Sstevel@tonic-gate extern bool_t xdr_des_block();
74*7c478bd9Sstevel@tonic-gate 
75*7c478bd9Sstevel@tonic-gate /*
76*7c478bd9Sstevel@tonic-gate  * Authentication info.  Opaque to client.
77*7c478bd9Sstevel@tonic-gate  */
78*7c478bd9Sstevel@tonic-gate struct opaque_auth {
79*7c478bd9Sstevel@tonic-gate 	enum_t	oa_flavor;		/* flavor of auth */
80*7c478bd9Sstevel@tonic-gate 	caddr_t	oa_base;		/* address of more auth stuff */
81*7c478bd9Sstevel@tonic-gate 	u_int	oa_length;		/* not to exceed MAX_AUTH_BYTES */
82*7c478bd9Sstevel@tonic-gate };
83*7c478bd9Sstevel@tonic-gate 
84*7c478bd9Sstevel@tonic-gate 
85*7c478bd9Sstevel@tonic-gate /*
86*7c478bd9Sstevel@tonic-gate  * Auth handle, interface to client side authenticators.
87*7c478bd9Sstevel@tonic-gate  */
88*7c478bd9Sstevel@tonic-gate typedef struct {
89*7c478bd9Sstevel@tonic-gate 	struct	opaque_auth	ah_cred;
90*7c478bd9Sstevel@tonic-gate 	struct	opaque_auth	ah_verf;
91*7c478bd9Sstevel@tonic-gate 	union	des_block	ah_key;
92*7c478bd9Sstevel@tonic-gate 	struct auth_ops {
93*7c478bd9Sstevel@tonic-gate 		void	(*ah_nextverf)();
94*7c478bd9Sstevel@tonic-gate 		int	(*ah_marshal)();	/* nextverf & serialize */
95*7c478bd9Sstevel@tonic-gate 		int	(*ah_validate)();	/* validate varifier */
96*7c478bd9Sstevel@tonic-gate 		int	(*ah_refresh)();	/* refresh credentials */
97*7c478bd9Sstevel@tonic-gate 		void	(*ah_destroy)();	/* destroy this structure */
98*7c478bd9Sstevel@tonic-gate 	} *ah_ops;
99*7c478bd9Sstevel@tonic-gate 	caddr_t ah_private;
100*7c478bd9Sstevel@tonic-gate } AUTH;
101*7c478bd9Sstevel@tonic-gate 
102*7c478bd9Sstevel@tonic-gate 
103*7c478bd9Sstevel@tonic-gate /*
104*7c478bd9Sstevel@tonic-gate  * Authentication ops.
105*7c478bd9Sstevel@tonic-gate  * The ops and the auth handle provide the interface to the authenticators.
106*7c478bd9Sstevel@tonic-gate  *
107*7c478bd9Sstevel@tonic-gate  * AUTH	*auth;
108*7c478bd9Sstevel@tonic-gate  * XDR	*xdrs;
109*7c478bd9Sstevel@tonic-gate  * struct opaque_auth verf;
110*7c478bd9Sstevel@tonic-gate  */
111*7c478bd9Sstevel@tonic-gate #define	AUTH_NEXTVERF(auth)		\
112*7c478bd9Sstevel@tonic-gate 		((*((auth)->ah_ops->ah_nextverf))(auth))
113*7c478bd9Sstevel@tonic-gate #define	auth_nextverf(auth)		\
114*7c478bd9Sstevel@tonic-gate 		((*((auth)->ah_ops->ah_nextverf))(auth))
115*7c478bd9Sstevel@tonic-gate 
116*7c478bd9Sstevel@tonic-gate #define	AUTH_MARSHALL(auth, xdrs)	\
117*7c478bd9Sstevel@tonic-gate 		((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
118*7c478bd9Sstevel@tonic-gate #define	auth_marshall(auth, xdrs)	\
119*7c478bd9Sstevel@tonic-gate 		((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
120*7c478bd9Sstevel@tonic-gate 
121*7c478bd9Sstevel@tonic-gate #define	AUTH_VALIDATE(auth, verfp)	\
122*7c478bd9Sstevel@tonic-gate 		((*((auth)->ah_ops->ah_validate))((auth), verfp))
123*7c478bd9Sstevel@tonic-gate #define	auth_validate(auth, verfp)	\
124*7c478bd9Sstevel@tonic-gate 		((*((auth)->ah_ops->ah_validate))((auth), verfp))
125*7c478bd9Sstevel@tonic-gate 
126*7c478bd9Sstevel@tonic-gate #define	AUTH_REFRESH(auth)		\
127*7c478bd9Sstevel@tonic-gate 		((*((auth)->ah_ops->ah_refresh))(auth))
128*7c478bd9Sstevel@tonic-gate #define	auth_refresh(auth)		\
129*7c478bd9Sstevel@tonic-gate 		((*((auth)->ah_ops->ah_refresh))(auth))
130*7c478bd9Sstevel@tonic-gate 
131*7c478bd9Sstevel@tonic-gate #define	AUTH_DESTROY(auth)		\
132*7c478bd9Sstevel@tonic-gate 		((*((auth)->ah_ops->ah_destroy))(auth))
133*7c478bd9Sstevel@tonic-gate #define	auth_destroy(auth)		\
134*7c478bd9Sstevel@tonic-gate 		((*((auth)->ah_ops->ah_destroy))(auth))
135*7c478bd9Sstevel@tonic-gate 
136*7c478bd9Sstevel@tonic-gate 
137*7c478bd9Sstevel@tonic-gate extern struct opaque_auth _null_auth;
138*7c478bd9Sstevel@tonic-gate 
139*7c478bd9Sstevel@tonic-gate 
140*7c478bd9Sstevel@tonic-gate /*
141*7c478bd9Sstevel@tonic-gate  * These are the various implementations of client side authenticators.
142*7c478bd9Sstevel@tonic-gate  */
143*7c478bd9Sstevel@tonic-gate 
144*7c478bd9Sstevel@tonic-gate /*
145*7c478bd9Sstevel@tonic-gate  * Unix style authentication
146*7c478bd9Sstevel@tonic-gate  * AUTH *authunix_create(machname, uid, gid, len, aup_gids)
147*7c478bd9Sstevel@tonic-gate  *	char *machname;
148*7c478bd9Sstevel@tonic-gate  *	int uid;
149*7c478bd9Sstevel@tonic-gate  *	int gid;
150*7c478bd9Sstevel@tonic-gate  *	int len;
151*7c478bd9Sstevel@tonic-gate  *	int *aup_gids;
152*7c478bd9Sstevel@tonic-gate  */
153*7c478bd9Sstevel@tonic-gate #ifdef KERNEL
154*7c478bd9Sstevel@tonic-gate extern AUTH *authkern_create();		/* takes no parameters */
155*7c478bd9Sstevel@tonic-gate #else
156*7c478bd9Sstevel@tonic-gate extern AUTH *authsys_create(const char *, const uid_t, const gid_t,
157*7c478bd9Sstevel@tonic-gate     const int, const gid_t *);
158*7c478bd9Sstevel@tonic-gate extern AUTH *authsys_create_default(void);	/* takes no parameters */
159*7c478bd9Sstevel@tonic-gate extern AUTH *authnone_create();		/* takes no parameters */
160*7c478bd9Sstevel@tonic-gate #endif
161*7c478bd9Sstevel@tonic-gate extern AUTH *authdes_create();
162*7c478bd9Sstevel@tonic-gate 
163*7c478bd9Sstevel@tonic-gate #define	AUTH_NONE	0		/* no authentication */
164*7c478bd9Sstevel@tonic-gate #define	AUTH_NULL	0		/* backward compatibility */
165*7c478bd9Sstevel@tonic-gate #define	AUTH_UNIX	1		/* unix style (uid, gids) */
166*7c478bd9Sstevel@tonic-gate #define	AUTH_SHORT	2		/* short hand unix style */
167*7c478bd9Sstevel@tonic-gate #define	AUTH_DES	3		/* des style (encrypted timestamps) */
168*7c478bd9Sstevel@tonic-gate 
169*7c478bd9Sstevel@tonic-gate #endif /* !_rpc_auth_h */
170