Index: head/lib/libgssapi/gss_add_cred.c =================================================================== --- head/lib/libgssapi/gss_add_cred.c (revision 297941) +++ head/lib/libgssapi/gss_add_cred.c (revision 297942) @@ -1,193 +1,193 @@ /*- * 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$ */ #include #include #include #include "mech_switch.h" #include "cred.h" #include "name.h" #include "utils.h" static struct _gss_mechanism_cred * _gss_copy_cred(struct _gss_mechanism_cred *mc) { struct _gss_mechanism_cred *new_mc; struct _gss_mech_switch *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) { _gss_mg_error(m, major_status, minor_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) { _gss_mg_error(m, major_status, minor_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; struct _gss_mech_switch *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; *minor_status = 0; *output_cred_handle = GSS_C_NO_CREDENTIAL; if (initiator_time_rec) *initiator_time_rec = 0; if (acceptor_time_rec) *acceptor_time_rec = 0; if (actual_mechs) *actual_mechs = GSS_C_NO_OID_SET; new_cred = malloc(sizeof(struct _gss_cred)); if (!new_cred) { *minor_status = ENOMEM; return (GSS_S_FAILURE); } 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; + target_mc = NULL; 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) { major_status = _gss_find_mn(minor_status, (struct _gss_name *) desired_name, desired_mech, &mn); if (major_status != GSS_S_COMPLETE) { free(new_cred); return (major_status); } } else { - mn = 0; + mn = NULL; } m = _gss_find_mech_switch(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) { _gss_mg_error(m, major_status, *minor_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); } Index: head/lib/libgssapi/gss_encapsulate_token.c =================================================================== --- head/lib/libgssapi/gss_encapsulate_token.c (revision 297941) +++ head/lib/libgssapi/gss_encapsulate_token.c (revision 297942) @@ -1,131 +1,131 @@ /*- * Copyright (c) 2008 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$ */ #include #include #include #include "utils.h" OM_uint32 gss_encapsulate_token(const gss_buffer_t input_token, gss_OID oid, gss_buffer_t output_token) { unsigned char *p; size_t len, inside_len; size_t a, b; int i; _gss_buffer_zero(output_token); /* * First time around, we calculate the size, second time, we * encode the token. */ - p = 0; + p = NULL; for (i = 0; i < 2; i++) { len = 0; /* * Token starts with [APPLICATION 0] SEQUENCE. */ if (p) *p++ = 0x60; len++; /* * The length embedded in the token is the space * needed for the encapsulated oid plus the length of * the inner token. */ if (oid->length > 127) return (GSS_S_DEFECTIVE_TOKEN); inside_len = 2 + oid->length + input_token->length; /* * Figure out how to encode the length */ if (inside_len < 128) { if (p) *p++ = inside_len; len++; } else { b = 1; if (inside_len >= 0x100) b++; if (inside_len >= 0x10000) b++; if (inside_len >= 0x1000000) b++; if (p) *p++ = b | 0x80; len++; a = inside_len << 8*(4 - b); while (b) { if (p) *p++ = (a >> 24); a <<= 8; len++; b--; } } /* * Encode the OID for the mechanism. Simplify life by * assuming that the OID length is less than 128 bytes. */ if (p) *p++ = 0x06; len++; if (p) *p++ = oid->length; len++; if (p) { memcpy(p, oid->elements, oid->length); p += oid->length; } len += oid->length; if (p) { memcpy(p, input_token->value, input_token->length); p += input_token->length; } len += input_token->length; if (i == 0) { output_token->length = len; output_token->value = malloc(len); if (!output_token->value) return (GSS_S_DEFECTIVE_TOKEN); p = output_token->value; } } return (GSS_S_COMPLETE); } Index: head/lib/libgssapi/gss_get_mic.c =================================================================== --- head/lib/libgssapi/gss_get_mic.c (revision 297941) +++ head/lib/libgssapi/gss_get_mic.c (revision 297942) @@ -1,53 +1,54 @@ /*- * 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$ */ #include #include "mech_switch.h" #include "context.h" #include "utils.h" 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; - struct _gss_mech_switch *m = ctx->gc_mech; + struct _gss_mech_switch *m; _gss_buffer_zero(message_token); if (ctx == NULL) { *minor_status = 0; return (GSS_S_NO_CONTEXT); } + m = ctx->gc_mech; return (m->gm_get_mic(minor_status, ctx->gc_ctx, qop_req, message_buffer, message_token)); } Index: head/lib/libgssapi/gss_inquire_context.c =================================================================== --- head/lib/libgssapi/gss_inquire_context.c (revision 297941) +++ head/lib/libgssapi/gss_inquire_context.c (revision 297942) @@ -1,109 +1,109 @@ /*- * 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$ */ #include #include "mech_switch.h" #include "context.h" #include "name.h" 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; struct _gss_mech_switch *m = ctx->gc_mech; struct _gss_name *name; gss_name_t src_mn, targ_mn; if (locally_initiated) *locally_initiated = 0; if (open) *open = 0; if (lifetime_rec) *lifetime_rec = 0; if (src_name) *src_name = GSS_C_NO_NAME; if (targ_name) *targ_name = GSS_C_NO_NAME; if (mech_type) *mech_type = GSS_C_NO_OID; src_mn = targ_mn = GSS_C_NO_NAME; major_status = m->gm_inquire_context(minor_status, ctx->gc_ctx, src_name ? &src_mn : NULL, targ_name ? &targ_mn : NULL, lifetime_rec, mech_type, ctx_flags, locally_initiated, open); if (major_status != GSS_S_COMPLETE) { _gss_mg_error(m, major_status, *minor_status); return (major_status); } if (src_name) { name = _gss_make_name(m, src_mn); if (!name) { if (mech_type) *mech_type = GSS_C_NO_OID; m->gm_release_name(minor_status, &src_mn); *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) { if (mech_type) *mech_type = GSS_C_NO_OID; if (src_name) gss_release_name(minor_status, src_name); m->gm_release_name(minor_status, &src_mn); - minor_status = 0; + minor_status = NULL; return (GSS_S_FAILURE); } *targ_name = (gss_name_t) name; } return (GSS_S_COMPLETE); } Index: head/lib/libgssapi/gss_mech_switch.c =================================================================== --- head/lib/libgssapi/gss_mech_switch.c (revision 297941) +++ head/lib/libgssapi/gss_mech_switch.c (revision 297942) @@ -1,314 +1,314 @@ /*- * 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$ */ #include #include #include #include #include #include #include #include "mech_switch.h" #include "utils.h" #ifndef _PATH_GSS_MECH #define _PATH_GSS_MECH "/etc/gss/mech" #endif struct _gss_mech_switch_list _gss_mechs = SLIST_HEAD_INITIALIZER(_gss_mechs); gss_OID_set _gss_mech_oids; /* * 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; oid->length = 0; oid->elements = NULL; /* * 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; + res = NULL; 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 { \ snprintf(buf, sizeof(buf), "%s_%s", \ m->gm_name_prefix, #name); \ m->gm_ ## name = dlsym(so, buf); \ if (!m->gm_ ## name) { \ fprintf(stderr, "can't find symbol %s\n", buf); \ goto bad; \ } \ } while (0) #define OPTSYM(name) \ do { \ snprintf(buf, sizeof(buf), "%s_%s", \ m->gm_name_prefix, #name); \ m->gm_ ## name = dlsym(so, buf); \ } while (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; int count; void *so; const char *(*prefix_fn)(void); if (SLIST_FIRST(&_gss_mechs)) return; major_status = gss_create_empty_oid_set(&minor_status, &_gss_mech_oids); if (major_status) return; fp = fopen(_PATH_GSS_MECH, "r"); if (!fp) { perror(_PATH_GSS_MECH); return; } count = 0; while (fgets(buf, sizeof(buf), fp)) { if (*buf == '#') continue; p = buf; name = strsep(&p, "\t\n "); if (p) while (isspace(*p)) p++; oid = strsep(&p, "\t\n "); if (p) while (isspace(*p)) p++; lib = strsep(&p, "\t\n "); if (p) while (isspace(*p)) p++; kobj = strsep(&p, "\t\n "); if (!name || !oid || !lib || !kobj) continue; so = dlopen(lib, RTLD_LOCAL); if (!so) { fprintf(stderr, "dlopen: %s\n", dlerror()); continue; } m = malloc(sizeof(struct _gss_mech_switch)); if (!m) break; m->gm_so = so; if (_gss_string_to_oid(oid, &m->gm_mech_oid)) { free(m); continue; } prefix_fn = (const char *(*)(void)) dlsym(so, "_gss_name_prefix"); if (prefix_fn) m->gm_name_prefix = prefix_fn(); else m->gm_name_prefix = "gss"; major_status = gss_add_oid_set_member(&minor_status, &m->gm_mech_oid, &_gss_mech_oids); if (major_status) { free(m->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); OPTSYM(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_sec_context_by_oid); OPTSYM(inquire_cred_by_oid); OPTSYM(set_sec_context_option); OPTSYM(set_cred_option); OPTSYM(pseudo_random); OPTSYM(pname_to_uid); SLIST_INSERT_HEAD(&_gss_mechs, m, gm_link); count++; continue; bad: free(m->gm_mech_oid.elements); free(m); dlclose(so); continue; } fclose(fp); } struct _gss_mech_switch * _gss_find_mech_switch(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_oid, mech)) return m; } return (0); } Index: head/lib/libgssapi/gss_pseudo_random.c =================================================================== --- head/lib/libgssapi/gss_pseudo_random.c (revision 297941) +++ head/lib/libgssapi/gss_pseudo_random.c (revision 297942) @@ -1,72 +1,73 @@ /*- * Copyright (c) 2007 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. */ /* $FreeBSD$ */ /* $Id: gss_pseudo_random.c 20053 2007-01-24 01:31:35Z lha $ */ #include #include "mech_switch.h" #include "context.h" #include "utils.h" OM_uint32 gss_pseudo_random(OM_uint32 *minor_status, gss_ctx_id_t context, int prf_key, const gss_buffer_t prf_in, ssize_t desired_output_len, gss_buffer_t prf_out) { struct _gss_context *ctx = (struct _gss_context *) context; - struct _gss_mech_switch *m = ctx->gc_mech; + struct _gss_mech_switch *m; OM_uint32 major_status; _gss_buffer_zero(prf_out); *minor_status = 0; if (ctx == NULL) { *minor_status = 0; return GSS_S_NO_CONTEXT; } + m = ctx->gc_mech; if (m->gm_pseudo_random == NULL) return GSS_S_UNAVAILABLE; major_status = (*m->gm_pseudo_random)(minor_status, ctx->gc_ctx, prf_key, prf_in, desired_output_len, prf_out); if (major_status != GSS_S_COMPLETE) _gss_mg_error(m, major_status, *minor_status); return major_status; } Index: head/lib/libgssapi/gss_verify_mic.c =================================================================== --- head/lib/libgssapi/gss_verify_mic.c (revision 297941) +++ head/lib/libgssapi/gss_verify_mic.c (revision 297942) @@ -1,53 +1,54 @@ /*- * 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$ */ #include #include "mech_switch.h" #include "context.h" 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; - struct _gss_mech_switch *m = ctx->gc_mech; + struct _gss_mech_switch *m; if (qop_state) *qop_state = 0; if (ctx == NULL) { *minor_status = 0; return (GSS_S_NO_CONTEXT); } + m = ctx->gc_mech; return (m->gm_verify_mic(minor_status, ctx->gc_ctx, message_buffer, token_buffer, qop_state)); } Index: head/lib/libgssapi/gss_wrap.c =================================================================== --- head/lib/libgssapi/gss_wrap.c (revision 297941) +++ head/lib/libgssapi/gss_wrap.c (revision 297942) @@ -1,58 +1,59 @@ /*- * 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$ */ #include #include "mech_switch.h" #include "context.h" #include "utils.h" 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; - struct _gss_mech_switch *m = ctx->gc_mech; + struct _gss_mech_switch *m; if (conf_state) *conf_state = 0; _gss_buffer_zero(output_message_buffer); if (ctx == NULL) { *minor_status = 0; return (GSS_S_NO_CONTEXT); } + 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)); } Index: head/lib/libgssapi/gss_wrap_size_limit.c =================================================================== --- head/lib/libgssapi/gss_wrap_size_limit.c (revision 297941) +++ head/lib/libgssapi/gss_wrap_size_limit.c (revision 297942) @@ -1,53 +1,54 @@ /*- * 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$ */ #include #include "mech_switch.h" #include "context.h" 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; - struct _gss_mech_switch *m = ctx->gc_mech; + struct _gss_mech_switch *m; *max_input_size = 0; if (ctx == NULL) { *minor_status = 0; return (GSS_S_NO_CONTEXT); } + 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)); }