Unleashed v1.4
[unleashed.git] / usr / src / lib / libgss / g_sign.c
blob9d137395dacc466bd4ad0677d979d667bbe47d65
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
22 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
26 * glue routine gss_sign
29 #include <mechglueP.h>
30 #include "gssapiP_generic.h"
32 static OM_uint32
33 val_sign_args(
34 OM_uint32 *minor_status,
35 gss_ctx_id_t context_handle,
36 gss_buffer_t message_buffer,
37 gss_buffer_t msg_token)
40 /* Initialize outputs. */
42 if (minor_status != NULL)
43 *minor_status = 0;
45 if (msg_token != GSS_C_NO_BUFFER) {
46 msg_token->value = NULL;
47 msg_token->length = 0;
50 /* Validate arguments. */
52 if (minor_status == NULL)
53 return (GSS_S_CALL_INACCESSIBLE_WRITE);
55 if (context_handle == GSS_C_NO_CONTEXT)
56 return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT);
58 if (message_buffer == GSS_C_NO_BUFFER)
59 return (GSS_S_CALL_INACCESSIBLE_READ);
61 if (msg_token == GSS_C_NO_BUFFER)
62 return (GSS_S_CALL_INACCESSIBLE_WRITE);
64 return (GSS_S_COMPLETE);
67 OM_uint32
68 gss_sign(minor_status,
69 context_handle,
70 qop_req,
71 message_buffer,
72 msg_token)
74 OM_uint32 * minor_status;
75 gss_ctx_id_t context_handle;
76 int qop_req;
77 gss_buffer_t message_buffer;
78 gss_buffer_t msg_token;
81 OM_uint32 status;
82 gss_union_ctx_id_t ctx;
83 gss_mechanism mech;
85 status = val_sign_args(minor_status, context_handle,
86 message_buffer, msg_token);
87 if (status != GSS_S_COMPLETE)
88 return (status);
91 * select the approprate underlying mechanism routine and
92 * call it.
95 ctx = (gss_union_ctx_id_t) context_handle;
96 mech = __gss_get_mechanism(ctx->mech_type);
98 if (mech) {
99 if (mech->gss_sign) {
100 status = mech->gss_sign(
101 mech->context,
102 minor_status,
103 ctx->internal_ctx_id,
104 qop_req,
105 message_buffer,
106 msg_token);
107 if (status != GSS_S_COMPLETE)
108 map_error(minor_status, mech);
109 } else
110 status = GSS_S_UNAVAILABLE;
112 return (status);
115 return (GSS_S_BAD_MECH);
118 OM_uint32
119 gss_get_mic(minor_status,
120 context_handle,
121 qop_req,
122 message_buffer,
123 msg_token)
125 OM_uint32 * minor_status;
126 const gss_ctx_id_t context_handle;
127 gss_qop_t qop_req;
128 const gss_buffer_t message_buffer;
129 gss_buffer_t msg_token;
132 return (gss_sign(minor_status, (gss_ctx_id_t)context_handle,
133 (int) qop_req, (gss_buffer_t)message_buffer, msg_token));