xref: /onnv-gate/usr/src/lib/libgss/g_process_context.c (revision 13132:9615cdbf7b70)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
59698SPeter.Shoults@Sun.COM  * Common Development and Distribution License (the "License").
69698SPeter.Shoults@Sun.COM  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*13132SGlenn.Barry@oracle.com  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
230Sstevel@tonic-gate  */
240Sstevel@tonic-gate 
250Sstevel@tonic-gate /*
260Sstevel@tonic-gate  *  glue routine gss_process_context
270Sstevel@tonic-gate  */
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #include <mechglueP.h>
30*13132SGlenn.Barry@oracle.com #include "gssapiP_generic.h"
310Sstevel@tonic-gate 
320Sstevel@tonic-gate OM_uint32
gss_process_context_token(minor_status,context_handle,token_buffer)330Sstevel@tonic-gate gss_process_context_token(minor_status,
340Sstevel@tonic-gate 				context_handle,
350Sstevel@tonic-gate 				token_buffer)
360Sstevel@tonic-gate 
370Sstevel@tonic-gate OM_uint32 *			minor_status;
380Sstevel@tonic-gate const gss_ctx_id_t		context_handle;
390Sstevel@tonic-gate gss_buffer_t			token_buffer;
400Sstevel@tonic-gate 
410Sstevel@tonic-gate {
420Sstevel@tonic-gate 	OM_uint32		status;
430Sstevel@tonic-gate 	gss_union_ctx_id_t	ctx;
440Sstevel@tonic-gate 	gss_mechanism		mech;
450Sstevel@tonic-gate 
460Sstevel@tonic-gate 	if (minor_status == NULL)
470Sstevel@tonic-gate 		return (GSS_S_CALL_INACCESSIBLE_WRITE);
480Sstevel@tonic-gate 	*minor_status = 0;
490Sstevel@tonic-gate 
500Sstevel@tonic-gate 	if (context_handle == GSS_C_NO_CONTEXT)
510Sstevel@tonic-gate 		return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT);
520Sstevel@tonic-gate 
539698SPeter.Shoults@Sun.COM 	if (token_buffer == GSS_C_NO_BUFFER)
549698SPeter.Shoults@Sun.COM 		return (GSS_S_CALL_INACCESSIBLE_READ);
559698SPeter.Shoults@Sun.COM 
560Sstevel@tonic-gate 	if (GSS_EMPTY_BUFFER(token_buffer))
570Sstevel@tonic-gate 		return (GSS_S_CALL_INACCESSIBLE_READ);
580Sstevel@tonic-gate 
590Sstevel@tonic-gate 	/*
600Sstevel@tonic-gate 	 * select the approprate underlying mechanism routine and
610Sstevel@tonic-gate 	 * call it.
620Sstevel@tonic-gate 	 */
630Sstevel@tonic-gate 
640Sstevel@tonic-gate 	ctx = (gss_union_ctx_id_t) context_handle;
650Sstevel@tonic-gate 	mech = __gss_get_mechanism(ctx->mech_type);
660Sstevel@tonic-gate 
670Sstevel@tonic-gate 	if (mech) {
680Sstevel@tonic-gate 
69*13132SGlenn.Barry@oracle.com 		if (mech->gss_process_context_token) {
700Sstevel@tonic-gate 			status = mech->gss_process_context_token(
710Sstevel@tonic-gate 							mech->context,
720Sstevel@tonic-gate 							minor_status,
730Sstevel@tonic-gate 							ctx->internal_ctx_id,
740Sstevel@tonic-gate 							token_buffer);
75*13132SGlenn.Barry@oracle.com 			if (status != GSS_S_COMPLETE)
76*13132SGlenn.Barry@oracle.com 				map_error(minor_status, mech);
77*13132SGlenn.Barry@oracle.com 		} else
780Sstevel@tonic-gate 			status = GSS_S_UNAVAILABLE;
790Sstevel@tonic-gate 
800Sstevel@tonic-gate 		return (status);
810Sstevel@tonic-gate 	}
820Sstevel@tonic-gate 
830Sstevel@tonic-gate 	return (GSS_S_BAD_MECH);
840Sstevel@tonic-gate }
85