2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#include <libintl.h>
2N/A#include <locale.h>
2N/A
2N/A#include "dh_gssapi.h"
2N/A
2N/A/*
2N/A * __dh_gss_display_status: This is the routine that implements
2N/A * gss_display_status for Diffie-Hellman mechanism. Note we will
2N/A * return failure if the status_type parameter is GSS_C_GSS_CODE
2N/A * since libgss should handle the mechanism independent codes.
2N/A */
2N/AOM_uint32
2N/A__dh_gss_display_status(
2N/A OM_uint32 *minor, /* This mechanism's status */
2N/A OM_uint32 status_value, /* The value to dispaly */
2N/A int status_type, /* Shoud alway be GSS_C_MECH_COE */
2N/A gss_OID mech, /* Our OID or GSS_C_NO_OID */
2N/A OM_uint32* mesg_ctx, /* Message context for continues */
2N/A gss_buffer_t status_str /* The displayed output */)
2N/A{
2N/A char *str;
2N/A OM_uint32 major = GSS_S_COMPLETE;
2N/A
2N/A if (!minor)
2N/A return (GSS_S_CALL_INACCESSIBLE_WRITE);
2N/A *minor = DH_SUCCESS;
2N/A
2N/A if (!mesg_ctx)
2N/A return (GSS_S_CALL_INACCESSIBLE_WRITE);
2N/A
2N/A /* We only have one message per status value */
2N/A *mesg_ctx = 0;
2N/A
2N/A
2N/A /*
2N/A * If status_type equals GSS_C_GSS_CODE, we'll return
2N/A * GSS_S_FAILURE. This status type is handled by the caller,
2N/A * libgss, since it is mechanism independent. We should never see
2N/A * this. If the status type does not equal GSS_C_MECH_CODE and
2N/A * does not equal GSS_C_GSS_CODE we return GSS_S_BAD_STATUS as per
2N/A * spec.
2N/A */
2N/A
2N/A if (status_type != GSS_C_MECH_CODE)
2N/A return ((status_type == GSS_C_GSS_CODE ?
2N/A GSS_S_FAILURE : GSS_S_BAD_STATUS));
2N/A
2N/A if (mech != GSS_C_NO_OID &&
2N/A !__OID_equal(&OID, mech))
2N/A return (GSS_S_BAD_MECH);
2N/A
2N/A /* Convert the DH status value to an internationalize string */
2N/A switch (status_value) {
2N/A case DH_SUCCESS:
2N/A str = dgettext(TEXT_DOMAIN, "mech_dh: Success");
2N/A break;
2N/A case DH_NOMEM_FAILURE:
2N/A str = dgettext(TEXT_DOMAIN, "mech_dh: No memory");
2N/A break;
2N/A case DH_ENCODE_FAILURE:
2N/A str = dgettext(TEXT_DOMAIN,
2N/A "mech_dh: Could not encode token");
2N/A break;
2N/A case DH_DECODE_FAILURE:
2N/A str = dgettext(TEXT_DOMAIN,
2N/A "mech_dh: Could not decode token");
2N/A break;
2N/A case DH_BADARG_FAILURE:
2N/A str = dgettext(TEXT_DOMAIN, "mech_dh: Bad argument");
2N/A break;
2N/A case DH_CIPHER_FAILURE:
2N/A str = dgettext(TEXT_DOMAIN, "mech_dh: Cipher failure");
2N/A break;
2N/A case DH_VERIFIER_FAILURE:
2N/A str = dgettext(TEXT_DOMAIN, "mech_dh: Verifier failure");
2N/A break;
2N/A case DH_SESSION_CIPHER_FAILURE:
2N/A str = dgettext(TEXT_DOMAIN, "mech_dh: Session cipher failure");
2N/A break;
2N/A case DH_NO_SECRET:
2N/A str = dgettext(TEXT_DOMAIN, "mech_dh: No secret key");
2N/A break;
2N/A case DH_NO_PRINCIPAL:
2N/A str = dgettext(TEXT_DOMAIN, "mech_dh: No principal");
2N/A break;
2N/A case DH_NOT_LOCAL:
2N/A str = dgettext(TEXT_DOMAIN, "mech_dh: Not local principal");
2N/A break;
2N/A case DH_UNKNOWN_QOP:
2N/A str = dgettext(TEXT_DOMAIN, "mech_dh: Unkown QOP");
2N/A break;
2N/A case DH_VERIFIER_MISMATCH:
2N/A str = dgettext(TEXT_DOMAIN, "mech_dh: Verifier mismatch");
2N/A break;
2N/A case DH_NO_SUCH_USER:
2N/A str = dgettext(TEXT_DOMAIN, "mech_dh: No such user");
2N/A break;
2N/A case DH_NETNAME_FAILURE:
2N/A str = dgettext(TEXT_DOMAIN,
2N/A "mech_dh: Could not generate netname");
2N/A break;
2N/A case DH_BAD_CRED:
2N/A str = dgettext(TEXT_DOMAIN, "mech_dh: Invalid credential");
2N/A break;
2N/A case DH_BAD_CONTEXT:
2N/A str = dgettext(TEXT_DOMAIN, "mech_dh: Invalid GSS context");
2N/A break;
2N/A case DH_PROTO_MISMATCH:
2N/A str = dgettext(TEXT_DOMAIN, "mech_dh: Diffie-Hellman protocol "
2N/A "mismatch");
2N/A break;
2N/A default:
2N/A str = dgettext(TEXT_DOMAIN, "mech_dh: Invalid or "
2N/A "unknown error");
2N/A major = GSS_S_BAD_STATUS;
2N/A break;
2N/A }
2N/A
2N/A /* Copy the string to the output */
2N/A status_str->value = strdup(str);
2N/A if (status_str == 0) {
2N/A *minor = DH_NOMEM_FAILURE;
2N/A return (GSS_S_FAILURE);
2N/A }
2N/A status_str->length = strlen(str);
2N/A
2N/A /* Return the GSS status of GSS_S_COMPLETE or GSS_S_BAD_STATUS */
2N/A return (major);
2N/A}
2N/A
2N/A
2N/A/*
2N/A * This function is completely implemented in libgss. Its entry point is
2N/A * set to NULL in dhmech.c
2N/A */
2N/A/*
2N/A * OM_uint32
2N/A * __dh_gss_indicate_mechs(void *ctx, OM_uint32 *minor, gss_OID_set *mechs)
2N/A * {
2N/A * return (GSS_S_UNAVAILABLE);
2N/A * }
2N/A */