wmi-1.3.16 from opsview.com
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/context.h,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
* $Id: context.h,v 1.2 2006/06/28 09:00:25 lha Exp $
|
||||
*/
|
||||
|
||||
#include <gssapi_mech.h>
|
||||
|
||||
struct _gss_context {
|
||||
gssapi_mech_interface gc_mech;
|
||||
gss_ctx_id_t gc_ctx;
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/cred.h,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
* $Id: cred.h,v 1.3 2006/10/05 18:26:54 lha Exp $
|
||||
*/
|
||||
|
||||
struct _gss_mechanism_cred {
|
||||
SLIST_ENTRY(_gss_mechanism_cred) gmc_link;
|
||||
gssapi_mech_interface gmc_mech; /* mechanism ops for MC */
|
||||
gss_OID gmc_mech_oid; /* mechanism oid for MC */
|
||||
gss_cred_id_t gmc_cred; /* underlying MC */
|
||||
};
|
||||
SLIST_HEAD(_gss_mechanism_cred_list, _gss_mechanism_cred);
|
||||
|
||||
struct _gss_cred {
|
||||
gss_cred_usage_t gc_usage;
|
||||
struct _gss_mechanism_cred_list gc_mc;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,273 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_accept_sec_context.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_accept_sec_context.c,v 1.7 2006/11/10 03:30:12 lha Exp $");
|
||||
|
||||
static OM_uint32
|
||||
parse_header(const gss_buffer_t input_token, gss_OID mech_oid)
|
||||
{
|
||||
unsigned char *p = input_token->value;
|
||||
size_t len = input_token->length;
|
||||
size_t a, b;
|
||||
|
||||
/*
|
||||
* Token must start with [APPLICATION 0] SEQUENCE.
|
||||
* But if it doesn't assume its DCE-STYLE Kerberos!
|
||||
*/
|
||||
if (len == 0)
|
||||
return (GSS_S_DEFECTIVE_TOKEN);
|
||||
|
||||
p++;
|
||||
len--;
|
||||
|
||||
/*
|
||||
* Decode the length and make sure it agrees with the
|
||||
* token length.
|
||||
*/
|
||||
if (len == 0)
|
||||
return (GSS_S_DEFECTIVE_TOKEN);
|
||||
if ((*p & 0x80) == 0) {
|
||||
a = *p;
|
||||
p++;
|
||||
len--;
|
||||
} else {
|
||||
b = *p & 0x7f;
|
||||
p++;
|
||||
len--;
|
||||
if (len < b)
|
||||
return (GSS_S_DEFECTIVE_TOKEN);
|
||||
a = 0;
|
||||
while (b) {
|
||||
a = (a << 8) | *p;
|
||||
p++;
|
||||
len--;
|
||||
b--;
|
||||
}
|
||||
}
|
||||
if (a != len)
|
||||
return (GSS_S_DEFECTIVE_TOKEN);
|
||||
|
||||
/*
|
||||
* Decode the OID for the mechanism. Simplify life by
|
||||
* assuming that the OID length is less than 128 bytes.
|
||||
*/
|
||||
if (len < 2 || *p != 0x06)
|
||||
return (GSS_S_DEFECTIVE_TOKEN);
|
||||
if ((p[1] & 0x80) || p[1] > (len - 2))
|
||||
return (GSS_S_DEFECTIVE_TOKEN);
|
||||
mech_oid->length = p[1];
|
||||
p += 2;
|
||||
len -= 2;
|
||||
mech_oid->elements = p;
|
||||
|
||||
return GSS_S_COMPLETE;
|
||||
}
|
||||
|
||||
static gss_OID_desc krb5_mechanism =
|
||||
{9, rk_UNCONST("\x2a\x86\x48\x86\xf7\x12\x01\x02\x02")};
|
||||
static gss_OID_desc spnego_mechanism =
|
||||
{6, rk_UNCONST("\x2b\x06\x01\x05\x05\x02")};
|
||||
|
||||
static OM_uint32
|
||||
choose_mech(const gss_buffer_t input, gss_OID mech_oid)
|
||||
{
|
||||
OM_uint32 status;
|
||||
|
||||
/*
|
||||
* First try to parse the gssapi token header and see if its a
|
||||
* correct header, use that in the first hand.
|
||||
*/
|
||||
|
||||
status = parse_header(input, mech_oid);
|
||||
if (status == GSS_S_COMPLETE)
|
||||
return GSS_S_COMPLETE;
|
||||
|
||||
/*
|
||||
* Lets guess what mech is really is, callback function to mech ??
|
||||
*/
|
||||
|
||||
if (input->length != 0 && ((const char *)input->value)[0] == 0x6E) {
|
||||
/* Could be a raw AP-REQ (check for APPLICATION tag) */
|
||||
*mech_oid = krb5_mechanism;
|
||||
return GSS_S_COMPLETE;
|
||||
} else if (input->length == 0) {
|
||||
/*
|
||||
* There is the a wiered mode of SPNEGO (in CIFS and
|
||||
* SASL GSS-SPENGO where the first token is zero
|
||||
* length and the acceptor returns a mech_list, lets
|
||||
* home that is what is happening now.
|
||||
*/
|
||||
*mech_oid = spnego_mechanism;
|
||||
return GSS_S_COMPLETE;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
OM_uint32 gss_accept_sec_context(OM_uint32 *minor_status,
|
||||
gss_ctx_id_t *context_handle,
|
||||
const gss_cred_id_t acceptor_cred_handle,
|
||||
const gss_buffer_t input_token,
|
||||
const gss_channel_bindings_t 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)
|
||||
{
|
||||
OM_uint32 major_status, mech_ret_flags;
|
||||
gssapi_mech_interface m;
|
||||
struct _gss_context *ctx = (struct _gss_context *) *context_handle;
|
||||
struct _gss_cred *cred = (struct _gss_cred *) acceptor_cred_handle;
|
||||
struct _gss_mechanism_cred *mc;
|
||||
gss_cred_id_t acceptor_mc, delegated_mc;
|
||||
gss_name_t src_mn;
|
||||
int allocated_ctx;
|
||||
|
||||
*minor_status = 0;
|
||||
if (src_name) *src_name = 0;
|
||||
if (mech_type) *mech_type = 0;
|
||||
if (ret_flags) *ret_flags = 0;
|
||||
if (time_rec) *time_rec = 0;
|
||||
if (delegated_cred_handle) *delegated_cred_handle = 0;
|
||||
output_token->length = 0;
|
||||
output_token->value = 0;
|
||||
|
||||
/*
|
||||
* If this is the first call (*context_handle is NULL), we must
|
||||
* parse the input token to figure out the mechanism to use.
|
||||
*/
|
||||
if (*context_handle == GSS_C_NO_CONTEXT) {
|
||||
gss_OID_desc mech_oid;
|
||||
|
||||
major_status = choose_mech(input_token, &mech_oid);
|
||||
if (major_status != GSS_S_COMPLETE)
|
||||
return major_status;
|
||||
|
||||
/*
|
||||
* Now that we have a mechanism, we can find the
|
||||
* implementation.
|
||||
*/
|
||||
ctx = malloc(sizeof(struct _gss_context));
|
||||
if (!ctx) {
|
||||
*minor_status = ENOMEM;
|
||||
return (GSS_S_DEFECTIVE_TOKEN);
|
||||
}
|
||||
memset(ctx, 0, sizeof(struct _gss_context));
|
||||
m = ctx->gc_mech = __gss_get_mechanism(&mech_oid);
|
||||
if (!m) {
|
||||
free(ctx);
|
||||
return (GSS_S_BAD_MECH);
|
||||
}
|
||||
allocated_ctx = 1;
|
||||
} else {
|
||||
m = ctx->gc_mech;
|
||||
allocated_ctx = 0;
|
||||
}
|
||||
|
||||
if (cred) {
|
||||
SLIST_FOREACH(mc, &cred->gc_mc, gmc_link)
|
||||
if (mc->gmc_mech == m)
|
||||
break;
|
||||
if (!mc)
|
||||
return (GSS_S_BAD_MECH);
|
||||
acceptor_mc = mc->gmc_cred;
|
||||
} else {
|
||||
acceptor_mc = GSS_C_NO_CREDENTIAL;
|
||||
}
|
||||
delegated_mc = GSS_C_NO_CREDENTIAL;
|
||||
|
||||
mech_ret_flags = 0;
|
||||
major_status = m->gm_accept_sec_context(minor_status,
|
||||
&ctx->gc_ctx,
|
||||
acceptor_mc,
|
||||
input_token,
|
||||
input_chan_bindings,
|
||||
&src_mn,
|
||||
mech_type,
|
||||
output_token,
|
||||
&mech_ret_flags,
|
||||
time_rec,
|
||||
&delegated_mc);
|
||||
if (major_status != GSS_S_COMPLETE &&
|
||||
major_status != GSS_S_CONTINUE_NEEDED)
|
||||
return (major_status);
|
||||
|
||||
if (!src_name) {
|
||||
m->gm_release_name(minor_status, &src_mn);
|
||||
} else {
|
||||
/*
|
||||
* Make a new name and mark it as an MN.
|
||||
*/
|
||||
struct _gss_name *name = _gss_make_name(m, src_mn);
|
||||
|
||||
if (!name) {
|
||||
m->gm_release_name(minor_status, &src_mn);
|
||||
return (GSS_S_FAILURE);
|
||||
}
|
||||
*src_name = (gss_name_t) name;
|
||||
}
|
||||
|
||||
if (mech_ret_flags & GSS_C_DELEG_FLAG) {
|
||||
if (!delegated_cred_handle) {
|
||||
m->gm_release_cred(minor_status, &delegated_mc);
|
||||
*ret_flags &= ~GSS_C_DELEG_FLAG;
|
||||
} else {
|
||||
struct _gss_cred *dcred;
|
||||
struct _gss_mechanism_cred *dmc;
|
||||
|
||||
dcred = malloc(sizeof(struct _gss_cred));
|
||||
if (!dcred) {
|
||||
*minor_status = ENOMEM;
|
||||
return (GSS_S_FAILURE);
|
||||
}
|
||||
SLIST_INIT(&dcred->gc_mc);
|
||||
dmc = malloc(sizeof(struct _gss_mechanism_cred));
|
||||
if (!dmc) {
|
||||
free(dcred);
|
||||
*minor_status = ENOMEM;
|
||||
return (GSS_S_FAILURE);
|
||||
}
|
||||
m->gm_inquire_cred(minor_status, delegated_mc,
|
||||
0, 0, &dcred->gc_usage, 0);
|
||||
dmc->gmc_mech = m;
|
||||
dmc->gmc_mech_oid = &m->gm_mech_oid;
|
||||
dmc->gmc_cred = delegated_mc;
|
||||
SLIST_INSERT_HEAD(&dcred->gc_mc, dmc, gmc_link);
|
||||
|
||||
*delegated_cred_handle = (gss_cred_id_t) dcred;
|
||||
}
|
||||
}
|
||||
|
||||
if (ret_flags)
|
||||
*ret_flags = mech_ret_flags;
|
||||
*context_handle = (gss_ctx_id_t) ctx;
|
||||
return (major_status);
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_acquire_cred.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_acquire_cred.c,v 1.4 2006/10/25 00:44:55 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_acquire_cred(OM_uint32 *minor_status,
|
||||
const gss_name_t desired_name,
|
||||
OM_uint32 time_req,
|
||||
const 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)
|
||||
{
|
||||
OM_uint32 major_status;
|
||||
gss_OID_set mechs = desired_mechs;
|
||||
gss_OID_set_desc set;
|
||||
struct _gss_name *name = (struct _gss_name *) desired_name;
|
||||
gssapi_mech_interface m;
|
||||
struct _gss_cred *cred;
|
||||
struct _gss_mechanism_cred *mc;
|
||||
OM_uint32 min_time, cred_time;
|
||||
int i;
|
||||
|
||||
_gss_load_mech();
|
||||
|
||||
/*
|
||||
* First make sure that at least one of the requested
|
||||
* mechanisms is one that we support.
|
||||
*/
|
||||
if (mechs) {
|
||||
for (i = 0; i < mechs->count; i++) {
|
||||
int t;
|
||||
gss_test_oid_set_member(minor_status,
|
||||
&mechs->elements[i], _gss_mech_oids, &t);
|
||||
if (t)
|
||||
break;
|
||||
}
|
||||
if (i == mechs->count) {
|
||||
*output_cred_handle = 0;
|
||||
*minor_status = 0;
|
||||
return (GSS_S_BAD_MECH);
|
||||
}
|
||||
}
|
||||
|
||||
if (actual_mechs) {
|
||||
major_status = gss_create_empty_oid_set(minor_status,
|
||||
actual_mechs);
|
||||
if (major_status)
|
||||
return (major_status);
|
||||
}
|
||||
|
||||
cred = malloc(sizeof(struct _gss_cred));
|
||||
if (!cred) {
|
||||
if (actual_mechs)
|
||||
gss_release_oid_set(minor_status, actual_mechs);
|
||||
*minor_status = ENOMEM;
|
||||
return (GSS_S_FAILURE);
|
||||
}
|
||||
cred->gc_usage = cred_usage;
|
||||
SLIST_INIT(&cred->gc_mc);
|
||||
|
||||
if (mechs == GSS_C_NO_OID_SET)
|
||||
mechs = _gss_mech_oids;
|
||||
|
||||
set.count = 1;
|
||||
min_time = GSS_C_INDEFINITE;
|
||||
for (i = 0; i < mechs->count; i++) {
|
||||
struct _gss_mechanism_name *mn = NULL;
|
||||
|
||||
m = __gss_get_mechanism(&mechs->elements[i]);
|
||||
if (!m)
|
||||
continue;
|
||||
|
||||
if (desired_name != GSS_C_NO_NAME) {
|
||||
mn = _gss_find_mn(name, &mechs->elements[i]);
|
||||
if (!mn)
|
||||
continue;
|
||||
}
|
||||
|
||||
mc = malloc(sizeof(struct _gss_mechanism_cred));
|
||||
if (!mc) {
|
||||
continue;
|
||||
}
|
||||
SLIST_INIT(&cred->gc_mc);
|
||||
mc->gmc_mech = m;
|
||||
mc->gmc_mech_oid = &m->gm_mech_oid;
|
||||
|
||||
/*
|
||||
* XXX Probably need to do something with actual_mechs.
|
||||
*/
|
||||
set.elements = &mechs->elements[i];
|
||||
major_status = m->gm_acquire_cred(minor_status,
|
||||
(desired_name != GSS_C_NO_NAME
|
||||
? mn->gmn_name : GSS_C_NO_NAME),
|
||||
time_req, &set, cred_usage,
|
||||
&mc->gmc_cred, NULL, &cred_time);
|
||||
if (major_status) {
|
||||
free(mc);
|
||||
continue;
|
||||
}
|
||||
if (cred_time < min_time)
|
||||
min_time = cred_time;
|
||||
|
||||
if (actual_mechs) {
|
||||
major_status = gss_add_oid_set_member(minor_status,
|
||||
mc->gmc_mech_oid, actual_mechs);
|
||||
if (major_status) {
|
||||
m->gm_release_cred(minor_status,
|
||||
&mc->gmc_cred);
|
||||
free(mc);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
SLIST_INSERT_HEAD(&cred->gc_mc, mc, gmc_link);
|
||||
}
|
||||
|
||||
/*
|
||||
* If we didn't manage to create a single credential, return
|
||||
* an error.
|
||||
*/
|
||||
if (!SLIST_FIRST(&cred->gc_mc)) {
|
||||
free(cred);
|
||||
if (actual_mechs)
|
||||
gss_release_oid_set(minor_status, actual_mechs);
|
||||
*output_cred_handle = 0;
|
||||
*minor_status = 0;
|
||||
return (GSS_S_NO_CRED);
|
||||
}
|
||||
|
||||
if (time_rec)
|
||||
*time_rec = min_time;
|
||||
*output_cred_handle = (gss_cred_id_t) cred;
|
||||
*minor_status = 0;
|
||||
return (GSS_S_COMPLETE);
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_add_cred.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_add_cred.c,v 1.3 2006/06/29 08:23:53 lha Exp $");
|
||||
|
||||
static struct _gss_mechanism_cred *
|
||||
_gss_copy_cred(struct _gss_mechanism_cred *mc)
|
||||
{
|
||||
struct _gss_mechanism_cred *new_mc;
|
||||
gssapi_mech_interface m = mc->gmc_mech;
|
||||
OM_uint32 major_status, minor_status;
|
||||
gss_name_t name;
|
||||
gss_cred_id_t cred;
|
||||
OM_uint32 initiator_lifetime, acceptor_lifetime;
|
||||
gss_cred_usage_t cred_usage;
|
||||
|
||||
major_status = m->gm_inquire_cred_by_mech(&minor_status,
|
||||
mc->gmc_cred, mc->gmc_mech_oid,
|
||||
&name, &initiator_lifetime, &acceptor_lifetime, &cred_usage);
|
||||
if (major_status)
|
||||
return (0);
|
||||
|
||||
major_status = m->gm_add_cred(&minor_status,
|
||||
GSS_C_NO_CREDENTIAL, name, mc->gmc_mech_oid,
|
||||
cred_usage, initiator_lifetime, acceptor_lifetime,
|
||||
&cred, 0, 0, 0);
|
||||
m->gm_release_name(&minor_status, &name);
|
||||
|
||||
if (major_status)
|
||||
return (0);
|
||||
|
||||
new_mc = malloc(sizeof(struct _gss_mechanism_cred));
|
||||
if (!new_mc) {
|
||||
m->gm_release_cred(&minor_status, &cred);
|
||||
return (0);
|
||||
}
|
||||
new_mc->gmc_mech = m;
|
||||
new_mc->gmc_mech_oid = &m->gm_mech_oid;
|
||||
new_mc->gmc_cred = cred;
|
||||
|
||||
return (new_mc);
|
||||
}
|
||||
|
||||
OM_uint32
|
||||
gss_add_cred(OM_uint32 *minor_status,
|
||||
const gss_cred_id_t input_cred_handle,
|
||||
const gss_name_t desired_name,
|
||||
const 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)
|
||||
{
|
||||
OM_uint32 major_status;
|
||||
gssapi_mech_interface m;
|
||||
struct _gss_cred *cred = (struct _gss_cred *) input_cred_handle;
|
||||
struct _gss_cred *new_cred;
|
||||
gss_cred_id_t release_cred;
|
||||
struct _gss_mechanism_cred *mc, *target_mc, *copy_mc;
|
||||
struct _gss_mechanism_name *mn;
|
||||
OM_uint32 junk;
|
||||
|
||||
*output_cred_handle = 0;
|
||||
*minor_status = 0;
|
||||
|
||||
new_cred = malloc(sizeof(struct _gss_cred));
|
||||
if (!new_cred) {
|
||||
*minor_status = ENOMEM;
|
||||
return (GSS_S_FAILURE);
|
||||
}
|
||||
new_cred->gc_usage = cred_usage;
|
||||
SLIST_INIT(&new_cred->gc_mc);
|
||||
|
||||
/*
|
||||
* We go through all the mc attached to the input_cred_handle
|
||||
* and check the mechanism. If it matches, we call
|
||||
* gss_add_cred for that mechanism, otherwise we copy the mc
|
||||
* to new_cred.
|
||||
*/
|
||||
target_mc = 0;
|
||||
if (cred) {
|
||||
SLIST_FOREACH(mc, &cred->gc_mc, gmc_link) {
|
||||
if (gss_oid_equal(mc->gmc_mech_oid, desired_mech)) {
|
||||
target_mc = mc;
|
||||
}
|
||||
copy_mc = _gss_copy_cred(mc);
|
||||
if (!copy_mc) {
|
||||
release_cred = (gss_cred_id_t)new_cred;
|
||||
gss_release_cred(&junk, &release_cred);
|
||||
*minor_status = ENOMEM;
|
||||
return (GSS_S_FAILURE);
|
||||
}
|
||||
SLIST_INSERT_HEAD(&new_cred->gc_mc, copy_mc, gmc_link);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Figure out a suitable mn, if any.
|
||||
*/
|
||||
if (desired_name) {
|
||||
mn = _gss_find_mn((struct _gss_name *) desired_name,
|
||||
desired_mech);
|
||||
if (!mn) {
|
||||
free(new_cred);
|
||||
return (GSS_S_BAD_NAME);
|
||||
}
|
||||
} else {
|
||||
mn = 0;
|
||||
}
|
||||
|
||||
m = __gss_get_mechanism(desired_mech);
|
||||
|
||||
mc = malloc(sizeof(struct _gss_mechanism_cred));
|
||||
if (!mc) {
|
||||
release_cred = (gss_cred_id_t)new_cred;
|
||||
gss_release_cred(&junk, &release_cred);
|
||||
*minor_status = ENOMEM;
|
||||
return (GSS_S_FAILURE);
|
||||
}
|
||||
mc->gmc_mech = m;
|
||||
mc->gmc_mech_oid = &m->gm_mech_oid;
|
||||
|
||||
major_status = m->gm_add_cred(minor_status,
|
||||
target_mc ? target_mc->gmc_cred : GSS_C_NO_CREDENTIAL,
|
||||
desired_name ? mn->gmn_name : GSS_C_NO_NAME,
|
||||
desired_mech,
|
||||
cred_usage,
|
||||
initiator_time_req,
|
||||
acceptor_time_req,
|
||||
&mc->gmc_cred,
|
||||
actual_mechs,
|
||||
initiator_time_rec,
|
||||
acceptor_time_rec);
|
||||
|
||||
if (major_status) {
|
||||
release_cred = (gss_cred_id_t)new_cred;
|
||||
gss_release_cred(&junk, &release_cred);
|
||||
free(mc);
|
||||
return (major_status);
|
||||
}
|
||||
SLIST_INSERT_HEAD(&new_cred->gc_mc, mc, gmc_link);
|
||||
*output_cred_handle = (gss_cred_id_t) new_cred;
|
||||
|
||||
return (GSS_S_COMPLETE);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 1997 - 2001, 2003 Kungliga Tekniska Högskolan
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* 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"
|
||||
RCSID("$Id: gss_add_oid_set_member.c,v 1.3 2006/10/22 09:36:13 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_add_oid_set_member (OM_uint32 * minor_status,
|
||||
const gss_OID member_oid,
|
||||
gss_OID_set * oid_set)
|
||||
{
|
||||
gss_OID tmp;
|
||||
size_t n;
|
||||
OM_uint32 res;
|
||||
int present;
|
||||
|
||||
res = gss_test_oid_set_member(minor_status, member_oid, *oid_set, &present);
|
||||
if (res != GSS_S_COMPLETE)
|
||||
return res;
|
||||
|
||||
if (present) {
|
||||
*minor_status = 0;
|
||||
return GSS_S_COMPLETE;
|
||||
}
|
||||
|
||||
n = (*oid_set)->count + 1;
|
||||
tmp = realloc ((*oid_set)->elements, n * sizeof(gss_OID_desc));
|
||||
if (tmp == NULL) {
|
||||
*minor_status = ENOMEM;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
(*oid_set)->elements = tmp;
|
||||
(*oid_set)->count = n;
|
||||
(*oid_set)->elements[n-1] = *member_oid;
|
||||
*minor_status = 0;
|
||||
return GSS_S_COMPLETE;
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright (c) 2004, PADL Software Pty Ltd.
|
||||
* 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 PADL Software 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 PADL SOFTWARE 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 PADL SOFTWARE 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"
|
||||
RCSID("$Id: gss_buffer_set.c,v 1.2 2006/10/24 21:53:02 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_create_empty_buffer_set
|
||||
(OM_uint32 * minor_status,
|
||||
gss_buffer_set_t *buffer_set)
|
||||
{
|
||||
gss_buffer_set_t set;
|
||||
|
||||
set = (gss_buffer_set_desc *) malloc(sizeof(*set));
|
||||
if (set == GSS_C_NO_BUFFER_SET) {
|
||||
*minor_status = ENOMEM;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
set->count = 0;
|
||||
set->elements = NULL;
|
||||
|
||||
*buffer_set = set;
|
||||
|
||||
*minor_status = 0;
|
||||
return GSS_S_COMPLETE;
|
||||
}
|
||||
|
||||
OM_uint32
|
||||
gss_add_buffer_set_member
|
||||
(OM_uint32 * minor_status,
|
||||
const gss_buffer_t member_buffer,
|
||||
gss_buffer_set_t *buffer_set)
|
||||
{
|
||||
gss_buffer_set_t set;
|
||||
gss_buffer_t p;
|
||||
OM_uint32 ret;
|
||||
|
||||
if (*buffer_set == GSS_C_NO_BUFFER_SET) {
|
||||
ret = gss_create_empty_buffer_set(minor_status,
|
||||
buffer_set);
|
||||
if (ret) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
set = *buffer_set;
|
||||
set->elements = realloc(set->elements,
|
||||
(set->count + 1) * sizeof(set->elements[0]));
|
||||
if (set->elements == NULL) {
|
||||
*minor_status = ENOMEM;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
p = &set->elements[set->count];
|
||||
|
||||
p->value = malloc(member_buffer->length);
|
||||
if (p->value == NULL) {
|
||||
*minor_status = ENOMEM;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
memcpy(p->value, member_buffer->value, member_buffer->length);
|
||||
p->length = member_buffer->length;
|
||||
|
||||
set->count++;
|
||||
|
||||
*minor_status = 0;
|
||||
return GSS_S_COMPLETE;
|
||||
}
|
||||
|
||||
OM_uint32
|
||||
gss_release_buffer_set(OM_uint32 * minor_status,
|
||||
gss_buffer_set_t *buffer_set)
|
||||
{
|
||||
int i;
|
||||
OM_uint32 minor;
|
||||
|
||||
*minor_status = 0;
|
||||
|
||||
if (*buffer_set == GSS_C_NO_BUFFER_SET)
|
||||
return GSS_S_COMPLETE;
|
||||
|
||||
for (i = 0; i < (*buffer_set)->count; i++)
|
||||
gss_release_buffer(&minor, &((*buffer_set)->elements[i]));
|
||||
|
||||
free((*buffer_set)->elements);
|
||||
|
||||
(*buffer_set)->elements = NULL;
|
||||
(*buffer_set)->count = 0;
|
||||
|
||||
free(*buffer_set);
|
||||
*buffer_set = GSS_C_NO_BUFFER_SET;
|
||||
|
||||
return GSS_S_COMPLETE;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_canonicalize_name.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_canonicalize_name.c,v 1.2 2006/06/28 09:00:25 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_canonicalize_name(OM_uint32 *minor_status,
|
||||
const gss_name_t input_name,
|
||||
const gss_OID mech_type,
|
||||
gss_name_t *output_name)
|
||||
{
|
||||
OM_uint32 major_status;
|
||||
struct _gss_name *name = (struct _gss_name *) input_name;
|
||||
struct _gss_mechanism_name *mn;
|
||||
gssapi_mech_interface m = __gss_get_mechanism(mech_type);
|
||||
gss_name_t new_canonical_name;
|
||||
|
||||
*minor_status = 0;
|
||||
*output_name = 0;
|
||||
|
||||
mn = _gss_find_mn(name, mech_type);
|
||||
if (!mn) {
|
||||
return (GSS_S_BAD_MECH);
|
||||
}
|
||||
|
||||
m = mn->gmn_mech;
|
||||
major_status = m->gm_canonicalize_name(minor_status,
|
||||
mn->gmn_name, mech_type, &new_canonical_name);
|
||||
if (major_status)
|
||||
return (major_status);
|
||||
|
||||
/*
|
||||
* Now we make a new name and mark it as an MN.
|
||||
*/
|
||||
*minor_status = 0;
|
||||
name = malloc(sizeof(struct _gss_name));
|
||||
if (!name) {
|
||||
m->gm_release_name(minor_status, &new_canonical_name);
|
||||
*minor_status = ENOMEM;
|
||||
return (GSS_S_FAILURE);
|
||||
}
|
||||
memset(name, 0, sizeof(struct _gss_name));
|
||||
|
||||
mn = malloc(sizeof(struct _gss_mechanism_name));
|
||||
if (!mn) {
|
||||
m->gm_release_name(minor_status, &new_canonical_name);
|
||||
free(name);
|
||||
*minor_status = ENOMEM;
|
||||
return (GSS_S_FAILURE);
|
||||
}
|
||||
|
||||
SLIST_INIT(&name->gn_mn);
|
||||
mn->gmn_mech = m;
|
||||
mn->gmn_mech_oid = &m->gm_mech_oid;
|
||||
mn->gmn_name = new_canonical_name;
|
||||
SLIST_INSERT_HEAD(&name->gn_mn, mn, gmn_link);
|
||||
|
||||
*output_name = (gss_name_t) name;
|
||||
|
||||
return (GSS_S_COMPLETE);
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_compare_name.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_compare_name.c,v 1.2 2006/06/28 09:00:25 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_compare_name(OM_uint32 *minor_status,
|
||||
const gss_name_t name1_arg,
|
||||
const gss_name_t name2_arg,
|
||||
int *name_equal)
|
||||
{
|
||||
struct _gss_name *name1 = (struct _gss_name *) name1_arg;
|
||||
struct _gss_name *name2 = (struct _gss_name *) name2_arg;
|
||||
|
||||
/*
|
||||
* First check the implementation-independant name if both
|
||||
* names have one. Otherwise, try to find common mechanism
|
||||
* names and compare them.
|
||||
*/
|
||||
if (name1->gn_value.value && name2->gn_value.value) {
|
||||
*name_equal = 1;
|
||||
if (!gss_oid_equal(&name1->gn_type, &name2->gn_type)) {
|
||||
*name_equal = 0;
|
||||
} else if (name1->gn_value.length != name2->gn_value.length ||
|
||||
memcmp(name1->gn_value.value, name1->gn_value.value,
|
||||
name1->gn_value.length)) {
|
||||
*name_equal = 0;
|
||||
}
|
||||
} else {
|
||||
struct _gss_mechanism_name *mn1;
|
||||
struct _gss_mechanism_name *mn2;
|
||||
|
||||
SLIST_FOREACH(mn1, &name1->gn_mn, gmn_link) {
|
||||
mn2 = _gss_find_mn(name2, mn1->gmn_mech_oid);
|
||||
if (mn2) {
|
||||
return (mn1->gmn_mech->gm_compare_name(
|
||||
minor_status,
|
||||
mn1->gmn_name,
|
||||
mn2->gmn_name,
|
||||
name_equal));
|
||||
}
|
||||
}
|
||||
*name_equal = 0;
|
||||
}
|
||||
|
||||
*minor_status = 0;
|
||||
return (GSS_S_COMPLETE);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_context_time.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_context_time.c,v 1.2 2006/06/28 09:00:25 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_context_time(OM_uint32 *minor_status,
|
||||
const gss_ctx_id_t context_handle,
|
||||
OM_uint32 *time_rec)
|
||||
{
|
||||
struct _gss_context *ctx = (struct _gss_context *) context_handle;
|
||||
gssapi_mech_interface m = ctx->gc_mech;
|
||||
|
||||
return (m->gm_context_time(minor_status, ctx->gc_ctx, time_rec));
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_create_empty_oid_set.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_create_empty_oid_set.c,v 1.2 2006/06/28 09:00:25 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_create_empty_oid_set(OM_uint32 *minor_status,
|
||||
gss_OID_set *oid_set)
|
||||
{
|
||||
gss_OID_set set;
|
||||
|
||||
*minor_status = 0;
|
||||
*oid_set = 0;
|
||||
|
||||
set = malloc(sizeof(gss_OID_set_desc));
|
||||
if (!set) {
|
||||
*minor_status = ENOMEM;
|
||||
return (GSS_S_FAILURE);
|
||||
}
|
||||
|
||||
set->count = 0;
|
||||
set->elements = 0;
|
||||
*oid_set = set;
|
||||
|
||||
return (GSS_S_COMPLETE);
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2006 Kungliga Tekniska Högskolan
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* 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"
|
||||
RCSID("$Id: gss_decapsulate_token.c,v 1.2 2006/10/14 10:04:45 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_decapsulate_token(gss_buffer_t input_token,
|
||||
gss_OID oid,
|
||||
gss_buffer_t output_token)
|
||||
{
|
||||
GSSAPIContextToken ct;
|
||||
heim_oid o;
|
||||
OM_uint32 status;
|
||||
int ret;
|
||||
size_t size;
|
||||
|
||||
output_token->length = 0;
|
||||
output_token->value = NULL;
|
||||
|
||||
ret = der_get_oid (oid->elements, oid->length, &o, &size);
|
||||
if (ret)
|
||||
return GSS_S_FAILURE;
|
||||
|
||||
ret = decode_GSSAPIContextToken(input_token->value, input_token->length,
|
||||
&ct, NULL);
|
||||
if (ret) {
|
||||
der_free_oid(&o);
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
if (der_heim_oid_cmp(&ct.thisMech, &o) == 0) {
|
||||
status = GSS_S_COMPLETE;
|
||||
output_token->value = ct.innerContextToken.data;
|
||||
output_token->length = ct.innerContextToken.length;
|
||||
der_free_oid(&ct.thisMech);
|
||||
} else {
|
||||
free_GSSAPIContextToken(&ct);
|
||||
status = GSS_S_FAILURE;
|
||||
}
|
||||
der_free_oid(&o);
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_delete_sec_context.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_delete_sec_context.c,v 1.2 2006/06/28 09:00:25 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_delete_sec_context(OM_uint32 *minor_status,
|
||||
gss_ctx_id_t *context_handle,
|
||||
gss_buffer_t output_token)
|
||||
{
|
||||
OM_uint32 major_status;
|
||||
struct _gss_context *ctx = (struct _gss_context *) *context_handle;
|
||||
|
||||
*minor_status = 0;
|
||||
if (ctx) {
|
||||
/*
|
||||
* If we have an implementation ctx, delete it,
|
||||
* otherwise fake an empty token.
|
||||
*/
|
||||
if (ctx->gc_ctx) {
|
||||
major_status = ctx->gc_mech->gm_delete_sec_context(
|
||||
minor_status, &ctx->gc_ctx, output_token);
|
||||
} else if (output_token != GSS_C_NO_BUFFER) {
|
||||
output_token->length = 0;
|
||||
output_token->value = 0;
|
||||
}
|
||||
free(ctx);
|
||||
*context_handle = 0;
|
||||
}
|
||||
|
||||
return (GSS_S_COMPLETE);
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_display_name.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_display_name.c,v 1.2 2006/06/28 09:00:25 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_display_name(OM_uint32 *minor_status,
|
||||
const gss_name_t input_name,
|
||||
gss_buffer_t output_name_buffer,
|
||||
gss_OID *output_name_type)
|
||||
{
|
||||
OM_uint32 major_status;
|
||||
struct _gss_name *name = (struct _gss_name *) input_name;
|
||||
struct _gss_mechanism_name *mn;
|
||||
|
||||
/*
|
||||
* If we know it, copy the buffer used to import the name in
|
||||
* the first place. Otherwise, ask all the MNs in turn if
|
||||
* they can display the thing.
|
||||
*/
|
||||
if (name->gn_value.value) {
|
||||
output_name_buffer->value = malloc(name->gn_value.length);
|
||||
if (!output_name_buffer->value) {
|
||||
*minor_status = ENOMEM;
|
||||
return (GSS_S_FAILURE);
|
||||
}
|
||||
output_name_buffer->length = name->gn_value.length;
|
||||
memcpy(output_name_buffer->value, name->gn_value.value,
|
||||
output_name_buffer->length);
|
||||
if (output_name_type)
|
||||
*output_name_type = &name->gn_type;
|
||||
|
||||
*minor_status = 0;
|
||||
return (GSS_S_COMPLETE);
|
||||
} else {
|
||||
SLIST_FOREACH(mn, &name->gn_mn, gmn_link) {
|
||||
major_status = mn->gmn_mech->gm_display_name(
|
||||
minor_status, mn->gmn_name,
|
||||
output_name_buffer,
|
||||
output_name_type);
|
||||
if (major_status == GSS_S_COMPLETE)
|
||||
return (GSS_S_COMPLETE);
|
||||
}
|
||||
}
|
||||
|
||||
*minor_status = 0;
|
||||
return (GSS_S_FAILURE);
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_display_status.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1998 - 2005 Kungliga Tekniska Högskolan
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* 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"
|
||||
RCSID("$Id: gss_display_status.c,v 1.4 2006/07/19 11:02:33 lha Exp $");
|
||||
|
||||
static const char *
|
||||
calling_error(OM_uint32 v)
|
||||
{
|
||||
static const char *msgs[] = {
|
||||
NULL, /* 0 */
|
||||
"A required input parameter could not be read.", /* */
|
||||
"A required output parameter could not be written.", /* */
|
||||
"A parameter was malformed"
|
||||
};
|
||||
|
||||
v >>= GSS_C_CALLING_ERROR_OFFSET;
|
||||
|
||||
if (v == 0)
|
||||
return "";
|
||||
else if (v >= sizeof(msgs)/sizeof(*msgs))
|
||||
return "unknown calling error";
|
||||
else
|
||||
return msgs[v];
|
||||
}
|
||||
|
||||
static const char *
|
||||
routine_error(OM_uint32 v)
|
||||
{
|
||||
static const char *msgs[] = {
|
||||
NULL, /* 0 */
|
||||
"An unsupported mechanism was requested",
|
||||
"An invalid name was supplied",
|
||||
"A supplied name was of an unsupported type",
|
||||
"Incorrect channel bindings were supplied",
|
||||
"An invalid status code was supplied",
|
||||
"A token had an invalid MIC",
|
||||
"No credentials were supplied, "
|
||||
"or the credentials were unavailable or inaccessible.",
|
||||
"No context has been established",
|
||||
"A token was invalid",
|
||||
"A credential was invalid",
|
||||
"The referenced credentials have expired",
|
||||
"The context has expired",
|
||||
"Miscellaneous failure (see text)",
|
||||
"The quality-of-protection requested could not be provide",
|
||||
"The operation is forbidden by local security policy",
|
||||
"The operation or option is not available",
|
||||
"The requested credential element already exists",
|
||||
"The provided name was not a mechanism name.",
|
||||
};
|
||||
|
||||
v >>= GSS_C_ROUTINE_ERROR_OFFSET;
|
||||
|
||||
if (v == 0)
|
||||
return "";
|
||||
else if (v >= sizeof(msgs)/sizeof(*msgs))
|
||||
return "unknown routine error";
|
||||
else
|
||||
return msgs[v];
|
||||
}
|
||||
|
||||
static const char *
|
||||
supplementary_error(OM_uint32 v)
|
||||
{
|
||||
static const char *msgs[] = {
|
||||
"normal completion",
|
||||
"continuation call to routine required",
|
||||
"duplicate per-message token detected",
|
||||
"timed-out per-message token detected",
|
||||
"reordered (early) per-message token detected",
|
||||
"skipped predecessor token(s) detected"
|
||||
};
|
||||
|
||||
v >>= GSS_C_SUPPLEMENTARY_OFFSET;
|
||||
|
||||
if (v >= sizeof(msgs)/sizeof(*msgs))
|
||||
return "unknown routine error";
|
||||
else
|
||||
return msgs[v];
|
||||
}
|
||||
|
||||
|
||||
OM_uint32
|
||||
gss_display_status(OM_uint32 *minor_status,
|
||||
OM_uint32 status_value,
|
||||
int status_type,
|
||||
const gss_OID mech_type,
|
||||
OM_uint32 *message_content,
|
||||
gss_buffer_t status_string)
|
||||
{
|
||||
OM_uint32 major_status;
|
||||
|
||||
*minor_status = 0;
|
||||
switch (status_type) {
|
||||
case GSS_C_GSS_CODE: {
|
||||
char *buf;
|
||||
|
||||
if (GSS_SUPPLEMENTARY_INFO(status_value))
|
||||
asprintf(&buf, "%s", supplementary_error(
|
||||
GSS_SUPPLEMENTARY_INFO(status_value)));
|
||||
else
|
||||
asprintf (&buf, "%s %s",
|
||||
calling_error(GSS_CALLING_ERROR(status_value)),
|
||||
routine_error(GSS_ROUTINE_ERROR(status_value)));
|
||||
|
||||
status_string->length = strlen(buf);
|
||||
status_string->value = buf;
|
||||
|
||||
return GSS_S_COMPLETE;
|
||||
}
|
||||
case GSS_C_MECH_CODE: {
|
||||
gssapi_mech_interface m;
|
||||
m = __gss_get_mechanism(mech_type);
|
||||
if (m) {
|
||||
major_status = m->gm_display_status(minor_status,
|
||||
status_value, status_type, mech_type,
|
||||
message_content, status_string);
|
||||
if (major_status == GSS_S_COMPLETE)
|
||||
return (GSS_S_COMPLETE);
|
||||
}
|
||||
}
|
||||
}
|
||||
status_string->value = NULL;
|
||||
status_string->length = 0;
|
||||
return (GSS_S_BAD_STATUS);
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_duplicate_name.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_duplicate_name.c,v 1.2 2006/06/28 09:00:25 lha Exp $");
|
||||
|
||||
OM_uint32 gss_duplicate_name(OM_uint32 *minor_status,
|
||||
const gss_name_t src_name,
|
||||
gss_name_t *dest_name)
|
||||
{
|
||||
OM_uint32 major_status;
|
||||
struct _gss_name *name = (struct _gss_name *) src_name;
|
||||
struct _gss_name *new_name;
|
||||
struct _gss_mechanism_name *mn;
|
||||
|
||||
*minor_status = 0;
|
||||
|
||||
/*
|
||||
* If this name has a value (i.e. it didn't come from
|
||||
* gss_canonicalize_name(), we re-import the thing. Otherwise,
|
||||
* we make an empty name to hold the MN copy.
|
||||
*/
|
||||
if (name->gn_value.value) {
|
||||
major_status = gss_import_name(minor_status,
|
||||
&name->gn_value, &name->gn_type, dest_name);
|
||||
if (major_status != GSS_S_COMPLETE)
|
||||
return (major_status);
|
||||
new_name = (struct _gss_name *) *dest_name;
|
||||
} else {
|
||||
new_name = malloc(sizeof(struct _gss_name));
|
||||
if (!new_name) {
|
||||
*minor_status = ENOMEM;
|
||||
return (GSS_S_FAILURE);
|
||||
}
|
||||
memset(new_name, 0, sizeof(struct _gss_name));
|
||||
SLIST_INIT(&name->gn_mn);
|
||||
*dest_name = (gss_name_t) new_name;
|
||||
}
|
||||
|
||||
/*
|
||||
* Import the new name into any mechanisms listed in the
|
||||
* original name. We could probably get away with only doing
|
||||
* this if the original was canonical.
|
||||
*/
|
||||
SLIST_FOREACH(mn, &name->gn_mn, gmn_link) {
|
||||
_gss_find_mn(new_name, mn->gmn_mech_oid);
|
||||
}
|
||||
|
||||
return (GSS_S_COMPLETE);
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 1997 - 2003 Kungliga Tekniska Högskolan
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* 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"
|
||||
RCSID("$Id: gss_duplicate_oid.c,v 1.1 2006/06/28 09:07:07 lha Exp $");
|
||||
|
||||
OM_uint32 gss_duplicate_oid (
|
||||
OM_uint32 *minor_status,
|
||||
gss_OID src_oid,
|
||||
gss_OID *dest_oid
|
||||
)
|
||||
{
|
||||
*minor_status = 0;
|
||||
|
||||
if (src_oid == GSS_C_NO_OID) {
|
||||
*dest_oid = GSS_C_NO_OID;
|
||||
return GSS_S_COMPLETE;
|
||||
}
|
||||
|
||||
*dest_oid = malloc(sizeof(**dest_oid));
|
||||
if (*dest_oid == GSS_C_NO_OID) {
|
||||
*minor_status = ENOMEM;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
(*dest_oid)->elements = malloc(src_oid->length);
|
||||
if ((*dest_oid)->elements == NULL) {
|
||||
free(*dest_oid);
|
||||
*minor_status = ENOMEM;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
memcpy((*dest_oid)->elements, src_oid->elements, src_oid->length);
|
||||
(*dest_oid)->length = src_oid->length;
|
||||
|
||||
*minor_status = 0;
|
||||
return GSS_S_COMPLETE;
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2006 Kungliga Tekniska Högskolan
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* 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"
|
||||
RCSID("$Id: gss_encapsulate_token.c,v 1.2 2006/10/14 10:05:12 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_encapsulate_token(gss_buffer_t input_token,
|
||||
gss_OID oid,
|
||||
gss_buffer_t output_token)
|
||||
{
|
||||
GSSAPIContextToken ct;
|
||||
int ret;
|
||||
size_t size;
|
||||
|
||||
ret = der_get_oid (oid->elements, oid->length, &ct.thisMech, &size);
|
||||
if (ret) {
|
||||
output_token->value = NULL;
|
||||
output_token->length = 0;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
ct.innerContextToken.data = input_token->value;
|
||||
ct.innerContextToken.length = input_token->length;
|
||||
|
||||
ASN1_MALLOC_ENCODE(GSSAPIContextToken,
|
||||
output_token->value, output_token->length,
|
||||
&ct, &size, ret);
|
||||
der_free_oid(&ct.thisMech);
|
||||
if (ret) {
|
||||
output_token->length = 0;
|
||||
output_token->value = NULL;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
if (output_token->length != size)
|
||||
abort();
|
||||
|
||||
return GSS_S_COMPLETE;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_export_name.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_export_name.c,v 1.3 2006/07/05 22:41:57 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_export_name(OM_uint32 *minor_status,
|
||||
const gss_name_t input_name,
|
||||
gss_buffer_t exported_name)
|
||||
{
|
||||
struct _gss_name *name = (struct _gss_name *) input_name;
|
||||
struct _gss_mechanism_name *mn;
|
||||
|
||||
exported_name->value = NULL;
|
||||
exported_name->length = 0;
|
||||
|
||||
/*
|
||||
* If this name already has any attached MNs, export the first
|
||||
* one, otherwise export based on the first mechanism in our
|
||||
* list.
|
||||
*/
|
||||
mn = SLIST_FIRST(&name->gn_mn);
|
||||
if (!mn) {
|
||||
*minor_status = 0;
|
||||
return (GSS_S_NAME_NOT_MN);
|
||||
}
|
||||
|
||||
return mn->gmn_mech->gm_export_name(minor_status,
|
||||
mn->gmn_name, exported_name);
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_export_sec_context.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_export_sec_context.c,v 1.2 2006/06/28 09:00:25 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_export_sec_context(OM_uint32 *minor_status,
|
||||
gss_ctx_id_t *context_handle,
|
||||
gss_buffer_t interprocess_token)
|
||||
{
|
||||
OM_uint32 major_status;
|
||||
struct _gss_context *ctx = (struct _gss_context *) *context_handle;
|
||||
gssapi_mech_interface m = ctx->gc_mech;
|
||||
gss_buffer_desc buf;
|
||||
|
||||
major_status = m->gm_export_sec_context(minor_status,
|
||||
&ctx->gc_ctx, &buf);
|
||||
|
||||
if (major_status == GSS_S_COMPLETE) {
|
||||
unsigned char *p;
|
||||
|
||||
free(ctx);
|
||||
*context_handle = GSS_C_NO_CONTEXT;
|
||||
interprocess_token->length = buf.length
|
||||
+ 2 + m->gm_mech_oid.length;
|
||||
interprocess_token->value = malloc(interprocess_token->length);
|
||||
if (!interprocess_token->value) {
|
||||
/*
|
||||
* We are in trouble here - the context is
|
||||
* already gone. This is allowed as long as we
|
||||
* set the caller's context_handle to
|
||||
* GSS_C_NO_CONTEXT, which we did above.
|
||||
* Return GSS_S_FAILURE.
|
||||
*/
|
||||
*minor_status = ENOMEM;
|
||||
return (GSS_S_FAILURE);
|
||||
}
|
||||
p = interprocess_token->value;
|
||||
p[0] = m->gm_mech_oid.length >> 8;
|
||||
p[1] = m->gm_mech_oid.length;
|
||||
memcpy(p + 2, m->gm_mech_oid.elements, m->gm_mech_oid.length);
|
||||
memcpy(p + 2 + m->gm_mech_oid.length, buf.value, buf.length);
|
||||
gss_release_buffer(minor_status, &buf);
|
||||
}
|
||||
|
||||
return (major_status);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_get_mic.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_get_mic.c,v 1.2 2006/06/28 09:00:25 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_get_mic(OM_uint32 *minor_status,
|
||||
const gss_ctx_id_t context_handle,
|
||||
gss_qop_t qop_req,
|
||||
const gss_buffer_t message_buffer,
|
||||
gss_buffer_t message_token)
|
||||
{
|
||||
struct _gss_context *ctx = (struct _gss_context *) context_handle;
|
||||
gssapi_mech_interface m = ctx->gc_mech;
|
||||
|
||||
return (m->gm_get_mic(minor_status, ctx->gc_ctx, qop_req,
|
||||
message_buffer, message_token));
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_import_name.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_import_name.c,v 1.3 2006/06/29 21:23:13 lha Exp $");
|
||||
|
||||
static OM_uint32
|
||||
_gss_import_export_name(OM_uint32 *minor_status,
|
||||
const gss_buffer_t input_name_buffer,
|
||||
gss_name_t *output_name)
|
||||
{
|
||||
OM_uint32 major_status;
|
||||
unsigned char *p = input_name_buffer->value;
|
||||
size_t len = input_name_buffer->length;
|
||||
size_t t;
|
||||
gss_OID_desc mech_oid;
|
||||
gssapi_mech_interface m;
|
||||
struct _gss_name *name;
|
||||
gss_name_t new_canonical_name;
|
||||
|
||||
*minor_status = 0;
|
||||
*output_name = 0;
|
||||
|
||||
/*
|
||||
* Make sure that TOK_ID is {4, 1}.
|
||||
*/
|
||||
if (len < 2)
|
||||
return (GSS_S_BAD_NAME);
|
||||
if (p[0] != 4 || p[1] != 1)
|
||||
return (GSS_S_BAD_NAME);
|
||||
p += 2;
|
||||
len -= 2;
|
||||
|
||||
/*
|
||||
* Get the mech length and the name length and sanity
|
||||
* check the size of of the buffer.
|
||||
*/
|
||||
if (len < 2)
|
||||
return (GSS_S_BAD_NAME);
|
||||
t = (p[0] << 8) + p[1];
|
||||
p += 2;
|
||||
len -= 2;
|
||||
|
||||
/*
|
||||
* Check the DER encoded OID to make sure it agrees with the
|
||||
* length we just decoded.
|
||||
*/
|
||||
if (p[0] != 6) /* 6=OID */
|
||||
return (GSS_S_BAD_NAME);
|
||||
p++;
|
||||
len--;
|
||||
t--;
|
||||
if (p[0] & 0x80) {
|
||||
int digits = p[0];
|
||||
p++;
|
||||
len--;
|
||||
t--;
|
||||
mech_oid.length = 0;
|
||||
while (digits--) {
|
||||
mech_oid.length = (mech_oid.length << 8) | p[0];
|
||||
p++;
|
||||
len--;
|
||||
t--;
|
||||
}
|
||||
} else {
|
||||
mech_oid.length = p[0];
|
||||
p++;
|
||||
len--;
|
||||
t--;
|
||||
}
|
||||
if (mech_oid.length != t)
|
||||
return (GSS_S_BAD_NAME);
|
||||
|
||||
mech_oid.elements = p;
|
||||
|
||||
if (len < t + 4)
|
||||
return (GSS_S_BAD_NAME);
|
||||
p += t;
|
||||
len -= t;
|
||||
|
||||
t = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
|
||||
p += 4;
|
||||
len -= 4;
|
||||
|
||||
if (len != t)
|
||||
return (GSS_S_BAD_NAME);
|
||||
|
||||
m = __gss_get_mechanism(&mech_oid);
|
||||
if (!m)
|
||||
return (GSS_S_BAD_MECH);
|
||||
|
||||
/*
|
||||
* Ask the mechanism to import the name.
|
||||
*/
|
||||
major_status = m->gm_import_name(minor_status,
|
||||
input_name_buffer, GSS_C_NT_EXPORT_NAME, &new_canonical_name);
|
||||
|
||||
/*
|
||||
* Now we make a new name and mark it as an MN.
|
||||
*/
|
||||
name = _gss_make_name(m, new_canonical_name);
|
||||
if (!name) {
|
||||
m->gm_release_name(minor_status, &new_canonical_name);
|
||||
return (GSS_S_FAILURE);
|
||||
}
|
||||
|
||||
*output_name = (gss_name_t) name;
|
||||
|
||||
*minor_status = 0;
|
||||
return (GSS_S_COMPLETE);
|
||||
}
|
||||
|
||||
OM_uint32
|
||||
gss_import_name(OM_uint32 *minor_status,
|
||||
const gss_buffer_t input_name_buffer,
|
||||
const gss_OID input_name_type,
|
||||
gss_name_t *output_name)
|
||||
{
|
||||
gss_OID name_type = input_name_type;
|
||||
OM_uint32 major_status;
|
||||
struct _gss_name *name;
|
||||
|
||||
if (input_name_buffer->length == 0) {
|
||||
*minor_status = 0;
|
||||
*output_name = 0;
|
||||
return (GSS_S_BAD_NAME);
|
||||
}
|
||||
|
||||
/*
|
||||
* Use GSS_NT_USER_NAME as default name type.
|
||||
*/
|
||||
if (name_type == GSS_C_NO_OID)
|
||||
name_type = GSS_C_NT_USER_NAME;
|
||||
|
||||
/*
|
||||
* If this is an exported name, we need to parse it to find
|
||||
* the mechanism and then import it as an MN. See RFC 2743
|
||||
* section 3.2 for a description of the format.
|
||||
*/
|
||||
if (gss_oid_equal(name_type, GSS_C_NT_EXPORT_NAME)) {
|
||||
return _gss_import_export_name(minor_status,
|
||||
input_name_buffer, output_name);
|
||||
}
|
||||
|
||||
/*
|
||||
* Only allow certain name types. This is pretty bogus - we
|
||||
* should figure out the list of supported name types using
|
||||
* gss_inquire_names_for_mech.
|
||||
*/
|
||||
if (!gss_oid_equal(name_type, GSS_C_NT_USER_NAME)
|
||||
&& !gss_oid_equal(name_type, GSS_C_NT_MACHINE_UID_NAME)
|
||||
&& !gss_oid_equal(name_type, GSS_C_NT_STRING_UID_NAME)
|
||||
&& !gss_oid_equal(name_type, GSS_C_NT_HOSTBASED_SERVICE_X)
|
||||
&& !gss_oid_equal(name_type, GSS_C_NT_HOSTBASED_SERVICE)
|
||||
&& !gss_oid_equal(name_type, GSS_C_NT_ANONYMOUS)
|
||||
&& !gss_oid_equal(name_type, GSS_KRB5_NT_PRINCIPAL_NAME)) {
|
||||
*minor_status = 0;
|
||||
*output_name = 0;
|
||||
return (GSS_S_BAD_NAMETYPE);
|
||||
}
|
||||
|
||||
*minor_status = 0;
|
||||
name = malloc(sizeof(struct _gss_name));
|
||||
if (!name) {
|
||||
*minor_status = ENOMEM;
|
||||
return (GSS_S_FAILURE);
|
||||
}
|
||||
memset(name, 0, sizeof(struct _gss_name));
|
||||
|
||||
major_status = _gss_copy_oid(minor_status,
|
||||
name_type, &name->gn_type);
|
||||
if (major_status) {
|
||||
free(name);
|
||||
return (GSS_S_FAILURE);
|
||||
}
|
||||
|
||||
major_status = _gss_copy_buffer(minor_status,
|
||||
input_name_buffer, &name->gn_value);
|
||||
if (major_status) {
|
||||
gss_name_t rname = (gss_name_t)name;
|
||||
gss_release_name(minor_status, &rname);
|
||||
return (GSS_S_FAILURE);
|
||||
}
|
||||
|
||||
SLIST_INIT(&name->gn_mn);
|
||||
|
||||
*output_name = (gss_name_t) name;
|
||||
return (GSS_S_COMPLETE);
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_import_sec_context.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_import_sec_context.c,v 1.2 2006/06/28 09:00:25 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_import_sec_context(OM_uint32 *minor_status,
|
||||
const gss_buffer_t interprocess_token,
|
||||
gss_ctx_id_t *context_handle)
|
||||
{
|
||||
OM_uint32 major_status;
|
||||
gssapi_mech_interface m;
|
||||
struct _gss_context *ctx;
|
||||
gss_OID_desc mech_oid;
|
||||
gss_buffer_desc buf;
|
||||
unsigned char *p;
|
||||
size_t len;
|
||||
|
||||
*minor_status = 0;
|
||||
*context_handle = 0;
|
||||
|
||||
/*
|
||||
* We added an oid to the front of the token in
|
||||
* gss_export_sec_context.
|
||||
*/
|
||||
p = interprocess_token->value;
|
||||
len = interprocess_token->length;
|
||||
if (len < 2)
|
||||
return (GSS_S_DEFECTIVE_TOKEN);
|
||||
mech_oid.length = (p[0] << 8) | p[1];
|
||||
if (len < mech_oid.length + 2)
|
||||
return (GSS_S_DEFECTIVE_TOKEN);
|
||||
mech_oid.elements = p + 2;
|
||||
buf.length = len - 2 - mech_oid.length;
|
||||
buf.value = p + 2 + mech_oid.length;
|
||||
|
||||
m = __gss_get_mechanism(&mech_oid);
|
||||
if (!m)
|
||||
return (GSS_S_DEFECTIVE_TOKEN);
|
||||
|
||||
ctx = malloc(sizeof(struct _gss_context));
|
||||
if (!ctx) {
|
||||
*minor_status = ENOMEM;
|
||||
return (GSS_S_FAILURE);
|
||||
}
|
||||
ctx->gc_mech = m;
|
||||
major_status = m->gm_import_sec_context(minor_status,
|
||||
&buf, &ctx->gc_ctx);
|
||||
if (major_status != GSS_S_COMPLETE) {
|
||||
free(ctx);
|
||||
} else {
|
||||
*context_handle = (gss_ctx_id_t) ctx;
|
||||
}
|
||||
|
||||
return (major_status);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_indicate_mechs.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_indicate_mechs.c,v 1.3 2006/07/05 22:36:49 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_indicate_mechs(OM_uint32 *minor_status,
|
||||
gss_OID_set *mech_set)
|
||||
{
|
||||
struct _gss_mech_switch *m;
|
||||
OM_uint32 major_status;
|
||||
gss_OID_set set;
|
||||
int i;
|
||||
|
||||
_gss_load_mech();
|
||||
|
||||
major_status = gss_create_empty_oid_set(minor_status, mech_set);
|
||||
if (major_status)
|
||||
return (major_status);
|
||||
|
||||
SLIST_FOREACH(m, &_gss_mechs, gm_link) {
|
||||
if (m->gm_mech.gm_indicate_mechs) {
|
||||
major_status = m->gm_mech.gm_indicate_mechs(
|
||||
minor_status, &set);
|
||||
if (major_status)
|
||||
continue;
|
||||
for (i = 0; i < set->count; i++)
|
||||
major_status = gss_add_oid_set_member(
|
||||
minor_status, &set->elements[i], mech_set);
|
||||
gss_release_oid_set(minor_status, &set);
|
||||
} else {
|
||||
major_status = gss_add_oid_set_member(
|
||||
minor_status, &m->gm_mech_oid, mech_set);
|
||||
}
|
||||
}
|
||||
|
||||
*minor_status = 0;
|
||||
return (GSS_S_COMPLETE);
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_init_sec_context.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_init_sec_context.c,v 1.3 2006/07/06 22:30:09 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_init_sec_context(OM_uint32 * minor_status,
|
||||
const gss_cred_id_t initiator_cred_handle,
|
||||
gss_ctx_id_t * context_handle,
|
||||
const gss_name_t target_name,
|
||||
const gss_OID input_mech_type,
|
||||
OM_uint32 req_flags,
|
||||
OM_uint32 time_req,
|
||||
const gss_channel_bindings_t input_chan_bindings,
|
||||
const gss_buffer_t input_token,
|
||||
gss_OID * actual_mech_type,
|
||||
gss_buffer_t output_token,
|
||||
OM_uint32 * ret_flags,
|
||||
OM_uint32 * time_rec)
|
||||
{
|
||||
OM_uint32 major_status;
|
||||
gssapi_mech_interface m;
|
||||
struct _gss_name *name = (struct _gss_name *) target_name;
|
||||
struct _gss_mechanism_name *mn;
|
||||
struct _gss_context *ctx = (struct _gss_context *) *context_handle;
|
||||
struct _gss_cred *cred = (struct _gss_cred *) initiator_cred_handle;
|
||||
struct _gss_mechanism_cred *mc;
|
||||
gss_cred_id_t cred_handle;
|
||||
int allocated_ctx;
|
||||
gss_OID mech_type = input_mech_type;
|
||||
|
||||
*minor_status = 0;
|
||||
|
||||
/*
|
||||
* If we haven't allocated a context yet, do so now and lookup
|
||||
* the mechanism switch table. If we have one already, make
|
||||
* sure we use the same mechanism switch as before.
|
||||
*/
|
||||
if (!ctx) {
|
||||
if (mech_type == NULL)
|
||||
mech_type = GSS_KRB5_MECHANISM;
|
||||
|
||||
ctx = malloc(sizeof(struct _gss_context));
|
||||
if (!ctx) {
|
||||
*minor_status = ENOMEM;
|
||||
return (GSS_S_FAILURE);
|
||||
}
|
||||
memset(ctx, 0, sizeof(struct _gss_context));
|
||||
m = ctx->gc_mech = __gss_get_mechanism(mech_type);
|
||||
if (!m) {
|
||||
free(ctx);
|
||||
return (GSS_S_BAD_MECH);
|
||||
}
|
||||
allocated_ctx = 1;
|
||||
} else {
|
||||
m = ctx->gc_mech;
|
||||
mech_type = &ctx->gc_mech->gm_mech_oid;
|
||||
allocated_ctx = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the MN for this mechanism.
|
||||
*/
|
||||
mn = _gss_find_mn(name, mech_type);
|
||||
if (mn == NULL) {
|
||||
if (allocated_ctx)
|
||||
free(ctx);
|
||||
return GSS_S_BAD_NAME;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we have a cred, find the cred for this mechanism.
|
||||
*/
|
||||
cred_handle = GSS_C_NO_CREDENTIAL;
|
||||
if (cred) {
|
||||
SLIST_FOREACH(mc, &cred->gc_mc, gmc_link) {
|
||||
if (gss_oid_equal(mech_type, mc->gmc_mech_oid)) {
|
||||
cred_handle = mc->gmc_cred;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
major_status = m->gm_init_sec_context(minor_status,
|
||||
cred_handle,
|
||||
&ctx->gc_ctx,
|
||||
mn->gmn_name,
|
||||
mech_type,
|
||||
req_flags,
|
||||
time_req,
|
||||
input_chan_bindings,
|
||||
input_token,
|
||||
actual_mech_type,
|
||||
output_token,
|
||||
ret_flags,
|
||||
time_rec);
|
||||
|
||||
if (major_status != GSS_S_COMPLETE
|
||||
&& major_status != GSS_S_CONTINUE_NEEDED) {
|
||||
if (allocated_ctx)
|
||||
free(ctx);
|
||||
} else {
|
||||
*context_handle = (gss_ctx_id_t) ctx;
|
||||
}
|
||||
|
||||
return (major_status);
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_inquire_context.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_inquire_context.c,v 1.2 2006/06/28 09:00:25 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_inquire_context(OM_uint32 *minor_status,
|
||||
const gss_ctx_id_t context_handle,
|
||||
gss_name_t *src_name,
|
||||
gss_name_t *targ_name,
|
||||
OM_uint32 *lifetime_rec,
|
||||
gss_OID *mech_type,
|
||||
OM_uint32 *ctx_flags,
|
||||
int *locally_initiated,
|
||||
int *open)
|
||||
{
|
||||
OM_uint32 major_status;
|
||||
struct _gss_context *ctx = (struct _gss_context *) context_handle;
|
||||
gssapi_mech_interface m = ctx->gc_mech;
|
||||
struct _gss_name *name;
|
||||
gss_name_t src_mn, targ_mn;
|
||||
|
||||
major_status = m->gm_inquire_context(minor_status,
|
||||
ctx->gc_ctx,
|
||||
src_name ? &src_mn : 0,
|
||||
targ_name ? &targ_mn : 0,
|
||||
lifetime_rec,
|
||||
mech_type,
|
||||
ctx_flags,
|
||||
locally_initiated,
|
||||
open);
|
||||
|
||||
if (src_name) *src_name = 0;
|
||||
if (targ_name) *targ_name = 0;
|
||||
|
||||
if (major_status != GSS_S_COMPLETE) {
|
||||
return (major_status);
|
||||
}
|
||||
|
||||
if (src_name) {
|
||||
name = _gss_make_name(m, src_mn);
|
||||
if (!name) {
|
||||
minor_status = 0;
|
||||
return (GSS_S_FAILURE);
|
||||
}
|
||||
*src_name = (gss_name_t) name;
|
||||
}
|
||||
|
||||
if (targ_name) {
|
||||
name = _gss_make_name(m, targ_mn);
|
||||
if (!name) {
|
||||
minor_status = 0;
|
||||
return (GSS_S_FAILURE);
|
||||
}
|
||||
*targ_name = (gss_name_t) name;
|
||||
}
|
||||
|
||||
return (GSS_S_COMPLETE);
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_inquire_cred.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_inquire_cred.c,v 1.5 2006/07/20 02:03:18 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_inquire_cred(OM_uint32 *minor_status,
|
||||
const gss_cred_id_t cred_handle,
|
||||
gss_name_t *name_ret,
|
||||
OM_uint32 *lifetime,
|
||||
gss_cred_usage_t *cred_usage,
|
||||
gss_OID_set *mechanisms)
|
||||
{
|
||||
OM_uint32 major_status;
|
||||
struct _gss_mech_switch *m;
|
||||
struct _gss_cred *cred = (struct _gss_cred *) cred_handle;
|
||||
struct _gss_name *name;
|
||||
struct _gss_mechanism_name *mn;
|
||||
OM_uint32 min_lifetime;
|
||||
int found = 0;
|
||||
|
||||
_gss_load_mech();
|
||||
|
||||
*minor_status = 0;
|
||||
if (name_ret)
|
||||
*name_ret = 0;
|
||||
if (lifetime)
|
||||
*lifetime = 0;
|
||||
if (cred_usage)
|
||||
*cred_usage = 0;
|
||||
|
||||
if (name_ret) {
|
||||
name = malloc(sizeof(struct _gss_name));
|
||||
if (!name) {
|
||||
*minor_status = ENOMEM;
|
||||
return (GSS_S_FAILURE);
|
||||
}
|
||||
memset(name, 0, sizeof(struct _gss_name));
|
||||
SLIST_INIT(&name->gn_mn);
|
||||
} else {
|
||||
name = 0;
|
||||
}
|
||||
|
||||
if (mechanisms) {
|
||||
major_status = gss_create_empty_oid_set(minor_status,
|
||||
mechanisms);
|
||||
if (major_status) {
|
||||
if (name) free(name);
|
||||
return (major_status);
|
||||
}
|
||||
}
|
||||
|
||||
min_lifetime = GSS_C_INDEFINITE;
|
||||
if (cred) {
|
||||
struct _gss_mechanism_cred *mc;
|
||||
|
||||
SLIST_FOREACH(mc, &cred->gc_mc, gmc_link) {
|
||||
gss_name_t mc_name;
|
||||
OM_uint32 mc_lifetime;
|
||||
|
||||
major_status = mc->gmc_mech->gm_inquire_cred(minor_status,
|
||||
mc->gmc_cred, &mc_name, &mc_lifetime, NULL, NULL);
|
||||
if (major_status)
|
||||
continue;
|
||||
|
||||
if (name) {
|
||||
mn = malloc(sizeof(struct _gss_mechanism_name));
|
||||
if (!mn) {
|
||||
mc->gmc_mech->gm_release_name(minor_status,
|
||||
&mc_name);
|
||||
continue;
|
||||
}
|
||||
mn->gmn_mech = mc->gmc_mech;
|
||||
mn->gmn_mech_oid = mc->gmc_mech_oid;
|
||||
mn->gmn_name = mc_name;
|
||||
SLIST_INSERT_HEAD(&name->gn_mn, mn, gmn_link);
|
||||
} else {
|
||||
mc->gmc_mech->gm_release_name(minor_status,
|
||||
&mc_name);
|
||||
}
|
||||
|
||||
if (mc_lifetime < min_lifetime)
|
||||
min_lifetime = mc_lifetime;
|
||||
|
||||
if (mechanisms)
|
||||
gss_add_oid_set_member(minor_status,
|
||||
mc->gmc_mech_oid, mechanisms);
|
||||
found++;
|
||||
}
|
||||
} else {
|
||||
SLIST_FOREACH(m, &_gss_mechs, gm_link) {
|
||||
gss_name_t mc_name;
|
||||
OM_uint32 mc_lifetime;
|
||||
|
||||
major_status = m->gm_mech.gm_inquire_cred(minor_status,
|
||||
GSS_C_NO_CREDENTIAL, &mc_name, &mc_lifetime,
|
||||
cred_usage, NULL);
|
||||
if (major_status)
|
||||
continue;
|
||||
|
||||
if (name && mc_name) {
|
||||
mn = malloc(
|
||||
sizeof(struct _gss_mechanism_name));
|
||||
if (!mn) {
|
||||
m->gm_mech.gm_release_name(
|
||||
minor_status, &mc_name);
|
||||
continue;
|
||||
}
|
||||
mn->gmn_mech = &m->gm_mech;
|
||||
mn->gmn_mech_oid = &m->gm_mech_oid;
|
||||
mn->gmn_name = mc_name;
|
||||
SLIST_INSERT_HEAD(&name->gn_mn, mn, gmn_link);
|
||||
} else if (mc_name) {
|
||||
m->gm_mech.gm_release_name(minor_status,
|
||||
&mc_name);
|
||||
}
|
||||
|
||||
if (mc_lifetime < min_lifetime)
|
||||
min_lifetime = mc_lifetime;
|
||||
|
||||
if (mechanisms)
|
||||
gss_add_oid_set_member(minor_status,
|
||||
&m->gm_mech_oid, mechanisms);
|
||||
found++;
|
||||
}
|
||||
}
|
||||
|
||||
if (found == 0) {
|
||||
gss_release_oid_set(minor_status, mechanisms);
|
||||
*minor_status = 0;
|
||||
return (GSS_S_NO_CRED);
|
||||
}
|
||||
|
||||
*minor_status = 0;
|
||||
if (name_ret)
|
||||
*name_ret = (gss_name_t) name;
|
||||
if (lifetime)
|
||||
*lifetime = min_lifetime;
|
||||
if (cred && cred_usage)
|
||||
*cred_usage = cred->gc_usage;
|
||||
return (GSS_S_COMPLETE);
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_inquire_cred_by_mech.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_inquire_cred_by_mech.c,v 1.2 2006/06/28 09:00:25 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_inquire_cred_by_mech(OM_uint32 *minor_status,
|
||||
const gss_cred_id_t cred_handle,
|
||||
const gss_OID mech_type,
|
||||
gss_name_t *cred_name,
|
||||
OM_uint32 *initiator_lifetime,
|
||||
OM_uint32 *acceptor_lifetime,
|
||||
gss_cred_usage_t *cred_usage)
|
||||
{
|
||||
OM_uint32 major_status;
|
||||
gssapi_mech_interface m;
|
||||
struct _gss_mechanism_cred *mcp;
|
||||
gss_cred_id_t mc;
|
||||
gss_name_t mn;
|
||||
struct _gss_name *name;
|
||||
|
||||
*minor_status = 0;
|
||||
|
||||
m = __gss_get_mechanism(mech_type);
|
||||
if (!m)
|
||||
return (GSS_S_NO_CRED);
|
||||
|
||||
if (cred_handle != GSS_C_NO_CREDENTIAL) {
|
||||
struct _gss_cred *cred = (struct _gss_cred *) cred_handle;
|
||||
SLIST_FOREACH(mcp, &cred->gc_mc, gmc_link)
|
||||
if (mcp->gmc_mech == m)
|
||||
break;
|
||||
if (!mcp)
|
||||
return (GSS_S_NO_CRED);
|
||||
mc = mcp->gmc_cred;
|
||||
} else {
|
||||
mc = GSS_C_NO_CREDENTIAL;
|
||||
}
|
||||
|
||||
major_status = m->gm_inquire_cred_by_mech(minor_status, mc, mech_type,
|
||||
&mn, initiator_lifetime, acceptor_lifetime, cred_usage);
|
||||
if (major_status != GSS_S_COMPLETE)
|
||||
return (major_status);
|
||||
|
||||
name = _gss_make_name(m, mn);
|
||||
if (!name) {
|
||||
m->gm_release_name(minor_status, &mn);
|
||||
return (GSS_S_NO_CRED);
|
||||
}
|
||||
|
||||
*cred_name = (gss_name_t) name;
|
||||
return (GSS_S_COMPLETE);
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 2004, PADL Software Pty Ltd.
|
||||
* 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 PADL Software 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 PADL SOFTWARE 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 PADL SOFTWARE 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"
|
||||
RCSID("$Id: gss_inquire_cred_by_oid.c,v 1.2 2006/06/28 16:20:41 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_inquire_cred_by_oid (OM_uint32 *minor_status,
|
||||
const gss_cred_id_t cred_handle,
|
||||
const gss_OID desired_object,
|
||||
gss_buffer_set_t *data_set)
|
||||
{
|
||||
struct _gss_cred *cred = (struct _gss_cred *) cred_handle;
|
||||
OM_uint32 status = GSS_S_COMPLETE;
|
||||
struct _gss_mechanism_cred *mc;
|
||||
gssapi_mech_interface m;
|
||||
gss_buffer_set_t set = GSS_C_NO_BUFFER_SET;
|
||||
|
||||
*minor_status = 0;
|
||||
|
||||
if (cred == NULL)
|
||||
return GSS_S_NO_CRED;
|
||||
|
||||
SLIST_FOREACH(mc, &cred->gc_mc, gmc_link) {
|
||||
gss_buffer_set_t rset = GSS_C_NO_BUFFER_SET;
|
||||
int i;
|
||||
|
||||
m = mc->gmc_mech;
|
||||
if (m == NULL)
|
||||
return GSS_S_BAD_MECH;
|
||||
|
||||
if (m->gm_inquire_cred_by_oid == NULL)
|
||||
continue;
|
||||
|
||||
status = m->gm_inquire_cred_by_oid(minor_status,
|
||||
mc->gmc_cred, desired_object, &rset);
|
||||
if (status != GSS_S_COMPLETE)
|
||||
continue;
|
||||
|
||||
for (i = 0; i < rset->count; i++) {
|
||||
status = gss_add_buffer_set_member(minor_status,
|
||||
&rset->elements[i], &set);
|
||||
if (status != GSS_S_COMPLETE)
|
||||
break;
|
||||
}
|
||||
gss_release_buffer_set(minor_status, &rset);
|
||||
}
|
||||
if (set == GSS_C_NO_BUFFER_SET)
|
||||
status = GSS_S_FAILURE;
|
||||
*data_set = set;
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_inquire_mechs_for_name.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_inquire_mechs_for_name.c,v 1.3 2006/07/20 02:04:00 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_inquire_mechs_for_name(OM_uint32 *minor_status,
|
||||
const gss_name_t input_name,
|
||||
gss_OID_set *mech_types)
|
||||
{
|
||||
OM_uint32 major_status;
|
||||
struct _gss_name *name = (struct _gss_name *) input_name;
|
||||
struct _gss_mech_switch *m;
|
||||
gss_OID_set name_types;
|
||||
int present;
|
||||
|
||||
*minor_status = 0;
|
||||
|
||||
_gss_load_mech();
|
||||
|
||||
major_status = gss_create_empty_oid_set(minor_status, mech_types);
|
||||
if (major_status)
|
||||
return (major_status);
|
||||
|
||||
/*
|
||||
* We go through all the loaded mechanisms and see if this
|
||||
* name's type is supported by the mechanism. If it is, add
|
||||
* the mechanism to the set.
|
||||
*/
|
||||
SLIST_FOREACH(m, &_gss_mechs, gm_link) {
|
||||
major_status = gss_inquire_names_for_mech(minor_status,
|
||||
&m->gm_mech_oid, &name_types);
|
||||
if (major_status) {
|
||||
gss_release_oid_set(minor_status, mech_types);
|
||||
return (major_status);
|
||||
}
|
||||
gss_test_oid_set_member(minor_status,
|
||||
&name->gn_type, name_types, &present);
|
||||
gss_release_oid_set(minor_status, &name_types);
|
||||
if (present) {
|
||||
major_status = gss_add_oid_set_member(minor_status,
|
||||
&m->gm_mech_oid, mech_types);
|
||||
if (major_status) {
|
||||
gss_release_oid_set(minor_status, mech_types);
|
||||
return (major_status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (GSS_S_COMPLETE);
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_inquire_names_for_mech.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_inquire_names_for_mech.c,v 1.2 2006/06/28 09:00:25 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_inquire_names_for_mech(OM_uint32 *minor_status,
|
||||
const gss_OID mechanism,
|
||||
gss_OID_set *name_types)
|
||||
{
|
||||
OM_uint32 major_status;
|
||||
gssapi_mech_interface m = __gss_get_mechanism(mechanism);
|
||||
|
||||
*minor_status = 0;
|
||||
if (!m)
|
||||
return (GSS_S_BAD_MECH);
|
||||
|
||||
/*
|
||||
* If the implementation can do it, ask it for a list of
|
||||
* names, otherwise fake it.
|
||||
*/
|
||||
if (m->gm_inquire_names_for_mech) {
|
||||
return (m->gm_inquire_names_for_mech(minor_status,
|
||||
mechanism, name_types));
|
||||
} else {
|
||||
major_status = gss_create_empty_oid_set(minor_status,
|
||||
name_types);
|
||||
if (major_status)
|
||||
return (major_status);
|
||||
major_status = gss_add_oid_set_member(minor_status,
|
||||
GSS_C_NT_HOSTBASED_SERVICE, name_types);
|
||||
if (major_status) {
|
||||
OM_uint32 ms;
|
||||
gss_release_oid_set(&ms, name_types);
|
||||
return (major_status);
|
||||
}
|
||||
major_status = gss_add_oid_set_member(minor_status,
|
||||
GSS_C_NT_USER_NAME, name_types);
|
||||
if (major_status) {
|
||||
OM_uint32 ms;
|
||||
gss_release_oid_set(&ms, name_types);
|
||||
return (major_status);
|
||||
}
|
||||
}
|
||||
|
||||
return (GSS_S_COMPLETE);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2004, PADL Software Pty Ltd.
|
||||
* 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 PADL Software 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 PADL SOFTWARE 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 PADL SOFTWARE 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"
|
||||
RCSID("$Id: gss_inquire_sec_context_by_oid.c,v 1.1 2006/06/28 09:07:08 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_inquire_sec_context_by_oid (OM_uint32 *minor_status,
|
||||
const gss_ctx_id_t context_handle,
|
||||
const gss_OID desired_object,
|
||||
gss_buffer_set_t *data_set)
|
||||
{
|
||||
struct _gss_context *ctx = (struct _gss_context *) context_handle;
|
||||
OM_uint32 major_status;
|
||||
gssapi_mech_interface m;
|
||||
|
||||
*minor_status = 0;
|
||||
|
||||
if (ctx == NULL)
|
||||
return GSS_S_NO_CONTEXT;
|
||||
|
||||
/*
|
||||
* select the approprate underlying mechanism routine and
|
||||
* call it.
|
||||
*/
|
||||
|
||||
m = ctx->gc_mech;
|
||||
|
||||
if (m == NULL)
|
||||
return GSS_S_BAD_MECH;
|
||||
|
||||
if (m->gm_inquire_sec_context_by_oid != NULL)
|
||||
major_status = m->gm_inquire_sec_context_by_oid(minor_status,
|
||||
ctx->gc_ctx, desired_object, data_set);
|
||||
else
|
||||
major_status = GSS_S_BAD_MECH;
|
||||
|
||||
return major_status;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,777 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_krb5.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_krb5.c,v 1.21 2006/11/10 00:57:27 lha Exp $");
|
||||
|
||||
#include <krb5.h>
|
||||
#include <roken.h>
|
||||
|
||||
|
||||
OM_uint32
|
||||
gss_krb5_copy_ccache(OM_uint32 *minor_status,
|
||||
gss_cred_id_t cred,
|
||||
krb5_ccache out)
|
||||
{
|
||||
gss_buffer_set_t data_set = GSS_C_NO_BUFFER_SET;
|
||||
krb5_context context;
|
||||
krb5_error_code kret;
|
||||
krb5_ccache id;
|
||||
OM_uint32 ret;
|
||||
char *str;
|
||||
|
||||
ret = gss_inquire_cred_by_oid(minor_status,
|
||||
cred,
|
||||
GSS_KRB5_COPY_CCACHE_X,
|
||||
&data_set);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (data_set == GSS_C_NO_BUFFER_SET || data_set->count != 1) {
|
||||
gss_release_buffer_set(minor_status, &data_set);
|
||||
*minor_status = EINVAL;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
kret = krb5_init_context(&context);
|
||||
if (kret) {
|
||||
*minor_status = kret;
|
||||
gss_release_buffer_set(minor_status, &data_set);
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
kret = asprintf(&str, "%.*s", (int)data_set->elements[0].length,
|
||||
(char *)data_set->elements[0].value);
|
||||
gss_release_buffer_set(minor_status, &data_set);
|
||||
if (kret == -1) {
|
||||
*minor_status = ENOMEM;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
kret = krb5_cc_resolve(context, str, &id);
|
||||
free(str);
|
||||
if (kret) {
|
||||
*minor_status = kret;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
kret = krb5_cc_copy_cache(context, id, out);
|
||||
krb5_cc_close(context, id);
|
||||
krb5_free_context(context);
|
||||
if (kret) {
|
||||
*minor_status = kret;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
OM_uint32
|
||||
gss_krb5_import_cred(OM_uint32 *minor_status,
|
||||
krb5_ccache id,
|
||||
krb5_principal keytab_principal,
|
||||
krb5_keytab keytab,
|
||||
gss_cred_id_t *cred)
|
||||
{
|
||||
gss_buffer_desc buffer;
|
||||
OM_uint32 major_status;
|
||||
krb5_context context;
|
||||
krb5_error_code ret;
|
||||
krb5_storage *sp;
|
||||
krb5_data data;
|
||||
char *str;
|
||||
|
||||
*cred = GSS_C_NO_CREDENTIAL;
|
||||
|
||||
ret = krb5_init_context(&context);
|
||||
if (ret) {
|
||||
*minor_status = ret;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
sp = krb5_storage_emem();
|
||||
if (sp == NULL) {
|
||||
*minor_status = ENOMEM;
|
||||
major_status = GSS_S_FAILURE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (id) {
|
||||
ret = krb5_cc_get_full_name(context, id, &str);
|
||||
if (ret == 0) {
|
||||
ret = krb5_store_string(sp, str);
|
||||
free(str);
|
||||
}
|
||||
} else
|
||||
ret = krb5_store_string(sp, "");
|
||||
if (ret) {
|
||||
*minor_status = ret;
|
||||
major_status = GSS_S_FAILURE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (keytab_principal) {
|
||||
ret = krb5_unparse_name(context, keytab_principal, &str);
|
||||
if (ret == 0) {
|
||||
ret = krb5_store_string(sp, str);
|
||||
free(str);
|
||||
}
|
||||
} else
|
||||
krb5_store_string(sp, "");
|
||||
if (ret) {
|
||||
*minor_status = ret;
|
||||
major_status = GSS_S_FAILURE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
if (keytab) {
|
||||
ret = krb5_kt_get_full_name(context, keytab, &str);
|
||||
if (ret == 0) {
|
||||
ret = krb5_store_string(sp, str);
|
||||
free(str);
|
||||
}
|
||||
} else
|
||||
krb5_store_string(sp, "");
|
||||
if (ret) {
|
||||
*minor_status = ret;
|
||||
major_status = GSS_S_FAILURE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
krb5_storage_to_data(sp, &data);
|
||||
|
||||
buffer.value = data.data;
|
||||
buffer.length = data.length;
|
||||
|
||||
major_status = gss_set_cred_option(minor_status,
|
||||
cred,
|
||||
GSS_KRB5_IMPORT_CRED_X,
|
||||
&buffer);
|
||||
krb5_data_free(&data);
|
||||
out:
|
||||
if (sp)
|
||||
krb5_storage_free(sp);
|
||||
krb5_free_context(context);
|
||||
return major_status;
|
||||
}
|
||||
|
||||
OM_uint32
|
||||
gsskrb5_register_acceptor_identity(const char *identity)
|
||||
{
|
||||
struct _gss_mech_switch *m;
|
||||
gss_buffer_desc buffer;
|
||||
OM_uint32 junk;
|
||||
|
||||
_gss_load_mech();
|
||||
|
||||
buffer.value = rk_UNCONST(identity);
|
||||
buffer.length = strlen(identity);
|
||||
|
||||
SLIST_FOREACH(m, &_gss_mechs, gm_link) {
|
||||
if (m->gm_mech.gm_set_sec_context_option == NULL)
|
||||
continue;
|
||||
m->gm_mech.gm_set_sec_context_option(&junk, NULL,
|
||||
GSS_KRB5_REGISTER_ACCEPTOR_IDENTITY_X, &buffer);
|
||||
}
|
||||
|
||||
return (GSS_S_COMPLETE);
|
||||
}
|
||||
|
||||
OM_uint32
|
||||
gsskrb5_set_dns_canonicalize(int flag)
|
||||
{
|
||||
struct _gss_mech_switch *m;
|
||||
gss_buffer_desc buffer;
|
||||
OM_uint32 junk;
|
||||
char b = (flag != 0);
|
||||
|
||||
_gss_load_mech();
|
||||
|
||||
buffer.value = &b;
|
||||
buffer.length = sizeof(b);
|
||||
|
||||
SLIST_FOREACH(m, &_gss_mechs, gm_link) {
|
||||
if (m->gm_mech.gm_set_sec_context_option == NULL)
|
||||
continue;
|
||||
m->gm_mech.gm_set_sec_context_option(&junk, NULL,
|
||||
GSS_KRB5_SET_DNS_CANONICALIZE_X, &buffer);
|
||||
}
|
||||
|
||||
return (GSS_S_COMPLETE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static krb5_error_code
|
||||
set_key(krb5_keyblock *keyblock, gss_krb5_lucid_key_t *key)
|
||||
{
|
||||
key->type = keyblock->keytype;
|
||||
key->length = keyblock->keyvalue.length;
|
||||
key->data = malloc(key->length);
|
||||
if (key->data == NULL && key->length != 0)
|
||||
return ENOMEM;
|
||||
memcpy(key->data, keyblock->keyvalue.data, key->length);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
free_key(gss_krb5_lucid_key_t *key)
|
||||
{
|
||||
memset(key->data, 0, key->length);
|
||||
free(key->data);
|
||||
memset(key, 0, sizeof(*key));
|
||||
}
|
||||
|
||||
|
||||
OM_uint32
|
||||
gss_krb5_export_lucid_sec_context(OM_uint32 *minor_status,
|
||||
gss_ctx_id_t *context_handle,
|
||||
OM_uint32 version,
|
||||
void **rctx)
|
||||
{
|
||||
krb5_context context = NULL;
|
||||
krb5_error_code ret;
|
||||
gss_buffer_set_t data_set = GSS_C_NO_BUFFER_SET;
|
||||
OM_uint32 major_status;
|
||||
gss_krb5_lucid_context_v1_t *ctx = NULL;
|
||||
krb5_storage *sp = NULL;
|
||||
uint32_t num;
|
||||
|
||||
if (context_handle == NULL
|
||||
|| *context_handle == GSS_C_NO_CONTEXT
|
||||
|| version != 1)
|
||||
{
|
||||
ret = EINVAL;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
major_status =
|
||||
gss_inquire_sec_context_by_oid (minor_status,
|
||||
*context_handle,
|
||||
GSS_KRB5_EXPORT_LUCID_CONTEXT_V1_X,
|
||||
&data_set);
|
||||
if (major_status)
|
||||
return major_status;
|
||||
|
||||
if (data_set == GSS_C_NO_BUFFER_SET || data_set->count != 1) {
|
||||
gss_release_buffer_set(minor_status, &data_set);
|
||||
*minor_status = EINVAL;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
ret = krb5_init_context(&context);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
ctx = calloc(1, sizeof(*ctx));
|
||||
if (ctx == NULL) {
|
||||
ret = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
sp = krb5_storage_from_mem(data_set->elements[0].value,
|
||||
data_set->elements[0].length);
|
||||
if (sp == NULL) {
|
||||
ret = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = krb5_ret_uint32(sp, &num);
|
||||
if (ret) goto out;
|
||||
if (num != 1) {
|
||||
ret = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
ctx->version = 1;
|
||||
/* initiator */
|
||||
ret = krb5_ret_uint32(sp, &ctx->initiate);
|
||||
if (ret) goto out;
|
||||
/* endtime */
|
||||
ret = krb5_ret_uint32(sp, &ctx->endtime);
|
||||
if (ret) goto out;
|
||||
/* send_seq */
|
||||
ret = krb5_ret_uint32(sp, &num);
|
||||
if (ret) goto out;
|
||||
ctx->send_seq = ((uint64_t)num) << 32;
|
||||
ret = krb5_ret_uint32(sp, &num);
|
||||
if (ret) goto out;
|
||||
ctx->send_seq |= num;
|
||||
/* recv_seq */
|
||||
ret = krb5_ret_uint32(sp, &num);
|
||||
if (ret) goto out;
|
||||
ctx->recv_seq = ((uint64_t)num) << 32;
|
||||
ret = krb5_ret_uint32(sp, &num);
|
||||
if (ret) goto out;
|
||||
ctx->recv_seq |= num;
|
||||
/* protocol */
|
||||
ret = krb5_ret_uint32(sp, &ctx->protocol);
|
||||
if (ret) goto out;
|
||||
if (ctx->protocol == 0) {
|
||||
krb5_keyblock key;
|
||||
|
||||
/* sign_alg */
|
||||
ret = krb5_ret_uint32(sp, &ctx->rfc1964_kd.sign_alg);
|
||||
if (ret) goto out;
|
||||
/* seal_alg */
|
||||
ret = krb5_ret_uint32(sp, &ctx->rfc1964_kd.seal_alg);
|
||||
if (ret) goto out;
|
||||
/* ctx_key */
|
||||
ret = krb5_ret_keyblock(sp, &key);
|
||||
if (ret) goto out;
|
||||
ret = set_key(&key, &ctx->rfc1964_kd.ctx_key);
|
||||
krb5_free_keyblock_contents(context, &key);
|
||||
if (ret) goto out;
|
||||
} else if (ctx->protocol == 1) {
|
||||
krb5_keyblock key;
|
||||
|
||||
/* acceptor_subkey */
|
||||
ret = krb5_ret_uint32(sp, &ctx->cfx_kd.have_acceptor_subkey);
|
||||
if (ret) goto out;
|
||||
/* ctx_key */
|
||||
ret = krb5_ret_keyblock(sp, &key);
|
||||
if (ret) goto out;
|
||||
ret = set_key(&key, &ctx->cfx_kd.ctx_key);
|
||||
krb5_free_keyblock_contents(context, &key);
|
||||
if (ret) goto out;
|
||||
/* acceptor_subkey */
|
||||
if (ctx->cfx_kd.have_acceptor_subkey) {
|
||||
ret = krb5_ret_keyblock(sp, &key);
|
||||
if (ret) goto out;
|
||||
ret = set_key(&key, &ctx->cfx_kd.acceptor_subkey);
|
||||
krb5_free_keyblock_contents(context, &key);
|
||||
if (ret) goto out;
|
||||
}
|
||||
} else {
|
||||
ret = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
*rctx = ctx;
|
||||
|
||||
out:
|
||||
gss_release_buffer_set(minor_status, &data_set);
|
||||
if (sp)
|
||||
krb5_storage_free(sp);
|
||||
if (context)
|
||||
krb5_free_context(context);
|
||||
|
||||
if (ret) {
|
||||
if (ctx)
|
||||
gss_krb5_free_lucid_sec_context(NULL, ctx);
|
||||
|
||||
*minor_status = ret;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
*minor_status = 0;
|
||||
return GSS_S_COMPLETE;
|
||||
}
|
||||
|
||||
OM_uint32
|
||||
gss_krb5_free_lucid_sec_context(OM_uint32 *minor_status, void *c)
|
||||
{
|
||||
gss_krb5_lucid_context_v1_t *ctx = c;
|
||||
|
||||
if (ctx->version != 1) {
|
||||
if (minor_status)
|
||||
*minor_status = 0;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
if (ctx->protocol == 0) {
|
||||
free_key(&ctx->rfc1964_kd.ctx_key);
|
||||
} else if (ctx->protocol == 1) {
|
||||
free_key(&ctx->cfx_kd.ctx_key);
|
||||
if (ctx->cfx_kd.have_acceptor_subkey)
|
||||
free_key(&ctx->cfx_kd.acceptor_subkey);
|
||||
}
|
||||
free(ctx);
|
||||
if (minor_status)
|
||||
*minor_status = 0;
|
||||
return GSS_S_COMPLETE;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
OM_uint32
|
||||
gss_krb5_set_allowable_enctypes(OM_uint32 *min_status,
|
||||
gss_cred_id_t cred,
|
||||
OM_uint32 num_enctypes,
|
||||
int32_t *enctypes)
|
||||
{
|
||||
OM_uint32 maj_status;
|
||||
gss_buffer_desc buffer;
|
||||
krb5_storage *sp;
|
||||
krb5_data data;
|
||||
|
||||
sp = krb5_storage_emem();
|
||||
if (sp == NULL) {
|
||||
*min_status = ENOMEM;
|
||||
maj_status = GSS_S_FAILURE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
while(*enctypes) {
|
||||
krb5_store_int32(sp, *enctypes);
|
||||
enctypes++;
|
||||
}
|
||||
|
||||
krb5_storage_to_data(sp, &data);
|
||||
|
||||
buffer.value = data.data;
|
||||
buffer.length = data.length;
|
||||
|
||||
maj_status = gss_set_cred_option(min_status,
|
||||
&cred,
|
||||
GSS_KRB5_SET_ALLOWABLE_ENCTYPES_X,
|
||||
&buffer);
|
||||
out:
|
||||
if (sp)
|
||||
krb5_storage_free(sp);
|
||||
return maj_status;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
OM_uint32
|
||||
gsskrb5_set_send_to_kdc(struct gsskrb5_send_to_kdc *c)
|
||||
{
|
||||
struct _gss_mech_switch *m;
|
||||
gss_buffer_desc buffer;
|
||||
OM_uint32 junk;
|
||||
|
||||
_gss_load_mech();
|
||||
|
||||
if (c) {
|
||||
buffer.value = c;
|
||||
buffer.length = sizeof(*c);
|
||||
} else {
|
||||
buffer.value = NULL;
|
||||
buffer.length = 0;
|
||||
}
|
||||
|
||||
SLIST_FOREACH(m, &_gss_mechs, gm_link) {
|
||||
if (m->gm_mech.gm_set_sec_context_option == NULL)
|
||||
continue;
|
||||
m->gm_mech.gm_set_sec_context_option(&junk, NULL,
|
||||
GSS_KRB5_SEND_TO_KDC_X, &buffer);
|
||||
}
|
||||
|
||||
return (GSS_S_COMPLETE);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
OM_uint32
|
||||
gsskrb5_extract_authtime_from_sec_context(OM_uint32 *minor_status,
|
||||
gss_ctx_id_t context_handle,
|
||||
time_t *authtime)
|
||||
{
|
||||
gss_buffer_set_t data_set = GSS_C_NO_BUFFER_SET;
|
||||
OM_uint32 maj_stat;
|
||||
|
||||
if (context_handle == GSS_C_NO_CONTEXT) {
|
||||
*minor_status = EINVAL;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
maj_stat =
|
||||
gss_inquire_sec_context_by_oid (minor_status,
|
||||
context_handle,
|
||||
GSS_KRB5_GET_AUTHTIME_X,
|
||||
&data_set);
|
||||
if (maj_stat)
|
||||
return maj_stat;
|
||||
|
||||
if (data_set == GSS_C_NO_BUFFER_SET) {
|
||||
gss_release_buffer_set(minor_status, &data_set);
|
||||
*minor_status = EINVAL;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
if (data_set->count != 1) {
|
||||
gss_release_buffer_set(minor_status, &data_set);
|
||||
*minor_status = EINVAL;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
if (data_set->elements[0].length != 4) {
|
||||
gss_release_buffer_set(minor_status, &data_set);
|
||||
*minor_status = EINVAL;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
{
|
||||
unsigned char *buf = data_set->elements[0].value;
|
||||
*authtime = (buf[3] <<24) | (buf[2] << 16) |
|
||||
(buf[1] << 8) | (buf[0] << 0);
|
||||
}
|
||||
|
||||
gss_release_buffer_set(minor_status, &data_set);
|
||||
|
||||
*minor_status = 0;
|
||||
return GSS_S_COMPLETE;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
OM_uint32
|
||||
gsskrb5_extract_authz_data_from_sec_context(OM_uint32 *minor_status,
|
||||
gss_ctx_id_t context_handle,
|
||||
int ad_type,
|
||||
gss_buffer_t ad_data)
|
||||
{
|
||||
gss_buffer_set_t data_set = GSS_C_NO_BUFFER_SET;
|
||||
OM_uint32 maj_stat;
|
||||
gss_OID_desc oid_flat;
|
||||
heim_oid baseoid, oid;
|
||||
size_t size;
|
||||
|
||||
if (context_handle == GSS_C_NO_CONTEXT) {
|
||||
*minor_status = EINVAL;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
/* All this to append an integer to an oid... */
|
||||
|
||||
if (der_get_oid(GSS_KRB5_EXTRACT_AUTHZ_DATA_FROM_SEC_CONTEXT_X->elements,
|
||||
GSS_KRB5_EXTRACT_AUTHZ_DATA_FROM_SEC_CONTEXT_X->length,
|
||||
&baseoid, NULL) != 0) {
|
||||
*minor_status = EINVAL;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
oid.length = baseoid.length + 1;
|
||||
oid.components = calloc(oid.length, sizeof(*oid.components));
|
||||
if (oid.components == NULL) {
|
||||
der_free_oid(&baseoid);
|
||||
|
||||
*minor_status = ENOMEM;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
memcpy(oid.components, baseoid.components,
|
||||
baseoid.length * sizeof(*baseoid.components));
|
||||
|
||||
der_free_oid(&baseoid);
|
||||
|
||||
oid.components[oid.length - 1] = ad_type;
|
||||
|
||||
oid_flat.length = der_length_oid(&oid);
|
||||
oid_flat.elements = malloc(oid_flat.length);
|
||||
if (oid_flat.elements == NULL) {
|
||||
free(oid.components);
|
||||
*minor_status = ENOMEM;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
if (der_put_oid((unsigned char *)oid_flat.elements + oid_flat.length - 1,
|
||||
oid_flat.length, &oid, &size) != 0) {
|
||||
free(oid.components);
|
||||
|
||||
*minor_status = EINVAL;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
if (oid_flat.length != size)
|
||||
abort();
|
||||
|
||||
free(oid.components);
|
||||
|
||||
/* FINALLY, we have the OID */
|
||||
|
||||
maj_stat = gss_inquire_sec_context_by_oid (minor_status,
|
||||
context_handle,
|
||||
&oid_flat,
|
||||
&data_set);
|
||||
|
||||
free(oid_flat.elements);
|
||||
|
||||
if (maj_stat)
|
||||
return maj_stat;
|
||||
|
||||
if (data_set == GSS_C_NO_BUFFER_SET || data_set->count != 1) {
|
||||
gss_release_buffer_set(minor_status, &data_set);
|
||||
*minor_status = EINVAL;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
ad_data->value = malloc(data_set->elements[0].length);
|
||||
if (ad_data->value == NULL) {
|
||||
gss_release_buffer_set(minor_status, &data_set);
|
||||
*minor_status = ENOMEM;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
ad_data->length = data_set->elements[0].length;
|
||||
memcpy(ad_data->value, data_set->elements[0].value, ad_data->length);
|
||||
gss_release_buffer_set(minor_status, &data_set);
|
||||
|
||||
*minor_status = 0;
|
||||
return GSS_S_COMPLETE;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
static OM_uint32
|
||||
gsskrb5_extract_key(OM_uint32 *minor_status,
|
||||
gss_ctx_id_t context_handle,
|
||||
const gss_OID oid,
|
||||
krb5_keyblock **keyblock)
|
||||
{
|
||||
krb5_error_code ret;
|
||||
gss_buffer_set_t data_set = GSS_C_NO_BUFFER_SET;
|
||||
OM_uint32 major_status;
|
||||
krb5_context context = NULL;
|
||||
krb5_storage *sp = NULL;
|
||||
|
||||
if (context_handle == GSS_C_NO_CONTEXT) {
|
||||
ret = EINVAL;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
ret = krb5_init_context(&context);
|
||||
if(ret) {
|
||||
*minor_status = ret;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
major_status =
|
||||
gss_inquire_sec_context_by_oid (minor_status,
|
||||
context_handle,
|
||||
oid,
|
||||
&data_set);
|
||||
if (major_status)
|
||||
return major_status;
|
||||
|
||||
if (data_set == GSS_C_NO_BUFFER_SET || data_set->count != 1) {
|
||||
gss_release_buffer_set(minor_status, &data_set);
|
||||
*minor_status = EINVAL;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
sp = krb5_storage_from_mem(data_set->elements[0].value,
|
||||
data_set->elements[0].length);
|
||||
if (sp == NULL) {
|
||||
ret = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
*keyblock = calloc(1, sizeof(**keyblock));
|
||||
if (keyblock == NULL) {
|
||||
ret = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = krb5_ret_keyblock(sp, *keyblock);
|
||||
|
||||
out:
|
||||
gss_release_buffer_set(minor_status, &data_set);
|
||||
if (sp)
|
||||
krb5_storage_free(sp);
|
||||
if (ret && keyblock) {
|
||||
krb5_free_keyblock(context, *keyblock);
|
||||
*keyblock = NULL;
|
||||
}
|
||||
if (context)
|
||||
krb5_free_context(context);
|
||||
|
||||
*minor_status = ret;
|
||||
if (ret)
|
||||
return GSS_S_FAILURE;
|
||||
|
||||
return GSS_S_COMPLETE;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
OM_uint32
|
||||
gsskrb5_extract_service_keyblock(OM_uint32 *minor_status,
|
||||
gss_ctx_id_t context_handle,
|
||||
krb5_keyblock **keyblock)
|
||||
{
|
||||
return gsskrb5_extract_key(minor_status,
|
||||
context_handle,
|
||||
GSS_KRB5_GET_SERVICE_KEYBLOCK_X,
|
||||
keyblock);
|
||||
}
|
||||
|
||||
OM_uint32
|
||||
gsskrb5_get_initiator_subkey(OM_uint32 *minor_status,
|
||||
gss_ctx_id_t context_handle,
|
||||
krb5_keyblock **keyblock)
|
||||
{
|
||||
return gsskrb5_extract_key(minor_status,
|
||||
context_handle,
|
||||
GSS_KRB5_GET_INITIATOR_SUBKEY_X,
|
||||
keyblock);
|
||||
}
|
||||
|
||||
OM_uint32
|
||||
gsskrb5_get_subkey(OM_uint32 *minor_status,
|
||||
gss_ctx_id_t context_handle,
|
||||
krb5_keyblock **keyblock)
|
||||
{
|
||||
return gsskrb5_extract_key(minor_status,
|
||||
context_handle,
|
||||
GSS_KRB5_GET_SUBKEY_X,
|
||||
keyblock);
|
||||
}
|
||||
|
||||
OM_uint32
|
||||
gsskrb5_set_default_realm(const char *realm)
|
||||
{
|
||||
struct _gss_mech_switch *m;
|
||||
gss_buffer_desc buffer;
|
||||
OM_uint32 junk;
|
||||
|
||||
_gss_load_mech();
|
||||
|
||||
buffer.value = rk_UNCONST(realm);
|
||||
buffer.length = strlen(realm);
|
||||
|
||||
SLIST_FOREACH(m, &_gss_mechs, gm_link) {
|
||||
if (m->gm_mech.gm_set_sec_context_option == NULL)
|
||||
continue;
|
||||
m->gm_mech.gm_set_sec_context_option(&junk, NULL,
|
||||
GSS_KRB5_SET_DEFAULT_REALM_X, &buffer);
|
||||
}
|
||||
|
||||
return (GSS_S_COMPLETE);
|
||||
}
|
||||
@@ -0,0 +1,324 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_mech_switch.c,v 1.2 2006/02/04 09:40:21 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
#include <heim_threads.h>
|
||||
RCSID("$Id: gss_mech_switch.c,v 1.7 2006/10/09 11:13:30 lha Exp $");
|
||||
|
||||
#ifndef _PATH_GSS_MECH
|
||||
#define _PATH_GSS_MECH "/etc/gss/mech"
|
||||
#endif
|
||||
|
||||
struct _gss_mech_switch_list _gss_mechs = { NULL } ;
|
||||
gss_OID_set _gss_mech_oids;
|
||||
static HEIMDAL_MUTEX _gss_mech_mutex = HEIMDAL_MUTEX_INITIALIZER;
|
||||
|
||||
/*
|
||||
* Convert a string containing an OID in 'dot' form
|
||||
* (e.g. 1.2.840.113554.1.2.2) to a gss_OID.
|
||||
*/
|
||||
static int
|
||||
_gss_string_to_oid(const char* s, gss_OID oid)
|
||||
{
|
||||
int number_count, i, j;
|
||||
int byte_count;
|
||||
const char *p, *q;
|
||||
char *res;
|
||||
|
||||
/*
|
||||
* First figure out how many numbers in the oid, then
|
||||
* calculate the compiled oid size.
|
||||
*/
|
||||
number_count = 0;
|
||||
for (p = s; p; p = q) {
|
||||
q = strchr(p, '.');
|
||||
if (q) q = q + 1;
|
||||
number_count++;
|
||||
}
|
||||
|
||||
/*
|
||||
* The first two numbers are in the first byte and each
|
||||
* subsequent number is encoded in a variable byte sequence.
|
||||
*/
|
||||
if (number_count < 2)
|
||||
return (EINVAL);
|
||||
|
||||
/*
|
||||
* We do this in two passes. The first pass, we just figure
|
||||
* out the size. Second time around, we actually encode the
|
||||
* number.
|
||||
*/
|
||||
res = 0;
|
||||
for (i = 0; i < 2; i++) {
|
||||
byte_count = 0;
|
||||
for (p = s, j = 0; p; p = q, j++) {
|
||||
unsigned int number = 0;
|
||||
|
||||
/*
|
||||
* Find the end of this number.
|
||||
*/
|
||||
q = strchr(p, '.');
|
||||
if (q) q = q + 1;
|
||||
|
||||
/*
|
||||
* Read the number of of the string. Don't
|
||||
* bother with anything except base ten.
|
||||
*/
|
||||
while (*p && *p != '.') {
|
||||
number = 10 * number + (*p - '0');
|
||||
p++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Encode the number. The first two numbers
|
||||
* are packed into the first byte. Subsequent
|
||||
* numbers are encoded in bytes seven bits at
|
||||
* a time with the last byte having the high
|
||||
* bit set.
|
||||
*/
|
||||
if (j == 0) {
|
||||
if (res)
|
||||
*res = number * 40;
|
||||
} else if (j == 1) {
|
||||
if (res) {
|
||||
*res += number;
|
||||
res++;
|
||||
}
|
||||
byte_count++;
|
||||
} else if (j >= 2) {
|
||||
/*
|
||||
* The number is encoded in seven bit chunks.
|
||||
*/
|
||||
unsigned int t;
|
||||
int bytes;
|
||||
|
||||
bytes = 0;
|
||||
for (t = number; t; t >>= 7)
|
||||
bytes++;
|
||||
if (bytes == 0) bytes = 1;
|
||||
while (bytes) {
|
||||
if (res) {
|
||||
int bit = 7*(bytes-1);
|
||||
|
||||
*res = (number >> bit) & 0x7f;
|
||||
if (bytes != 1)
|
||||
*res |= 0x80;
|
||||
res++;
|
||||
}
|
||||
byte_count++;
|
||||
bytes--;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!res) {
|
||||
res = malloc(byte_count);
|
||||
if (!res)
|
||||
return (ENOMEM);
|
||||
oid->length = byte_count;
|
||||
oid->elements = res;
|
||||
}
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
#define SYM(name) \
|
||||
do { \
|
||||
m->gm_mech.gm_ ## name = dlsym(so, "gss_" #name); \
|
||||
if (!m->gm_mech.gm_ ## name) { \
|
||||
fprintf(stderr, "can't find symbol gss_" #name "\n"); \
|
||||
goto bad; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define OPTSYM(name) \
|
||||
do { \
|
||||
m->gm_mech.gm_ ## name = dlsym(so, "gss_" #name); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
static int
|
||||
add_builtin(gssapi_mech_interface mech)
|
||||
{
|
||||
struct _gss_mech_switch *m;
|
||||
OM_uint32 minor_status;
|
||||
|
||||
m = malloc(sizeof(*m));
|
||||
if (m == NULL)
|
||||
return 1;
|
||||
m->gm_so = NULL;
|
||||
m->gm_mech = *mech;
|
||||
m->gm_mech_oid = mech->gm_mech_oid; /* XXX */
|
||||
gss_add_oid_set_member(&minor_status,
|
||||
&m->gm_mech.gm_mech_oid, &_gss_mech_oids);
|
||||
|
||||
SLIST_INSERT_HEAD(&_gss_mechs, m, gm_link);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Load the mechanisms file (/etc/gss/mech).
|
||||
*/
|
||||
void
|
||||
_gss_load_mech(void)
|
||||
{
|
||||
OM_uint32 major_status, minor_status;
|
||||
FILE *fp;
|
||||
char buf[256];
|
||||
char *p;
|
||||
char *name, *oid, *lib, *kobj;
|
||||
struct _gss_mech_switch *m;
|
||||
void *so;
|
||||
|
||||
|
||||
HEIMDAL_MUTEX_lock(&_gss_mech_mutex);
|
||||
|
||||
if (SLIST_FIRST(&_gss_mechs)) {
|
||||
HEIMDAL_MUTEX_unlock(&_gss_mech_mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
major_status = gss_create_empty_oid_set(&minor_status,
|
||||
&_gss_mech_oids);
|
||||
if (major_status) {
|
||||
HEIMDAL_MUTEX_unlock(&_gss_mech_mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
add_builtin(__gss_krb5_initialize());
|
||||
add_builtin(__gss_spnego_initialize());
|
||||
|
||||
fp = fopen(_PATH_GSS_MECH, "r");
|
||||
if (!fp) {
|
||||
/* perror(_PATH_GSS_MECH); */
|
||||
HEIMDAL_MUTEX_unlock(&_gss_mech_mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
while (fgets(buf, sizeof(buf), fp)) {
|
||||
if (*buf == '#')
|
||||
continue;
|
||||
p = buf;
|
||||
name = strsep(&p, "\t\n ");
|
||||
if (p) while (isspace((unsigned char)*p)) p++;
|
||||
oid = strsep(&p, "\t\n ");
|
||||
if (p) while (isspace((unsigned char)*p)) p++;
|
||||
lib = strsep(&p, "\t\n ");
|
||||
if (p) while (isspace((unsigned char)*p)) p++;
|
||||
kobj = strsep(&p, "\t\n ");
|
||||
if (!name || !oid || !lib || !kobj)
|
||||
continue;
|
||||
|
||||
#ifndef RTLD_LOCAL
|
||||
#define RTLD_LOCAL 0
|
||||
#endif
|
||||
|
||||
so = dlopen(lib, RTLD_LOCAL);
|
||||
if (!so) {
|
||||
/* fprintf(stderr, "dlopen: %s\n", dlerror()); */
|
||||
continue;
|
||||
}
|
||||
|
||||
m = malloc(sizeof(*m));
|
||||
if (!m)
|
||||
break;
|
||||
m->gm_so = so;
|
||||
if (_gss_string_to_oid(oid, &m->gm_mech.gm_mech_oid)) {
|
||||
free(m);
|
||||
continue;
|
||||
}
|
||||
|
||||
major_status = gss_add_oid_set_member(&minor_status,
|
||||
&m->gm_mech.gm_mech_oid, &_gss_mech_oids);
|
||||
if (major_status) {
|
||||
free(m->gm_mech.gm_mech_oid.elements);
|
||||
free(m);
|
||||
continue;
|
||||
}
|
||||
|
||||
SYM(acquire_cred);
|
||||
SYM(release_cred);
|
||||
SYM(init_sec_context);
|
||||
SYM(accept_sec_context);
|
||||
SYM(process_context_token);
|
||||
SYM(delete_sec_context);
|
||||
SYM(context_time);
|
||||
SYM(get_mic);
|
||||
SYM(verify_mic);
|
||||
SYM(wrap);
|
||||
SYM(unwrap);
|
||||
SYM(display_status);
|
||||
SYM(indicate_mechs);
|
||||
SYM(compare_name);
|
||||
SYM(display_name);
|
||||
SYM(import_name);
|
||||
SYM(export_name);
|
||||
SYM(release_name);
|
||||
SYM(inquire_cred);
|
||||
SYM(inquire_context);
|
||||
SYM(wrap_size_limit);
|
||||
SYM(add_cred);
|
||||
SYM(inquire_cred_by_mech);
|
||||
SYM(export_sec_context);
|
||||
SYM(import_sec_context);
|
||||
SYM(inquire_names_for_mech);
|
||||
SYM(inquire_mechs_for_name);
|
||||
SYM(canonicalize_name);
|
||||
SYM(duplicate_name);
|
||||
OPTSYM(inquire_cred_by_oid);
|
||||
OPTSYM(inquire_sec_context_by_oid);
|
||||
OPTSYM(set_sec_context_option);
|
||||
OPTSYM(set_cred_option);
|
||||
|
||||
SLIST_INSERT_HEAD(&_gss_mechs, m, gm_link);
|
||||
continue;
|
||||
|
||||
bad:
|
||||
free(m->gm_mech.gm_mech_oid.elements);
|
||||
free(m);
|
||||
dlclose(so);
|
||||
continue;
|
||||
}
|
||||
fclose(fp);
|
||||
HEIMDAL_MUTEX_unlock(&_gss_mech_mutex);
|
||||
}
|
||||
|
||||
gssapi_mech_interface
|
||||
__gss_get_mechanism(gss_OID mech)
|
||||
{
|
||||
struct _gss_mech_switch *m;
|
||||
|
||||
_gss_load_mech();
|
||||
SLIST_FOREACH(m, &_gss_mechs, gm_link) {
|
||||
if (gss_oid_equal(&m->gm_mech.gm_mech_oid, mech))
|
||||
return &m->gm_mech;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_names.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_names.c,v 1.2 2006/06/28 09:00:25 lha Exp $");
|
||||
|
||||
struct _gss_mechanism_name *
|
||||
_gss_find_mn(struct _gss_name *name, gss_OID mech)
|
||||
{
|
||||
OM_uint32 major_status, minor_status;
|
||||
gssapi_mech_interface m;
|
||||
struct _gss_mechanism_name *mn;
|
||||
|
||||
SLIST_FOREACH(mn, &name->gn_mn, gmn_link) {
|
||||
if (gss_oid_equal(mech, mn->gmn_mech_oid))
|
||||
break;
|
||||
}
|
||||
|
||||
if (!mn) {
|
||||
/*
|
||||
* If this name is canonical (i.e. there is only an
|
||||
* MN but it is from a different mech), give up now.
|
||||
*/
|
||||
if (!name->gn_value.value)
|
||||
return (0);
|
||||
|
||||
m = __gss_get_mechanism(mech);
|
||||
if (!m)
|
||||
return (0);
|
||||
|
||||
mn = malloc(sizeof(struct _gss_mechanism_name));
|
||||
if (!mn)
|
||||
return (0);
|
||||
|
||||
major_status = m->gm_import_name(&minor_status,
|
||||
&name->gn_value,
|
||||
(name->gn_type.elements
|
||||
? &name->gn_type : GSS_C_NO_OID),
|
||||
&mn->gmn_name);
|
||||
if (major_status) {
|
||||
free(mn);
|
||||
return (0);
|
||||
}
|
||||
|
||||
mn->gmn_mech = m;
|
||||
mn->gmn_mech_oid = &m->gm_mech_oid;
|
||||
SLIST_INSERT_HEAD(&name->gn_mn, mn, gmn_link);
|
||||
}
|
||||
return (mn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Make a name from an MN.
|
||||
*/
|
||||
struct _gss_name *
|
||||
_gss_make_name(gssapi_mech_interface m, gss_name_t new_mn)
|
||||
{
|
||||
struct _gss_name *name;
|
||||
struct _gss_mechanism_name *mn;
|
||||
|
||||
name = malloc(sizeof(struct _gss_name));
|
||||
if (!name)
|
||||
return (0);
|
||||
memset(name, 0, sizeof(struct _gss_name));
|
||||
|
||||
mn = malloc(sizeof(struct _gss_mechanism_name));
|
||||
if (!mn) {
|
||||
free(name);
|
||||
return (0);
|
||||
}
|
||||
|
||||
SLIST_INIT(&name->gn_mn);
|
||||
mn->gmn_mech = m;
|
||||
mn->gmn_mech_oid = &m->gm_mech_oid;
|
||||
mn->gmn_name = new_mn;
|
||||
SLIST_INSERT_HEAD(&name->gn_mn, mn, gmn_link);
|
||||
|
||||
return (name);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2006 Kungliga Tekniska Högskolan
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* 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"
|
||||
RCSID("$Id: gss_oid_equal.c,v 1.1 2006/06/28 09:07:08 lha Exp $");
|
||||
|
||||
int
|
||||
gss_oid_equal(const gss_OID a, const gss_OID b)
|
||||
{
|
||||
if (a == b)
|
||||
return 1;
|
||||
if (a == GSS_C_NO_OID || b == GSS_C_NO_OID || a->length != b->length)
|
||||
return 0;
|
||||
return memcmp(a->elements, b->elements, a->length) == 0;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_process_context_token.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_process_context_token.c,v 1.2 2006/06/28 09:00:25 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_process_context_token(OM_uint32 *minor_status,
|
||||
const gss_ctx_id_t context_handle,
|
||||
const gss_buffer_t token_buffer)
|
||||
{
|
||||
struct _gss_context *ctx = (struct _gss_context *) context_handle;
|
||||
gssapi_mech_interface m = ctx->gc_mech;
|
||||
|
||||
return (m->gm_process_context_token(minor_status, ctx->gc_ctx,
|
||||
token_buffer));
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_release_buffer.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_release_buffer.c,v 1.2 2006/06/28 09:00:25 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_release_buffer(OM_uint32 *minor_status,
|
||||
gss_buffer_t buffer)
|
||||
{
|
||||
|
||||
*minor_status = 0;
|
||||
if (buffer->value)
|
||||
free(buffer->value);
|
||||
buffer->length = 0;
|
||||
buffer->value = 0;
|
||||
|
||||
return (GSS_S_COMPLETE);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_release_cred.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_release_cred.c,v 1.2 2006/06/28 09:00:25 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_release_cred(OM_uint32 *minor_status, gss_cred_id_t *cred_handle)
|
||||
{
|
||||
struct _gss_cred *cred = (struct _gss_cred *) *cred_handle;
|
||||
struct _gss_mechanism_cred *mc;
|
||||
|
||||
if (*cred_handle == GSS_C_NO_CREDENTIAL)
|
||||
return (GSS_S_COMPLETE);
|
||||
|
||||
while (SLIST_FIRST(&cred->gc_mc)) {
|
||||
mc = SLIST_FIRST(&cred->gc_mc);
|
||||
SLIST_REMOVE_HEAD(&cred->gc_mc, gmc_link);
|
||||
mc->gmc_mech->gm_release_cred(minor_status, &mc->gmc_cred);
|
||||
free(mc);
|
||||
}
|
||||
free(cred);
|
||||
|
||||
*minor_status = 0;
|
||||
*cred_handle = 0;
|
||||
return (GSS_S_COMPLETE);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_release_name.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_release_name.c,v 1.3 2006/10/22 07:59:06 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_release_name(OM_uint32 *minor_status,
|
||||
gss_name_t *input_name)
|
||||
{
|
||||
struct _gss_name *name = (struct _gss_name *) *input_name;
|
||||
|
||||
*minor_status = 0;
|
||||
if (name) {
|
||||
if (name->gn_type.elements)
|
||||
free(name->gn_type.elements);
|
||||
while (SLIST_FIRST(&name->gn_mn)) {
|
||||
struct _gss_mechanism_name *mn;
|
||||
mn = SLIST_FIRST(&name->gn_mn);
|
||||
SLIST_REMOVE_HEAD(&name->gn_mn, gmn_link);
|
||||
mn->gmn_mech->gm_release_name(minor_status,
|
||||
&mn->gmn_name);
|
||||
free(mn);
|
||||
}
|
||||
gss_release_buffer(minor_status, &name->gn_value);
|
||||
free(name);
|
||||
*input_name = GSS_C_NO_NAME;
|
||||
}
|
||||
return (GSS_S_COMPLETE);
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2006 Kungliga Tekniska Högskolan
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* 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"
|
||||
|
||||
RCSID("$Id: gss_release_oid.c,v 1.1 2006/06/30 09:34:54 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_release_oid(OM_uint32 *minor_status, gss_OID *oid)
|
||||
{
|
||||
gss_OID o = *oid;
|
||||
|
||||
*oid = GSS_C_NO_OID;
|
||||
|
||||
if (minor_status != NULL)
|
||||
*minor_status = 0;
|
||||
|
||||
if (o == GSS_C_NO_OID)
|
||||
return GSS_S_COMPLETE;
|
||||
|
||||
if (o->elements != NULL) {
|
||||
free(o->elements);
|
||||
o->elements = NULL;
|
||||
}
|
||||
o->length = 0;
|
||||
free(o);
|
||||
|
||||
return GSS_S_COMPLETE;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_release_oid_set.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_release_oid_set.c,v 1.2 2006/06/28 09:00:25 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_release_oid_set(OM_uint32 *minor_status,
|
||||
gss_OID_set *set)
|
||||
{
|
||||
|
||||
*minor_status = 0;
|
||||
if (*set) {
|
||||
if ((*set)->elements)
|
||||
free((*set)->elements);
|
||||
free(*set);
|
||||
*set = 0;
|
||||
}
|
||||
return (GSS_S_COMPLETE);
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_seal.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_seal.c,v 1.2 2006/06/28 09:00:25 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_seal(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)
|
||||
{
|
||||
|
||||
return (gss_wrap(minor_status,
|
||||
context_handle, conf_req_flag, qop_req,
|
||||
input_message_buffer, conf_state,
|
||||
output_message_buffer));
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (c) 2004, PADL Software Pty Ltd.
|
||||
* 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 PADL Software 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 PADL SOFTWARE 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 PADL SOFTWARE 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"
|
||||
RCSID("$Id: gss_set_cred_option.c,v 1.7 2006/07/01 08:50:49 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_set_cred_option (OM_uint32 *minor_status,
|
||||
gss_cred_id_t *cred_handle,
|
||||
const gss_OID object,
|
||||
const gss_buffer_t value)
|
||||
{
|
||||
struct _gss_cred *cred = (struct _gss_cred *) *cred_handle;
|
||||
OM_uint32 major_status = GSS_S_COMPLETE;
|
||||
struct _gss_mechanism_cred *mc;
|
||||
int one_ok = 0;
|
||||
|
||||
*minor_status = 0;
|
||||
|
||||
_gss_load_mech();
|
||||
|
||||
if (cred == NULL) {
|
||||
struct _gss_mech_switch *m;
|
||||
|
||||
cred = malloc(sizeof(*cred));
|
||||
if (cred == NULL)
|
||||
return GSS_S_FAILURE;
|
||||
|
||||
cred->gc_usage = GSS_C_BOTH; /* XXX */
|
||||
SLIST_INIT(&cred->gc_mc);
|
||||
|
||||
SLIST_FOREACH(m, &_gss_mechs, gm_link) {
|
||||
|
||||
if (m->gm_mech.gm_set_cred_option == NULL)
|
||||
continue;
|
||||
|
||||
mc = malloc(sizeof(*mc));
|
||||
if (mc == NULL) {
|
||||
/* XXX free the other mc's */
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
mc->gmc_mech = &m->gm_mech;
|
||||
mc->gmc_mech_oid = &m->gm_mech_oid;
|
||||
mc->gmc_cred = GSS_C_NO_CREDENTIAL;
|
||||
|
||||
major_status = m->gm_mech.gm_set_cred_option(
|
||||
minor_status, &mc->gmc_cred, object, value);
|
||||
|
||||
if (major_status) {
|
||||
free(mc);
|
||||
continue;
|
||||
}
|
||||
one_ok = 1;
|
||||
SLIST_INSERT_HEAD(&cred->gc_mc, mc, gmc_link);
|
||||
}
|
||||
*cred_handle = (gss_cred_id_t)cred;
|
||||
if (!one_ok) {
|
||||
OM_uint32 junk;
|
||||
gss_release_cred(&junk, cred_handle);
|
||||
}
|
||||
} else {
|
||||
gssapi_mech_interface m;
|
||||
|
||||
SLIST_FOREACH(mc, &cred->gc_mc, gmc_link) {
|
||||
m = mc->gmc_mech;
|
||||
|
||||
if (m == NULL)
|
||||
return GSS_S_BAD_MECH;
|
||||
|
||||
if (m->gm_set_cred_option == NULL)
|
||||
continue;
|
||||
|
||||
major_status = m->gm_set_cred_option(minor_status,
|
||||
&mc->gmc_cred, object, value);
|
||||
if (major_status == GSS_S_BAD_MECH)
|
||||
one_ok = 1;
|
||||
}
|
||||
}
|
||||
if (one_ok) {
|
||||
*minor_status = 0;
|
||||
return GSS_S_COMPLETE;
|
||||
}
|
||||
return major_status;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2004, PADL Software Pty Ltd.
|
||||
* 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 PADL Software 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 PADL SOFTWARE 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 PADL SOFTWARE 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"
|
||||
RCSID("$Id: gss_set_sec_context_option.c,v 1.2 2006/06/28 14:39:00 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_set_sec_context_option (OM_uint32 *minor_status,
|
||||
gss_ctx_id_t *context_handle,
|
||||
const gss_OID object,
|
||||
const gss_buffer_t value)
|
||||
{
|
||||
struct _gss_context *ctx;
|
||||
OM_uint32 major_status;
|
||||
gssapi_mech_interface m;
|
||||
|
||||
*minor_status = 0;
|
||||
|
||||
if (context_handle == NULL)
|
||||
return GSS_S_NO_CONTEXT;
|
||||
|
||||
ctx = (struct _gss_context *) *context_handle;
|
||||
|
||||
if (ctx == NULL)
|
||||
return GSS_S_NO_CONTEXT;
|
||||
|
||||
m = ctx->gc_mech;
|
||||
|
||||
if (m == NULL)
|
||||
return GSS_S_BAD_MECH;
|
||||
|
||||
if (m->gm_set_sec_context_option != NULL)
|
||||
major_status = m->gm_set_sec_context_option(minor_status,
|
||||
&ctx->gc_ctx, object, value);
|
||||
else
|
||||
major_status = GSS_S_BAD_MECH;
|
||||
|
||||
return major_status;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_sign.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_sign.c,v 1.2 2006/06/28 09:00:25 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_sign(OM_uint32 *minor_status,
|
||||
gss_ctx_id_t context_handle,
|
||||
int qop_req,
|
||||
gss_buffer_t message_buffer,
|
||||
gss_buffer_t message_token)
|
||||
{
|
||||
|
||||
return gss_get_mic(minor_status,
|
||||
context_handle, qop_req, message_buffer, message_token);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_test_oid_set_member.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_test_oid_set_member.c,v 1.2 2006/06/28 09:00:25 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_test_oid_set_member(OM_uint32 *minor_status,
|
||||
const gss_OID member,
|
||||
const gss_OID_set set,
|
||||
int *present)
|
||||
{
|
||||
int i;
|
||||
|
||||
*present = 0;
|
||||
for (i = 0; i < set->count; i++)
|
||||
if (gss_oid_equal(member, &set->elements[i]))
|
||||
*present = 1;
|
||||
|
||||
*minor_status = 0;
|
||||
return (GSS_S_COMPLETE);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_unseal.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_unseal.c,v 1.2 2006/06/28 09:00:25 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_unseal(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)
|
||||
{
|
||||
|
||||
return (gss_unwrap(minor_status,
|
||||
context_handle, input_message_buffer,
|
||||
output_message_buffer, conf_state, (gss_qop_t *)qop_state));
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_unwrap.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_unwrap.c,v 1.2 2006/06/28 09:00:25 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_unwrap(OM_uint32 *minor_status,
|
||||
const gss_ctx_id_t context_handle,
|
||||
const gss_buffer_t input_message_buffer,
|
||||
gss_buffer_t output_message_buffer,
|
||||
int *conf_state,
|
||||
gss_qop_t *qop_state)
|
||||
{
|
||||
struct _gss_context *ctx = (struct _gss_context *) context_handle;
|
||||
gssapi_mech_interface m = ctx->gc_mech;
|
||||
|
||||
return (m->gm_unwrap(minor_status, ctx->gc_ctx,
|
||||
input_message_buffer, output_message_buffer,
|
||||
conf_state, qop_state));
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_utils.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_utils.c,v 1.2 2006/06/28 09:00:25 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
_gss_copy_oid(OM_uint32 *minor_status,
|
||||
const gss_OID from_oid, gss_OID to_oid)
|
||||
{
|
||||
size_t len = from_oid->length;
|
||||
|
||||
*minor_status = 0;
|
||||
to_oid->elements = malloc(len);
|
||||
if (!to_oid->elements) {
|
||||
*minor_status = ENOMEM;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
to_oid->length = len;
|
||||
memcpy(to_oid->elements, from_oid->elements, len);
|
||||
return (GSS_S_COMPLETE);
|
||||
}
|
||||
|
||||
|
||||
OM_uint32
|
||||
_gss_copy_buffer(OM_uint32 *minor_status,
|
||||
const gss_buffer_t from_buf, gss_buffer_t to_buf)
|
||||
{
|
||||
size_t len = from_buf->length;
|
||||
|
||||
*minor_status = 0;
|
||||
to_buf->value = malloc(len);
|
||||
if (!to_buf->value) {
|
||||
*minor_status = ENOMEM;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
to_buf->length = len;
|
||||
memcpy(to_buf->value, from_buf->value, len);
|
||||
return (GSS_S_COMPLETE);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_verify.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_verify.c,v 1.2 2006/06/28 09:00:25 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_verify(OM_uint32 *minor_status,
|
||||
gss_ctx_id_t context_handle,
|
||||
gss_buffer_t message_buffer,
|
||||
gss_buffer_t token_buffer,
|
||||
int *qop_state)
|
||||
{
|
||||
|
||||
return (gss_verify_mic(minor_status,
|
||||
context_handle, message_buffer, token_buffer,
|
||||
(gss_qop_t *)qop_state));
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_verify_mic.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_verify_mic.c,v 1.2 2006/06/28 09:00:25 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_verify_mic(OM_uint32 *minor_status,
|
||||
const gss_ctx_id_t context_handle,
|
||||
const gss_buffer_t message_buffer,
|
||||
const gss_buffer_t token_buffer,
|
||||
gss_qop_t *qop_state)
|
||||
{
|
||||
struct _gss_context *ctx = (struct _gss_context *) context_handle;
|
||||
gssapi_mech_interface m = ctx->gc_mech;
|
||||
|
||||
return (m->gm_verify_mic(minor_status, ctx->gc_ctx,
|
||||
message_buffer, token_buffer, qop_state));
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_wrap.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_wrap.c,v 1.2 2006/06/28 09:00:26 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_wrap(OM_uint32 *minor_status,
|
||||
const gss_ctx_id_t context_handle,
|
||||
int conf_req_flag,
|
||||
gss_qop_t qop_req,
|
||||
const gss_buffer_t input_message_buffer,
|
||||
int *conf_state,
|
||||
gss_buffer_t output_message_buffer)
|
||||
{
|
||||
struct _gss_context *ctx = (struct _gss_context *) context_handle;
|
||||
gssapi_mech_interface m = ctx->gc_mech;
|
||||
|
||||
return (m->gm_wrap(minor_status, ctx->gc_ctx,
|
||||
conf_req_flag, qop_req, input_message_buffer,
|
||||
conf_state, output_message_buffer));
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/gss_wrap_size_limit.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "mech_locl.h"
|
||||
RCSID("$Id: gss_wrap_size_limit.c,v 1.2 2006/06/28 09:00:26 lha Exp $");
|
||||
|
||||
OM_uint32
|
||||
gss_wrap_size_limit(OM_uint32 *minor_status,
|
||||
const 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)
|
||||
{
|
||||
struct _gss_context *ctx = (struct _gss_context *) context_handle;
|
||||
gssapi_mech_interface m = ctx->gc_mech;
|
||||
|
||||
return (m->gm_wrap_size_limit(minor_status, ctx->gc_ctx,
|
||||
conf_req_flag, qop_req, req_output_size, max_input_size));
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
-- $Id: gssapi.asn1,v 1.3 2006/10/18 21:08:19 lha Exp $
|
||||
|
||||
GSS-API DEFINITIONS ::= BEGIN
|
||||
|
||||
IMPORTS heim_any_set FROM heim;
|
||||
|
||||
GSSAPIContextToken ::= [APPLICATION 0] IMPLICIT SEQUENCE {
|
||||
thisMech OBJECT IDENTIFIER,
|
||||
innerContextToken heim_any_set
|
||||
}
|
||||
|
||||
END
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2006 Kungliga Tekniska Högskolan
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* $Id: mech_locl.h,v 1.4 2006/10/07 18:25:27 lha Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <krb5-types.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <gssapi_asn1.h>
|
||||
#include <der.h>
|
||||
|
||||
#include <roken.h>
|
||||
|
||||
#include <gssapi.h>
|
||||
#include <gssapi_mech.h>
|
||||
|
||||
#include "mechqueue.h"
|
||||
|
||||
#include "context.h"
|
||||
#include "cred.h"
|
||||
#include "mech_switch.h"
|
||||
#include "name.h"
|
||||
#include "utils.h"
|
||||
@@ -0,0 +1,42 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/mech_switch.h,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
* $Id: mech_switch.h,v 1.3 2006/10/05 18:31:53 lha Exp $
|
||||
*/
|
||||
|
||||
#include <gssapi_mech.h>
|
||||
|
||||
struct _gss_mech_switch {
|
||||
SLIST_ENTRY(_gss_mech_switch) gm_link;
|
||||
gss_OID_desc gm_mech_oid;
|
||||
void *gm_so;
|
||||
gssapi_mech_interface_desc gm_mech;
|
||||
};
|
||||
SLIST_HEAD(_gss_mech_switch_list, _gss_mech_switch);
|
||||
extern struct _gss_mech_switch_list _gss_mechs;
|
||||
extern gss_OID_set _gss_mech_oids;
|
||||
|
||||
void _gss_load_mech(void);
|
||||
@@ -0,0 +1,101 @@
|
||||
/* $NetBSD: queue.h,v 1.39 2004/04/18 14:25:34 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1991, 1993
|
||||
* The Regents of the University of California. 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 University 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 REGENTS 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 REGENTS 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.
|
||||
*
|
||||
* @(#)queue.h 8.5 (Berkeley) 8/20/94
|
||||
*/
|
||||
|
||||
#ifndef _MECHQUEUE_H_
|
||||
#define _MECHQUEUE_H_
|
||||
|
||||
#ifndef SLIST_HEAD
|
||||
|
||||
/*
|
||||
* Singly-linked List definitions.
|
||||
*/
|
||||
#define SLIST_HEAD(name, type) \
|
||||
struct name { \
|
||||
struct type *slh_first; /* first element */ \
|
||||
}
|
||||
|
||||
#define SLIST_HEAD_INITIALIZER(head) \
|
||||
{ NULL }
|
||||
|
||||
#define SLIST_ENTRY(type) \
|
||||
struct { \
|
||||
struct type *sle_next; /* next element */ \
|
||||
}
|
||||
|
||||
/*
|
||||
* Singly-linked List functions.
|
||||
*/
|
||||
#define SLIST_INIT(head) do { \
|
||||
(head)->slh_first = NULL; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
|
||||
(elm)->field.sle_next = (slistelm)->field.sle_next; \
|
||||
(slistelm)->field.sle_next = (elm); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define SLIST_INSERT_HEAD(head, elm, field) do { \
|
||||
(elm)->field.sle_next = (head)->slh_first; \
|
||||
(head)->slh_first = (elm); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define SLIST_REMOVE_HEAD(head, field) do { \
|
||||
(head)->slh_first = (head)->slh_first->field.sle_next; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define SLIST_REMOVE(head, elm, type, field) do { \
|
||||
if ((head)->slh_first == (elm)) { \
|
||||
SLIST_REMOVE_HEAD((head), field); \
|
||||
} \
|
||||
else { \
|
||||
struct type *curelm = (head)->slh_first; \
|
||||
while(curelm->field.sle_next != (elm)) \
|
||||
curelm = curelm->field.sle_next; \
|
||||
curelm->field.sle_next = \
|
||||
curelm->field.sle_next->field.sle_next; \
|
||||
} \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define SLIST_FOREACH(var, head, field) \
|
||||
for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next)
|
||||
|
||||
/*
|
||||
* Singly-linked List access methods.
|
||||
*/
|
||||
#define SLIST_EMPTY(head) ((head)->slh_first == NULL)
|
||||
#define SLIST_FIRST(head) ((head)->slh_first)
|
||||
#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
|
||||
|
||||
#endif /* SLIST_HEAD */
|
||||
|
||||
#endif /* !_MECHQUEUE_H_ */
|
||||
@@ -0,0 +1,47 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/name.h,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
* $Id: name.h,v 1.4 2006/10/05 18:36:07 lha Exp $
|
||||
*/
|
||||
|
||||
struct _gss_mechanism_name {
|
||||
SLIST_ENTRY(_gss_mechanism_name) gmn_link;
|
||||
gssapi_mech_interface gmn_mech; /* mechanism ops for MN */
|
||||
gss_OID gmn_mech_oid; /* mechanism oid for MN */
|
||||
gss_name_t gmn_name; /* underlying MN */
|
||||
};
|
||||
SLIST_HEAD(_gss_mechanism_name_list, _gss_mechanism_name);
|
||||
|
||||
struct _gss_name {
|
||||
gss_OID_desc gn_type; /* type of name */
|
||||
gss_buffer_desc gn_value; /* value (as imported) */
|
||||
struct _gss_mechanism_name_list gn_mn; /* list of MNs */
|
||||
};
|
||||
|
||||
struct _gss_mechanism_name *
|
||||
_gss_find_mn(struct _gss_name *name, gss_OID mech);
|
||||
struct _gss_name *
|
||||
_gss_make_name(gssapi_mech_interface m, gss_name_t new_mn);
|
||||
@@ -0,0 +1,32 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Doug Rabson
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libgssapi/utils.h,v 1.1 2005/12/29 14:40:20 dfr Exp $
|
||||
* $Id: utils.h,v 1.3 2006/07/20 01:48:25 lha Exp $
|
||||
*/
|
||||
|
||||
OM_uint32 _gss_copy_oid(OM_uint32 *, const gss_OID, gss_OID);
|
||||
OM_uint32 _gss_copy_buffer(OM_uint32 *minor_status,
|
||||
const gss_buffer_t from_buf, gss_buffer_t to_buf);
|
||||
Reference in New Issue
Block a user