1153838Sdfr/*- 2153838Sdfr * Copyright (c) 2005 Doug Rabson 3153838Sdfr * All rights reserved. 4153838Sdfr * 5153838Sdfr * Redistribution and use in source and binary forms, with or without 6153838Sdfr * modification, are permitted provided that the following conditions 7153838Sdfr * are met: 8153838Sdfr * 1. Redistributions of source code must retain the above copyright 9153838Sdfr * notice, this list of conditions and the following disclaimer. 10153838Sdfr * 2. Redistributions in binary form must reproduce the above copyright 11153838Sdfr * notice, this list of conditions and the following disclaimer in the 12153838Sdfr * documentation and/or other materials provided with the distribution. 13153838Sdfr * 14153838Sdfr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15153838Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16153838Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17153838Sdfr * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18153838Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19153838Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20153838Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21153838Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22153838Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23153838Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24153838Sdfr * SUCH DAMAGE. 25153838Sdfr * 26153838Sdfr * $FreeBSD$ 27153838Sdfr */ 28153838Sdfr 29153838Sdfr#include <gssapi/gssapi.h> 30153838Sdfr#include <stdlib.h> 31153838Sdfr#include <errno.h> 32153838Sdfr 33153838Sdfr#include "mech_switch.h" 34153838Sdfr#include "context.h" 35153838Sdfr#include "cred.h" 36153838Sdfr 37153838SdfrOM_uint32 38153838Sdfrgsskrb5_register_acceptor_identity(const char *identity) 39153838Sdfr{ 40153838Sdfr struct _gss_mech_switch *m; 41153838Sdfr 42153838Sdfr _gss_load_mech(); 43153838Sdfr SLIST_FOREACH(m, &_gss_mechs, gm_link) { 44153838Sdfr if (m->gm_krb5_register_acceptor_identity) 45153838Sdfr m->gm_krb5_register_acceptor_identity(identity); 46153838Sdfr } 47153838Sdfr 48153838Sdfr return (GSS_S_COMPLETE); 49153838Sdfr} 50153838Sdfr 51153838SdfrOM_uint32 52153838Sdfrgss_krb5_copy_ccache(OM_uint32 *minor_status, 53153838Sdfr gss_cred_id_t cred_handle, 54153838Sdfr struct krb5_ccache_data *out) 55153838Sdfr{ 56153838Sdfr struct _gss_mechanism_cred *mcp; 57153838Sdfr struct _gss_cred *cred = (struct _gss_cred *) cred_handle; 58153838Sdfr struct _gss_mech_switch *m; 59153838Sdfr 60153838Sdfr *minor_status = 0; 61153838Sdfr 62153838Sdfr SLIST_FOREACH(mcp, &cred->gc_mc, gmc_link) { 63153838Sdfr m = mcp->gmc_mech; 64153838Sdfr if (m->gm_krb5_copy_ccache) 65153838Sdfr return (m->gm_krb5_copy_ccache(minor_status, 66153838Sdfr mcp->gmc_cred, out)); 67153838Sdfr } 68153838Sdfr 69153838Sdfr return (GSS_S_FAILURE); 70153838Sdfr} 71153838Sdfr 72153838SdfrOM_uint32 73153838Sdfrgss_krb5_compat_des3_mic(OM_uint32 *minor_status, 74153838Sdfr gss_ctx_id_t context_handle, int flag) 75153838Sdfr{ 76153838Sdfr struct _gss_context *ctx = (struct _gss_context *) context_handle; 77153838Sdfr struct _gss_mech_switch *m = ctx->gc_mech; 78153838Sdfr 79153838Sdfr *minor_status = 0; 80153838Sdfr 81153838Sdfr if (m->gm_krb5_compat_des3_mic) 82153838Sdfr return (m->gm_krb5_compat_des3_mic(minor_status, 83153838Sdfr ctx->gc_ctx, flag)); 84153838Sdfr 85153838Sdfr return (GSS_S_FAILURE); 86153838Sdfr} 87153838Sdfr 88