Path: blob/main/crypto/krb5/src/lib/gssapi/generic/gssapi_ext.h
39563 views
/*1* Copyright 2008 by the Massachusetts Institute of Technology.2* All Rights Reserved.3*4* Export of this software from the United States of America may5* require a specific license from the United States Government.6* It is the responsibility of any person or organization contemplating7* export to obtain such a license before exporting.8*9* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and10* distribute this software and its documentation for any purpose and11* without fee is hereby granted, provided that the above copyright12* notice appear in all copies and that both that copyright notice and13* this permission notice appear in supporting documentation, and that14* the name of M.I.T. not be used in advertising or publicity pertaining15* to distribution of the software without specific, written prior16* permission. Furthermore if you modify this software you must label17* your software as modified software and not distribute it in such a18* fashion that it might be confused with the original M.I.T. software.19* M.I.T. makes no representations about the suitability of20* this software for any purpose. It is provided "as is" without express21* or implied warranty.22*/2324#ifndef GSSAPI_EXT_H_25#define GSSAPI_EXT_H_2627#include <gssapi/gssapi.h>2829#ifdef __cplusplus30extern "C" {31#endif /* __cplusplus */3233/*34* Solaris extensions35*/36#ifndef _WIN3237OM_uint32 KRB5_CALLCONV38gss_pname_to_uid39(OM_uint32 *minor,40const gss_name_t name,41const gss_OID mech_type,42uid_t *uidOut);43#endif4445/**46* Provides a platform-specific name for a GSSAPI name as interpreted by a47* given mechanism.48*49* @param [out] minor Minor status code50* @param [in] name The gss name resulting from accept_sec_context51* @param [in] mech_type The mechanism that will be asked to map @a name to a52* local name53* @param [out] localname Caller-allocated buffer to be filled in with the54* local name on success55*/56OM_uint32 KRB5_CALLCONV57gss_localname58(OM_uint32 *minor,59const gss_name_t name,60gss_const_OID mech_type,61gss_buffer_t localname);6263/**64* Determine whether a mechanism name is authorized to act as a username.65*66* @param [in] name Mechanism name67* @param [in] username System username68*69* This is a simple wrapper around gss_authorize_localname(). It only supports70* system usernames as local names, and cannot distinguish between lack of71* authorization and other errors.72*73* @retval 1 @a name is authorized to act as @a username74* @retval 0 @a name is not authorized or an error occurred75*/76int KRB5_CALLCONV77gss_userok(const gss_name_t name,78const char *username);7980/**81* Determine whether a mechanism name is authorized to act as a local name.82*83* @param [out] minor Minor status code84* @param [in] name Mechanism name85* @param [in] user Local name86*87* @a name is a mechanism name, typically the result of a completed88* gss_accept_sec_context(). @a user is an internal name representing a local89* name, such as a name imported by gss_import_name() with an @a90* input_name_type of @c GSS_C_NT_USER_NAME.91*92* @return Return GSS_S_COMPLETE if @a name is authorized to act as @a user,93* GSS_S_UNAUTHORIZED if not, or an appropriate GSS error code if an error94* occurred.95*96* @sa gss_userok97*/98OM_uint32 KRB5_CALLCONV99gss_authorize_localname(OM_uint32 *minor,100const gss_name_t name,101const gss_name_t user);102103OM_uint32 KRB5_CALLCONV104gss_acquire_cred_with_password(105OM_uint32 *, /* minor_status */106const gss_name_t, /* desired_name */107const gss_buffer_t, /* password */108OM_uint32, /* time_req */109const gss_OID_set, /* desired_mechs */110gss_cred_usage_t, /* cred_usage */111gss_cred_id_t *, /* output_cred_handle */112gss_OID_set *, /* actual_mechs */113OM_uint32 *); /* time_rec */114115OM_uint32 KRB5_CALLCONV116gss_add_cred_with_password(117OM_uint32 *, /* minor_status */118const gss_cred_id_t,/* input_cred_handle */119const gss_name_t, /* desired_name */120const gss_OID, /* desired_mech */121const gss_buffer_t, /* password */122gss_cred_usage_t, /* cred_usage */123OM_uint32, /* initiator_time_req */124OM_uint32, /* acceptor_time_req */125gss_cred_id_t *, /* output_cred_handle */126gss_OID_set *, /* actual_mechs */127OM_uint32 *, /* initiator_time_rec */128OM_uint32 *); /* acceptor_time_rec */129130/*131* GGF extensions132*/133typedef struct gss_buffer_set_desc_struct {134size_t count;135gss_buffer_desc *elements;136} gss_buffer_set_desc, *gss_buffer_set_t;137138#define GSS_C_NO_BUFFER_SET ((gss_buffer_set_t) 0)139140OM_uint32 KRB5_CALLCONV gss_create_empty_buffer_set141(OM_uint32 * /*minor_status*/,142gss_buffer_set_t * /*buffer_set*/);143144OM_uint32 KRB5_CALLCONV gss_add_buffer_set_member145(OM_uint32 * /*minor_status*/,146const gss_buffer_t /*member_buffer*/,147gss_buffer_set_t * /*buffer_set*/);148149OM_uint32 KRB5_CALLCONV gss_release_buffer_set150(OM_uint32 * /*minor_status*/,151gss_buffer_set_t * /*buffer_set*/);152153OM_uint32 KRB5_CALLCONV gss_inquire_sec_context_by_oid154(OM_uint32 * /*minor_status*/,155const gss_ctx_id_t /*context_handle*/,156const gss_OID /*desired_object*/,157gss_buffer_set_t * /*data_set*/);158159OM_uint32 KRB5_CALLCONV gss_inquire_cred_by_oid160(OM_uint32 * /*minor_status*/,161const gss_cred_id_t /*cred_handle*/,162const gss_OID /*desired_object*/,163gss_buffer_set_t * /*data_set*/);164165OM_uint32 KRB5_CALLCONV gss_set_sec_context_option166(OM_uint32 * /*minor_status*/,167gss_ctx_id_t * /*cred_handle*/,168const gss_OID /*desired_object*/,169const gss_buffer_t /*value*/);170171/*172* Export import cred extensions from GGF, but using Heimdal's signatures173*/174OM_uint32 KRB5_CALLCONV gss_export_cred175(OM_uint32 * /* minor_status */,176gss_cred_id_t /* cred_handle */,177gss_buffer_t /* token */);178179OM_uint32 KRB5_CALLCONV gss_import_cred180(OM_uint32 * /* minor_status */,181gss_buffer_t /* token */,182gss_cred_id_t * /* cred_handle */);183184/*185* Heimdal extension186*/187OM_uint32 KRB5_CALLCONV gss_set_cred_option188(OM_uint32 * /*minor_status*/,189gss_cred_id_t * /*cred*/,190const gss_OID /*desired_object*/,191const gss_buffer_t /*value*/);192193/*194* Call the given method on the given mechanism195*/196OM_uint32 KRB5_CALLCONV gssspi_mech_invoke197(OM_uint32 * /*minor_status*/,198const gss_OID /*desired_mech*/,199const gss_OID /*desired_object*/,200gss_buffer_t /*value*/);201202/*203* AEAD extensions204*/205206OM_uint32 KRB5_CALLCONV gss_wrap_aead207(OM_uint32 * /*minor_status*/,208gss_ctx_id_t /*context_handle*/,209int /*conf_req_flag*/,210gss_qop_t /*qop_req*/,211gss_buffer_t /*input_assoc_buffer*/,212gss_buffer_t /*input_payload_buffer*/,213int * /*conf_state*/,214gss_buffer_t /*output_message_buffer*/);215216OM_uint32 KRB5_CALLCONV gss_unwrap_aead217(OM_uint32 * /*minor_status*/,218gss_ctx_id_t /*context_handle*/,219gss_buffer_t /*input_message_buffer*/,220gss_buffer_t /*input_assoc_buffer*/,221gss_buffer_t /*output_payload_buffer*/,222int * /*conf_state*/,223gss_qop_t * /*qop_state*/);224225/*226* SSPI extensions227*/228#define GSS_C_DCE_STYLE 0x1000229#define GSS_C_IDENTIFY_FLAG 0x2000230#define GSS_C_EXTENDED_ERROR_FLAG 0x4000231232/*233* Returns a buffer set with the first member containing the234* session key for SSPI compatibility. The optional second235* member contains an OID identifying the session key type.236*/237GSS_DLLIMP extern gss_OID GSS_C_INQ_SSPI_SESSION_KEY;238239/*240* Returns a buffer set with the first member containing the ticket session key241* for ODBC compatibility. The optional second member contains an OID242* identifying the session key type.243*/244GSS_DLLIMP extern gss_OID GSS_C_INQ_ODBC_SESSION_KEY;245246GSS_DLLIMP extern gss_OID GSS_C_INQ_NEGOEX_KEY;247GSS_DLLIMP extern gss_OID GSS_C_INQ_NEGOEX_VERIFY_KEY;248249OM_uint32 KRB5_CALLCONV gss_complete_auth_token250(OM_uint32 *minor_status,251const gss_ctx_id_t context_handle,252gss_buffer_t input_message_buffer);253254typedef struct gss_iov_buffer_desc_struct {255OM_uint32 type;256gss_buffer_desc buffer;257} gss_iov_buffer_desc, *gss_iov_buffer_t;258259#define GSS_C_NO_IOV_BUFFER ((gss_iov_buffer_t)0)260261#define GSS_IOV_BUFFER_TYPE_EMPTY 0262#define GSS_IOV_BUFFER_TYPE_DATA 1 /* Packet data */263#define GSS_IOV_BUFFER_TYPE_HEADER 2 /* Mechanism header */264#define GSS_IOV_BUFFER_TYPE_MECH_PARAMS 3 /* Mechanism specific parameters */265#define GSS_IOV_BUFFER_TYPE_TRAILER 7 /* Mechanism trailer */266#define GSS_IOV_BUFFER_TYPE_PADDING 9 /* Padding */267#define GSS_IOV_BUFFER_TYPE_STREAM 10 /* Complete wrap token */268#define GSS_IOV_BUFFER_TYPE_SIGN_ONLY 11 /* Sign only packet data */269#define GSS_IOV_BUFFER_TYPE_MIC_TOKEN 12 /* MIC token destination */270271#define GSS_IOV_BUFFER_FLAG_MASK 0xFFFF0000272#define GSS_IOV_BUFFER_FLAG_ALLOCATE 0x00010000 /* indicates GSS should allocate */273#define GSS_IOV_BUFFER_FLAG_ALLOCATED 0x00020000 /* indicates caller should free */274275#define GSS_IOV_BUFFER_TYPE(_type) ((_type) & ~(GSS_IOV_BUFFER_FLAG_MASK))276#define GSS_IOV_BUFFER_FLAGS(_type) ((_type) & GSS_IOV_BUFFER_FLAG_MASK)277278/*279* Sign and optionally encrypt a sequence of buffers. The buffers280* shall be ordered HEADER | DATA | PADDING | TRAILER. Suitable281* space for the header, padding and trailer should be provided282* by calling gss_wrap_iov_length(), or the ALLOCATE flag should283* be set on those buffers.284*285* Encryption is in-place. SIGN_ONLY buffers are untouched. Only286* a single PADDING buffer should be provided. The order of the287* buffers in memory does not matter. Buffers in the IOV should288* be arranged in the order above, and in the case of multiple289* DATA buffers the sender and receiver should agree on the290* order.291*292* With GSS_C_DCE_STYLE it is acceptable to not provide PADDING293* and TRAILER, but the caller must guarantee the plaintext data294* being encrypted is correctly padded, otherwise an error will295* be returned.296*297* While applications that have knowledge of the underlying298* cryptosystem may request a specific configuration of data299* buffers, the only generally supported configurations are:300*301* HEADER | DATA | PADDING | TRAILER302*303* which will emit GSS_Wrap() compatible tokens, and:304*305* HEADER | SIGN_ONLY | DATA | PADDING | TRAILER306*307* for AEAD.308*309* The typical (special cased) usage for DCE is as follows:310*311* SIGN_ONLY_1 | DATA | SIGN_ONLY_2 | HEADER312*/313OM_uint32 KRB5_CALLCONV gss_wrap_iov314(315OM_uint32 *, /* minor_status */316gss_ctx_id_t, /* context_handle */317int, /* conf_req_flag */318gss_qop_t, /* qop_req */319int *, /* conf_state */320gss_iov_buffer_desc *, /* iov */321int); /* iov_count */322323/*324* Verify and optionally decrypt a sequence of buffers. To process325* a GSS-API message without separate buffer, pass STREAM | DATA.326* Upon return DATA will contain the decrypted or integrity327* protected message. Only a single DATA buffer may be provided328* with this usage. DATA by default will point into STREAM, but if329* the ALLOCATE flag is set a copy will be returned.330*331* Otherwise, decryption is in-place. SIGN_ONLY buffers are332* untouched.333*/334OM_uint32 KRB5_CALLCONV gss_unwrap_iov335(336OM_uint32 *, /* minor_status */337gss_ctx_id_t, /* context_handle */338int *, /* conf_state */339gss_qop_t *, /* qop_state */340gss_iov_buffer_desc *, /* iov */341int); /* iov_count */342343/*344* Query HEADER, PADDING and TRAILER buffer lengths. DATA buffers345* should be provided so the correct padding length can be determined.346*/347OM_uint32 KRB5_CALLCONV gss_wrap_iov_length348(349OM_uint32 *, /* minor_status */350gss_ctx_id_t, /* context_handle */351int, /* conf_req_flag */352gss_qop_t, /* qop_req */353int *, /* conf_state */354gss_iov_buffer_desc *, /* iov */355int); /* iov_count */356357/*358* Produce a GSSAPI MIC token for a sequence of buffers. All SIGN_ONLY and359* DATA buffers will be signed, in the order they appear. One MIC_TOKEN buffer360* must be included for the result. Suitable space should be provided for the361* MIC_TOKEN buffer by calling gss_get_mic_iov_length, or the ALLOCATE flag362* should be set on that buffer. If the ALLOCATE flag is used, use363* gss_release_iov_buffer to free the allocated buffer within the iov list when364* it is no longer needed.365*/366OM_uint32 KRB5_CALLCONV gss_get_mic_iov367(368OM_uint32 *, /* minor_status */369gss_ctx_id_t, /* context_handle */370gss_qop_t, /* qop_req */371gss_iov_buffer_desc *, /* iov */372int); /* iov_count */373374/*375* Query the MIC_TOKEN buffer length within the iov list.376*/377OM_uint32 KRB5_CALLCONV gss_get_mic_iov_length(378OM_uint32 *, /* minor_status */379gss_ctx_id_t, /* context_handle */380gss_qop_t, /* qop_req */381gss_iov_buffer_desc *, /* iov */382int); /* iov_count */383384/*385* Verify the MIC_TOKEN buffer within the iov list against the SIGN_ONLY and386* DATA buffers in the order they appear. Return values are the same as for387* gss_verify_mic.388*/389OM_uint32 KRB5_CALLCONV gss_verify_mic_iov390(391OM_uint32 *, /* minor_status */392gss_ctx_id_t, /* context_handle */393gss_qop_t *, /* qop_state */394gss_iov_buffer_desc *, /* iov */395int); /* iov_count */396397/*398* Release buffers that have the ALLOCATED flag set.399*/400OM_uint32 KRB5_CALLCONV gss_release_iov_buffer401(402OM_uint32 *, /* minor_status */403gss_iov_buffer_desc *, /* iov */404int); /* iov_count */405406/*407* Protocol transition408*/409OM_uint32 KRB5_CALLCONV410gss_acquire_cred_impersonate_name(411OM_uint32 *, /* minor_status */412const gss_cred_id_t, /* impersonator_cred_handle */413const gss_name_t, /* desired_name */414OM_uint32, /* time_req */415const gss_OID_set, /* desired_mechs */416gss_cred_usage_t, /* cred_usage */417gss_cred_id_t *, /* output_cred_handle */418gss_OID_set *, /* actual_mechs */419OM_uint32 *); /* time_rec */420421OM_uint32 KRB5_CALLCONV422gss_add_cred_impersonate_name(423OM_uint32 *, /* minor_status */424gss_cred_id_t, /* input_cred_handle */425const gss_cred_id_t, /* impersonator_cred_handle */426const gss_name_t, /* desired_name */427const gss_OID, /* desired_mech */428gss_cred_usage_t, /* cred_usage */429OM_uint32, /* initiator_time_req */430OM_uint32, /* acceptor_time_req */431gss_cred_id_t *, /* output_cred_handle */432gss_OID_set *, /* actual_mechs */433OM_uint32 *, /* initiator_time_rec */434OM_uint32 *); /* acceptor_time_rec */435436/*437* Naming extensions438*/439GSS_DLLIMP extern gss_buffer_t GSS_C_ATTR_LOCAL_LOGIN_USER;440GSS_DLLIMP extern gss_OID GSS_C_NT_COMPOSITE_EXPORT;441442OM_uint32 KRB5_CALLCONV gss_display_name_ext443(444OM_uint32 *, /* minor_status */445gss_name_t, /* name */446gss_OID, /* display_as_name_type */447gss_buffer_t /* display_name */448);449450OM_uint32 KRB5_CALLCONV gss_inquire_name451(452OM_uint32 *, /* minor_status */453gss_name_t, /* name */454int *, /* name_is_MN */455gss_OID *, /* MN_mech */456gss_buffer_set_t * /* attrs */457);458459OM_uint32 KRB5_CALLCONV gss_get_name_attribute460(461OM_uint32 *, /* minor_status */462gss_name_t, /* name */463gss_buffer_t, /* attr */464int *, /* authenticated */465int *, /* complete */466gss_buffer_t, /* value */467gss_buffer_t, /* display_value */468int * /* more */469);470471OM_uint32 KRB5_CALLCONV gss_set_name_attribute472(473OM_uint32 *, /* minor_status */474gss_name_t, /* name */475int, /* complete */476gss_buffer_t, /* attr */477gss_buffer_t /* value */478);479480OM_uint32 KRB5_CALLCONV gss_delete_name_attribute481(482OM_uint32 *, /* minor_status */483gss_name_t, /* name */484gss_buffer_t /* attr */485);486487OM_uint32 KRB5_CALLCONV gss_export_name_composite488(489OM_uint32 *, /* minor_status */490gss_name_t, /* name */491gss_buffer_t /* exp_composite_name */492);493494typedef struct gss_any *gss_any_t;495496OM_uint32 KRB5_CALLCONV gss_map_name_to_any497(498OM_uint32 *, /* minor_status */499gss_name_t, /* name */500int, /* authenticated */501gss_buffer_t, /* type_id */502gss_any_t * /* output */503);504505OM_uint32 KRB5_CALLCONV gss_release_any_name_mapping506(507OM_uint32 *, /* minor_status */508gss_name_t, /* name */509gss_buffer_t, /* type_id */510gss_any_t * /* input */511);512513/* draft-josefsson-gss-capsulate */514OM_uint32 KRB5_CALLCONV gss_encapsulate_token515(516gss_const_buffer_t, /* input_token */517gss_const_OID, /* token_oid */518gss_buffer_t /* output_token */519);520521OM_uint32 KRB5_CALLCONV gss_decapsulate_token522(523gss_const_buffer_t, /* input_token */524gss_const_OID, /* token_oid */525gss_buffer_t /* output_token */526);527528int KRB5_CALLCONV gss_oid_equal529(530gss_const_OID, /* first_oid */531gss_const_OID /* second_oid */532);533534/* Credential store extensions */535536struct gss_key_value_element_struct {537const char *key;538const char *value;539};540typedef struct gss_key_value_element_struct gss_key_value_element_desc;541542struct gss_key_value_set_struct {543OM_uint32 count;544gss_key_value_element_desc *elements;545};546typedef struct gss_key_value_set_struct gss_key_value_set_desc;547typedef const gss_key_value_set_desc *gss_const_key_value_set_t;548549#define GSS_C_NO_CRED_STORE ((gss_const_key_value_set_t) 0)550551OM_uint32 KRB5_CALLCONV552gss_acquire_cred_from(553OM_uint32 *, /* minor_status */554gss_name_t, /* desired_name */555OM_uint32, /* time_req */556gss_OID_set, /* desired_mechs */557gss_cred_usage_t, /* cred_usage */558gss_const_key_value_set_t, /* cred_store */559gss_cred_id_t *, /* output_cred_handle */560gss_OID_set *, /* actual_mechs */561OM_uint32 *); /* time_rec */562563OM_uint32 KRB5_CALLCONV564gss_add_cred_from(565OM_uint32 *, /* minor_status */566gss_cred_id_t, /* input_cred_handle */567gss_name_t, /* desired_name */568gss_OID, /* desired_mech */569gss_cred_usage_t, /* cred_usage */570OM_uint32, /* initiator_time_req */571OM_uint32, /* acceptor_time_req */572gss_const_key_value_set_t, /* cred_store */573gss_cred_id_t *, /* output_cred_handle */574gss_OID_set *, /* actual_mechs */575OM_uint32 *, /* initiator_time_rec */576OM_uint32 *); /* acceptor_time_rec */577578OM_uint32 KRB5_CALLCONV579gss_store_cred_into(580OM_uint32 *, /* minor_status */581gss_cred_id_t, /* input_cred_handle */582gss_cred_usage_t, /* input_usage */583gss_OID, /* desired_mech */584OM_uint32, /* overwrite_cred */585OM_uint32, /* default_cred */586gss_const_key_value_set_t, /* cred_store */587gss_OID_set *, /* elements_stored */588gss_cred_usage_t *); /* cred_usage_stored */589590/*591* A mech can make itself negotiable via NegoEx (draft-zhu-negoex) by592* implementing the following three SPIs, and also implementing593* gss_inquire_sec_context_by_oid() and answering the GSS_C_INQ_NEGOEX_KEY and594* GSS_C_INQ_NEGOEX_VERIFY_KEY OIDs. The answer must be in two buffers: the595* first contains the key contents, and the second contains the key enctype as596* a four-byte little-endian integer.597*598* By default, NegoEx mechanisms will not be directly negotiated via SPNEGO.599* If direct SPNEGO negotiation is required for interoperability, implement600* gss_inquire_attrs_for_mech() and assert the GSS_C_MA_NEGOEX_AND_SPNEGO601* attribute (along with any applicable RFC 5587 attributes).602*/603604#define GSS_C_CHANNEL_BOUND_FLAG 2048 /* 0x00000800 */605606OM_uint32 KRB5_CALLCONV607gssspi_query_meta_data(608OM_uint32 *minor_status,609gss_const_OID mech_oid,610gss_cred_id_t cred_handle,611gss_ctx_id_t *context_handle,612const gss_name_t targ_name,613OM_uint32 req_flags,614gss_buffer_t meta_data);615616OM_uint32 KRB5_CALLCONV617gssspi_exchange_meta_data(618OM_uint32 *minor_status,619gss_const_OID mech_oid,620gss_cred_id_t cred_handle,621gss_ctx_id_t *context_handle,622const gss_name_t targ_name,623OM_uint32 req_flags,624gss_const_buffer_t meta_data);625626OM_uint32 KRB5_CALLCONV627gssspi_query_mechanism_info(628OM_uint32 *minor_status,629gss_const_OID mech_oid,630unsigned char auth_scheme[16]);631632GSS_DLLIMP extern gss_const_OID GSS_C_MA_NEGOEX_AND_SPNEGO;633634#ifdef __cplusplus635}636#endif637638/*639* When used with gss_inquire_sec_context_by_oid(), return a buffer set with640* the first member containing an unsigned 32-bit integer in network byte641* order. This is the Security Strength Factor (SSF) associated with the642* secure channel established by the security context. NOTE: This value is643* made available solely as an indication for use by APIs like Cyrus SASL that644* classify the strength of a secure channel via this number. The strength of645* a channel cannot necessarily be represented by a simple number.646*/647GSS_DLLIMP extern gss_OID GSS_C_SEC_CONTEXT_SASL_SSF;648649#endif /* GSSAPI_EXT_H_ */650651652