1 /* #pragma ident "@(#)g_oid_ops.c 1.11 98/01/22 SMI" */ 2 /* lib/gssapi/mechglue/g_oid_ops.c - GSSAPI V2 interfaces to manipulate OIDs */ 3 /* 4 * Copyright 1995, 2007 by the Massachusetts Institute of Technology. 5 * All Rights Reserved. 6 * 7 * Export of this software from the United States of America may 8 * require a specific license from the United States Government. 9 * It is the responsibility of any person or organization contemplating 10 * export to obtain such a license before exporting. 11 * 12 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and 13 * distribute this software and its documentation for any purpose and 14 * without fee is hereby granted, provided that the above copyright 15 * notice appear in all copies and that both that copyright notice and 16 * this permission notice appear in supporting documentation, and that 17 * the name of M.I.T. not be used in advertising or publicity pertaining 18 * to distribution of the software without specific, written prior 19 * permission. Furthermore if you modify this software you must label 20 * your software as modified software and not distribute it in such a 21 * fashion that it might be confused with the original M.I.T. software. 22 * M.I.T. makes no representations about the suitability of 23 * this software for any purpose. It is provided "as is" without express 24 * or implied warranty. 25 */ 26 27 #include "mglueP.h" 28 29 /* 30 * gss_release_oid has been moved to g_initialize, because it requires access 31 * to the mechanism list. All functions requiring direct access to the 32 * mechanism list are now in g_initialize.c 33 */ 34 35 OM_uint32 KRB5_CALLCONV 36 gss_create_empty_oid_set(OM_uint32 *minor_status, gss_OID_set *oid_set) 37 { 38 OM_uint32 status; 39 40 if (minor_status != NULL) 41 *minor_status = 0; 42 if (oid_set != NULL) 43 *oid_set = GSS_C_NO_OID_SET; 44 if (minor_status == NULL || oid_set == NULL) 45 return GSS_S_CALL_INACCESSIBLE_WRITE; 46 status = generic_gss_create_empty_oid_set(minor_status, oid_set); 47 if (status != GSS_S_COMPLETE) 48 map_errcode(minor_status); 49 return status; 50 } 51 52 OM_uint32 KRB5_CALLCONV 53 gss_add_oid_set_member(OM_uint32 *minor_status, gss_OID member_oid, 54 gss_OID_set *oid_set) 55 { 56 OM_uint32 status; 57 58 if (minor_status != NULL) 59 *minor_status = 0; 60 if (minor_status == NULL || oid_set == NULL) 61 return GSS_S_CALL_INACCESSIBLE_WRITE; 62 if (member_oid == GSS_C_NO_OID || member_oid->length == 0 || 63 member_oid->elements == NULL) 64 return GSS_S_CALL_INACCESSIBLE_READ; 65 status = generic_gss_add_oid_set_member(minor_status, member_oid, oid_set); 66 if (status != GSS_S_COMPLETE) 67 map_errcode(minor_status); 68 return status; 69 } 70 71 OM_uint32 KRB5_CALLCONV 72 gss_test_oid_set_member(OM_uint32 *minor_status, gss_OID member, 73 gss_OID_set set, int *present) 74 { 75 if (minor_status != NULL) 76 *minor_status = 0; 77 if (present != NULL) 78 *present = 0; 79 if (minor_status == NULL || present == NULL) 80 return GSS_S_CALL_INACCESSIBLE_WRITE; 81 if (member == GSS_C_NO_OID || set == GSS_C_NO_OID_SET) 82 return GSS_S_CALL_INACCESSIBLE_READ; 83 return generic_gss_test_oid_set_member(minor_status, member, set, present); 84 } 85 86 OM_uint32 KRB5_CALLCONV 87 gss_oid_to_str(OM_uint32 *minor_status, gss_OID oid, gss_buffer_t oid_str) 88 { 89 OM_uint32 status; 90 91 if (minor_status != NULL) 92 *minor_status = 0; 93 if (oid_str != GSS_C_NO_BUFFER) { 94 oid_str->length = 0; 95 oid_str->value = NULL; 96 } 97 if (minor_status == NULL || oid_str == GSS_C_NO_BUFFER) 98 return GSS_S_CALL_INACCESSIBLE_WRITE; 99 if (oid == GSS_C_NO_OID || oid->length == 0 || oid->elements == NULL) 100 return GSS_S_CALL_INACCESSIBLE_READ; 101 status = generic_gss_oid_to_str(minor_status, oid, oid_str); 102 if (status != GSS_S_COMPLETE) 103 map_errcode(minor_status); 104 return status; 105 } 106 107 OM_uint32 KRB5_CALLCONV 108 gss_str_to_oid(OM_uint32 *minor_status, gss_buffer_t oid_str, gss_OID *oid) 109 { 110 OM_uint32 status; 111 112 if (minor_status != NULL) 113 *minor_status = 0; 114 if (oid != NULL) 115 *oid = GSS_C_NO_OID; 116 if (minor_status == NULL || oid == NULL) 117 return GSS_S_CALL_INACCESSIBLE_WRITE; 118 if (GSS_EMPTY_BUFFER(oid_str)) 119 return GSS_S_CALL_INACCESSIBLE_READ; 120 status = generic_gss_str_to_oid(minor_status, oid_str, oid); 121 if (status != GSS_S_COMPLETE) 122 map_errcode(minor_status); 123 return status; 124 } 125 126 int KRB5_CALLCONV 127 gss_oid_equal( 128 gss_const_OID first_oid, 129 gss_const_OID second_oid) 130 { 131 /* GSS_C_NO_OID doesn't match itself, per draft-josefsson-gss-capsulate. */ 132 if (first_oid == GSS_C_NO_OID || second_oid == GSS_C_NO_OID) 133 return 0; 134 return g_OID_equal(first_oid, second_oid); 135 } 136