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