2 * Copyright 1993 by OpenVision Technologies, Inc.
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without fee,
6 * provided that the above copyright notice appears in all copies and
7 * that both that copyright notice and this permission notice appear in
8 * supporting documentation, and that the name of OpenVision not be used
9 * in advertising or publicity pertaining to distribution of the software
10 * without specific, written prior permission. OpenVision makes no
11 * representations about the suitability of this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
14 * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
18 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
19 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
23 #include "gssapiP_krb5.h"
26 krb5_gss_delete_sec_context(context, minor_status, context_handle, output_token)
28 OM_uint32 *minor_status;
29 gss_ctx_id_t *context_handle;
30 gss_buffer_t output_token;
32 krb5_gss_ctx_id_rec *ctx;
35 output_token->length = 0;
36 output_token->value = NULL;
40 if (*context_handle == GSS_C_NO_CONTEXT) {
42 return(GSS_S_COMPLETE);
46 /* validate the context handle */
47 if (! kg_validate_ctx_id(*context_handle)) {
48 *minor_status = (OM_uint32) G_VALIDATE_FAILED;
49 return(GSS_S_NO_CONTEXT);
52 /* construct a delete context token if necessary */
56 gss_buffer_desc empty;
57 empty.length = 0; empty.value = NULL;
59 if (major = kg_seal(minor_status, *context_handle, 0, GSS_C_QOP_DEFAULT,
60 &empty, NULL, output_token, KG_TOK_DEL_CTX))
64 /* invalidate the context handle */
66 (void)kg_delete_ctx_id(*context_handle);
68 /* free all the context state */
70 ctx = (gss_ctx_id_t) *context_handle;
72 if (ctx->enc.processed)
73 krb5_finish_key(context, &ctx->enc.eblock);
74 krb5_free_keyblock(context, ctx->enc.key);
76 if (ctx->seq.processed)
77 krb5_finish_key(context, &ctx->seq.eblock);
79 krb5_free_principal(context, ctx->here);
80 krb5_free_principal(context, ctx->there);
81 krb5_free_keyblock(context, ctx->subkey);
85 /* zero the handle itself */
87 *context_handle = GSS_C_NO_CONTEXT;
90 return(GSS_S_COMPLETE);