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