import less(1)
[unleashed/tickless.git] / usr / src / lib / libc / port / nsl / key_prot.c
bloba1765efdfc27a4cef8b195bdd53f95fd7124d20a
1 /*
2 * CDDL HEADER START
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.
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.
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]
20 * CDDL HEADER END
24 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
28 #pragma ident "%Z%%M% %I% %E% SMI"
30 #include "mt.h"
31 #include <rpc/rpc.h>
32 #include <rpc/key_prot.h>
35 * Originally ompiled from key_prot.x using rpcgen.
38 bool_t
39 xdr_keystatus(XDR *xdrs, keystatus *objp)
41 return (xdr_enum(xdrs, (enum_t *)objp));
44 bool_t
45 xdr_keybuf(XDR *xdrs, keybuf objp)
47 return (xdr_opaque(xdrs, objp, HEXKEYBYTES));
50 bool_t
51 xdr_keybuf3(XDR *xdrs, keybuf3 *objp)
53 return (xdr_bytes(xdrs, (char **)&objp->keybuf3_val,
54 (uint_t *)&objp->keybuf3_len, ~0));
57 bool_t
58 xdr_netnamestr(XDR *xdrs, netnamestr *objp)
60 return (xdr_string(xdrs, objp, MAXNETNAMELEN));
63 bool_t
64 xdr_keylen_t(XDR *xdrs, keylen_t *objp)
66 return (xdr_int(xdrs, objp));
69 bool_t
70 xdr_algtype_t(XDR *xdrs, algtype_t *objp)
72 return (xdr_int(xdrs, objp));
75 bool_t
76 xdr_mechtype(XDR *xdrs, mechtype *objp)
78 if (!xdr_keylen_t(xdrs, &objp->keylen))
79 return (FALSE);
80 return (xdr_algtype_t(xdrs, &objp->algtype));
83 bool_t
84 xdr_keynum_t(XDR *xdrs, keynum_t *objp)
86 return (xdr_int(xdrs, objp));
89 bool_t
90 xdr_deskeyarray(XDR *xdrs, deskeyarray *objp)
92 return (xdr_array(xdrs, (char **)&objp->deskeyarray_val,
93 (uint_t *)&objp->deskeyarray_len, ~0,
94 sizeof (des_block), (xdrproc_t)xdr_des_block));
97 bool_t
98 xdr_cryptkeyarg(XDR *xdrs, cryptkeyarg *objp)
100 if (!xdr_netnamestr(xdrs, &objp->remotename))
101 return (FALSE);
102 return (xdr_des_block(xdrs, &objp->deskey));
105 bool_t
106 xdr_cryptkeyarg2(XDR *xdrs, cryptkeyarg2 *objp)
108 if (!xdr_netnamestr(xdrs, &objp->remotename))
109 return (FALSE);
110 if (!xdr_netobj(xdrs, &objp->remotekey))
111 return (FALSE);
112 return (xdr_des_block(xdrs, &objp->deskey));
115 bool_t
116 xdr_cryptkeyarg3(XDR *xdrs, cryptkeyarg3 *objp)
118 if (!xdr_netnamestr(xdrs, &objp->remotename))
119 return (FALSE);
120 if (!xdr_keybuf3(xdrs, &objp->remotekey))
121 return (FALSE);
122 if (!xdr_deskeyarray(xdrs, &objp->deskey))
123 return (FALSE);
124 if (!xdr_algtype_t(xdrs, &objp->algtype))
125 return (FALSE);
126 return (xdr_keylen_t(xdrs, &objp->keylen));
129 bool_t
130 xdr_cryptkeyres(XDR *xdrs, cryptkeyres *objp)
132 if (!xdr_keystatus(xdrs, &objp->status))
133 return (FALSE);
134 if (objp->status != KEY_SUCCESS)
135 return (TRUE);
136 return (xdr_des_block(xdrs, &objp->cryptkeyres_u.deskey));
139 bool_t
140 xdr_cryptkeyres3(XDR *xdrs, cryptkeyres3 *objp)
142 if (!xdr_keystatus(xdrs, &objp->status))
143 return (FALSE);
144 if (objp->status != KEY_SUCCESS)
145 return (TRUE);
146 return (xdr_deskeyarray(xdrs, &objp->cryptkeyres3_u.deskey));
149 bool_t
150 xdr_unixcred(XDR *xdrs, unixcred *objp)
152 if (!xdr_u_int(xdrs, &objp->uid))
153 return (FALSE);
154 if (!xdr_u_int(xdrs, &objp->gid))
155 return (FALSE);
156 return (xdr_array(xdrs, (char **)&objp->gids.gids_val,
157 (uint_t *)&objp->gids.gids_len, MAXGIDS,
158 sizeof (uint_t), (xdrproc_t)xdr_u_int));
161 bool_t
162 xdr_unixcred3(XDR *xdrs, unixcred3 *objp)
164 if (!xdr_u_int(xdrs, &objp->uid))
165 return (FALSE);
166 if (!xdr_u_int(xdrs, &objp->gid))
167 return (FALSE);
168 return (xdr_array(xdrs, (char **)&objp->gids.gids_val,
169 (uint_t *)&objp->gids.gids_len, ~0,
170 sizeof (uint_t), (xdrproc_t)xdr_u_int));
173 bool_t
174 xdr_getcredres(XDR *xdrs, getcredres *objp)
176 if (!xdr_keystatus(xdrs, &objp->status))
177 return (FALSE);
178 if (objp->status != KEY_SUCCESS)
179 return (TRUE);
180 return (xdr_unixcred(xdrs, &objp->getcredres_u.cred));
183 bool_t
184 xdr_getcredres3(XDR *xdrs, getcredres3 *objp)
186 if (!xdr_keystatus(xdrs, &objp->status))
187 return (FALSE);
188 if (objp->status != KEY_SUCCESS)
189 return (TRUE);
190 return (xdr_unixcred3(xdrs, &objp->getcredres3_u.cred));
193 bool_t
194 xdr_key_netstarg(XDR *xdrs, key_netstarg *objp)
196 if (!xdr_keybuf(xdrs, objp->st_priv_key))
197 return (FALSE);
198 if (!xdr_keybuf(xdrs, objp->st_pub_key))
199 return (FALSE);
200 return (xdr_netnamestr(xdrs, &objp->st_netname));
203 bool_t
204 xdr_key_netstarg3(XDR *xdrs, key_netstarg3 *objp)
206 if (!xdr_keybuf3(xdrs, &objp->st_priv_key))
207 return (FALSE);
208 if (!xdr_keybuf3(xdrs, &objp->st_pub_key))
209 return (FALSE);
210 if (!xdr_netnamestr(xdrs, &objp->st_netname))
211 return (FALSE);
212 if (!xdr_algtype_t(xdrs, &objp->algtype))
213 return (FALSE);
214 if (!xdr_keylen_t(xdrs, &objp->keylen))
215 return (FALSE);
216 return (xdr_des_block(xdrs, &objp->userkey));
219 bool_t
220 xdr_key_netstres(XDR *xdrs, key_netstres *objp)
222 if (!xdr_keystatus(xdrs, &objp->status))
223 return (FALSE);
224 switch (objp->status) {
225 case KEY_SUCCESS:
226 if (!xdr_key_netstarg(xdrs, &objp->key_netstres_u.knet))
227 return (FALSE);
228 break;
230 return (TRUE);
233 bool_t
234 xdr_key_netstres3(XDR *xdrs, key_netstres3 *objp)
236 if (!xdr_keystatus(xdrs, &objp->status))
237 return (FALSE);
238 if (objp->status != KEY_SUCCESS)
239 return (TRUE);
240 return (xdr_key_netstarg3(xdrs, &objp->key_netstres3_u.knet));
243 bool_t
244 xdr_deskeyarg3(XDR *xdrs, deskeyarg3 *objp)
246 if (!xdr_keybuf3(xdrs, &objp->pub_key))
247 return (FALSE);
248 if (!xdr_int(xdrs, &objp->nkeys))
249 return (FALSE);
250 if (!xdr_algtype_t(xdrs, &objp->algtype))
251 return (FALSE);
252 return (xdr_keylen_t(xdrs, &objp->keylen));
255 bool_t
256 xdr_setkeyarg3(XDR *xdrs, setkeyarg3 *objp)
258 if (!xdr_keybuf3(xdrs, &objp->key))
259 return (FALSE);
260 if (!xdr_des_block(xdrs, &objp->userkey))
261 return (FALSE);
262 if (!xdr_algtype_t(xdrs, &objp->algtype))
263 return (FALSE);
264 return (xdr_keylen_t(xdrs, &objp->keylen));