xref: /freebsd/crypto/krb5/doc/html/_sources/plugindev/gssapi.rst.txt (revision 7f2fe78b9dd5f51c821d771b63d2e096f6fd49e9)
1*7f2fe78bSCy SchubertGSSAPI mechanism interface
2*7f2fe78bSCy Schubert==========================
3*7f2fe78bSCy Schubert
4*7f2fe78bSCy SchubertThe GSSAPI library in MIT krb5 can load mechanism modules to augment
5*7f2fe78bSCy Schubertthe set of built-in mechanisms.
6*7f2fe78bSCy Schubert
7*7f2fe78bSCy Schubert.. note: The GSSAPI loadable mechanism interface does not follow the
8*7f2fe78bSCy Schubert         normal conventions for MIT krb5 pluggable interfaces.
9*7f2fe78bSCy Schubert
10*7f2fe78bSCy SchubertA mechanism module is a Unix shared object or Windows DLL, built
11*7f2fe78bSCy Schubertseparately from the krb5 tree.  Modules are loaded according to the
12*7f2fe78bSCy SchubertGSS mechanism config files described in :ref:`gssapi_plugin_config`.
13*7f2fe78bSCy Schubert
14*7f2fe78bSCy SchubertFor the most part, a GSSAPI mechanism module exports the same
15*7f2fe78bSCy Schubertfunctions as would a GSSAPI implementation itself, with the same
16*7f2fe78bSCy Schubertfunction signatures.  The mechanism selection layer within the GSSAPI
17*7f2fe78bSCy Schubertlibrary (called the "mechglue") will dispatch calls from the
18*7f2fe78bSCy Schubertapplication to the module if the module's mechanism is requested.  If
19*7f2fe78bSCy Schuberta module does not wish to implement a GSSAPI extension, it can simply
20*7f2fe78bSCy Schubertrefrain from exporting it, and the mechglue will fail gracefully if
21*7f2fe78bSCy Schubertthe application calls that function.
22*7f2fe78bSCy Schubert
23*7f2fe78bSCy SchubertThe mechglue does not invoke a module's **gss_add_cred**,
24*7f2fe78bSCy Schubert**gss_add_cred_from**, **gss_add_cred_impersonate_name**, or
25*7f2fe78bSCy Schubert**gss_add_cred_with_password** function.  A mechanism only needs to
26*7f2fe78bSCy Schubertimplement the "acquire" variants of those functions.
27*7f2fe78bSCy Schubert
28*7f2fe78bSCy SchubertA module does not need to coordinate its minor status codes with those
29*7f2fe78bSCy Schubertof other mechanisms.  If the mechglue detects conflicts, it will map
30*7f2fe78bSCy Schubertthe mechanism's status codes onto unique values, and then map them
31*7f2fe78bSCy Schubertback again when **gss_display_status** is called.
32*7f2fe78bSCy Schubert
33*7f2fe78bSCy Schubert
34*7f2fe78bSCy SchubertNegoEx modules
35*7f2fe78bSCy Schubert--------------
36*7f2fe78bSCy Schubert
37*7f2fe78bSCy SchubertSome Windows GSSAPI mechanisms can only be negotiated via a Microsoft
38*7f2fe78bSCy Schubertextension to SPNEGO called NegoEx.  Beginning with release 1.18,
39*7f2fe78bSCy Schubertmechanism modules can support NegoEx as follows:
40*7f2fe78bSCy Schubert
41*7f2fe78bSCy Schubert* Implement the gssspi_query_meta_data(), gssspi_exchange_meta_data(),
42*7f2fe78bSCy Schubert  and gssspi_query_mechanism_info() SPIs declared in
43*7f2fe78bSCy Schubert  ``<gssapi/gssapi_ext.h>``.
44*7f2fe78bSCy Schubert
45*7f2fe78bSCy Schubert* Implement gss_inquire_sec_context_by_oid() and answer the
46*7f2fe78bSCy Schubert  **GSS_C_INQ_NEGOEX_KEY** and **GSS_C_INQ_NEGOEX_VERIFY_KEY** OIDs
47*7f2fe78bSCy Schubert  to provide the checksum keys for outgoing and incoming checksums,
48*7f2fe78bSCy Schubert  respectively.  The answer must be in two buffers: the first buffer
49*7f2fe78bSCy Schubert  contains the key contents, and the second buffer contains the key
50*7f2fe78bSCy Schubert  encryption type as a four-byte little-endian integer.
51*7f2fe78bSCy Schubert
52*7f2fe78bSCy SchubertBy default, NegoEx mechanisms will not be directly negotiated via
53*7f2fe78bSCy SchubertSPNEGO.  If direct SPNEGO negotiation is required for
54*7f2fe78bSCy Schubertinteroperability, implement gss_inquire_attrs_for_mech() and assert
55*7f2fe78bSCy Schubertthe GSS_C_MA_NEGOEX_AND_SPNEGO attribute (along with any applicable
56*7f2fe78bSCy SchubertRFC 5587 attributes).
57*7f2fe78bSCy Schubert
58*7f2fe78bSCy Schubert
59*7f2fe78bSCy SchubertInterposer modules
60*7f2fe78bSCy Schubert------------------
61*7f2fe78bSCy Schubert
62*7f2fe78bSCy SchubertThe mechglue also supports a kind of loadable module, called an
63*7f2fe78bSCy Schubertinterposer module, which intercepts calls to existing mechanisms
64*7f2fe78bSCy Schubertrather than implementing a new mechanism.
65*7f2fe78bSCy Schubert
66*7f2fe78bSCy SchubertAn interposer module must export the symbol **gss_mech_interposer**
67*7f2fe78bSCy Schubertwith the following signature::
68*7f2fe78bSCy Schubert
69*7f2fe78bSCy Schubert    gss_OID_set gss_mech_interposer(gss_OID mech_type);
70*7f2fe78bSCy Schubert
71*7f2fe78bSCy SchubertThis function is invoked with the OID of the interposer mechanism as
72*7f2fe78bSCy Schubertspecified in the mechanism config file, and returns a set of mechanism
73*7f2fe78bSCy SchubertOIDs to be interposed.  The returned OID set must have been created
74*7f2fe78bSCy Schubertusing the mechglue's gss_create_empty_oid_set and
75*7f2fe78bSCy Schubertgss_add_oid_set_member functions.
76*7f2fe78bSCy Schubert
77*7f2fe78bSCy SchubertAn interposer module must use the prefix ``gssi_`` for the GSSAPI
78*7f2fe78bSCy Schubertfunctions it exports, instead of the prefix ``gss_``.  In most cases,
79*7f2fe78bSCy Schubertunexported ``gssi_`` functions will result in failure from their
80*7f2fe78bSCy Schubertcorresponding ``gss_`` calls.
81*7f2fe78bSCy Schubert
82*7f2fe78bSCy SchubertAn interposer module can link against the GSSAPI library in order to
83*7f2fe78bSCy Schubertmake calls to the original mechanism.  To do so, it must specify a
84*7f2fe78bSCy Schubertspecial mechanism OID which is the concatention of the interposer's
85*7f2fe78bSCy Schubertown OID byte string and the original mechanism's OID byte string.
86*7f2fe78bSCy Schubert
87*7f2fe78bSCy SchubertFunctions that do not accept a mechanism argument directly require no
88*7f2fe78bSCy Schubertspecial handling, with the following exceptions:
89*7f2fe78bSCy Schubert
90*7f2fe78bSCy SchubertSince **gss_accept_sec_context** does not accept a mechanism argument,
91*7f2fe78bSCy Schubertan interposer mechanism must, in order to invoke the original
92*7f2fe78bSCy Schubertmechanism's function, acquire a credential for the concatenated OID
93*7f2fe78bSCy Schubertand pass that as the *verifier_cred_handle* parameter.
94*7f2fe78bSCy Schubert
95*7f2fe78bSCy SchubertSince **gss_import_name**, **gss_import_cred**, and
96*7f2fe78bSCy Schubert**gss_import_sec_context** do not accept mechanism parameters, the SPI
97*7f2fe78bSCy Schuberthas been extended to include variants which do.  This allows the
98*7f2fe78bSCy Schubertinterposer module to know which mechanism should be used to interpret
99*7f2fe78bSCy Schubertthe token.  These functions have the following signatures::
100*7f2fe78bSCy Schubert
101*7f2fe78bSCy Schubert    OM_uint32 gssi_import_sec_context_by_mech(OM_uint32 *minor_status,
102*7f2fe78bSCy Schubert        gss_OID desired_mech, gss_buffer_t interprocess_token,
103*7f2fe78bSCy Schubert        gss_ctx_id_t *context_handle);
104*7f2fe78bSCy Schubert
105*7f2fe78bSCy Schubert    OM_uint32 gssi_import_name_by_mech(OM_uint32 *minor_status,
106*7f2fe78bSCy Schubert        gss_OID mech_type, gss_buffer_t input_name_buffer,
107*7f2fe78bSCy Schubert        gss_OID input_name_type, gss_name_t output_name);
108*7f2fe78bSCy Schubert
109*7f2fe78bSCy Schubert    OM_uint32 gssi_import_cred_by_mech(OM_uint32 *minor_status,
110*7f2fe78bSCy Schubert        gss_OID mech_type, gss_buffer_t token,
111*7f2fe78bSCy Schubert        gss_cred_id_t *cred_handle);
112*7f2fe78bSCy Schubert
113*7f2fe78bSCy SchubertTo re-enter the original mechanism when importing tokens for the above
114*7f2fe78bSCy Schubertfunctions, the interposer module must wrap the mechanism token in the
115*7f2fe78bSCy Schubertmechglue's format, using the concatenated OID (except in
116*7f2fe78bSCy Schubert**gss_import_name**).  The mechglue token formats are:
117*7f2fe78bSCy Schubert
118*7f2fe78bSCy Schubert* For **gss_import_sec_context**, a four-byte OID length in big-endian
119*7f2fe78bSCy Schubert  order, followed by the concatenated OID, followed by the mechanism
120*7f2fe78bSCy Schubert  token.
121*7f2fe78bSCy Schubert
122*7f2fe78bSCy Schubert* For **gss_import_name**, the bytes 04 01, followed by a two-byte OID
123*7f2fe78bSCy Schubert  length in big-endian order, followed by the mechanism OID, followed
124*7f2fe78bSCy Schubert  by a four-byte token length in big-endian order, followed by the
125*7f2fe78bSCy Schubert  mechanism token.  Unlike most uses of OIDs in the API, the mechanism
126*7f2fe78bSCy Schubert  OID encoding must include the DER tag and length for an object
127*7f2fe78bSCy Schubert  identifier (06 followed by the DER length of the OID byte string),
128*7f2fe78bSCy Schubert  and this prefix must be included in the two-byte OID length.
129*7f2fe78bSCy Schubert  input_name_type must also be set to GSS_C_NT_EXPORT_NAME.
130*7f2fe78bSCy Schubert
131*7f2fe78bSCy Schubert* For **gss_import_cred**, a four-byte OID length in big-endian order,
132*7f2fe78bSCy Schubert  followed by the concatenated OID, followed by a four-byte token
133*7f2fe78bSCy Schubert  length in big-endian order, followed by the mechanism token.  This
134*7f2fe78bSCy Schubert  sequence may be repeated multiple times.
135