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__, _function_name_, \
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__, _function_name_, __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                                  _function_name_, __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__, _function_name_, \
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__, _function_name_, \
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                                  _function_name_, __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                 _function_name_, \
00106                 __LINE__, \
00107                 "%s", \
00108                 _tmp_str_)); \
00109     }
00110 
00111 #define GLOBUS_GSI_GSSAPI_ERRNO_ERROR_RESULT(_MIN_RESULT_, \
00112                                                _ERRORTYPE_, _ERRORSTR_) \
00113     { \
00114         char *                          _tmp_str_ = \
00115              globus_common_create_string _ERRORSTR_; \
00116         *_MIN_RESULT_ = (OM_uint32) globus_error_put( \
00117             globus_error_wrap_errno_error( \
00118                 GLOBUS_GSI_GSSAPI_MODULE, \
00119                 errno, \
00120                 _ERRORTYPE_, \
00121                 __FILE__, \
00122                 _function_name_, \
00123                 __LINE__, \
00124                 "%s", \
00125                 _tmp_str_)); \
00126         globus_libc_free(_tmp_str_); \
00127     }
00128 
00129 
00130 /* DEBUG MACROS */
00131 
00132 extern int                              globus_i_gsi_gssapi_debug_level;
00133 extern FILE *                           globus_i_gsi_gssapi_debug_fstream;
00134 extern globus_mutex_t                   globus_i_gssapi_activate_mutex;
00135 extern globus_bool_t                    globus_i_gssapi_active;
00136 
00137 
00138 #ifdef BUILD_DEBUG
00139 
00140 #define GLOBUS_I_GSI_GSSAPI_DEBUG(_LEVEL_) \
00141     (globus_i_gsi_gssapi_debug_level >= (_LEVEL_))
00142 
00143 #define GLOBUS_I_GSI_GSSAPI_DEBUG_FPRINTF(_LEVEL_, _MESSAGE_) \
00144 {                                                             \
00145     if (GLOBUS_I_GSI_GSSAPI_DEBUG(_LEVEL_))                   \
00146     {                                                         \
00147         globus_libc_fprintf _MESSAGE_;                        \
00148     }                                                         \
00149 } 
00150 
00151 #define GLOBUS_I_GSI_GSSAPI_DEBUG_FNPRINTF(_LEVEL_, _MESSAGE_) \
00152 { \
00153         if (GLOBUS_I_GSI_GSSAPI_DEBUG(_LEVEL_)) \
00154         { \
00155            char *                       _tmp_str_ = \
00156                globus_common_create_nstring _MESSAGE_; \
00157            globus_libc_fprintf(globus_i_gsi_gssapi_debug_fstream, \
00158                                "%s", _tmp_str_); \
00159            globus_libc_free(_tmp_str_); \
00160         } \
00161 }
00162 
00163 #define GLOBUS_I_GSI_GSSAPI_DEBUG_PRINT(_LEVEL_, _MESSAGE_) \
00164 {                                                           \
00165     if (GLOBUS_I_GSI_GSSAPI_DEBUG(_LEVEL_))                 \
00166     {                                                       \
00167         globus_libc_fprintf(                                \
00168             globus_i_gsi_gssapi_debug_fstream,              \
00169             "%s", _MESSAGE_);                               \
00170     }                                                       \
00171 }
00172  
00173 #define GLOBUS_I_GSI_GSSAPI_DEBUG_PRINT_OBJECT(_LEVEL_, _TYPE_, _OBJ_) \
00174 {                                                                      \
00175     if (GLOBUS_I_GSI_GSSAPI_DEBUG(_LEVEL_))                            \
00176     {                                                                  \
00177         _TYPE_##_print_fp(                                             \
00178             globus_i_gsi_gssapi_debug_fstream,                         \
00179             _OBJ_);                                                    \
00180     }                                                                  \
00181 }
00182 
00183 #else
00184 
00185 #define GLOBUS_I_GSI_GSSAPI_DEBUG(_LEVEL_) 0
00186 #define GLOBUS_I_GSI_GSSAPI_DEBUG_FPRINTF(_LEVEL_, _MESSAGE_)
00187 #define GLOBUS_I_GSI_GSSAPI_DEBUG_FNPRINTF(_LEVEL_, _MESSAGE_)
00188 #define GLOBUS_I_GSI_GSSAPI_DEBUG_PRINT(_LEVEL_, _MESSAGE_)
00189 #define GLOBUS_I_GSI_GSSAPI_DEBUG_PRINT_OBJECT(_LEVEL,_TYPE_, _OBJ_)
00190 
00191 #endif
00192 
00193 #define GLOBUS_I_GSI_GSSAPI_DEBUG_ENTER \
00194             GLOBUS_I_GSI_GSSAPI_DEBUG_FPRINTF( \
00195                 1, (globus_i_gsi_gssapi_debug_fstream, \
00196                     "%s entering\n", _function_name_))
00197 
00198 #define GLOBUS_I_GSI_GSSAPI_DEBUG_EXIT \
00199             GLOBUS_I_GSI_GSSAPI_DEBUG_FPRINTF( \
00200                 1, (globus_i_gsi_gssapi_debug_fstream, \
00201                     "%s exiting: major_status=%d\n", \
00202                     _function_name_, (int)major_status))
00203 
00204 #define GLOBUS_I_GSI_GSSAPI_INTERNAL_DEBUG_EXIT \
00205             GLOBUS_I_GSI_GSSAPI_DEBUG_FPRINTF( \
00206                 1, (globus_i_gsi_gssapi_debug_fstream, \
00207                     "%s exiting\n", \
00208                     _function_name_))
00209 
00210 extern int                              globus_i_gsi_gssapi_force_tls;
00211 
00212 typedef enum
00213 {
00214     GLOBUS_I_GSI_GSS_DEFAULT_CONTEXT,
00215     GLOBUS_I_GSI_GSS_ANON_CONTEXT
00216 } globus_i_gsi_gss_context_type_t;
00217 
00218 OM_uint32
00219 globus_i_gsi_gss_copy_name_to_name(
00220     OM_uint32 *                         minor_status,
00221     gss_name_desc **                    output,
00222     const gss_name_desc *               input);
00223 
00224 OM_uint32
00225 globus_i_gsi_gss_create_and_fill_context(
00226     OM_uint32 *                         minor_status,
00227     gss_ctx_id_desc **                  context_handle,
00228     gss_cred_id_desc *                  cred_handle,
00229     const gss_cred_usage_t              cred_usage,
00230     OM_uint32                           req_flags);
00231 
00232 OM_uint32
00233 globus_i_gsi_gss_create_anonymous_cred(
00234     OM_uint32 *                         minor_status,
00235     gss_cred_id_t *                     output_cred_handle,
00236     const gss_cred_usage_t              cred_usage);
00237 
00238 OM_uint32
00239 globus_i_gsi_gss_cred_read_bio(
00240     OM_uint32 *                         minor_status,
00241     const gss_cred_usage_t              cred_usage,
00242     gss_cred_id_t *                     cred_id_handle,
00243     BIO *                               bp);
00244 
00245 OM_uint32
00246 globus_i_gsi_gss_cred_read(
00247     OM_uint32 *                         minor_status,
00248     const gss_cred_usage_t              cred_usage,
00249     gss_cred_id_t *                     cred_handle,
00250     const X509_NAME *                   desired_subject);
00251 
00252 OM_uint32
00253 globus_i_gsi_gss_create_cred(
00254     OM_uint32 *                         minor_status,
00255     const gss_cred_usage_t              cred_usage,
00256     gss_cred_id_t *                     output_cred_handle_P,
00257     globus_gsi_cred_handle_t *          cred_handle);
00258 
00259 int globus_i_gsi_gss_verify_extensions_callback(
00260     globus_gsi_callback_data_t          callback_data,
00261     X509_EXTENSION *                    extension);
00262 
00263 OM_uint32
00264 globus_i_gsi_gss_handshake(
00265     OM_uint32 *                         minor_status,
00266     gss_ctx_id_desc *                   context_handle);
00267 
00268 OM_uint32
00269 globus_i_gsi_gss_get_token(
00270     OM_uint32 *                         minor_status,
00271     const gss_ctx_id_desc *             context_handle,
00272     BIO *                               bio,
00273     const gss_buffer_t                  output_token);
00274 
00275 OM_uint32
00276 globus_i_gsi_gss_put_token(
00277     OM_uint32 *                         minor_status,
00278     const gss_ctx_id_desc *             context_handle,
00279     BIO *                               bio,
00280     const gss_buffer_t                  input_token);
00281 
00282 OM_uint32
00283 globus_i_gsi_gss_retrieve_peer(
00284     OM_uint32 *                         minor_status,
00285     gss_ctx_id_desc *                   context_handle,
00286     const gss_cred_usage_t              cred_usage);
00287 
00288 #if LINK_WITH_INTERNAL_OPENSSL_API
00289 OM_uint32
00290 globus_i_gsi_gss_SSL_write_bio(
00291     OM_uint32 *                         minor_status,
00292     gss_ctx_id_desc *                   context,
00293     BIO *                               bp);
00294 
00295 OM_uint32
00296 globus_i_gsi_gss_SSL_read_bio(
00297     OM_uint32 *                         minor_status,
00298     gss_ctx_id_desc *                   context,
00299     BIO *                               bp);
00300 #endif
00301 
00302 OM_uint32
00303 globus_i_gsi_gss_get_context_goodtill(
00304     OM_uint32 *                         minor_status,
00305     gss_ctx_id_t                        context,
00306     time_t *                            goodtill);
00307 
00308 OM_uint32
00309 globus_i_gsi_gssapi_init_ssl_context(
00310     OM_uint32 *                         minor_status,
00311     gss_cred_id_t                       credential,
00312     globus_i_gsi_gss_context_type_t     anon_ctx);
00313 
00314 globus_result_t
00315 globus_i_gsi_gssapi_openssl_error_result(
00316     int                                 error_type,
00317     const char *                        filename,
00318     const char *                        function_name,
00319     int                                 line_number,
00320     const char *                        short_desc,
00321     const char *                        long_desc);
00322 
00323 globus_result_t
00324 globus_i_gsi_gssapi_error_result(
00325     const OM_uint32                     minor_status,
00326     const char *                        filename,
00327     const char *                        function_name,
00328     int                                 line_number,
00329     const char *                        short_desc,
00330     const char *                        long_desc);
00331 
00332 globus_result_t
00333 globus_i_gsi_gssapi_error_chain_result(
00334     globus_result_t                     chain_result,
00335     int                                 error_type,
00336     const char *                        filename,
00337     const char *                        function_name,
00338     int                                 line_number,
00339     const char *                        short_desc,
00340     const char *                        long_desc);
00341 
00342 globus_result_t
00343 globus_i_gsi_gssapi_error_join_chains_result(
00344     globus_result_t                     outer_error,
00345     globus_result_t                     inner_error);
00346 
00347 OM_uint32
00348 globus_i_gsi_gssapi_get_hostname(
00349     OM_uint32 *                         minor_status,
00350     gss_name_desc *                     name);
00351 
00352 
00353 typedef enum
00354 {
00355     GSS_I_COMPATIBILITY_HYBRID,
00356     GSS_I_COMPATIBILITY_STRICT_GT2,
00357     GSS_I_COMPATIBILITY_STRICT_RFC2818
00358 }
00359 gss_i_name_compatibility_mode_t;
00360 
00361 extern gss_i_name_compatibility_mode_t  gss_i_name_compatibility_mode;
00362 
00363 #endif /* GLOBUS_I_GSI_GSS_UTILS_H */

Generated on 14 Nov 2014 for globus_gssapi_gsi by  doxygen 1.4.7