fb98811412f1a61efdc30b38091bf4708148a806Allan Foster/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
4c0f084e476c05989eb702c500a763ef09ba044ejeff.schenk/*
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster * Copyright 1993 by OpenVision Technologies, Inc.
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster *
6e153e9671eb382c49354ab856404a71477cce58jeff.schenk * Permission to use, copy, modify, distribute, and sell this software
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster * and its documentation for any purpose is hereby granted without fee,
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster * provided that the above copyright notice appears in all copies and
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster * that both that copyright notice and this permission notice appear in
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster * supporting documentation, and that the name of OpenVision not be used
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster * in advertising or publicity pertaining to distribution of the software
6e153e9671eb382c49354ab856404a71477cce58jeff.schenk * without specific, written prior permission. OpenVision makes no
6e153e9671eb382c49354ab856404a71477cce58jeff.schenk * representations about the suitability of this software for any
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster * purpose. It is provided "as is" without express or implied warranty.
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster *
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster * PERFORMANCE OF THIS SOFTWARE.
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster */
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster#include "gssapiP_krb5.h"
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster/*
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster * $Id: process_context_token.c 23457 2009-12-08 00:04:48Z tlyu $
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster */
4c0f084e476c05989eb702c500a763ef09ba044ejeff.schenk
fb98811412f1a61efdc30b38091bf4708148a806Allan FosterOM_uint32
fb98811412f1a61efdc30b38091bf4708148a806Allan Fosterkrb5_gss_process_context_token(minor_status, context_handle,
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster token_buffer)
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster OM_uint32 *minor_status;
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster gss_ctx_id_t context_handle;
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster gss_buffer_t token_buffer;
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster{
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster krb5_gss_ctx_id_rec *ctx;
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster OM_uint32 majerr;
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster /* validate the context handle */
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster if (! kg_validate_ctx_id(context_handle)) {
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster *minor_status = (OM_uint32) G_VALIDATE_FAILED;
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster return(GSS_S_NO_CONTEXT);
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster }
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster ctx = (krb5_gss_ctx_id_t) context_handle;
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster if (! ctx->established) {
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster *minor_status = KG_CTX_INCOMPLETE;
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster return(GSS_S_NO_CONTEXT);
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster }
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster /* "unseal" the token */
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster if (GSS_ERROR(majerr = kg_unseal(minor_status, context_handle,
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster token_buffer,
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster GSS_C_NO_BUFFER, NULL, NULL,
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster KG_TOK_DEL_CTX)))
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster return(majerr);
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster /* that's it. delete the context */
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster return(krb5_gss_delete_sec_context(minor_status, &context_handle,
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster GSS_C_NO_BUFFER));
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster}
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster