1 /* $OpenBSD: auth.h,v 1.2 1997/09/21 10:46:09 niklas Exp $ */
2 /* $NetBSD: auth.h,v 1.7 1995/04/29 05:27:55 cgd Exp $ */
5 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
6 * unrestricted use provided that this legend is included on all tape
7 * media and as a part of the software program in whole or part. Users
8 * may copy or modify Sun RPC without charge, but are not authorized
9 * to license or distribute it to anyone else except as part of a product or
10 * program developed by the user.
12 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
13 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
14 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
16 * Sun RPC is provided with no support and without any obligation on the
17 * part of Sun Microsystems, Inc. to assist in its use, correction,
18 * modification or enhancement.
20 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
21 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
22 * OR ANY PART THEREOF.
24 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
25 * or profits or other special, indirect and consequential damages, even if
26 * Sun has been advised of the possibility of such damages.
28 * Sun Microsystems, Inc.
30 * Mountain View, California 94043
32 * from: @(#)auth.h 1.17 88/02/08 SMI
33 * @(#)auth.h 2.3 88/08/07 4.0 RPCSRC
37 * auth.h, Authentication interface.
39 * Copyright (C) 1984, Sun Microsystems, Inc.
41 * The data structures are completely opaque to the client. The client
42 * is required to pass a AUTH * to routines that create rpc
48 #include <sys/cdefs.h>
50 #define MAX_AUTH_BYTES 400
51 #define MAXNETNAMELEN 255 /* maximum length of network user's name */
54 * Status returned from authentication check
59 * failed at remote end
61 AUTH_BADCRED=1, /* bogus credentials (seal broken) */
62 AUTH_REJECTEDCRED=2, /* client should begin new session */
63 AUTH_BADVERF=3, /* bogus verifier (seal broken) */
64 AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */
65 AUTH_TOOWEAK=5, /* rejected due to security reasons */
69 AUTH_INVALIDRESP=6, /* bogus response verifier */
70 AUTH_FAILED=7, /* some unknown reason */
74 RPCSEC_GSS_CREDPROBLEM = 13,
75 RPCSEC_GSS_CTXPROBLEM = 14
78 typedef u_int32_t u_int32; /* 32-bit unsigned integers */
87 typedef union des_block des_block;
89 extern bool_t xdr_des_block __P((XDR *, des_block *));
93 * Authentication info. Opaque to client.
96 enum_t oa_flavor; /* flavor of auth */
97 caddr_t oa_base; /* address of more auth stuff */
98 u_int oa_length; /* not to exceed MAX_AUTH_BYTES */
103 * Auth handle, interface to client side authenticators.
105 typedef struct __rpc_auth {
106 struct opaque_auth ah_cred;
107 struct opaque_auth ah_verf;
108 union des_block ah_key;
110 void (*ah_nextverf) __P((struct __rpc_auth *));
111 /* nextverf & serialize */
112 int (*ah_marshal) __P((struct __rpc_auth *, XDR *));
113 /* validate verifier */
114 int (*ah_validate) __P((struct __rpc_auth *,
115 struct opaque_auth *));
116 /* refresh credentials */
117 int (*ah_refresh) __P((struct __rpc_auth *));
118 /* destroy this structure */
119 void (*ah_destroy) __P((struct __rpc_auth *));
120 /* encode data for wire */
121 int (*ah_wrap) __P((struct __rpc_auth *, XDR *, xdrproc_t, caddr_t));
122 /* decode data for wire */
123 int (*ah_unwrap) __P((struct __rpc_auth *, XDR *, xdrproc_t, caddr_t));
131 * Authentication ops.
132 * The ops and the auth handle provide the interface to the authenticators.
136 * struct opaque_auth verf;
138 #define AUTH_NEXTVERF(auth) \
139 ((*((auth)->ah_ops->ah_nextverf))(auth))
140 #define auth_nextverf(auth) \
141 ((*((auth)->ah_ops->ah_nextverf))(auth))
143 #define AUTH_MARSHALL(auth, xdrs) \
144 ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
145 #define auth_marshall(auth, xdrs) \
146 ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
148 #define AUTH_VALIDATE(auth, verfp) \
149 ((*((auth)->ah_ops->ah_validate))((auth), verfp))
150 #define auth_validate(auth, verfp) \
151 ((*((auth)->ah_ops->ah_validate))((auth), verfp))
153 #define AUTH_REFRESH(auth) \
154 ((*((auth)->ah_ops->ah_refresh))(auth))
155 #define auth_refresh(auth) \
156 ((*((auth)->ah_ops->ah_refresh))(auth))
158 #define AUTH_DESTROY(auth) \
159 ((*((auth)->ah_ops->ah_destroy))(auth))
160 #define auth_destroy(auth) \
161 ((*((auth)->ah_ops->ah_destroy))(auth))
163 #define AUTH_WRAP(auth, xdrs, xfunc, xwhere) \
164 ((*((auth)->ah_ops->ah_wrap))(auth, xdrs, \
166 #define auth_wrap(auth, xdrs, xfunc, xwhere) \
167 ((*((auth)->ah_ops->ah_wrap))(auth, xdrs, \
170 #define AUTH_UNWRAP(auth, xdrs, xfunc, xwhere) \
171 ((*((auth)->ah_ops->ah_unwrap))(auth, xdrs, \
173 #define auth_unwrap(auth, xdrs, xfunc, xwhere) \
174 ((*((auth)->ah_ops->ah_unwrap))(auth, xdrs, \
178 extern struct opaque_auth _null_auth;
181 * Any style authentication. These routines can be used by any
182 * authentication style that does not use the wrap/unwrap functions.
184 int authany_wrap(), authany_unwrap();
187 * These are the various implementations of client side authenticators.
191 * Unix style authentication
192 * AUTH *authunix_create(machname, uid, gid, len, aup_gids)
201 extern AUTH *authunix_create __P((char *, int, int, int, int *));
202 extern AUTH *authunix_create_default __P((void));
203 extern AUTH *authnone_create __P((void));
204 extern AUTH *authdes_create __P((char *, u_int,
205 struct sockaddr_in *, des_block *));
206 extern bool_t xdr_opaque_auth __P((XDR *, struct opaque_auth *));
209 #define AUTH_NONE 0 /* no authentication */
210 #define AUTH_NULL 0 /* backward compatibility */
211 #define AUTH_UNIX 1 /* unix style (uid, gids) */
212 #define AUTH_SHORT 2 /* short hand unix style */
213 #define AUTH_DES 3 /* des style (encrypted timestamps) */
214 #define RPCSEC_GSS 6 /* RPCSEC_GSS */
216 #endif /* !_RPC_AUTH_H */