17 #ifndef GLOBUS_I_GSI_GSS_UTILS_H
18 #define GLOBUS_I_GSI_GSS_UTILS_H
20 #ifndef GLOBUS_DONT_DOCUMENT_INTERNAL
32 #define GLOBUS_GSI_GSSAPI_ERROR_RESULT(_MIN_RESULT_, _MIN_, \
34 if (_MIN_RESULT_ != NULL) \
37 globus_common_create_string _ERRSTR_; \
38 *_MIN_RESULT_ = (OM_uint32) globus_i_gsi_gssapi_error_result( \
39 _MIN_, __FILE__, _function_name_, \
40 __LINE__, tmpstr, NULL); \
41 globus_libc_free(tmpstr); \
44 #define GLOBUS_GSI_GSSAPI_OPENSSL_ERROR_RESULT(_MIN_RESULT_, \
45 _ERRORTYPE_, _ERRORSTR_) \
48 globus_common_create_string _ERRORSTR_; \
50 (OM_uint32) globus_i_gsi_gssapi_openssl_error_result( \
51 _ERRORTYPE_, __FILE__, _function_name_, __LINE__, tmpstr, NULL); \
52 globus_libc_free(tmpstr); \
55 #define GLOBUS_GSI_GSSAPI_ERROR_CHAIN_RESULT(_MIN_RESULT_, _TOP_RESULT_, \
57 *_MIN_RESULT_ = (OM_uint32) globus_i_gsi_gssapi_error_chain_result( \
58 (globus_result_t)_TOP_RESULT_, \
59 _ERRORTYPE_, __FILE__, \
60 _function_name_, __LINE__, NULL, NULL)
62 #define GLOBUS_GSI_GSSAPI_LONG_ERROR_RESULT(_MIN_RESULT_, _MIN_, \
63 _ERRSTR_, _LONG_DESC_) \
66 globus_common_create_string _ERRSTR_; \
67 *_MIN_RESULT_ = (OM_uint32) globus_i_gsi_gssapi_error_result( \
68 _MIN_, __FILE__, _function_name_, \
69 __LINE__, tmpstr, _LONG_DESC_); \
70 globus_libc_free(tmpstr); \
73 #define GLOBUS_GSI_GSSAPI_OPENSSL_LONG_ERROR_RESULT(_MIN_RESULT_, \
79 globus_common_create_string _ERRORSTR_; \
81 (OM_uint32) globus_i_gsi_gssapi_openssl_error_result( \
82 _ERRORTYPE_, __FILE__, _function_name_, \
83 __LINE__, tmpstr, _LONG_DESC_); \
84 globus_libc_free(tmpstr); \
87 #define GLOBUS_GSI_GSSAPI_LONG_ERROR_CHAIN_RESULT(_MIN_RESULT_, _TOP_RESULT_, \
88 _ERRORTYPE_, _LONG_DESC_) \
89 *_MIN_RESULT_ = (OM_uint32) globus_i_gsi_gssapi_error_chain_result( \
90 (globus_result_t)_TOP_RESULT_, \
91 _ERRORTYPE_, __FILE__, \
92 _function_name_, __LINE__, NULL, _LONG_DESC_)
94 #define GLOBUS_GSI_GSSAPI_MALLOC_ERROR(_MIN_RESULT_) \
97 globus_l_gsi_gssapi_error_strings[ \
98 GLOBUS_GSI_GSSAPI_ERROR_OUT_OF_MEMORY]; \
99 *_MIN_RESULT_ = (OM_uint32) globus_error_put( \
100 globus_error_wrap_errno_error( \
101 GLOBUS_GSI_GSSAPI_MODULE, \
103 GLOBUS_GSI_GSSAPI_ERROR_OUT_OF_MEMORY, \
111 #define GLOBUS_GSI_GSSAPI_ERRNO_ERROR_RESULT(_MIN_RESULT_, \
112 _ERRORTYPE_, _ERRORSTR_) \
115 globus_common_create_string _ERRORSTR_; \
116 *_MIN_RESULT_ = (OM_uint32) globus_error_put( \
117 globus_error_wrap_errno_error( \
118 GLOBUS_GSI_GSSAPI_MODULE, \
126 globus_libc_free(_tmp_str_); \
132 extern int globus_i_gsi_gssapi_debug_level;
133 extern FILE * globus_i_gsi_gssapi_debug_fstream;
134 extern globus_mutex_t globus_i_gssapi_activate_mutex;
135 extern globus_bool_t globus_i_gssapi_active;
140 #define GLOBUS_I_GSI_GSSAPI_DEBUG(_LEVEL_) \
141 (globus_i_gsi_gssapi_debug_level >= (_LEVEL_))
143 #define GLOBUS_I_GSI_GSSAPI_DEBUG_FPRINTF(_LEVEL_, _MESSAGE_) \
145 if (GLOBUS_I_GSI_GSSAPI_DEBUG(_LEVEL_)) \
147 globus_libc_fprintf _MESSAGE_; \
151 #define GLOBUS_I_GSI_GSSAPI_DEBUG_FNPRINTF(_LEVEL_, _MESSAGE_) \
153 if (GLOBUS_I_GSI_GSSAPI_DEBUG(_LEVEL_)) \
156 globus_common_create_nstring _MESSAGE_; \
157 globus_libc_fprintf(globus_i_gsi_gssapi_debug_fstream, \
159 globus_libc_free(_tmp_str_); \
163 #define GLOBUS_I_GSI_GSSAPI_DEBUG_PRINT(_LEVEL_, _MESSAGE_) \
165 if (GLOBUS_I_GSI_GSSAPI_DEBUG(_LEVEL_)) \
167 globus_libc_fprintf( \
168 globus_i_gsi_gssapi_debug_fstream, \
173 #define GLOBUS_I_GSI_GSSAPI_DEBUG_PRINT_OBJECT(_LEVEL_, _TYPE_, _OBJ_) \
175 if (GLOBUS_I_GSI_GSSAPI_DEBUG(_LEVEL_)) \
178 globus_i_gsi_gssapi_debug_fstream, \
185 #define GLOBUS_I_GSI_GSSAPI_DEBUG(_LEVEL_) 0
186 #define GLOBUS_I_GSI_GSSAPI_DEBUG_FPRINTF(_LEVEL_, _MESSAGE_)
187 #define GLOBUS_I_GSI_GSSAPI_DEBUG_FNPRINTF(_LEVEL_, _MESSAGE_)
188 #define GLOBUS_I_GSI_GSSAPI_DEBUG_PRINT(_LEVEL_, _MESSAGE_)
189 #define GLOBUS_I_GSI_GSSAPI_DEBUG_PRINT_OBJECT(_LEVEL,_TYPE_, _OBJ_)
193 #define GLOBUS_I_GSI_GSSAPI_DEBUG_ENTER \
194 GLOBUS_I_GSI_GSSAPI_DEBUG_FPRINTF( \
195 1, (globus_i_gsi_gssapi_debug_fstream, \
196 "%s entering\n", _function_name_))
198 #define GLOBUS_I_GSI_GSSAPI_DEBUG_EXIT \
199 GLOBUS_I_GSI_GSSAPI_DEBUG_FPRINTF( \
200 1, (globus_i_gsi_gssapi_debug_fstream, \
201 "%s exiting: major_status=%d\n", \
202 _function_name_, (int)major_status))
204 #define GLOBUS_I_GSI_GSSAPI_INTERNAL_DEBUG_EXIT \
205 GLOBUS_I_GSI_GSSAPI_DEBUG_FPRINTF( \
206 1, (globus_i_gsi_gssapi_debug_fstream, \
210 extern int globus_i_gsi_gssapi_force_tls;
211 extern const char * globus_i_gsi_gssapi_cipher_list;
212 extern globus_bool_t globus_i_gsi_gssapi_server_cipher_order;
216 GLOBUS_I_GSI_GSS_DEFAULT_CONTEXT,
217 GLOBUS_I_GSI_GSS_ANON_CONTEXT
218 } globus_i_gsi_gss_context_type_t;
221 globus_i_gsi_gss_copy_name_to_name(
222 OM_uint32 * minor_status,
223 gss_name_desc ** output,
224 const gss_name_desc * input);
227 globus_i_gsi_gss_create_and_fill_context(
228 OM_uint32 * minor_status,
229 gss_ctx_id_desc ** context_handle,
230 gss_cred_id_desc * cred_handle,
231 const gss_cred_usage_t cred_usage,
232 OM_uint32 req_flags);
235 globus_i_gsi_gss_create_anonymous_cred(
236 OM_uint32 * minor_status,
237 gss_cred_id_t * output_cred_handle,
238 const gss_cred_usage_t cred_usage);
241 globus_i_gsi_gss_cred_read_bio(
242 OM_uint32 * minor_status,
243 const gss_cred_usage_t cred_usage,
244 gss_cred_id_t * cred_id_handle,
248 globus_i_gsi_gss_cred_read(
249 OM_uint32 * minor_status,
250 const gss_cred_usage_t cred_usage,
251 gss_cred_id_t * cred_handle,
252 const X509_NAME * desired_subject);
255 globus_i_gsi_gss_create_cred(
256 OM_uint32 * minor_status,
257 const gss_cred_usage_t cred_usage,
258 gss_cred_id_t * output_cred_handle_P,
259 globus_gsi_cred_handle_t * cred_handle);
261 int globus_i_gsi_gss_verify_extensions_callback(
262 globus_gsi_callback_data_t callback_data,
263 X509_EXTENSION * extension);
266 globus_i_gsi_gss_handshake(
267 OM_uint32 * minor_status,
268 gss_ctx_id_desc * context_handle);
271 globus_i_gsi_gss_get_token(
272 OM_uint32 * minor_status,
273 const gss_ctx_id_desc * context_handle,
275 const gss_buffer_t output_token);
278 globus_i_gsi_gss_put_token(
279 OM_uint32 * minor_status,
280 const gss_ctx_id_desc * context_handle,
282 const gss_buffer_t input_token);
285 globus_i_gsi_gss_retrieve_peer(
286 OM_uint32 * minor_status,
287 gss_ctx_id_desc * context_handle,
288 const gss_cred_usage_t cred_usage);
290 #if LINK_WITH_INTERNAL_OPENSSL_API
292 globus_i_gsi_gss_SSL_write_bio(
293 OM_uint32 * minor_status,
294 gss_ctx_id_desc * context,
298 globus_i_gsi_gss_SSL_read_bio(
299 OM_uint32 * minor_status,
300 gss_ctx_id_desc * context,
305 globus_i_gsi_gss_get_context_goodtill(
306 OM_uint32 * minor_status,
307 gss_ctx_id_t context,
311 globus_i_gsi_gssapi_init_ssl_context(
312 OM_uint32 * minor_status,
313 gss_cred_id_t credential,
314 globus_i_gsi_gss_context_type_t anon_ctx);
317 globus_i_gsi_gssapi_openssl_error_result(
319 const char * filename,
320 const char * function_name,
322 const char * short_desc,
323 const char * long_desc);
326 globus_i_gsi_gssapi_error_result(
327 const OM_uint32 minor_status,
328 const char * filename,
329 const char * function_name,
331 const char * short_desc,
332 const char * long_desc);
335 globus_i_gsi_gssapi_error_chain_result(
336 globus_result_t chain_result,
338 const char * filename,
339 const char * function_name,
341 const char * short_desc,
342 const char * long_desc);
345 globus_i_gsi_gssapi_error_join_chains_result(
346 globus_result_t outer_error,
347 globus_result_t inner_error);
350 globus_i_gsi_gssapi_get_hostname(
351 OM_uint32 * minor_status,
352 gss_name_desc * name);
357 GSS_I_COMPATIBILITY_HYBRID,
358 GSS_I_COMPATIBILITY_STRICT_GT2,
359 GSS_I_COMPATIBILITY_STRICT_RFC2818
361 gss_i_name_compatibility_mode_t;
363 extern gss_i_name_compatibility_mode_t gss_i_name_compatibility_mode;