xref: /illumos-gate/usr/src/uts/common/rpc/auth_des.h (revision f012ee0c3db17469b492c2cf757226f3d7b1ebbc)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
38 
39 /*
40  * auth_des.h, Protocol for DES style authentication for RPC
41  *
42  */
43 
44 #include <rpc/auth.h>
45 #ifdef _KERNEL
46 #include <rpc/svc.h>
47 #endif /* _KERNEL */
48 
49 #ifdef	__cplusplus
50 extern "C" {
51 #endif
52 
53 
54 /*
55  * There are two kinds of "names": fullnames and nicknames
56  */
57 enum authdes_namekind {
58 	ADN_FULLNAME,
59 	ADN_NICKNAME
60 };
61 
62 /*
63  * A fullname contains the network name of the client,
64  * a conversation key and the window
65  */
66 struct authdes_fullname {
67 	char *name;	/* network name of client, up to MAXNETNAMELEN */
68 	des_block key;	/* conversation key */
69 	uint32_t window;	/* associated window */
70 };
71 
72 
73 /*
74  * A credential
75  */
76 struct authdes_cred {
77 	enum authdes_namekind adc_namekind;
78 	struct authdes_fullname adc_fullname;
79 	uint32_t adc_nickname;
80 };
81 
82 /*
83  * A des authentication verifier
84  */
85 struct authdes_verf {
86 	union {
87 		struct timeval adv_ctime;	/* clear time */
88 		des_block adv_xtime;		/* crypt time */
89 	} adv_time_u;
90 	uint32_t adv_int_u;
91 };
92 
93 /*
94  * des authentication verifier: client variety
95  *
96  * adv_timestamp is the current time.
97  * adv_winverf is the credential window + 1.
98  * Both are encrypted using the conversation key.
99  */
100 #define	adv_timestamp	adv_time_u.adv_ctime
101 #define	adv_xtimestamp	adv_time_u.adv_xtime
102 #define	adv_winverf	adv_int_u
103 
104 /*
105  * des authentication verifier: server variety
106  *
107  * adv_timeverf is the client's timestamp + client's window
108  * adv_nickname is the server's nickname for the client.
109  * adv_timeverf is encrypted using the conversation key.
110  */
111 #define	adv_timeverf	adv_time_u.adv_ctime
112 #define	adv_xtimeverf	adv_time_u.adv_xtime
113 #define	adv_nickname	adv_int_u
114 
115 /*
116  * Map a des credential into a unix cred.
117  *
118  *  authdes_getucred(adc, uid, gid, grouplen, groups)
119  *	struct authdes_cred *adc;
120  *	uid_t *uid;
121  *	gid_t *gid;
122  *	short *grouplen;
123  *	gid_t *groups;
124  *
125  */
126 
127 #ifdef _KERNEL
128 extern int	kauthdes_getucred(const struct authdes_cred *, cred_t *);
129 #else
130 #ifdef __STDC__
131 extern int	authdes_getucred(const struct authdes_cred *,
132 			uid_t *, gid_t *, short *, gid_t *);
133 #else
134 extern int	authdes_getucred();
135 #endif
136 #endif
137 
138 #ifndef _KERNEL
139 #ifdef __STDC__
140 extern int	getpublickey(const char *, char *);
141 extern int	getsecretkey(const char *, char *, const char *);
142 #else
143 extern int	getpublickey();
144 extern int	getsecretkey();
145 #endif
146 #endif
147 
148 #ifdef _KERNEL
149 
150 #ifdef __STDC__
151 extern int	authdes_create(char *, uint_t, struct netbuf *,
152 			struct knetconfig *, des_block *, int, AUTH **);
153 extern bool_t	xdr_authdes_cred(XDR *, struct authdes_cred *);
154 extern bool_t	xdr_authdes_verf(XDR *, struct authdes_verf *);
155 extern int	rtime(struct knetconfig *, struct netbuf *, int,
156 			struct timeval *, struct timeval *);
157 extern enum clnt_stat kgetnetname(char *);
158 extern enum auth_stat _svcauth_des(struct svc_req *, struct rpc_msg *);
159 #else
160 extern int	authdes_create();
161 extern bool_t	xdr_authdes_cred();
162 extern bool_t	xdr_authdes_verf();
163 extern int	rtime();
164 extern enum clnt_stat	kgetnetname();
165 extern enum auth_stat _svcauth_des();
166 #endif
167 
168 extern kmutex_t	authdes_ops_lock;
169 
170 #endif
171 
172 #ifdef	__cplusplus
173 }
174 #endif
175 
176 #endif	/* _RPC_AUTH_DES_H */
177