1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 /* 3 * Copyright 1993 by OpenVision Technologies, Inc. 4 * 5 * Permission to use, copy, modify, distribute, and sell this software 6 * and its documentation for any purpose is hereby granted without fee, 7 * provided that the above copyright notice appears in all copies and 8 * that both that copyright notice and this permission notice appear in 9 * supporting documentation, and that the name of OpenVision not be used 10 * in advertising or publicity pertaining to distribution of the software 11 * without specific, written prior permission. OpenVision makes no 12 * representations about the suitability of this software for any 13 * purpose. It is provided "as is" without express or implied warranty. 14 * 15 * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 17 * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR 18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 19 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 20 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 21 * PERFORMANCE OF THIS SOFTWARE. 22 */ 23 24 #include "gssapiP_krb5.h" 25 26 /* 27 * $Id$ 28 */ 29 30 OM_uint32 KRB5_CALLCONV 31 krb5_gss_delete_sec_context(minor_status, context_handle, output_token) 32 OM_uint32 *minor_status; 33 gss_ctx_id_t *context_handle; 34 gss_buffer_t output_token; 35 { 36 krb5_context context; 37 krb5_gss_ctx_id_rec *ctx; 38 39 if (output_token) { 40 output_token->length = 0; 41 output_token->value = NULL; 42 } 43 44 /*SUPPRESS 29*/ 45 if (*context_handle == GSS_C_NO_CONTEXT) { 46 *minor_status = 0; 47 return(GSS_S_COMPLETE); 48 } 49 50 ctx = (krb5_gss_ctx_id_t) *context_handle; 51 context = ctx->k5_context; 52 53 /* free all the context state */ 54 55 if (ctx->seqstate) 56 g_seqstate_free(ctx->seqstate); 57 58 if (ctx->enc) 59 krb5_k_free_key(context, ctx->enc); 60 61 if (ctx->seq) 62 krb5_k_free_key(context, ctx->seq); 63 64 if (ctx->here) 65 kg_release_name(context, &ctx->here); 66 if (ctx->there) 67 kg_release_name(context, &ctx->there); 68 if (ctx->subkey) 69 krb5_k_free_key(context, ctx->subkey); 70 if (ctx->acceptor_subkey) 71 krb5_k_free_key(context, ctx->acceptor_subkey); 72 73 if (ctx->auth_context) { 74 if (ctx->cred_rcache) 75 (void)krb5_auth_con_setrcache(context, ctx->auth_context, NULL); 76 77 krb5_auth_con_free(context, ctx->auth_context); 78 } 79 80 if (ctx->mech_used) 81 krb5_gss_release_oid(minor_status, &ctx->mech_used); 82 83 if (ctx->authdata) 84 krb5_free_authdata(context, ctx->authdata); 85 86 if (ctx->k5_context) 87 krb5_free_context(ctx->k5_context); 88 89 /* Zero out context */ 90 zap(ctx, sizeof(*ctx)); 91 xfree(ctx); 92 93 /* zero the handle itself */ 94 95 *context_handle = GSS_C_NO_CONTEXT; 96 97 *minor_status = 0; 98 return(GSS_S_COMPLETE); 99 } 100