00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef GSSAPI_OPENSSL_H
00018 #define GSSAPI_OPENSSL_H
00019
00026 #include "globus_config.h"
00027 #include "globus_common.h"
00028
00029 #include "gssapi.h"
00030 #include "globus_gsi_gss_constants.h"
00031
00032 #include "globus_gsi_callback.h"
00033 #include "globus_gsi_proxy.h"
00034 #include "globus_gsi_credential.h"
00035
00036 #include <stdio.h>
00037 #include "openssl/ssl.h"
00038 #include "openssl/err.h"
00039 #include "openssl/bio.h"
00040 #include "openssl/pem.h"
00041 #include "openssl/x509.h"
00042 #include "openssl/x509v3.h"
00043 #include "openssl/stack.h"
00044
00045 #define GLOBUS_I_GSI_GSSAPI_IMPL_VERSION 1
00046
00047 #define GSS_I_CTX_INITIALIZED 1
00048 #define GSS_I_DISALLOW_ENCRYPTION 2
00049 #define GSS_I_PROTECTION_FAIL_ON_CONTEXT_EXPIRATION 4
00050 #define GSS_I_APPLICATION_WILL_HANDLE_EXTENSIONS 8
00051
00052 #define GSS_C_QOP_GLOBUS_GSSAPI_OPENSSL_BIG 1
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 #define SSL3_RT_GSSAPI_OPENSSL 26
00076
00077
00078
00079 #define L2N(LONG_VAL, CHAR_ARRAY) \
00080 { \
00081 unsigned char * _char_array_ = CHAR_ARRAY; \
00082 *(_char_array_++) = (unsigned char) (((LONG_VAL) >> 24) & 0xff); \
00083 *(_char_array_++) = (unsigned char) (((LONG_VAL) >> 16) & 0xff); \
00084 *(_char_array_++) = (unsigned char) (((LONG_VAL) >> 8) & 0xff); \
00085 *(_char_array_++) = (unsigned char) (((LONG_VAL)) & 0xff); \
00086 }
00087
00088 #define N2L(CHAR_ARRAY, LONG_VAL) \
00089 { \
00090 unsigned char * _char_array_ = CHAR_ARRAY; \
00091 (LONG_VAL) = ((*(_char_array_++)) << 24) & 0xff000000; \
00092 (LONG_VAL) |= ((*(_char_array_++)) << 16) & 0xff0000; \
00093 (LONG_VAL) |= ((*(_char_array_++)) << 8) & 0xff00; \
00094 (LONG_VAL) |= ((*(_char_array_++)) & 0xff); \
00095 }
00096
00097 #define N2S(CHAR_ARRAY, SHORT) \
00098 { \
00099 char * _char_array_ = CHAR_ARRAY; \
00100 (SHORT) = ((unsigned int) (*(_char_array_++))) << 8; \
00101 (SHORT) |= ((unsigned int) (*(_char_array_++))); \
00102 }
00103
00104 #define S2N(SHORT, CHAR_ARRAY) \
00105 { \
00106 char * _char_array_ = CHAR_ARRAY; \
00107 *(_char_array_++) = (unsigned char) (((SHORT) >> 8) & 0xff); \
00108 *(_char_array_++) = (unsigned char) ((SHORT) & 0xff); \
00109 }
00110
00111
00112
00113 #define g_OID_equal(o1, o2) \
00114 (((o1) == (o2)) || \
00115 ((o1) && (o2) && \
00116 ((o1)->length == (o2)->length) && \
00117 (memcmp((o1)->elements,(o2)->elements,(int) (o1)->length) == 0)))
00118
00119 typedef struct gss_name_desc_struct {
00120
00121 gss_OID name_oid;
00122
00123 X509_NAME * x509n;
00124 char * x509n_oneline;
00125 GENERAL_NAMES * subjectAltNames;
00126 char * user_name;
00127 char * service_name;
00128 char * host_name;
00129 char * ip_address;
00130 char * ip_name;
00131 } gss_name_desc;
00132
00133 typedef struct gss_cred_id_desc_struct {
00134 globus_gsi_cred_handle_t cred_handle;
00135 gss_name_desc * globusid;
00136 gss_cred_usage_t cred_usage;
00137 SSL_CTX * ssl_context;
00138 } gss_cred_id_desc;
00139
00140 typedef struct gss_ctx_id_desc_struct{
00141 globus_mutex_t mutex;
00142 globus_gsi_callback_data_t callback_data;
00143 gss_cred_id_desc * peer_cred_handle;
00144 gss_cred_id_desc * cred_handle;
00145 gss_cred_id_desc * deleg_cred_handle;
00146 globus_gsi_proxy_handle_t proxy_handle;
00147 OM_uint32 ret_flags;
00148 OM_uint32 req_flags;
00149 OM_uint32 ctx_flags;
00150 int cred_obtained;
00151 SSL * gss_ssl;
00152 BIO * gss_rbio;
00153 BIO * gss_wbio;
00154 BIO * gss_sslbio;
00155 gss_con_st_t gss_state;
00156 int locally_initiated;
00157 gss_delegation_state_t delegation_state;
00158 gss_OID_set extension_oids;
00159 } gss_ctx_id_desc;
00160
00161 extern
00162 const gss_OID_desc * const gss_mech_globus_gssapi_openssl;
00163
00164 extern
00165 const gss_OID_desc * const gss_proxycertinfo_extension;
00166
00167 extern
00168 gss_OID_desc * gss_nt_host_ip;
00169
00170 extern
00171 gss_OID_desc * gss_nt_x509;
00172
00173 #define GLOBUS_GSS_C_NT_HOST_IP gss_nt_host_ip
00174 #define GLOBUS_GSS_C_NT_X509 gss_nt_x509
00175
00176 extern
00177 globus_thread_once_t once_control;
00178
00179 void
00180 globus_l_gsi_gssapi_activate_once(void);
00181
00182 #endif