]> git.ipfire.org Git - thirdparty/glibc.git/blame - sunrpc/key_prot.c
Once again change RPC copyright notices.
[thirdparty/glibc.git] / sunrpc / key_prot.c
CommitLineData
a7ab6ec8 1/* Copyright (c) 2010, Oracle America, Inc.
800d775e 2 *
a7ab6ec8
UD
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
800d775e 6 *
a7ab6ec8
UD
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above
10 * copyright notice, this list of conditions and the following
11 * disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 * * Neither the name of the "Oracle America, Inc." nor the names of its
14 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
800d775e 16 *
a7ab6ec8
UD
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
800d775e 29 */
800d775e
UD
30
31#include "rpc/key_prot.h"
32
33bool_t
34xdr_keystatus (XDR * xdrs, keystatus * objp)
35{
77fe0b9c 36 if (!INTUSE(xdr_enum) (xdrs, (enum_t *) objp))
800d775e
UD
37 return FALSE;
38
39 return TRUE;
40}
77fe0b9c 41INTDEF(xdr_keystatus)
800d775e
UD
42
43bool_t
44xdr_keybuf (XDR * xdrs, keybuf objp)
45{
77fe0b9c 46 if (!INTUSE(xdr_opaque) (xdrs, objp, HEXKEYBYTES))
800d775e
UD
47 return FALSE;
48
49 return TRUE;
50}
77fe0b9c 51INTDEF(xdr_keybuf)
800d775e
UD
52
53bool_t
54xdr_netnamestr (XDR * xdrs, netnamestr * objp)
55{
77fe0b9c 56 if (!INTUSE(xdr_string) (xdrs, objp, MAXNETNAMELEN))
800d775e
UD
57 return FALSE;
58
59 return TRUE;
60}
77fe0b9c 61INTDEF(xdr_netnamestr)
800d775e
UD
62
63bool_t
64xdr_cryptkeyarg (XDR * xdrs, cryptkeyarg * objp)
65{
77fe0b9c 66 if (!INTUSE(xdr_netnamestr) (xdrs, &objp->remotename))
800d775e
UD
67 return FALSE;
68
77fe0b9c 69 if (!INTUSE(xdr_des_block) (xdrs, &objp->deskey))
800d775e
UD
70 return FALSE;
71
72 return TRUE;
73}
77fe0b9c 74INTDEF(xdr_cryptkeyarg)
800d775e
UD
75
76bool_t
77xdr_cryptkeyarg2 (XDR * xdrs, cryptkeyarg2 * objp)
78{
77fe0b9c 79 if (!INTUSE(xdr_netnamestr) (xdrs, &objp->remotename))
800d775e 80 return FALSE;
77fe0b9c 81 if (!INTUSE(xdr_netobj) (xdrs, &objp->remotekey))
800d775e 82 return FALSE;
77fe0b9c 83 if (!INTUSE(xdr_des_block) (xdrs, &objp->deskey))
800d775e
UD
84 return FALSE;
85 return TRUE;
86}
77fe0b9c 87INTDEF(xdr_cryptkeyarg2)
800d775e
UD
88
89bool_t
90xdr_cryptkeyres (XDR * xdrs, cryptkeyres * objp)
91{
77fe0b9c 92 if (!INTUSE(xdr_keystatus) (xdrs, &objp->status))
800d775e
UD
93 return FALSE;
94 switch (objp->status)
95 {
96 case KEY_SUCCESS:
77fe0b9c 97 if (!INTUSE(xdr_des_block) (xdrs, &objp->cryptkeyres_u.deskey))
800d775e
UD
98 return FALSE;
99 break;
100 default:
101 break;
102 }
103 return TRUE;
104}
77fe0b9c 105INTDEF(xdr_cryptkeyres)
800d775e
UD
106
107bool_t
108xdr_unixcred (XDR * xdrs, unixcred * objp)
109{
77fe0b9c 110 if (!INTUSE(xdr_u_int) (xdrs, &objp->uid))
800d775e 111 return FALSE;
77fe0b9c 112 if (!INTUSE(xdr_u_int) (xdrs, &objp->gid))
800d775e 113 return FALSE;
8f1fe057 114 if (!INTUSE(xdr_array) (xdrs, (void *) &objp->gids.gids_val,
77fe0b9c
UD
115 (u_int *) & objp->gids.gids_len, MAXGIDS,
116 sizeof (u_int), (xdrproc_t) INTUSE(xdr_u_int)))
800d775e
UD
117 return FALSE;
118 return TRUE;
119}
77fe0b9c 120INTDEF(xdr_unixcred)
800d775e
UD
121
122bool_t
123xdr_getcredres (XDR * xdrs, getcredres * objp)
124{
77fe0b9c 125 if (!INTUSE(xdr_keystatus) (xdrs, &objp->status))
800d775e
UD
126 return FALSE;
127 switch (objp->status)
128 {
129 case KEY_SUCCESS:
77fe0b9c 130 if (!INTUSE(xdr_unixcred) (xdrs, &objp->getcredres_u.cred))
800d775e
UD
131 return FALSE;
132 break;
133 default:
134 break;
135 }
136 return TRUE;
137}
138
139bool_t
140xdr_key_netstarg (XDR * xdrs, key_netstarg * objp)
141{
77fe0b9c 142 if (!INTUSE(xdr_keybuf) (xdrs, objp->st_priv_key))
800d775e 143 return FALSE;
77fe0b9c 144 if (!INTUSE(xdr_keybuf) (xdrs, objp->st_pub_key))
800d775e 145 return FALSE;
77fe0b9c 146 if (!INTUSE(xdr_netnamestr) (xdrs, &objp->st_netname))
800d775e
UD
147 return FALSE;
148 return TRUE;
149}
77fe0b9c 150INTDEF(xdr_key_netstarg)
800d775e
UD
151
152bool_t
153xdr_key_netstres (XDR * xdrs, key_netstres * objp)
154{
77fe0b9c 155 if (!INTUSE(xdr_keystatus) (xdrs, &objp->status))
800d775e
UD
156 return FALSE;
157 switch (objp->status)
158 {
159 case KEY_SUCCESS:
77fe0b9c 160 if (!INTUSE(xdr_key_netstarg) (xdrs, &objp->key_netstres_u.knet))
800d775e
UD
161 return FALSE;
162 break;
163 default:
164 break;
165 }
166 return TRUE;
167}
77fe0b9c 168INTDEF(xdr_key_netstres)