xref: /titanic_51/usr/src/lib/libgss/g_process_context.c (revision 275c9da86e89f8abf71135cf63d9fc23671b2e60)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1996,1997, by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 /*
30  *  glue routine gss_process_context
31  */
32 
33 #include <mechglueP.h>
34 
35 OM_uint32
36 gss_process_context_token(minor_status,
37 				context_handle,
38 				token_buffer)
39 
40 OM_uint32 *			minor_status;
41 const gss_ctx_id_t		context_handle;
42 gss_buffer_t			token_buffer;
43 
44 {
45 	OM_uint32		status;
46 	gss_union_ctx_id_t	ctx;
47 	gss_mechanism		mech;
48 
49 	if (minor_status == NULL)
50 		return (GSS_S_CALL_INACCESSIBLE_WRITE);
51 	*minor_status = 0;
52 
53 	if (context_handle == GSS_C_NO_CONTEXT)
54 		return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT);
55 
56 	if (GSS_EMPTY_BUFFER(token_buffer))
57 		return (GSS_S_CALL_INACCESSIBLE_READ);
58 
59 	/*
60 	 * select the approprate underlying mechanism routine and
61 	 * call it.
62 	 */
63 
64 	ctx = (gss_union_ctx_id_t) context_handle;
65 	mech = __gss_get_mechanism(ctx->mech_type);
66 
67 	if (mech) {
68 
69 		if (mech->gss_process_context_token)
70 			status = mech->gss_process_context_token(
71 							mech->context,
72 							minor_status,
73 							ctx->internal_ctx_id,
74 							token_buffer);
75 		else
76 			status = GSS_S_UNAVAILABLE;
77 
78 		return (status);
79 	}
80 
81 	return (GSS_S_BAD_MECH);
82 }
83