1 /* oid.c --- Definition of static GSS-API OIDs.
2  * Copyright (C) 2003-2014 Simon Josefsson
3  *
4  * This file is part of the Generic Security Service (GSS).
5  *
6  * GSS is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * GSS is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
14  * License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with GSS; if not, see http://www.gnu.org/licenses or write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth
19  * Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #include "internal.h"
24 
25 /*
26  * The implementation must reserve static storage for a
27  * gss_OID_desc object containing the value
28  * {10, (void *)"\x2a\x86\x48\x86\xf7\x12"
29  * "\x01\x02\x01\x01"},
30  * corresponding to an object-identifier value of
31  * {iso(1) member-body(2) United States(840) mit(113554)
32  * infosys(1) gssapi(2) generic(1) user_name(1)}.  The constant
33  * GSS_C_NT_USER_NAME should be initialized to point
34  * to that gss_OID_desc.
35  */
36 gss_OID_desc GSS_C_NT_USER_NAME_static = {
37   10, (void *) "\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x01"
38 };
39 
40 gss_OID GSS_C_NT_USER_NAME = &GSS_C_NT_USER_NAME_static;
41 
42 /*
43  * The implementation must reserve static storage for a
44  * gss_OID_desc object containing the value
45  * {10, (void *)"\x2a\x86\x48\x86\xf7\x12"
46  *              "\x01\x02\x01\x02"},
47  * corresponding to an object-identifier value of
48  * {iso(1) member-body(2) United States(840) mit(113554)
49  * infosys(1) gssapi(2) generic(1) machine_uid_name(2)}.
50  * The constant GSS_C_NT_MACHINE_UID_NAME should be
51  * initialized to point to that gss_OID_desc.
52  */
53 gss_OID_desc GSS_C_NT_MACHINE_UID_NAME_static = {
54   10, (void *) "\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x02"
55 };
56 
57 gss_OID GSS_C_NT_MACHINE_UID_NAME = &GSS_C_NT_MACHINE_UID_NAME_static;
58 
59 /*
60  * The implementation must reserve static storage for a
61  * gss_OID_desc object containing the value
62  * {10, (void *)"\x2a\x86\x48\x86\xf7\x12"
63  *              "\x01\x02\x01\x03"},
64  * corresponding to an object-identifier value of
65  * {iso(1) member-body(2) United States(840) mit(113554)
66  * infosys(1) gssapi(2) generic(1) string_uid_name(3)}.
67  * The constant GSS_C_NT_STRING_UID_NAME should be
68  * initialized to point to that gss_OID_desc.
69  */
70 gss_OID_desc GSS_C_NT_STRING_UID_NAME_static = {
71   10, (void *) "\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x03"
72 };
73 
74 gss_OID GSS_C_NT_STRING_UID_NAME = &GSS_C_NT_STRING_UID_NAME_static;
75 
76 /*
77  * The implementation must reserve static storage for a
78  * gss_OID_desc object containing the value
79  * {6, (void *)"\x2b\x06\x01\x05\x06\x02"},
80  * corresponding to an object-identifier value of
81  * {iso(1) org(3) dod(6) internet(1) security(5)
82  * nametypes(6) gss-host-based-services(2)).  The constant
83  * GSS_C_NT_HOSTBASED_SERVICE_X should be initialized to point
84  * to that gss_OID_desc.  This is a deprecated OID value, and
85  * implementations wishing to support hostbased-service names
86  * should instead use the GSS_C_NT_HOSTBASED_SERVICE OID,
87  * defined below, to identify such names;
88  * GSS_C_NT_HOSTBASED_SERVICE_X should be accepted a synonym
89  * for GSS_C_NT_HOSTBASED_SERVICE when presented as an input
90  * parameter, but should not be emitted by GSS-API
91  * implementations
92  */
93 gss_OID_desc GSS_C_NT_HOSTBASED_SERVICE_X_static = {
94   6, (void *) "\x2b\x06\x01\x05\x06\x02"
95 };
96 
97 gss_OID GSS_C_NT_HOSTBASED_SERVICE_X = &GSS_C_NT_HOSTBASED_SERVICE_X_static;
98 
99 /*
100  * The implementation must reserve static storage for a
101  * gss_OID_desc object containing the value
102  * {10, (void *)"\x2a\x86\x48\x86\xf7\x12"
103  *              "\x01\x02\x01\x04"}, corresponding to an
104  * object-identifier value of {iso(1) member-body(2)
105  * Unites States(840) mit(113554) infosys(1) gssapi(2)
106  * generic(1) service_name(4)}.  The constant
107  * GSS_C_NT_HOSTBASED_SERVICE should be initialized
108  * to point to that gss_OID_desc.
109  */
110 gss_OID_desc GSS_C_NT_HOSTBASED_SERVICE_static = {
111   10, (void *) "\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x04"
112 };
113 
114 gss_OID GSS_C_NT_HOSTBASED_SERVICE = &GSS_C_NT_HOSTBASED_SERVICE_static;
115 
116 /*
117  * The implementation must reserve static storage for a
118  * gss_OID_desc object containing the value
119  * {6, (void *)"\x2b\x06\01\x05\x06\x03"},
120  * corresponding to an object identifier value of
121  * {1(iso), 3(org), 6(dod), 1(internet), 5(security),
122  * 6(nametypes), 3(gss-anonymous-name)}.  The constant
123  * and GSS_C_NT_ANONYMOUS should be initialized to point
124  * to that gss_OID_desc.
125  */
126 gss_OID_desc GSS_C_NT_ANONYMOUS_static = {
127   6, (void *) "\x2b\x06\01\x05\x06\x03"
128 };
129 
130 gss_OID GSS_C_NT_ANONYMOUS = &GSS_C_NT_ANONYMOUS_static;
131 
132 
133 /*
134  * The implementation must reserve static storage for a
135  * gss_OID_desc object containing the value
136  * {6, (void *)"\x2b\x06\x01\x05\x06\x04"},
137  * corresponding to an object-identifier value of
138  * {1(iso), 3(org), 6(dod), 1(internet), 5(security),
139  * 6(nametypes), 4(gss-api-exported-name)}.  The constant
140  * GSS_C_NT_EXPORT_NAME should be initialized to point
141  * to that gss_OID_desc.
142  */
143 gss_OID_desc GSS_C_NT_EXPORT_NAME_static = {
144   6, (void *) "\x2b\x06\x01\x05\x06\x04"
145 };
146 
147 gss_OID GSS_C_NT_EXPORT_NAME = &GSS_C_NT_EXPORT_NAME_static;
148 
149 /**
150  * gss_oid_equal:
151  * @first_oid: (Object ID, read) First Object identifier.
152  * @second_oid: (Object ID, read) First Object identifier.
153  *
154  * Compare two OIDs for equality.  The comparison is "deep", i.e., the
155  * actual byte sequences of the OIDs are compared instead of just the
156  * pointer equality.  This function is standardized in RFC 6339.
157  *
158  * Return value: Returns boolean value true when the two OIDs are
159  *   equal, otherwise false.
160  **/
161 int
gss_oid_equal(gss_const_OID first_oid,gss_const_OID second_oid)162 gss_oid_equal (gss_const_OID first_oid, gss_const_OID second_oid)
163 {
164   return first_oid && second_oid &&
165     first_oid->length == second_oid->length &&
166     memcmp (first_oid->elements, second_oid->elements,
167 	    second_oid->length) == 0;
168 }
169