xref: /illumos-gate/usr/src/uts/common/rpc/auth_des.h (revision 08855964b9970604433f7b19dcd71cf5af5e5f14)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
27 /* All Rights Reserved */
28 /*
29  * Portions of this source code were derived from Berkeley
30  * 4.3 BSD under license from the Regents of the University of
31  * California.
32  */
33 
34 #ifndef	_RPC_AUTH_DES_H
35 #define	_RPC_AUTH_DES_H
36 
37 /*
38  * auth_des.h, Protocol for DES style authentication for RPC
39  *
40  */
41 
42 #include <rpc/auth.h>
43 #ifdef _KERNEL
44 #include <rpc/svc.h>
45 #endif /* _KERNEL */
46 
47 #ifdef	__cplusplus
48 extern "C" {
49 #endif
50 
51 
52 /*
53  * There are two kinds of "names": fullnames and nicknames
54  */
55 enum authdes_namekind {
56 	ADN_FULLNAME,
57 	ADN_NICKNAME
58 };
59 
60 /*
61  * A fullname contains the network name of the client,
62  * a conversation key and the window
63  */
64 struct authdes_fullname {
65 	char *name;	/* network name of client, up to MAXNETNAMELEN */
66 	des_block key;	/* conversation key */
67 	uint32_t window;	/* associated window */
68 };
69 
70 
71 /*
72  * A credential
73  */
74 struct authdes_cred {
75 	enum authdes_namekind adc_namekind;
76 	struct authdes_fullname adc_fullname;
77 	uint32_t adc_nickname;
78 };
79 
80 /*
81  * A des authentication verifier
82  */
83 struct authdes_verf {
84 	union {
85 		struct timeval adv_ctime;	/* clear time */
86 		des_block adv_xtime;		/* crypt time */
87 	} adv_time_u;
88 	uint32_t adv_int_u;
89 };
90 
91 /*
92  * des authentication verifier: client variety
93  *
94  * adv_timestamp is the current time.
95  * adv_winverf is the credential window + 1.
96  * Both are encrypted using the conversation key.
97  */
98 #define	adv_timestamp	adv_time_u.adv_ctime
99 #define	adv_xtimestamp	adv_time_u.adv_xtime
100 #define	adv_winverf	adv_int_u
101 
102 /*
103  * des authentication verifier: server variety
104  *
105  * adv_timeverf is the client's timestamp + client's window
106  * adv_nickname is the server's nickname for the client.
107  * adv_timeverf is encrypted using the conversation key.
108  */
109 #define	adv_timeverf	adv_time_u.adv_ctime
110 #define	adv_xtimeverf	adv_time_u.adv_xtime
111 #define	adv_nickname	adv_int_u
112 
113 /*
114  * Map a des credential into a unix cred.
115  *
116  *  authdes_getucred(adc, uid, gid, grouplen, groups)
117  *	struct authdes_cred *adc;
118  *	uid_t *uid;
119  *	gid_t *gid;
120  *	short *grouplen;
121  *	gid_t *groups;
122  *
123  */
124 
125 #ifdef _KERNEL
126 extern int	kauthdes_getucred(const struct authdes_cred *, cred_t *);
127 #else
128 #ifdef __STDC__
129 extern int	authdes_getucred(const struct authdes_cred *,
130 			uid_t *, gid_t *, short *, gid_t *);
131 #else
132 extern int	authdes_getucred();
133 #endif
134 #endif
135 
136 #ifndef _KERNEL
137 #ifdef __STDC__
138 extern int	getpublickey(const char *, char *);
139 extern int	getsecretkey(const char *, char *, const char *);
140 #else
141 extern int	getpublickey();
142 extern int	getsecretkey();
143 #endif
144 #endif
145 
146 #ifdef _KERNEL
147 
148 #ifdef __STDC__
149 extern int	authdes_create(char *, uint_t, struct netbuf *,
150 			struct knetconfig *, des_block *, int, AUTH **);
151 extern bool_t	xdr_authdes_cred(XDR *, struct authdes_cred *);
152 extern bool_t	xdr_authdes_verf(XDR *, struct authdes_verf *);
153 extern int	rtime(struct knetconfig *, struct netbuf *, int,
154 			struct timeval *, struct timeval *);
155 extern enum clnt_stat kgetnetname(char *);
156 extern enum auth_stat _svcauth_des(struct svc_req *, struct rpc_msg *);
157 #else
158 extern int	authdes_create();
159 extern bool_t	xdr_authdes_cred();
160 extern bool_t	xdr_authdes_verf();
161 extern int	rtime();
162 extern enum clnt_stat	kgetnetname();
163 extern enum auth_stat _svcauth_des();
164 #endif
165 
166 extern kmutex_t	authdes_ops_lock;
167 
168 #endif
169 
170 #ifdef	__cplusplus
171 }
172 #endif
173 
174 #endif	/* _RPC_AUTH_DES_H */
175