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 for gss_delete_sec_context
270Sstevel@tonic-gate */
280Sstevel@tonic-gate
290Sstevel@tonic-gate #include <mechglueP.h>
30*13132SGlenn.Barry@oracle.com #include "gssapiP_generic.h"
310Sstevel@tonic-gate #include <stdio.h>
320Sstevel@tonic-gate #ifdef HAVE_STDLIB_H
330Sstevel@tonic-gate #include <stdlib.h>
340Sstevel@tonic-gate #endif
350Sstevel@tonic-gate
369698SPeter.Shoults@Sun.COM static OM_uint32
val_del_sec_ctx_args(OM_uint32 * minor_status,gss_ctx_id_t * context_handle,gss_buffer_t output_token)379698SPeter.Shoults@Sun.COM val_del_sec_ctx_args(
389698SPeter.Shoults@Sun.COM OM_uint32 *minor_status,
399698SPeter.Shoults@Sun.COM gss_ctx_id_t *context_handle,
409698SPeter.Shoults@Sun.COM gss_buffer_t output_token)
419698SPeter.Shoults@Sun.COM {
429698SPeter.Shoults@Sun.COM
439698SPeter.Shoults@Sun.COM /* Initialize outputs. */
449698SPeter.Shoults@Sun.COM
459698SPeter.Shoults@Sun.COM if (minor_status != NULL)
469698SPeter.Shoults@Sun.COM *minor_status = 0;
479698SPeter.Shoults@Sun.COM
489698SPeter.Shoults@Sun.COM if (output_token != GSS_C_NO_BUFFER) {
499698SPeter.Shoults@Sun.COM output_token->length = 0;
509698SPeter.Shoults@Sun.COM output_token->value = NULL;
519698SPeter.Shoults@Sun.COM }
529698SPeter.Shoults@Sun.COM
539698SPeter.Shoults@Sun.COM /* Validate arguments. */
549698SPeter.Shoults@Sun.COM
559698SPeter.Shoults@Sun.COM if (minor_status == NULL)
569698SPeter.Shoults@Sun.COM return (GSS_S_CALL_INACCESSIBLE_WRITE);
579698SPeter.Shoults@Sun.COM
589698SPeter.Shoults@Sun.COM if (context_handle == NULL || *context_handle == GSS_C_NO_CONTEXT)
599698SPeter.Shoults@Sun.COM return (GSS_S_CALL_INACCESSIBLE_WRITE | GSS_S_NO_CONTEXT);
609698SPeter.Shoults@Sun.COM
619698SPeter.Shoults@Sun.COM return (GSS_S_COMPLETE);
629698SPeter.Shoults@Sun.COM }
639698SPeter.Shoults@Sun.COM
640Sstevel@tonic-gate OM_uint32
gss_delete_sec_context(minor_status,context_handle,output_token)650Sstevel@tonic-gate gss_delete_sec_context(minor_status,
660Sstevel@tonic-gate context_handle,
670Sstevel@tonic-gate output_token)
680Sstevel@tonic-gate
690Sstevel@tonic-gate OM_uint32 * minor_status;
700Sstevel@tonic-gate gss_ctx_id_t * context_handle;
710Sstevel@tonic-gate gss_buffer_t output_token;
720Sstevel@tonic-gate
730Sstevel@tonic-gate {
740Sstevel@tonic-gate OM_uint32 status;
750Sstevel@tonic-gate gss_union_ctx_id_t ctx;
760Sstevel@tonic-gate
779698SPeter.Shoults@Sun.COM status = val_del_sec_ctx_args(minor_status,
789698SPeter.Shoults@Sun.COM context_handle,
799698SPeter.Shoults@Sun.COM output_token);
809698SPeter.Shoults@Sun.COM if (status != GSS_S_COMPLETE)
819698SPeter.Shoults@Sun.COM return (status);
820Sstevel@tonic-gate
830Sstevel@tonic-gate /*
840Sstevel@tonic-gate * select the approprate underlying mechanism routine and
850Sstevel@tonic-gate * call it.
860Sstevel@tonic-gate */
870Sstevel@tonic-gate
880Sstevel@tonic-gate ctx = (gss_union_ctx_id_t) *context_handle;
89*13132SGlenn.Barry@oracle.com if (GSSINT_CHK_LOOP(ctx))
90*13132SGlenn.Barry@oracle.com return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT);
910Sstevel@tonic-gate
92*13132SGlenn.Barry@oracle.com status = gssint_delete_internal_sec_context(minor_status,
93*13132SGlenn.Barry@oracle.com ctx->mech_type,
94*13132SGlenn.Barry@oracle.com &ctx->internal_ctx_id,
95*13132SGlenn.Barry@oracle.com output_token);
96*13132SGlenn.Barry@oracle.com if (status)
97*13132SGlenn.Barry@oracle.com return status;
980Sstevel@tonic-gate
99*13132SGlenn.Barry@oracle.com /* now free up the space for the union context structure */
100*13132SGlenn.Barry@oracle.com free(ctx->mech_type->elements);
101*13132SGlenn.Barry@oracle.com free(ctx->mech_type);
102*13132SGlenn.Barry@oracle.com free(*context_handle);
103*13132SGlenn.Barry@oracle.com *context_handle = GSS_C_NO_CONTEXT;
1040Sstevel@tonic-gate
105*13132SGlenn.Barry@oracle.com return (GSS_S_COMPLETE);
1060Sstevel@tonic-gate }
107