auth.h revision 1.2 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.2 brezak #ifndef _RPC_AUTH_H
42 1.2 brezak #define _RPC_AUTH_H
43 1.2 brezak #include <sys/cdefs.h>
44 1.1 deraadt
45 1.1 deraadt #define MAX_AUTH_BYTES 400
46 1.1 deraadt #define MAXNETNAMELEN 255 /* maximum length of network user's name */
47 1.1 deraadt
48 1.1 deraadt /*
49 1.1 deraadt * Status returned from authentication check
50 1.1 deraadt */
51 1.1 deraadt enum auth_stat {
52 1.1 deraadt AUTH_OK=0,
53 1.1 deraadt /*
54 1.1 deraadt * failed at remote end
55 1.1 deraadt */
56 1.1 deraadt AUTH_BADCRED=1, /* bogus credentials (seal broken) */
57 1.1 deraadt AUTH_REJECTEDCRED=2, /* client should begin new session */
58 1.1 deraadt AUTH_BADVERF=3, /* bogus verifier (seal broken) */
59 1.1 deraadt AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */
60 1.1 deraadt AUTH_TOOWEAK=5, /* rejected due to security reasons */
61 1.1 deraadt /*
62 1.1 deraadt * failed locally
63 1.1 deraadt */
64 1.1 deraadt AUTH_INVALIDRESP=6, /* bogus response verifier */
65 1.1 deraadt AUTH_FAILED=7 /* some unknown reason */
66 1.1 deraadt };
67 1.1 deraadt
68 1.1 deraadt #if (mc68000 || sparc || vax || i386 || tahoe || hp300)
69 1.1 deraadt typedef u_long u_int32; /* 32-bit unsigned integers */
70 1.1 deraadt #endif
71 1.1 deraadt
72 1.1 deraadt union des_block {
73 1.1 deraadt struct {
74 1.1 deraadt u_int32 high;
75 1.1 deraadt u_int32 low;
76 1.1 deraadt } key;
77 1.1 deraadt char c[8];
78 1.1 deraadt };
79 1.1 deraadt typedef union des_block des_block;
80 1.2 brezak __BEGIN_DECLS
81 1.2 brezak extern bool_t xdr_des_block __P((XDR *, des_block *));
82 1.2 brezak __END_DECLS
83 1.1 deraadt
84 1.1 deraadt /*
85 1.1 deraadt * Authentication info. Opaque to client.
86 1.1 deraadt */
87 1.1 deraadt struct opaque_auth {
88 1.1 deraadt enum_t oa_flavor; /* flavor of auth */
89 1.1 deraadt caddr_t oa_base; /* address of more auth stuff */
90 1.1 deraadt u_int oa_length; /* not to exceed MAX_AUTH_BYTES */
91 1.1 deraadt };
92 1.1 deraadt
93 1.1 deraadt
94 1.1 deraadt /*
95 1.1 deraadt * Auth handle, interface to client side authenticators.
96 1.1 deraadt */
97 1.1 deraadt typedef struct {
98 1.1 deraadt struct opaque_auth ah_cred;
99 1.1 deraadt struct opaque_auth ah_verf;
100 1.1 deraadt union des_block ah_key;
101 1.1 deraadt struct auth_ops {
102 1.1 deraadt void (*ah_nextverf)();
103 1.1 deraadt int (*ah_marshal)(); /* nextverf & serialize */
104 1.1 deraadt int (*ah_validate)(); /* validate varifier */
105 1.1 deraadt int (*ah_refresh)(); /* refresh credentials */
106 1.1 deraadt void (*ah_destroy)(); /* destroy this structure */
107 1.1 deraadt } *ah_ops;
108 1.1 deraadt caddr_t ah_private;
109 1.1 deraadt } AUTH;
110 1.1 deraadt
111 1.1 deraadt
112 1.1 deraadt /*
113 1.1 deraadt * Authentication ops.
114 1.1 deraadt * The ops and the auth handle provide the interface to the authenticators.
115 1.1 deraadt *
116 1.1 deraadt * AUTH *auth;
117 1.1 deraadt * XDR *xdrs;
118 1.1 deraadt * struct opaque_auth verf;
119 1.1 deraadt */
120 1.1 deraadt #define AUTH_NEXTVERF(auth) \
121 1.1 deraadt ((*((auth)->ah_ops->ah_nextverf))(auth))
122 1.1 deraadt #define auth_nextverf(auth) \
123 1.1 deraadt ((*((auth)->ah_ops->ah_nextverf))(auth))
124 1.1 deraadt
125 1.1 deraadt #define AUTH_MARSHALL(auth, xdrs) \
126 1.1 deraadt ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
127 1.1 deraadt #define auth_marshall(auth, xdrs) \
128 1.1 deraadt ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
129 1.1 deraadt
130 1.1 deraadt #define AUTH_VALIDATE(auth, verfp) \
131 1.1 deraadt ((*((auth)->ah_ops->ah_validate))((auth), verfp))
132 1.1 deraadt #define auth_validate(auth, verfp) \
133 1.1 deraadt ((*((auth)->ah_ops->ah_validate))((auth), verfp))
134 1.1 deraadt
135 1.1 deraadt #define AUTH_REFRESH(auth) \
136 1.1 deraadt ((*((auth)->ah_ops->ah_refresh))(auth))
137 1.1 deraadt #define auth_refresh(auth) \
138 1.1 deraadt ((*((auth)->ah_ops->ah_refresh))(auth))
139 1.1 deraadt
140 1.1 deraadt #define AUTH_DESTROY(auth) \
141 1.1 deraadt ((*((auth)->ah_ops->ah_destroy))(auth))
142 1.1 deraadt #define auth_destroy(auth) \
143 1.1 deraadt ((*((auth)->ah_ops->ah_destroy))(auth))
144 1.1 deraadt
145 1.1 deraadt
146 1.1 deraadt extern struct opaque_auth _null_auth;
147 1.1 deraadt
148 1.1 deraadt
149 1.1 deraadt /*
150 1.1 deraadt * These are the various implementations of client side authenticators.
151 1.1 deraadt */
152 1.1 deraadt
153 1.1 deraadt /*
154 1.1 deraadt * Unix style authentication
155 1.1 deraadt * AUTH *authunix_create(machname, uid, gid, len, aup_gids)
156 1.1 deraadt * char *machname;
157 1.1 deraadt * int uid;
158 1.1 deraadt * int gid;
159 1.1 deraadt * int len;
160 1.1 deraadt * int *aup_gids;
161 1.1 deraadt */
162 1.2 brezak __BEGIN_DECLS
163 1.2 brezak extern AUTH *authunix_create __P((char *, int, int, int, int *));
164 1.2 brezak extern AUTH *authunix_create_default __P((void));
165 1.2 brezak extern AUTH *authnone_create __P((void));
166 1.1 deraadt extern AUTH *authdes_create();
167 1.2 brezak __END_DECLS
168 1.1 deraadt
169 1.1 deraadt #define AUTH_NONE 0 /* no authentication */
170 1.1 deraadt #define AUTH_NULL 0 /* backward compatibility */
171 1.1 deraadt #define AUTH_UNIX 1 /* unix style (uid, gids) */
172 1.1 deraadt #define AUTH_SHORT 2 /* short hand unix style */
173 1.1 deraadt #define AUTH_DES 3 /* des style (encrypted timestamps) */
174 1.2 brezak
175 1.2 brezak #endif /* !_RPC_AUTH_H */
176