Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4680 | right-hear | 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 | /* |
||
32 | * auth.h, Authentication interface. |
||
33 | * |
||
34 | * Copyright (C) 1984, Sun Microsystems, Inc. |
||
35 | * |
||
36 | * The data structures are completely opaque to the client. The client |
||
37 | * is required to pass a AUTH * to routines that create rpc |
||
38 | * "sessions". |
||
39 | */ |
||
40 | |||
41 | #ifndef _RPC_AUTH_H |
||
42 | |||
43 | #define _RPC_AUTH_H 1 |
||
44 | #include |
||
45 | #include |
||
46 | #include |
||
47 | |||
48 | __BEGIN_DECLS |
||
49 | |||
50 | #define MAX_AUTH_BYTES 400 |
||
51 | #define MAXNETNAMELEN 255 /* maximum length of network user's name */ |
||
52 | |||
53 | /* |
||
54 | * Status returned from authentication check |
||
55 | */ |
||
56 | enum auth_stat { |
||
57 | AUTH_OK=0, |
||
58 | /* |
||
59 | * failed at remote end |
||
60 | */ |
||
61 | AUTH_BADCRED=1, /* bogus credentials (seal broken) */ |
||
62 | AUTH_REJECTEDCRED=2, /* client should begin new session */ |
||
63 | AUTH_BADVERF=3, /* bogus verifier (seal broken) */ |
||
64 | AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */ |
||
65 | AUTH_TOOWEAK=5, /* rejected due to security reasons */ |
||
66 | /* |
||
67 | * failed locally |
||
68 | */ |
||
69 | AUTH_INVALIDRESP=6, /* bogus response verifier */ |
||
70 | AUTH_FAILED=7 /* some unknown reason */ |
||
71 | }; |
||
72 | |||
73 | union des_block { |
||
74 | struct { |
||
75 | uint32_t high; |
||
76 | uint32_t low; |
||
77 | } key; |
||
78 | char c[8]; |
||
79 | }; |
||
80 | typedef union des_block des_block; |
||
81 | extern bool_t xdr_des_block (XDR *__xdrs, des_block *__blkp) __THROW; |
||
82 | |||
83 | /* |
||
84 | * Authentication info. Opaque to client. |
||
85 | */ |
||
86 | struct opaque_auth { |
||
87 | enum_t oa_flavor; /* flavor of auth */ |
||
88 | char* oa_base; /* address of more auth stuff */ |
||
89 | unsigned int oa_length; /* not to exceed MAX_AUTH_BYTES */ |
||
90 | }; |
||
91 | |||
92 | /* |
||
93 | * Auth handle, interface to client side authenticators. |
||
94 | */ |
||
95 | typedef struct AUTH AUTH; |
||
96 | struct AUTH { |
||
97 | struct opaque_auth ah_cred; |
||
98 | struct opaque_auth ah_verf; |
||
99 | union des_block ah_key; |
||
100 | struct auth_ops { |
||
101 | void (*ah_nextverf) (AUTH *); |
||
102 | int (*ah_marshal) (AUTH *, XDR *); /* nextverf & serialize */ |
||
103 | int (*ah_validate) (AUTH *, struct opaque_auth *); |
||
104 | /* validate verifier */ |
||
105 | int (*ah_refresh) (AUTH *); /* refresh credentials */ |
||
106 | void (*ah_destroy) (AUTH *); /* destroy this structure */ |
||
107 | } *ah_ops; |
||
108 | char* ah_private; |
||
109 | }; |
||
110 | |||
111 | |||
112 | /* |
||
113 | * Authentication ops. |
||
114 | * The ops and the auth handle provide the interface to the authenticators. |
||
115 | * |
||
116 | * AUTH *auth; |
||
117 | * XDR *xdrs; |
||
118 | * struct opaque_auth verf; |
||
119 | */ |
||
120 | #define AUTH_NEXTVERF(auth) \ |
||
121 | ((*((auth)->ah_ops->ah_nextverf))(auth)) |
||
122 | #define auth_nextverf(auth) \ |
||
123 | ((*((auth)->ah_ops->ah_nextverf))(auth)) |
||
124 | |||
125 | #define AUTH_MARSHALL(auth, xdrs) \ |
||
126 | ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) |
||
127 | #define auth_marshall(auth, xdrs) \ |
||
128 | ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) |
||
129 | |||
130 | #define AUTH_VALIDATE(auth, verfp) \ |
||
131 | ((*((auth)->ah_ops->ah_validate))((auth), verfp)) |
||
132 | #define auth_validate(auth, verfp) \ |
||
133 | ((*((auth)->ah_ops->ah_validate))((auth), verfp)) |
||
134 | |||
135 | #define AUTH_REFRESH(auth) \ |
||
136 | ((*((auth)->ah_ops->ah_refresh))(auth)) |
||
137 | #define auth_refresh(auth) \ |
||
138 | ((*((auth)->ah_ops->ah_refresh))(auth)) |
||
139 | |||
140 | #define AUTH_DESTROY(auth) \ |
||
141 | ((*((auth)->ah_ops->ah_destroy))(auth)) |
||
142 | #define auth_destroy(auth) \ |
||
143 | ((*((auth)->ah_ops->ah_destroy))(auth)) |
||
144 | |||
145 | |||
146 | extern struct opaque_auth _null_auth; |
||
147 | |||
148 | |||
149 | /* |
||
150 | * These are the various implementations of client side authenticators. |
||
151 | */ |
||
152 | |||
153 | /* |
||
154 | * Unix style authentication |
||
155 | * AUTH *authunix_create(machname, uid, gid, len, aup_gids) |
||
156 | * char *machname; |
||
157 | * int uid; |
||
158 | * int gid; |
||
159 | * int len; |
||
160 | * int *aup_gids; |
||
161 | */ |
||
162 | extern AUTH *authunix_create (char *__machname,uid_t __uid, gid_t __gid, |
||
163 | int __len, gid_t *__aup_gids) __THROW; |
||
164 | extern AUTH *authunix_create_default (void) __THROW; |
||
165 | extern AUTH *authnone_create (void) __THROW; |
||
166 | extern AUTH *authdes_create (const char *__servername, unsigned int __window, |
||
167 | struct sockaddr *__syncaddr, des_block *__ckey) |
||
168 | __THROW; |
||
169 | extern AUTH *authdes_pk_create (const char *, netobj *, unsigned int, |
||
170 | struct sockaddr *, des_block *) __THROW; |
||
171 | |||
172 | |||
173 | #define AUTH_NONE 0 /* no authentication */ |
||
174 | #define AUTH_NULL 0 /* backward compatibility */ |
||
175 | #define AUTH_SYS 1 /* unix style (uid, gids) */ |
||
176 | #define AUTH_UNIX AUTH_SYS |
||
177 | #define AUTH_SHORT 2 /* short hand unix style */ |
||
178 | #define AUTH_DES 3 /* des style (encrypted timestamps) */ |
||
179 | #define AUTH_DH AUTH_DES /* Diffie-Hellman (this is DES) */ |
||
180 | #define AUTH_KERB 4 /* kerberos style */ |
||
181 | |||
182 | /* |
||
183 | * Netname manipulating functions |
||
184 | * |
||
185 | */ |
||
186 | extern int getnetname (char *) __THROW; |
||
187 | extern int host2netname (char *, const char *, const char *) __THROW; |
||
188 | extern int user2netname (char *, const uid_t, const char *) __THROW; |
||
189 | extern int netname2user (const char *, uid_t *, gid_t *, int *, gid_t *) |
||
190 | __THROW; |
||
191 | extern int netname2host (const char *, char *, const int) __THROW; |
||
192 | |||
193 | /* |
||
194 | * |
||
195 | * These routines interface to the keyserv daemon |
||
196 | * |
||
197 | */ |
||
198 | extern int key_decryptsession (char *, des_block *) __THROW; |
||
199 | extern int key_decryptsession_pk (char *, netobj *, des_block *) __THROW; |
||
200 | extern int key_encryptsession (char *, des_block *) __THROW; |
||
201 | extern int key_encryptsession_pk (char *, netobj *, des_block *) __THROW; |
||
202 | extern int key_gendes (des_block *) __THROW; |
||
203 | extern int key_setsecret (char *) __THROW; |
||
204 | extern int key_secretkey_is_set (void) __THROW; |
||
205 | extern int key_get_conv (char *, des_block *) __THROW; |
||
206 | |||
207 | /* |
||
208 | * XDR an opaque authentication struct. |
||
209 | */ |
||
210 | extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *) __THROW; |
||
211 | |||
212 | __END_DECLS |
||
213 | |||
214 | #endif /* rpc/auth.h */ |