664013a71b9d2b3248f8336dfc820580b43ca931
[platform/upstream/glibc.git] / sunrpc / key_prot.c
1 /*
2  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
3  * unrestricted use provided that this legend is included on all tape
4  * media and as a part of the software program in whole or part.  Users
5  * may copy or modify Sun RPC without charge, but are not authorized
6  * to license or distribute it to anyone else except as part of a product or
7  * program developed by the user.
8  *
9  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
10  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
11  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
12  *
13  * Sun RPC is provided with no support and without any obligation on the
14  * part of Sun Microsystems, Inc. to assist in its use, correction,
15  * modification or enhancement.
16  *
17  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
18  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
19  * OR ANY PART THEREOF.
20  *
21  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
22  * or profits or other special, indirect and consequential damages, even if
23  * Sun has been advised of the possibility of such damages.
24  *
25  * Sun Microsystems, Inc.
26  * 2550 Garcia Avenue
27  * Mountain View, California  94043
28  */
29 #if 0
30 #pragma ident   "@(#)key_prot.x 1.7     94/04/29 SMI"
31 #endif
32
33 /* Copyright (c)  1990, 1991 Sun Microsystems, Inc. */
34
35 #include "rpc/key_prot.h"
36
37 bool_t
38 xdr_keystatus (XDR * xdrs, keystatus * objp)
39 {
40   if (!xdr_enum (xdrs, (enum_t *) objp))
41     return FALSE;
42
43   return TRUE;
44 }
45
46 bool_t
47 xdr_keybuf (XDR * xdrs, keybuf objp)
48 {
49   if (!xdr_opaque (xdrs, objp, HEXKEYBYTES))
50     return FALSE;
51
52   return TRUE;
53 }
54
55 bool_t
56 xdr_netnamestr (XDR * xdrs, netnamestr * objp)
57 {
58   if (!xdr_string (xdrs, objp, MAXNETNAMELEN))
59     return FALSE;
60
61   return TRUE;
62 }
63
64 bool_t
65 xdr_cryptkeyarg (XDR * xdrs, cryptkeyarg * objp)
66 {
67   if (!xdr_netnamestr (xdrs, &objp->remotename))
68     return FALSE;
69
70   if (!xdr_des_block (xdrs, &objp->deskey))
71     return FALSE;
72
73   return TRUE;
74 }
75
76 bool_t
77 xdr_cryptkeyarg2 (XDR * xdrs, cryptkeyarg2 * objp)
78 {
79   if (!xdr_netnamestr (xdrs, &objp->remotename))
80     return FALSE;
81   if (!xdr_netobj (xdrs, &objp->remotekey))
82     return FALSE;
83   if (!xdr_des_block (xdrs, &objp->deskey))
84     return FALSE;
85   return TRUE;
86 }
87
88 bool_t
89 xdr_cryptkeyres (XDR * xdrs, cryptkeyres * objp)
90 {
91   if (!xdr_keystatus (xdrs, &objp->status))
92     return FALSE;
93   switch (objp->status)
94     {
95     case KEY_SUCCESS:
96       if (!xdr_des_block (xdrs, &objp->cryptkeyres_u.deskey))
97         return FALSE;
98       break;
99     default:
100       break;
101     }
102   return TRUE;
103 }
104
105 bool_t
106 xdr_unixcred (XDR * xdrs, unixcred * objp)
107 {
108   if (!xdr_u_int (xdrs, &objp->uid))
109     return FALSE;
110   if (!xdr_u_int (xdrs, &objp->gid))
111     return FALSE;
112   if (!xdr_array (xdrs, (char **) &objp->gids.gids_val,
113                   (u_int *) & objp->gids.gids_len, MAXGIDS,
114                   sizeof (u_int), (xdrproc_t) xdr_u_int))
115     return FALSE;
116   return TRUE;
117 }
118
119 bool_t
120 xdr_getcredres (XDR * xdrs, getcredres * objp)
121 {
122   if (!xdr_keystatus (xdrs, &objp->status))
123     return FALSE;
124   switch (objp->status)
125     {
126     case KEY_SUCCESS:
127       if (!xdr_unixcred (xdrs, &objp->getcredres_u.cred))
128         return FALSE;
129       break;
130     default:
131       break;
132     }
133   return TRUE;
134 }
135
136 bool_t
137 xdr_key_netstarg (XDR * xdrs, key_netstarg * objp)
138 {
139   if (!xdr_keybuf (xdrs, objp->st_priv_key))
140     return FALSE;
141   if (!xdr_keybuf (xdrs, objp->st_pub_key))
142     return FALSE;
143   if (!xdr_netnamestr (xdrs, &objp->st_netname))
144     return FALSE;
145   return TRUE;
146 }
147
148 bool_t
149 xdr_key_netstres (XDR * xdrs, key_netstres * objp)
150 {
151   if (!xdr_keystatus (xdrs, &objp->status))
152     return FALSE;
153   switch (objp->status)
154     {
155     case KEY_SUCCESS:
156       if (!xdr_key_netstarg (xdrs, &objp->key_netstres_u.knet))
157         return FALSE;
158       break;
159     default:
160       break;
161     }
162   return TRUE;
163 }