home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / utilities / utilss / sockets / include / rpc / h / auth < prev    next >
Encoding:
Text File  |  1995-01-11  |  5.8 KB  |  180 lines

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