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(OM_uint32 *minor_status, 32 gss_ctx_id_t *context_handle, 33 gss_buffer_t output_token) 34 { 35 krb5_context context; 36 krb5_gss_ctx_id_rec *ctx; 37 38 if (output_token) { 39 output_token->length = 0; 40 output_token->value = NULL; 41 } 42 43 /*SUPPRESS 29*/ 44 if (*context_handle == GSS_C_NO_CONTEXT) { 45 *minor_status = 0; 46 return(GSS_S_COMPLETE); 47 } 48 49 ctx = (krb5_gss_ctx_id_t) *context_handle; 50 context = ctx->k5_context; 51 52 /* free all the context state */ 53 54 if (ctx->seqstate) 55 g_seqstate_free(ctx->seqstate); 56 57 if (ctx->enc) 58 krb5_k_free_key(context, ctx->enc); 59 60 if (ctx->seq) 61 krb5_k_free_key(context, ctx->seq); 62 63 if (ctx->here) 64 kg_release_name(context, &ctx->here); 65 if (ctx->there) 66 kg_release_name(context, &ctx->there); 67 if (ctx->subkey) 68 krb5_k_free_key(context, ctx->subkey); 69 if (ctx->acceptor_subkey) 70 krb5_k_free_key(context, ctx->acceptor_subkey); 71 72 if (ctx->auth_context) { 73 if (ctx->cred_rcache) 74 (void)krb5_auth_con_setrcache(context, ctx->auth_context, NULL); 75 76 krb5_auth_con_free(context, ctx->auth_context); 77 } 78 79 if (ctx->mech_used) 80 krb5_gss_release_oid(minor_status, &ctx->mech_used); 81 82 if (ctx->authdata) 83 krb5_free_authdata(context, ctx->authdata); 84 85 if (ctx->k5_context) 86 krb5_free_context(ctx->k5_context); 87 88 /* Zero out context */ 89 zap(ctx, sizeof(*ctx)); 90 xfree(ctx); 91 92 /* zero the handle itself */ 93 94 *context_handle = GSS_C_NO_CONTEXT; 95 96 *minor_status = 0; 97 return(GSS_S_COMPLETE); 98 } 99