Back to index

glibc  2.9
auth.h
Go to the documentation of this file.
00001 /* @(#)auth.h 2.3 88/08/07 4.0 RPCSRC; from 1.17 88/02/08 SMI */
00002 /*
00003  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
00004  * unrestricted use provided that this legend is included on all tape
00005  * media and as a part of the software program in whole or part.  Users
00006  * may copy or modify Sun RPC without charge, but are not authorized
00007  * to license or distribute it to anyone else except as part of a product or
00008  * program developed by the user.
00009  *
00010  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
00011  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
00012  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
00013  *
00014  * Sun RPC is provided with no support and without any obligation on the
00015  * part of Sun Microsystems, Inc. to assist in its use, correction,
00016  * modification or enhancement.
00017  *
00018  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
00019  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
00020  * OR ANY PART THEREOF.
00021  *
00022  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
00023  * or profits or other special, indirect and consequential damages, even if
00024  * Sun has been advised of the possibility of such damages.
00025  *
00026  * Sun Microsystems, Inc.
00027  * 2550 Garcia Avenue
00028  * Mountain View, California  94043
00029  */
00030 
00031 /*
00032  * auth.h, Authentication interface.
00033  *
00034  * Copyright (C) 1984, Sun Microsystems, Inc.
00035  *
00036  * The data structures are completely opaque to the client.  The client
00037  * is required to pass a AUTH * to routines that create rpc
00038  * "sessions".
00039  */
00040 
00041 #ifndef _RPC_AUTH_H
00042 
00043 #define _RPC_AUTH_H  1
00044 #include <features.h>
00045 #include <rpc/xdr.h>
00046 
00047 __BEGIN_DECLS
00048 
00049 #define MAX_AUTH_BYTES      400
00050 #define MAXNETNAMELEN       255    /* maximum length of network user's name */
00051 
00052 /*
00053  * Status returned from authentication check
00054  */
00055 enum auth_stat {
00056        AUTH_OK=0,
00057        /*
00058         * failed at remote end
00059         */
00060        AUTH_BADCRED=1,                    /* bogus credentials (seal broken) */
00061        AUTH_REJECTEDCRED=2,        /* client should begin new session */
00062        AUTH_BADVERF=3,                    /* bogus verifier (seal broken) */
00063        AUTH_REJECTEDVERF=4,        /* verifier expired or was replayed */
00064        AUTH_TOOWEAK=5,                    /* rejected due to security reasons */
00065        /*
00066         * failed locally
00067        */
00068        AUTH_INVALIDRESP=6,         /* bogus response verifier */
00069        AUTH_FAILED=7               /* some unknown reason */
00070 };
00071 
00072 union des_block {
00073        struct {
00074               u_int32_t high;
00075               u_int32_t low;
00076        } key;
00077        char c[8];
00078 };
00079 typedef union des_block des_block;
00080 extern bool_t xdr_des_block (XDR *__xdrs, des_block *__blkp) __THROW;
00081 
00082 /*
00083  * Authentication info.  Opaque to client.
00084  */
00085 struct opaque_auth {
00086        enum_t oa_flavor;           /* flavor of auth */
00087        caddr_t       oa_base;             /* address of more auth stuff */
00088        u_int  oa_length;           /* not to exceed MAX_AUTH_BYTES */
00089 };
00090 
00091 /*
00092  * Auth handle, interface to client side authenticators.
00093  */
00094 typedef struct AUTH AUTH;
00095 struct AUTH {
00096   struct opaque_auth ah_cred;
00097   struct opaque_auth ah_verf;
00098   union des_block ah_key;
00099   struct auth_ops {
00100     void (*ah_nextverf) (AUTH *);
00101     int  (*ah_marshal) (AUTH *, XDR *);          /* nextverf & serialize */
00102     int  (*ah_validate) (AUTH *, struct opaque_auth *);
00103                                           /* validate verifier */
00104     int  (*ah_refresh) (AUTH *);          /* refresh credentials */
00105     void (*ah_destroy) (AUTH *);          /* destroy this structure */
00106   } *ah_ops;
00107   caddr_t ah_private;
00108 };
00109 
00110 
00111 /*
00112  * Authentication ops.
00113  * The ops and the auth handle provide the interface to the authenticators.
00114  *
00115  * AUTH       *auth;
00116  * XDR *xdrs;
00117  * struct opaque_auth verf;
00118  */
00119 #define AUTH_NEXTVERF(auth)        \
00120               ((*((auth)->ah_ops->ah_nextverf))(auth))
00121 #define auth_nextverf(auth)        \
00122               ((*((auth)->ah_ops->ah_nextverf))(auth))
00123 
00124 #define AUTH_MARSHALL(auth, xdrs)  \
00125               ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
00126 #define auth_marshall(auth, xdrs)  \
00127               ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
00128 
00129 #define AUTH_VALIDATE(auth, verfp) \
00130               ((*((auth)->ah_ops->ah_validate))((auth), verfp))
00131 #define auth_validate(auth, verfp) \
00132               ((*((auth)->ah_ops->ah_validate))((auth), verfp))
00133 
00134 #define AUTH_REFRESH(auth)         \
00135               ((*((auth)->ah_ops->ah_refresh))(auth))
00136 #define auth_refresh(auth)         \
00137               ((*((auth)->ah_ops->ah_refresh))(auth))
00138 
00139 #define AUTH_DESTROY(auth)         \
00140               ((*((auth)->ah_ops->ah_destroy))(auth))
00141 #define auth_destroy(auth)         \
00142               ((*((auth)->ah_ops->ah_destroy))(auth))
00143 
00144 
00145 extern struct opaque_auth _null_auth;
00146 
00147 
00148 /*
00149  * These are the various implementations of client side authenticators.
00150  */
00151 
00152 /*
00153  * Unix style authentication
00154  * AUTH *authunix_create(machname, uid, gid, len, aup_gids)
00155  *     char *machname;
00156  *     int uid;
00157  *     int gid;
00158  *     int len;
00159  *     int *aup_gids;
00160  */
00161 extern AUTH *authunix_create (char *__machname, __uid_t __uid, __gid_t __gid,
00162                            int __len, __gid_t *__aup_gids);
00163 extern AUTH *authunix_create_default (void);
00164 extern AUTH *authnone_create (void) __THROW;
00165 extern AUTH *authdes_create (const char *__servername, u_int __window,
00166                           struct sockaddr *__syncaddr, des_block *__ckey)
00167      __THROW;
00168 extern AUTH *authdes_pk_create (const char *, netobj *, u_int,
00169                             struct sockaddr *, des_block *) __THROW;
00170 
00171 
00172 #define AUTH_NONE    0             /* no authentication */
00173 #define       AUTH_NULL     0             /* backward compatibility */
00174 #define       AUTH_SYS      1             /* unix style (uid, gids) */
00175 #define       AUTH_UNIX     AUTH_SYS
00176 #define       AUTH_SHORT    2             /* short hand unix style */
00177 #define AUTH_DES     3             /* des style (encrypted timestamps) */
00178 #define AUTH_DH             AUTH_DES      /* Diffie-Hellman (this is DES) */
00179 #define AUTH_KERB       4               /* kerberos style */
00180 
00181 /*
00182  *  Netname manipulating functions
00183  *
00184  */
00185 extern int getnetname (char *) __THROW;
00186 extern int host2netname (char *, __const char *, __const char *) __THROW;
00187 extern int user2netname (char *, __const uid_t, __const char *) __THROW;
00188 extern int netname2user (__const char *, uid_t *, gid_t *, int *, gid_t *)
00189      __THROW;
00190 extern int netname2host (__const char *, char *, __const int) __THROW;
00191 
00192 /*
00193  *
00194  * These routines interface to the keyserv daemon
00195  *
00196  */
00197 extern int key_decryptsession (char *, des_block *);
00198 extern int key_decryptsession_pk (char *, netobj *, des_block *);
00199 extern int key_encryptsession (char *, des_block *);
00200 extern int key_encryptsession_pk (char *, netobj *, des_block *);
00201 extern int key_gendes (des_block *);
00202 extern int key_setsecret (char *);
00203 extern int key_secretkey_is_set (void);
00204 extern int key_get_conv (char *, des_block *);
00205 
00206 /*
00207  * XDR an opaque authentication struct.
00208  */
00209 extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *) __THROW;
00210 
00211 __END_DECLS
00212 
00213 #endif /* rpc/auth.h */