4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright (c) 2011 Bayard G. Bell. All rights reserved.
26 * A module for Kerberos V5 security mechanism.
30 #include <sys/types.h>
31 #include <sys/modctl.h>
32 #include <sys/errno.h>
33 #include <mechglueP.h>
34 #include <gssapiP_krb5.h>
35 #include <gssapi_err_generic.h>
36 #include <gssapi/kgssapi_defs.h>
37 #include <sys/debug.h>
40 /* mechglue wrappers */
42 static OM_uint32 k5glue_delete_sec_context
43 (void *, OM_uint32
*, /* minor_status */
44 gss_ctx_id_t
*, /* context_handle */
45 gss_buffer_t
, /* output_token */
48 static OM_uint32 k5glue_sign
49 (void *, OM_uint32
*, /* minor_status */
50 gss_ctx_id_t
, /* context_handle */
52 gss_buffer_t
, /* message_buffer */
53 gss_buffer_t
, /* message_token */
56 static OM_uint32 k5glue_verify
57 (void *, OM_uint32
*, /* minor_status */
58 gss_ctx_id_t
, /* context_handle */
59 gss_buffer_t
, /* message_buffer */
60 gss_buffer_t
, /* token_buffer */
61 int *, /* qop_state */
64 static OM_uint32 k5glue_seal
65 (void *, OM_uint32
*, /* minor_status */
66 gss_ctx_id_t
, /* context_handle */
67 int, /* conf_req_flag */
69 gss_buffer_t
, /* input_message_buffer */
70 int *, /* conf_state */
71 gss_buffer_t
, /* output_message_buffer */
74 static OM_uint32 k5glue_unseal
75 (void *, OM_uint32
*, /* minor_status */
76 gss_ctx_id_t
, /* context_handle */
77 gss_buffer_t
, /* input_message_buffer */
78 gss_buffer_t
, /* output_message_buffer */
79 int *, /* conf_state */
80 int *, /* qop_state */
83 static OM_uint32 k5glue_import_sec_context
84 (void *, OM_uint32
*, /* minor_status */
85 gss_buffer_t
, /* interprocess_token */
86 gss_ctx_id_t
*); /* context_handle */
90 static struct gss_config krb5_mechanism
=
91 {{9, "\052\206\110\206\367\022\001\002\002"},
96 k5glue_delete_sec_context
,
98 k5glue_import_sec_context
,
104 gss_mech_initialize()
106 return (&krb5_mechanism
);
111 * Module linkage information for the kernel.
113 extern struct mod_ops mod_miscops
;
115 static struct modlmisc modlmisc
= {
116 &mod_miscops
, "Krb5 GSS mechanism"
119 static struct modlinkage modlinkage
= {
126 static int krb5_fini_code
= EBUSY
;
132 gss_mechanism mech
, tmp
;
134 if ((retval
= mod_install(&modlinkage
)) != 0)
137 mech
= gss_mech_initialize();
139 mutex_enter(&__kgss_mech_lock
);
140 tmp
= __kgss_get_mechanism(&mech
->mech_type
);
144 "KRB5 GSS mechanism: mechanism already in table.\n");
146 if (tmp
->uses_kmod
== TRUE
) {
147 KRB5_LOG0(KRB5_INFO
, "KRB5 GSS mechanism: mechanism "
148 "table supports kernel operations!\n");
151 * keep us loaded, but let us be unloadable. This
152 * will give the developer time to trouble shoot
156 __kgss_add_mechanism(mech
);
157 ASSERT(__kgss_get_mechanism(&mech
->mech_type
) == mech
);
159 mutex_exit(&__kgss_mech_lock
);
167 int ret
= krb5_fini_code
;
170 ret
= (mod_remove(&modlinkage
));
176 _info(struct modinfo
*modinfop
)
178 return (mod_info(&modlinkage
, modinfop
));
183 k5glue_delete_sec_context(ctx
, minor_status
, context_handle
, output_token
,
186 OM_uint32
*minor_status
;
187 gss_ctx_id_t
*context_handle
;
188 gss_buffer_t output_token
;
189 OM_uint32 gssd_ctx_verifier
;
191 return (krb5_gss_delete_sec_context(minor_status
,
192 context_handle
, output_token
,
199 k5glue_import_sec_context(ctx
, minor_status
, interprocess_token
, context_handle
)
201 OM_uint32
*minor_status
;
202 gss_buffer_t interprocess_token
;
203 gss_ctx_id_t
*context_handle
;
205 return (krb5_gss_import_sec_context(minor_status
,
213 k5glue_seal(ctx
, minor_status
, context_handle
, conf_req_flag
, qop_req
,
214 input_message_buffer
, conf_state
, output_message_buffer
,
217 OM_uint32
*minor_status
;
218 gss_ctx_id_t context_handle
;
221 gss_buffer_t input_message_buffer
;
223 gss_buffer_t output_message_buffer
;
224 OM_uint32 gssd_ctx_verifier
;
226 return (krb5_gss_seal(minor_status
, context_handle
,
227 conf_req_flag
, qop_req
, input_message_buffer
,
228 conf_state
, output_message_buffer
, gssd_ctx_verifier
));
233 k5glue_sign(ctx
, minor_status
, context_handle
,
234 qop_req
, message_buffer
,
235 message_token
, gssd_ctx_verifier
)
237 OM_uint32
*minor_status
;
238 gss_ctx_id_t context_handle
;
240 gss_buffer_t message_buffer
;
241 gss_buffer_t message_token
;
242 OM_uint32 gssd_ctx_verifier
;
244 return (krb5_gss_sign(minor_status
, context_handle
,
245 qop_req
, message_buffer
, message_token
, gssd_ctx_verifier
));
250 k5glue_unseal(ctx
, minor_status
, context_handle
, input_message_buffer
,
251 output_message_buffer
, conf_state
, qop_state
, gssd_ctx_verifier
)
253 OM_uint32
*minor_status
;
254 gss_ctx_id_t context_handle
;
255 gss_buffer_t input_message_buffer
;
256 gss_buffer_t output_message_buffer
;
259 OM_uint32 gssd_ctx_verifier
;
261 return (krb5_gss_unseal(minor_status
, context_handle
,
262 input_message_buffer
, output_message_buffer
,
263 conf_state
, qop_state
, gssd_ctx_verifier
));
269 k5glue_verify(ctx
, minor_status
, context_handle
, message_buffer
,
270 token_buffer
, qop_state
, gssd_ctx_verifier
)
272 OM_uint32
*minor_status
;
273 gss_ctx_id_t context_handle
;
274 gss_buffer_t message_buffer
;
275 gss_buffer_t token_buffer
;
277 OM_uint32 gssd_ctx_verifier
;
279 return (krb5_gss_verify(minor_status
,
283 qop_state
, gssd_ctx_verifier
));