2 #ifndef GSSAPI_OPENSSL_H
3 #define GSSAPI_OPENSSL_H
13 #include "globus_config.h"
14 #include "globus_common.h"
19 #include "globus_gsi_callback.h"
20 #include "globus_gsi_proxy.h"
21 #include "globus_gsi_credential.h"
24 #include "openssl/ssl.h"
25 #include "openssl/err.h"
26 #include "openssl/bio.h"
27 #include "openssl/pem.h"
28 #include "openssl/x509.h"
29 #include "openssl/x509v3.h"
30 #include "openssl/stack.h"
32 #define GLOBUS_I_GSI_GSSAPI_IMPL_VERSION 1
34 #define GSS_I_CTX_INITIALIZED 1
35 #define GSS_I_DISALLOW_ENCRYPTION 2
36 #define GSS_I_PROTECTION_FAIL_ON_CONTEXT_EXPIRATION 4
37 #define GSS_I_APPLICATION_WILL_HANDLE_EXTENSIONS 8
39 #define GSS_C_QOP_GLOBUS_GSSAPI_OPENSSL_BIG 1
62 #define SSL3_RT_GSSAPI_OPENSSL 26
66 #define L2N(LONG_VAL, CHAR_ARRAY) \
68 unsigned char * _char_array_ = CHAR_ARRAY; \
69 *(_char_array_++) = (unsigned char) (((LONG_VAL) >> 24) & 0xff); \
70 *(_char_array_++) = (unsigned char) (((LONG_VAL) >> 16) & 0xff); \
71 *(_char_array_++) = (unsigned char) (((LONG_VAL) >> 8) & 0xff); \
72 *(_char_array_++) = (unsigned char) (((LONG_VAL)) & 0xff); \
75 #define N2L(CHAR_ARRAY, LONG_VAL) \
77 const unsigned char * _char_array_ = CHAR_ARRAY; \
78 (LONG_VAL) = ((*(_char_array_++)) << 24) & 0xff000000; \
79 (LONG_VAL) |= ((*(_char_array_++)) << 16) & 0xff0000; \
80 (LONG_VAL) |= ((*(_char_array_++)) << 8) & 0xff00; \
81 (LONG_VAL) |= ((*(_char_array_++)) & 0xff); \
84 #define N2S(CHAR_ARRAY, SHORT) \
86 char * _char_array_ = CHAR_ARRAY; \
87 (SHORT) = ((unsigned int) (*(_char_array_++))) << 8; \
88 (SHORT) |= ((unsigned int) (*(_char_array_++))); \
91 #define S2N(SHORT, CHAR_ARRAY) \
93 char * _char_array_ = CHAR_ARRAY; \
94 *(_char_array_++) = (unsigned char) (((SHORT) >> 8) & 0xff); \
95 *(_char_array_++) = (unsigned char) ((SHORT) & 0xff); \
98 #define U642N(U64VAL, CHAR_ARRAY) \
100 unsigned char * _char_array_ = CHAR_ARRAY; \
101 *(_char_array_++) = (unsigned char) (((U64VAL) >> 56) & 0xff); \
102 *(_char_array_++) = (unsigned char) (((U64VAL) >> 48) & 0xff); \
103 *(_char_array_++) = (unsigned char) (((U64VAL) >> 40) & 0xff); \
104 *(_char_array_++) = (unsigned char) (((U64VAL) >> 32) & 0xff); \
105 *(_char_array_++) = (unsigned char) (((U64VAL) >> 24) & 0xff); \
106 *(_char_array_++) = (unsigned char) (((U64VAL) >> 16) & 0xff); \
107 *(_char_array_++) = (unsigned char) (((U64VAL) >> 8) & 0xff); \
108 *(_char_array_++) = (unsigned char) (((U64VAL) ) & 0xff); \
111 #define N2U64(CHAR_ARRAY, U64VAL) \
113 const unsigned char * _char_array_ = CHAR_ARRAY; \
114 uint64_t _u64val_ = 0; \
115 _u64val_ = (((uint64_t)(*(_char_array_++))) << 56) & 0xff00000000000000; \
116 _u64val_ = (((uint64_t)(*(_char_array_++))) << 48) & 0xff000000000000; \
117 _u64val_ = (((uint64_t)(*(_char_array_++))) << 40) & 0xff0000000000; \
118 _u64val_ = (((uint64_t)(*(_char_array_++))) << 32) & 0xff00000000; \
119 _u64val_ = (((uint64_t)(*(_char_array_++))) << 24) & 0xff000000; \
120 _u64val_ = (((uint64_t)(*(_char_array_++))) << 16) & 0xff0000; \
121 _u64val_ = (((uint64_t)(*(_char_array_++))) << 8) & 0xff00; \
122 _u64val_ = (((uint64_t)(*(_char_array_++))) ) & 0xff; \
123 (U64VAL) = _u64val_; \
127 #define g_OID_equal(o1, o2) \
130 ((o1)->length == (o2)->length) && \
131 (memcmp((o1)->elements,(o2)->elements,(int) (o1)->length) == 0)))
133 typedef struct gss_name_desc_struct {
138 char * x509n_oneline;
139 GENERAL_NAMES * subjectAltNames;
148 typedef struct gss_cred_id_desc_struct {
149 globus_gsi_cred_handle_t cred_handle;
150 gss_name_desc * globusid;
151 gss_cred_usage_t cred_usage;
152 SSL_CTX * ssl_context;
156 typedef struct gss_ctx_id_desc_struct{
157 globus_mutex_t mutex;
158 globus_gsi_callback_data_t callback_data;
159 gss_cred_id_desc * peer_cred_handle;
160 gss_cred_id_desc * cred_handle;
161 gss_cred_id_desc * deleg_cred_handle;
162 globus_gsi_proxy_handle_t proxy_handle;
168 #if OPENSSL_VERSION_NUMBER >= 0x10000100L
170 uint64_t mac_read_sequence;
172 uint64_t mac_write_sequence;
174 unsigned char * mac_key;
179 unsigned char * mac_iv_fixed;
186 int locally_initiated;
188 gss_OID_set extension_oids;
189 gss_cred_id_t *sni_credentials;
190 bool sni_credentials_obtained;
191 size_t sni_credentials_count;
192 char *sni_servername;
198 const gss_OID_desc *
const gss_mech_globus_gssapi_openssl;
201 const gss_OID_desc *
const gss_mech_globus_gssapi_openssl_micv2;
204 const gss_OID_desc *
const gss_proxycertinfo_extension;
207 gss_OID_desc * gss_nt_host_ip;
210 gss_OID_desc * gss_nt_x509;
213 const gss_OID_desc *
const gss_ext_server_name_oid;
216 const gss_OID_desc *
const gss_ext_alpn_oid;
219 const gss_OID_desc *
const gss_ext_tls_version_oid;
222 const gss_OID_desc *
const gss_ext_tls_cipher_oid;
225 globus_bool_t globus_i_backward_compatible_mic;
227 globus_bool_t globus_i_accept_backward_compatible_mic;
229 #define GLOBUS_GSS_C_NT_HOST_IP gss_nt_host_ip
230 #define GLOBUS_GSS_C_NT_X509 gss_nt_x509
236 globus_l_gsi_gssapi_activate_once(
void);
240 OM_uint32 *minor_status,
241 const gss_ctx_id_t context_handle,
242 const EVP_MD ** hash,
243 const EVP_CIPHER ** cipher);
247 globus_i_gssapi_gsi_gmac(
248 OM_uint32 * minor_status,
249 const EVP_CIPHER * evp_cipher,
250 const unsigned char * iv,
251 const unsigned char * key,
252 const gss_buffer_desc *message_buffer,
253 unsigned char tag[
static 16]);
gss_delegation_state_t
Delegation State Type.
Definition: globus_gsi_gss_constants.h:95
globus_thread_once_t once_control
Definition: module.c:100
gss_con_st_t
Connection State Type.
Definition: globus_gsi_gss_constants.h:83
Globus GSI GSS constants.
OM_uint32 globus_i_gss_get_hash(OM_uint32 *minor_status, const gss_ctx_id_t context_handle, const EVP_MD **hash, const EVP_CIPHER **cipher)
Find the hash and cipher functions used by a context.
Definition: get_hash.c:8