xref: /freebsd/include/rpc/auth_des.h (revision f5147e312f43a9050468de539aeafa072caa1a60)
1 /*	@(#)auth_des.h	2.2 88/07/29 4.0 RPCSRC; from 1.3 88/02/08 SMI */
2 /*	$FreeBSD$ */
3 /*-
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  * Copyright (c) 2009, Sun Microsystems, Inc.
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions are met:
11  * - Redistributions of source code must retain the above copyright notice,
12  *   this list of conditions and the following disclaimer.
13  * - Redistributions in binary form must reproduce the above copyright notice,
14  *   this list of conditions and the following disclaimer in the documentation
15  *   and/or other materials provided with the distribution.
16  * - Neither the name of Sun Microsystems, Inc. nor the names of its
17  *   contributors may be used to endorse or promote products derived
18  *   from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  *
32  *	from: @(#)auth_des.h 2.2 88/07/29 4.0 RPCSRC
33  *	from: @(#)auth_des.h 1.14    94/04/25 SMI
34  */
35 
36 /*
37  * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc.
38  */
39 
40 /*
41  * auth_des.h, Protocol for DES style authentication for RPC
42  */
43 
44 #ifndef _AUTH_DES_
45 #define _AUTH_DES_
46 
47 /*
48  * There are two kinds of "names": fullnames and nicknames
49  */
50 enum authdes_namekind {
51 	ADN_FULLNAME,
52 	ADN_NICKNAME
53 };
54 
55 /*
56  * A fullname contains the network name of the client,
57  * a conversation key and the window
58  */
59 struct authdes_fullname {
60 	char *name;		/* network name of client, up to MAXNETNAMELEN */
61 	des_block key;		/* conversation key */
62 	u_long window;		/* associated window */
63 };
64 
65 
66 /*
67  * A credential
68  */
69 struct authdes_cred {
70 	enum authdes_namekind adc_namekind;
71 	struct authdes_fullname adc_fullname;
72 	u_long adc_nickname;
73 };
74 
75 
76 
77 /*
78  * A des authentication verifier
79  */
80 struct authdes_verf {
81 	union {
82 		struct timeval adv_ctime;	/* clear time */
83 		des_block adv_xtime;		/* crypt time */
84 	} adv_time_u;
85 	u_long adv_int_u;
86 };
87 
88 /*
89  * des authentication verifier: client variety
90  *
91  * adv_timestamp is the current time.
92  * adv_winverf is the credential window + 1.
93  * Both are encrypted using the conversation key.
94  */
95 #define adv_timestamp	adv_time_u.adv_ctime
96 #define adv_xtimestamp	adv_time_u.adv_xtime
97 #define adv_winverf	adv_int_u
98 
99 /*
100  * des authentication verifier: server variety
101  *
102  * adv_timeverf is the client's timestamp + client's window
103  * adv_nickname is the server's nickname for the client.
104  * adv_timeverf is encrypted using the conversation key.
105  */
106 #define adv_timeverf	adv_time_u.adv_ctime
107 #define adv_xtimeverf	adv_time_u.adv_xtime
108 #define adv_nickname	adv_int_u
109 
110 /*
111  * Map a des credential into a unix cred.
112  *
113  */
114 __BEGIN_DECLS
115 extern int authdes_getucred( struct authdes_cred *, uid_t *, gid_t *, int *, gid_t * );
116 __END_DECLS
117 
118 __BEGIN_DECLS
119 extern bool_t	xdr_authdes_cred(XDR *, struct authdes_cred *);
120 extern bool_t	xdr_authdes_verf(XDR *, struct authdes_verf *);
121 extern int	rtime(dev_t, struct netbuf *, int, struct timeval *,
122 		    struct timeval *);
123 extern void	kgetnetname(char *);
124 extern enum auth_stat _svcauth_des(struct svc_req *, struct rpc_msg *);
125 __END_DECLS
126 
127 #endif /* ndef _AUTH_DES_ */
128