ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * Copyright 1995 by the Massachusetts Institute of Technology.
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * All Rights Reserved.
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * Export of this software from the United States of America may
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * require a specific license from the United States Government.
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * It is the responsibility of any person or organization contemplating
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * export to obtain such a license before exporting.
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * distribute this software and its documentation for any purpose and
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * without fee is hereby granted, provided that the above copyright
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * notice appear in all copies and that both that copyright notice and
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * this permission notice appear in supporting documentation, and that
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * the name of M.I.T. not be used in advertising or publicity pertaining
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * to distribution of the software without specific, written prior
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * permission. Furthermore if you modify this software you must label
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * your software as modified software and not distribute it in such a
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * fashion that it might be confused with the original M.I.T. software.
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * M.I.T. makes no representations about the suitability of
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * this software for any purpose. It is provided "as is" without express
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * or implied warranty.
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * oid_ops.c - GSS-API V2 interfaces to manipulate OIDs
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * The V2 API says the following!
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * gss_release_oid[()] will recognize any of the GSSAPI's own OID values,
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * and will silently ignore attempts to free these OIDs; for other OIDs
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * it will call the C free() routine for both the OID data and the
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * descriptor. This allows applications to freely mix their own heap-
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * allocated OID values with OIDs returned by GSS-API.
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * We use the official OID definitions instead of the unofficial OID
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * defintions. But we continue to support the unofficial OID
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * gss_nt_service_name just in case if some gss applications use
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * the old OID.
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb if ((*oid_set = (gss_OID_set) malloc(sizeof(gss_OID_set_desc)))) {
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtbgeneric_gss_add_oid_set_member(minor_status, member_oid, oid_set)
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb /* Get an enlarged copy of the array */
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb if (((*oid_set)->elements = (gss_OID) malloc(((*oid_set)->count+1) *
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb sizeof(gss_OID_desc)))) {
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb /* Copy in the old junk */
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb /* Duplicate the input element */
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb /* Success - copy elements */
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb /* Set length */
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb /* Update count */
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb /* Failure - restore old contents of list */
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtbgeneric_gss_test_oid_set_member(minor_status, member, set, present)
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * OID<->string routines. These are uuuuugly.
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb if (oid == NULL || oid->length == 0 || oid->elements == NULL)
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb /* Decoded according to krb5/gssapi_krb5.c */
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb /* First determine the size of the string */
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb snprintf(numstr, sizeof(numstr), "%lu ", (unsigned long)number/40);
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb snprintf(numstr, sizeof(numstr), "%lu ", (unsigned long)number%40);
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb if ((OM_uint32) (numshift+7) < (sizeof (OM_uint32)*8)) {/* XXX */
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb snprintf(numstr, sizeof(numstr), "%lu ", (unsigned long)number);
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * If we get here, we've calculated the length of "n n n ... n ". Add 4
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * here for "{ " and "}\0".
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb snprintf(numstr, sizeof(numstr), "%lu ", (unsigned long)number/40);
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb snprintf(numstr, sizeof(numstr), "%lu ", (unsigned long)number%40);
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb snprintf(numstr, sizeof(numstr), "%lu ", (unsigned long)number);
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb /* Skip over leading space */
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * The first two numbers are chewed up by the first octet.
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * Phew! We've come this far, so the syntax is good.
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb /* Have to fill in the bytes msb-first */
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry/* Compose an OID of a prefix and an integer suffix */
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry op = (unsigned char *) oid->elements + prefix_len + nbytes;
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry if (i != -1)
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry memcmp(oid->elements, prefix, prefix_len) != 0) {
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry op = (unsigned char *) oid->elements + prefix_len;
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry for (i = 0; i < slen; i++) {
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * Copyright 1993 by OpenVision Technologies, Inc.
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * Permission to use, copy, modify, distribute, and sell this software
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * and its documentation for any purpose is hereby granted without fee,
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * provided that the above copyright notice appears in all copies and
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * that both that copyright notice and this permission notice appear in
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * supporting documentation, and that the name of OpenVision not be used
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * in advertising or publicity pertaining to distribution of the software
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * without specific, written prior permission. OpenVision makes no
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * representations about the suitability of this software for any
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * purpose. It is provided "as is" without express or implied warranty.
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb * PERFORMANCE OF THIS SOFTWARE.
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb if ((copy = (gss_OID_set_desc *) calloc(1, sizeof (*copy))) == NULL) {
ab9b2e153c3a9a2b1141fefa87925b1a9beb1236gtb calloc(oidset->count, sizeof (*copy->elements))) == NULL) {