Path: blob/main/crypto/krb5/src/windows/lib/cacheapi.h
34907 views
/* windows/lib/cacheapi.h */1/*2* Copyright 1997 by the Regents of the University of Michigan3*4* This software is being provided to you, the LICENSEE, by the5* Regents of the University of Michigan (UM) under the following6* license. By obtaining, using and/or copying this software, you agree7* that you have read, understood, and will comply with these terms and8* conditions:9*10* Permission to use, copy, modify and distribute this software and its11* documentation for any purpose and without fee or royalty is hereby12* granted, provided that you agree to comply with the following copyright13* notice and statements, including the disclaimer, and that the same14* appear on ALL copies of the software and documentation, including15* modifications that you make for internal use or for distribution:16*17* Copyright 1997 by the Regents of the University of Michigan.18* All rights reserved.19*20* THIS SOFTWARE IS PROVIDED "AS IS", AND UM MAKES NO REPRESENTATIONS21* OR WARRANTIES, EXPRESS OR IMPLIED. By way of example, but not22* limitation, UM MAKES NO REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY23* OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE LICENSED24* SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS,25* COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.26*27* The name of the University of Michigan or UM may NOT be used in28* advertising or publicity pertaining to distribution of the software.29* Title to copyright in this software and any associated documentation30* shall at all times remain with UM, and USER agrees to preserve same.31*32* The University of Michigan33* c/o Steve Rothwell <[email protected]>34* 535 W. William Street35* Ann Arbor, Michigan 48013-494336* U.S.A.37*/3839/*40** CacheAPI.h41**42** The externally visible functions and data structures43** for the Kerberos Common Cache DLL44** This should be the ONLY externally visible file.45** This is ALL anyone should need to call the API.46**47**48*/4950#ifndef Krb_CCacheAPI_h_51#define Krb_CCacheAPI_h_5253#include <windows.h>5455//typedef int cc_int32;56#define cc_int32 long57#define cc_uint32 unsigned long5859typedef cc_int32 cc_time_t;6061#define CC_API_VER_1 162#define CC_API_VER_2 26364//enum {65// CC_API_VER_1 = 1,66// CC_API_VER_2 = 267//};6869#define CCACHE_API __declspec(dllexport) cc_int327071/*72** The Official Error Codes73*/74#define CC_NOERROR 075#define CC_BADNAME 176#define CC_NOTFOUND 277#define CC_END 378#define CC_IO 479#define CC_WRITE 580#define CC_NOMEM 681#define CC_FORMAT 782#define CC_LOCKED 883#define CC_BAD_API_VERSION 984#define CC_NO_EXIST 1085#define CC_NOT_SUPP 1186#define CC_BAD_PARM 1287#define CC_ERR_CACHE_ATTACH 1388#define CC_ERR_CACHE_RELEASE 1489#define CC_ERR_CACHE_FULL 1590#define CC_ERR_CRED_VERSION 169192/*93** types, structs, & constants94*/95// Flag bits promised by Ted "RSN"96#define CC_FLAGS_RESERVED 0xFFFFFFFF9798typedef cc_uint32 cc_nc_flags; // set via constants above99100typedef struct opaque_dll_control_block_type* apiCB;101typedef struct opaque_ccache_pointer_type* ccache_p;102typedef struct opaque_credential_iterator_type* ccache_cit;103104typedef struct _cc_data105{106cc_uint32 type; // should be one of _cc_data_type107cc_uint32 length;108unsigned char* data; // the proverbial bag-o-bits109} cc_data;110111// V5 Credentials112typedef struct _cc_creds {113char* client;114char* server;115cc_data keyblock;116cc_time_t authtime;117cc_time_t starttime;118cc_time_t endtime;119cc_time_t renew_till;120cc_uint32 is_skey;121cc_uint32 ticket_flags;122cc_data ** addresses;123cc_data ticket;124cc_data second_ticket;125cc_data ** authdata;126} cc_creds;127128129typedef union cred_ptr_union_type {130cc_creds* pV5Cred;131} cred_ptr_union;132133typedef struct cred_union_type {134cc_int32 cred_type;135cred_ptr_union cred;136} cred_union;137138typedef struct _infoNC {139char* name;140char* principal;141cc_int32 vers;142} infoNC;143144/*145** The official (externally visible) API146*/147148#ifdef __cplusplus149extern "C" /* this entire list of functions */150{151#endif /* __cplusplus */152153/*154** Main cache routines : initialize, shutdown, get_cache_names, & get_change_time155*/156CCACHE_API157cc_initialize(158apiCB** cc_ctx, // < DLL's primary control structure.159// returned here, passed everywhere else160cc_int32 api_version, // > ver supported by caller (use CC_API_VER_1)161cc_int32* api_supported, // < if ~NULL, max ver supported by DLL162const char** vendor // < if ~NULL, vendor name in read only C string163);164165CCACHE_API166cc_shutdown(167apiCB** cc_ctx // <> DLL's primary control structure. NULL after call.168);169170CCACHE_API171cc_get_change_time(172apiCB* cc_ctx, // > DLL's primary control structure173cc_time_t* time // < time of last change to main cache174);175176/*177** Named Cache (NC) routines178** create, open, close, destroy, get_principal, get_cred_version, &179** lock_request180**181** Multiple NCs are allowed within the main cache. Each has a Name and182** kerberos version # (V5). Caller gets "ccache_ptr"s for NCs.183*/184CCACHE_API185cc_create(186apiCB* cc_ctx, // > DLL's primary control structure187const char* name, // > name of cache to be [destroyed if exists, then] created188const char* principal,189cc_int32 vers, // > ticket version (CC_CRED_V5)190cc_uint32 cc_flags, // > options191ccache_p** ccache_ptr // < NC control structure192);193194CCACHE_API195cc_open(196apiCB* cc_ctx, // > DLL's primary control structure197const char* name, // > name of pre-created cache198cc_int32 vers, // > ticket version (CC_CRED_V5)199cc_uint32 cc_flags, // > options200ccache_p** ccache_ptr // < NC control structure201);202203CCACHE_API204cc_close(205apiCB* cc_ctx, // > DLL's primary control structure206ccache_p** ccache_ptr // <> NC control structure. NULL after call.207);208209CCACHE_API210cc_destroy(211apiCB* cc_ctx, // > DLL's primary control structure212ccache_p** ccache_ptr // <> NC control structure. NULL after call.213);214215/*216** Ways to get information about the NCs217*/218219CCACHE_API220cc_seq_fetch_NCs_begin(221apiCB* cc_ctx,222ccache_cit** itNCs223);224225CCACHE_API226cc_seq_fetch_NCs_end(227apiCB* cc_ctx,228ccache_cit** itNCs229);230231CCACHE_API232cc_seq_fetch_NCs_next(233apiCB* cc_ctx,234ccache_p** ccache_ptr,235ccache_cit* itNCs236);237238CCACHE_API239cc_seq_fetch_NCs(240apiCB* cc_ctx, // > DLL's primary control structure241ccache_p** ccache_ptr, // < NC control structure (free via cc_close())242ccache_cit** itNCs // <> iterator used by DLL,243// set to NULL before first call244// returned NULL at CC_END245);246247CCACHE_API248cc_get_NC_info(249apiCB* cc_ctx, // > DLL's primary control structure250struct _infoNC*** ppNCi // < (NULL before call) null terminated,251// list of a structs (free via cc_free_infoNC())252);253254CCACHE_API255cc_free_NC_info(256apiCB* cc_ctx,257struct _infoNC*** ppNCi // < free list of structs returned by258// cc_get_cache_names(). set to NULL on return259);260261/*262** Functions that provide distinguishing characteristics of NCs.263*/264265CCACHE_API266cc_get_name(267apiCB* cc_ctx, // > DLL's primary control structure268const ccache_p* ccache_ptr, // > NC control structure269char** name // < name of NC associated with ccache_ptr270// (free via cc_free_name())271);272273CCACHE_API274cc_set_principal(275apiCB* cc_ctx, // > DLL's primary control structure276const ccache_p* ccache_pointer, // > NC control structure277const cc_int32 vers,278const char* principal // > name of principal associated with NC279// Free via cc_free_principal()280);281282CCACHE_API283cc_get_principal(284apiCB* cc_ctx, // > DLL's primary control structure285const ccache_p* ccache_pointer, // > NC control structure286char** principal // < name of principal associated with NC287// Free via cc_free_principal()288);289290CCACHE_API291cc_get_cred_version(292apiCB* cc_ctx, // > DLL's primary control structure293const ccache_p* ccache_ptr, // > NC control structure294cc_int32* vers // < ticket version associated with NC295);296297#define CC_LOCK_UNLOCK 1298#define CC_LOCK_READER 2299#define CC_LOCK_WRITER 3300#define CC_LOCK_NOBLOCK 16301302CCACHE_API303cc_lock_request(304apiCB* cc_ctx, // > DLL's primary control structure305const ccache_p* ccache_ptr, // > NC control structure306const cc_int32 lock_type // > one (or combination) of above defined307// lock types308);309310/*311** Credentials routines (work within an NC)312** store, remove_cred, seq_fetch_creds313*/314CCACHE_API315cc_store(316apiCB* cc_ctx, // > DLL's primary control structure317ccache_p* ccache_ptr, // > NC control structure318const cred_union creds // > credentials to be copied into NC319);320321CCACHE_API322cc_remove_cred(323apiCB* cc_ctx, // > DLL's primary control structure324ccache_p* ccache_ptr, // > NC control structure325const cred_union cred // > credentials to remove from NC326);327328CCACHE_API329cc_seq_fetch_creds(330apiCB* cc_ctx, // > DLL's primary control structure331const ccache_p* ccache_ptr, // > NC control structure332cred_union** creds, // < filled in by DLL, free via cc_free_creds()333ccache_cit** itCreds // <> iterator used by DLL, set to NULL334// before first call -- Also NULL for final335// call if loop ends before CC_END336);337338CCACHE_API339cc_seq_fetch_creds_begin(340apiCB* cc_ctx,341const ccache_p* ccache_ptr,342ccache_cit** itCreds343);344345CCACHE_API346cc_seq_fetch_creds_end(347apiCB* cc_ctx,348ccache_cit** itCreds349);350351CCACHE_API352cc_seq_fetch_creds_next(353apiCB* cc_ctx,354cred_union** cred,355ccache_cit* itCreds356);357358/*359** methods of liberation,360** or freeing space via the free that goes with the malloc used to get it361** It's important to use the free carried in the DLL, not the one supplied362** by your compiler vendor.363**364** freeing a NULL pointer is not treated as an error365*/366CCACHE_API367cc_free_principal(368apiCB* cc_ctx, // > DLL's primary control structure369char** principal // <> ptr to principal to be freed, returned as NULL370// (from cc_get_principal())371);372373CCACHE_API374cc_free_name(375apiCB* cc_ctx, // > DLL's primary control structure376char** name // <> ptr to name to be freed, returned as NULL377// (from cc_get_name())378);379380CCACHE_API381cc_free_creds(382apiCB* cc_ctx, // > DLL's primary control structure383cred_union** pCred // <> cred (from cc_seq_fetch_creds()) to be freed384// Returned as NULL.385);386387#ifdef __cplusplus388} /* end extern "C" */389#endif /* __cplusplus */390391#endif /* Krb_CCacheAPI_h_ */392393394