r19603: Make it easier to control the debug level of smbd.
[kai/samba.git] / source4 / heimdal / lib / gssapi / external.c
1 /*
2  * Copyright (c) 1997 - 2000 Kungliga Tekniska Högskolan
3  * (Royal Institute of Technology, Stockholm, Sweden). 
4  * All rights reserved. 
5  *
6  * Redistribution and use in source and binary forms, with or without 
7  * modification, are permitted provided that the following conditions 
8  * are met: 
9  *
10  * 1. Redistributions of source code must retain the above copyright 
11  *    notice, this list of conditions and the following disclaimer. 
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright 
14  *    notice, this list of conditions and the following disclaimer in the 
15  *    documentation and/or other materials provided with the distribution. 
16  *
17  * 3. Neither the name of the Institute nor the names of its contributors 
18  *    may be used to endorse or promote products derived from this software 
19  *    without specific prior written permission. 
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
31  * SUCH DAMAGE. 
32  */
33
34 #include "gssapi_locl.h"
35
36 RCSID("$Id: external.c,v 1.7 2005/08/23 11:59:47 lha Exp $");
37
38 /*
39  * The implementation must reserve static storage for a
40  * gss_OID_desc object containing the value
41  * {10, (void *)"\x2a\x86\x48\x86\xf7\x12"
42  *              "\x01\x02\x01\x01"},
43  * corresponding to an object-identifier value of
44  * {iso(1) member-body(2) United States(840) mit(113554)
45  *  infosys(1) gssapi(2) generic(1) user_name(1)}.  The constant
46  * GSS_C_NT_USER_NAME should be initialized to point
47  * to that gss_OID_desc.
48  */
49
50 static gss_OID_desc gss_c_nt_user_name_oid_desc =
51 {10, rk_UNCONST("\x2a\x86\x48\x86\xf7\x12" "\x01\x02\x01\x01")};
52
53 gss_OID GSS_C_NT_USER_NAME = &gss_c_nt_user_name_oid_desc;
54
55 /*
56  * The implementation must reserve static storage for a
57  * gss_OID_desc object containing the value
58  * {10, (void *)"\x2a\x86\x48\x86\xf7\x12"
59  *              "\x01\x02\x01\x02"},
60  * corresponding to an object-identifier value of
61  * {iso(1) member-body(2) United States(840) mit(113554)
62  *  infosys(1) gssapi(2) generic(1) machine_uid_name(2)}.
63  * The constant GSS_C_NT_MACHINE_UID_NAME should be
64  * initialized to point to that gss_OID_desc.
65  */
66
67 static gss_OID_desc gss_c_nt_machine_uid_name_oid_desc =
68 {10, rk_UNCONST("\x2a\x86\x48\x86\xf7\x12" "\x01\x02\x01\x02")};
69
70 gss_OID GSS_C_NT_MACHINE_UID_NAME = &gss_c_nt_machine_uid_name_oid_desc;
71
72 /*
73  * The implementation must reserve static storage for a
74  * gss_OID_desc object containing the value
75  * {10, (void *)"\x2a\x86\x48\x86\xf7\x12"
76  *              "\x01\x02\x01\x03"},
77  * corresponding to an object-identifier value of
78  * {iso(1) member-body(2) United States(840) mit(113554)
79  *  infosys(1) gssapi(2) generic(1) string_uid_name(3)}.
80  * The constant GSS_C_NT_STRING_UID_NAME should be
81  * initialized to point to that gss_OID_desc.
82  */
83
84 static gss_OID_desc gss_c_nt_string_uid_name_oid_desc =
85 {10, rk_UNCONST("\x2a\x86\x48\x86\xf7\x12" "\x01\x02\x01\x03")};
86
87 gss_OID GSS_C_NT_STRING_UID_NAME = &gss_c_nt_string_uid_name_oid_desc;
88
89 /*
90  * The implementation must reserve static storage for a
91  * gss_OID_desc object containing the value
92  * {6, (void *)"\x2b\x06\x01\x05\x06\x02"},
93  * corresponding to an object-identifier value of
94  * {iso(1) org(3) dod(6) internet(1) security(5)
95  * nametypes(6) gss-host-based-services(2)).  The constant
96  * GSS_C_NT_HOSTBASED_SERVICE_X should be initialized to point
97  * to that gss_OID_desc.  This is a deprecated OID value, and
98  * implementations wishing to support hostbased-service names
99  * should instead use the GSS_C_NT_HOSTBASED_SERVICE OID,
100  * defined below, to identify such names;
101  * GSS_C_NT_HOSTBASED_SERVICE_X should be accepted a synonym
102  * for GSS_C_NT_HOSTBASED_SERVICE when presented as an input
103  * parameter, but should not be emitted by GSS-API
104  * implementations
105  */
106
107 static gss_OID_desc gss_c_nt_hostbased_service_x_oid_desc =
108 {6, rk_UNCONST("\x2b\x06\x01\x05\x06\x02")};
109
110 gss_OID GSS_C_NT_HOSTBASED_SERVICE_X = &gss_c_nt_hostbased_service_x_oid_desc;
111
112 /*
113  * The implementation must reserve static storage for a
114  * gss_OID_desc object containing the value
115  * {10, (void *)"\x2a\x86\x48\x86\xf7\x12"
116  *              "\x01\x02\x01\x04"}, corresponding to an
117  * object-identifier value of {iso(1) member-body(2)
118  * Unites States(840) mit(113554) infosys(1) gssapi(2)
119  * generic(1) service_name(4)}.  The constant
120  * GSS_C_NT_HOSTBASED_SERVICE should be initialized
121  * to point to that gss_OID_desc.
122  */
123 static gss_OID_desc gss_c_nt_hostbased_service_oid_desc =
124 {10, rk_UNCONST("\x2a\x86\x48\x86\xf7\x12" "\x01\x02\x01\x04")};
125
126 gss_OID GSS_C_NT_HOSTBASED_SERVICE = &gss_c_nt_hostbased_service_oid_desc;
127
128 /*
129  * The implementation must reserve static storage for a
130  * gss_OID_desc object containing the value
131  * {6, (void *)"\x2b\x06\01\x05\x06\x03"},
132  * corresponding to an object identifier value of
133  * {1(iso), 3(org), 6(dod), 1(internet), 5(security),
134  * 6(nametypes), 3(gss-anonymous-name)}.  The constant
135  * and GSS_C_NT_ANONYMOUS should be initialized to point
136  * to that gss_OID_desc.
137  */
138
139 static gss_OID_desc gss_c_nt_anonymous_oid_desc =
140 {6, rk_UNCONST("\x2b\x06\01\x05\x06\x03")};
141
142 gss_OID GSS_C_NT_ANONYMOUS = &gss_c_nt_anonymous_oid_desc;
143
144 /*
145  * The implementation must reserve static storage for a
146  * gss_OID_desc object containing the value
147  * {6, (void *)"\x2b\x06\x01\x05\x06\x04"},
148  * corresponding to an object-identifier value of
149  * {1(iso), 3(org), 6(dod), 1(internet), 5(security),
150  * 6(nametypes), 4(gss-api-exported-name)}.  The constant
151  * GSS_C_NT_EXPORT_NAME should be initialized to point
152  * to that gss_OID_desc.
153  */
154
155 static gss_OID_desc gss_c_nt_export_name_oid_desc =
156 {6, rk_UNCONST("\x2b\x06\x01\x05\x06\x04") };
157
158 gss_OID GSS_C_NT_EXPORT_NAME = &gss_c_nt_export_name_oid_desc;
159
160 /*
161  *   This name form shall be represented by the Object Identifier {iso(1)
162  *   member-body(2) United States(840) mit(113554) infosys(1) gssapi(2)
163  *   krb5(2) krb5_name(1)}.  The recommended symbolic name for this type
164  *   is "GSS_KRB5_NT_PRINCIPAL_NAME".
165  */
166
167 static gss_OID_desc gss_krb5_nt_principal_name_oid_desc =
168 {10, rk_UNCONST("\x2a\x86\x48\x86\xf7\x12\x01\x02\x02\x01") };
169
170 gss_OID GSS_KRB5_NT_PRINCIPAL_NAME = &gss_krb5_nt_principal_name_oid_desc;
171
172 /*
173  *   This name form shall be represented by the Object Identifier {iso(1)
174  *   member-body(2) United States(840) mit(113554) infosys(1) gssapi(2)
175  *   generic(1) user_name(1)}.  The recommended symbolic name for this
176  *   type is "GSS_KRB5_NT_USER_NAME".
177  */
178
179 gss_OID GSS_KRB5_NT_USER_NAME = &gss_c_nt_user_name_oid_desc;
180
181 /*
182  *   This name form shall be represented by the Object Identifier {iso(1)
183  *   member-body(2) United States(840) mit(113554) infosys(1) gssapi(2)
184  *   generic(1) machine_uid_name(2)}.  The recommended symbolic name for
185  *   this type is "GSS_KRB5_NT_MACHINE_UID_NAME".
186  */
187
188 gss_OID GSS_KRB5_NT_MACHINE_UID_NAME = &gss_c_nt_machine_uid_name_oid_desc;
189
190 /*
191  *   This name form shall be represented by the Object Identifier {iso(1)
192  *   member-body(2) United States(840) mit(113554) infosys(1) gssapi(2)
193  *   generic(1) string_uid_name(3)}.  The recommended symbolic name for
194  *   this type is "GSS_KRB5_NT_STRING_UID_NAME".
195  */
196
197 gss_OID GSS_KRB5_NT_STRING_UID_NAME = &gss_c_nt_string_uid_name_oid_desc;
198
199 /*
200  *   To support ongoing experimentation, testing, and evolution of the
201  *   specification, the Kerberos V5 GSS-API mechanism as defined in this
202  *   and any successor memos will be identified with the following Object
203  *   Identifier, as defined in RFC-1510, until the specification is
204  *   advanced to the level of Proposed Standard RFC:
205  *
206  *   {iso(1), org(3), dod(5), internet(1), security(5), kerberosv5(2)}
207  *
208  *   Upon advancement to the level of Proposed Standard RFC, the Kerberos
209  *   V5 GSS-API mechanism will be identified by an Object Identifier
210  *   having the value:
211  *
212  *   {iso(1) member-body(2) United States(840) mit(113554) infosys(1)
213  *   gssapi(2) krb5(2)}
214  */
215
216 #if 0 /* This is the old OID */
217
218 static gss_OID_desc gss_krb5_mechanism_oid_desc =
219 {5, rk_UNCONST("\x2b\x05\x01\x05\x02")};
220
221 #endif
222
223 static gss_OID_desc gss_krb5_mechanism_oid_desc =
224 {9, rk_UNCONST("\x2a\x86\x48\x86\xf7\x12\x01\x02\x02") };
225
226 gss_OID GSS_KRB5_MECHANISM = &gss_krb5_mechanism_oid_desc;
227
228 /*
229  * RFC2478, SPNEGO:
230  *  The security mechanism of the initial
231  *  negotiation token is identified by the Object Identifier
232  *  iso.org.dod.internet.security.mechanism.snego (1.3.6.1.5.5.2).
233  */
234
235 static gss_OID_desc gss_spnego_mechanism_oid_desc =
236 {6, rk_UNCONST("\x2b\x06\x01\x05\x05\x02")};
237
238 gss_OID GSS_SPNEGO_MECHANISM = &gss_spnego_mechanism_oid_desc;
239
240 /*
241  * draft-ietf-cat-iakerb-09, IAKERB:
242  *   The mechanism ID for IAKERB proxy GSS-API Kerberos, in accordance
243  *   with the mechanism proposed by SPNEGO [7] for negotiating protocol
244  *   variations, is:  {iso(1) org(3) dod(6) internet(1) security(5)
245  *   mechanisms(5) iakerb(10) iakerbProxyProtocol(1)}.  The proposed
246  *   mechanism ID for IAKERB minimum messages GSS-API Kerberos, in
247  *   accordance with the mechanism proposed by SPNEGO for negotiating
248  *   protocol variations, is: {iso(1) org(3) dod(6) internet(1)
249  *   security(5) mechanisms(5) iakerb(10)
250  *   iakerbMinimumMessagesProtocol(2)}.
251  */
252
253 static gss_OID_desc gss_iakerb_proxy_mechanism_oid_desc =
254 {7, rk_UNCONST("\x2b\x06\x01\x05\x05\x0a\x01")};
255
256 gss_OID GSS_IAKERB_PROXY_MECHANISM = &gss_iakerb_proxy_mechanism_oid_desc;
257
258 static gss_OID_desc gss_iakerb_min_msg_mechanism_oid_desc =
259 {7, rk_UNCONST("\x2b\x06\x01\x05\x05\x0a\x02") };
260
261 gss_OID GSS_IAKERB_MIN_MSG_MECHANISM = &gss_iakerb_min_msg_mechanism_oid_desc;
262
263 /*
264  * Context for krb5 calls.
265  */
266
267 krb5_context gssapi_krb5_context;