xref: /titanic_41/usr/src/lib/libgss/g_verify.c (revision aff4bce51ecc47df7e5a6351b7cee6bc20408c63)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*
27  *  glue routine for gss_verify
28  */
29 
30 #include <mechglueP.h>
31 
32 OM_uint32
33 gss_verify(minor_status,
34 		context_handle,
35 		message_buffer,
36 		token_buffer,
37 		qop_state)
38 
39 OM_uint32 *		minor_status;
40 gss_ctx_id_t		context_handle;
41 gss_buffer_t		message_buffer;
42 gss_buffer_t		token_buffer;
43 int *			qop_state;
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 ((message_buffer == GSS_C_NO_BUFFER) ||
57 	    GSS_EMPTY_BUFFER(token_buffer))
58 		return (GSS_S_CALL_INACCESSIBLE_READ);
59 
60 	/*
61 	 * select the approprate underlying mechanism routine and
62 	 * call it.
63 	 */
64 
65 	ctx = (gss_union_ctx_id_t) context_handle;
66 	mech = __gss_get_mechanism(ctx->mech_type);
67 
68 	if (mech) {
69 		if (mech->gss_verify)
70 			status = mech->gss_verify(
71 						mech->context,
72 						minor_status,
73 						ctx->internal_ctx_id,
74 						message_buffer,
75 						token_buffer,
76 						qop_state);
77 		else
78 			status = GSS_S_UNAVAILABLE;
79 
80 		return (status);
81 	}
82 
83     return (GSS_S_BAD_MECH);
84 }
85 
86 OM_uint32
87 gss_verify_mic(minor_status,
88 		context_handle,
89 		message_buffer,
90 		token_buffer,
91 		qop_state)
92 
93 OM_uint32 *		minor_status;
94 const gss_ctx_id_t	context_handle;
95 const gss_buffer_t	message_buffer;
96 const gss_buffer_t	token_buffer;
97 gss_qop_t *		qop_state;
98 
99 {
100 	return (gss_verify(minor_status, (gss_ctx_id_t)context_handle,
101 			(gss_buffer_t)message_buffer,
102 			(gss_buffer_t)token_buffer, (int *) qop_state));
103 }
104