xref: /freebsd/lib/libc/rpc/authdes_prot.c (revision 8360efbd6c932013ffdb2f83d2f2de4278febb5e)
1e8636dfdSBill Paul #if defined(LIBC_SCCS) && !defined(lint)
2e8636dfdSBill Paul static char sccsid[] = 	"@(#)authdes_prot.c	2.1 88/07/29 4.0 RPCSRC; from 1.6 88/02/08 SMI";
3e8636dfdSBill Paul #endif
48360efbdSAlfred Perlstein /*	$FreeBSD$ */
5e8636dfdSBill Paul /*
6e8636dfdSBill Paul  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
7e8636dfdSBill Paul  * unrestricted use provided that this legend is included on all tape
8e8636dfdSBill Paul  * media and as a part of the software program in whole or part.  Users
9e8636dfdSBill Paul  * may copy or modify Sun RPC without charge, but are not authorized
10e8636dfdSBill Paul  * to license or distribute it to anyone else except as part of a product or
11e8636dfdSBill Paul  * program developed by the user.
12e8636dfdSBill Paul  *
13e8636dfdSBill Paul  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
14e8636dfdSBill Paul  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
15e8636dfdSBill Paul  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
16e8636dfdSBill Paul  *
17e8636dfdSBill Paul  * Sun RPC is provided with no support and without any obligation on the
18e8636dfdSBill Paul  * part of Sun Microsystems, Inc. to assist in its use, correction,
19e8636dfdSBill Paul  * modification or enhancement.
20e8636dfdSBill Paul  *
21e8636dfdSBill Paul  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
22e8636dfdSBill Paul  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
23e8636dfdSBill Paul  * OR ANY PART THEREOF.
24e8636dfdSBill Paul  *
25e8636dfdSBill Paul  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
26e8636dfdSBill Paul  * or profits or other special, indirect and consequential damages, even if
27e8636dfdSBill Paul  * Sun has been advised of the possibility of such damages.
28e8636dfdSBill Paul  *
29e8636dfdSBill Paul  * Sun Microsystems, Inc.
30e8636dfdSBill Paul  * 2550 Garcia Avenue
31e8636dfdSBill Paul  * Mountain View, California  94043
32e8636dfdSBill Paul  */
33e8636dfdSBill Paul /*
348360efbdSAlfred Perlstein  * Copyright (c) 1986-1991 by Sun Microsystems Inc.
35e8636dfdSBill Paul  */
36e8636dfdSBill Paul 
37e8636dfdSBill Paul /*
38e8636dfdSBill Paul  * authdes_prot.c, XDR routines for DES authentication
39e8636dfdSBill Paul  */
40e8636dfdSBill Paul 
418360efbdSAlfred Perlstein #include "namespace.h"
42e8636dfdSBill Paul #include <rpc/types.h>
43e8636dfdSBill Paul #include <rpc/xdr.h>
44e8636dfdSBill Paul #include <rpc/auth.h>
45e8636dfdSBill Paul #include <rpc/auth_des.h>
468360efbdSAlfred Perlstein #include "un-namespace.h"
47e8636dfdSBill Paul 
48e8636dfdSBill Paul #define ATTEMPT(xdr_op) if (!(xdr_op)) return (FALSE)
49e8636dfdSBill Paul 
50e8636dfdSBill Paul bool_t
51e8636dfdSBill Paul xdr_authdes_cred(xdrs, cred)
52e8636dfdSBill Paul 	XDR *xdrs;
53e8636dfdSBill Paul 	struct authdes_cred *cred;
54e8636dfdSBill Paul {
55e8636dfdSBill Paul 	/*
56e8636dfdSBill Paul 	 * Unrolled xdr
57e8636dfdSBill Paul 	 */
58e8636dfdSBill Paul 	ATTEMPT(xdr_enum(xdrs, (enum_t *)&cred->adc_namekind));
59e8636dfdSBill Paul 	switch (cred->adc_namekind) {
60e8636dfdSBill Paul 	case ADN_FULLNAME:
618360efbdSAlfred Perlstein 		ATTEMPT(xdr_string(xdrs, &cred->adc_fullname.name,
628360efbdSAlfred Perlstein 		    MAXNETNAMELEN));
638360efbdSAlfred Perlstein 		ATTEMPT(xdr_opaque(xdrs, (caddr_t)&cred->adc_fullname.key,
648360efbdSAlfred Perlstein 		    sizeof(des_block)));
658360efbdSAlfred Perlstein 		ATTEMPT(xdr_opaque(xdrs, (caddr_t)&cred->adc_fullname.window,
668360efbdSAlfred Perlstein 		    sizeof(cred->adc_fullname.window)));
67e8636dfdSBill Paul 		return (TRUE);
68e8636dfdSBill Paul 	case ADN_NICKNAME:
698360efbdSAlfred Perlstein 		ATTEMPT(xdr_opaque(xdrs, (caddr_t)&cred->adc_nickname,
708360efbdSAlfred Perlstein 		    sizeof(cred->adc_nickname)));
71e8636dfdSBill Paul 		return (TRUE);
72e8636dfdSBill Paul 	default:
73e8636dfdSBill Paul 		return (FALSE);
74e8636dfdSBill Paul 	}
75e8636dfdSBill Paul }
76e8636dfdSBill Paul 
77e8636dfdSBill Paul 
78e8636dfdSBill Paul bool_t
79e8636dfdSBill Paul xdr_authdes_verf(xdrs, verf)
80e8636dfdSBill Paul 	register XDR *xdrs;
81e8636dfdSBill Paul 	register struct authdes_verf *verf;
82e8636dfdSBill Paul {
83e8636dfdSBill Paul 	/*
84e8636dfdSBill Paul  	 * Unrolled xdr
85e8636dfdSBill Paul  	 */
868360efbdSAlfred Perlstein 	ATTEMPT(xdr_opaque(xdrs, (caddr_t)&verf->adv_xtimestamp,
878360efbdSAlfred Perlstein 	    sizeof(des_block)));
888360efbdSAlfred Perlstein 	ATTEMPT(xdr_opaque(xdrs, (caddr_t)&verf->adv_int_u,
898360efbdSAlfred Perlstein 	    sizeof(verf->adv_int_u)));
90e8636dfdSBill Paul 	return (TRUE);
91e8636dfdSBill Paul }
92