126219Swpaul#if defined(LIBC_SCCS) && !defined(lint)
226219Swpaulstatic char sccsid[] = 	"@(#)authdes_prot.c	2.1 88/07/29 4.0 RPCSRC; from 1.6 88/02/08 SMI";
326219Swpaul#endif
492990Sobrien#include <sys/cdefs.h>
592990Sobrien__FBSDID("$FreeBSD$");
692990Sobrien
7261057Smav/*-
8261057Smav * Copyright (c) 2009, Sun Microsystems, Inc.
9261057Smav * All rights reserved.
10261057Smav *
11261057Smav * Redistribution and use in source and binary forms, with or without
12261057Smav * modification, are permitted provided that the following conditions are met:
13261057Smav * - Redistributions of source code must retain the above copyright notice,
14261057Smav *   this list of conditions and the following disclaimer.
15261057Smav * - Redistributions in binary form must reproduce the above copyright notice,
16261057Smav *   this list of conditions and the following disclaimer in the documentation
17261057Smav *   and/or other materials provided with the distribution.
18261057Smav * - Neither the name of Sun Microsystems, Inc. nor the names of its
19261057Smav *   contributors may be used to endorse or promote products derived
20261057Smav *   from this software without specific prior written permission.
2126219Swpaul *
22261057Smav * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23261057Smav * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24261057Smav * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25261057Smav * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
26261057Smav * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27261057Smav * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28261057Smav * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29261057Smav * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30261057Smav * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31261057Smav * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32261057Smav * POSSIBILITY OF SUCH DAMAGE.
3326219Swpaul */
3426219Swpaul/*
3574462Salfred * Copyright (c) 1986-1991 by Sun Microsystems Inc.
3626219Swpaul */
3726219Swpaul
3826219Swpaul/*
3926219Swpaul * authdes_prot.c, XDR routines for DES authentication
4026219Swpaul */
4126219Swpaul
4274462Salfred#include "namespace.h"
4326219Swpaul#include <rpc/types.h>
4426219Swpaul#include <rpc/xdr.h>
4526219Swpaul#include <rpc/auth.h>
4626219Swpaul#include <rpc/auth_des.h>
4774462Salfred#include "un-namespace.h"
4826219Swpaul
4926219Swpaul#define ATTEMPT(xdr_op) if (!(xdr_op)) return (FALSE)
5026219Swpaul
5126219Swpaulbool_t
5226219Swpaulxdr_authdes_cred(xdrs, cred)
5326219Swpaul	XDR *xdrs;
5426219Swpaul	struct authdes_cred *cred;
5526219Swpaul{
56173763Sjb	enum authdes_namekind *padc_namekind = &cred->adc_namekind;
5726219Swpaul	/*
5826219Swpaul	 * Unrolled xdr
5926219Swpaul	 */
60173763Sjb	ATTEMPT(xdr_enum(xdrs, (enum_t *) padc_namekind));
6126219Swpaul	switch (cred->adc_namekind) {
6226219Swpaul	case ADN_FULLNAME:
6374462Salfred		ATTEMPT(xdr_string(xdrs, &cred->adc_fullname.name,
6474462Salfred		    MAXNETNAMELEN));
6574462Salfred		ATTEMPT(xdr_opaque(xdrs, (caddr_t)&cred->adc_fullname.key,
6674462Salfred		    sizeof(des_block)));
6774462Salfred		ATTEMPT(xdr_opaque(xdrs, (caddr_t)&cred->adc_fullname.window,
6874462Salfred		    sizeof(cred->adc_fullname.window)));
6926219Swpaul		return (TRUE);
7026219Swpaul	case ADN_NICKNAME:
7174462Salfred		ATTEMPT(xdr_opaque(xdrs, (caddr_t)&cred->adc_nickname,
7274462Salfred		    sizeof(cred->adc_nickname)));
7326219Swpaul		return (TRUE);
7426219Swpaul	default:
7526219Swpaul		return (FALSE);
7626219Swpaul	}
7726219Swpaul}
7826219Swpaul
7926219Swpaul
8026219Swpaulbool_t
8126219Swpaulxdr_authdes_verf(xdrs, verf)
8292889Sobrien	XDR *xdrs;
8392889Sobrien	struct authdes_verf *verf;
8426219Swpaul{
8526219Swpaul	/*
8626219Swpaul 	 * Unrolled xdr
8726219Swpaul 	 */
8874462Salfred	ATTEMPT(xdr_opaque(xdrs, (caddr_t)&verf->adv_xtimestamp,
8974462Salfred	    sizeof(des_block)));
9074462Salfred	ATTEMPT(xdr_opaque(xdrs, (caddr_t)&verf->adv_int_u,
9174462Salfred	    sizeof(verf->adv_int_u)));
9226219Swpaul	return (TRUE);
9326219Swpaul}
94