xref: /onnv-gate/usr/src/lib/krb5/kadm5/srv/adb_xdr.c (revision 7934:6aeeafc994de)
10Sstevel@tonic-gate /*
2*7934SMark.Phalan@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
30Sstevel@tonic-gate  * Use is subject to license terms.
40Sstevel@tonic-gate  */
50Sstevel@tonic-gate 
60Sstevel@tonic-gate 
70Sstevel@tonic-gate /*
80Sstevel@tonic-gate  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
90Sstevel@tonic-gate  *
100Sstevel@tonic-gate  *	Openvision retains the copyright to derivative works of
110Sstevel@tonic-gate  *	this source code.  Do *NOT* create a derivative of this
120Sstevel@tonic-gate  *	source code before consulting with your legal department.
130Sstevel@tonic-gate  *	Do *NOT* integrate *ANY* of this source code into another
140Sstevel@tonic-gate  *	product before consulting with your legal department.
150Sstevel@tonic-gate  *
160Sstevel@tonic-gate  *	For further information, read the top-level Openvision
170Sstevel@tonic-gate  *	copyright which is contained in the top-level MIT Kerberos
180Sstevel@tonic-gate  *	copyright.
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
210Sstevel@tonic-gate  *
220Sstevel@tonic-gate  */
230Sstevel@tonic-gate 
240Sstevel@tonic-gate 
250Sstevel@tonic-gate /*
260Sstevel@tonic-gate  * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved
270Sstevel@tonic-gate  *
28*7934SMark.Phalan@Sun.COM  * $Header$
290Sstevel@tonic-gate  */
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #if !defined(lint) && !defined(__CODECENTER__)
32*7934SMark.Phalan@Sun.COM static char *rcsid = "$Header$";
330Sstevel@tonic-gate #endif
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #include <sys/types.h>
36*7934SMark.Phalan@Sun.COM #include	"server_internal.h"
370Sstevel@tonic-gate #include <krb5.h>
380Sstevel@tonic-gate #include <rpc/rpc.h> /* SUNWresync121 XXX */
390Sstevel@tonic-gate #include "admin_xdr.h"
402881Smp153739 #ifdef HAVE_MEMORY_H
410Sstevel@tonic-gate #include <memory.h>
422881Smp153739 #endif
430Sstevel@tonic-gate 
440Sstevel@tonic-gate bool_t
xdr_krb5_key_data(XDR * xdrs,krb5_key_data * objp)450Sstevel@tonic-gate xdr_krb5_key_data(XDR *xdrs, krb5_key_data *objp)
460Sstevel@tonic-gate {
470Sstevel@tonic-gate     unsigned int tmp;
480Sstevel@tonic-gate 
490Sstevel@tonic-gate     if (!xdr_krb5_int16(xdrs, &objp->key_data_ver))
500Sstevel@tonic-gate 	return(FALSE);
510Sstevel@tonic-gate     if (!xdr_krb5_int16(xdrs, &objp->key_data_kvno))
520Sstevel@tonic-gate 	return(FALSE);
530Sstevel@tonic-gate     if (!xdr_krb5_int16(xdrs, &objp->key_data_type[0]))
540Sstevel@tonic-gate 	return(FALSE);
550Sstevel@tonic-gate     if (!xdr_krb5_int16(xdrs, &objp->key_data_type[1]))
560Sstevel@tonic-gate 	return(FALSE);
572881Smp153739 	/* SUNW14resync */
582881Smp153739     if (!xdr_krb5_ui_2(xdrs, (krb5_ui_2 *)&objp->key_data_length[0]))
590Sstevel@tonic-gate 	return(FALSE);
602881Smp153739     if (!xdr_krb5_ui_2(xdrs, (krb5_ui_2 *)&objp->key_data_length[1]))
610Sstevel@tonic-gate 	return(FALSE);
620Sstevel@tonic-gate 
630Sstevel@tonic-gate     tmp = (unsigned int) objp->key_data_length[0];
640Sstevel@tonic-gate     if (!xdr_bytes(xdrs, (char **) &objp->key_data_contents[0],
650Sstevel@tonic-gate 		   &tmp, ~0))
660Sstevel@tonic-gate 	return FALSE;
670Sstevel@tonic-gate 
680Sstevel@tonic-gate     tmp = (unsigned int) objp->key_data_length[1];
690Sstevel@tonic-gate     if (!xdr_bytes(xdrs, (char **) &objp->key_data_contents[1],
700Sstevel@tonic-gate 		   &tmp, ~0))
710Sstevel@tonic-gate 	return FALSE;
720Sstevel@tonic-gate 
730Sstevel@tonic-gate     /* don't need to copy tmp out, since key_data_length will be set
740Sstevel@tonic-gate        by the above encoding. */
750Sstevel@tonic-gate 
760Sstevel@tonic-gate     return(TRUE);
770Sstevel@tonic-gate }
780Sstevel@tonic-gate 
790Sstevel@tonic-gate bool_t
xdr_osa_pw_hist_ent(XDR * xdrs,osa_pw_hist_ent * objp)800Sstevel@tonic-gate xdr_osa_pw_hist_ent(XDR *xdrs, osa_pw_hist_ent *objp)
810Sstevel@tonic-gate {
820Sstevel@tonic-gate     if (!xdr_array(xdrs, (caddr_t *) &objp->key_data,
830Sstevel@tonic-gate 		   (u_int *) &objp->n_key_data, ~0,
840Sstevel@tonic-gate 		   sizeof(krb5_key_data),
850Sstevel@tonic-gate 		   xdr_krb5_key_data))
860Sstevel@tonic-gate 	return (FALSE);
870Sstevel@tonic-gate     return (TRUE);
880Sstevel@tonic-gate }
890Sstevel@tonic-gate 
900Sstevel@tonic-gate bool_t
xdr_osa_princ_ent_rec(XDR * xdrs,osa_princ_ent_t objp)910Sstevel@tonic-gate xdr_osa_princ_ent_rec(XDR *xdrs, osa_princ_ent_t objp)
920Sstevel@tonic-gate {
930Sstevel@tonic-gate     switch (xdrs->x_op) {
940Sstevel@tonic-gate     case XDR_ENCODE:
950Sstevel@tonic-gate 	 objp->version = OSA_ADB_PRINC_VERSION_1;
960Sstevel@tonic-gate 	 /* fall through */
970Sstevel@tonic-gate     case XDR_FREE:
980Sstevel@tonic-gate 	 if (!xdr_int(xdrs, &objp->version))
990Sstevel@tonic-gate 	      return FALSE;
1000Sstevel@tonic-gate 	 break;
1010Sstevel@tonic-gate     case XDR_DECODE:
1020Sstevel@tonic-gate 	 if (!xdr_int(xdrs, &objp->version))
1030Sstevel@tonic-gate 	      return FALSE;
1040Sstevel@tonic-gate 	 if (objp->version != OSA_ADB_PRINC_VERSION_1)
1050Sstevel@tonic-gate 	      return FALSE;
1060Sstevel@tonic-gate 	 break;
1070Sstevel@tonic-gate     }
1080Sstevel@tonic-gate 
1090Sstevel@tonic-gate     if (!xdr_nullstring(xdrs, &objp->policy))
1100Sstevel@tonic-gate 	return (FALSE);
1110Sstevel@tonic-gate     if (!xdr_long(xdrs, &objp->aux_attributes))
1120Sstevel@tonic-gate 	return (FALSE);
1130Sstevel@tonic-gate     if (!xdr_u_int(xdrs, &objp->old_key_next))
1140Sstevel@tonic-gate 	return (FALSE);
1150Sstevel@tonic-gate     if (!xdr_krb5_kvno(xdrs, &objp->admin_history_kvno))
1160Sstevel@tonic-gate 	return (FALSE);
1170Sstevel@tonic-gate     if (!xdr_array(xdrs, (caddr_t *) &objp->old_keys,
1180Sstevel@tonic-gate 		   (unsigned int *) &objp->old_key_len, ~0,
1190Sstevel@tonic-gate 		   sizeof(osa_pw_hist_ent),
1200Sstevel@tonic-gate 		   xdr_osa_pw_hist_ent))
1210Sstevel@tonic-gate 	return (FALSE);
1220Sstevel@tonic-gate     return (TRUE);
1230Sstevel@tonic-gate }
1240Sstevel@tonic-gate 
1254960Swillf void
osa_free_princ_ent(osa_princ_ent_t val)1264960Swillf osa_free_princ_ent(osa_princ_ent_t val)
1270Sstevel@tonic-gate {
1284960Swillf     XDR xdrs;
1294960Swillf 
1304960Swillf     xdrmem_create(&xdrs, NULL, 0, XDR_FREE);
1314960Swillf 
1324960Swillf     xdr_osa_princ_ent_rec(&xdrs, val);
1334960Swillf     free(val);
1340Sstevel@tonic-gate }
135*7934SMark.Phalan@Sun.COM 
136