1dba7a33eSGarrett Wollman /* 2dba7a33eSGarrett Wollman * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 3dba7a33eSGarrett Wollman * unrestricted use provided that this legend is included on all tape 4dba7a33eSGarrett Wollman * media and as a part of the software program in whole or part. Users 5dba7a33eSGarrett Wollman * may copy or modify Sun RPC without charge, but are not authorized 6dba7a33eSGarrett Wollman * to license or distribute it to anyone else except as part of a product or 7dba7a33eSGarrett Wollman * program developed by the user. 8dba7a33eSGarrett Wollman * 9dba7a33eSGarrett Wollman * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 1071d9c781SMike Pritchard * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 11dba7a33eSGarrett Wollman * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 12dba7a33eSGarrett Wollman * 13dba7a33eSGarrett Wollman * Sun RPC is provided with no support and without any obligation on the 14dba7a33eSGarrett Wollman * part of Sun Microsystems, Inc. to assist in its use, correction, 15dba7a33eSGarrett Wollman * modification or enhancement. 16dba7a33eSGarrett Wollman * 17dba7a33eSGarrett Wollman * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 18dba7a33eSGarrett Wollman * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 19dba7a33eSGarrett Wollman * OR ANY PART THEREOF. 20dba7a33eSGarrett Wollman * 21dba7a33eSGarrett Wollman * In no event will Sun Microsystems, Inc. be liable for any lost revenue 22dba7a33eSGarrett Wollman * or profits or other special, indirect and consequential damages, even if 23dba7a33eSGarrett Wollman * Sun has been advised of the possibility of such damages. 24dba7a33eSGarrett Wollman * 25dba7a33eSGarrett Wollman * Sun Microsystems, Inc. 26dba7a33eSGarrett Wollman * 2550 Garcia Avenue 27dba7a33eSGarrett Wollman * Mountain View, California 94043 2886b9a9ccSGarrett Wollman * 2986b9a9ccSGarrett Wollman * from: @(#)auth.h 1.17 88/02/08 SMI 3086b9a9ccSGarrett Wollman * from: @(#)auth.h 2.3 88/08/07 4.0 RPCSRC 31f26dae2bSBill Paul * $Id: auth.h,v 1.6 1996/12/30 13:59:37 peter Exp $ 32dba7a33eSGarrett Wollman */ 33dba7a33eSGarrett Wollman 34dba7a33eSGarrett Wollman /* 35dba7a33eSGarrett Wollman * auth.h, Authentication interface. 36dba7a33eSGarrett Wollman * 37dba7a33eSGarrett Wollman * Copyright (C) 1984, Sun Microsystems, Inc. 38dba7a33eSGarrett Wollman * 39dba7a33eSGarrett Wollman * The data structures are completely opaque to the client. The client 40dba7a33eSGarrett Wollman * is required to pass a AUTH * to routines that create rpc 41dba7a33eSGarrett Wollman * "sessions". 42dba7a33eSGarrett Wollman */ 43dba7a33eSGarrett Wollman 4486b9a9ccSGarrett Wollman #ifndef _RPC_AUTH_H 4586b9a9ccSGarrett Wollman #define _RPC_AUTH_H 4686b9a9ccSGarrett Wollman #include <sys/cdefs.h> 47f26dae2bSBill Paul #include <sys/socket.h> 48dba7a33eSGarrett Wollman 49dba7a33eSGarrett Wollman #define MAX_AUTH_BYTES 400 50dba7a33eSGarrett Wollman #define MAXNETNAMELEN 255 /* maximum length of network user's name */ 51dba7a33eSGarrett Wollman 52dba7a33eSGarrett Wollman /* 53dba7a33eSGarrett Wollman * Status returned from authentication check 54dba7a33eSGarrett Wollman */ 55dba7a33eSGarrett Wollman enum auth_stat { 56dba7a33eSGarrett Wollman AUTH_OK=0, 57dba7a33eSGarrett Wollman /* 58dba7a33eSGarrett Wollman * failed at remote end 59dba7a33eSGarrett Wollman */ 60dba7a33eSGarrett Wollman AUTH_BADCRED=1, /* bogus credentials (seal broken) */ 61dba7a33eSGarrett Wollman AUTH_REJECTEDCRED=2, /* client should begin new session */ 62dba7a33eSGarrett Wollman AUTH_BADVERF=3, /* bogus verifier (seal broken) */ 63dba7a33eSGarrett Wollman AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */ 64dba7a33eSGarrett Wollman AUTH_TOOWEAK=5, /* rejected due to security reasons */ 65dba7a33eSGarrett Wollman /* 66dba7a33eSGarrett Wollman * failed locally 67dba7a33eSGarrett Wollman */ 68dba7a33eSGarrett Wollman AUTH_INVALIDRESP=6, /* bogus response verifier */ 69dba7a33eSGarrett Wollman AUTH_FAILED=7 /* some unknown reason */ 70dba7a33eSGarrett Wollman }; 71dba7a33eSGarrett Wollman 72dba7a33eSGarrett Wollman union des_block { 73dba7a33eSGarrett Wollman struct { 74128443c8SJeffrey Hsu u_int32_t high; 75128443c8SJeffrey Hsu u_int32_t low; 76dba7a33eSGarrett Wollman } key; 77dba7a33eSGarrett Wollman char c[8]; 78dba7a33eSGarrett Wollman }; 79dba7a33eSGarrett Wollman typedef union des_block des_block; 8086b9a9ccSGarrett Wollman __BEGIN_DECLS 8186b9a9ccSGarrett Wollman extern bool_t xdr_des_block __P((XDR *, des_block *)); 8286b9a9ccSGarrett Wollman __END_DECLS 83dba7a33eSGarrett Wollman 84dba7a33eSGarrett Wollman /* 85dba7a33eSGarrett Wollman * Authentication info. Opaque to client. 86dba7a33eSGarrett Wollman */ 87dba7a33eSGarrett Wollman struct opaque_auth { 88dba7a33eSGarrett Wollman enum_t oa_flavor; /* flavor of auth */ 89dba7a33eSGarrett Wollman caddr_t oa_base; /* address of more auth stuff */ 90dba7a33eSGarrett Wollman u_int oa_length; /* not to exceed MAX_AUTH_BYTES */ 91dba7a33eSGarrett Wollman }; 9270de0abfSPeter Wemm __BEGIN_DECLS 9389ee8ac3SBruce Evans bool_t xdr_opaque_auth __P((XDR *xdrs, struct opaque_auth *ap)); 9470de0abfSPeter Wemm __END_DECLS 95dba7a33eSGarrett Wollman 96dba7a33eSGarrett Wollman 97dba7a33eSGarrett Wollman /* 98dba7a33eSGarrett Wollman * Auth handle, interface to client side authenticators. 99dba7a33eSGarrett Wollman */ 10070de0abfSPeter Wemm typedef struct __rpc_auth { 101dba7a33eSGarrett Wollman struct opaque_auth ah_cred; 102dba7a33eSGarrett Wollman struct opaque_auth ah_verf; 103dba7a33eSGarrett Wollman union des_block ah_key; 104dba7a33eSGarrett Wollman struct auth_ops { 10570de0abfSPeter Wemm void (*ah_nextverf) __P((struct __rpc_auth *)); 10670de0abfSPeter Wemm /* nextverf & serialize */ 10770de0abfSPeter Wemm int (*ah_marshal) __P((struct __rpc_auth *, XDR *)); 10870de0abfSPeter Wemm /* validate verifier */ 10970de0abfSPeter Wemm int (*ah_validate) __P((struct __rpc_auth *, 11070de0abfSPeter Wemm struct opaque_auth *)); 11170de0abfSPeter Wemm /* refresh credentials */ 11270de0abfSPeter Wemm int (*ah_refresh) __P((struct __rpc_auth *)); 11370de0abfSPeter Wemm /* destroy this structure */ 11470de0abfSPeter Wemm void (*ah_destroy) __P((struct __rpc_auth *)); 115dba7a33eSGarrett Wollman } *ah_ops; 116dba7a33eSGarrett Wollman caddr_t ah_private; 117dba7a33eSGarrett Wollman } AUTH; 118dba7a33eSGarrett Wollman 119dba7a33eSGarrett Wollman 120dba7a33eSGarrett Wollman /* 121dba7a33eSGarrett Wollman * Authentication ops. 122dba7a33eSGarrett Wollman * The ops and the auth handle provide the interface to the authenticators. 123dba7a33eSGarrett Wollman * 124dba7a33eSGarrett Wollman * AUTH *auth; 125dba7a33eSGarrett Wollman * XDR *xdrs; 126dba7a33eSGarrett Wollman * struct opaque_auth verf; 127dba7a33eSGarrett Wollman */ 128dba7a33eSGarrett Wollman #define AUTH_NEXTVERF(auth) \ 129dba7a33eSGarrett Wollman ((*((auth)->ah_ops->ah_nextverf))(auth)) 130dba7a33eSGarrett Wollman #define auth_nextverf(auth) \ 131dba7a33eSGarrett Wollman ((*((auth)->ah_ops->ah_nextverf))(auth)) 132dba7a33eSGarrett Wollman 133dba7a33eSGarrett Wollman #define AUTH_MARSHALL(auth, xdrs) \ 134dba7a33eSGarrett Wollman ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) 135dba7a33eSGarrett Wollman #define auth_marshall(auth, xdrs) \ 136dba7a33eSGarrett Wollman ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) 137dba7a33eSGarrett Wollman 138dba7a33eSGarrett Wollman #define AUTH_VALIDATE(auth, verfp) \ 139dba7a33eSGarrett Wollman ((*((auth)->ah_ops->ah_validate))((auth), verfp)) 140dba7a33eSGarrett Wollman #define auth_validate(auth, verfp) \ 141dba7a33eSGarrett Wollman ((*((auth)->ah_ops->ah_validate))((auth), verfp)) 142dba7a33eSGarrett Wollman 143dba7a33eSGarrett Wollman #define AUTH_REFRESH(auth) \ 144dba7a33eSGarrett Wollman ((*((auth)->ah_ops->ah_refresh))(auth)) 145dba7a33eSGarrett Wollman #define auth_refresh(auth) \ 146dba7a33eSGarrett Wollman ((*((auth)->ah_ops->ah_refresh))(auth)) 147dba7a33eSGarrett Wollman 148dba7a33eSGarrett Wollman #define AUTH_DESTROY(auth) \ 149dba7a33eSGarrett Wollman ((*((auth)->ah_ops->ah_destroy))(auth)) 150dba7a33eSGarrett Wollman #define auth_destroy(auth) \ 151dba7a33eSGarrett Wollman ((*((auth)->ah_ops->ah_destroy))(auth)) 152dba7a33eSGarrett Wollman 153dba7a33eSGarrett Wollman 154dba7a33eSGarrett Wollman extern struct opaque_auth _null_auth; 155dba7a33eSGarrett Wollman 156dba7a33eSGarrett Wollman /* 157dba7a33eSGarrett Wollman * These are the various implementations of client side authenticators. 158dba7a33eSGarrett Wollman */ 159dba7a33eSGarrett Wollman 160dba7a33eSGarrett Wollman /* 161dba7a33eSGarrett Wollman * Unix style authentication 162dba7a33eSGarrett Wollman * AUTH *authunix_create(machname, uid, gid, len, aup_gids) 163dba7a33eSGarrett Wollman * char *machname; 164dba7a33eSGarrett Wollman * int uid; 165dba7a33eSGarrett Wollman * int gid; 166dba7a33eSGarrett Wollman * int len; 167dba7a33eSGarrett Wollman * int *aup_gids; 168dba7a33eSGarrett Wollman */ 16986b9a9ccSGarrett Wollman __BEGIN_DECLS 17070de0abfSPeter Wemm struct sockaddr_in; 17186b9a9ccSGarrett Wollman extern AUTH *authunix_create __P((char *, int, int, int, int *)); 17286b9a9ccSGarrett Wollman extern AUTH *authunix_create_default __P((void)); 17386b9a9ccSGarrett Wollman extern AUTH *authnone_create __P((void)); 17486b9a9ccSGarrett Wollman __END_DECLS 175dba7a33eSGarrett Wollman 176f26dae2bSBill Paul /* Forward compatibility with TI-RPC */ 177f26dae2bSBill Paul #define authsys_create authunix_create 178f26dae2bSBill Paul #define authsys_create_default authunix_create_default 179f26dae2bSBill Paul 180f26dae2bSBill Paul /* 181f26dae2bSBill Paul * DES style authentication 182f26dae2bSBill Paul * AUTH *authdes_create(servername, window, timehost, ckey) 183f26dae2bSBill Paul * char *servername; - network name of server 184f26dae2bSBill Paul * u_int window; - time to live 185f26dae2bSBill Paul * struct sockaddr *timehost; - optional hostname to sync with 186f26dae2bSBill Paul * des_block *ckey; - optional conversation key to use 187f26dae2bSBill Paul */ 188f26dae2bSBill Paul __BEGIN_DECLS 189f26dae2bSBill Paul extern AUTH *authdes_create __P(( char *, u_int, struct sockaddr *, des_block * )); 190f26dae2bSBill Paul #ifdef NOTYET 191f26dae2bSBill Paul /* 192f26dae2bSBill Paul * TI-RPC supports this call, but it requires the inclusion of 193f26dae2bSBill Paul * NIS+-specific headers which would require the inclusion of other 194f26dae2bSBill Paul * headers which would result in a tangled mess. For now, the NIS+ 195f26dae2bSBill Paul * code prototypes this routine internally. 196f26dae2bSBill Paul */ 197f26dae2bSBill Paul extern AUTH *authdes_pk_create __P(( char *, netobj *, u_int, 198f26dae2bSBill Paul struct sockaddr *, des_block *, 199f26dae2bSBill Paul nis_server * )); 200f26dae2bSBill Paul #endif 201f26dae2bSBill Paul __END_DECLS 202f26dae2bSBill Paul 203f26dae2bSBill Paul /* 204f26dae2bSBill Paul * Netname manipulation routines. 205f26dae2bSBill Paul */ 206f26dae2bSBill Paul __BEGIN_DECLS 207f26dae2bSBill Paul extern int netname2user __P(( char *, uid_t *, gid_t *, int *, gid_t *)); 208f26dae2bSBill Paul extern int netname2host __P(( char *, char *, int )); 209f26dae2bSBill Paul extern int getnetname __P(( char * )); 210f26dae2bSBill Paul extern int user2netname __P(( char *, uid_t, char * )); 211f26dae2bSBill Paul extern int host2netname __P(( char *, char *, char * )); 212f26dae2bSBill Paul extern void passwd2des __P(( char *, char * )); 213f26dae2bSBill Paul __END_DECLS 214f26dae2bSBill Paul 215f26dae2bSBill Paul /* 216f26dae2bSBill Paul * Keyserv interface routines. 217f26dae2bSBill Paul * XXX Should not be here. 218f26dae2bSBill Paul */ 219f26dae2bSBill Paul #ifndef HEXKEYBYTES 220f26dae2bSBill Paul #define HEXKEYBYTES 48 221f26dae2bSBill Paul #endif 222f26dae2bSBill Paul typedef char kbuf[HEXKEYBYTES]; 223f26dae2bSBill Paul typedef char *namestr; 224f26dae2bSBill Paul 225f26dae2bSBill Paul struct netstarg { 226f26dae2bSBill Paul kbuf st_priv_key; 227f26dae2bSBill Paul kbuf st_pub_key; 228f26dae2bSBill Paul namestr st_netname; 229f26dae2bSBill Paul }; 230f26dae2bSBill Paul 231f26dae2bSBill Paul __BEGIN_DECLS 232f26dae2bSBill Paul extern int key_decryptsession __P(( const char *, des_block * )); 233f26dae2bSBill Paul extern int key_decryptsession_pk __P(( char *, netobj *, des_block * )); 234f26dae2bSBill Paul extern int key_encryptsession __P(( const char *, des_block * )); 235f26dae2bSBill Paul extern int key_encryptsession_pk __P(( char *, netobj *, des_block * )); 236f26dae2bSBill Paul extern int key_gendes __P(( des_block * )); 237f26dae2bSBill Paul extern int key_setsecret __P(( const char * )); 238f26dae2bSBill Paul extern int key_secretkey_is_set __P(( void )); 239f26dae2bSBill Paul extern int key_setnet __P(( struct netstarg * )); 240f26dae2bSBill Paul extern int key_get_conv __P(( char *, des_block * )); 241f26dae2bSBill Paul __END_DECLS 242f26dae2bSBill Paul 243f26dae2bSBill Paul /* 244f26dae2bSBill Paul * Publickey routines. 245f26dae2bSBill Paul */ 246f26dae2bSBill Paul __BEGIN_DECLS 247f26dae2bSBill Paul extern int getpublickey __P(( char *, char * )); 248f26dae2bSBill Paul extern int getpublicandprivatekey __P(( char *, char * )); 249f26dae2bSBill Paul extern int getsecretkey __P(( char *, char *, char * )); 250f26dae2bSBill Paul __END_DECLS 251f26dae2bSBill Paul 252f26dae2bSBill Paul 253b6e649bcSPeter Wemm #ifndef AUTH_NONE /* Protect against <login_cap.h> */ 254dba7a33eSGarrett Wollman #define AUTH_NONE 0 /* no authentication */ 25548ea0becSEivind Eklund #endif 256dba7a33eSGarrett Wollman #define AUTH_NULL 0 /* backward compatibility */ 257dba7a33eSGarrett Wollman #define AUTH_UNIX 1 /* unix style (uid, gids) */ 258f26dae2bSBill Paul #define AUTH_SYS 1 /* forward compatibility */ 259dba7a33eSGarrett Wollman #define AUTH_SHORT 2 /* short hand unix style */ 260dba7a33eSGarrett Wollman #define AUTH_DES 3 /* des style (encrypted timestamps) */ 26186b9a9ccSGarrett Wollman 26286b9a9ccSGarrett Wollman #endif /* !_RPC_AUTH_H */ 263