Path: blob/master/src/java.security.jgss/share/native/libj2gss/NativeFunc.h
41149 views
/*1* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#ifndef NATIVE_FUNC_H26#define NATIVE_FUNC_H2728#include "gssapi.h"2930#ifdef WIN3231#include <windows.h>32#define GETLIB(libName) LoadLibrary(libName)33#define GETFUNC(lib,name) GetProcAddress(lib,name)34#define CLOSELIB(lib) CloseHandle(lib)35#else36#include <dlfcn.h>37#define GETLIB(libName) dlopen(libName, RTLD_NOW)38#define GETFUNC(lib,name) dlsym(lib,name)39#define CLOSELIB(lib) dlclose(lib)40#endif4142#ifndef TRUE43#define TRUE 144#endif4546#ifndef FALSE47#define FALSE 048#endif4950int loadNative(const char *libName);5152/* function pointer definitions */53typedef OM_uint32 (*RELEASE_NAME_FN_PTR)54(OM_uint32 *minor_status,55gss_name_t *name);5657typedef OM_uint32 (*IMPORT_NAME_FN_PTR)58(OM_uint32 *minor_status,59gss_const_buffer_t input_name_buffer,60gss_const_OID input_name_type,61gss_name_t *output_name);6263typedef OM_uint32 (*COMPARE_NAME_FN_PTR)64(OM_uint32 *minor_status,65gss_const_name_t name1,66gss_const_name_t name2,67int *name_equal);6869typedef OM_uint32 (*CANONICALIZE_NAME_FN_PTR)70(OM_uint32 *minor_status,71gss_const_name_t input_name,72gss_const_OID mech_type,73gss_name_t *output_name);7475typedef OM_uint32 (*EXPORT_NAME_FN_PTR)76(OM_uint32 *minor_status,77gss_const_name_t input_name,78gss_buffer_t exported_name);7980typedef OM_uint32 (*DISPLAY_NAME_FN_PTR)81(OM_uint32 *minor_status,82gss_const_name_t input_name,83gss_buffer_t output_name_buffer,84gss_OID *output_name_type);8586typedef OM_uint32 (*ACQUIRE_CRED_FN_PTR)87(OM_uint32 *minor_status,88gss_const_name_t desired_name,89OM_uint32 time_req,90gss_const_OID_set desired_mech,91gss_cred_usage_t cred_usage,92gss_cred_id_t *output_cred_handle,93gss_OID_set *actual_mechs,94OM_uint32 *time_rec);9596typedef OM_uint32 (*RELEASE_CRED_FN_PTR)97(OM_uint32 *minor_status,98gss_cred_id_t *cred_handle);99100typedef OM_uint32 (*INQUIRE_CRED_FN_PTR)101(OM_uint32 *minor_status,102gss_const_cred_id_t cred_handle,103gss_name_t *name,104OM_uint32 *lifetime,105gss_cred_usage_t *cred_usage,106gss_OID_set *mechanisms);107108typedef OM_uint32 (*IMPORT_SEC_CONTEXT_FN_PTR)109(OM_uint32 *minor_status,110gss_const_buffer_t interprocess_token,111gss_ctx_id_t *context_handle);112113typedef OM_uint32 (*INIT_SEC_CONTEXT_FN_PTR)114(OM_uint32 *minor_status,115gss_const_cred_id_t initiator_cred_handle,116gss_ctx_id_t *context_handle,117gss_const_name_t target_name,118gss_const_OID mech_type,119OM_uint32 req_flags,120OM_uint32 time_req,121gss_const_channel_bindings_t input_chan_bindings,122gss_const_buffer_t input_token,123gss_OID *actual_mech_type,124gss_buffer_t output_token,125OM_uint32 *ret_flags,126OM_uint32 *time_rec);127128typedef OM_uint32 (*ACCEPT_SEC_CONTEXT_FN_PTR)129(OM_uint32 *minor_status,130gss_ctx_id_t *context_handle,131gss_const_cred_id_t acceptor_cred_handle,132gss_const_buffer_t input_token,133gss_const_channel_bindings_t input_chan_bindings,134gss_name_t *src_name,135gss_OID *mech_type,136gss_buffer_t output_token,137OM_uint32 *ret_flags,138OM_uint32 *time_rec,139gss_cred_id_t *delegated_cred_handle);140141typedef OM_uint32 (*INQUIRE_CONTEXT_FN_PTR)142(OM_uint32 *minor_status,143gss_const_ctx_id_t context_handle,144gss_name_t *src_name,145gss_name_t *targ_name,146OM_uint32 *lifetime_rec,147gss_OID *mech_type,148OM_uint32 *ctx_flags,149int *locally_initiated,150int *open);151152typedef OM_uint32 (*DELETE_SEC_CONTEXT_FN_PTR)153(OM_uint32 *minor_status,154gss_ctx_id_t *context_handle,155gss_buffer_t output_token);156157typedef OM_uint32 (*CONTEXT_TIME_FN_PTR)158(OM_uint32 *minor_status,159gss_const_ctx_id_t context_handle,160OM_uint32 *time_rec);161162typedef OM_uint32 (*WRAP_SIZE_LIMIT_FN_PTR)163(OM_uint32 *minor_status,164gss_const_ctx_id_t context_handle,165int conf_req_flag,166gss_qop_t qop_req,167OM_uint32 req_output_size,168OM_uint32 *max_input_size);169170typedef OM_uint32 (*EXPORT_SEC_CONTEXT_FN_PTR)171(OM_uint32 *minor_status,172gss_ctx_id_t *context_handle,173gss_buffer_t interprocess_token);174175typedef OM_uint32 (*GET_MIC_FN_PTR)176(OM_uint32 *minor_status,177gss_const_ctx_id_t context_handle,178gss_qop_t qop_req,179gss_const_buffer_t message_buffer,180gss_buffer_t msg_token);181182typedef OM_uint32 (*VERIFY_MIC_FN_PTR)183(OM_uint32 *minor_status,184gss_const_ctx_id_t context_handle,185gss_const_buffer_t message_buffer,186gss_const_buffer_t token_buffer,187gss_qop_t *qop_state);188189typedef OM_uint32 (*WRAP_FN_PTR)190(OM_uint32 *minor_status,191gss_const_ctx_id_t context_handle,192int conf_req_flag,193gss_qop_t qop_req,194gss_const_buffer_t input_message_buffer,195int *conf_state,196gss_buffer_t output_message_buffer);197198typedef OM_uint32 (*UNWRAP_FN_PTR)199(OM_uint32 *minor_status,200gss_const_ctx_id_t context_handle,201gss_const_buffer_t input_message_buffer,202gss_buffer_t output_message_buffer,203int *conf_state,204gss_qop_t *qop_state);205206typedef OM_uint32 (*INDICATE_MECHS_FN_PTR)207(OM_uint32 *minor_status,208gss_OID_set *mech_set);209210typedef OM_uint32 (*INQUIRE_NAMES_FOR_MECH_FN_PTR)211(OM_uint32 *minor_status,212gss_const_OID mechanism,213gss_OID_set *name_types);214215typedef OM_uint32 (*ADD_OID_SET_MEMBER_FN_PTR)216(OM_uint32 *minor_status,217gss_const_OID member_oid,218gss_OID_set *oid_set);219220typedef OM_uint32 (*DISPLAY_STATUS_FN_PTR)221(OM_uint32 *minor_status,222OM_uint32 status_value,223int status_type,224gss_const_OID mech_type,225OM_uint32 *message_context,226gss_buffer_t status_string);227228typedef OM_uint32 (*CREATE_EMPTY_OID_SET_FN_PTR)229(OM_uint32 *minor_status,230gss_OID_set *oid_set);231232typedef OM_uint32 (*RELEASE_OID_SET_FN_PTR)233(OM_uint32 *minor_status,234gss_OID_set *set);235236typedef OM_uint32 (*RELEASE_BUFFER_FN_PTR)237(OM_uint32 *minor_status,238gss_buffer_t buffer);239240241/* dynamically resolved functions from gss library */242243typedef struct GSS_FUNCTION_TABLE {244gss_OID_set mechs;245RELEASE_NAME_FN_PTR releaseName;246IMPORT_NAME_FN_PTR importName;247COMPARE_NAME_FN_PTR compareName;248CANONICALIZE_NAME_FN_PTR canonicalizeName;249EXPORT_NAME_FN_PTR exportName;250DISPLAY_NAME_FN_PTR displayName;251ACQUIRE_CRED_FN_PTR acquireCred;252RELEASE_CRED_FN_PTR releaseCred;253INQUIRE_CRED_FN_PTR inquireCred;254IMPORT_SEC_CONTEXT_FN_PTR importSecContext;255INIT_SEC_CONTEXT_FN_PTR initSecContext;256ACCEPT_SEC_CONTEXT_FN_PTR acceptSecContext;257INQUIRE_CONTEXT_FN_PTR inquireContext;258DELETE_SEC_CONTEXT_FN_PTR deleteSecContext;259CONTEXT_TIME_FN_PTR contextTime;260WRAP_SIZE_LIMIT_FN_PTR wrapSizeLimit;261EXPORT_SEC_CONTEXT_FN_PTR exportSecContext;262GET_MIC_FN_PTR getMic;263VERIFY_MIC_FN_PTR verifyMic;264WRAP_FN_PTR wrap;265UNWRAP_FN_PTR unwrap;266INDICATE_MECHS_FN_PTR indicateMechs;267INQUIRE_NAMES_FOR_MECH_FN_PTR inquireNamesForMech;268ADD_OID_SET_MEMBER_FN_PTR addOidSetMember;269DISPLAY_STATUS_FN_PTR displayStatus;270CREATE_EMPTY_OID_SET_FN_PTR createEmptyOidSet;271RELEASE_OID_SET_FN_PTR releaseOidSet;272RELEASE_BUFFER_FN_PTR releaseBuffer;273274} GSS_FUNCTION_TABLE;275276typedef GSS_FUNCTION_TABLE *GSS_FUNCTION_TABLE_PTR;277278/* global GSS function table */279extern GSS_FUNCTION_TABLE_PTR ftab;280281#endif282283284