1*7f2fe78bSCy Schubert /* lib/rpc/authgss_prot.c */
2*7f2fe78bSCy Schubert /*
3*7f2fe78bSCy Schubert Copyright (c) 2000 The Regents of the University of Michigan.
4*7f2fe78bSCy Schubert All rights reserved.
5*7f2fe78bSCy Schubert
6*7f2fe78bSCy Schubert Copyright (c) 2000 Dug Song <dugsong@UMICH.EDU>.
7*7f2fe78bSCy Schubert All rights reserved, all wrongs reversed.
8*7f2fe78bSCy Schubert
9*7f2fe78bSCy Schubert Redistribution and use in source and binary forms, with or without
10*7f2fe78bSCy Schubert modification, are permitted provided that the following conditions
11*7f2fe78bSCy Schubert are met:
12*7f2fe78bSCy Schubert
13*7f2fe78bSCy Schubert 1. Redistributions of source code must retain the above copyright
14*7f2fe78bSCy Schubert notice, this list of conditions and the following disclaimer.
15*7f2fe78bSCy Schubert 2. Redistributions in binary form must reproduce the above copyright
16*7f2fe78bSCy Schubert notice, this list of conditions and the following disclaimer in the
17*7f2fe78bSCy Schubert documentation and/or other materials provided with the distribution.
18*7f2fe78bSCy Schubert 3. Neither the name of the University nor the names of its
19*7f2fe78bSCy Schubert contributors may be used to endorse or promote products derived
20*7f2fe78bSCy Schubert from this software without specific prior written permission.
21*7f2fe78bSCy Schubert
22*7f2fe78bSCy Schubert THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
23*7f2fe78bSCy Schubert WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24*7f2fe78bSCy Schubert MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25*7f2fe78bSCy Schubert DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26*7f2fe78bSCy Schubert FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27*7f2fe78bSCy Schubert CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28*7f2fe78bSCy Schubert SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
29*7f2fe78bSCy Schubert BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30*7f2fe78bSCy Schubert LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31*7f2fe78bSCy Schubert NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32*7f2fe78bSCy Schubert SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33*7f2fe78bSCy Schubert
34*7f2fe78bSCy Schubert Id: authgss_prot.c,v 1.18 2000/09/01 04:14:03 dugsong Exp
35*7f2fe78bSCy Schubert */
36*7f2fe78bSCy Schubert
37*7f2fe78bSCy Schubert #include <stdio.h>
38*7f2fe78bSCy Schubert #include <stdlib.h>
39*7f2fe78bSCy Schubert #include <stdarg.h>
40*7f2fe78bSCy Schubert #include <string.h>
41*7f2fe78bSCy Schubert #include <gssrpc/rpc.h>
42*7f2fe78bSCy Schubert #ifdef HAVE_HEIMDAL
43*7f2fe78bSCy Schubert #include <gssapi.h>
44*7f2fe78bSCy Schubert #else
45*7f2fe78bSCy Schubert #include <gssapi/gssapi.h>
46*7f2fe78bSCy Schubert #endif
47*7f2fe78bSCy Schubert
48*7f2fe78bSCy Schubert bool_t
xdr_rpc_gss_buf(XDR * xdrs,gss_buffer_t buf,u_int maxsize)49*7f2fe78bSCy Schubert xdr_rpc_gss_buf(XDR *xdrs, gss_buffer_t buf, u_int maxsize)
50*7f2fe78bSCy Schubert {
51*7f2fe78bSCy Schubert bool_t xdr_stat;
52*7f2fe78bSCy Schubert u_int tmplen;
53*7f2fe78bSCy Schubert char *cp;
54*7f2fe78bSCy Schubert
55*7f2fe78bSCy Schubert if (xdrs->x_op != XDR_DECODE) {
56*7f2fe78bSCy Schubert if (buf->length > UINT_MAX)
57*7f2fe78bSCy Schubert return (FALSE);
58*7f2fe78bSCy Schubert else
59*7f2fe78bSCy Schubert tmplen = buf->length;
60*7f2fe78bSCy Schubert }
61*7f2fe78bSCy Schubert cp = buf->value;
62*7f2fe78bSCy Schubert xdr_stat = xdr_bytes(xdrs, &cp, &tmplen, maxsize);
63*7f2fe78bSCy Schubert buf->value = cp;
64*7f2fe78bSCy Schubert
65*7f2fe78bSCy Schubert if (xdr_stat && xdrs->x_op == XDR_DECODE)
66*7f2fe78bSCy Schubert buf->length = tmplen;
67*7f2fe78bSCy Schubert
68*7f2fe78bSCy Schubert return (xdr_stat);
69*7f2fe78bSCy Schubert }
70*7f2fe78bSCy Schubert
71*7f2fe78bSCy Schubert bool_t
xdr_rpc_gss_cred(XDR * xdrs,struct rpc_gss_cred * p)72*7f2fe78bSCy Schubert xdr_rpc_gss_cred(XDR *xdrs, struct rpc_gss_cred *p)
73*7f2fe78bSCy Schubert {
74*7f2fe78bSCy Schubert bool_t xdr_stat;
75*7f2fe78bSCy Schubert
76*7f2fe78bSCy Schubert xdr_stat = (xdr_u_int(xdrs, &p->gc_v) &&
77*7f2fe78bSCy Schubert xdr_enum(xdrs, (enum_t *)&p->gc_proc) &&
78*7f2fe78bSCy Schubert xdr_u_int32(xdrs, &p->gc_seq) &&
79*7f2fe78bSCy Schubert xdr_enum(xdrs, (enum_t *)&p->gc_svc) &&
80*7f2fe78bSCy Schubert xdr_rpc_gss_buf(xdrs, &p->gc_ctx, MAX_AUTH_BYTES));
81*7f2fe78bSCy Schubert
82*7f2fe78bSCy Schubert log_debug("xdr_rpc_gss_cred: %s %s "
83*7f2fe78bSCy Schubert "(v %d, proc %d, seq %d, svc %d, ctx %p:%d)",
84*7f2fe78bSCy Schubert (xdrs->x_op == XDR_ENCODE) ? "encode" : "decode",
85*7f2fe78bSCy Schubert (xdr_stat == TRUE) ? "success" : "failure",
86*7f2fe78bSCy Schubert p->gc_v, p->gc_proc, p->gc_seq, p->gc_svc,
87*7f2fe78bSCy Schubert p->gc_ctx.value, p->gc_ctx.length);
88*7f2fe78bSCy Schubert
89*7f2fe78bSCy Schubert return (xdr_stat);
90*7f2fe78bSCy Schubert }
91*7f2fe78bSCy Schubert
92*7f2fe78bSCy Schubert bool_t
xdr_rpc_gss_init_args(XDR * xdrs,gss_buffer_desc * p)93*7f2fe78bSCy Schubert xdr_rpc_gss_init_args(XDR *xdrs, gss_buffer_desc *p)
94*7f2fe78bSCy Schubert {
95*7f2fe78bSCy Schubert bool_t xdr_stat;
96*7f2fe78bSCy Schubert
97*7f2fe78bSCy Schubert xdr_stat = xdr_rpc_gss_buf(xdrs, p, MAX_NETOBJ_SZ);
98*7f2fe78bSCy Schubert
99*7f2fe78bSCy Schubert log_debug("xdr_rpc_gss_init_args: %s %s (token %p:%d)",
100*7f2fe78bSCy Schubert (xdrs->x_op == XDR_ENCODE) ? "encode" : "decode",
101*7f2fe78bSCy Schubert (xdr_stat == TRUE) ? "success" : "failure",
102*7f2fe78bSCy Schubert p->value, p->length);
103*7f2fe78bSCy Schubert
104*7f2fe78bSCy Schubert return (xdr_stat);
105*7f2fe78bSCy Schubert }
106*7f2fe78bSCy Schubert
107*7f2fe78bSCy Schubert bool_t
xdr_rpc_gss_init_res(XDR * xdrs,struct rpc_gss_init_res * p)108*7f2fe78bSCy Schubert xdr_rpc_gss_init_res(XDR *xdrs, struct rpc_gss_init_res *p)
109*7f2fe78bSCy Schubert {
110*7f2fe78bSCy Schubert bool_t xdr_stat;
111*7f2fe78bSCy Schubert
112*7f2fe78bSCy Schubert xdr_stat = (xdr_rpc_gss_buf(xdrs, &p->gr_ctx, MAX_NETOBJ_SZ) &&
113*7f2fe78bSCy Schubert xdr_u_int32(xdrs, &p->gr_major) &&
114*7f2fe78bSCy Schubert xdr_u_int32(xdrs, &p->gr_minor) &&
115*7f2fe78bSCy Schubert xdr_u_int32(xdrs, &p->gr_win) &&
116*7f2fe78bSCy Schubert xdr_rpc_gss_buf(xdrs, &p->gr_token, MAX_NETOBJ_SZ));
117*7f2fe78bSCy Schubert
118*7f2fe78bSCy Schubert log_debug("xdr_rpc_gss_init_res %s %s "
119*7f2fe78bSCy Schubert "(ctx %p:%d, maj %d, min %d, win %d, token %p:%d)",
120*7f2fe78bSCy Schubert (xdrs->x_op == XDR_ENCODE) ? "encode" : "decode",
121*7f2fe78bSCy Schubert (xdr_stat == TRUE) ? "success" : "failure",
122*7f2fe78bSCy Schubert p->gr_ctx.value, p->gr_ctx.length,
123*7f2fe78bSCy Schubert p->gr_major, p->gr_minor, p->gr_win,
124*7f2fe78bSCy Schubert p->gr_token.value, p->gr_token.length);
125*7f2fe78bSCy Schubert
126*7f2fe78bSCy Schubert return (xdr_stat);
127*7f2fe78bSCy Schubert }
128*7f2fe78bSCy Schubert
129*7f2fe78bSCy Schubert bool_t
xdr_rpc_gss_wrap_data(XDR * xdrs,xdrproc_t xdr_func,caddr_t xdr_ptr,gss_ctx_id_t ctx,gss_qop_t qop,rpc_gss_svc_t svc,uint32_t seq)130*7f2fe78bSCy Schubert xdr_rpc_gss_wrap_data(XDR *xdrs, xdrproc_t xdr_func, caddr_t xdr_ptr,
131*7f2fe78bSCy Schubert gss_ctx_id_t ctx, gss_qop_t qop,
132*7f2fe78bSCy Schubert rpc_gss_svc_t svc, uint32_t seq)
133*7f2fe78bSCy Schubert {
134*7f2fe78bSCy Schubert XDR tmpxdrs;
135*7f2fe78bSCy Schubert gss_buffer_desc databuf, wrapbuf;
136*7f2fe78bSCy Schubert OM_uint32 maj_stat, min_stat;
137*7f2fe78bSCy Schubert int conf_state;
138*7f2fe78bSCy Schubert bool_t xdr_stat;
139*7f2fe78bSCy Schubert
140*7f2fe78bSCy Schubert xdralloc_create(&tmpxdrs, XDR_ENCODE);
141*7f2fe78bSCy Schubert
142*7f2fe78bSCy Schubert xdr_stat = FALSE;
143*7f2fe78bSCy Schubert
144*7f2fe78bSCy Schubert /* Marshal rpc_gss_data_t (sequence number + arguments). */
145*7f2fe78bSCy Schubert if (!xdr_u_int32(&tmpxdrs, &seq) || !(*xdr_func)(&tmpxdrs, xdr_ptr))
146*7f2fe78bSCy Schubert goto errout;
147*7f2fe78bSCy Schubert
148*7f2fe78bSCy Schubert /* Set databuf to marshalled rpc_gss_data_t. */
149*7f2fe78bSCy Schubert databuf.length = xdr_getpos(&tmpxdrs);
150*7f2fe78bSCy Schubert databuf.value = xdralloc_getdata(&tmpxdrs);
151*7f2fe78bSCy Schubert
152*7f2fe78bSCy Schubert if (svc == RPCSEC_GSS_SVC_INTEGRITY) {
153*7f2fe78bSCy Schubert if (!xdr_rpc_gss_buf(xdrs, &databuf, (unsigned int)-1))
154*7f2fe78bSCy Schubert goto errout;
155*7f2fe78bSCy Schubert
156*7f2fe78bSCy Schubert /* Checksum rpc_gss_data_t. */
157*7f2fe78bSCy Schubert maj_stat = gss_get_mic(&min_stat, ctx, qop,
158*7f2fe78bSCy Schubert &databuf, &wrapbuf);
159*7f2fe78bSCy Schubert if (maj_stat != GSS_S_COMPLETE) {
160*7f2fe78bSCy Schubert log_debug("gss_get_mic failed");
161*7f2fe78bSCy Schubert goto errout;
162*7f2fe78bSCy Schubert }
163*7f2fe78bSCy Schubert /* Marshal checksum. */
164*7f2fe78bSCy Schubert xdr_stat = xdr_rpc_gss_buf(xdrs, &wrapbuf, (unsigned int)-1);
165*7f2fe78bSCy Schubert gss_release_buffer(&min_stat, &wrapbuf);
166*7f2fe78bSCy Schubert }
167*7f2fe78bSCy Schubert else if (svc == RPCSEC_GSS_SVC_PRIVACY) {
168*7f2fe78bSCy Schubert /* Encrypt rpc_gss_data_t. */
169*7f2fe78bSCy Schubert maj_stat = gss_wrap(&min_stat, ctx, TRUE, qop, &databuf,
170*7f2fe78bSCy Schubert &conf_state, &wrapbuf);
171*7f2fe78bSCy Schubert if (maj_stat != GSS_S_COMPLETE) {
172*7f2fe78bSCy Schubert log_status("gss_wrap", maj_stat, min_stat);
173*7f2fe78bSCy Schubert goto errout;
174*7f2fe78bSCy Schubert }
175*7f2fe78bSCy Schubert /* Marshal databody_priv. */
176*7f2fe78bSCy Schubert xdr_stat = xdr_rpc_gss_buf(xdrs, &wrapbuf, (unsigned int)-1);
177*7f2fe78bSCy Schubert gss_release_buffer(&min_stat, &wrapbuf);
178*7f2fe78bSCy Schubert }
179*7f2fe78bSCy Schubert errout:
180*7f2fe78bSCy Schubert xdr_destroy(&tmpxdrs);
181*7f2fe78bSCy Schubert return (xdr_stat);
182*7f2fe78bSCy Schubert }
183*7f2fe78bSCy Schubert
184*7f2fe78bSCy Schubert bool_t
xdr_rpc_gss_unwrap_data(XDR * xdrs,xdrproc_t xdr_func,caddr_t xdr_ptr,gss_ctx_id_t ctx,gss_qop_t qop,rpc_gss_svc_t svc,uint32_t seq)185*7f2fe78bSCy Schubert xdr_rpc_gss_unwrap_data(XDR *xdrs, xdrproc_t xdr_func, caddr_t xdr_ptr,
186*7f2fe78bSCy Schubert gss_ctx_id_t ctx, gss_qop_t qop,
187*7f2fe78bSCy Schubert rpc_gss_svc_t svc, uint32_t seq)
188*7f2fe78bSCy Schubert {
189*7f2fe78bSCy Schubert XDR tmpxdrs;
190*7f2fe78bSCy Schubert gss_buffer_desc databuf, wrapbuf;
191*7f2fe78bSCy Schubert OM_uint32 maj_stat, min_stat;
192*7f2fe78bSCy Schubert uint32_t seq_num;
193*7f2fe78bSCy Schubert int conf_state;
194*7f2fe78bSCy Schubert gss_qop_t qop_state;
195*7f2fe78bSCy Schubert bool_t xdr_stat;
196*7f2fe78bSCy Schubert
197*7f2fe78bSCy Schubert if (xdr_func == xdr_void || xdr_ptr == NULL)
198*7f2fe78bSCy Schubert return (TRUE);
199*7f2fe78bSCy Schubert
200*7f2fe78bSCy Schubert memset(&databuf, 0, sizeof(databuf));
201*7f2fe78bSCy Schubert memset(&wrapbuf, 0, sizeof(wrapbuf));
202*7f2fe78bSCy Schubert
203*7f2fe78bSCy Schubert if (svc == RPCSEC_GSS_SVC_INTEGRITY) {
204*7f2fe78bSCy Schubert /* Decode databody_integ. */
205*7f2fe78bSCy Schubert if (!xdr_rpc_gss_buf(xdrs, &databuf, (unsigned int)-1)) {
206*7f2fe78bSCy Schubert log_debug("xdr decode databody_integ failed");
207*7f2fe78bSCy Schubert return (FALSE);
208*7f2fe78bSCy Schubert }
209*7f2fe78bSCy Schubert /* Decode checksum. */
210*7f2fe78bSCy Schubert if (!xdr_rpc_gss_buf(xdrs, &wrapbuf, (unsigned int)-1)) {
211*7f2fe78bSCy Schubert gss_release_buffer(&min_stat, &databuf);
212*7f2fe78bSCy Schubert log_debug("xdr decode checksum failed");
213*7f2fe78bSCy Schubert return (FALSE);
214*7f2fe78bSCy Schubert }
215*7f2fe78bSCy Schubert /* Verify checksum and QOP. */
216*7f2fe78bSCy Schubert maj_stat = gss_verify_mic(&min_stat, ctx, &databuf,
217*7f2fe78bSCy Schubert &wrapbuf, &qop_state);
218*7f2fe78bSCy Schubert free(wrapbuf.value);
219*7f2fe78bSCy Schubert
220*7f2fe78bSCy Schubert if (maj_stat != GSS_S_COMPLETE || qop_state != qop) {
221*7f2fe78bSCy Schubert gss_release_buffer(&min_stat, &databuf);
222*7f2fe78bSCy Schubert log_status("gss_verify_mic", maj_stat, min_stat);
223*7f2fe78bSCy Schubert return (FALSE);
224*7f2fe78bSCy Schubert }
225*7f2fe78bSCy Schubert }
226*7f2fe78bSCy Schubert else if (svc == RPCSEC_GSS_SVC_PRIVACY) {
227*7f2fe78bSCy Schubert /* Decode databody_priv. */
228*7f2fe78bSCy Schubert if (!xdr_rpc_gss_buf(xdrs, &wrapbuf, (unsigned int)-1)) {
229*7f2fe78bSCy Schubert log_debug("xdr decode databody_priv failed");
230*7f2fe78bSCy Schubert return (FALSE);
231*7f2fe78bSCy Schubert }
232*7f2fe78bSCy Schubert /* Decrypt databody. */
233*7f2fe78bSCy Schubert maj_stat = gss_unwrap(&min_stat, ctx, &wrapbuf, &databuf,
234*7f2fe78bSCy Schubert &conf_state, &qop_state);
235*7f2fe78bSCy Schubert
236*7f2fe78bSCy Schubert free(wrapbuf.value);
237*7f2fe78bSCy Schubert
238*7f2fe78bSCy Schubert /* Verify encryption and QOP. */
239*7f2fe78bSCy Schubert if (maj_stat != GSS_S_COMPLETE || qop_state != qop ||
240*7f2fe78bSCy Schubert conf_state != TRUE) {
241*7f2fe78bSCy Schubert gss_release_buffer(&min_stat, &databuf);
242*7f2fe78bSCy Schubert log_status("gss_unwrap", maj_stat, min_stat);
243*7f2fe78bSCy Schubert return (FALSE);
244*7f2fe78bSCy Schubert }
245*7f2fe78bSCy Schubert }
246*7f2fe78bSCy Schubert /* Decode rpc_gss_data_t (sequence number + arguments). */
247*7f2fe78bSCy Schubert xdrmem_create(&tmpxdrs, databuf.value, databuf.length, XDR_DECODE);
248*7f2fe78bSCy Schubert xdr_stat = (xdr_u_int32(&tmpxdrs, &seq_num) &&
249*7f2fe78bSCy Schubert (*xdr_func)(&tmpxdrs, xdr_ptr));
250*7f2fe78bSCy Schubert XDR_DESTROY(&tmpxdrs);
251*7f2fe78bSCy Schubert gss_release_buffer(&min_stat, &databuf);
252*7f2fe78bSCy Schubert
253*7f2fe78bSCy Schubert /* Verify sequence number. */
254*7f2fe78bSCy Schubert if (xdr_stat == TRUE && seq_num != seq) {
255*7f2fe78bSCy Schubert log_debug("wrong sequence number in databody");
256*7f2fe78bSCy Schubert return (FALSE);
257*7f2fe78bSCy Schubert }
258*7f2fe78bSCy Schubert return (xdr_stat);
259*7f2fe78bSCy Schubert }
260*7f2fe78bSCy Schubert
261*7f2fe78bSCy Schubert bool_t
xdr_rpc_gss_data(XDR * xdrs,xdrproc_t xdr_func,caddr_t xdr_ptr,gss_ctx_id_t ctx,gss_qop_t qop,rpc_gss_svc_t svc,uint32_t seq)262*7f2fe78bSCy Schubert xdr_rpc_gss_data(XDR *xdrs, xdrproc_t xdr_func, caddr_t xdr_ptr,
263*7f2fe78bSCy Schubert gss_ctx_id_t ctx, gss_qop_t qop,
264*7f2fe78bSCy Schubert rpc_gss_svc_t svc, uint32_t seq)
265*7f2fe78bSCy Schubert {
266*7f2fe78bSCy Schubert switch (xdrs->x_op) {
267*7f2fe78bSCy Schubert
268*7f2fe78bSCy Schubert case XDR_ENCODE:
269*7f2fe78bSCy Schubert return (xdr_rpc_gss_wrap_data(xdrs, xdr_func, xdr_ptr,
270*7f2fe78bSCy Schubert ctx, qop, svc, seq));
271*7f2fe78bSCy Schubert case XDR_DECODE:
272*7f2fe78bSCy Schubert return (xdr_rpc_gss_unwrap_data(xdrs, xdr_func, xdr_ptr,
273*7f2fe78bSCy Schubert ctx, qop,svc, seq));
274*7f2fe78bSCy Schubert case XDR_FREE:
275*7f2fe78bSCy Schubert return (TRUE);
276*7f2fe78bSCy Schubert }
277*7f2fe78bSCy Schubert return (FALSE);
278*7f2fe78bSCy Schubert }
279*7f2fe78bSCy Schubert
280*7f2fe78bSCy Schubert #ifdef DEBUG
281*7f2fe78bSCy Schubert #include <ctype.h>
282*7f2fe78bSCy Schubert
283*7f2fe78bSCy Schubert void
log_debug(const char * fmt,...)284*7f2fe78bSCy Schubert log_debug(const char *fmt, ...)
285*7f2fe78bSCy Schubert {
286*7f2fe78bSCy Schubert va_list ap;
287*7f2fe78bSCy Schubert
288*7f2fe78bSCy Schubert va_start(ap, fmt);
289*7f2fe78bSCy Schubert fprintf(stderr, "rpcsec_gss: ");
290*7f2fe78bSCy Schubert vfprintf(stderr, fmt, ap);
291*7f2fe78bSCy Schubert fprintf(stderr, "\n");
292*7f2fe78bSCy Schubert va_end(ap);
293*7f2fe78bSCy Schubert }
294*7f2fe78bSCy Schubert
295*7f2fe78bSCy Schubert void
log_status(char * m,OM_uint32 maj_stat,OM_uint32 min_stat)296*7f2fe78bSCy Schubert log_status(char *m, OM_uint32 maj_stat, OM_uint32 min_stat)
297*7f2fe78bSCy Schubert {
298*7f2fe78bSCy Schubert OM_uint32 min, msg_ctx;
299*7f2fe78bSCy Schubert gss_buffer_desc msgg, msgm;
300*7f2fe78bSCy Schubert
301*7f2fe78bSCy Schubert msg_ctx = 0;
302*7f2fe78bSCy Schubert gss_display_status(&min, maj_stat, GSS_C_GSS_CODE, GSS_C_NULL_OID,
303*7f2fe78bSCy Schubert &msg_ctx, &msgg);
304*7f2fe78bSCy Schubert msg_ctx = 0;
305*7f2fe78bSCy Schubert gss_display_status(&min, min_stat, GSS_C_MECH_CODE, GSS_C_NULL_OID,
306*7f2fe78bSCy Schubert &msg_ctx, &msgm);
307*7f2fe78bSCy Schubert
308*7f2fe78bSCy Schubert log_debug("%s: %.*s - %.*s\n", m,
309*7f2fe78bSCy Schubert msgg.length, (char *)msgg.value,
310*7f2fe78bSCy Schubert msgm.length, (char *)msgm.value);
311*7f2fe78bSCy Schubert
312*7f2fe78bSCy Schubert gss_release_buffer(&min, &msgg);
313*7f2fe78bSCy Schubert gss_release_buffer(&min, &msgm);
314*7f2fe78bSCy Schubert }
315*7f2fe78bSCy Schubert
316*7f2fe78bSCy Schubert void
log_hexdump(const u_char * buf,int len,int offset)317*7f2fe78bSCy Schubert log_hexdump(const u_char *buf, int len, int offset)
318*7f2fe78bSCy Schubert {
319*7f2fe78bSCy Schubert u_int i, j, jm;
320*7f2fe78bSCy Schubert int c;
321*7f2fe78bSCy Schubert
322*7f2fe78bSCy Schubert fprintf(stderr, "\n");
323*7f2fe78bSCy Schubert for (i = 0; i < len; i += 0x10) {
324*7f2fe78bSCy Schubert fprintf(stderr, " %04x: ", (u_int)(i + offset));
325*7f2fe78bSCy Schubert jm = len - i;
326*7f2fe78bSCy Schubert jm = jm > 16 ? 16 : jm;
327*7f2fe78bSCy Schubert
328*7f2fe78bSCy Schubert for (j = 0; j < jm; j++) {
329*7f2fe78bSCy Schubert if ((j % 2) == 1)
330*7f2fe78bSCy Schubert fprintf(stderr, "%02x ", (u_int) buf[i+j]);
331*7f2fe78bSCy Schubert else
332*7f2fe78bSCy Schubert fprintf(stderr, "%02x", (u_int) buf[i+j]);
333*7f2fe78bSCy Schubert }
334*7f2fe78bSCy Schubert for (; j < 16; j++) {
335*7f2fe78bSCy Schubert if ((j % 2) == 1) printf(" ");
336*7f2fe78bSCy Schubert else fprintf(stderr, " ");
337*7f2fe78bSCy Schubert }
338*7f2fe78bSCy Schubert fprintf(stderr, " ");
339*7f2fe78bSCy Schubert
340*7f2fe78bSCy Schubert for (j = 0; j < jm; j++) {
341*7f2fe78bSCy Schubert c = buf[i+j];
342*7f2fe78bSCy Schubert c = isprint(c) ? c : '.';
343*7f2fe78bSCy Schubert fprintf(stderr, "%c", c);
344*7f2fe78bSCy Schubert }
345*7f2fe78bSCy Schubert fprintf(stderr, "\n");
346*7f2fe78bSCy Schubert }
347*7f2fe78bSCy Schubert }
348*7f2fe78bSCy Schubert
349*7f2fe78bSCy Schubert #else
350*7f2fe78bSCy Schubert
351*7f2fe78bSCy Schubert void
log_debug(const char * fmt,...)352*7f2fe78bSCy Schubert log_debug(const char *fmt, ...)
353*7f2fe78bSCy Schubert {
354*7f2fe78bSCy Schubert }
355*7f2fe78bSCy Schubert
356*7f2fe78bSCy Schubert void
log_status(char * m,OM_uint32 maj_stat,OM_uint32 min_stat)357*7f2fe78bSCy Schubert log_status(char *m, OM_uint32 maj_stat, OM_uint32 min_stat)
358*7f2fe78bSCy Schubert {
359*7f2fe78bSCy Schubert }
360*7f2fe78bSCy Schubert
361*7f2fe78bSCy Schubert void
log_hexdump(const u_char * buf,int len,int offset)362*7f2fe78bSCy Schubert log_hexdump(const u_char *buf, int len, int offset)
363*7f2fe78bSCy Schubert {
364*7f2fe78bSCy Schubert }
365*7f2fe78bSCy Schubert
366*7f2fe78bSCy Schubert #endif
367