Path: blob/main/crypto/heimdal/lib/gssapi/krb5/compat.c
34923 views
/*1* Copyright (c) 2003 - 2005 Kungliga Tekniska Högskolan2* (Royal Institute of Technology, Stockholm, Sweden).3* All rights reserved.4*5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8*9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11*12* 2. Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in the14* documentation and/or other materials provided with the distribution.15*16* 3. Neither the name of the Institute nor the names of its contributors17* may be used to endorse or promote products derived from this software18* without specific prior written permission.19*20* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND21* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE22* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE23* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE24* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL25* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS26* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)27* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT28* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY29* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF30* SUCH DAMAGE.31*/3233#include "gsskrb5_locl.h"3435static krb5_error_code36check_compat(OM_uint32 *minor_status,37krb5_context context, krb5_const_principal name,38const char *option, krb5_boolean *compat,39krb5_boolean match_val)40{41krb5_error_code ret = 0;42char **p, **q;43krb5_principal match;444546p = krb5_config_get_strings(context, NULL, "gssapi",47option, NULL);48if(p == NULL)49return 0;5051match = NULL;52for(q = p; *q; q++) {53ret = krb5_parse_name(context, *q, &match);54if (ret)55break;5657if (krb5_principal_match(context, name, match)) {58*compat = match_val;59break;60}6162krb5_free_principal(context, match);63match = NULL;64}65if (match)66krb5_free_principal(context, match);67krb5_config_free_strings(p);6869if (ret) {70if (minor_status)71*minor_status = ret;72return GSS_S_FAILURE;73}7475return 0;76}7778/*79* ctx->ctx_id_mutex is assumed to be locked80*/8182OM_uint3283_gss_DES3_get_mic_compat(OM_uint32 *minor_status,84gsskrb5_ctx ctx,85krb5_context context)86{87krb5_boolean use_compat = FALSE;88OM_uint32 ret;8990if ((ctx->more_flags & COMPAT_OLD_DES3_SELECTED) == 0) {91ret = check_compat(minor_status, context, ctx->target,92"broken_des3_mic", &use_compat, TRUE);93if (ret)94return ret;95ret = check_compat(minor_status, context, ctx->target,96"correct_des3_mic", &use_compat, FALSE);97if (ret)98return ret;99100if (use_compat)101ctx->more_flags |= COMPAT_OLD_DES3;102ctx->more_flags |= COMPAT_OLD_DES3_SELECTED;103}104return 0;105}106107#if 0108OM_uint32109gss_krb5_compat_des3_mic(OM_uint32 *minor_status, gss_ctx_id_t ctx, int on)110{111*minor_status = 0;112113HEIMDAL_MUTEX_lock(&ctx->ctx_id_mutex);114if (on) {115ctx->more_flags |= COMPAT_OLD_DES3;116} else {117ctx->more_flags &= ~COMPAT_OLD_DES3;118}119ctx->more_flags |= COMPAT_OLD_DES3_SELECTED;120HEIMDAL_MUTEX_unlock(&ctx->ctx_id_mutex);121122return 0;123}124#endif125126127