Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

auth.h

Go to the documentation of this file.
00001 /*  $Id$ */
00002 /*      $OpenBSD: auth.h,v 1.2 1997/09/21 10:46:09 niklas Exp $ */
00003 /*      $NetBSD: auth.h,v 1.7 1995/04/29 05:27:55 cgd Exp $     */
00004 
00005 /*
00006  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
00007  * unrestricted use provided that this legend is included on all tape
00008  * media and as a part of the software program in whole or part.  Users
00009  * may copy or modify Sun RPC without charge, but are not authorized
00010  * to license or distribute it to anyone else except as part of a product or
00011  * program developed by the user.
00012  * 
00013  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
00014  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
00015  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
00016  * 
00017  * Sun RPC is provided with no support and without any obligation on the
00018  * part of Sun Microsystems, Inc. to assist in its use, correction,
00019  * modification or enhancement.
00020  * 
00021  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
00022  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
00023  * OR ANY PART THEREOF.
00024  * 
00025  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
00026  * or profits or other special, indirect and consequential damages, even if
00027  * Sun has been advised of the possibility of such damages.
00028  * 
00029  * Sun Microsystems, Inc.
00030  * 2550 Garcia Avenue
00031  * Mountain View, California  94043
00032  *
00033  *      from: @(#)auth.h 1.17 88/02/08 SMI
00034  *      @(#)auth.h      2.3 88/08/07 4.0 RPCSRC
00035  */
00036 
00037 /*
00038  * auth.h, Authentication interface.
00039  *
00040  * Copyright (C) 1984, Sun Microsystems, Inc.
00041  *
00042  * The data structures are completely opaque to the client.  The client
00043  * is required to pass a AUTH * to routines that create rpc
00044  * "sessions".
00045  */
00046 
00047 #ifndef _RPC_AUTH_H
00048 #define _RPC_AUTH_H
00049 #ifndef WIN32
00050         #include <sys/cdefs.h>
00051 #endif
00052 
00053 #define MAX_AUTH_BYTES  400
00054 #define MAXNETNAMELEN   255     /* maximum length of network user's name */
00055 
00056 /*
00057  * Status returned from authentication check
00058  */
00059 enum auth_stat {
00060         AUTH_OK=0,
00061         /*
00062          * failed at remote end
00063          */
00064         AUTH_BADCRED=1,                 /* bogus credentials (seal broken) */
00065         AUTH_REJECTEDCRED=2,            /* client should begin new session */
00066         AUTH_BADVERF=3,                 /* bogus verifier (seal broken) */
00067         AUTH_REJECTEDVERF=4,            /* verifier expired or was replayed */
00068         AUTH_TOOWEAK=5,                 /* rejected due to security reasons */
00069         /*
00070          * failed locally
00071         */
00072         AUTH_INVALIDRESP=6,             /* bogus response verifier */
00073         AUTH_FAILED=7                   /* some unknown reason */
00074 };
00075 
00076 #ifdef WIN32
00077     /* This is now located in <stdint.h> */
00078         /*typedef unsigned int u_int32;*/       /* 32-bit unsigned integers */
00079     #include <stdint.h>
00080 #else
00081         /*typedef u_int32_t u_int32;*/  /* 32-bit unsigned integers */
00082 #endif
00083 
00084 union des_block {
00085         struct {
00086                 u_int32 high;
00087                 u_int32 low;
00088         } key;
00089         char c[8];
00090 };
00091 typedef union des_block des_block;
00092 __BEGIN_DECLS
00093 extern bool_t xdr_des_block __P((XDR *, des_block *));
00094 __END_DECLS
00095 
00096 /*
00097  * Authentication info.  Opaque to client.
00098  */
00099 struct opaque_auth {
00100         enum_t  oa_flavor;              /* flavor of auth */
00101         caddr_t oa_base;                /* address of more auth stuff */
00102         u_int   oa_length;              /* not to exceed MAX_AUTH_BYTES */
00103 };
00104 
00105 
00106 /*
00107  * Auth handle, interface to client side authenticators.
00108  */
00109 typedef struct __rpc_auth {
00110         struct  opaque_auth     ah_cred;
00111         struct  opaque_auth     ah_verf;
00112         union   des_block       ah_key;
00113         struct auth_ops {
00114                 void    (*ah_nextverf) __P((struct __rpc_auth *));
00115                 /* nextverf & serialize */
00116                 int     (*ah_marshal) __P((struct __rpc_auth *, XDR *));
00117                 /* validate varifier */
00118                 int     (*ah_validate) __P((struct __rpc_auth *,
00119                             struct opaque_auth *));
00120                 /* refresh credentials */
00121                 int     (*ah_refresh) __P((struct __rpc_auth *));
00122                 /* destroy this structure */
00123                 void    (*ah_destroy) __P((struct __rpc_auth *));
00124         } *ah_ops;
00125         caddr_t ah_private;
00126 } AUTH;
00127 
00128 
00129 /*
00130  * Authentication ops.
00131  * The ops and the auth handle provide the interface to the authenticators.
00132  *
00133  * AUTH *auth;
00134  * XDR  *xdrs;
00135  * struct opaque_auth verf;
00136  */
00137 #define AUTH_NEXTVERF(auth)             \
00138                 ((*((auth)->ah_ops->ah_nextverf))(auth))
00139 #define auth_nextverf(auth)             \
00140                 ((*((auth)->ah_ops->ah_nextverf))(auth))
00141 
00142 #define AUTH_MARSHALL(auth, xdrs)       \
00143                 ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
00144 #define auth_marshall(auth, xdrs)       \
00145                 ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
00146 
00147 #define AUTH_VALIDATE(auth, verfp)      \
00148                 ((*((auth)->ah_ops->ah_validate))((auth), verfp))
00149 #define auth_validate(auth, verfp)      \
00150                 ((*((auth)->ah_ops->ah_validate))((auth), verfp))
00151 
00152 #define AUTH_REFRESH(auth)              \
00153                 ((*((auth)->ah_ops->ah_refresh))(auth))
00154 #define auth_refresh(auth)              \
00155                 ((*((auth)->ah_ops->ah_refresh))(auth))
00156 
00157 #define AUTH_DESTROY(auth)              \
00158                 ((*((auth)->ah_ops->ah_destroy))(auth))
00159 #define auth_destroy(auth)              \
00160                 ((*((auth)->ah_ops->ah_destroy))(auth))
00161 
00162 
00163 extern struct opaque_auth _null_auth;
00164 
00165 
00166 /*
00167  * These are the various implementations of client side authenticators.
00168  */
00169 
00170 /*
00171  * Unix style authentication
00172  * AUTH *authunix_create(machname, uid, gid, len, aup_gids)
00173  *      char *machname;
00174  *      int uid;
00175  *      int gid;
00176  *      int len;
00177  *      int *aup_gids;
00178  */
00179 __BEGIN_DECLS
00180 struct sockaddr_in;
00181 extern AUTH *authunix_create            __P((char *, int, int, int, int *));
00182 extern AUTH *authunix_create_default    __P((void));
00183 extern AUTH *authnone_create            __P((void));
00184 extern AUTH *authdes_create             __P((char *, u_int,
00185                                             struct sockaddr_in *, des_block *));
00186 __END_DECLS
00187 
00188 #define AUTH_NONE       0               /* no authentication */
00189 #define AUTH_NULL       0               /* backward compatibility */
00190 #define AUTH_UNIX       1               /* unix style (uid, gids) */
00191 #define AUTH_SHORT      2               /* short hand unix style */
00192 #define AUTH_DES        3               /* des style (encrypted timestamps) */
00193 
00194 #endif /* !_RPC_AUTH_H */

Generated on Sun May 14 14:51:20 2006 by  doxygen 1.4.2