Home | History | Annotate | Download | only in libgss
      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_unseal
     31  */
     32 
     33 #include <mechglueP.h>
     34 
     35 OM_uint32
     36 gss_unseal(minor_status,
     37 		context_handle,
     38 		input_message_buffer,
     39 		output_message_buffer,
     40 		conf_state,
     41 		qop_state)
     42 
     43 OM_uint32 *		minor_status;
     44 gss_ctx_id_t		context_handle;
     45 gss_buffer_t		input_message_buffer;
     46 gss_buffer_t		output_message_buffer;
     47 int *			conf_state;
     48 int *			qop_state;
     49 
     50 {
     51 /* EXPORT DELETE START */
     52 	OM_uint32		status;
     53 	gss_union_ctx_id_t	ctx;
     54 	gss_mechanism		mech;
     55 
     56 	if (minor_status == NULL)
     57 		return (GSS_S_CALL_INACCESSIBLE_WRITE);
     58 	*minor_status = 0;
     59 
     60 	if (context_handle == GSS_C_NO_CONTEXT)
     61 		return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT);
     62 
     63 	if (GSS_EMPTY_BUFFER(input_message_buffer))
     64 		return (GSS_S_CALL_INACCESSIBLE_READ);
     65 
     66 	if (output_message_buffer == NULL)
     67 		return (GSS_S_CALL_INACCESSIBLE_WRITE);
     68 
     69 	output_message_buffer->length = 0;
     70 	output_message_buffer->value = NULL;
     71 
     72 	/*
     73 	 * select the approprate underlying mechanism routine and
     74 	 * call it.
     75 	 */
     76 
     77 	ctx = (gss_union_ctx_id_t) context_handle;
     78 	mech = __gss_get_mechanism(ctx->mech_type);
     79 
     80 	if (mech) {
     81 		if (mech->gss_unseal)
     82 			status = mech->gss_unseal(
     83 						mech->context,
     84 						minor_status,
     85 						ctx->internal_ctx_id,
     86 						input_message_buffer,
     87 						output_message_buffer,
     88 						conf_state,
     89 						qop_state);
     90 		else
     91 			status = GSS_S_UNAVAILABLE;
     92 
     93 		return (status);
     94 	}
     95 
     96 /* EXPORT DELETE END */
     97 
     98 	return (GSS_S_BAD_MECH);
     99 }
    100 
    101 OM_uint32
    102 gss_unwrap(minor_status,
    103 		context_handle,
    104 		input_message_buffer,
    105 		output_message_buffer,
    106 		conf_state,
    107 		qop_state)
    108 
    109 OM_uint32 *		minor_status;
    110 const gss_ctx_id_t	context_handle;
    111 const gss_buffer_t	input_message_buffer;
    112 gss_buffer_t		output_message_buffer;
    113 int *			conf_state;
    114 gss_qop_t *		qop_state;
    115 
    116 {
    117 	return (gss_unseal(minor_status, (gss_ctx_id_t)context_handle,
    118 			(gss_buffer_t)input_message_buffer,
    119 			output_message_buffer, conf_state, (int *) qop_state));
    120 }
    121