1 /* @(#)auth.h 2.3 88/08/07 4.0 RPCSRC; from 1.17 88/02/08 SMI */
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.
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.
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.
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.
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.
26 * Sun Microsystems, Inc.
28 * Mountain View, California 94043
32 * auth.h, Authentication interface.
34 * Copyright (C) 1984, Sun Microsystems, Inc.
36 * The data structures are completely opaque to the client. The client
37 * is required to pass a AUTH * to routines that create rpc
49 #define MAX_AUTH_BYTES 400
50 #define MAXNETNAMELEN 255 /* maximum length of network user's name */
53 * Status returned from authentication check
58 * failed at remote end
60 AUTH_BADCRED
=1, /* bogus credentials (seal broken) */
61 AUTH_REJECTEDCRED
=2, /* client should begin new session */
62 AUTH_BADVERF
=3, /* bogus verifier (seal broken) */
63 AUTH_REJECTEDVERF
=4, /* verifier expired or was replayed */
64 AUTH_TOOWEAK
=5, /* rejected due to security reasons */
68 AUTH_INVALIDRESP
=6, /* bogus response verifier */
69 AUTH_FAILED
=7 /* some unknown reason */
79 typedef union des_block des_block
;
80 extern bool_t
xdr_des_block (XDR
*__xdrs
, des_block
*__blkp
) __THROW
;
83 * Authentication info. Opaque to client.
86 enum_t oa_flavor
; /* flavor of auth */
87 caddr_t oa_base
; /* address of more auth stuff */
88 u_int oa_length
; /* not to exceed MAX_AUTH_BYTES */
92 * Auth handle, interface to client side authenticators.
94 typedef struct AUTH AUTH
;
96 struct opaque_auth ah_cred
;
97 struct opaque_auth ah_verf
;
98 union des_block ah_key
;
99 /* not sure whether non-const-ness is a part of the spec... if it is,
100 * enclose "const" in #ifdef _LIBC / #endif
101 * to make it effective only for libc compile */
104 void (*ah_nextverf
) (AUTH
*);
105 int (*ah_marshal
) (AUTH
*, XDR
*); /* nextverf & serialize */
106 int (*ah_validate
) (AUTH
*, struct opaque_auth
*);
107 /* validate verifier */
108 int (*ah_refresh
) (AUTH
*); /* refresh credentials */
109 void (*ah_destroy
) (AUTH
*); /* destroy this structure */
116 * Authentication ops.
117 * The ops and the auth handle provide the interface to the authenticators.
121 * struct opaque_auth verf;
123 #define AUTH_NEXTVERF(auth) \
124 ((*((auth)->ah_ops->ah_nextverf))(auth))
125 #define auth_nextverf(auth) \
126 ((*((auth)->ah_ops->ah_nextverf))(auth))
128 #define AUTH_MARSHALL(auth, xdrs) \
129 ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
130 #define auth_marshall(auth, xdrs) \
131 ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
133 #define AUTH_VALIDATE(auth, verfp) \
134 ((*((auth)->ah_ops->ah_validate))((auth), verfp))
135 #define auth_validate(auth, verfp) \
136 ((*((auth)->ah_ops->ah_validate))((auth), verfp))
138 #define AUTH_REFRESH(auth) \
139 ((*((auth)->ah_ops->ah_refresh))(auth))
140 #define auth_refresh(auth) \
141 ((*((auth)->ah_ops->ah_refresh))(auth))
143 #define AUTH_DESTROY(auth) \
144 ((*((auth)->ah_ops->ah_destroy))(auth))
145 #define auth_destroy(auth) \
146 ((*((auth)->ah_ops->ah_destroy))(auth))
149 extern struct opaque_auth _null_auth
;
153 * These are the various implementations of client side authenticators.
157 * Unix style authentication
158 * AUTH *authunix_create(machname, uid, gid, len, aup_gids)
165 extern AUTH
*authunix_create (char *__machname
, __uid_t __uid
, __gid_t __gid
,
166 int __len
, __gid_t
*__aup_gids
);
167 libc_hidden_proto(authunix_create
)
168 extern AUTH
*authunix_create_default (void);
169 libc_hidden_proto(authunix_create_default
)
170 extern AUTH
*authnone_create (void) __THROW
;
171 libc_hidden_proto(authnone_create
)
173 extern AUTH
*authdes_create (const char *__servername
, u_int __window
,
174 struct sockaddr
*__syncaddr
, des_block
*__ckey
)
176 extern AUTH
*authdes_pk_create (const char *, netobj
*, u_int
,
177 struct sockaddr
*, des_block
*) __THROW
;
181 #define AUTH_NONE 0 /* no authentication */
182 #define AUTH_NULL 0 /* backward compatibility */
183 #define AUTH_SYS 1 /* unix style (uid, gids) */
184 #define AUTH_UNIX AUTH_SYS
185 #define AUTH_SHORT 2 /* short hand unix style */
186 #define AUTH_DES 3 /* des style (encrypted timestamps) */
187 #define AUTH_DH AUTH_DES /* Diffie-Hellman (this is DES) */
188 #define AUTH_KERB 4 /* kerberos style */
192 * Netname manipulating functions
195 extern int getnetname (char *) __THROW
;
196 extern int host2netname (char *, const char *, const char *) __THROW
;
197 extern int user2netname (char *, const uid_t
, const char *) __THROW
;
198 extern int netname2user (const char *, uid_t
*, gid_t
*, int *, gid_t
*)
200 extern int netname2host (const char *, char *, const int) __THROW
;
204 * These routines interface to the keyserv daemon
207 extern int key_decryptsession (char *, des_block
*);
208 extern int key_decryptsession_pk (char *, netobj
*, des_block
*);
209 extern int key_encryptsession (char *, des_block
*);
210 extern int key_encryptsession_pk (char *, netobj
*, des_block
*);
211 extern int key_gendes (des_block
*);
212 extern int key_setsecret (char *);
213 extern int key_secretkey_is_set (void);
214 extern int key_get_conv (char *, des_block
*);
218 * XDR an opaque authentication struct.
220 extern bool_t
xdr_opaque_auth (XDR
*, struct opaque_auth
*) __THROW
;
221 libc_hidden_proto(xdr_opaque_auth
)
225 #endif /* rpc/auth.h */