00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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
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
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 3, (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 3, (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 3, (globus_i_gsi_gssapi_debug_fstream, \
00189 "%s exiting\n", \
00190 __func__))
00191
00192 extern int globus_i_gsi_gssapi_min_tls_protocol;
00193 extern int globus_i_gsi_gssapi_max_tls_protocol;
00194 extern const char * globus_i_gsi_gssapi_cipher_list;
00195 extern globus_bool_t globus_i_gsi_gssapi_server_cipher_order;
00196 extern uid_t globus_i_gsi_gssapi_vhost_cred_owner;
00197
00198 typedef enum
00199 {
00200 GLOBUS_I_GSI_GSS_DEFAULT_CONTEXT,
00201 GLOBUS_I_GSI_GSS_ANON_CONTEXT
00202 } globus_i_gsi_gss_context_type_t;
00203
00204 OM_uint32
00205 globus_i_gsi_gss_copy_name_to_name(
00206 OM_uint32 * minor_status,
00207 gss_name_desc ** output,
00208 const gss_name_desc * input);
00209
00210 OM_uint32
00211 globus_i_gsi_gss_create_and_fill_context(
00212 OM_uint32 * minor_status,
00213 gss_ctx_id_desc ** context_handle,
00214 gss_OID mech,
00215 const gss_name_t target_name,
00216 gss_cred_id_desc * cred_handle,
00217 const gss_cred_usage_t cred_usage,
00218 OM_uint32 req_flags);
00219
00220 OM_uint32
00221 globus_i_gsi_gss_create_anonymous_cred(
00222 OM_uint32 * minor_status,
00223 gss_cred_id_t * output_cred_handle,
00224 const gss_cred_usage_t cred_usage);
00225
00226 OM_uint32
00227 globus_i_gsi_gss_cred_read_bio(
00228 OM_uint32 * minor_status,
00229 const gss_cred_usage_t cred_usage,
00230 gss_cred_id_t * cred_id_handle,
00231 BIO * bp);
00232
00233 OM_uint32
00234 globus_i_gsi_gss_cred_read(
00235 OM_uint32 * minor_status,
00236 const gss_cred_usage_t cred_usage,
00237 gss_cred_id_t * cred_handle,
00238 const X509_NAME * desired_subject);
00239
00240 OM_uint32
00241 globus_i_gsi_gss_create_cred(
00242 OM_uint32 * minor_status,
00243 const gss_cred_usage_t cred_usage,
00244 gss_cred_id_t * output_cred_handle_P,
00245 globus_gsi_cred_handle_t * cred_handle,
00246 globus_bool_t sni_context);
00247
00248 int globus_i_gsi_gss_verify_extensions_callback(
00249 globus_gsi_callback_data_t callback_data,
00250 X509_EXTENSION * extension);
00251
00252 OM_uint32
00253 globus_i_gsi_gss_handshake(
00254 OM_uint32 * minor_status,
00255 gss_ctx_id_desc * context_handle);
00256
00257 OM_uint32
00258 globus_i_gsi_gss_get_token(
00259 OM_uint32 * minor_status,
00260 const gss_ctx_id_desc * context_handle,
00261 BIO * bio,
00262 const gss_buffer_t output_token);
00263
00264 OM_uint32
00265 globus_i_gsi_gss_put_token(
00266 OM_uint32 * minor_status,
00267 const gss_ctx_id_desc * context_handle,
00268 BIO * bio,
00269 const gss_buffer_t input_token);
00270
00271 OM_uint32
00272 globus_i_gsi_gss_retrieve_peer(
00273 OM_uint32 * minor_status,
00274 gss_ctx_id_desc * context_handle,
00275 const gss_cred_usage_t cred_usage);
00276
00277 #if LINK_WITH_INTERNAL_OPENSSL_API
00278 OM_uint32
00279 globus_i_gsi_gss_SSL_write_bio(
00280 OM_uint32 * minor_status,
00281 gss_ctx_id_desc * context,
00282 BIO * bp);
00283
00284 OM_uint32
00285 globus_i_gsi_gss_SSL_read_bio(
00286 OM_uint32 * minor_status,
00287 gss_ctx_id_desc * context,
00288 BIO * bp);
00289 #endif
00290
00291 OM_uint32
00292 globus_i_gsi_gss_get_context_goodtill(
00293 OM_uint32 * minor_status,
00294 gss_ctx_id_t context,
00295 time_t * goodtill);
00296
00297 OM_uint32
00298 globus_i_gsi_gssapi_init_ssl_context(
00299 OM_uint32 * minor_status,
00300 gss_cred_id_t credential,
00301 globus_i_gsi_gss_context_type_t anon_ctx,
00302 globus_bool_t sni_context);
00303
00304 globus_result_t
00305 globus_i_gsi_gssapi_openssl_error_result(
00306 int error_type,
00307 const char * filename,
00308 const char * function_name,
00309 int line_number,
00310 const char * short_desc,
00311 const char * long_desc);
00312
00313 globus_result_t
00314 globus_i_gsi_gssapi_error_result(
00315 const OM_uint32 minor_status,
00316 const char * filename,
00317 const char * function_name,
00318 int line_number,
00319 const char * short_desc,
00320 const char * long_desc);
00321
00322 globus_result_t
00323 globus_i_gsi_gssapi_error_chain_result(
00324 globus_result_t chain_result,
00325 int error_type,
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_join_chains_result(
00334 globus_result_t outer_error,
00335 globus_result_t inner_error);
00336
00337 OM_uint32
00338 globus_i_gsi_gssapi_get_hostname(
00339 OM_uint32 * minor_status,
00340 gss_name_desc * name);
00341
00342 OM_uint32
00343 globus_i_gss_read_vhost_cred_dir(
00344 OM_uint32 *minor_status,
00345 const char *dirname,
00346 gss_cred_id_t **output_credentials_array,
00347 size_t *output_credentials_array_count);
00348
00349 typedef enum
00350 {
00351 GSS_I_COMPATIBILITY_HYBRID,
00352 GSS_I_COMPATIBILITY_STRICT_GT2,
00353 GSS_I_COMPATIBILITY_STRICT_RFC2818
00354 }
00355 gss_i_name_compatibility_mode_t;
00356
00357 extern gss_i_name_compatibility_mode_t gss_i_name_compatibility_mode;
00358
00359 #endif