/*
*/
/*
* Copyright 1993 by OpenVision Technologies, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appears in all copies and
* that both that copyright notice and this permission notice appear in
* supporting documentation, and that the name of OpenVision not be used
* in advertising or publicity pertaining to distribution of the software
* without specific, written prior permission. OpenVision makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
* OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/*
* $Id: krb5_gss_glue.c 18262 2006-06-29 04:38:48Z tlyu $
*/
#include "gssapiP_krb5.h"
#include "mglueP.h"
#include <syslog.h>
/** mechglue wrappers **/
static OM_uint32 k5glue_acquire_cred
(void *, OM_uint32*, /* minor_status */
gss_name_t, /* desired_name */
OM_uint32, /* time_req */
gss_OID_set, /* desired_mechs */
gss_cred_usage_t, /* cred_usage */
gss_cred_id_t*, /* output_cred_handle */
gss_OID_set*, /* actual_mechs */
OM_uint32* /* time_rec */
);
static OM_uint32 k5glue_release_cred
(void *, OM_uint32*, /* minor_status */
gss_cred_id_t* /* cred_handle */
);
static OM_uint32 k5glue_init_sec_context
(void *, OM_uint32*, /* minor_status */
gss_cred_id_t, /* claimant_cred_handle */
gss_ctx_id_t*, /* context_handle */
gss_name_t, /* target_name */
gss_OID, /* mech_type */
OM_uint32, /* req_flags */
OM_uint32, /* time_req */
/* input_chan_bindings */
gss_buffer_t, /* input_token */
gss_OID*, /* actual_mech_type */
gss_buffer_t, /* output_token */
OM_uint32*, /* ret_flags */
OM_uint32* /* time_rec */
);
(void *, OM_uint32*, /* minor_status */
gss_ctx_id_t*, /* context_handle */
gss_cred_id_t, /* verifier_cred_handle */
gss_buffer_t, /* input_token_buffer */
/* input_chan_bindings */
gss_name_t*, /* src_name */
gss_OID*, /* mech_type */
gss_buffer_t, /* output_token */
OM_uint32*, /* ret_flags */
OM_uint32*, /* time_rec */
gss_cred_id_t* /* delegated_cred_handle */
);
(void *, OM_uint32*, /* minor_status */
gss_ctx_id_t, /* context_handle */
gss_buffer_t /* token_buffer */
);
(void *, OM_uint32*, /* minor_status */
gss_ctx_id_t*, /* context_handle */
gss_buffer_t /* output_token */
);
static OM_uint32 k5glue_context_time
(void *, OM_uint32*, /* minor_status */
gss_ctx_id_t, /* context_handle */
OM_uint32* /* time_rec */
);
static OM_uint32 k5glue_sign
(void *, OM_uint32*, /* minor_status */
gss_ctx_id_t, /* context_handle */
int, /* qop_req */
gss_buffer_t, /* message_buffer */
gss_buffer_t /* message_token */
);
static OM_uint32 k5glue_verify
(void *, OM_uint32*, /* minor_status */
gss_ctx_id_t, /* context_handle */
gss_buffer_t, /* message_buffer */
gss_buffer_t, /* token_buffer */
int* /* qop_state */
);
static OM_uint32 k5glue_seal
(void *, OM_uint32*, /* minor_status */
gss_ctx_id_t, /* context_handle */
int, /* conf_req_flag */
int, /* qop_req */
gss_buffer_t, /* input_message_buffer */
int*, /* conf_state */
gss_buffer_t /* output_message_buffer */
);
static OM_uint32 k5glue_unseal
(void *, OM_uint32*, /* minor_status */
gss_ctx_id_t, /* context_handle */
gss_buffer_t, /* input_message_buffer */
gss_buffer_t, /* output_message_buffer */
int*, /* conf_state */
int* /* qop_state */
);
static OM_uint32 k5glue_display_status
(void *, OM_uint32*, /* minor_status */
OM_uint32, /* status_value */
int, /* status_type */
gss_OID, /* mech_type */
OM_uint32*, /* message_context */
gss_buffer_t /* status_string */
);
static OM_uint32 k5glue_indicate_mechs
(void *, OM_uint32*, /* minor_status */
gss_OID_set* /* mech_set */
);
static OM_uint32 k5glue_compare_name
(void *, OM_uint32*, /* minor_status */
gss_name_t, /* name1 */
gss_name_t, /* name2 */
int* /* name_equal */
);
static OM_uint32 k5glue_display_name
(void *, OM_uint32*, /* minor_status */
gss_name_t, /* input_name */
gss_buffer_t, /* output_name_buffer */
gss_OID* /* output_name_type */
);
static OM_uint32 k5glue_import_name
(void *, OM_uint32*, /* minor_status */
gss_buffer_t, /* input_name_buffer */
gss_OID, /* input_name_type */
gss_name_t* /* output_name */
);
static OM_uint32 k5glue_release_name
(void *, OM_uint32*, /* minor_status */
gss_name_t* /* input_name */
);
static OM_uint32 k5glue_inquire_cred
(void *, OM_uint32 *, /* minor_status */
gss_cred_id_t, /* cred_handle */
gss_name_t *, /* name */
OM_uint32 *, /* lifetime */
gss_cred_usage_t*,/* cred_usage */
gss_OID_set * /* mechanisms */
);
static OM_uint32 k5glue_inquire_context
(void *, OM_uint32*, /* minor_status */
gss_ctx_id_t, /* context_handle */
gss_name_t*, /* initiator_name */
gss_name_t*, /* acceptor_name */
OM_uint32*, /* lifetime_rec */
gss_OID*, /* mech_type */
OM_uint32*, /* ret_flags */
int*, /* locally_initiated */
int* /* open */
);
#if 0
/* New V2 entry points */
static OM_uint32 k5glue_get_mic
(void *, OM_uint32 *, /* minor_status */
gss_ctx_id_t, /* context_handle */
gss_qop_t, /* qop_req */
gss_buffer_t, /* message_buffer */
gss_buffer_t /* message_token */
);
static OM_uint32 k5glue_verify_mic
(void *, OM_uint32 *, /* minor_status */
gss_ctx_id_t, /* context_handle */
gss_buffer_t, /* message_buffer */
gss_buffer_t, /* message_token */
gss_qop_t * /* qop_state */
);
static OM_uint32 k5glue_wrap
(void *, OM_uint32 *, /* minor_status */
gss_ctx_id_t, /* context_handle */
int, /* conf_req_flag */
gss_qop_t, /* qop_req */
gss_buffer_t, /* input_message_buffer */
int *, /* conf_state */
gss_buffer_t /* output_message_buffer */
);
static OM_uint32 k5glue_unwrap
(void *, OM_uint32 *, /* minor_status */
gss_ctx_id_t, /* context_handle */
gss_buffer_t, /* input_message_buffer */
gss_buffer_t, /* output_message_buffer */
int *, /* conf_state */
gss_qop_t * /* qop_state */
);
#endif
static OM_uint32 k5glue_wrap_size_limit
(void *, OM_uint32 *, /* minor_status */
gss_ctx_id_t, /* context_handle */
int, /* conf_req_flag */
gss_qop_t, /* qop_req */
OM_uint32, /* req_output_size */
OM_uint32 * /* max_input_size */
);
#if 0
(void *, OM_uint32 *, /* minor_status */
void *, /* input_name */
gss_OID, /* input_name_type */
gss_name_t * /* output_name */
);
(void *, OM_uint32 *, /* minor_status */
gss_name_t, /* input_name */
gss_OID, /* desired_name_type */
void * * /* output_name */
);
#endif
static OM_uint32 k5glue_add_cred
(void *, OM_uint32 *, /* minor_status */
gss_cred_id_t, /* input_cred_handle */
gss_name_t, /* desired_name */
gss_OID, /* desired_mech */
gss_cred_usage_t, /* cred_usage */
OM_uint32, /* initiator_time_req */
OM_uint32, /* acceptor_time_req */
gss_cred_id_t *, /* output_cred_handle */
gss_OID_set *, /* actual_mechs */
OM_uint32 *, /* initiator_time_rec */
OM_uint32 * /* acceptor_time_rec */
);
(void *, OM_uint32 *, /* minor_status */
gss_cred_id_t, /* cred_handle */
gss_OID, /* mech_type */
gss_name_t *, /* name */
OM_uint32 *, /* initiator_lifetime */
OM_uint32 *, /* acceptor_lifetime */
gss_cred_usage_t * /* cred_usage */
);
(void *, OM_uint32 *, /* minor_status */
gss_ctx_id_t *, /* context_handle */
gss_buffer_t /* interprocess_token */
);
(void *, OM_uint32 *, /* minor_status */
gss_buffer_t, /* interprocess_token */
gss_ctx_id_t * /* context_handle */
);
(void *, OM_uint32 *, /* minor_status */
gss_OID * /* oid */
);
(void *, OM_uint32 *, /* minor_status */
gss_OID, /* mechanism */
gss_OID_set * /* name_types */
);
#if 0
(void *, OM_uint32 *, /* minor_status */
const gss_name_t, /* input_name */
const gss_OID, /* mech_type */
gss_name_t * /* output_name */
);
#endif
static OM_uint32 k5glue_export_name
(void *, OM_uint32 *, /* minor_status */
const gss_name_t, /* input_name */
gss_buffer_t /* exported_name */
);
/* SUNW15resync - Solaris specific */
static OM_uint32 k5glue_store_cred (
void *,
OM_uint32 *, /* minor_status */
const gss_cred_id_t, /* input_cred */
gss_cred_usage_t, /* cred_usage */
const gss_OID, /* desired_mech */
OM_uint32, /* overwrite_cred */
OM_uint32, /* default_cred */
gss_OID_set *, /* elements_stored */
gss_cred_usage_t * /* cred_usage_stored */
);
/* SUNW17PACresync - this decl not needed in MIT but is for Sol */
/* Note code is in gsspi_krb5.c */
OM_uint32 *,
const gss_ctx_id_t,
const gss_OID,
gss_buffer_set_t *);
static OM_uint32
void *, /* context */
OM_uint32 *, /* minor_status */
const gss_name_t, /* pname */
const char *, /* local user */
int * /* user ok? */
/* */);
static OM_uint32
void *, /* context */
OM_uint32 *, /* minor_status */
const gss_name_t, /* pname */
uid_t * /* uid */
/* */);
#if 0
static OM_uint32 k5glue_duplicate_name
(void *, OM_uint32 *, /* minor_status */
const gss_name_t, /* input_name */
gss_name_t * /* dest_name */
);
#endif
#if 0
static OM_uint32 k5glue_validate_cred
(void *, OM_uint32 *, /* minor_status */
gss_cred_id_t /* cred */
);
#endif
#if 0
/*
* SUNW15resync
* Solaris can't use the KRB5_GSS_CONFIG_INIT macro because of the src
* slicing&dicing needs of the "nightly -SD" build. When it goes away,
* we should use it assuming MIT still uses it then.
*/
/*
* The krb5 mechanism provides two mech OIDs; use this initializer to
* ensure that both dispatch tables contain identical function
* pointers.
*/
#define KRB5_GSS_CONFIG_INIT \
NULL, \
...
#endif
#if 0 /* Solaris Kerberos */
100, "kerberos_v5",
#endif
NULL,
};
#if 0 /* Solaris Kerberos */
200, "kerberos_v5 (pre-RFC OID)",
#endif
NULL,
};
#if 0 /* Solaris Kerberos */
300, "kerberos_v5 (wrong OID)",
#endif
NULL,
};
};
#ifdef MS_BUG_TEST
};
#endif
#if 1
#endif
gssint_get_mech_configs(void)
{
#ifdef MS_BUG_TEST
return krb5_mech_configs_hack;
}
#endif
return krb5_mech_configs;
}
static OM_uint32
void *ctx;
{
}
static OM_uint32
void *ctx;
{
return(krb5_gss_acquire_cred(minor_status,
time_rec));
}
/* V2 */
static OM_uint32
void *ctx;
{
}
#if 0
/* V2 */
static OM_uint32
void *ctx;
{
}
#endif
static OM_uint32
void *ctx;
int *name_equal;
{
name2, name_equal));
}
static OM_uint32
void *ctx;
{
time_rec));
}
#if 0
/* V2 */
static OM_uint32
void *ctx;
{
}
#endif
static OM_uint32
void *ctx;
{
}
static OM_uint32
void *ctx;
{
}
static OM_uint32
void *ctx;
int status_type;
{
}
/* V2 */
static OM_uint32
void *ctx;
{
}
#if 0
/* V2 */
static OM_uint32
void *ctx;
{
}
#endif
static OM_uint32
void *ctx;
{
#if 0
if (err) {
*minor_status = err;
return GSS_S_FAILURE;
}
#endif
}
/* V2 */
static OM_uint32
void *ctx;
{
}
static OM_uint32
void *ctx;
{
}
static OM_uint32
void *ctx;
{
time_rec));
}
static OM_uint32
void *ctx;
int *locally_initiated;
int *open;
{
open));
}
static OM_uint32
void *ctx;
{
}
/* V2 */
static OM_uint32
void *ctx;
{
}
/* V2 */
static OM_uint32
void *ctx;
{
name_types));
}
#if 0
/* V2 */
static OM_uint32
void *ctx;
{
}
#endif
static OM_uint32
void *ctx;
{
}
static OM_uint32
void *ctx;
{
}
static OM_uint32
void *ctx;
{
}
#if 0
static OM_uint32
void *ctx;
{
buffer));
}
#endif
/* V2 */
static OM_uint32
void *ctx;
{
}
#if 0
static OM_uint32
void *ctx;
{
}
#endif
/* V1 only */
static OM_uint32
void *ctx;
int conf_req_flag;
int qop_req;
int *conf_state;
{
}
static OM_uint32
void *ctx;
int qop_req;
{
}
#if 0
/* V2 */
static OM_uint32
void *ctx;
{
}
/* V2 */
static OM_uint32
void *ctx;
int conf_req_flag;
int *conf_state;
{
}
/* V2 */
static OM_uint32
void *ctx;
{
}
/* V2 */
static OM_uint32
void *ctx;
int *present;
{
present));
}
#endif
/* V1 only */
static OM_uint32
void *ctx;
int *conf_state;
int *qop_state;
{
conf_state, qop_state));
}
#if 0
/* V2 */
static OM_uint32
void *ctx;
int *conf_state;
{
}
#endif
/* V1 only */
static OM_uint32
void *ctx;
int *qop_state;
{
return(krb5_gss_verify(minor_status,
qop_state));
}
/* V2 interface */
static OM_uint32
void *ctx;
int conf_req_flag;
{
}
#if 0
/* V2 interface */
static OM_uint32
void *ctx;
const gss_name_t input_name;
{
}
#endif
/* V2 interface */
static OM_uint32
void *ctx;
const gss_name_t input_name;
{
}
/* SUNW15resync - this is not in the MIT mech (lib) yet */
static OM_uint32
void *ctx;
const gss_cred_id_t input_cred;
{
}
static OM_uint32
void *ctxt, /* context */
const char *user, /* local user */
int *user_ok /* user ok? */
/* */)
{
}
static OM_uint32
void *ctxt, /* context */
/* */)
{
}
#if 0
/* V2 interface */
static OM_uint32
void *ctx;
const gss_name_t input_name;
{
}
#endif
{
if (mcred != GSS_C_NO_CREDENTIAL)
if (mcred != GSS_C_NO_CREDENTIAL)
return GSS_S_DEFECTIVE_CREDENTIAL;
}
{
if (mcred != GSS_C_NO_CREDENTIAL)
num_ktypes, ktypes);
if (mcred != GSS_C_NO_CREDENTIAL)
num_ktypes, ktypes);
return GSS_S_DEFECTIVE_CREDENTIAL;
}
/*
* Glue routine for returning the mechanism-specific credential from a
* external union credential.
*/
/* SUNW15resync - in MIT 1.5, it's in g_glue.c (libgss) but we don't
want to link against libgss so we put it here since we need it in the mech */
{
int i;
return GSS_C_NO_CREDENTIAL;
for (i=0; i < union_cred->count; i++) {
return union_cred->cred_array[i];
}
return GSS_C_NO_CREDENTIAL;
}
/*
* entry point for the gss layer,
* called "krb5_gss_initialize()" in MIT 1.2.1
*/
/* SUNW15resync - this used to be in k5mech.c */
{
/*
* Solaris Kerberos: We also want to use the same functions for KRB5 as
* we do for the MS KRB5 (krb5_mechanism_wrong). So both are valid.
*/
/* ensure that the requested oid matches our oid */
return (NULL);
}
#if 0 /* SUNW15resync - no longer needed(?) */
return (NULL);
#endif
return (&krb5_mechanism);
}
/*
* This API should go away and be replaced with an accessor
* into a gss_name_t.
*/
int ad_type,
{
return GSS_S_CALL_INACCESSIBLE_WRITE;
&req_oid);
if (GSS_ERROR(major_status))
return major_status;
&data_set);
if (major_status != GSS_S_COMPLETE) {
return major_status;
}
/*
* SUNW17PACresync / Solaris Kerberos
* MIT17 allows only count==1 which is correct for pre-Win2008 but
* our testing with Win2008 shows count==2 and Win7 count==3.
*/
*minor_status = EINVAL;
return GSS_S_FAILURE;
}
return ENOMEM;
}
return GSS_S_COMPLETE;
}
{
return GSS_S_CALL_INACCESSIBLE_WRITE;
&data_set);
if (major_status != GSS_S_COMPLETE)
return major_status;
if (data_set == GSS_C_NO_BUFFER_SET ||
*minor_status = EINVAL;
return GSS_S_FAILURE;
}
*minor_status = 0;
return GSS_S_COMPLETE;
}