gssapi.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004-2007, 2009-2011, 2013  Internet Systems Consortium, Inc. ("ISC")
00003  * Copyright (C) 2000, 2001  Internet Software Consortium.
00004  *
00005  * Permission to use, copy, modify, and/or distribute this software for any
00006  * purpose with or without fee is hereby granted, provided that the above
00007  * copyright notice and this permission notice appear in all copies.
00008  *
00009  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
00010  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00011  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
00012  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
00013  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00014  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00015  * PERFORMANCE OF THIS SOFTWARE.
00016  */
00017 
00018 /* $Id: gssapi.h,v 1.16 2011/01/08 23:47:01 tbox Exp $ */
00019 
00020 #ifndef DST_GSSAPI_H
00021 #define DST_GSSAPI_H 1
00022 
00023 /*! \file dst/gssapi.h */
00024 
00025 #include <isc/formatcheck.h>
00026 #include <isc/lang.h>
00027 #include <isc/platform.h>
00028 #include <isc/types.h>
00029 #include <dns/types.h>
00030 
00031 #ifdef GSSAPI
00032 #ifdef WIN32
00033 /*
00034  * MSVC does not like macros in #include lines.
00035  */
00036 #include <gssapi/gssapi.h>
00037 #include <gssapi/gssapi_krb5.h>
00038 #else
00039 #include ISC_PLATFORM_GSSAPIHEADER
00040 #ifdef ISC_PLATFORM_GSSAPI_KRB5_HEADER
00041 #include ISC_PLATFORM_GSSAPI_KRB5_HEADER
00042 #endif
00043 #endif
00044 #ifndef GSS_SPNEGO_MECHANISM
00045 #define GSS_SPNEGO_MECHANISM ((void*)0)
00046 #endif
00047 #endif
00048 
00049 ISC_LANG_BEGINDECLS
00050 
00051 /***
00052  *** Types
00053  ***/
00054 
00055 /***
00056  *** Functions
00057  ***/
00058 
00059 isc_result_t
00060 dst_gssapi_acquirecred(dns_name_t *name, isc_boolean_t initiate,
00061                        gss_cred_id_t *cred);
00062 /*
00063  *      Acquires GSS credentials.
00064  *
00065  *      Requires:
00066  *      'name'      is a valid name, preferably one known by the GSS provider
00067  *      'initiate'  indicates whether the credentials are for initiating or
00068  *                  accepting contexts
00069  *      'cred'      is a pointer to NULL, which will be allocated with the
00070  *                  credential handle.  Call dst_gssapi_releasecred to free
00071  *                  the memory.
00072  *
00073  *      Returns:
00074  *              ISC_R_SUCCESS msg was successfully updated to include the
00075  *                                    query to be sent
00076  *              other             an error occurred while building the message
00077  */
00078 
00079 isc_result_t
00080 dst_gssapi_releasecred(gss_cred_id_t *cred);
00081 /*
00082  *      Releases GSS credentials.  Calling this function does release the
00083  *  memory allocated for the credential in dst_gssapi_acquirecred()
00084  *
00085  *      Requires:
00086  *      'mctx'  is a valid memory context
00087  *      'cred'  is a pointer to the credential to be released
00088  *
00089  *      Returns:
00090  *              ISC_R_SUCCESS   credential was released successfully
00091  *              other           an error occurred while releaseing
00092  *                              the credential
00093  */
00094 
00095 isc_result_t
00096 dst_gssapi_initctx(dns_name_t *name, isc_buffer_t *intoken,
00097                    isc_buffer_t *outtoken, gss_ctx_id_t *gssctx,
00098                    isc_mem_t *mctx, char **err_message);
00099 /*
00100  *      Initiates a GSS context.
00101  *
00102  *      Requires:
00103  *      'name'     is a valid name, preferably one known by the GSS
00104  *      provider
00105  *      'intoken'  is a token received from the acceptor, or NULL if
00106  *                 there isn't one
00107  *      'outtoken' is a buffer to receive the token generated by
00108  *                 gss_init_sec_context() to be sent to the acceptor
00109  *      'context'  is a pointer to a valid gss_ctx_id_t
00110  *                 (which may have the value GSS_C_NO_CONTEXT)
00111  *
00112  *      Returns:
00113  *              ISC_R_SUCCESS   msg was successfully updated to include the
00114  *                              query to be sent
00115  *              other           an error occurred while building the message
00116  *              *err_message    optional error message
00117  */
00118 
00119 isc_result_t
00120 dst_gssapi_acceptctx(gss_cred_id_t cred,
00121                      const char *gssapi_keytab,
00122                      isc_region_t *intoken, isc_buffer_t **outtoken,
00123                      gss_ctx_id_t *context, dns_name_t *principal,
00124                      isc_mem_t *mctx);
00125 /*
00126  *      Accepts a GSS context.
00127  *
00128  *      Requires:
00129  *      'mctx'     is a valid memory context
00130  *      'cred'     is the acceptor's valid GSS credential handle
00131  *      'intoken'  is a token received from the initiator
00132  *      'outtoken' is a pointer a buffer pointer used to return the token
00133  *                 generated by gss_accept_sec_context() to be sent to the
00134  *                 initiator
00135  *      'context'  is a valid pointer to receive the generated context handle.
00136  *                 On the initial call, it should be a pointer to NULL, which
00137  *                 will be allocated as a gss_ctx_id_t.  Subsequent calls
00138  *                 should pass in the handle generated on the first call.
00139  *                 Call dst_gssapi_releasecred to delete the context and free
00140  *                 the memory.
00141  *
00142  *      Requires:
00143  *              'outtoken' to != NULL && *outtoken == NULL.
00144  *
00145  *      Returns:
00146  *              ISC_R_SUCCESS   msg was successfully updated to include the
00147  *                              query to be sent
00148  *              other           an error occurred while building the message
00149  */
00150 
00151 isc_result_t
00152 dst_gssapi_deletectx(isc_mem_t *mctx, gss_ctx_id_t *gssctx);
00153 /*
00154  *      Destroys a GSS context.  This function deletes the context from the GSS
00155  *      provider and then frees the memory used by the context pointer.
00156  *
00157  *      Requires:
00158  *      'mctx'    is a valid memory context
00159  *      'context' is a valid GSS context
00160  *
00161  *      Returns:
00162  *              ISC_R_SUCCESS
00163  */
00164 
00165 
00166 void
00167 gss_log(int level, const char *fmt, ...)
00168 ISC_FORMAT_PRINTF(2, 3);
00169 /*
00170  * Logging function for GSS.
00171  *
00172  *  Requires
00173  *      'level' is the log level to be used, as an integer
00174  *      'fmt'   is a printf format specifier
00175  */
00176 
00177 char *
00178 gss_error_tostring(isc_uint32_t major, isc_uint32_t minor,
00179                    char *buf, size_t buflen);
00180 /*
00181  *      Render a GSS major status/minor status pair into a string
00182  *
00183  *      Requires:
00184  *      'major' is a GSS major status code
00185  *      'minor' is a GSS minor status code
00186  *
00187  *      Returns:
00188  *              A string containing the text representation of the error codes.
00189  *              Users should copy the string if they wish to keep it.
00190  */
00191 
00192 isc_boolean_t
00193 dst_gssapi_identitymatchesrealmkrb5(dns_name_t *signer, dns_name_t *name,
00194                               dns_name_t *realm);
00195 /*
00196  *      Compare a "signer" (in the format of a Kerberos-format Kerberos5
00197  *      principal: host/example.com@EXAMPLE.COM) to the realm name stored
00198  *      in "name" (which represents the realm name).
00199  *
00200  */
00201 
00202 isc_boolean_t
00203 dst_gssapi_identitymatchesrealmms(dns_name_t *signer, dns_name_t *name,
00204                             dns_name_t *realm);
00205 /*
00206  *      Compare a "signer" (in the format of a Kerberos-format Kerberos5
00207  *      principal: host/example.com@EXAMPLE.COM) to the realm name stored
00208  *      in "name" (which represents the realm name).
00209  *
00210  */
00211 
00212 ISC_LANG_ENDDECLS
00213 
00214 #endif /* DST_GSSAPI_H */

Generated on Tue Apr 28 17:40:57 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha