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