1*ae771770SStanislav Sedov /*-
2*ae771770SStanislav Sedov * Copyright (c) 2005 Doug Rabson
3*ae771770SStanislav Sedov * All rights reserved.
4*ae771770SStanislav Sedov *
5*ae771770SStanislav Sedov * Redistribution and use in source and binary forms, with or without
6*ae771770SStanislav Sedov * modification, are permitted provided that the following conditions
7*ae771770SStanislav Sedov * are met:
8*ae771770SStanislav Sedov * 1. Redistributions of source code must retain the above copyright
9*ae771770SStanislav Sedov * notice, this list of conditions and the following disclaimer.
10*ae771770SStanislav Sedov * 2. Redistributions in binary form must reproduce the above copyright
11*ae771770SStanislav Sedov * notice, this list of conditions and the following disclaimer in the
12*ae771770SStanislav Sedov * documentation and/or other materials provided with the distribution.
13*ae771770SStanislav Sedov *
14*ae771770SStanislav Sedov * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15*ae771770SStanislav Sedov * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16*ae771770SStanislav Sedov * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17*ae771770SStanislav Sedov * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18*ae771770SStanislav Sedov * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19*ae771770SStanislav Sedov * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20*ae771770SStanislav Sedov * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21*ae771770SStanislav Sedov * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22*ae771770SStanislav Sedov * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23*ae771770SStanislav Sedov * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24*ae771770SStanislav Sedov * SUCH DAMAGE.
25*ae771770SStanislav Sedov *
26*ae771770SStanislav Sedov * $FreeBSD: src/lib/libgssapi/gss_delete_sec_context.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
27*ae771770SStanislav Sedov */
28*ae771770SStanislav Sedov
29*ae771770SStanislav Sedov #include "mech_locl.h"
30*ae771770SStanislav Sedov
31*ae771770SStanislav Sedov GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
gss_delete_sec_context(OM_uint32 * minor_status,gss_ctx_id_t * context_handle,gss_buffer_t output_token)32*ae771770SStanislav Sedov gss_delete_sec_context(OM_uint32 *minor_status,
33*ae771770SStanislav Sedov gss_ctx_id_t *context_handle,
34*ae771770SStanislav Sedov gss_buffer_t output_token)
35*ae771770SStanislav Sedov {
36*ae771770SStanislav Sedov OM_uint32 major_status;
37*ae771770SStanislav Sedov struct _gss_context *ctx = (struct _gss_context *) *context_handle;
38*ae771770SStanislav Sedov
39*ae771770SStanislav Sedov if (output_token)
40*ae771770SStanislav Sedov _mg_buffer_zero(output_token);
41*ae771770SStanislav Sedov
42*ae771770SStanislav Sedov *minor_status = 0;
43*ae771770SStanislav Sedov if (ctx) {
44*ae771770SStanislav Sedov /*
45*ae771770SStanislav Sedov * If we have an implementation ctx, delete it,
46*ae771770SStanislav Sedov * otherwise fake an empty token.
47*ae771770SStanislav Sedov */
48*ae771770SStanislav Sedov if (ctx->gc_ctx) {
49*ae771770SStanislav Sedov major_status = ctx->gc_mech->gm_delete_sec_context(
50*ae771770SStanislav Sedov minor_status, &ctx->gc_ctx, output_token);
51*ae771770SStanislav Sedov }
52*ae771770SStanislav Sedov free(ctx);
53*ae771770SStanislav Sedov *context_handle = GSS_C_NO_CONTEXT;
54*ae771770SStanislav Sedov }
55*ae771770SStanislav Sedov
56*ae771770SStanislav Sedov return (GSS_S_COMPLETE);
57*ae771770SStanislav Sedov }
58