17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * Copyright 1993 by OpenVision Technologies, Inc.
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * Permission to use, copy, modify, distribute, and sell this software
57c478bd9Sstevel@tonic-gate  * and its documentation for any purpose is hereby granted without fee,
67c478bd9Sstevel@tonic-gate  * provided that the above copyright notice appears in all copies and
77c478bd9Sstevel@tonic-gate  * that both that copyright notice and this permission notice appear in
87c478bd9Sstevel@tonic-gate  * supporting documentation, and that the name of OpenVision not be used
97c478bd9Sstevel@tonic-gate  * in advertising or publicity pertaining to distribution of the software
107c478bd9Sstevel@tonic-gate  * without specific, written prior permission. OpenVision makes no
117c478bd9Sstevel@tonic-gate  * representations about the suitability of this software for any
127c478bd9Sstevel@tonic-gate  * purpose.  It is provided "as is" without express or implied warranty.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
157c478bd9Sstevel@tonic-gate  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
167c478bd9Sstevel@tonic-gate  * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
177c478bd9Sstevel@tonic-gate  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
187c478bd9Sstevel@tonic-gate  * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
197c478bd9Sstevel@tonic-gate  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
207c478bd9Sstevel@tonic-gate  * PERFORMANCE OF THIS SOFTWARE.
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate 
23ab9b2e15Sgtb #include "gssapiP_krb5.h"
247c478bd9Sstevel@tonic-gate 
257c478bd9Sstevel@tonic-gate /*
26*159d09a2SMark Phalan  * $Id: process_context_token.c 18396 2006-07-25 20:29:43Z lxs $
277c478bd9Sstevel@tonic-gate  */
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate OM_uint32
krb5_gss_process_context_token(minor_status,context_handle,token_buffer)30ab9b2e15Sgtb krb5_gss_process_context_token(minor_status, context_handle,
317c478bd9Sstevel@tonic-gate 			       token_buffer)
327c478bd9Sstevel@tonic-gate      OM_uint32 *minor_status;
337c478bd9Sstevel@tonic-gate      gss_ctx_id_t context_handle;
347c478bd9Sstevel@tonic-gate      gss_buffer_t token_buffer;
357c478bd9Sstevel@tonic-gate {
367c478bd9Sstevel@tonic-gate    krb5_gss_ctx_id_rec *ctx;
377c478bd9Sstevel@tonic-gate    OM_uint32 majerr;
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate    /* validate the context handle */
407c478bd9Sstevel@tonic-gate    if (! kg_validate_ctx_id(context_handle)) {
417c478bd9Sstevel@tonic-gate       *minor_status = (OM_uint32) G_VALIDATE_FAILED;
427c478bd9Sstevel@tonic-gate       return(GSS_S_NO_CONTEXT);
437c478bd9Sstevel@tonic-gate    }
447c478bd9Sstevel@tonic-gate 
45ab9b2e15Sgtb    ctx = (krb5_gss_ctx_id_t) context_handle;
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate    if (! ctx->established) {
487c478bd9Sstevel@tonic-gate       *minor_status = KG_CTX_INCOMPLETE;
497c478bd9Sstevel@tonic-gate       return(GSS_S_NO_CONTEXT);
507c478bd9Sstevel@tonic-gate    }
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate    /* "unseal" the token */
537c478bd9Sstevel@tonic-gate 
54ab9b2e15Sgtb    if (GSS_ERROR(majerr = kg_unseal(minor_status, context_handle,
557c478bd9Sstevel@tonic-gate                                     token_buffer,
567c478bd9Sstevel@tonic-gate 				    GSS_C_NO_BUFFER, NULL, NULL,
57ab9b2e15Sgtb 				    KG_TOK_DEL_CTX)))
587c478bd9Sstevel@tonic-gate       return(majerr);
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate    /* that's it.  delete the context */
617c478bd9Sstevel@tonic-gate 
62ab9b2e15Sgtb    return(krb5_gss_delete_sec_context(minor_status, &context_handle,
63ab9b2e15Sgtb 				      GSS_C_NO_BUFFER));
647c478bd9Sstevel@tonic-gate }
65