cred.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* cred.c
*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <unistd.h>
#include "dh_gssapi.h"
/*
* This module supports the GSS credential family of routines for
* Diffie-Hellman mechanism.
*/
/*
* __dh_gss_acquire_cred: Get the credential associated with principal
* with the requested expire time and usage. Return the credential with
* the optional set of supported mechs and actual time left on the credential.
*
* Note in Diffie-Hellman the supplied principal name must be that of
* the caller. There is no way to delegate credentials.
*
* Libgss alwas sets desired_mechs to GSS_C_NO_OID_SET and set the return
* set of mechs to NULL.
*/
{
/* Diffie-Hellman mechanism context is ctx */
/* Need to write to these */
return (GSS_S_CALL_INACCESSIBLE_WRITE);
/* Set sane outputs */
*minor = 0;
if (mechs)
if (expire_rec)
*expire_rec = 0;
/*
* If not GSS_C_NO_OID_SET then the set must contain the
* Diffie-Hellman mechanism
*/
if (desired_mechs != GSS_C_NO_OID_SET &&
return (GSS_S_BAD_MECH);
/* See if the callers secretkey is available */
return (GSS_S_NO_CRED);
/* Get the principal name of the caller */
return (GSS_S_NO_CRED);
/*
* Diffie-Hellman requires the principal to be the principal
* of the caller
*/
if (principal &&
return (GSS_S_NO_CRED);
}
/* Allocate the credential */
return (GSS_S_FAILURE);
}
/* Set credential state */
/*
* If mechs set it to the set that contains the appropriate
* Diffie-Hellman mechanism
*/
return (GSS_S_FAILURE);
}
/* Register the credential */
return (GSS_S_FAILURE);
}
if (expire_rec)
/* Return the Diffie-Hellman credential through cred */
return (GSS_S_COMPLETE);
}
/*
* __dh_gss_add_cred is currently a no-op. All the work is done at the
* libgss layer. That layer will invoke the mechanism specific gss_acquire_cred
* routine. This entry point should never be called. The entry point for
* this routine is set to NULL in dhmech.c.
*/
/*
* OM_uint32
* __dh_gss_add_cred(void * ctx, OM_uint32 *minor, gss_cred_id_t cred_in,
* gss_name_t name, gss_OID mech, gss_cred_usage_t usage,
* OM_uint32 init_time_req, OM_uint32 accep_time_req,
* gss_cred_id_t *cred_out, gss_OID_set *mechs,
* OM_uint32 *init_time_rec, OM_uint32 *accep_time_rec)
* {
* return (GSS_S_UNAVAILABLE);
* }
*/
/*
* __dh_gss_inquire_cred: Return tracked state of the supplied credential.
*/
{
/* cred is a Diffie-Hellman credential */
/* ctx is a Diffie-Hellman context */
if (minor == 0)
return (GSS_S_CALL_INACCESSIBLE_WRITE);
if (cntx == 0)
return (GSS_S_CALL_INACCESSIBLE_READ);
*minor = DH_SUCCESS;
/* Default case */
if (cred == GSS_C_NO_CREDENTIAL) {
return (GSS_S_NO_CRED);
if (name)
if (lifetime)
if (usage)
*usage = GSS_C_BOTH;
} else {
/* Validate creditial */
return (GSS_S_DEFECTIVE_CREDENTIAL);
if (name)
if (lifetime) {
else {
*lifetime = t;
}
}
if (usage)
}
return (GSS_S_FAILURE);
if (mechs &&
return (GSS_S_FAILURE);
}
/* Check if the credential is still valid */
return (t ? GSS_S_COMPLETE : GSS_S_CREDENTIALS_EXPIRED);
}
/*
* __dh_gss_inquire_cred_by_mech: Return the information associated with
* cred and mech. Since we're a backend, mech must be our mech.
*
* We verify that passed in mech is correct and use the above routine
* to do the work.
*/
{
/* ctx is them Diffie-Hellman mechanism context */
/* This should never happen. It would indicate a libgss failure */
*minor = DH_BAD_CONTEXT;
return (GSS_S_FAILURE);
}
/* Fetch cred info */
/* Return option values */
if (major == GSS_S_COMPLETE) {
/* set init_time if we can */
if (init_time)
/* Ditto for accept time */
if (accept_time)
if (usage)
}
return (major);
}
/*
* __dh_gss_release_cred: Release the resources associated with cred.
*/
{
/* Check that we can read and write required parameters */
return (GSS_S_CALL_INACCESSIBLE_WRITE);
/* Nothing to do */
if (*cred == GSS_C_NO_CREDENTIAL)
return (GSS_S_COMPLETE);
/* Check if the credential is valid */
return (GSS_S_NO_CRED);
/* Unregister the credential */
/* Free the principal and the cred itself */
/* Set cred to no credential */
return (GSS_S_COMPLETE);
}