initial drop of gss-mo
This commit is contained in:
@@ -111,6 +111,7 @@ mechsrc = \
|
||||
mech/gss_inquire_names_for_mech.c \
|
||||
mech/gss_krb5.c \
|
||||
mech/gss_mech_switch.c \
|
||||
mech/gss_mo.o \
|
||||
mech/gss_names.c \
|
||||
mech/gss_oid_equal.c \
|
||||
mech/gss_oid_to_str.c \
|
||||
|
@@ -90,29 +90,35 @@ typedef uint32_t gss_uint32;
|
||||
|
||||
struct gss_name_t_desc_struct;
|
||||
typedef struct gss_name_t_desc_struct *gss_name_t;
|
||||
typedef const struct gss_name_t_desc_struct *gss_const_name_t;
|
||||
|
||||
struct gss_ctx_id_t_desc_struct;
|
||||
typedef struct gss_ctx_id_t_desc_struct *gss_ctx_id_t;
|
||||
typedef const struct gss_ctx_id_t_desc_struct gss_const_ctx_id_t;
|
||||
|
||||
typedef struct gss_OID_desc_struct {
|
||||
OM_uint32 length;
|
||||
void *elements;
|
||||
} gss_OID_desc, *gss_OID;
|
||||
typedef const gss_OID_desc * gss_const_OID;
|
||||
|
||||
typedef struct gss_OID_set_desc_struct {
|
||||
size_t count;
|
||||
gss_OID elements;
|
||||
} gss_OID_set_desc, *gss_OID_set;
|
||||
typedef const gss_OID_set_desc * gss_const_OID_set;
|
||||
|
||||
typedef int gss_cred_usage_t;
|
||||
|
||||
struct gss_cred_id_t_desc_struct;
|
||||
typedef struct gss_cred_id_t_desc_struct *gss_cred_id_t;
|
||||
typedef const struct gss_cred_id_t_desc_struct *gss_const_cred_id_t;
|
||||
|
||||
typedef struct gss_buffer_desc_struct {
|
||||
size_t length;
|
||||
void *value;
|
||||
} gss_buffer_desc, *gss_buffer_t;
|
||||
typedef const gss_buffer_desc * gss_const_buffer_t;
|
||||
|
||||
typedef struct gss_channel_bindings_struct {
|
||||
OM_uint32 initiator_addrtype;
|
||||
@@ -121,6 +127,7 @@ typedef struct gss_channel_bindings_struct {
|
||||
gss_buffer_desc acceptor_address;
|
||||
gss_buffer_desc application_data;
|
||||
} *gss_channel_bindings_t;
|
||||
typedef const struct gss_channel_bindings_struct *gss_const_channel_bindings_t;
|
||||
|
||||
/* GGF extension data types */
|
||||
typedef struct gss_buffer_set_desc_struct {
|
||||
@@ -138,6 +145,8 @@ typedef struct gss_iov_buffer_desc_struct {
|
||||
*/
|
||||
typedef OM_uint32 gss_qop_t;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Flag bits for context-level services.
|
||||
*/
|
||||
@@ -438,6 +447,7 @@ extern gss_OID_desc GSSAPI_LIB_VARIABLE __gss_sasl_digest_md5_mechanism_oid_desc
|
||||
#define GSS_S_UNAVAILABLE (16ul << GSS_C_ROUTINE_ERROR_OFFSET)
|
||||
#define GSS_S_DUPLICATE_ELEMENT (17ul << GSS_C_ROUTINE_ERROR_OFFSET)
|
||||
#define GSS_S_NAME_NOT_MN (18ul << GSS_C_ROUTINE_ERROR_OFFSET)
|
||||
#define GSS_S_BAD_MECH_ATTR (19ul << GSS_C_ROUTINE_ERROR_OFFSET)
|
||||
|
||||
/*
|
||||
* Supplementary info bits:
|
||||
@@ -929,6 +939,58 @@ gss_import_cred(OM_uint32 * /* minor_status */,
|
||||
gss_buffer_t /* cred_token */,
|
||||
gss_cred_id_t * /* cred_handle */);
|
||||
|
||||
/*
|
||||
* mech option
|
||||
*/
|
||||
|
||||
GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
|
||||
gss_mo_set(gss_OID mech, gss_OID option, int enable, gss_buffer_t value);
|
||||
|
||||
GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
|
||||
gss_mo_get(gss_OID mech, gss_OID option, gss_buffer_t value);
|
||||
|
||||
GSSAPI_LIB_FUNCTION void GSSAPI_LIB_CALL
|
||||
gss_mo_list(gss_OID mech, gss_OID_set *options);
|
||||
|
||||
GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
|
||||
gss_mo_name(gss_OID mech, gss_OID options, gss_buffer_t name);
|
||||
|
||||
/*
|
||||
* SASL glue functions and mech inquire
|
||||
*/
|
||||
|
||||
GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
|
||||
gss_inquire_saslname_for_mech(OM_uint32 *minor_status,
|
||||
const gss_OID desired_mech,
|
||||
gss_buffer_t sasl_mech_name,
|
||||
gss_buffer_t mech_name,
|
||||
gss_buffer_t mech_description);
|
||||
|
||||
GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
|
||||
gss_inquire_mech_for_saslname(OM_uint32 *minor_status,
|
||||
const gss_buffer_t sasl_mech_name,
|
||||
gss_OID *mech_type);
|
||||
|
||||
GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
|
||||
gss_indicate_mechs_by_attrs(OM_uint32 * minor_status,
|
||||
gss_const_OID_set desired_mech_attrs,
|
||||
gss_const_OID_set except_mech_attrs,
|
||||
gss_const_OID_set critical_mech_attrs,
|
||||
gss_OID_set mechs);
|
||||
|
||||
GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
|
||||
gss_inquire_attrs_for_mech(OM_uint32 * minor_status,
|
||||
gss_const_OID mech,
|
||||
gss_OID_set *mech_attr,
|
||||
gss_OID_set *known_mech_attrs);
|
||||
|
||||
GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
|
||||
gss_display_mech_attr(OM_uint32 * minor_status,
|
||||
gss_const_OID mech_attr,
|
||||
gss_buffer_t name,
|
||||
gss_buffer_t short_desc,
|
||||
gss_buffer_t long_desc);
|
||||
|
||||
|
||||
GSSAPI_CPP_END
|
||||
|
||||
|
@@ -354,7 +354,61 @@ _gss_import_cred_t(OM_uint32 * minor_status,
|
||||
gss_cred_id_t * cred_handle);
|
||||
|
||||
|
||||
#define GMI_VERSION 2
|
||||
typedef OM_uint32
|
||||
_gss_acquire_cred_ex_t(void * /* status */,
|
||||
const gss_name_t /* desired_name */,
|
||||
OM_uint32 /* flags */,
|
||||
OM_uint32 /* time_req */,
|
||||
gss_cred_usage_t /* cred_usage */,
|
||||
void * /* identity */,
|
||||
void * /* ctx */,
|
||||
void (* /*complete */)(void *, OM_uint32, void *, gss_cred_id_t, OM_uint32));
|
||||
|
||||
typedef void
|
||||
_gss_iter_creds_t(OM_uint32 /* flags */,
|
||||
void * /* userctx */,
|
||||
void (* /*cred_iter */ )(void *, gss_OID, gss_cred_id_t));
|
||||
|
||||
typedef OM_uint32
|
||||
_gss_destroy_cred_t(OM_uint32 * /* minor_status */,
|
||||
gss_cred_id_t */* cred */);
|
||||
|
||||
typedef OM_uint32
|
||||
_gss_cred_hold_t(OM_uint32 * /* minor_status */,
|
||||
gss_cred_id_t /* cred */);
|
||||
|
||||
typedef OM_uint32
|
||||
_gss_cred_unhold_t(OM_uint32 * /* minor_status */,
|
||||
gss_cred_id_t /* cred */);
|
||||
|
||||
typedef OM_uint32
|
||||
_gss_cred_label_set_t(OM_uint32 * /* minor_status */,
|
||||
gss_cred_id_t /* cred */,
|
||||
const char * /* label */,
|
||||
gss_buffer_t /* value */);
|
||||
|
||||
typedef OM_uint32
|
||||
_gss_cred_label_get_t(OM_uint32 * /* minor_status */,
|
||||
gss_cred_id_t /* cred */,
|
||||
const char * /* label */,
|
||||
gss_buffer_t /* value */);
|
||||
|
||||
typedef struct gss_mo_desc_struct gss_mo_desc;
|
||||
|
||||
struct gss_mo_desc_struct {
|
||||
gss_OID option;
|
||||
const char *name;
|
||||
void *ctx;
|
||||
int (*get)(gss_OID, gss_mo_desc *, gss_buffer_t);
|
||||
int (*set)(gss_OID, gss_mo_desc *, int, gss_buffer_t);
|
||||
OM_uint32 flags;
|
||||
#define GSS_MO_IS_MA 1
|
||||
#define GSS_MO_MA_CRITIAL 2
|
||||
const char *description;
|
||||
};
|
||||
|
||||
|
||||
#define GMI_VERSION 4
|
||||
|
||||
/* gm_flags */
|
||||
#define GM_USE_MG_CRED 1 /* uses mech glue credentials */
|
||||
@@ -405,6 +459,15 @@ typedef struct gssapi_mech_interface_desc {
|
||||
_gss_store_cred_t *gm_store_cred;
|
||||
_gss_export_cred_t *gm_export_cred;
|
||||
_gss_import_cred_t *gm_import_cred;
|
||||
_gss_acquire_cred_ex_t *gm_acquire_cred_ex;
|
||||
_gss_iter_creds_t *gm_iter_creds;
|
||||
_gss_destroy_cred_t *gm_destroy_cred;
|
||||
_gss_cred_hold_t *gm_cred_hold;
|
||||
_gss_cred_unhold_t *gm_cred_unhold;
|
||||
_gss_cred_label_get_t *gm_cred_label_get;
|
||||
_gss_cred_label_set_t *gm_cred_label_set;
|
||||
gss_mo_desc *gm_mo;
|
||||
size_t gm_mo_num;
|
||||
} gssapi_mech_interface_desc, *gssapi_mech_interface;
|
||||
|
||||
gssapi_mech_interface
|
||||
|
197
lib/gssapi/mech/gss_mo.c
Normal file
197
lib/gssapi/mech/gss_mo.c
Normal file
@@ -0,0 +1,197 @@
|
||||
/*
|
||||
* Copyright (c) 2010 Kungliga Tekniska Högskolan
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* All rights reserved.
|
||||
*
|
||||
* Portions Copyright (c) 2010 Apple Inc. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
|
||||
static int
|
||||
get_option_def(int def, gss_OID mech, gss_mo_desc *mo, gss_buffer_t value)
|
||||
{
|
||||
return def;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
_gss_mo_get_option_1(gss_OID mech, gss_mo_desc *mo, gss_buffer_t value)
|
||||
{
|
||||
return get_option_def(1, mech, mo, value);
|
||||
}
|
||||
|
||||
int
|
||||
_gss_mo_get_option_0(gss_OID mech, gss_mo_desc *mo, gss_buffer_t value)
|
||||
{
|
||||
return get_option_def(0, mech, mo, value);
|
||||
}
|
||||
|
||||
int
|
||||
gss_mo_set(gss_OID mech, gss_OID option, int enable, gss_buffer_t value)
|
||||
{
|
||||
gssapi_mech_interface m;
|
||||
size_t n;
|
||||
|
||||
if ((m = __gss_get_mechanism(mech)) == NULL)
|
||||
return GSS_S_BAD_MECH;
|
||||
|
||||
for (n = 0; n < m->gm_mo_num; n++)
|
||||
if (gss_oid_equal(option, m->gm_mo[n].option) && m->gm_mo[n].set)
|
||||
return m->gm_mo[n].set(mech, &m->gm_mo[n], enable, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
gss_mo_get(gss_OID mech, gss_OID option, gss_buffer_t value)
|
||||
{
|
||||
gssapi_mech_interface m;
|
||||
size_t n;
|
||||
|
||||
if (value)
|
||||
_mg_buffer_zero(value);
|
||||
|
||||
if ((m = __gss_get_mechanism(mech)) == NULL)
|
||||
return 0;
|
||||
|
||||
for (n = 0; n < m->gm_mo_num; n++)
|
||||
if (gss_oid_equal(option, m->gm_mo[n].option) && m->gm_mo[n].get)
|
||||
return m->gm_mo[n].get(mech, &m->gm_mo[n], value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
gss_mo_list(gss_OID mech, gss_OID_set *options)
|
||||
{
|
||||
gssapi_mech_interface m;
|
||||
OM_uint32 major, minor;
|
||||
size_t n;
|
||||
|
||||
if (options == NULL)
|
||||
return;
|
||||
|
||||
*options = GSS_C_NO_OID_SET;
|
||||
|
||||
if ((m = __gss_get_mechanism(mech)) == NULL)
|
||||
return;
|
||||
|
||||
major = gss_create_empty_oid_set(&minor, options);
|
||||
if (major != GSS_S_COMPLETE)
|
||||
return;
|
||||
|
||||
for (n = 0; n < m->gm_mo_num; n++)
|
||||
gss_add_oid_set_member(&minor, m->gm_mo[n].option, options);
|
||||
}
|
||||
|
||||
OM_uint32
|
||||
gss_mo_name(gss_OID mech, gss_OID option, gss_buffer_t name)
|
||||
{
|
||||
gssapi_mech_interface m;
|
||||
size_t n;
|
||||
|
||||
if (name == NULL)
|
||||
return GSS_S_BAD_NAME;
|
||||
|
||||
if ((m = __gss_get_mechanism(mech)) == NULL)
|
||||
return GSS_S_BAD_MECH;
|
||||
|
||||
for (n = 0; n < m->gm_mo_num; n++) {
|
||||
if (gss_oid_equal(option, m->gm_mo[n].option)) {
|
||||
name->value = strdup(m->gm_mo[n].name);
|
||||
if (name->value == NULL)
|
||||
return GSS_S_BAD_NAME;
|
||||
name->length = strlen(m->gm_mo[n].name);
|
||||
return GSS_S_COMPLETE;
|
||||
}
|
||||
}
|
||||
return GSS_S_BAD_NAME;
|
||||
}
|
||||
|
||||
GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
|
||||
gss_inquire_saslname_for_mech(OM_uint32 *minor_status,
|
||||
const gss_OID desired_mech,
|
||||
gss_buffer_t sasl_mech_name,
|
||||
gss_buffer_t mech_name,
|
||||
gss_buffer_t mech_description)
|
||||
{
|
||||
_mg_buffer_zero(sasl_mech_name);
|
||||
_mg_buffer_zero(mech_name);
|
||||
_mg_buffer_zero(mech_description);
|
||||
|
||||
return GSS_S_COMPLETE;
|
||||
}
|
||||
|
||||
GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
|
||||
gss_inquire_mech_for_saslname(OM_uint32 *minor_status,
|
||||
const gss_buffer_t sasl_mech_name,
|
||||
gss_OID *mech_type)
|
||||
{
|
||||
*mech_type = NULL;
|
||||
return GSS_S_COMPLETE;
|
||||
}
|
||||
|
||||
GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
|
||||
gss_indicate_mechs_by_attrs(OM_uint32 * minor_status,
|
||||
gss_const_OID_set desired_mech_attrs,
|
||||
gss_const_OID_set except_mech_attrs,
|
||||
gss_const_OID_set critical_mech_attrs,
|
||||
gss_OID_set mechs)
|
||||
{
|
||||
_mg_oid_set_zero(mechs);
|
||||
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
|
||||
gss_inquire_attrs_for_mech(OM_uint32 * minor_status,
|
||||
gss_const_OID mech,
|
||||
gss_OID_set * mech_attr,
|
||||
gss_OID_set *known_mech_attrs)
|
||||
{
|
||||
_mg_oid_set_zero(mech_attr);
|
||||
_mg_oid_set_zero(known_mech_attrs);
|
||||
|
||||
return GSS_S_COMPLETE;
|
||||
}
|
||||
|
||||
GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
|
||||
gss_display_mech_attr(OM_uint32 * minor_status,
|
||||
gss_const_OID mech_attr,
|
||||
gss_buffer_t name,
|
||||
gss_buffer_t short_desc,
|
||||
gss_buffer_t long_desc)
|
||||
{
|
||||
_mg_buffer_zero(name);
|
||||
_mg_buffer_zero(short_desc);
|
||||
_mg_buffer_zero(long_desc);
|
||||
|
||||
return GSS_S_FAILURE;
|
||||
}
|
@@ -65,3 +65,6 @@
|
||||
|
||||
#define _mg_buffer_zero(buffer) \
|
||||
do { (buffer)->value = NULL; (buffer)->length = 0; } while(0)
|
||||
|
||||
#define _mg_oid_set_zero(oid_set) \
|
||||
do { (oid_set)->elements = NULL; (oid_set)->length = 0; } while(0)
|
||||
|
Reference in New Issue
Block a user