00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef GLOBUS_I_XIO_GSI_H
00018 #define GLOBUS_I_XIO_GSI_H
00019
00020 #include <assert.h>
00021 #include "globus_xio_driver.h"
00022 #include "globus_xio_load.h"
00023 #include "globus_common.h"
00024 #include "globus_xio_gsi.h"
00025 #include "gssapi.h"
00026 #include "globus_gss_assist.h"
00027 #include "globus_error_gssapi.h"
00028
00029 #define GLOBUS_XIO_GSI_DRIVER_MODULE GlobusXIOMyModule(gsi)
00030
00031
00032
00033 #define GlobusLXIOGSICreateHeader(__iovec, __length) \
00034 { \
00035 *(((unsigned char *) (__iovec).iov_base)) = \
00036 (unsigned char) (((__length) >> 24) & 0xff); \
00037 *(((unsigned char *) (__iovec).iov_base)+1) = \
00038 (unsigned char) (((__length) >> 16) & 0xff); \
00039 *(((unsigned char *) (__iovec).iov_base)+2) = \
00040 (unsigned char) (((__length) >> 8) & 0xff); \
00041 *(((unsigned char *) (__iovec).iov_base)+3) = \
00042 (unsigned char) (((__length) ) & 0xff); \
00043 }
00044
00045
00046
00047 #define GlobusLXIOGSIGetTokenLength(__iovec, __length) \
00048 { \
00049 globus_byte_t * c; \
00050 c = (__iovec).iov_base; \
00051 (__length) = ((globus_size_t) (*((c)++))) << 24; \
00052 (__length) |= ((globus_size_t) (*((c)++))) << 16; \
00053 (__length) |= ((globus_size_t) (*((c)++))) << 8; \
00054 (__length) |= ((globus_size_t) (*((c)++))); \
00055 }
00056
00057
00058
00059
00060 #define GlobusXIOErrorWrapGSSFailed(failed_func, major_status, minor_status) \
00061 globus_error_put( \
00062 globus_error_wrap_gssapi_error( \
00063 GLOBUS_XIO_GSI_DRIVER_MODULE, \
00064 (major_status), \
00065 (minor_status), \
00066 GLOBUS_XIO_GSI_ERROR_WRAP_GSSAPI, \
00067 __FILE__, \
00068 _xio_name, \
00069 __LINE__, \
00070 _XIOSL("%s failed."), \
00071 (failed_func)))
00072
00073
00074 #define GlobusXioGSIErrorBadProtectionLevel() \
00075 globus_error_put( \
00076 globus_error_construct_error( \
00077 GLOBUS_XIO_GSI_DRIVER_MODULE, \
00078 GLOBUS_NULL, \
00079 GLOBUS_XIO_GSI_ERROR_INVALID_PROTECTION_LEVEL, \
00080 __FILE__, \
00081 _xio_name, \
00082 __LINE__, \
00083 _XIOSL("Peer specified lower protection level")))
00084
00085 #define GlobusXioGSIErrorTokenTooBig() \
00086 globus_error_put( \
00087 globus_error_construct_error( \
00088 GLOBUS_XIO_GSI_DRIVER_MODULE, \
00089 GLOBUS_NULL, \
00090 GLOBUS_XIO_GSI_ERROR_TOKEN_TOO_BIG, \
00091 __FILE__, \
00092 _xio_name, \
00093 __LINE__, \
00094 _XIOSL("Token size exceeds limit. Usually happens when someone tries to establish a insecure connection with a secure endpoint, e.g. when someone sends plain HTTP to a HTTPS endpoint without first establishing a SSL session.")))
00095
00096 #define GlobusXioGSIErrorEmptyTargetName() \
00097 globus_error_put( \
00098 globus_error_construct_error( \
00099 GLOBUS_XIO_GSI_DRIVER_MODULE, \
00100 GLOBUS_NULL, \
00101 GLOBUS_XIO_GSI_ERROR_EMPTY_TARGET_NAME, \
00102 __FILE__, \
00103 _xio_name, \
00104 __LINE__, \
00105 _XIOSL("Identity authorization requested, but no target name set")))
00106
00107 #define GlobusXioGSIErrorEmptyHostName() \
00108 globus_error_put( \
00109 globus_error_construct_error( \
00110 GLOBUS_XIO_GSI_DRIVER_MODULE, \
00111 GLOBUS_NULL, \
00112 GLOBUS_XIO_GSI_ERROR_EMPTY_HOST_NAME, \
00113 __FILE__, \
00114 _xio_name, \
00115 __LINE__, \
00116 _XIOSL("Host authorization requested, but no host name set")))
00117
00118 #define GlobusXioGSIAuthorizationFailed(_peer_name, _expected_name) \
00119 globus_error_put( \
00120 globus_error_construct_error( \
00121 GLOBUS_XIO_GSI_DRIVER_MODULE, \
00122 GLOBUS_NULL, \
00123 GLOBUS_XIO_GSI_AUTHORIZATION_FAILED, \
00124 __FILE__, \
00125 _xio_name, \
00126 __LINE__, \
00127 _XIOSL("The peer authenticated as %s. Expected the peer " \
00128 "to authenticate as %s"), (_peer_name), (_expected_name)))
00129
00130
00131
00132
00133 GlobusDebugDeclare(GLOBUS_XIO_GSI);
00134
00135 #define GLOBUS_XIO_GSI_DEBUG_TRACE 4
00136 #define GLOBUS_XIO_GSI_DEBUG_INTERNAL_TRACE 8
00137
00138 #define GlobusXIOGSIDebugPrintf(level, message) \
00139 GlobusDebugPrintf(GLOBUS_XIO_GSI, level, message)
00140
00141 #define GlobusXIOGSIDebugEnter() \
00142 GlobusXIOGSIDebugPrintf( \
00143 GLOBUS_XIO_GSI_DEBUG_TRACE, \
00144 (_XIOSL("[%s] Entering\n"), _xio_name))
00145
00146 #define GlobusXIOGSIDebugExit() \
00147 GlobusXIOGSIDebugPrintf( \
00148 GLOBUS_XIO_GSI_DEBUG_TRACE, \
00149 (_XIOSL("[%s] Exiting\n"), _xio_name))
00150
00151 #define GlobusXIOGSIDebugExitWithError() \
00152 GlobusXIOGSIDebugPrintf( \
00153 GLOBUS_XIO_GSI_DEBUG_TRACE, \
00154 (_XIOSL("[%s] Exiting with error\n"), _xio_name))
00155
00156 #define GlobusXIOGSIDebugInternalEnter() \
00157 GlobusXIOGSIDebugPrintf( \
00158 GLOBUS_XIO_GSI_DEBUG_INTERNAL_TRACE, \
00159 (_XIOSL("[%s] I Entering\n"), _xio_name))
00160
00161 #define GlobusXIOGSIDebugInternalExit() \
00162 GlobusXIOGSIDebugPrintf( \
00163 GLOBUS_XIO_GSI_DEBUG_INTERNAL_TRACE, \
00164 (_XIOSL("[%s] I Exiting\n"), _xio_name))
00165
00166 #define GlobusXIOGSIDebugInternalExitWithError() \
00167 GlobusXIOGSIDebugPrintf( \
00168 GLOBUS_XIO_GSI_DEBUG_INTERNAL_TRACE, \
00169 (_XIOSL("[%s] I Exiting with error\n"), _xio_name))
00170
00171
00172
00173
00174 typedef struct
00175 {
00176 gss_cred_id_t credential;
00177 OM_uint32 req_flags;
00178 OM_uint32 time_req;
00179 gss_OID mech_type;
00180 gss_channel_bindings_t channel_bindings;
00181 globus_bool_t wrap_tokens;
00182 globus_size_t buffer_size;
00183 globus_xio_gsi_protection_level_t prot_level;
00184 gss_name_t target_name;
00185 globus_bool_t init;
00186 globus_xio_gsi_authorization_mode_t authz_mode;
00187 char * credentials_dir;
00188 unsigned char * alpn_list;
00189 size_t alpn_list_len;
00190 } globus_l_attr_t;
00191
00192
00193
00194
00195
00196 typedef struct
00197 {
00198 globus_l_attr_t * attr;
00199 OM_uint32 ret_flags;
00200 OM_uint32 time_rec;
00201 OM_uint32 max_wrap_size;
00202 gss_ctx_id_t context;
00203 gss_cred_id_t delegated_cred;
00204 gss_cred_id_t credential;
00205 gss_OID mech_used;
00206 gss_name_t peer_name;
00207 gss_name_t local_name;
00208 size_t write_iovec_count;
00209 globus_xio_iovec_t * write_iovec;
00210 globus_bool_t frame_writes;
00211 size_t write_header_count;
00212 unsigned char * write_headers;
00213 globus_size_t bytes_written;
00214 globus_xio_iovec_t read_iovec[2];
00215 unsigned char header[4];
00216 unsigned char * read_buffer;
00217 globus_size_t bytes_read;
00218 globus_xio_iovec_t * user_iovec;
00219 size_t user_iovec_count;
00220 size_t user_iovec_index;
00221 size_t user_iovec_offset;
00222 unsigned char * unwrapped_buffer;
00223 globus_size_t unwrapped_buffer_length;
00224 globus_size_t unwrapped_buffer_offset;
00225 globus_size_t bytes_returned;
00226 globus_bool_t done;
00227 globus_object_t * result_obj;
00228 globus_bool_t eof;
00229 int connection_id;
00230 globus_xio_driver_handle_t xio_driver_handle;
00231 char * host_name;
00232 gss_cred_id_t *cred_array;
00233 size_t cred_array_length;
00234 } globus_l_handle_t;
00235
00236
00237
00238
00239
00240
00241 typedef struct
00242 {
00243 globus_l_handle_t * xio_handle;
00244 void * user_arg;
00245 globus_xio_gsi_delegation_init_callback_t
00246 init_callback;
00247 globus_xio_gsi_delegation_accept_callback_t
00248 accept_callback;
00249 gss_cred_id_t cred;
00250 gss_OID_set restriction_oids;
00251 gss_buffer_set_t restriction_buffers;
00252 OM_uint32 time_req;
00253 OM_uint32 time_rec;
00254 globus_xio_iovec_t iovec[2];
00255 unsigned char header[4];
00256 globus_bool_t done;
00257 globus_object_t * result_obj;
00258 globus_bool_t reading_header;
00259 } globus_l_delegation_handle_t;
00260
00261 typedef struct
00262 {
00263 globus_bool_t done;
00264 globus_result_t result;
00265 globus_mutex_t mutex;
00266 globus_cond_t cond;
00267 OM_uint32 * time_rec;
00268 gss_cred_id_t * cred;
00269 } globus_l_xio_gsi_delegation_arg_t;
00270
00271 #endif
00272