process_context_token.c revision 5053:532e59d6bffd
1#pragma ident "%Z%%M% %I% %E% SMI" 2 3/* 4 * Copyright 1993 by OpenVision Technologies, Inc. 5 * 6 * Permission to use, copy, modify, distribute, and sell this software 7 * and its documentation for any purpose is hereby granted without fee, 8 * provided that the above copyright notice appears in all copies and 9 * that both that copyright notice and this permission notice appear in 10 * supporting documentation, and that the name of OpenVision not be used 11 * in advertising or publicity pertaining to distribution of the software 12 * without specific, written prior permission. OpenVision makes no 13 * representations about the suitability of this software for any 14 * purpose. It is provided "as is" without express or implied warranty. 15 * 16 * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 18 * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR 19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 20 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 21 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 22 * PERFORMANCE OF THIS SOFTWARE. 23 */ 24 25#include "gssapiP_krb5.h" 26 27/* 28 * $Id: process_context_token.c 16171 2004-03-15 17:45:01Z raeburn $ 29 */ 30 31OM_uint32 32krb5_gss_process_context_token(minor_status, context_handle, 33 token_buffer) 34 OM_uint32 *minor_status; 35 gss_ctx_id_t context_handle; 36 gss_buffer_t token_buffer; 37{ 38 krb5_gss_ctx_id_rec *ctx; 39 OM_uint32 majerr; 40 41 /* validate the context handle */ 42 if (! kg_validate_ctx_id(context_handle)) { 43 *minor_status = (OM_uint32) G_VALIDATE_FAILED; 44 return(GSS_S_NO_CONTEXT); 45 } 46 47 ctx = (krb5_gss_ctx_id_t) context_handle; 48 49 if (! ctx->established) { 50 *minor_status = KG_CTX_INCOMPLETE; 51 return(GSS_S_NO_CONTEXT); 52 } 53 54 /* "unseal" the token */ 55 56 if (GSS_ERROR(majerr = kg_unseal(minor_status, context_handle, 57 token_buffer, 58 GSS_C_NO_BUFFER, NULL, NULL, 59 KG_TOK_DEL_CTX))) 60 return(majerr); 61 62 /* that's it. delete the context */ 63 64 return(krb5_gss_delete_sec_context(minor_status, &context_handle, 65 GSS_C_NO_BUFFER)); 66} 67