Path: blob/main/crypto/krb5/src/lib/gssapi/mechglue/g_oid_ops.c
39586 views
/* #pragma ident "@(#)g_oid_ops.c 1.11 98/01/22 SMI" */1/* lib/gssapi/mechglue/g_oid_ops.c - GSSAPI V2 interfaces to manipulate OIDs */2/*3* Copyright 1995, 2007 by the Massachusetts Institute of Technology.4* All Rights Reserved.5*6* Export of this software from the United States of America may7* require a specific license from the United States Government.8* It is the responsibility of any person or organization contemplating9* export to obtain such a license before exporting.10*11* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and12* distribute this software and its documentation for any purpose and13* without fee is hereby granted, provided that the above copyright14* notice appear in all copies and that both that copyright notice and15* this permission notice appear in supporting documentation, and that16* the name of M.I.T. not be used in advertising or publicity pertaining17* to distribution of the software without specific, written prior18* permission. Furthermore if you modify this software you must label19* your software as modified software and not distribute it in such a20* fashion that it might be confused with the original M.I.T. software.21* M.I.T. makes no representations about the suitability of22* this software for any purpose. It is provided "as is" without express23* or implied warranty.24*/2526#include "mglueP.h"2728/*29* gss_release_oid has been moved to g_initialize, because it requires access30* to the mechanism list. All functions requiring direct access to the31* mechanism list are now in g_initialize.c32*/3334OM_uint32 KRB5_CALLCONV35gss_create_empty_oid_set(OM_uint32 *minor_status, gss_OID_set *oid_set)36{37OM_uint32 status;3839if (minor_status != NULL)40*minor_status = 0;41if (oid_set != NULL)42*oid_set = GSS_C_NO_OID_SET;43if (minor_status == NULL || oid_set == NULL)44return GSS_S_CALL_INACCESSIBLE_WRITE;45status = generic_gss_create_empty_oid_set(minor_status, oid_set);46if (status != GSS_S_COMPLETE)47map_errcode(minor_status);48return status;49}5051OM_uint32 KRB5_CALLCONV52gss_add_oid_set_member(OM_uint32 *minor_status, gss_OID member_oid,53gss_OID_set *oid_set)54{55OM_uint32 status;5657if (minor_status != NULL)58*minor_status = 0;59if (minor_status == NULL || oid_set == NULL)60return GSS_S_CALL_INACCESSIBLE_WRITE;61if (member_oid == GSS_C_NO_OID || member_oid->length == 0 ||62member_oid->elements == NULL)63return GSS_S_CALL_INACCESSIBLE_READ;64status = generic_gss_add_oid_set_member(minor_status, member_oid, oid_set);65if (status != GSS_S_COMPLETE)66map_errcode(minor_status);67return status;68}6970OM_uint32 KRB5_CALLCONV71gss_test_oid_set_member(OM_uint32 *minor_status, gss_OID member,72gss_OID_set set, int *present)73{74if (minor_status != NULL)75*minor_status = 0;76if (present != NULL)77*present = 0;78if (minor_status == NULL || present == NULL)79return GSS_S_CALL_INACCESSIBLE_WRITE;80if (member == GSS_C_NO_OID || set == GSS_C_NO_OID_SET)81return GSS_S_CALL_INACCESSIBLE_READ;82return generic_gss_test_oid_set_member(minor_status, member, set, present);83}8485OM_uint32 KRB5_CALLCONV86gss_oid_to_str(OM_uint32 *minor_status, gss_OID oid, gss_buffer_t oid_str)87{88OM_uint32 status;8990if (minor_status != NULL)91*minor_status = 0;92if (oid_str != GSS_C_NO_BUFFER) {93oid_str->length = 0;94oid_str->value = NULL;95}96if (minor_status == NULL || oid_str == GSS_C_NO_BUFFER)97return GSS_S_CALL_INACCESSIBLE_WRITE;98if (oid == GSS_C_NO_OID || oid->length == 0 || oid->elements == NULL)99return GSS_S_CALL_INACCESSIBLE_READ;100status = generic_gss_oid_to_str(minor_status, oid, oid_str);101if (status != GSS_S_COMPLETE)102map_errcode(minor_status);103return status;104}105106OM_uint32 KRB5_CALLCONV107gss_str_to_oid(OM_uint32 *minor_status, gss_buffer_t oid_str, gss_OID *oid)108{109OM_uint32 status;110111if (minor_status != NULL)112*minor_status = 0;113if (oid != NULL)114*oid = GSS_C_NO_OID;115if (minor_status == NULL || oid == NULL)116return GSS_S_CALL_INACCESSIBLE_WRITE;117if (GSS_EMPTY_BUFFER(oid_str))118return GSS_S_CALL_INACCESSIBLE_READ;119status = generic_gss_str_to_oid(minor_status, oid_str, oid);120if (status != GSS_S_COMPLETE)121map_errcode(minor_status);122return status;123}124125int KRB5_CALLCONV126gss_oid_equal(127gss_const_OID first_oid,128gss_const_OID second_oid)129{130/* GSS_C_NO_OID doesn't match itself, per draft-josefsson-gss-capsulate. */131if (first_oid == GSS_C_NO_OID || second_oid == GSS_C_NO_OID)132return 0;133return g_OID_equal(first_oid, second_oid);134}135136137