globus_gssapi_gsi  13.17
 All Files Functions Variables Enumerations Groups Pages
globus_i_gsi_gss_utils.h
1 
2 #ifndef GLOBUS_I_GSI_GSS_UTILS_H
3 #define GLOBUS_I_GSI_GSS_UTILS_H
4 
5 #ifndef GLOBUS_DONT_DOCUMENT_INTERNAL
6 
10 #endif
11 
12 #include "gssapi.h"
13 #include "gssapi_openssl.h"
14 
15 /* ERROR MACROS */
16 
17 #define GLOBUS_GSI_GSSAPI_ERROR_RESULT(_MIN_RESULT_, _MIN_, \
18  _ERRSTR_) \
19  if (_MIN_RESULT_ != NULL) \
20  { \
21  char * tmpstr = \
22  globus_common_create_string _ERRSTR_; \
23  *_MIN_RESULT_ = (OM_uint32) globus_i_gsi_gssapi_error_result( \
24  _MIN_, __FILE__, __func__, \
25  __LINE__, tmpstr, NULL); \
26  globus_libc_free(tmpstr); \
27  }
28 
29 #define GLOBUS_GSI_GSSAPI_OPENSSL_ERROR_RESULT(_MIN_RESULT_, \
30  _ERRORTYPE_, _ERRORSTR_) \
31  { \
32  char * tmpstr = \
33  globus_common_create_string _ERRORSTR_; \
34  *_MIN_RESULT_ = \
35  (OM_uint32) globus_i_gsi_gssapi_openssl_error_result( \
36  _ERRORTYPE_, __FILE__, __func__, __LINE__, tmpstr, NULL); \
37  globus_libc_free(tmpstr); \
38  }
39 
40 #define GLOBUS_GSI_GSSAPI_ERROR_CHAIN_RESULT(_MIN_RESULT_, _TOP_RESULT_, \
41  _ERRORTYPE_) \
42  *_MIN_RESULT_ = (OM_uint32) globus_i_gsi_gssapi_error_chain_result( \
43  (globus_result_t)_TOP_RESULT_, \
44  _ERRORTYPE_, __FILE__, \
45  __func__, __LINE__, NULL, NULL)
46 
47 #define GLOBUS_GSI_GSSAPI_LONG_ERROR_RESULT(_MIN_RESULT_, _MIN_, \
48  _ERRSTR_, _LONG_DESC_) \
49  { \
50  char * tmpstr = \
51  globus_common_create_string _ERRSTR_; \
52  *_MIN_RESULT_ = (OM_uint32) globus_i_gsi_gssapi_error_result( \
53  _MIN_, __FILE__, __func__, \
54  __LINE__, tmpstr, _LONG_DESC_); \
55  globus_libc_free(tmpstr); \
56  }
57 
58 #define GLOBUS_GSI_GSSAPI_OPENSSL_LONG_ERROR_RESULT(_MIN_RESULT_, \
59  _ERRORTYPE_, \
60  _ERRORSTR_, \
61  _LONG_DESC_) \
62  { \
63  char * tmpstr = \
64  globus_common_create_string _ERRORSTR_; \
65  *_MIN_RESULT_ = \
66  (OM_uint32) globus_i_gsi_gssapi_openssl_error_result( \
67  _ERRORTYPE_, __FILE__, __func__, \
68  __LINE__, tmpstr, _LONG_DESC_); \
69  globus_libc_free(tmpstr); \
70  }
71 
72 #define GLOBUS_GSI_GSSAPI_LONG_ERROR_CHAIN_RESULT(_MIN_RESULT_, _TOP_RESULT_, \
73  _ERRORTYPE_, _LONG_DESC_) \
74  *_MIN_RESULT_ = (OM_uint32) globus_i_gsi_gssapi_error_chain_result( \
75  (globus_result_t)_TOP_RESULT_, \
76  _ERRORTYPE_, __FILE__, \
77  __func__, __LINE__, NULL, _LONG_DESC_)
78 
79 #define GLOBUS_GSI_GSSAPI_MALLOC_ERROR(_MIN_RESULT_) \
80  { \
81  char * _tmp_str_ = \
82  globus_l_gsi_gssapi_error_strings[ \
83  GLOBUS_GSI_GSSAPI_ERROR_OUT_OF_MEMORY]; \
84  *_MIN_RESULT_ = (OM_uint32) globus_error_put( \
85  globus_error_wrap_errno_error( \
86  GLOBUS_GSI_GSSAPI_MODULE, \
87  errno, \
88  GLOBUS_GSI_GSSAPI_ERROR_OUT_OF_MEMORY, \
89  __FILE__, \
90  __func__, \
91  __LINE__, \
92  "%s", \
93  _tmp_str_)); \
94  }
95 
96 
97 /* DEBUG MACROS */
98 
99 extern int globus_i_gsi_gssapi_debug_level;
100 extern FILE * globus_i_gsi_gssapi_debug_fstream;
101 extern globus_mutex_t globus_i_gssapi_activate_mutex;
102 extern globus_bool_t globus_i_gssapi_active;
103 
104 
105 #ifdef BUILD_DEBUG
106 
107 #define GLOBUS_I_GSI_GSSAPI_DEBUG(_LEVEL_) \
108  (globus_i_gsi_gssapi_debug_level >= (_LEVEL_))
109 
110 #define GLOBUS_I_GSI_GSSAPI_DEBUG_FPRINTF(_LEVEL_, _MESSAGE_) \
111 { \
112  if (GLOBUS_I_GSI_GSSAPI_DEBUG(_LEVEL_)) \
113  { \
114  globus_libc_fprintf _MESSAGE_; \
115  } \
116 }
117 
118 #define GLOBUS_I_GSI_GSSAPI_DEBUG_FNPRINTF(_LEVEL_, _MESSAGE_) \
119 { \
120  if (GLOBUS_I_GSI_GSSAPI_DEBUG(_LEVEL_)) \
121  { \
122  char * _tmp_str_ = \
123  globus_common_create_nstring _MESSAGE_; \
124  globus_libc_fprintf(globus_i_gsi_gssapi_debug_fstream, \
125  "%s", _tmp_str_); \
126  globus_libc_free(_tmp_str_); \
127  } \
128 }
129 
130 #define GLOBUS_I_GSI_GSSAPI_DEBUG_PRINT(_LEVEL_, _MESSAGE_) \
131 { \
132  if (GLOBUS_I_GSI_GSSAPI_DEBUG(_LEVEL_)) \
133  { \
134  globus_libc_fprintf( \
135  globus_i_gsi_gssapi_debug_fstream, \
136  "%s", _MESSAGE_); \
137  } \
138 }
139 
140 #define GLOBUS_I_GSI_GSSAPI_DEBUG_PRINT_OBJECT(_LEVEL_, _TYPE_, _OBJ_) \
141 { \
142  if (GLOBUS_I_GSI_GSSAPI_DEBUG(_LEVEL_)) \
143  { \
144  _TYPE_##_print_fp( \
145  globus_i_gsi_gssapi_debug_fstream, \
146  _OBJ_); \
147  } \
148 }
149 
150 #else
151 
152 #define GLOBUS_I_GSI_GSSAPI_DEBUG(_LEVEL_) 0
153 #define GLOBUS_I_GSI_GSSAPI_DEBUG_FPRINTF(_LEVEL_, _MESSAGE_)
154 #define GLOBUS_I_GSI_GSSAPI_DEBUG_FNPRINTF(_LEVEL_, _MESSAGE_)
155 #define GLOBUS_I_GSI_GSSAPI_DEBUG_PRINT(_LEVEL_, _MESSAGE_)
156 #define GLOBUS_I_GSI_GSSAPI_DEBUG_PRINT_OBJECT(_LEVEL,_TYPE_, _OBJ_)
157 
158 #endif
159 
160 #define GLOBUS_I_GSI_GSSAPI_DEBUG_ENTER \
161  GLOBUS_I_GSI_GSSAPI_DEBUG_FPRINTF( \
162  3, (globus_i_gsi_gssapi_debug_fstream, \
163  "%s entering\n", __func__))
164 
165 #define GLOBUS_I_GSI_GSSAPI_DEBUG_EXIT \
166  GLOBUS_I_GSI_GSSAPI_DEBUG_FPRINTF( \
167  3, (globus_i_gsi_gssapi_debug_fstream, \
168  "%s exiting: major_status=%d\n", \
169  __func__, (int)major_status))
170 
171 #define GLOBUS_I_GSI_GSSAPI_INTERNAL_DEBUG_EXIT \
172  GLOBUS_I_GSI_GSSAPI_DEBUG_FPRINTF( \
173  3, (globus_i_gsi_gssapi_debug_fstream, \
174  "%s exiting\n", \
175  __func__))
176 
177 extern int globus_i_gsi_gssapi_min_tls_protocol;
178 extern int globus_i_gsi_gssapi_max_tls_protocol;
179 extern const char * globus_i_gsi_gssapi_cipher_list;
180 extern globus_bool_t globus_i_gsi_gssapi_server_cipher_order;
181 extern uid_t globus_i_gsi_gssapi_vhost_cred_owner;
182 
183 typedef enum
184 {
185  GLOBUS_I_GSI_GSS_DEFAULT_CONTEXT,
186  GLOBUS_I_GSI_GSS_ANON_CONTEXT
187 } globus_i_gsi_gss_context_type_t;
188 
189 OM_uint32
190 globus_i_gsi_gss_copy_name_to_name(
191  OM_uint32 * minor_status,
192  gss_name_desc ** output,
193  const gss_name_desc * input);
194 
195 OM_uint32
196 globus_i_gsi_gss_create_and_fill_context(
197  OM_uint32 * minor_status,
198  gss_ctx_id_desc ** context_handle,
199  gss_OID mech,
200  const gss_name_t target_name,
201  gss_cred_id_desc * cred_handle,
202  const gss_cred_usage_t cred_usage,
203  OM_uint32 req_flags);
204 
205 OM_uint32
206 globus_i_gsi_gss_create_anonymous_cred(
207  OM_uint32 * minor_status,
208  gss_cred_id_t * output_cred_handle,
209  const gss_cred_usage_t cred_usage);
210 
211 OM_uint32
212 globus_i_gsi_gss_cred_read_bio(
213  OM_uint32 * minor_status,
214  const gss_cred_usage_t cred_usage,
215  gss_cred_id_t * cred_id_handle,
216  BIO * bp);
217 
218 OM_uint32
219 globus_i_gsi_gss_cred_read(
220  OM_uint32 * minor_status,
221  const gss_cred_usage_t cred_usage,
222  gss_cred_id_t * cred_handle,
223  const X509_NAME * desired_subject);
224 
225 OM_uint32
226 globus_i_gsi_gss_create_cred(
227  OM_uint32 * minor_status,
228  const gss_cred_usage_t cred_usage,
229  gss_cred_id_t * output_cred_handle_P,
230  globus_gsi_cred_handle_t * cred_handle,
231  globus_bool_t sni_context);
232 
233 int globus_i_gsi_gss_verify_extensions_callback(
234  globus_gsi_callback_data_t callback_data,
235  X509_EXTENSION * extension);
236 
237 OM_uint32
238 globus_i_gsi_gss_handshake(
239  OM_uint32 * minor_status,
240  gss_ctx_id_desc * context_handle);
241 
242 OM_uint32
243 globus_i_gsi_gss_get_token(
244  OM_uint32 * minor_status,
245  const gss_ctx_id_desc * context_handle,
246  BIO * bio,
247  const gss_buffer_t output_token);
248 
249 OM_uint32
250 globus_i_gsi_gss_put_token(
251  OM_uint32 * minor_status,
252  const gss_ctx_id_desc * context_handle,
253  BIO * bio,
254  const gss_buffer_t input_token);
255 
256 OM_uint32
257 globus_i_gsi_gss_retrieve_peer(
258  OM_uint32 * minor_status,
259  gss_ctx_id_desc * context_handle,
260  const gss_cred_usage_t cred_usage);
261 
262 #if LINK_WITH_INTERNAL_OPENSSL_API
263 OM_uint32
264 globus_i_gsi_gss_SSL_write_bio(
265  OM_uint32 * minor_status,
266  gss_ctx_id_desc * context,
267  BIO * bp);
268 
269 OM_uint32
270 globus_i_gsi_gss_SSL_read_bio(
271  OM_uint32 * minor_status,
272  gss_ctx_id_desc * context,
273  BIO * bp);
274 #endif
275 
276 OM_uint32
277 globus_i_gsi_gss_get_context_goodtill(
278  OM_uint32 * minor_status,
279  gss_ctx_id_t context,
280  time_t * goodtill);
281 
282 OM_uint32
283 globus_i_gsi_gssapi_init_ssl_context(
284  OM_uint32 * minor_status,
285  gss_cred_id_t credential,
286  globus_i_gsi_gss_context_type_t anon_ctx,
287  globus_bool_t sni_context);
288 
289 globus_result_t
290 globus_i_gsi_gssapi_openssl_error_result(
291  int error_type,
292  const char * filename,
293  const char * function_name,
294  int line_number,
295  const char * short_desc,
296  const char * long_desc);
297 
298 globus_result_t
299 globus_i_gsi_gssapi_error_result(
300  const OM_uint32 minor_status,
301  const char * filename,
302  const char * function_name,
303  int line_number,
304  const char * short_desc,
305  const char * long_desc);
306 
307 globus_result_t
308 globus_i_gsi_gssapi_error_chain_result(
309  globus_result_t chain_result,
310  int error_type,
311  const char * filename,
312  const char * function_name,
313  int line_number,
314  const char * short_desc,
315  const char * long_desc);
316 
317 globus_result_t
318 globus_i_gsi_gssapi_error_join_chains_result(
319  globus_result_t outer_error,
320  globus_result_t inner_error);
321 
322 OM_uint32
323 globus_i_gsi_gssapi_get_hostname(
324  OM_uint32 * minor_status,
325  gss_name_desc * name);
326 
327 OM_uint32
328 globus_i_gss_read_vhost_cred_dir(
329  OM_uint32 *minor_status,
330  const char *dirname,
331  gss_cred_id_t **output_credentials_array,
332  size_t *output_credentials_array_count);
333 
334 typedef enum
335 {
336  GSS_I_COMPATIBILITY_HYBRID,
337  GSS_I_COMPATIBILITY_STRICT_GT2,
338  GSS_I_COMPATIBILITY_STRICT_RFC2818
339 }
340 gss_i_name_compatibility_mode_t;
341 
342 extern gss_i_name_compatibility_mode_t gss_i_name_compatibility_mode;
343 
344 #endif /* GLOBUS_I_GSI_GSS_UTILS_H */
GSS API OpenSSL.