xref: /titanic_50/usr/src/lib/libgss/g_sign.c (revision 20c794b39650d115e17a15983b6b82e46238cf45)
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_sign
31  */
32 
33 #include <mechglueP.h>
34 
35 OM_uint32
36 gss_sign(minor_status,
37 	context_handle,
38 	qop_req,
39 	message_buffer,
40 	msg_token)
41 
42 OM_uint32 *		minor_status;
43 gss_ctx_id_t		context_handle;
44 int			qop_req;
45 gss_buffer_t		message_buffer;
46 gss_buffer_t		msg_token;
47 
48 {
49 	OM_uint32		status;
50 	gss_union_ctx_id_t	ctx;
51 	gss_mechanism		mech;
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)
61 		return (GSS_S_CALL_INACCESSIBLE_READ);
62 
63 	if (msg_token == NULL)
64 		return (GSS_S_CALL_INACCESSIBLE_WRITE);
65 
66 	msg_token->value = NULL;
67 	msg_token->length = 0;
68 	/*
69 	 * select the approprate underlying mechanism routine and
70 	 * call it.
71 	 */
72 
73 	ctx = (gss_union_ctx_id_t) context_handle;
74 	mech = __gss_get_mechanism(ctx->mech_type);
75 
76 	if (mech) {
77 		if (mech->gss_sign)
78 			status = mech->gss_sign(
79 						mech->context,
80 						minor_status,
81 						ctx->internal_ctx_id,
82 						qop_req,
83 						message_buffer,
84 						msg_token);
85 		else
86 			status = GSS_S_UNAVAILABLE;
87 
88 		return (status);
89 	}
90 
91 	return (GSS_S_BAD_MECH);
92 }
93 
94 OM_uint32
95 gss_get_mic(minor_status,
96 		context_handle,
97 		qop_req,
98 		message_buffer,
99 		msg_token)
100 
101 OM_uint32 *		minor_status;
102 const gss_ctx_id_t	context_handle;
103 gss_qop_t		qop_req;
104 const gss_buffer_t	message_buffer;
105 gss_buffer_t		msg_token;
106 
107 {
108 	return (gss_sign(minor_status, (gss_ctx_id_t)context_handle,
109 		(int) qop_req, (gss_buffer_t)message_buffer, msg_token));
110 }
111