auth.h 6.5 KB

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