xref: /titanic_50/usr/src/lib/libgss/g_verify.c (revision 29e83d4b25fd82feb8e0e0fbe89f7e2a8438533d)
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 for gss_verify
31  */
32 
33 #include <mechglueP.h>
34 
35 OM_uint32
36 gss_verify(minor_status,
37 		context_handle,
38 		message_buffer,
39 		token_buffer,
40 		qop_state)
41 
42 OM_uint32 *		minor_status;
43 gss_ctx_id_t		context_handle;
44 gss_buffer_t		message_buffer;
45 gss_buffer_t		token_buffer;
46 int *			qop_state;
47 {
48 	OM_uint32		status;
49 	gss_union_ctx_id_t	ctx;
50 	gss_mechanism		mech;
51 
52 
53 	if (minor_status == NULL)
54 		return (GSS_S_CALL_INACCESSIBLE_WRITE);
55 	*minor_status = 0;
56 
57 	if (context_handle == GSS_C_NO_CONTEXT)
58 		return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT);
59 
60 	if ((message_buffer == NULL) || GSS_EMPTY_BUFFER(token_buffer))
61 		return (GSS_S_CALL_INACCESSIBLE_READ);
62 
63 	/*
64 	 * select the approprate underlying mechanism routine and
65 	 * call it.
66 	 */
67 
68 	ctx = (gss_union_ctx_id_t) context_handle;
69 	mech = __gss_get_mechanism(ctx->mech_type);
70 
71 	if (mech) {
72 		if (mech->gss_verify)
73 			status = mech->gss_verify(
74 						mech->context,
75 						minor_status,
76 						ctx->internal_ctx_id,
77 						message_buffer,
78 						token_buffer,
79 						qop_state);
80 		else
81 			status = GSS_S_UNAVAILABLE;
82 
83 		return (status);
84 	}
85 
86     return (GSS_S_BAD_MECH);
87 }
88 
89 OM_uint32
90 gss_verify_mic(minor_status,
91 		context_handle,
92 		message_buffer,
93 		token_buffer,
94 		qop_state)
95 
96 OM_uint32 *		minor_status;
97 const gss_ctx_id_t	context_handle;
98 const gss_buffer_t	message_buffer;
99 const gss_buffer_t	token_buffer;
100 gss_qop_t *		qop_state;
101 
102 {
103 	return (gss_verify(minor_status, (gss_ctx_id_t)context_handle,
104 			(gss_buffer_t)message_buffer,
105 			(gss_buffer_t)token_buffer, (int *) qop_state));
106 }
107