17c478bd9Sstevel@tonic-gate /*
2*159d09a2SMark Phalan * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
37c478bd9Sstevel@tonic-gate * Use is subject to license terms.
47c478bd9Sstevel@tonic-gate */
57c478bd9Sstevel@tonic-gate
67c478bd9Sstevel@tonic-gate
77c478bd9Sstevel@tonic-gate /*
87c478bd9Sstevel@tonic-gate * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
97c478bd9Sstevel@tonic-gate *
107c478bd9Sstevel@tonic-gate * Openvision retains the copyright to derivative works of
117c478bd9Sstevel@tonic-gate * this source code. Do *NOT* create a derivative of this
127c478bd9Sstevel@tonic-gate * source code before consulting with your legal department.
137c478bd9Sstevel@tonic-gate * Do *NOT* integrate *ANY* of this source code into another
147c478bd9Sstevel@tonic-gate * product before consulting with your legal department.
157c478bd9Sstevel@tonic-gate *
167c478bd9Sstevel@tonic-gate * For further information, read the top-level Openvision
177c478bd9Sstevel@tonic-gate * copyright which is contained in the top-level MIT Kerberos
187c478bd9Sstevel@tonic-gate * copyright.
197c478bd9Sstevel@tonic-gate *
207c478bd9Sstevel@tonic-gate * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
217c478bd9Sstevel@tonic-gate *
227c478bd9Sstevel@tonic-gate */
237c478bd9Sstevel@tonic-gate
247c478bd9Sstevel@tonic-gate
257c478bd9Sstevel@tonic-gate /*
267c478bd9Sstevel@tonic-gate * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved
277c478bd9Sstevel@tonic-gate *
28*159d09a2SMark Phalan * $Header$
297c478bd9Sstevel@tonic-gate */
307c478bd9Sstevel@tonic-gate
317c478bd9Sstevel@tonic-gate #if !defined(lint) && !defined(__CODECENTER__)
32*159d09a2SMark Phalan static char *rcsid = "$Header$";
337c478bd9Sstevel@tonic-gate #endif
347c478bd9Sstevel@tonic-gate
357c478bd9Sstevel@tonic-gate #include <sys/types.h>
36*159d09a2SMark Phalan #include "server_internal.h"
377c478bd9Sstevel@tonic-gate #include <krb5.h>
387c478bd9Sstevel@tonic-gate #include <rpc/rpc.h> /* SUNWresync121 XXX */
397c478bd9Sstevel@tonic-gate #include "admin_xdr.h"
4056a424ccSmp153739 #ifdef HAVE_MEMORY_H
417c478bd9Sstevel@tonic-gate #include <memory.h>
4256a424ccSmp153739 #endif
437c478bd9Sstevel@tonic-gate
447c478bd9Sstevel@tonic-gate bool_t
xdr_krb5_key_data(XDR * xdrs,krb5_key_data * objp)457c478bd9Sstevel@tonic-gate xdr_krb5_key_data(XDR *xdrs, krb5_key_data *objp)
467c478bd9Sstevel@tonic-gate {
477c478bd9Sstevel@tonic-gate unsigned int tmp;
487c478bd9Sstevel@tonic-gate
497c478bd9Sstevel@tonic-gate if (!xdr_krb5_int16(xdrs, &objp->key_data_ver))
507c478bd9Sstevel@tonic-gate return(FALSE);
517c478bd9Sstevel@tonic-gate if (!xdr_krb5_int16(xdrs, &objp->key_data_kvno))
527c478bd9Sstevel@tonic-gate return(FALSE);
537c478bd9Sstevel@tonic-gate if (!xdr_krb5_int16(xdrs, &objp->key_data_type[0]))
547c478bd9Sstevel@tonic-gate return(FALSE);
557c478bd9Sstevel@tonic-gate if (!xdr_krb5_int16(xdrs, &objp->key_data_type[1]))
567c478bd9Sstevel@tonic-gate return(FALSE);
5756a424ccSmp153739 /* SUNW14resync */
5856a424ccSmp153739 if (!xdr_krb5_ui_2(xdrs, (krb5_ui_2 *)&objp->key_data_length[0]))
597c478bd9Sstevel@tonic-gate return(FALSE);
6056a424ccSmp153739 if (!xdr_krb5_ui_2(xdrs, (krb5_ui_2 *)&objp->key_data_length[1]))
617c478bd9Sstevel@tonic-gate return(FALSE);
627c478bd9Sstevel@tonic-gate
637c478bd9Sstevel@tonic-gate tmp = (unsigned int) objp->key_data_length[0];
647c478bd9Sstevel@tonic-gate if (!xdr_bytes(xdrs, (char **) &objp->key_data_contents[0],
657c478bd9Sstevel@tonic-gate &tmp, ~0))
667c478bd9Sstevel@tonic-gate return FALSE;
677c478bd9Sstevel@tonic-gate
687c478bd9Sstevel@tonic-gate tmp = (unsigned int) objp->key_data_length[1];
697c478bd9Sstevel@tonic-gate if (!xdr_bytes(xdrs, (char **) &objp->key_data_contents[1],
707c478bd9Sstevel@tonic-gate &tmp, ~0))
717c478bd9Sstevel@tonic-gate return FALSE;
727c478bd9Sstevel@tonic-gate
737c478bd9Sstevel@tonic-gate /* don't need to copy tmp out, since key_data_length will be set
747c478bd9Sstevel@tonic-gate by the above encoding. */
757c478bd9Sstevel@tonic-gate
767c478bd9Sstevel@tonic-gate return(TRUE);
777c478bd9Sstevel@tonic-gate }
787c478bd9Sstevel@tonic-gate
797c478bd9Sstevel@tonic-gate bool_t
xdr_osa_pw_hist_ent(XDR * xdrs,osa_pw_hist_ent * objp)807c478bd9Sstevel@tonic-gate xdr_osa_pw_hist_ent(XDR *xdrs, osa_pw_hist_ent *objp)
817c478bd9Sstevel@tonic-gate {
827c478bd9Sstevel@tonic-gate if (!xdr_array(xdrs, (caddr_t *) &objp->key_data,
837c478bd9Sstevel@tonic-gate (u_int *) &objp->n_key_data, ~0,
847c478bd9Sstevel@tonic-gate sizeof(krb5_key_data),
857c478bd9Sstevel@tonic-gate xdr_krb5_key_data))
867c478bd9Sstevel@tonic-gate return (FALSE);
877c478bd9Sstevel@tonic-gate return (TRUE);
887c478bd9Sstevel@tonic-gate }
897c478bd9Sstevel@tonic-gate
907c478bd9Sstevel@tonic-gate bool_t
xdr_osa_princ_ent_rec(XDR * xdrs,osa_princ_ent_t objp)917c478bd9Sstevel@tonic-gate xdr_osa_princ_ent_rec(XDR *xdrs, osa_princ_ent_t objp)
927c478bd9Sstevel@tonic-gate {
937c478bd9Sstevel@tonic-gate switch (xdrs->x_op) {
947c478bd9Sstevel@tonic-gate case XDR_ENCODE:
957c478bd9Sstevel@tonic-gate objp->version = OSA_ADB_PRINC_VERSION_1;
967c478bd9Sstevel@tonic-gate /* fall through */
977c478bd9Sstevel@tonic-gate case XDR_FREE:
987c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->version))
997c478bd9Sstevel@tonic-gate return FALSE;
1007c478bd9Sstevel@tonic-gate break;
1017c478bd9Sstevel@tonic-gate case XDR_DECODE:
1027c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->version))
1037c478bd9Sstevel@tonic-gate return FALSE;
1047c478bd9Sstevel@tonic-gate if (objp->version != OSA_ADB_PRINC_VERSION_1)
1057c478bd9Sstevel@tonic-gate return FALSE;
1067c478bd9Sstevel@tonic-gate break;
1077c478bd9Sstevel@tonic-gate }
1087c478bd9Sstevel@tonic-gate
1097c478bd9Sstevel@tonic-gate if (!xdr_nullstring(xdrs, &objp->policy))
1107c478bd9Sstevel@tonic-gate return (FALSE);
1117c478bd9Sstevel@tonic-gate if (!xdr_long(xdrs, &objp->aux_attributes))
1127c478bd9Sstevel@tonic-gate return (FALSE);
1137c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->old_key_next))
1147c478bd9Sstevel@tonic-gate return (FALSE);
1157c478bd9Sstevel@tonic-gate if (!xdr_krb5_kvno(xdrs, &objp->admin_history_kvno))
1167c478bd9Sstevel@tonic-gate return (FALSE);
1177c478bd9Sstevel@tonic-gate if (!xdr_array(xdrs, (caddr_t *) &objp->old_keys,
1187c478bd9Sstevel@tonic-gate (unsigned int *) &objp->old_key_len, ~0,
1197c478bd9Sstevel@tonic-gate sizeof(osa_pw_hist_ent),
1207c478bd9Sstevel@tonic-gate xdr_osa_pw_hist_ent))
1217c478bd9Sstevel@tonic-gate return (FALSE);
1227c478bd9Sstevel@tonic-gate return (TRUE);
1237c478bd9Sstevel@tonic-gate }
1247c478bd9Sstevel@tonic-gate
12554925bf6Swillf void
osa_free_princ_ent(osa_princ_ent_t val)12654925bf6Swillf osa_free_princ_ent(osa_princ_ent_t val)
1277c478bd9Sstevel@tonic-gate {
12854925bf6Swillf XDR xdrs;
1297c478bd9Sstevel@tonic-gate
13054925bf6Swillf xdrmem_create(&xdrs, NULL, 0, XDR_FREE);
13154925bf6Swillf
13254925bf6Swillf xdr_osa_princ_ent_rec(&xdrs, val);
13354925bf6Swillf free(val);
1347c478bd9Sstevel@tonic-gate }
135*159d09a2SMark Phalan
136