xref: /netbsd-src/crypto/external/bsd/heimdal/dist/lib/gssapi/spnego/external.c (revision d3273b5b76f5afaafe308cead5511dbb8df8c5e9)
1*d3273b5bSchristos /*	$NetBSD: external.c,v 1.2 2017/01/28 21:31:47 christos Exp $	*/
2ca1c9b0cSelric 
3ca1c9b0cSelric /*
4ca1c9b0cSelric  * Copyright (c) 2004, PADL Software Pty Ltd.
5ca1c9b0cSelric  * All rights reserved.
6ca1c9b0cSelric  *
7ca1c9b0cSelric  * Redistribution and use in source and binary forms, with or without
8ca1c9b0cSelric  * modification, are permitted provided that the following conditions
9ca1c9b0cSelric  * are met:
10ca1c9b0cSelric  *
11ca1c9b0cSelric  * 1. Redistributions of source code must retain the above copyright
12ca1c9b0cSelric  *    notice, this list of conditions and the following disclaimer.
13ca1c9b0cSelric  *
14ca1c9b0cSelric  * 2. Redistributions in binary form must reproduce the above copyright
15ca1c9b0cSelric  *    notice, this list of conditions and the following disclaimer in the
16ca1c9b0cSelric  *    documentation and/or other materials provided with the distribution.
17ca1c9b0cSelric  *
18ca1c9b0cSelric  * 3. Neither the name of PADL Software nor the names of its contributors
19ca1c9b0cSelric  *    may be used to endorse or promote products derived from this software
20ca1c9b0cSelric  *    without specific prior written permission.
21ca1c9b0cSelric  *
22ca1c9b0cSelric  * THIS SOFTWARE IS PROVIDED BY PADL SOFTWARE AND CONTRIBUTORS ``AS IS'' AND
23ca1c9b0cSelric  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24ca1c9b0cSelric  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25ca1c9b0cSelric  * ARE DISCLAIMED.  IN NO EVENT SHALL PADL SOFTWARE OR CONTRIBUTORS BE LIABLE
26ca1c9b0cSelric  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27ca1c9b0cSelric  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28ca1c9b0cSelric  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29ca1c9b0cSelric  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30ca1c9b0cSelric  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31ca1c9b0cSelric  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32ca1c9b0cSelric  * SUCH DAMAGE.
33ca1c9b0cSelric  */
34ca1c9b0cSelric 
35ca1c9b0cSelric #include "spnego_locl.h"
36ca1c9b0cSelric #include <gssapi_mech.h>
37ca1c9b0cSelric 
38ca1c9b0cSelric /*
39ca1c9b0cSelric  * RFC2478, SPNEGO:
40ca1c9b0cSelric  *  The security mechanism of the initial
41ca1c9b0cSelric  *  negotiation token is identified by the Object Identifier
42ca1c9b0cSelric  *  iso.org.dod.internet.security.mechanism.snego (1.3.6.1.5.5.2).
43ca1c9b0cSelric  */
44ca1c9b0cSelric static gss_mo_desc spnego_mo[] = {
45ca1c9b0cSelric     {
46ca1c9b0cSelric 	GSS_C_MA_SASL_MECH_NAME,
47ca1c9b0cSelric 	GSS_MO_MA,
48ca1c9b0cSelric 	"SASL mech name",
494f77a458Spettai 	rk_UNCONST("SPNEGO"),
50ca1c9b0cSelric 	_gss_mo_get_ctx_as_string,
51ca1c9b0cSelric 	NULL
52ca1c9b0cSelric     },
53ca1c9b0cSelric     {
54ca1c9b0cSelric 	GSS_C_MA_MECH_NAME,
55ca1c9b0cSelric 	GSS_MO_MA,
56ca1c9b0cSelric 	"Mechanism name",
574f77a458Spettai 	rk_UNCONST("SPNEGO"),
58ca1c9b0cSelric 	_gss_mo_get_ctx_as_string,
59ca1c9b0cSelric 	NULL
60ca1c9b0cSelric     },
61ca1c9b0cSelric     {
62ca1c9b0cSelric 	GSS_C_MA_MECH_DESCRIPTION,
63ca1c9b0cSelric 	GSS_MO_MA,
64ca1c9b0cSelric 	"Mechanism description",
654f77a458Spettai 	rk_UNCONST("Heimdal SPNEGO Mechanism"),
66ca1c9b0cSelric 	_gss_mo_get_ctx_as_string,
67ca1c9b0cSelric 	NULL
68ca1c9b0cSelric     },
69ca1c9b0cSelric     {
70ca1c9b0cSelric 	GSS_C_MA_MECH_NEGO,
71b9d004c6Schristos 	GSS_MO_MA,
72b9d004c6Schristos 	NULL,
73b9d004c6Schristos 	NULL,
74b9d004c6Schristos 	NULL,
75b9d004c6Schristos 	NULL
76ca1c9b0cSelric     },
77ca1c9b0cSelric     {
78ca1c9b0cSelric 	GSS_C_MA_MECH_PSEUDO,
79b9d004c6Schristos 	GSS_MO_MA,
80b9d004c6Schristos 	NULL,
81b9d004c6Schristos 	NULL,
82b9d004c6Schristos 	NULL,
83b9d004c6Schristos 	NULL
84ca1c9b0cSelric     }
85ca1c9b0cSelric };
86ca1c9b0cSelric 
87ca1c9b0cSelric static gssapi_mech_interface_desc spnego_mech = {
88ca1c9b0cSelric     GMI_VERSION,
89ca1c9b0cSelric     "spnego",
904f77a458Spettai     {6, rk_UNCONST("\x2b\x06\x01\x05\x05\x02") },
91ca1c9b0cSelric     0,
92ca1c9b0cSelric     _gss_spnego_acquire_cred,
93ca1c9b0cSelric     _gss_spnego_release_cred,
94ca1c9b0cSelric     _gss_spnego_init_sec_context,
95ca1c9b0cSelric     _gss_spnego_accept_sec_context,
96ca1c9b0cSelric     _gss_spnego_process_context_token,
974f77a458Spettai     _gss_spnego_delete_sec_context,
98ca1c9b0cSelric     _gss_spnego_context_time,
99ca1c9b0cSelric     _gss_spnego_get_mic,
100ca1c9b0cSelric     _gss_spnego_verify_mic,
101ca1c9b0cSelric     _gss_spnego_wrap,
102ca1c9b0cSelric     _gss_spnego_unwrap,
103ca1c9b0cSelric     NULL, /* gm_display_status */
104ca1c9b0cSelric     NULL, /* gm_indicate_mechs */
105ca1c9b0cSelric     _gss_spnego_compare_name,
106ca1c9b0cSelric     _gss_spnego_display_name,
107ca1c9b0cSelric     _gss_spnego_import_name,
108ca1c9b0cSelric     _gss_spnego_export_name,
109ca1c9b0cSelric     _gss_spnego_release_name,
110ca1c9b0cSelric     _gss_spnego_inquire_cred,
111ca1c9b0cSelric     _gss_spnego_inquire_context,
112ca1c9b0cSelric     _gss_spnego_wrap_size_limit,
113ca1c9b0cSelric     gss_add_cred,
114ca1c9b0cSelric     _gss_spnego_inquire_cred_by_mech,
115ca1c9b0cSelric     _gss_spnego_export_sec_context,
116ca1c9b0cSelric     _gss_spnego_import_sec_context,
117ca1c9b0cSelric     NULL /* _gss_spnego_inquire_names_for_mech */,
118ca1c9b0cSelric     _gss_spnego_inquire_mechs_for_name,
119ca1c9b0cSelric     _gss_spnego_canonicalize_name,
120ca1c9b0cSelric     _gss_spnego_duplicate_name,
121ca1c9b0cSelric     _gss_spnego_inquire_sec_context_by_oid,
122ca1c9b0cSelric     _gss_spnego_inquire_cred_by_oid,
123ca1c9b0cSelric     _gss_spnego_set_sec_context_option,
124ca1c9b0cSelric     _gss_spnego_set_cred_option,
125ca1c9b0cSelric     _gss_spnego_pseudo_random,
126ca1c9b0cSelric     _gss_spnego_wrap_iov,
127ca1c9b0cSelric     _gss_spnego_unwrap_iov,
128ca1c9b0cSelric     _gss_spnego_wrap_iov_length,
129ca1c9b0cSelric     NULL,
130ca1c9b0cSelric     _gss_spnego_export_cred,
131ca1c9b0cSelric     _gss_spnego_import_cred,
132ca1c9b0cSelric     NULL,
133ca1c9b0cSelric     NULL,
134ca1c9b0cSelric     NULL,
135ca1c9b0cSelric     NULL,
136ca1c9b0cSelric     NULL,
137ca1c9b0cSelric     NULL,
138ca1c9b0cSelric     NULL,
139ca1c9b0cSelric     spnego_mo,
1404f77a458Spettai     sizeof(spnego_mo) / sizeof(spnego_mo[0]),
1414f77a458Spettai     NULL,
1424f77a458Spettai     NULL,
1434f77a458Spettai     NULL,
1444f77a458Spettai     NULL,
1454f77a458Spettai     NULL,
1464f77a458Spettai     NULL,
147b9d004c6Schristos     NULL,
148b9d004c6Schristos     NULL,
149b9d004c6Schristos     NULL,
150ca1c9b0cSelric };
151ca1c9b0cSelric 
152ca1c9b0cSelric gssapi_mech_interface
__gss_spnego_initialize(void)153ca1c9b0cSelric __gss_spnego_initialize(void)
154ca1c9b0cSelric {
155ca1c9b0cSelric 	return &spnego_mech;
156ca1c9b0cSelric }
157