17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5503a2b89SPeter Shoults * Common Development and Distribution License (the "License"). 6503a2b89SPeter Shoults * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*5e01956fSGlenn Barry * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 237c478bd9Sstevel@tonic-gate */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate /* 267c478bd9Sstevel@tonic-gate * glue routine for gss_delete_sec_context 277c478bd9Sstevel@tonic-gate */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #include <mechglueP.h> 30*5e01956fSGlenn Barry #include "gssapiP_generic.h" 317c478bd9Sstevel@tonic-gate #include <stdio.h> 327c478bd9Sstevel@tonic-gate #ifdef HAVE_STDLIB_H 337c478bd9Sstevel@tonic-gate #include <stdlib.h> 347c478bd9Sstevel@tonic-gate #endif 357c478bd9Sstevel@tonic-gate 36503a2b89SPeter Shoults static OM_uint32 37503a2b89SPeter Shoults val_del_sec_ctx_args( 38503a2b89SPeter Shoults OM_uint32 *minor_status, 39503a2b89SPeter Shoults gss_ctx_id_t *context_handle, 40503a2b89SPeter Shoults gss_buffer_t output_token) 41503a2b89SPeter Shoults { 42503a2b89SPeter Shoults 43503a2b89SPeter Shoults /* Initialize outputs. */ 44503a2b89SPeter Shoults 45503a2b89SPeter Shoults if (minor_status != NULL) 46503a2b89SPeter Shoults *minor_status = 0; 47503a2b89SPeter Shoults 48503a2b89SPeter Shoults if (output_token != GSS_C_NO_BUFFER) { 49503a2b89SPeter Shoults output_token->length = 0; 50503a2b89SPeter Shoults output_token->value = NULL; 51503a2b89SPeter Shoults } 52503a2b89SPeter Shoults 53503a2b89SPeter Shoults /* Validate arguments. */ 54503a2b89SPeter Shoults 55503a2b89SPeter Shoults if (minor_status == NULL) 56503a2b89SPeter Shoults return (GSS_S_CALL_INACCESSIBLE_WRITE); 57503a2b89SPeter Shoults 58503a2b89SPeter Shoults if (context_handle == NULL || *context_handle == GSS_C_NO_CONTEXT) 59503a2b89SPeter Shoults return (GSS_S_CALL_INACCESSIBLE_WRITE | GSS_S_NO_CONTEXT); 60503a2b89SPeter Shoults 61503a2b89SPeter Shoults return (GSS_S_COMPLETE); 62503a2b89SPeter Shoults } 63503a2b89SPeter Shoults 647c478bd9Sstevel@tonic-gate OM_uint32 657c478bd9Sstevel@tonic-gate gss_delete_sec_context(minor_status, 667c478bd9Sstevel@tonic-gate context_handle, 677c478bd9Sstevel@tonic-gate output_token) 687c478bd9Sstevel@tonic-gate 697c478bd9Sstevel@tonic-gate OM_uint32 * minor_status; 707c478bd9Sstevel@tonic-gate gss_ctx_id_t * context_handle; 717c478bd9Sstevel@tonic-gate gss_buffer_t output_token; 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate { 747c478bd9Sstevel@tonic-gate OM_uint32 status; 757c478bd9Sstevel@tonic-gate gss_union_ctx_id_t ctx; 767c478bd9Sstevel@tonic-gate 77503a2b89SPeter Shoults status = val_del_sec_ctx_args(minor_status, 78503a2b89SPeter Shoults context_handle, 79503a2b89SPeter Shoults output_token); 80503a2b89SPeter Shoults if (status != GSS_S_COMPLETE) 81503a2b89SPeter Shoults return (status); 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate /* 847c478bd9Sstevel@tonic-gate * select the approprate underlying mechanism routine and 857c478bd9Sstevel@tonic-gate * call it. 867c478bd9Sstevel@tonic-gate */ 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate ctx = (gss_union_ctx_id_t) *context_handle; 89*5e01956fSGlenn Barry if (GSSINT_CHK_LOOP(ctx)) 90*5e01956fSGlenn Barry return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT); 917c478bd9Sstevel@tonic-gate 92*5e01956fSGlenn Barry status = gssint_delete_internal_sec_context(minor_status, 93*5e01956fSGlenn Barry ctx->mech_type, 947c478bd9Sstevel@tonic-gate &ctx->internal_ctx_id, 957c478bd9Sstevel@tonic-gate output_token); 96*5e01956fSGlenn Barry if (status) 97*5e01956fSGlenn Barry return status; 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate /* now free up the space for the union context structure */ 1007c478bd9Sstevel@tonic-gate free(ctx->mech_type->elements); 1017c478bd9Sstevel@tonic-gate free(ctx->mech_type); 1027c478bd9Sstevel@tonic-gate free(*context_handle); 103*5e01956fSGlenn Barry *context_handle = GSS_C_NO_CONTEXT; 1047c478bd9Sstevel@tonic-gate 105*5e01956fSGlenn Barry return (GSS_S_COMPLETE); 1067c478bd9Sstevel@tonic-gate } 107