home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 8.ddi / usr / include / rpc / auth.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  5.2 KB  |  196 lines

  1. /*    Copyright (c) 1990 UNIX System Laboratories, Inc.    */
  2. /*    Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T    */
  3. /*      All Rights Reserved      */
  4.  
  5. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF         */
  6. /*    UNIX System Laboratories, Inc.                         */
  7. /*    The copyright notice above does not evidence any       */
  8. /*    actual or intended publication of such source code.    */
  9.  
  10. #ident    "@(#)/usr/include/rpc/auth.h.sl 1.1 4.0 12/08/90 55662 AT&T-USL"
  11.  
  12. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  13. *    PROPRIETARY NOTICE (Combined)
  14. *
  15. * This source code is unpublished proprietary information
  16. * constituting, or derived under license from AT&T's UNIX(r) System V.
  17. * In addition, portions of such source code were derived from Berkeley
  18. * 4.3 BSD under license from the Regents of the University of
  19. * California.
  20. *
  21. *
  22. *
  23. *    Copyright Notice 
  24. *
  25. * Notice of copyright on this source code product does not indicate 
  26. *  publication.
  27. *
  28. *    (c) 1986,1987,1988.1989  Sun Microsystems, Inc
  29. *    (c) 1983,1984,1985,1986,1987,1988,1989  AT&T.
  30. *          All rights reserved.
  31. */ 
  32.  
  33. /*
  34.  * auth.h, Authentication interface.
  35.  *
  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".
  39.  */
  40. #ifndef _RPC_AUTH_H
  41. #define _RPC_AUTH_H
  42.  
  43. #define MAX_AUTH_BYTES    400
  44. #define MAXNETNAMELEN    255    /* maximum length of network user's name */
  45.  
  46. /*
  47.  * Status returned from authentication check
  48.  */
  49. enum auth_stat {
  50.     AUTH_OK=0,
  51.     /*
  52.      * failed at remote end
  53.      */
  54.     AUTH_BADCRED=1,            /* bogus credentials (seal broken) */
  55.     AUTH_REJECTEDCRED=2,        /* client should begin new session */
  56.     AUTH_BADVERF=3,            /* bogus verifier (seal broken) */
  57.     AUTH_REJECTEDVERF=4,        /* verifier expired or was replayed */
  58.     AUTH_TOOWEAK=5,            /* rejected due to security reasons */
  59.     /*
  60.      * failed locally
  61.     */
  62.     AUTH_INVALIDRESP=6,        /* bogus response verifier */
  63.     AUTH_FAILED=7            /* some unknown reason */
  64. };
  65.  
  66. #if (mc68000 || sparc || vax || i386 || u3b2)
  67. typedef u_long u_int32;    /* 32-bit unsigned integers */
  68. #endif
  69.  
  70. union des_block {
  71.     struct {
  72.         u_int32 high;
  73.         u_int32 low;
  74.     } key;
  75.     char c[8];
  76. };
  77. typedef union des_block des_block;
  78. extern bool_t xdr_des_block();
  79.  
  80. /*
  81.  * Authentication info. Opaque to client.
  82.  */
  83. struct opaque_auth {
  84.     enum_t    oa_flavor;        /* flavor of auth */
  85.     caddr_t    oa_base;        /* address of more auth stuff */
  86.     u_int    oa_length;        /* not to exceed MAX_AUTH_BYTES */
  87. };
  88.  
  89.  
  90. /*
  91.  * Auth handle, interface to client side authenticators.
  92.  */
  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 varifier */
  101.         int    (*ah_refresh)();    /* refresh credentials */
  102.         void    (*ah_destroy)();    /* destroy this structure */
  103.     } *ah_ops;
  104.     caddr_t ah_private;
  105. } AUTH;
  106.  
  107.  
  108. /*
  109.  * Authentication ops.
  110.  * The ops and the auth handle provide the interface to the authenticators.
  111.  *
  112.  * AUTH    *auth;
  113.  * XDR    *xdrs;
  114.  * struct opaque_auth verf;
  115.  */
  116. #define AUTH_NEXTVERF(auth)        \
  117.         ((*((auth)->ah_ops->ah_nextverf))(auth))
  118. #define auth_nextverf(auth)        \
  119.         ((*((auth)->ah_ops->ah_nextverf))(auth))
  120.  
  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))
  125.  
  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))
  130.  
  131. #define AUTH_REFRESH(auth)        \
  132.         ((*((auth)->ah_ops->ah_refresh))(auth))
  133. #define auth_refresh(auth)        \
  134.         ((*((auth)->ah_ops->ah_refresh))(auth))
  135.  
  136. #define AUTH_DESTROY(auth)        \
  137.         ((*((auth)->ah_ops->ah_destroy))(auth))
  138. #define auth_destroy(auth)        \
  139.         ((*((auth)->ah_ops->ah_destroy))(auth))
  140.  
  141.  
  142. extern struct opaque_auth _null_auth;
  143.  
  144.  
  145. /*
  146.  * These are the various implementations of client side authenticators.
  147.  */
  148.  
  149. /*
  150.  * System style authentication
  151.  * AUTH *authsys_create(machname, uid, gid, len, aup_gids)
  152.  *    char *machname;
  153.  *    uid_t uid;
  154.  *    gid_t gid;
  155.  *    int len;
  156.  *    gid_t *aup_gids;
  157.  */
  158. #ifdef _KERNEL
  159. extern AUTH *authkern_create();        /* takes no parameters */
  160. #else
  161. extern AUTH *authsys_create();
  162. extern AUTH *authsys_create_default();    /* takes no parameters */
  163. extern AUTH *authnone_create();        /* takes no parameters */
  164.  
  165. /* Will get obsolete in near future */
  166. #define authunix_create(machname, uid, gid, len, aup_gids) \
  167.     authsys_create(machname, uid, gid, len, aup_gids)
  168. #define authunix_create_default() authsys_create_default()
  169.  
  170. #endif
  171.  
  172. /*
  173.  * DES style authentication
  174.  * AUTH *authdes_seccreate(servername, window, timehost, ckey)
  175.  *    char *servername;        - network name of server
  176.  *    u_int window;            - time to live
  177.  *    char *timehost;            - optional hostname to sync with
  178.  *    des_block *ckey;        - optional conversation key to use
  179.  */
  180. /* Will get obsolete in near future */
  181. #ifdef _KERNEL
  182. extern int authdes_create();
  183. #else
  184. extern AUTH *authdes_create();
  185. #endif
  186. extern AUTH *authdes_seccreate();
  187.  
  188. #define AUTH_NONE    0        /* no authentication */
  189. #define    AUTH_NULL    0        /* backward compatibility */
  190. #define    AUTH_SYS    1        /* unix style (uid, gids) */
  191. #define AUTH_UNIX    AUTH_SYS
  192. #define    AUTH_SHORT    2        /* short hand unix style */
  193. #define AUTH_DES    3        /* des style (encrypted timestamps) */
  194.  
  195. #endif /* !_RPC_AUTH_H */
  196.