1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * Copyright 2002 Sun Microsystems, Inc. All rights reserved. 3*0Sstevel@tonic-gate * Use is subject to license terms. 4*0Sstevel@tonic-gate */ 5*0Sstevel@tonic-gate 6*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 7*0Sstevel@tonic-gate 8*0Sstevel@tonic-gate /* 9*0Sstevel@tonic-gate * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING 10*0Sstevel@tonic-gate * 11*0Sstevel@tonic-gate * Openvision retains the copyright to derivative works of 12*0Sstevel@tonic-gate * this source code. Do *NOT* create a derivative of this 13*0Sstevel@tonic-gate * source code before consulting with your legal department. 14*0Sstevel@tonic-gate * Do *NOT* integrate *ANY* of this source code into another 15*0Sstevel@tonic-gate * product before consulting with your legal department. 16*0Sstevel@tonic-gate * 17*0Sstevel@tonic-gate * For further information, read the top-level Openvision 18*0Sstevel@tonic-gate * copyright which is contained in the top-level MIT Kerberos 19*0Sstevel@tonic-gate * copyright. 20*0Sstevel@tonic-gate * 21*0Sstevel@tonic-gate * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING 22*0Sstevel@tonic-gate * 23*0Sstevel@tonic-gate */ 24*0Sstevel@tonic-gate 25*0Sstevel@tonic-gate 26*0Sstevel@tonic-gate /* 27*0Sstevel@tonic-gate * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved 28*0Sstevel@tonic-gate * 29*0Sstevel@tonic-gate * $Header: /cvs/krbdev/krb5/src/lib/kadm5/srv/adb_xdr.c,v 1.2 1998/02/14 02:31:34 tlyu Exp $ 30*0Sstevel@tonic-gate */ 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #if !defined(lint) && !defined(__CODECENTER__) 33*0Sstevel@tonic-gate static char *rcsid = "$Header: /cvs/krbdev/krb5/src/lib/kadm5/srv/adb_xdr.c,v 1.2 1998/02/14 02:31:34 tlyu Exp $"; 34*0Sstevel@tonic-gate #endif 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate #include <sys/types.h> 37*0Sstevel@tonic-gate #include <krb5.h> 38*0Sstevel@tonic-gate #include <rpc/rpc.h> /* SUNWresync121 XXX */ 39*0Sstevel@tonic-gate #include "adb.h" 40*0Sstevel@tonic-gate #include "admin_xdr.h" 41*0Sstevel@tonic-gate #include <memory.h> 42*0Sstevel@tonic-gate 43*0Sstevel@tonic-gate extern bool_t 44*0Sstevel@tonic-gate xdr_krb5_int16(XDR *xdrs, krb5_int16 *objp); 45*0Sstevel@tonic-gate 46*0Sstevel@tonic-gate bool_t 47*0Sstevel@tonic-gate xdr_krb5_key_data(XDR *xdrs, krb5_key_data *objp) 48*0Sstevel@tonic-gate { 49*0Sstevel@tonic-gate unsigned int tmp; 50*0Sstevel@tonic-gate 51*0Sstevel@tonic-gate if (!xdr_krb5_int16(xdrs, &objp->key_data_ver)) 52*0Sstevel@tonic-gate return(FALSE); 53*0Sstevel@tonic-gate if (!xdr_krb5_int16(xdrs, &objp->key_data_kvno)) 54*0Sstevel@tonic-gate return(FALSE); 55*0Sstevel@tonic-gate if (!xdr_krb5_int16(xdrs, &objp->key_data_type[0])) 56*0Sstevel@tonic-gate return(FALSE); 57*0Sstevel@tonic-gate if (!xdr_krb5_int16(xdrs, &objp->key_data_type[1])) 58*0Sstevel@tonic-gate return(FALSE); 59*0Sstevel@tonic-gate if (!xdr_krb5_int16(xdrs, &objp->key_data_length[0])) 60*0Sstevel@tonic-gate return(FALSE); 61*0Sstevel@tonic-gate if (!xdr_krb5_int16(xdrs, &objp->key_data_length[1])) 62*0Sstevel@tonic-gate return(FALSE); 63*0Sstevel@tonic-gate 64*0Sstevel@tonic-gate tmp = (unsigned int) objp->key_data_length[0]; 65*0Sstevel@tonic-gate if (!xdr_bytes(xdrs, (char **) &objp->key_data_contents[0], 66*0Sstevel@tonic-gate &tmp, ~0)) 67*0Sstevel@tonic-gate return FALSE; 68*0Sstevel@tonic-gate 69*0Sstevel@tonic-gate tmp = (unsigned int) objp->key_data_length[1]; 70*0Sstevel@tonic-gate if (!xdr_bytes(xdrs, (char **) &objp->key_data_contents[1], 71*0Sstevel@tonic-gate &tmp, ~0)) 72*0Sstevel@tonic-gate return FALSE; 73*0Sstevel@tonic-gate 74*0Sstevel@tonic-gate /* don't need to copy tmp out, since key_data_length will be set 75*0Sstevel@tonic-gate by the above encoding. */ 76*0Sstevel@tonic-gate 77*0Sstevel@tonic-gate return(TRUE); 78*0Sstevel@tonic-gate } 79*0Sstevel@tonic-gate 80*0Sstevel@tonic-gate bool_t 81*0Sstevel@tonic-gate xdr_osa_pw_hist_ent(XDR *xdrs, osa_pw_hist_ent *objp) 82*0Sstevel@tonic-gate { 83*0Sstevel@tonic-gate if (!xdr_array(xdrs, (caddr_t *) &objp->key_data, 84*0Sstevel@tonic-gate (u_int *) &objp->n_key_data, ~0, 85*0Sstevel@tonic-gate sizeof(krb5_key_data), 86*0Sstevel@tonic-gate xdr_krb5_key_data)) 87*0Sstevel@tonic-gate return (FALSE); 88*0Sstevel@tonic-gate return (TRUE); 89*0Sstevel@tonic-gate } 90*0Sstevel@tonic-gate 91*0Sstevel@tonic-gate bool_t 92*0Sstevel@tonic-gate xdr_osa_princ_ent_rec(XDR *xdrs, osa_princ_ent_t objp) 93*0Sstevel@tonic-gate { 94*0Sstevel@tonic-gate switch (xdrs->x_op) { 95*0Sstevel@tonic-gate case XDR_ENCODE: 96*0Sstevel@tonic-gate objp->version = OSA_ADB_PRINC_VERSION_1; 97*0Sstevel@tonic-gate /* fall through */ 98*0Sstevel@tonic-gate case XDR_FREE: 99*0Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->version)) 100*0Sstevel@tonic-gate return FALSE; 101*0Sstevel@tonic-gate break; 102*0Sstevel@tonic-gate case XDR_DECODE: 103*0Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->version)) 104*0Sstevel@tonic-gate return FALSE; 105*0Sstevel@tonic-gate if (objp->version != OSA_ADB_PRINC_VERSION_1) 106*0Sstevel@tonic-gate return FALSE; 107*0Sstevel@tonic-gate break; 108*0Sstevel@tonic-gate } 109*0Sstevel@tonic-gate 110*0Sstevel@tonic-gate if (!xdr_nullstring(xdrs, &objp->policy)) 111*0Sstevel@tonic-gate return (FALSE); 112*0Sstevel@tonic-gate if (!xdr_long(xdrs, &objp->aux_attributes)) 113*0Sstevel@tonic-gate return (FALSE); 114*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->old_key_next)) 115*0Sstevel@tonic-gate return (FALSE); 116*0Sstevel@tonic-gate if (!xdr_krb5_kvno(xdrs, &objp->admin_history_kvno)) 117*0Sstevel@tonic-gate return (FALSE); 118*0Sstevel@tonic-gate if (!xdr_array(xdrs, (caddr_t *) &objp->old_keys, 119*0Sstevel@tonic-gate (unsigned int *) &objp->old_key_len, ~0, 120*0Sstevel@tonic-gate sizeof(osa_pw_hist_ent), 121*0Sstevel@tonic-gate xdr_osa_pw_hist_ent)) 122*0Sstevel@tonic-gate return (FALSE); 123*0Sstevel@tonic-gate return (TRUE); 124*0Sstevel@tonic-gate } 125*0Sstevel@tonic-gate 126*0Sstevel@tonic-gate bool_t 127*0Sstevel@tonic-gate xdr_osa_policy_ent_rec(XDR *xdrs, osa_policy_ent_t objp) 128*0Sstevel@tonic-gate { 129*0Sstevel@tonic-gate switch (xdrs->x_op) { 130*0Sstevel@tonic-gate case XDR_ENCODE: 131*0Sstevel@tonic-gate objp->version = OSA_ADB_POLICY_VERSION_1; 132*0Sstevel@tonic-gate /* fall through */ 133*0Sstevel@tonic-gate case XDR_FREE: 134*0Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->version)) 135*0Sstevel@tonic-gate return FALSE; 136*0Sstevel@tonic-gate break; 137*0Sstevel@tonic-gate case XDR_DECODE: 138*0Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->version)) 139*0Sstevel@tonic-gate return FALSE; 140*0Sstevel@tonic-gate if (objp->version != OSA_ADB_POLICY_VERSION_1) 141*0Sstevel@tonic-gate return FALSE; 142*0Sstevel@tonic-gate break; 143*0Sstevel@tonic-gate } 144*0Sstevel@tonic-gate 145*0Sstevel@tonic-gate if(!xdr_nullstring(xdrs, &objp->name)) 146*0Sstevel@tonic-gate return (FALSE); 147*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->pw_min_life)) 148*0Sstevel@tonic-gate return (FALSE); 149*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->pw_max_life)) 150*0Sstevel@tonic-gate return (FALSE); 151*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->pw_min_length)) 152*0Sstevel@tonic-gate return (FALSE); 153*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->pw_min_classes)) 154*0Sstevel@tonic-gate return (FALSE); 155*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->pw_history_num)) 156*0Sstevel@tonic-gate return (FALSE); 157*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->policy_refcnt)) 158*0Sstevel@tonic-gate return (FALSE); 159*0Sstevel@tonic-gate return (TRUE); 160*0Sstevel@tonic-gate } 161