/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* oid.c
*
* Copyright (c) 1997, by Sun Microsystems, Inc.
* All rights reserved.
*
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <string.h>
#include "dh_gssapi.h"
/*
* These are private mech_dh oid support routines.
*/
/* See if two oids have the same value */
int
{
return (0);
}
/* Count the number of elements in an oid. Return -1 on badly formed OID */
int
{
int i;
/* For each byte */
for (i = 0; p < e; i++) {
/* If the upper bit is set it is part of this element */
while (*p & 0x80) {
p++;
if (p == e)
return (-1);
}
p++;
}
return (i);
}
/* Copy an oid to an allocated gss_OID_desc */
{
/* Allocate the elements of the new OID */
return (DH_NOMEM_FAILURE);
/* Set the length */
/* And copy the elements */
return (DH_SUCCESS);
}
/* Copy an oid, allocating storage */
{
/* Allocate a new OID */
/* Clear the destination */
/* return failure if no memory for oid */
return (DH_NOMEM_FAILURE);
/* Copy the soure oid in to the new OID */
return (DH_NOMEM_FAILURE);
}
/* Set the destination oid */
return (DH_SUCCESS);
}
/* Check if an oid is a member of an oid set */
int
{
int i;
/* For each member in the set ... */
return (TRUE);
return (FALSE);
}
/* Copy oid set to a newly allocated set */
{
int i;
/* Clear the destination */
*dest = GSS_C_NO_OID_SET;
/* Allocate a new container for the set */
return (DH_NOMEM_FAILURE);
/* Allocate storage for the elements of the set */
return (DH_NOMEM_FAILURE);
}
/* set the number of elements in the set */
/* Add each member of the source set to the new set */
!= DH_SUCCESS)
break;
/* Free partially allocated set on error */
for (; i >= 0; i--)
return (DH_NOMEM_FAILURE);
}
/* Set the destination to the set */
return (DH_SUCCESS);
}
/*
* Form a gss_OID_set from an array of gss_OID_desc.
*/
{
int i;
/* Clear the output set */
*dest = GSS_C_NO_OID_SET;
/* Allocate the set */
return (DH_NOMEM_FAILURE);
/* And space for the members */
return (DH_NOMEM_FAILURE);
}
/* Set the set count */
/* For each element in the array, addit to the set */
!= DH_SUCCESS)
break;
/* if we failed recover memory */
for (; i >= 0; i--)
return (DH_NOMEM_FAILURE);
}
/* Set the destination */
return (DH_SUCCESS);
}
/*
* Given an oid create a GSS_OID_set with a copy of that oid as its
* sole member.
*/
{
int rc;
gss_OID_set s;
/* Nothing to do */
return (DH_SUCCESS);
/* Allocate a set description */
return (DH_NOMEM_FAILURE);
/* Add the OID to the set */
s->count = 1;
Free(s);
return (rc);
}
/* return the set */
*set = s;
return (DH_SUCCESS);
}