home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / NextDeveloper / Headers / bsd / rpc / auth.h < prev    next >
Text File  |  1992-03-04  |  4KB  |  148 lines

  1. /*    @(#)auth.h    1.2 88/08/02 4.0NFSSRC SMI    */
  2.  
  3. /* 
  4.  * Copyright (c) 1988 by Sun Microsystems, Inc.
  5.  *  1.17 88/02/08 SMI  
  6.  */
  7.  
  8.  
  9. /*
  10.  * auth.h, Authentication interface.
  11.  *
  12.  * Copyright (C) 1984, Sun Microsystems, Inc.
  13.  *
  14.  * The data structures are completely opaque to the client.  The client
  15.  * is reqW)    d to pass a AUTH * to routines that create rpc
  16.  * "sessions".
  17.  */
  18.  
  19.  
  20. #import    <bsd/rpc/machine/auth.h>
  21.  
  22. #define MAX_AUTH_BYTES    400
  23. #define MAXNETNAMELEN    255    /* maximum length of network user's name */
  24.  
  25. /*
  26.  * Status returned from authentication check
  27.  */
  28. enum auth_stat {
  29.     AUTH_OK=0,
  30.     /*
  31.      * failed at remote end
  32.      */
  33.     AUTH_BADCRED=1,            /* bogus credentials (seal broken) */
  34.     AUTH_REJECTEDCRED=2,        /* client should begin new session */
  35.     AUTH_BADVERF=3,            /* bogus verifier (seal broken) */
  36.     AUTH_REJECTEDVERF=4,        /* verifier expired or was replayed */
  37.     AUTH_TOOWEAK=5,            /* rejected due to security reasons */
  38.     /*
  39.      * failed locally
  40.     */
  41.     AUTH_INVALIDRESP=6,        /* bogus response verifier */
  42.     AUTH_FAILED=7            /* some unknown reason */
  43. };
  44.  
  45. union des_block {
  46.     struct {
  47.         u_int32 high;
  48.         u_int32 low;
  49.     } key;
  50.     char c[8];
  51. };
  52. typedef union des_block des_block;
  53. extern bool_t xdr_des_block();
  54.  
  55. /*
  56.  * Authentication info.  Opaque to client.
  57.  */
  58. struct opaque_auth {
  59.     enum_t    oa_flavor;        /* flavor of auth */
  60.     caddr_t    oa_base;        /* address of more auth stuff */
  61.     u_int    oa_length;        /* not to exceed MAX_AUTH_BYTES */
  62. };
  63.  
  64.  
  65. /*
  66.  * Auth handle, interface to client side authenticators.
  67.  */
  68. typedef struct {
  69.     struct    opaque_auth    ah_cred;
  70.     struct    opaque_auth    ah_verf;
  71. #ifndef __NeXT__
  72.     union    des_block    ah_key;
  73. #endif  __NeXT__
  74.     struct auth_ops {
  75.         void    (*ah_nextverf)();
  76.         int    (*ah_marshal)();    /* nextverf & serialize */
  77.         int    (*ah_validate)();    /* validate varifier */
  78.         int    (*ah_refresh)();    /* refresh credentials */
  79.         void    (*ah_destroy)();    /* destroy this structure */
  80.     } *ah_ops;
  81.     caddr_t ah_private;
  82. #ifdef __NeXT__
  83.     union    des_block    ah_key;
  84. #endif __NeXT__
  85. } AUTH;
  86.  
  87.  
  88. /*
  89.  * Authentication ops.
  90.  * The ops and the auth handle provide the interface to the authenticators.
  91.  *
  92.  * AUTH    *auth;
  93.  * XDR    *xdrs;
  94.  * struct opaque_auth verf;
  95.  */
  96. #define AUTH_NEXTVERF(auth)        \
  97.         ((*((auth)->ah_ops->ah_nextverf))(auth))
  98. #define auth_nextverf(auth)        \
  99.         ((*((auth)->ah_ops->ah_nextverf))(auth))
  100.  
  101. #define AUTH_MARSHALL(auth, xdrs)    \
  102.         ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
  103. #define auth_marshall(auth, xdrs)    \
  104.         ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
  105.  
  106. #define AUTH_VALIDATE(auth, verfp)    \
  107.         ((*((auth)->ah_ops->ah_validate))((auth), verfp))
  108. #define auth_validate(auth, verfp)    \
  109.         ((*((auth)->ah_ops->ah_validate))((auth), verfp))
  110.  
  111. #define AUTH_REFRESH(auth)        \
  112.         ((*((aW)->ah_ops->ah_refresh))(auth))
  113. #define auth_refresh(auth)        \
  114.         ((*((auth)->ah_ops->ah_refresh))(auth))
  115.  
  116. #define AUTH_DESTROY(auth)        \
  117.         ((*((auth)->ah_ops->ah_destroy))(auth))
  118. #define auth_destroy(auth)        \
  119.         ((*((auth)->ah_ops->ah_destroy))(auth))
  120.  
  121.  
  122. extern struct opaque_auth _null_auth;
  123.  
  124.  
  125. /*
  126.  * These are the various implementations of client side authenticators.
  127.  */
  128.  
  129. /*
  130.  * Unix style authentication
  131.  * AUTH *authunix_create(machname, uid, gid, len, aup_gids)
  132.  *    char *machname;
  133.  *    int uid;
  134.  *    int gid;
  135.  *    int len;
  136.  *    int *aup_gids;
  137.  */
  138. extern AUTH *authunix_create();
  139. extern AUTH *authunix_create_default();    /* takes no parameters */
  140. extern AUTH *authnone_create();        /* takes no parameters */
  141. extern AUTH *authdes_create();    
  142.  
  143. #define AUTH_NONE    0        /* no authentication */
  144. #define    AUTH_NULL    0        /* backward compatibility */
  145. #define    AUTH_UNIX    1        /* unix style (uid, gids) */
  146. #define    AUTH_SHORT    2        /* short hand unix style */
  147. #define AUTH_DES    3        /* des style (encrypted timestamps) */
  148.