xref: /onnv-gate/usr/src/lib/libgss/g_unseal.c (revision 13132:9615cdbf7b70)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
59698SPeter.Shoults@Sun.COM  * Common Development and Distribution License (the "License").
69698SPeter.Shoults@Sun.COM  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*13132SGlenn.Barry@oracle.com  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
230Sstevel@tonic-gate  */
240Sstevel@tonic-gate 
250Sstevel@tonic-gate /*
260Sstevel@tonic-gate  *  glue routine gss_unseal
270Sstevel@tonic-gate  */
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #include <mechglueP.h>
30*13132SGlenn.Barry@oracle.com #include "gssapiP_generic.h"
310Sstevel@tonic-gate 
320Sstevel@tonic-gate OM_uint32
gss_unseal(minor_status,context_handle,input_message_buffer,output_message_buffer,conf_state,qop_state)330Sstevel@tonic-gate gss_unseal(minor_status,
340Sstevel@tonic-gate 		context_handle,
350Sstevel@tonic-gate 		input_message_buffer,
360Sstevel@tonic-gate 		output_message_buffer,
370Sstevel@tonic-gate 		conf_state,
380Sstevel@tonic-gate 		qop_state)
390Sstevel@tonic-gate 
400Sstevel@tonic-gate OM_uint32 *		minor_status;
410Sstevel@tonic-gate gss_ctx_id_t		context_handle;
420Sstevel@tonic-gate gss_buffer_t		input_message_buffer;
430Sstevel@tonic-gate gss_buffer_t		output_message_buffer;
440Sstevel@tonic-gate int *			conf_state;
450Sstevel@tonic-gate int *			qop_state;
460Sstevel@tonic-gate 
470Sstevel@tonic-gate {
480Sstevel@tonic-gate /* EXPORT DELETE START */
490Sstevel@tonic-gate 	OM_uint32		status;
500Sstevel@tonic-gate 	gss_union_ctx_id_t	ctx;
510Sstevel@tonic-gate 	gss_mechanism		mech;
520Sstevel@tonic-gate 
539698SPeter.Shoults@Sun.COM 	if (minor_status != NULL)
549698SPeter.Shoults@Sun.COM 		*minor_status = 0;
559698SPeter.Shoults@Sun.COM 
569698SPeter.Shoults@Sun.COM 	if (output_message_buffer != GSS_C_NO_BUFFER) {
579698SPeter.Shoults@Sun.COM 		output_message_buffer->length = 0;
589698SPeter.Shoults@Sun.COM 		output_message_buffer->value = NULL;
599698SPeter.Shoults@Sun.COM 	}
609698SPeter.Shoults@Sun.COM 
610Sstevel@tonic-gate 	if (minor_status == NULL)
620Sstevel@tonic-gate 		return (GSS_S_CALL_INACCESSIBLE_WRITE);
630Sstevel@tonic-gate 
640Sstevel@tonic-gate 	if (context_handle == GSS_C_NO_CONTEXT)
650Sstevel@tonic-gate 		return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT);
660Sstevel@tonic-gate 
679698SPeter.Shoults@Sun.COM 	if (input_message_buffer == GSS_C_NO_BUFFER ||
689698SPeter.Shoults@Sun.COM 	    GSS_EMPTY_BUFFER(input_message_buffer))
690Sstevel@tonic-gate 		return (GSS_S_CALL_INACCESSIBLE_READ);
700Sstevel@tonic-gate 
719698SPeter.Shoults@Sun.COM 	if (output_message_buffer == GSS_C_NO_BUFFER)
720Sstevel@tonic-gate 		return (GSS_S_CALL_INACCESSIBLE_WRITE);
730Sstevel@tonic-gate 
740Sstevel@tonic-gate 	/*
750Sstevel@tonic-gate 	 * select the approprate underlying mechanism routine and
760Sstevel@tonic-gate 	 * call it.
770Sstevel@tonic-gate 	 */
780Sstevel@tonic-gate 
790Sstevel@tonic-gate 	ctx = (gss_union_ctx_id_t) context_handle;
800Sstevel@tonic-gate 	mech = __gss_get_mechanism(ctx->mech_type);
810Sstevel@tonic-gate 
820Sstevel@tonic-gate 	if (mech) {
83*13132SGlenn.Barry@oracle.com 		if (mech->gss_unseal) {
840Sstevel@tonic-gate 			status = mech->gss_unseal(
850Sstevel@tonic-gate 						mech->context,
860Sstevel@tonic-gate 						minor_status,
870Sstevel@tonic-gate 						ctx->internal_ctx_id,
880Sstevel@tonic-gate 						input_message_buffer,
890Sstevel@tonic-gate 						output_message_buffer,
900Sstevel@tonic-gate 						conf_state,
910Sstevel@tonic-gate 						qop_state);
92*13132SGlenn.Barry@oracle.com 			if (status != GSS_S_COMPLETE)
93*13132SGlenn.Barry@oracle.com 				map_error(minor_status, mech);
94*13132SGlenn.Barry@oracle.com 		} else
950Sstevel@tonic-gate 			status = GSS_S_UNAVAILABLE;
960Sstevel@tonic-gate 
970Sstevel@tonic-gate 		return (status);
980Sstevel@tonic-gate 	}
990Sstevel@tonic-gate 
1000Sstevel@tonic-gate /* EXPORT DELETE END */
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate 	return (GSS_S_BAD_MECH);
1030Sstevel@tonic-gate }
1040Sstevel@tonic-gate 
1050Sstevel@tonic-gate OM_uint32
gss_unwrap(minor_status,context_handle,input_message_buffer,output_message_buffer,conf_state,qop_state)1060Sstevel@tonic-gate gss_unwrap(minor_status,
1070Sstevel@tonic-gate 		context_handle,
1080Sstevel@tonic-gate 		input_message_buffer,
1090Sstevel@tonic-gate 		output_message_buffer,
1100Sstevel@tonic-gate 		conf_state,
1110Sstevel@tonic-gate 		qop_state)
1120Sstevel@tonic-gate 
1130Sstevel@tonic-gate OM_uint32 *		minor_status;
1140Sstevel@tonic-gate const gss_ctx_id_t	context_handle;
1150Sstevel@tonic-gate const gss_buffer_t	input_message_buffer;
1160Sstevel@tonic-gate gss_buffer_t		output_message_buffer;
1170Sstevel@tonic-gate int *			conf_state;
1180Sstevel@tonic-gate gss_qop_t *		qop_state;
1190Sstevel@tonic-gate 
1200Sstevel@tonic-gate {
1210Sstevel@tonic-gate 	return (gss_unseal(minor_status, (gss_ctx_id_t)context_handle,
1220Sstevel@tonic-gate 			(gss_buffer_t)input_message_buffer,
1230Sstevel@tonic-gate 			output_message_buffer, conf_state, (int *) qop_state));
1240Sstevel@tonic-gate }
125