|
1 /* |
|
2 * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. Oracle designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Oracle in the LICENSE file that accompanied this code. |
|
10 * |
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
|
15 * accompanied this code). |
|
16 * |
|
17 * You should have received a copy of the GNU General Public License version |
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 * |
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 * or visit www.oracle.com if you need additional information or have any |
|
23 * questions. |
|
24 */ |
|
25 |
|
26 #ifndef NATIVE_FUNC_H |
|
27 #define NATIVE_FUNC_H |
|
28 |
|
29 #include "gssapi.h" |
|
30 |
|
31 #ifdef WIN32 |
|
32 #include <windows.h> |
|
33 #define GETLIB(libName) LoadLibrary(libName) |
|
34 #define GETFUNC(lib,name) GetProcAddress(lib,name) |
|
35 #define CLOSELIB(lib) CloseHandle(lib) |
|
36 #else |
|
37 #include <dlfcn.h> |
|
38 #define GETLIB(libName) dlopen(libName, RTLD_NOW) |
|
39 #define GETFUNC(lib,name) dlsym(lib,name) |
|
40 #define CLOSELIB(lib) dlclose(lib) |
|
41 #endif |
|
42 |
|
43 #ifndef TRUE |
|
44 #define TRUE 1 |
|
45 #endif |
|
46 |
|
47 #ifndef FALSE |
|
48 #define FALSE 0 |
|
49 #endif |
|
50 |
|
51 int loadNative(const char *libName); |
|
52 |
|
53 /* function pointer definitions */ |
|
54 typedef OM_uint32 (*RELEASE_NAME_FN_PTR) |
|
55 (OM_uint32 *minor_status, |
|
56 gss_name_t *name); |
|
57 |
|
58 typedef OM_uint32 (*IMPORT_NAME_FN_PTR) |
|
59 (OM_uint32 *minor_status, |
|
60 gss_buffer_t input_name_buffer, |
|
61 gss_OID input_name_type, |
|
62 gss_name_t *output_name); |
|
63 |
|
64 typedef OM_uint32 (*COMPARE_NAME_FN_PTR) |
|
65 (OM_uint32 *minor_status, |
|
66 gss_name_t name1, |
|
67 gss_name_t name2, |
|
68 int *name_equal); |
|
69 |
|
70 typedef OM_uint32 (*CANONICALIZE_NAME_FN_PTR) |
|
71 (OM_uint32 *minor_status, |
|
72 gss_name_t input_name, |
|
73 gss_OID mech_type, |
|
74 gss_name_t *output_name); |
|
75 |
|
76 typedef OM_uint32 (*EXPORT_NAME_FN_PTR) |
|
77 (OM_uint32 *minor_status, |
|
78 gss_name_t input_name, |
|
79 gss_buffer_t exported_name); |
|
80 |
|
81 typedef OM_uint32 (*DISPLAY_NAME_FN_PTR) |
|
82 (OM_uint32 *minor_status, |
|
83 gss_name_t input_name, |
|
84 gss_buffer_t output_name_buffer, |
|
85 gss_OID *output_name_type); |
|
86 |
|
87 typedef OM_uint32 (*ACQUIRE_CRED_FN_PTR) |
|
88 (OM_uint32 *minor_status, |
|
89 gss_name_t desired_name, |
|
90 OM_uint32 time_req, |
|
91 gss_OID_set desired_mech, |
|
92 gss_cred_usage_t cred_usage, |
|
93 gss_cred_id_t *output_cred_handle, |
|
94 gss_OID_set *actual_mechs, |
|
95 OM_uint32 *time_rec); |
|
96 |
|
97 typedef OM_uint32 (*RELEASE_CRED_FN_PTR) |
|
98 (OM_uint32 *minor_status, |
|
99 gss_cred_id_t *cred_handle); |
|
100 |
|
101 typedef OM_uint32 (*INQUIRE_CRED_FN_PTR) |
|
102 (OM_uint32 *minor_status, |
|
103 gss_cred_id_t cred_handle, |
|
104 gss_name_t *name, |
|
105 OM_uint32 *lifetime, |
|
106 gss_cred_usage_t *cred_usage, |
|
107 gss_OID_set *mechanisms); |
|
108 |
|
109 typedef OM_uint32 (*IMPORT_SEC_CONTEXT_FN_PTR) |
|
110 (OM_uint32 *minor_status, |
|
111 gss_buffer_t interprocess_token, |
|
112 gss_ctx_id_t *context_handle); |
|
113 |
|
114 typedef OM_uint32 (*INIT_SEC_CONTEXT_FN_PTR) |
|
115 (OM_uint32 *minor_status, |
|
116 gss_cred_id_t initiator_cred_handle, |
|
117 gss_ctx_id_t *context_handle, |
|
118 gss_name_t *target_name, |
|
119 gss_OID mech_type, |
|
120 OM_uint32 req_flags, |
|
121 OM_uint32 time_req, |
|
122 gss_channel_bindings_t input_chan_bindings, |
|
123 gss_buffer_t input_token, |
|
124 gss_OID *actual_mech_type, |
|
125 gss_buffer_t output_token, |
|
126 OM_uint32 *ret_flags, |
|
127 OM_uint32 *time_rec); |
|
128 |
|
129 typedef OM_uint32 (*ACCEPT_SEC_CONTEXT_FN_PTR) |
|
130 (OM_uint32 *minor_status, |
|
131 gss_ctx_id_t *context_handle, |
|
132 gss_cred_id_t acceptor_cred_handle, |
|
133 gss_buffer_t input_token, |
|
134 gss_channel_bindings_t input_chan_bindings, |
|
135 gss_name_t *src_name, |
|
136 gss_OID *mech_type, |
|
137 gss_buffer_t output_token, |
|
138 OM_uint32 *ret_flags, |
|
139 OM_uint32 *time_rec, |
|
140 gss_cred_id_t *delegated_cred_handle); |
|
141 |
|
142 typedef OM_uint32 (*INQUIRE_CONTEXT_FN_PTR) |
|
143 (OM_uint32 *minor_status, |
|
144 gss_ctx_id_t context_handle, |
|
145 gss_name_t *src_name, |
|
146 gss_name_t *targ_name, |
|
147 OM_uint32 *lifetime_rec, |
|
148 gss_OID *mech_type, |
|
149 OM_uint32 *ctx_flags, |
|
150 int *locally_initiated, |
|
151 int *open); |
|
152 |
|
153 typedef OM_uint32 (*DELETE_SEC_CONTEXT_FN_PTR) |
|
154 (OM_uint32 *minor_status, |
|
155 gss_ctx_id_t *context_handle, |
|
156 gss_buffer_t output_token); |
|
157 |
|
158 typedef OM_uint32 (*CONTEXT_TIME_FN_PTR) |
|
159 (OM_uint32 *minor_status, |
|
160 gss_ctx_id_t *context_handle, |
|
161 OM_uint32 *time_rec); |
|
162 |
|
163 typedef OM_uint32 (*WRAP_SIZE_LIMIT_FN_PTR) |
|
164 (OM_uint32 *minor_status, |
|
165 gss_ctx_id_t context_handle, |
|
166 int conf_req_flag, |
|
167 gss_qop_t qop_req, |
|
168 OM_uint32 req_output_size, |
|
169 OM_uint32 *max_input_size); |
|
170 |
|
171 typedef OM_uint32 (*EXPORT_SEC_CONTEXT_FN_PTR) |
|
172 (OM_uint32 *minor_status, |
|
173 gss_ctx_id_t *context_handle, |
|
174 gss_buffer_t interprocess_token); |
|
175 |
|
176 typedef OM_uint32 (*GET_MIC_FN_PTR) |
|
177 (OM_uint32 *minor_status, |
|
178 gss_ctx_id_t context_handle, |
|
179 gss_qop_t qop_req, |
|
180 gss_buffer_t message_buffer, |
|
181 gss_buffer_t msg_token); |
|
182 |
|
183 typedef OM_uint32 (*VERIFY_MIC_FN_PTR) |
|
184 (OM_uint32 *minor_status, |
|
185 gss_ctx_id_t context_handle, |
|
186 gss_buffer_t message_buffer, |
|
187 gss_buffer_t token_buffer, |
|
188 gss_qop_t *qop_state); |
|
189 |
|
190 typedef OM_uint32 (*WRAP_FN_PTR) |
|
191 (OM_uint32 *minor_status, |
|
192 gss_ctx_id_t context_handle, |
|
193 int conf_req_flag, |
|
194 gss_qop_t qop_req, |
|
195 gss_buffer_t input_message_buffer, |
|
196 int *conf_state, |
|
197 gss_buffer_t output_message_buffer); |
|
198 |
|
199 typedef OM_uint32 (*UNWRAP_FN_PTR) |
|
200 (OM_uint32 *minor_status, |
|
201 gss_ctx_id_t context_handle, |
|
202 gss_buffer_t input_message_buffer, |
|
203 gss_buffer_t output_message_buffer, |
|
204 int *conf_state, |
|
205 gss_qop_t *qop_state); |
|
206 |
|
207 typedef OM_uint32 (*INDICATE_MECHS_FN_PTR) |
|
208 (OM_uint32 *minor_status, |
|
209 gss_OID_set *mech_set); |
|
210 |
|
211 typedef OM_uint32 (*INQUIRE_NAMES_FOR_MECH_FN_PTR) |
|
212 (OM_uint32 *minor_status, |
|
213 const gss_OID mechanism, |
|
214 gss_OID_set *name_types); |
|
215 |
|
216 typedef OM_uint32 (*ADD_OID_SET_MEMBER_FN_PTR) |
|
217 (OM_uint32 *minor_status, |
|
218 gss_OID member_oid, |
|
219 gss_OID_set *oid_set); |
|
220 |
|
221 typedef OM_uint32 (*DISPLAY_STATUS_FN_PTR) |
|
222 (OM_uint32 *minor_status, |
|
223 OM_uint32 status_value, |
|
224 int status_type, |
|
225 gss_OID mech_type, |
|
226 OM_uint32 *message_context, |
|
227 gss_buffer_t status_string); |
|
228 |
|
229 typedef OM_uint32 (*CREATE_EMPTY_OID_SET_FN_PTR) |
|
230 (OM_uint32 *minor_status, |
|
231 gss_OID_set *oid_set); |
|
232 |
|
233 typedef OM_uint32 (*RELEASE_OID_SET_FN_PTR) |
|
234 (OM_uint32 *minor_status, |
|
235 gss_OID_set *set); |
|
236 |
|
237 typedef OM_uint32 (*RELEASE_BUFFER_FN_PTR) |
|
238 (OM_uint32 *minor_status, |
|
239 gss_buffer_t buffer); |
|
240 |
|
241 |
|
242 /* dynamically resolved functions from gss library */ |
|
243 |
|
244 typedef struct GSS_FUNCTION_TABLE { |
|
245 gss_OID_set mechs; |
|
246 RELEASE_NAME_FN_PTR releaseName; |
|
247 IMPORT_NAME_FN_PTR importName; |
|
248 COMPARE_NAME_FN_PTR compareName; |
|
249 CANONICALIZE_NAME_FN_PTR canonicalizeName; |
|
250 EXPORT_NAME_FN_PTR exportName; |
|
251 DISPLAY_NAME_FN_PTR displayName; |
|
252 ACQUIRE_CRED_FN_PTR acquireCred; |
|
253 RELEASE_CRED_FN_PTR releaseCred; |
|
254 INQUIRE_CRED_FN_PTR inquireCred; |
|
255 IMPORT_SEC_CONTEXT_FN_PTR importSecContext; |
|
256 INIT_SEC_CONTEXT_FN_PTR initSecContext; |
|
257 ACCEPT_SEC_CONTEXT_FN_PTR acceptSecContext; |
|
258 INQUIRE_CONTEXT_FN_PTR inquireContext; |
|
259 DELETE_SEC_CONTEXT_FN_PTR deleteSecContext; |
|
260 CONTEXT_TIME_FN_PTR contextTime; |
|
261 WRAP_SIZE_LIMIT_FN_PTR wrapSizeLimit; |
|
262 EXPORT_SEC_CONTEXT_FN_PTR exportSecContext; |
|
263 GET_MIC_FN_PTR getMic; |
|
264 VERIFY_MIC_FN_PTR verifyMic; |
|
265 WRAP_FN_PTR wrap; |
|
266 UNWRAP_FN_PTR unwrap; |
|
267 INDICATE_MECHS_FN_PTR indicateMechs; |
|
268 INQUIRE_NAMES_FOR_MECH_FN_PTR inquireNamesForMech; |
|
269 ADD_OID_SET_MEMBER_FN_PTR addOidSetMember; |
|
270 DISPLAY_STATUS_FN_PTR displayStatus; |
|
271 CREATE_EMPTY_OID_SET_FN_PTR createEmptyOidSet; |
|
272 RELEASE_OID_SET_FN_PTR releaseOidSet; |
|
273 RELEASE_BUFFER_FN_PTR releaseBuffer; |
|
274 |
|
275 } GSS_FUNCTION_TABLE; |
|
276 |
|
277 typedef GSS_FUNCTION_TABLE *GSS_FUNCTION_TABLE_PTR; |
|
278 |
|
279 /* global GSS function table */ |
|
280 GSS_FUNCTION_TABLE_PTR ftab; |
|
281 |
|
282 #endif |