1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 23 /* 24 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 25 * Use is subject to license terms. 26 */ 27 28 #pragma ident "%Z%%M% %I% %E% SMI" 29 30 #include <rpc/rpc.h> 31 #include <rpc/key_prot.h> 32 33 /* 34 * Originally ompiled from key_prot.x using rpcgen. 35 */ 36 37 bool_t 38 xdr_keystatus(XDR *xdrs, keystatus *objp) 39 { 40 return (xdr_enum(xdrs, (enum_t *)objp)); 41 } 42 43 bool_t 44 xdr_keybuf(XDR *xdrs, keybuf objp) 45 { 46 return (xdr_opaque(xdrs, objp, HEXKEYBYTES)); 47 } 48 49 bool_t 50 xdr_keybuf3(XDR *xdrs, keybuf3 *objp) 51 { 52 return (xdr_bytes(xdrs, (char **)&objp->keybuf3_val, 53 (uint_t *)&objp->keybuf3_len, ~0)); 54 } 55 56 bool_t 57 xdr_netnamestr(XDR *xdrs, netnamestr *objp) 58 { 59 return (xdr_string(xdrs, objp, MAXNETNAMELEN)); 60 } 61 62 bool_t 63 xdr_keylen_t(XDR *xdrs, keylen_t *objp) 64 { 65 return (xdr_int(xdrs, objp)); 66 } 67 68 bool_t 69 xdr_algtype_t(XDR *xdrs, algtype_t *objp) 70 { 71 return (xdr_int(xdrs, objp)); 72 } 73 74 bool_t 75 xdr_mechtype(XDR *xdrs, mechtype *objp) 76 { 77 if (!xdr_keylen_t(xdrs, &objp->keylen)) 78 return (FALSE); 79 return (xdr_algtype_t(xdrs, &objp->algtype)); 80 } 81 82 bool_t 83 xdr_keynum_t(XDR *xdrs, keynum_t *objp) 84 { 85 return (xdr_int(xdrs, objp)); 86 } 87 88 bool_t 89 xdr_deskeyarray(XDR *xdrs, deskeyarray *objp) 90 { 91 return (xdr_array(xdrs, (char **)&objp->deskeyarray_val, 92 (uint_t *)&objp->deskeyarray_len, ~0, 93 sizeof (des_block), (xdrproc_t)xdr_des_block)); 94 } 95 96 bool_t 97 xdr_cryptkeyarg(XDR *xdrs, cryptkeyarg *objp) 98 { 99 if (!xdr_netnamestr(xdrs, &objp->remotename)) 100 return (FALSE); 101 return (xdr_des_block(xdrs, &objp->deskey)); 102 } 103 104 bool_t 105 xdr_cryptkeyarg2(XDR *xdrs, cryptkeyarg2 *objp) 106 { 107 if (!xdr_netnamestr(xdrs, &objp->remotename)) 108 return (FALSE); 109 if (!xdr_netobj(xdrs, &objp->remotekey)) 110 return (FALSE); 111 return (xdr_des_block(xdrs, &objp->deskey)); 112 } 113 114 bool_t 115 xdr_cryptkeyarg3(XDR *xdrs, cryptkeyarg3 *objp) 116 { 117 if (!xdr_netnamestr(xdrs, &objp->remotename)) 118 return (FALSE); 119 if (!xdr_keybuf3(xdrs, &objp->remotekey)) 120 return (FALSE); 121 if (!xdr_deskeyarray(xdrs, &objp->deskey)) 122 return (FALSE); 123 if (!xdr_algtype_t(xdrs, &objp->algtype)) 124 return (FALSE); 125 return (xdr_keylen_t(xdrs, &objp->keylen)); 126 } 127 128 bool_t 129 xdr_cryptkeyres(XDR *xdrs, cryptkeyres *objp) 130 { 131 if (!xdr_keystatus(xdrs, &objp->status)) 132 return (FALSE); 133 if (objp->status != KEY_SUCCESS) 134 return (TRUE); 135 return (xdr_des_block(xdrs, &objp->cryptkeyres_u.deskey)); 136 } 137 138 bool_t 139 xdr_cryptkeyres3(XDR *xdrs, cryptkeyres3 *objp) 140 { 141 if (!xdr_keystatus(xdrs, &objp->status)) 142 return (FALSE); 143 if (objp->status != KEY_SUCCESS) 144 return (TRUE); 145 return (xdr_deskeyarray(xdrs, &objp->cryptkeyres3_u.deskey)); 146 } 147 148 bool_t 149 xdr_unixcred(XDR *xdrs, unixcred *objp) 150 { 151 if (!xdr_u_int(xdrs, &objp->uid)) 152 return (FALSE); 153 if (!xdr_u_int(xdrs, &objp->gid)) 154 return (FALSE); 155 return (xdr_array(xdrs, (char **)&objp->gids.gids_val, 156 (uint_t *)&objp->gids.gids_len, MAXGIDS, 157 sizeof (uint_t), (xdrproc_t)xdr_u_int)); 158 } 159 160 bool_t 161 xdr_unixcred3(XDR *xdrs, unixcred3 *objp) 162 { 163 if (!xdr_u_int(xdrs, &objp->uid)) 164 return (FALSE); 165 if (!xdr_u_int(xdrs, &objp->gid)) 166 return (FALSE); 167 return (xdr_array(xdrs, (char **)&objp->gids.gids_val, 168 (uint_t *)&objp->gids.gids_len, ~0, 169 sizeof (uint_t), (xdrproc_t)xdr_u_int)); 170 } 171 172 bool_t 173 xdr_getcredres(XDR *xdrs, getcredres *objp) 174 { 175 if (!xdr_keystatus(xdrs, &objp->status)) 176 return (FALSE); 177 if (objp->status != KEY_SUCCESS) 178 return (TRUE); 179 return (xdr_unixcred(xdrs, &objp->getcredres_u.cred)); 180 } 181 182 bool_t 183 xdr_getcredres3(XDR *xdrs, getcredres3 *objp) 184 { 185 if (!xdr_keystatus(xdrs, &objp->status)) 186 return (FALSE); 187 if (objp->status != KEY_SUCCESS) 188 return (TRUE); 189 return (xdr_unixcred3(xdrs, &objp->getcredres3_u.cred)); 190 } 191 192 bool_t 193 xdr_key_netstarg(XDR *xdrs, key_netstarg *objp) 194 { 195 if (!xdr_keybuf(xdrs, objp->st_priv_key)) 196 return (FALSE); 197 if (!xdr_keybuf(xdrs, objp->st_pub_key)) 198 return (FALSE); 199 return (xdr_netnamestr(xdrs, &objp->st_netname)); 200 } 201 202 bool_t 203 xdr_key_netstarg3(XDR *xdrs, key_netstarg3 *objp) 204 { 205 if (!xdr_keybuf3(xdrs, &objp->st_priv_key)) 206 return (FALSE); 207 if (!xdr_keybuf3(xdrs, &objp->st_pub_key)) 208 return (FALSE); 209 if (!xdr_netnamestr(xdrs, &objp->st_netname)) 210 return (FALSE); 211 if (!xdr_algtype_t(xdrs, &objp->algtype)) 212 return (FALSE); 213 if (!xdr_keylen_t(xdrs, &objp->keylen)) 214 return (FALSE); 215 return (xdr_des_block(xdrs, &objp->userkey)); 216 } 217 218 bool_t 219 xdr_key_netstres(XDR *xdrs, key_netstres *objp) 220 { 221 if (!xdr_keystatus(xdrs, &objp->status)) 222 return (FALSE); 223 switch (objp->status) { 224 case KEY_SUCCESS: 225 if (!xdr_key_netstarg(xdrs, &objp->key_netstres_u.knet)) 226 return (FALSE); 227 break; 228 } 229 return (TRUE); 230 } 231 232 bool_t 233 xdr_key_netstres3(XDR *xdrs, key_netstres3 *objp) 234 { 235 if (!xdr_keystatus(xdrs, &objp->status)) 236 return (FALSE); 237 if (objp->status != KEY_SUCCESS) 238 return (TRUE); 239 return (xdr_key_netstarg3(xdrs, &objp->key_netstres3_u.knet)); 240 } 241 242 bool_t 243 xdr_deskeyarg3(XDR *xdrs, deskeyarg3 *objp) 244 { 245 if (!xdr_keybuf3(xdrs, &objp->pub_key)) 246 return (FALSE); 247 if (!xdr_int(xdrs, &objp->nkeys)) 248 return (FALSE); 249 if (!xdr_algtype_t(xdrs, &objp->algtype)) 250 return (FALSE); 251 return (xdr_keylen_t(xdrs, &objp->keylen)); 252 } 253 254 bool_t 255 xdr_setkeyarg3(XDR *xdrs, setkeyarg3 *objp) 256 { 257 if (!xdr_keybuf3(xdrs, &objp->key)) 258 return (FALSE); 259 if (!xdr_des_block(xdrs, &objp->userkey)) 260 return (FALSE); 261 if (!xdr_algtype_t(xdrs, &objp->algtype)) 262 return (FALSE); 263 return (xdr_keylen_t(xdrs, &objp->keylen)); 264 } 265