xref: /illumos-gate/usr/src/lib/gss_mechs/mech_krb5/mech/disp_major_status.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
2*7c478bd9Sstevel@tonic-gate /*
3*7c478bd9Sstevel@tonic-gate  * Copyright 1993 by OpenVision Technologies, Inc.
4*7c478bd9Sstevel@tonic-gate  *
5*7c478bd9Sstevel@tonic-gate  * Permission to use, copy, modify, distribute, and sell this software
6*7c478bd9Sstevel@tonic-gate  * and its documentation for any purpose is hereby granted without fee,
7*7c478bd9Sstevel@tonic-gate  * provided that the above copyright notice appears in all copies and
8*7c478bd9Sstevel@tonic-gate  * that both that copyright notice and this permission notice appear in
9*7c478bd9Sstevel@tonic-gate  * supporting documentation, and that the name of OpenVision not be used
10*7c478bd9Sstevel@tonic-gate  * in advertising or publicity pertaining to distribution of the software
11*7c478bd9Sstevel@tonic-gate  * without specific, written prior permission. OpenVision makes no
12*7c478bd9Sstevel@tonic-gate  * representations about the suitability of this software for any
13*7c478bd9Sstevel@tonic-gate  * purpose.  It is provided "as is" without express or implied warranty.
14*7c478bd9Sstevel@tonic-gate  *
15*7c478bd9Sstevel@tonic-gate  * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16*7c478bd9Sstevel@tonic-gate  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
17*7c478bd9Sstevel@tonic-gate  * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18*7c478bd9Sstevel@tonic-gate  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
19*7c478bd9Sstevel@tonic-gate  * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
20*7c478bd9Sstevel@tonic-gate  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21*7c478bd9Sstevel@tonic-gate  * PERFORMANCE OF THIS SOFTWARE.
22*7c478bd9Sstevel@tonic-gate  */
23*7c478bd9Sstevel@tonic-gate 
24*7c478bd9Sstevel@tonic-gate #include <gssapiP_generic.h>
25*7c478bd9Sstevel@tonic-gate #include <string.h>
26*7c478bd9Sstevel@tonic-gate #include <stdio.h>
27*7c478bd9Sstevel@tonic-gate 
28*7c478bd9Sstevel@tonic-gate /*
29*7c478bd9Sstevel@tonic-gate  * $Id: disp_major_status.c,v 1.6 1996/07/22 20:33:01 marc Exp $
30*7c478bd9Sstevel@tonic-gate  */
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #define	GSS_CALLING_ERROR_FIELD(x) \
33*7c478bd9Sstevel@tonic-gate 	(((x) >> GSS_C_CALLING_ERROR_OFFSET) & GSS_C_CALLING_ERROR_MASK)
34*7c478bd9Sstevel@tonic-gate 
35*7c478bd9Sstevel@tonic-gate #define	GSS_ROUTINE_ERROR_FIELD(x) \
36*7c478bd9Sstevel@tonic-gate 	(((x) >> GSS_C_ROUTINE_ERROR_OFFSET) & GSS_C_ROUTINE_ERROR_MASK)
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate /* This code has knowledge of the min and max errors of each type
39*7c478bd9Sstevel@tonic-gate    within the gssapi major status */
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate #define GSS_ERROR_STR(value, array, select, min, max, num) \
42*7c478bd9Sstevel@tonic-gate    (((select(value) < (min)) || (select(value) > (max))) ? NULL : \
43*7c478bd9Sstevel@tonic-gate     (array)[num(value)])
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate /**/
46*7c478bd9Sstevel@tonic-gate 
47*7c478bd9Sstevel@tonic-gate static const char * const calling_error_string[] = {
48*7c478bd9Sstevel@tonic-gate    NULL,
49*7c478bd9Sstevel@tonic-gate    "A required input parameter could not be read",
50*7c478bd9Sstevel@tonic-gate    "A required input parameter could not be written",
51*7c478bd9Sstevel@tonic-gate    "A parameter was malformed",
52*7c478bd9Sstevel@tonic-gate };
53*7c478bd9Sstevel@tonic-gate 
54*7c478bd9Sstevel@tonic-gate static const char * const calling_error = "calling error";
55*7c478bd9Sstevel@tonic-gate 
56*7c478bd9Sstevel@tonic-gate #define GSS_CALLING_ERROR_STR(x) \
57*7c478bd9Sstevel@tonic-gate    GSS_ERROR_STR((x), calling_error_string, GSS_CALLING_ERROR, \
58*7c478bd9Sstevel@tonic-gate 		 GSS_S_CALL_INACCESSIBLE_READ, GSS_S_CALL_BAD_STRUCTURE, \
59*7c478bd9Sstevel@tonic-gate 		 GSS_CALLING_ERROR_FIELD)
60*7c478bd9Sstevel@tonic-gate 
61*7c478bd9Sstevel@tonic-gate /**/
62*7c478bd9Sstevel@tonic-gate 
63*7c478bd9Sstevel@tonic-gate static const char * const routine_error_string[] = {
64*7c478bd9Sstevel@tonic-gate    NULL,
65*7c478bd9Sstevel@tonic-gate    "An unsupported mechanism was requested",
66*7c478bd9Sstevel@tonic-gate    "An invalid name was supplied",
67*7c478bd9Sstevel@tonic-gate    "A supplied name was of an unsupported type",
68*7c478bd9Sstevel@tonic-gate    "Incorrect channel bindings were supplied",
69*7c478bd9Sstevel@tonic-gate    "An invalid status code was supplied",
70*7c478bd9Sstevel@tonic-gate    "A token had an invalid signature",
71*7c478bd9Sstevel@tonic-gate    "No credentials were supplied",
72*7c478bd9Sstevel@tonic-gate    "No context has been established",
73*7c478bd9Sstevel@tonic-gate    "A token was invalid",
74*7c478bd9Sstevel@tonic-gate    "A credential was invalid",
75*7c478bd9Sstevel@tonic-gate    "The referenced credentials have expired",
76*7c478bd9Sstevel@tonic-gate    "The context has expired",
77*7c478bd9Sstevel@tonic-gate    "Miscellaneous failure",
78*7c478bd9Sstevel@tonic-gate    "The quality-of-protection requested could not be provided",
79*7c478bd9Sstevel@tonic-gate    "The operation is forbidden by the local security policy",
80*7c478bd9Sstevel@tonic-gate    "The operation or option is not available",
81*7c478bd9Sstevel@tonic-gate };
82*7c478bd9Sstevel@tonic-gate 
83*7c478bd9Sstevel@tonic-gate static const char * const routine_error = "routine error";
84*7c478bd9Sstevel@tonic-gate 
85*7c478bd9Sstevel@tonic-gate #define GSS_ROUTINE_ERROR_STR(x) \
86*7c478bd9Sstevel@tonic-gate    GSS_ERROR_STR((x), routine_error_string, GSS_ROUTINE_ERROR, \
87*7c478bd9Sstevel@tonic-gate 		 GSS_S_BAD_MECH, GSS_S_FAILURE, \
88*7c478bd9Sstevel@tonic-gate 		 GSS_ROUTINE_ERROR_FIELD)
89*7c478bd9Sstevel@tonic-gate 
90*7c478bd9Sstevel@tonic-gate /**/
91*7c478bd9Sstevel@tonic-gate 
92*7c478bd9Sstevel@tonic-gate /* this becomes overly gross after about 4 strings */
93*7c478bd9Sstevel@tonic-gate 
94*7c478bd9Sstevel@tonic-gate static const char * const sinfo_string[] = {
95*7c478bd9Sstevel@tonic-gate    "The routine must be called again to complete its function",
96*7c478bd9Sstevel@tonic-gate    "The token was a duplicate of an earlier token",
97*7c478bd9Sstevel@tonic-gate    "The token's validity period has expired",
98*7c478bd9Sstevel@tonic-gate    "A later token has already been processed",
99*7c478bd9Sstevel@tonic-gate };
100*7c478bd9Sstevel@tonic-gate 
101*7c478bd9Sstevel@tonic-gate static const char * const sinfo_code = "supplementary info code";
102*7c478bd9Sstevel@tonic-gate 
103*7c478bd9Sstevel@tonic-gate #define LSBGET(x) ((((x)^((x)-1))+1)>>1)
104*7c478bd9Sstevel@tonic-gate #define LSBMASK(n) ((1<<(n))^((1<<(n))-1))
105*7c478bd9Sstevel@tonic-gate 
106*7c478bd9Sstevel@tonic-gate #define GSS_SINFO_STR(x) \
107*7c478bd9Sstevel@tonic-gate    ((((1<<(x)) < GSS_S_CONTINUE_NEEDED) || ((1<<(x)) > GSS_S_UNSEQ_TOKEN)) ? \
108*7c478bd9Sstevel@tonic-gate     /**/NULL:sinfo_string[(x)])
109*7c478bd9Sstevel@tonic-gate 
110*7c478bd9Sstevel@tonic-gate /**/
111*7c478bd9Sstevel@tonic-gate 
112*7c478bd9Sstevel@tonic-gate static const char * const no_error = "No error";
113*7c478bd9Sstevel@tonic-gate static const char * const unknown_error = "Unknown %s (field = %d)";
114*7c478bd9Sstevel@tonic-gate 
115*7c478bd9Sstevel@tonic-gate /**/
116*7c478bd9Sstevel@tonic-gate 
117*7c478bd9Sstevel@tonic-gate int display_unknown(kind, value, buffer)
118*7c478bd9Sstevel@tonic-gate      const char *kind;
119*7c478bd9Sstevel@tonic-gate      OM_uint32 value;
120*7c478bd9Sstevel@tonic-gate      gss_buffer_t buffer;
121*7c478bd9Sstevel@tonic-gate {
122*7c478bd9Sstevel@tonic-gate    size_t len;
123*7c478bd9Sstevel@tonic-gate    char *str;
124*7c478bd9Sstevel@tonic-gate 
125*7c478bd9Sstevel@tonic-gate    str = (char *) xmalloc(strlen(unknown_error)+strlen(kind)+7);
126*7c478bd9Sstevel@tonic-gate    if (str == NULL)
127*7c478bd9Sstevel@tonic-gate       return(0);
128*7c478bd9Sstevel@tonic-gate 
129*7c478bd9Sstevel@tonic-gate    sprintf(str, unknown_error, kind, value);
130*7c478bd9Sstevel@tonic-gate 
131*7c478bd9Sstevel@tonic-gate    buffer->length = strlen(str);
132*7c478bd9Sstevel@tonic-gate    buffer->value = str;
133*7c478bd9Sstevel@tonic-gate 
134*7c478bd9Sstevel@tonic-gate    return(1);
135*7c478bd9Sstevel@tonic-gate }
136*7c478bd9Sstevel@tonic-gate 
137*7c478bd9Sstevel@tonic-gate /* code should be set to the calling error field */
138*7c478bd9Sstevel@tonic-gate 
139*7c478bd9Sstevel@tonic-gate static OM_uint32 display_calling(minor_status, code, status_string)
140*7c478bd9Sstevel@tonic-gate      OM_uint32 *minor_status;
141*7c478bd9Sstevel@tonic-gate      OM_uint32 code;
142*7c478bd9Sstevel@tonic-gate      gss_buffer_t status_string;
143*7c478bd9Sstevel@tonic-gate {
144*7c478bd9Sstevel@tonic-gate    const char *str;
145*7c478bd9Sstevel@tonic-gate 
146*7c478bd9Sstevel@tonic-gate    if ((str = GSS_CALLING_ERROR_STR(code)) != NULL) {
147*7c478bd9Sstevel@tonic-gate       if (! g_make_string_buffer(str, status_string)) {
148*7c478bd9Sstevel@tonic-gate 	 *minor_status = ENOMEM;
149*7c478bd9Sstevel@tonic-gate 	 return(GSS_S_FAILURE);
150*7c478bd9Sstevel@tonic-gate       }
151*7c478bd9Sstevel@tonic-gate    } else {
152*7c478bd9Sstevel@tonic-gate       if (! display_unknown(calling_error, GSS_CALLING_ERROR_FIELD(code),
153*7c478bd9Sstevel@tonic-gate 			    status_string)) {
154*7c478bd9Sstevel@tonic-gate 	 *minor_status = ENOMEM;
155*7c478bd9Sstevel@tonic-gate 	 return(GSS_S_FAILURE);
156*7c478bd9Sstevel@tonic-gate       }
157*7c478bd9Sstevel@tonic-gate    }
158*7c478bd9Sstevel@tonic-gate    *minor_status = 0;
159*7c478bd9Sstevel@tonic-gate    return(GSS_S_COMPLETE);
160*7c478bd9Sstevel@tonic-gate }
161*7c478bd9Sstevel@tonic-gate 
162*7c478bd9Sstevel@tonic-gate /* code should be set to the routine error field */
163*7c478bd9Sstevel@tonic-gate 
164*7c478bd9Sstevel@tonic-gate static OM_uint32 display_routine(minor_status, code, status_string)
165*7c478bd9Sstevel@tonic-gate      OM_uint32 *minor_status;
166*7c478bd9Sstevel@tonic-gate      OM_uint32 code;
167*7c478bd9Sstevel@tonic-gate      gss_buffer_t status_string;
168*7c478bd9Sstevel@tonic-gate {
169*7c478bd9Sstevel@tonic-gate    const char *str;
170*7c478bd9Sstevel@tonic-gate 
171*7c478bd9Sstevel@tonic-gate    if ((str = GSS_ROUTINE_ERROR_STR(code)) != NULL) {
172*7c478bd9Sstevel@tonic-gate       if (! g_make_string_buffer(str, status_string)) {
173*7c478bd9Sstevel@tonic-gate 	 *minor_status = ENOMEM;
174*7c478bd9Sstevel@tonic-gate 	 return(GSS_S_FAILURE);
175*7c478bd9Sstevel@tonic-gate       }
176*7c478bd9Sstevel@tonic-gate    } else {
177*7c478bd9Sstevel@tonic-gate       if (! display_unknown(routine_error, GSS_ROUTINE_ERROR_FIELD(code),
178*7c478bd9Sstevel@tonic-gate 			    status_string)) {
179*7c478bd9Sstevel@tonic-gate 	 *minor_status = ENOMEM;
180*7c478bd9Sstevel@tonic-gate 	 return(GSS_S_FAILURE);
181*7c478bd9Sstevel@tonic-gate       }
182*7c478bd9Sstevel@tonic-gate    }
183*7c478bd9Sstevel@tonic-gate    *minor_status = 0;
184*7c478bd9Sstevel@tonic-gate    return(GSS_S_COMPLETE);
185*7c478bd9Sstevel@tonic-gate }
186*7c478bd9Sstevel@tonic-gate 
187*7c478bd9Sstevel@tonic-gate /* code should be set to the bit offset (log_2) of a supplementary info bit */
188*7c478bd9Sstevel@tonic-gate 
189*7c478bd9Sstevel@tonic-gate static OM_uint32 display_bit(minor_status, code, status_string)
190*7c478bd9Sstevel@tonic-gate      OM_uint32 *minor_status;
191*7c478bd9Sstevel@tonic-gate      OM_uint32 code;
192*7c478bd9Sstevel@tonic-gate      gss_buffer_t status_string;
193*7c478bd9Sstevel@tonic-gate {
194*7c478bd9Sstevel@tonic-gate    const char *str;
195*7c478bd9Sstevel@tonic-gate 
196*7c478bd9Sstevel@tonic-gate    if ((str = GSS_SINFO_STR(code)) != NULL) {
197*7c478bd9Sstevel@tonic-gate       if (! g_make_string_buffer(str, status_string)) {
198*7c478bd9Sstevel@tonic-gate 	 *minor_status = ENOMEM;
199*7c478bd9Sstevel@tonic-gate 	 return(GSS_S_FAILURE);
200*7c478bd9Sstevel@tonic-gate       }
201*7c478bd9Sstevel@tonic-gate    } else {
202*7c478bd9Sstevel@tonic-gate       if (! display_unknown(sinfo_code, 1<<code, status_string)) {
203*7c478bd9Sstevel@tonic-gate 	 *minor_status = ENOMEM;
204*7c478bd9Sstevel@tonic-gate 	 return(GSS_S_FAILURE);
205*7c478bd9Sstevel@tonic-gate       }
206*7c478bd9Sstevel@tonic-gate    }
207*7c478bd9Sstevel@tonic-gate    *minor_status = 0;
208*7c478bd9Sstevel@tonic-gate    return(GSS_S_COMPLETE);
209*7c478bd9Sstevel@tonic-gate }
210*7c478bd9Sstevel@tonic-gate 
211*7c478bd9Sstevel@tonic-gate /**/
212*7c478bd9Sstevel@tonic-gate 
213*7c478bd9Sstevel@tonic-gate /* return error messages, for routine errors, call error, and status,
214*7c478bd9Sstevel@tonic-gate    in that order.
215*7c478bd9Sstevel@tonic-gate      message_context == 0 : print the routine error
216*7c478bd9Sstevel@tonic-gate      message_context == 1 : print the calling error
217*7c478bd9Sstevel@tonic-gate      message_context > 2  : print supplementary info bit (message_context-2)
218*7c478bd9Sstevel@tonic-gate      */
219*7c478bd9Sstevel@tonic-gate 
220*7c478bd9Sstevel@tonic-gate OM_uint32 g_display_major_status(minor_status, status_value,
221*7c478bd9Sstevel@tonic-gate 				 message_context, status_string)
222*7c478bd9Sstevel@tonic-gate      OM_uint32 *minor_status;
223*7c478bd9Sstevel@tonic-gate      OM_uint32 status_value;
224*7c478bd9Sstevel@tonic-gate      OM_uint32 *message_context;
225*7c478bd9Sstevel@tonic-gate      gss_buffer_t status_string;
226*7c478bd9Sstevel@tonic-gate {
227*7c478bd9Sstevel@tonic-gate    OM_uint32 ret, tmp;
228*7c478bd9Sstevel@tonic-gate    int bit;
229*7c478bd9Sstevel@tonic-gate 
230*7c478bd9Sstevel@tonic-gate    /*** deal with no error at all specially */
231*7c478bd9Sstevel@tonic-gate 
232*7c478bd9Sstevel@tonic-gate    if (status_value == 0) {
233*7c478bd9Sstevel@tonic-gate       if (! g_make_string_buffer(no_error, status_string)) {
234*7c478bd9Sstevel@tonic-gate 	 *minor_status = ENOMEM;
235*7c478bd9Sstevel@tonic-gate 	 return(GSS_S_FAILURE);
236*7c478bd9Sstevel@tonic-gate       }
237*7c478bd9Sstevel@tonic-gate       *message_context = 0;
238*7c478bd9Sstevel@tonic-gate       *minor_status = 0;
239*7c478bd9Sstevel@tonic-gate       return(GSS_S_COMPLETE);
240*7c478bd9Sstevel@tonic-gate    }
241*7c478bd9Sstevel@tonic-gate 
242*7c478bd9Sstevel@tonic-gate    /*** do routine error */
243*7c478bd9Sstevel@tonic-gate 
244*7c478bd9Sstevel@tonic-gate    if (*message_context == 0) {
245*7c478bd9Sstevel@tonic-gate       if ((tmp = GSS_ROUTINE_ERROR(status_value)) != 0) {
246*7c478bd9Sstevel@tonic-gate 	 status_value -= tmp;
247*7c478bd9Sstevel@tonic-gate 	 if ((ret = display_routine(minor_status, tmp, status_string)))
248*7c478bd9Sstevel@tonic-gate 	    return(ret);
249*7c478bd9Sstevel@tonic-gate 	 *minor_status = 0;
250*7c478bd9Sstevel@tonic-gate 	 if (status_value) {
251*7c478bd9Sstevel@tonic-gate 	    (*message_context)++;
252*7c478bd9Sstevel@tonic-gate 	    return(GSS_S_COMPLETE);
253*7c478bd9Sstevel@tonic-gate 	 } else {
254*7c478bd9Sstevel@tonic-gate 	    *message_context = 0;
255*7c478bd9Sstevel@tonic-gate 	    return(GSS_S_COMPLETE);
256*7c478bd9Sstevel@tonic-gate 	 }
257*7c478bd9Sstevel@tonic-gate       } else {
258*7c478bd9Sstevel@tonic-gate 	 (*message_context)++;
259*7c478bd9Sstevel@tonic-gate       }
260*7c478bd9Sstevel@tonic-gate    } else {
261*7c478bd9Sstevel@tonic-gate       status_value -= GSS_ROUTINE_ERROR(status_value);
262*7c478bd9Sstevel@tonic-gate    }
263*7c478bd9Sstevel@tonic-gate 
264*7c478bd9Sstevel@tonic-gate    /*** do calling error */
265*7c478bd9Sstevel@tonic-gate 
266*7c478bd9Sstevel@tonic-gate    if (*message_context == 1) {
267*7c478bd9Sstevel@tonic-gate       if ((tmp = GSS_CALLING_ERROR(status_value)) != 0) {
268*7c478bd9Sstevel@tonic-gate 	 status_value -= tmp;
269*7c478bd9Sstevel@tonic-gate 	 if ((ret = display_calling(minor_status, tmp, status_string)))
270*7c478bd9Sstevel@tonic-gate 	    return(ret);
271*7c478bd9Sstevel@tonic-gate 	 *minor_status = 0;
272*7c478bd9Sstevel@tonic-gate 	 if (status_value) {
273*7c478bd9Sstevel@tonic-gate 	    (*message_context)++;
274*7c478bd9Sstevel@tonic-gate 	    return(GSS_S_COMPLETE);
275*7c478bd9Sstevel@tonic-gate 	 } else {
276*7c478bd9Sstevel@tonic-gate 	    *message_context = 0;
277*7c478bd9Sstevel@tonic-gate 	    return(GSS_S_COMPLETE);
278*7c478bd9Sstevel@tonic-gate 	 }
279*7c478bd9Sstevel@tonic-gate       } else {
280*7c478bd9Sstevel@tonic-gate 	 (*message_context)++;
281*7c478bd9Sstevel@tonic-gate       }
282*7c478bd9Sstevel@tonic-gate    } else {
283*7c478bd9Sstevel@tonic-gate       status_value -= GSS_CALLING_ERROR(status_value);
284*7c478bd9Sstevel@tonic-gate    }
285*7c478bd9Sstevel@tonic-gate 
286*7c478bd9Sstevel@tonic-gate    /*** do sinfo bits (*message_context == 2 + number of bits done) */
287*7c478bd9Sstevel@tonic-gate 
288*7c478bd9Sstevel@tonic-gate    tmp = ((GSS_SUPPLEMENTARY_INFO(status_value)) >> GSS_C_SUPPLEMENTARY_OFFSET);
289*7c478bd9Sstevel@tonic-gate    /* mask off the bits which have been done */
290*7c478bd9Sstevel@tonic-gate    if (*message_context > 2) {
291*7c478bd9Sstevel@tonic-gate       tmp &= ~LSBMASK(*message_context-3);
292*7c478bd9Sstevel@tonic-gate       status_value &= ~LSBMASK(*message_context-3);
293*7c478bd9Sstevel@tonic-gate    }
294*7c478bd9Sstevel@tonic-gate 
295*7c478bd9Sstevel@tonic-gate    if (!tmp) {
296*7c478bd9Sstevel@tonic-gate       /* bogon input - there should be something left */
297*7c478bd9Sstevel@tonic-gate       *minor_status = (OM_uint32) G_BAD_MSG_CTX;
298*7c478bd9Sstevel@tonic-gate       return(GSS_S_FAILURE);
299*7c478bd9Sstevel@tonic-gate    }
300*7c478bd9Sstevel@tonic-gate 
301*7c478bd9Sstevel@tonic-gate    /* compute the bit offset */
302*7c478bd9Sstevel@tonic-gate    /*SUPPRESS 570*/
303*7c478bd9Sstevel@tonic-gate    for (bit=0; (((OM_uint32) 1)<<bit) != LSBGET(tmp); bit++) ;
304*7c478bd9Sstevel@tonic-gate 
305*7c478bd9Sstevel@tonic-gate    /* print it */
306*7c478bd9Sstevel@tonic-gate    if ((ret = display_bit(minor_status, bit, status_string)))
307*7c478bd9Sstevel@tonic-gate       return(ret);
308*7c478bd9Sstevel@tonic-gate 
309*7c478bd9Sstevel@tonic-gate    /* compute the new status_value/message_context */
310*7c478bd9Sstevel@tonic-gate    status_value -= ((OM_uint32) 1)<<bit;
311*7c478bd9Sstevel@tonic-gate 
312*7c478bd9Sstevel@tonic-gate    if (status_value) {
313*7c478bd9Sstevel@tonic-gate       *message_context = bit+3;
314*7c478bd9Sstevel@tonic-gate       return(GSS_S_COMPLETE);
315*7c478bd9Sstevel@tonic-gate    } else {
316*7c478bd9Sstevel@tonic-gate       *message_context = 0;
317*7c478bd9Sstevel@tonic-gate       return(GSS_S_COMPLETE);
318*7c478bd9Sstevel@tonic-gate    }
319*7c478bd9Sstevel@tonic-gate }
320