globus_i_gsi_gss_utils.h

00001 /*
00002  * Copyright 1999-2006 University of Chicago
00003  * 
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  * 
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef GLOBUS_I_GSI_GSS_UTILS_H
00018 #define GLOBUS_I_GSI_GSS_UTILS_H
00019 
00020 #ifndef GLOBUS_DONT_DOCUMENT_INTERNAL
00021 
00025 #endif
00026 
00027 #include "gssapi.h"
00028 #include "gssapi_openssl.h"
00029 
00030 /* ERROR MACROS */
00031 
00032 #define GLOBUS_GSI_GSSAPI_ERROR_RESULT(_MIN_RESULT_, _MIN_, \
00033                                        _ERRSTR_) \
00034     if (_MIN_RESULT_ != NULL) \
00035     { \
00036          char *                         tmpstr = \
00037              globus_common_create_string _ERRSTR_; \
00038          *_MIN_RESULT_ = (OM_uint32) globus_i_gsi_gssapi_error_result( \
00039              _MIN_, __FILE__, __func__, \
00040              __LINE__, tmpstr, NULL); \
00041          globus_libc_free(tmpstr); \
00042     }
00043 
00044 #define GLOBUS_GSI_GSSAPI_OPENSSL_ERROR_RESULT(_MIN_RESULT_, \
00045                                                _ERRORTYPE_, _ERRORSTR_) \
00046     { \
00047          char *                         tmpstr = \
00048              globus_common_create_string _ERRORSTR_; \
00049          *_MIN_RESULT_ = \
00050              (OM_uint32) globus_i_gsi_gssapi_openssl_error_result( \
00051              _ERRORTYPE_, __FILE__, __func__, __LINE__, tmpstr, NULL); \
00052          globus_libc_free(tmpstr); \
00053     }
00054 
00055 #define GLOBUS_GSI_GSSAPI_ERROR_CHAIN_RESULT(_MIN_RESULT_, _TOP_RESULT_, \
00056                                              _ERRORTYPE_) \
00057     *_MIN_RESULT_ = (OM_uint32) globus_i_gsi_gssapi_error_chain_result( \
00058                                  (globus_result_t)_TOP_RESULT_, \
00059                                  _ERRORTYPE_, __FILE__, \
00060                                  __func__, __LINE__, NULL, NULL)
00061 
00062 #define GLOBUS_GSI_GSSAPI_LONG_ERROR_RESULT(_MIN_RESULT_, _MIN_, \
00063                                             _ERRSTR_, _LONG_DESC_) \
00064     { \
00065          char *                         tmpstr = \
00066              globus_common_create_string _ERRSTR_; \
00067          *_MIN_RESULT_ = (OM_uint32) globus_i_gsi_gssapi_error_result( \
00068              _MIN_, __FILE__, __func__, \
00069              __LINE__, tmpstr, _LONG_DESC_); \
00070          globus_libc_free(tmpstr); \
00071     }
00072 
00073 #define GLOBUS_GSI_GSSAPI_OPENSSL_LONG_ERROR_RESULT(_MIN_RESULT_, \
00074                                                     _ERRORTYPE_, \
00075                                                     _ERRORSTR_, \
00076                                                     _LONG_DESC_) \
00077     { \
00078          char *                         tmpstr = \
00079              globus_common_create_string _ERRORSTR_; \
00080          *_MIN_RESULT_ = \
00081              (OM_uint32) globus_i_gsi_gssapi_openssl_error_result( \
00082              _ERRORTYPE_, __FILE__, __func__, \
00083              __LINE__, tmpstr, _LONG_DESC_); \
00084          globus_libc_free(tmpstr); \
00085     }
00086 
00087 #define GLOBUS_GSI_GSSAPI_LONG_ERROR_CHAIN_RESULT(_MIN_RESULT_, _TOP_RESULT_, \
00088                                                   _ERRORTYPE_, _LONG_DESC_) \
00089     *_MIN_RESULT_ = (OM_uint32) globus_i_gsi_gssapi_error_chain_result( \
00090                                  (globus_result_t)_TOP_RESULT_, \
00091                                  _ERRORTYPE_, __FILE__, \
00092                                  __func__, __LINE__, NULL, _LONG_DESC_)
00093 
00094 #define GLOBUS_GSI_GSSAPI_MALLOC_ERROR(_MIN_RESULT_) \
00095     { \
00096         char *                          _tmp_str_ = \
00097         globus_l_gsi_gssapi_error_strings[ \
00098             GLOBUS_GSI_GSSAPI_ERROR_OUT_OF_MEMORY]; \
00099         *_MIN_RESULT_ = (OM_uint32) globus_error_put( \
00100             globus_error_wrap_errno_error( \
00101                 GLOBUS_GSI_GSSAPI_MODULE, \
00102                 errno, \
00103                 GLOBUS_GSI_GSSAPI_ERROR_OUT_OF_MEMORY, \
00104                 __FILE__, \
00105                 __func__, \
00106                 __LINE__, \
00107                 "%s", \
00108                 _tmp_str_)); \
00109     }
00110 
00111 
00112 /* DEBUG MACROS */
00113 
00114 extern int                              globus_i_gsi_gssapi_debug_level;
00115 extern FILE *                           globus_i_gsi_gssapi_debug_fstream;
00116 extern globus_mutex_t                   globus_i_gssapi_activate_mutex;
00117 extern globus_bool_t                    globus_i_gssapi_active;
00118 
00119 
00120 #ifdef BUILD_DEBUG
00121 
00122 #define GLOBUS_I_GSI_GSSAPI_DEBUG(_LEVEL_) \
00123     (globus_i_gsi_gssapi_debug_level >= (_LEVEL_))
00124 
00125 #define GLOBUS_I_GSI_GSSAPI_DEBUG_FPRINTF(_LEVEL_, _MESSAGE_) \
00126 {                                                             \
00127     if (GLOBUS_I_GSI_GSSAPI_DEBUG(_LEVEL_))                   \
00128     {                                                         \
00129         globus_libc_fprintf _MESSAGE_;                        \
00130     }                                                         \
00131 } 
00132 
00133 #define GLOBUS_I_GSI_GSSAPI_DEBUG_FNPRINTF(_LEVEL_, _MESSAGE_) \
00134 { \
00135         if (GLOBUS_I_GSI_GSSAPI_DEBUG(_LEVEL_)) \
00136         { \
00137            char *                       _tmp_str_ = \
00138                globus_common_create_nstring _MESSAGE_; \
00139            globus_libc_fprintf(globus_i_gsi_gssapi_debug_fstream, \
00140                                "%s", _tmp_str_); \
00141            globus_libc_free(_tmp_str_); \
00142         } \
00143 }
00144 
00145 #define GLOBUS_I_GSI_GSSAPI_DEBUG_PRINT(_LEVEL_, _MESSAGE_) \
00146 {                                                           \
00147     if (GLOBUS_I_GSI_GSSAPI_DEBUG(_LEVEL_))                 \
00148     {                                                       \
00149         globus_libc_fprintf(                                \
00150             globus_i_gsi_gssapi_debug_fstream,              \
00151             "%s", _MESSAGE_);                               \
00152     }                                                       \
00153 }
00154  
00155 #define GLOBUS_I_GSI_GSSAPI_DEBUG_PRINT_OBJECT(_LEVEL_, _TYPE_, _OBJ_) \
00156 {                                                                      \
00157     if (GLOBUS_I_GSI_GSSAPI_DEBUG(_LEVEL_))                            \
00158     {                                                                  \
00159         _TYPE_##_print_fp(                                             \
00160             globus_i_gsi_gssapi_debug_fstream,                         \
00161             _OBJ_);                                                    \
00162     }                                                                  \
00163 }
00164 
00165 #else
00166 
00167 #define GLOBUS_I_GSI_GSSAPI_DEBUG(_LEVEL_) 0
00168 #define GLOBUS_I_GSI_GSSAPI_DEBUG_FPRINTF(_LEVEL_, _MESSAGE_)
00169 #define GLOBUS_I_GSI_GSSAPI_DEBUG_FNPRINTF(_LEVEL_, _MESSAGE_)
00170 #define GLOBUS_I_GSI_GSSAPI_DEBUG_PRINT(_LEVEL_, _MESSAGE_)
00171 #define GLOBUS_I_GSI_GSSAPI_DEBUG_PRINT_OBJECT(_LEVEL,_TYPE_, _OBJ_)
00172 
00173 #endif
00174 
00175 #define GLOBUS_I_GSI_GSSAPI_DEBUG_ENTER \
00176             GLOBUS_I_GSI_GSSAPI_DEBUG_FPRINTF( \
00177                 1, (globus_i_gsi_gssapi_debug_fstream, \
00178                     "%s entering\n", __func__))
00179 
00180 #define GLOBUS_I_GSI_GSSAPI_DEBUG_EXIT \
00181             GLOBUS_I_GSI_GSSAPI_DEBUG_FPRINTF( \
00182                 1, (globus_i_gsi_gssapi_debug_fstream, \
00183                     "%s exiting: major_status=%d\n", \
00184                     __func__, (int)major_status))
00185 
00186 #define GLOBUS_I_GSI_GSSAPI_INTERNAL_DEBUG_EXIT \
00187             GLOBUS_I_GSI_GSSAPI_DEBUG_FPRINTF( \
00188                 1, (globus_i_gsi_gssapi_debug_fstream, \
00189                     "%s exiting\n", \
00190                     __func__))
00191 
00192 extern int                              globus_i_gsi_gssapi_force_tls;
00193 extern const char *                     globus_i_gsi_gssapi_cipher_list;
00194 extern globus_bool_t                    globus_i_gsi_gssapi_server_cipher_order;
00195 
00196 typedef enum
00197 {
00198     GLOBUS_I_GSI_GSS_DEFAULT_CONTEXT,
00199     GLOBUS_I_GSI_GSS_ANON_CONTEXT
00200 } globus_i_gsi_gss_context_type_t;
00201 
00202 OM_uint32
00203 globus_i_gsi_gss_copy_name_to_name(
00204     OM_uint32 *                         minor_status,
00205     gss_name_desc **                    output,
00206     const gss_name_desc *               input);
00207 
00208 OM_uint32
00209 globus_i_gsi_gss_create_and_fill_context(
00210     OM_uint32 *                         minor_status,
00211     gss_ctx_id_desc **                  context_handle,
00212     gss_OID                             mech,
00213     gss_cred_id_desc *                  cred_handle,
00214     const gss_cred_usage_t              cred_usage,
00215     OM_uint32                           req_flags);
00216 
00217 OM_uint32
00218 globus_i_gsi_gss_create_anonymous_cred(
00219     OM_uint32 *                         minor_status,
00220     gss_cred_id_t *                     output_cred_handle,
00221     const gss_cred_usage_t              cred_usage);
00222 
00223 OM_uint32
00224 globus_i_gsi_gss_cred_read_bio(
00225     OM_uint32 *                         minor_status,
00226     const gss_cred_usage_t              cred_usage,
00227     gss_cred_id_t *                     cred_id_handle,
00228     BIO *                               bp);
00229 
00230 OM_uint32
00231 globus_i_gsi_gss_cred_read(
00232     OM_uint32 *                         minor_status,
00233     const gss_cred_usage_t              cred_usage,
00234     gss_cred_id_t *                     cred_handle,
00235     const X509_NAME *                   desired_subject);
00236 
00237 OM_uint32
00238 globus_i_gsi_gss_create_cred(
00239     OM_uint32 *                         minor_status,
00240     const gss_cred_usage_t              cred_usage,
00241     gss_cred_id_t *                     output_cred_handle_P,
00242     globus_gsi_cred_handle_t *          cred_handle);
00243 
00244 int globus_i_gsi_gss_verify_extensions_callback(
00245     globus_gsi_callback_data_t          callback_data,
00246     X509_EXTENSION *                    extension);
00247 
00248 OM_uint32
00249 globus_i_gsi_gss_handshake(
00250     OM_uint32 *                         minor_status,
00251     gss_ctx_id_desc *                   context_handle);
00252 
00253 OM_uint32
00254 globus_i_gsi_gss_get_token(
00255     OM_uint32 *                         minor_status,
00256     const gss_ctx_id_desc *             context_handle,
00257     BIO *                               bio,
00258     const gss_buffer_t                  output_token);
00259 
00260 OM_uint32
00261 globus_i_gsi_gss_put_token(
00262     OM_uint32 *                         minor_status,
00263     const gss_ctx_id_desc *             context_handle,
00264     BIO *                               bio,
00265     const gss_buffer_t                  input_token);
00266 
00267 OM_uint32
00268 globus_i_gsi_gss_retrieve_peer(
00269     OM_uint32 *                         minor_status,
00270     gss_ctx_id_desc *                   context_handle,
00271     const gss_cred_usage_t              cred_usage);
00272 
00273 #if LINK_WITH_INTERNAL_OPENSSL_API
00274 OM_uint32
00275 globus_i_gsi_gss_SSL_write_bio(
00276     OM_uint32 *                         minor_status,
00277     gss_ctx_id_desc *                   context,
00278     BIO *                               bp);
00279 
00280 OM_uint32
00281 globus_i_gsi_gss_SSL_read_bio(
00282     OM_uint32 *                         minor_status,
00283     gss_ctx_id_desc *                   context,
00284     BIO *                               bp);
00285 #endif
00286 
00287 OM_uint32
00288 globus_i_gsi_gss_get_context_goodtill(
00289     OM_uint32 *                         minor_status,
00290     gss_ctx_id_t                        context,
00291     time_t *                            goodtill);
00292 
00293 OM_uint32
00294 globus_i_gsi_gssapi_init_ssl_context(
00295     OM_uint32 *                         minor_status,
00296     gss_cred_id_t                       credential,
00297     globus_i_gsi_gss_context_type_t     anon_ctx);
00298 
00299 globus_result_t
00300 globus_i_gsi_gssapi_openssl_error_result(
00301     int                                 error_type,
00302     const char *                        filename,
00303     const char *                        function_name,
00304     int                                 line_number,
00305     const char *                        short_desc,
00306     const char *                        long_desc);
00307 
00308 globus_result_t
00309 globus_i_gsi_gssapi_error_result(
00310     const OM_uint32                     minor_status,
00311     const char *                        filename,
00312     const char *                        function_name,
00313     int                                 line_number,
00314     const char *                        short_desc,
00315     const char *                        long_desc);
00316 
00317 globus_result_t
00318 globus_i_gsi_gssapi_error_chain_result(
00319     globus_result_t                     chain_result,
00320     int                                 error_type,
00321     const char *                        filename,
00322     const char *                        function_name,
00323     int                                 line_number,
00324     const char *                        short_desc,
00325     const char *                        long_desc);
00326 
00327 globus_result_t
00328 globus_i_gsi_gssapi_error_join_chains_result(
00329     globus_result_t                     outer_error,
00330     globus_result_t                     inner_error);
00331 
00332 OM_uint32
00333 globus_i_gsi_gssapi_get_hostname(
00334     OM_uint32 *                         minor_status,
00335     gss_name_desc *                     name);
00336 
00337 
00338 typedef enum
00339 {
00340     GSS_I_COMPATIBILITY_HYBRID,
00341     GSS_I_COMPATIBILITY_STRICT_GT2,
00342     GSS_I_COMPATIBILITY_STRICT_RFC2818
00343 }
00344 gss_i_name_compatibility_mode_t;
00345 
00346 extern gss_i_name_compatibility_mode_t  gss_i_name_compatibility_mode;
00347 
00348 #endif /* GLOBUS_I_GSI_GSS_UTILS_H */

Generated on 10 Mar 2017 for globus_gssapi_gsi by  doxygen 1.4.7