auth.h revision 1.1 1 1.1 deraadt /* @(#)auth.h 2.3 88/08/07 4.0 RPCSRC; from 1.17 88/02/08 SMI */
2 1.1 deraadt /*
3 1.1 deraadt * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
4 1.1 deraadt * unrestricted use provided that this legend is included on all tape
5 1.1 deraadt * media and as a part of the software program in whole or part. Users
6 1.1 deraadt * may copy or modify Sun RPC without charge, but are not authorized
7 1.1 deraadt * to license or distribute it to anyone else except as part of a product or
8 1.1 deraadt * program developed by the user.
9 1.1 deraadt *
10 1.1 deraadt * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
11 1.1 deraadt * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
12 1.1 deraadt * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
13 1.1 deraadt *
14 1.1 deraadt * Sun RPC is provided with no support and without any obligation on the
15 1.1 deraadt * part of Sun Microsystems, Inc. to assist in its use, correction,
16 1.1 deraadt * modification or enhancement.
17 1.1 deraadt *
18 1.1 deraadt * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
19 1.1 deraadt * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
20 1.1 deraadt * OR ANY PART THEREOF.
21 1.1 deraadt *
22 1.1 deraadt * In no event will Sun Microsystems, Inc. be liable for any lost revenue
23 1.1 deraadt * or profits or other special, indirect and consequential damages, even if
24 1.1 deraadt * Sun has been advised of the possibility of such damages.
25 1.1 deraadt *
26 1.1 deraadt * Sun Microsystems, Inc.
27 1.1 deraadt * 2550 Garcia Avenue
28 1.1 deraadt * Mountain View, California 94043
29 1.1 deraadt */
30 1.1 deraadt
31 1.1 deraadt /*
32 1.1 deraadt * auth.h, Authentication interface.
33 1.1 deraadt *
34 1.1 deraadt * Copyright (C) 1984, Sun Microsystems, Inc.
35 1.1 deraadt *
36 1.1 deraadt * The data structures are completely opaque to the client. The client
37 1.1 deraadt * is required to pass a AUTH * to routines that create rpc
38 1.1 deraadt * "sessions".
39 1.1 deraadt */
40 1.1 deraadt
41 1.1 deraadt
42 1.1 deraadt #define MAX_AUTH_BYTES 400
43 1.1 deraadt #define MAXNETNAMELEN 255 /* maximum length of network user's name */
44 1.1 deraadt
45 1.1 deraadt /*
46 1.1 deraadt * Status returned from authentication check
47 1.1 deraadt */
48 1.1 deraadt enum auth_stat {
49 1.1 deraadt AUTH_OK=0,
50 1.1 deraadt /*
51 1.1 deraadt * failed at remote end
52 1.1 deraadt */
53 1.1 deraadt AUTH_BADCRED=1, /* bogus credentials (seal broken) */
54 1.1 deraadt AUTH_REJECTEDCRED=2, /* client should begin new session */
55 1.1 deraadt AUTH_BADVERF=3, /* bogus verifier (seal broken) */
56 1.1 deraadt AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */
57 1.1 deraadt AUTH_TOOWEAK=5, /* rejected due to security reasons */
58 1.1 deraadt /*
59 1.1 deraadt * failed locally
60 1.1 deraadt */
61 1.1 deraadt AUTH_INVALIDRESP=6, /* bogus response verifier */
62 1.1 deraadt AUTH_FAILED=7 /* some unknown reason */
63 1.1 deraadt };
64 1.1 deraadt
65 1.1 deraadt #if (mc68000 || sparc || vax || i386 || tahoe || hp300)
66 1.1 deraadt typedef u_long u_int32; /* 32-bit unsigned integers */
67 1.1 deraadt #endif
68 1.1 deraadt
69 1.1 deraadt union des_block {
70 1.1 deraadt struct {
71 1.1 deraadt u_int32 high;
72 1.1 deraadt u_int32 low;
73 1.1 deraadt } key;
74 1.1 deraadt char c[8];
75 1.1 deraadt };
76 1.1 deraadt typedef union des_block des_block;
77 1.1 deraadt extern bool_t xdr_des_block();
78 1.1 deraadt
79 1.1 deraadt /*
80 1.1 deraadt * Authentication info. Opaque to client.
81 1.1 deraadt */
82 1.1 deraadt struct opaque_auth {
83 1.1 deraadt enum_t oa_flavor; /* flavor of auth */
84 1.1 deraadt caddr_t oa_base; /* address of more auth stuff */
85 1.1 deraadt u_int oa_length; /* not to exceed MAX_AUTH_BYTES */
86 1.1 deraadt };
87 1.1 deraadt
88 1.1 deraadt
89 1.1 deraadt /*
90 1.1 deraadt * Auth handle, interface to client side authenticators.
91 1.1 deraadt */
92 1.1 deraadt typedef struct {
93 1.1 deraadt struct opaque_auth ah_cred;
94 1.1 deraadt struct opaque_auth ah_verf;
95 1.1 deraadt union des_block ah_key;
96 1.1 deraadt struct auth_ops {
97 1.1 deraadt void (*ah_nextverf)();
98 1.1 deraadt int (*ah_marshal)(); /* nextverf & serialize */
99 1.1 deraadt int (*ah_validate)(); /* validate varifier */
100 1.1 deraadt int (*ah_refresh)(); /* refresh credentials */
101 1.1 deraadt void (*ah_destroy)(); /* destroy this structure */
102 1.1 deraadt } *ah_ops;
103 1.1 deraadt caddr_t ah_private;
104 1.1 deraadt } AUTH;
105 1.1 deraadt
106 1.1 deraadt
107 1.1 deraadt /*
108 1.1 deraadt * Authentication ops.
109 1.1 deraadt * The ops and the auth handle provide the interface to the authenticators.
110 1.1 deraadt *
111 1.1 deraadt * AUTH *auth;
112 1.1 deraadt * XDR *xdrs;
113 1.1 deraadt * struct opaque_auth verf;
114 1.1 deraadt */
115 1.1 deraadt #define AUTH_NEXTVERF(auth) \
116 1.1 deraadt ((*((auth)->ah_ops->ah_nextverf))(auth))
117 1.1 deraadt #define auth_nextverf(auth) \
118 1.1 deraadt ((*((auth)->ah_ops->ah_nextverf))(auth))
119 1.1 deraadt
120 1.1 deraadt #define AUTH_MARSHALL(auth, xdrs) \
121 1.1 deraadt ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
122 1.1 deraadt #define auth_marshall(auth, xdrs) \
123 1.1 deraadt ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
124 1.1 deraadt
125 1.1 deraadt #define AUTH_VALIDATE(auth, verfp) \
126 1.1 deraadt ((*((auth)->ah_ops->ah_validate))((auth), verfp))
127 1.1 deraadt #define auth_validate(auth, verfp) \
128 1.1 deraadt ((*((auth)->ah_ops->ah_validate))((auth), verfp))
129 1.1 deraadt
130 1.1 deraadt #define AUTH_REFRESH(auth) \
131 1.1 deraadt ((*((auth)->ah_ops->ah_refresh))(auth))
132 1.1 deraadt #define auth_refresh(auth) \
133 1.1 deraadt ((*((auth)->ah_ops->ah_refresh))(auth))
134 1.1 deraadt
135 1.1 deraadt #define AUTH_DESTROY(auth) \
136 1.1 deraadt ((*((auth)->ah_ops->ah_destroy))(auth))
137 1.1 deraadt #define auth_destroy(auth) \
138 1.1 deraadt ((*((auth)->ah_ops->ah_destroy))(auth))
139 1.1 deraadt
140 1.1 deraadt
141 1.1 deraadt extern struct opaque_auth _null_auth;
142 1.1 deraadt
143 1.1 deraadt
144 1.1 deraadt /*
145 1.1 deraadt * These are the various implementations of client side authenticators.
146 1.1 deraadt */
147 1.1 deraadt
148 1.1 deraadt /*
149 1.1 deraadt * Unix style authentication
150 1.1 deraadt * AUTH *authunix_create(machname, uid, gid, len, aup_gids)
151 1.1 deraadt * char *machname;
152 1.1 deraadt * int uid;
153 1.1 deraadt * int gid;
154 1.1 deraadt * int len;
155 1.1 deraadt * int *aup_gids;
156 1.1 deraadt */
157 1.1 deraadt extern AUTH *authunix_create();
158 1.1 deraadt extern AUTH *authunix_create_default(); /* takes no parameters */
159 1.1 deraadt extern AUTH *authnone_create(); /* takes no parameters */
160 1.1 deraadt extern AUTH *authdes_create();
161 1.1 deraadt
162 1.1 deraadt #define AUTH_NONE 0 /* no authentication */
163 1.1 deraadt #define AUTH_NULL 0 /* backward compatibility */
164 1.1 deraadt #define AUTH_UNIX 1 /* unix style (uid, gids) */
165 1.1 deraadt #define AUTH_SHORT 2 /* short hand unix style */
166 1.1 deraadt #define AUTH_DES 3 /* des style (encrypted timestamps) */
167