602 lines
13 KiB
C
602 lines
13 KiB
C
/**************************************************************************
|
|
* %name: sscs_win_calls.c %
|
|
* %instance: security_2 %
|
|
* %version: 1 %
|
|
* %created_by: cameron %
|
|
* %date_modified: Tue Apr 05 20:41:03 2005 %
|
|
***************************************************************************
|
|
*
|
|
***************************************************************************
|
|
*/
|
|
|
|
|
|
|
|
#include "nsscs_idk.h"
|
|
#include "sscs_lldefs.h"
|
|
#include "sscs_cache.h"
|
|
|
|
#define INITGUID
|
|
#include <objbase.h>
|
|
//#include "walletdef.h"
|
|
#include "sscs_win_secretstoredef.h"
|
|
|
|
static PIVerifiedAccessSS pIAccess = NULL;
|
|
static PISecretStore pISecretStore = NULL;
|
|
|
|
/* ######################################################################## */
|
|
/* ############################### STUBS HERE ############################# */
|
|
/* ######################################################################## */
|
|
|
|
/*
|
|
* NAME - sscs_CacheOpenSecretStore
|
|
*
|
|
* DESCRIPTION
|
|
*
|
|
*
|
|
*/
|
|
void * sscs_CacheOpenSecretStore
|
|
(
|
|
void *secretStoreID,
|
|
unsigned long ssFlags,
|
|
void *reserved
|
|
)
|
|
{ /* beginning of the call */
|
|
/* ########################## DECLARATIONS START HERE ######################### */
|
|
|
|
NCSTATUS status;
|
|
SCHANDLE *hSC = malloc(sizeof(SCHANDLE));
|
|
|
|
/* ############################## CODE STARTS HERE ############################ */
|
|
|
|
CoInitialize(NULL);
|
|
status = CoCreateInstance(
|
|
(REFCLSID)&CLSID_SecretStoreClientService,
|
|
NULL,
|
|
CLSCTX_SERVER,
|
|
(REFIID)&IID_VerifyAccessSS_1,
|
|
(void **)&pIAccess);
|
|
|
|
|
|
if (status == NC_STATUS_SUCCESS)
|
|
{
|
|
status = pIAccess->lpVtbl->QuerySecureInterface(
|
|
pIAccess,
|
|
GetModuleHandle(NULL),
|
|
(PGUID)&IID_SSCS,
|
|
(void **)&pISecretStore);
|
|
|
|
|
|
pIAccess->lpVtbl->Release(pIAccess);
|
|
|
|
}
|
|
else if(status == REGDB_E_CLASSNOTREG)
|
|
{
|
|
OutputDebugString("SecretStore: Class not Registered");
|
|
}
|
|
else if (status == CLASS_E_NOAGGREGATION )
|
|
{
|
|
OutputDebugString("SecretStore: Class no aggregation");
|
|
}
|
|
else if (status == E_NOINTERFACE)
|
|
{
|
|
OutputDebugString("SecretStore: No Interface");
|
|
}
|
|
|
|
if (status != NC_STATUS_SUCCESS)
|
|
{
|
|
CoUninitialize();
|
|
return 0;
|
|
}
|
|
|
|
|
|
status = pISecretStore->lpVtbl->CacheOpenSecretStore (
|
|
pISecretStore,
|
|
secretStoreID,
|
|
ssFlags,
|
|
hSC,
|
|
NULL
|
|
);
|
|
|
|
if (status != NC_STATUS_SUCCESS)
|
|
{
|
|
CoUninitialize();
|
|
return 0;
|
|
}
|
|
else
|
|
return((void*)hSC);
|
|
|
|
/* ############################### CODE ENDS HERE ############################# */
|
|
} //* sscs_CacheOpenSecretStore
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
* NAME - sscs_CacheCloseSecretStore
|
|
*
|
|
* DESCRIPTION
|
|
*
|
|
*
|
|
*/
|
|
int sscs_CacheCloseSecretStore
|
|
(
|
|
void *ssHandle,
|
|
unsigned long ssFlags,
|
|
void *reserved
|
|
)
|
|
{ /* beginning of the call */
|
|
/* ########################## DECLARATIONS START HERE ######################### */
|
|
|
|
NCSTATUS status;
|
|
SCHANDLE hSC = (SCHANDLE)ssHandle;
|
|
|
|
/* ############################## CODE STARTS HERE ############################ */
|
|
|
|
status = pISecretStore->lpVtbl->CacheCloseSecretStore (
|
|
pISecretStore,
|
|
0,
|
|
ssFlags,
|
|
reserved);
|
|
|
|
pISecretStore->lpVtbl->Release(pISecretStore);
|
|
CoUninitialize();
|
|
|
|
return status;
|
|
|
|
/* ############################### CODE ENDS HERE ############################# */
|
|
} //* sscs_CacheCloseSecretStore
|
|
|
|
|
|
/*
|
|
* NAME - sscs_CacheRemoveSecretStore
|
|
*
|
|
* DESCRIPTION
|
|
*
|
|
*
|
|
*/
|
|
int sscs_CacheRemoveSecretStore
|
|
(
|
|
void *ssHandle,
|
|
unsigned long ssFlags,
|
|
void *reserved
|
|
)
|
|
{ /* beginning of the call */
|
|
/* ########################## DECLARATIONS START HERE ######################### */
|
|
|
|
NCSTATUS status;
|
|
SCHANDLE hSC = (SCHANDLE)ssHandle;
|
|
|
|
/* ############################## CODE STARTS HERE ############################ */
|
|
|
|
status = pISecretStore->lpVtbl->CacheRemoveSecretStore (
|
|
pISecretStore,
|
|
&hSC,
|
|
ssFlags,
|
|
reserved);
|
|
|
|
return status;
|
|
|
|
/* ############################### CODE ENDS HERE ############################# */
|
|
} //* sscs_CacheRemoveSecretStore
|
|
|
|
|
|
|
|
/*
|
|
* NAME - sscs_CacheEnumerateKeychainIDs
|
|
*
|
|
* DESCRIPTION
|
|
*
|
|
*
|
|
*/
|
|
int sscs_CacheEnumerateKeychainIDs
|
|
(
|
|
void *ssHandle,
|
|
unsigned long ssFlags,
|
|
SSCS_SRCH_KEY_T *searchKey,
|
|
SSCS_KEYCHAIN_ID_LIST_T *kcIDList,
|
|
void *reserved
|
|
)
|
|
{ /* beginning of the call */
|
|
/* ########################## DECLARATIONS START HERE ######################### */
|
|
|
|
NCSTATUS status;
|
|
SCHANDLE hSC = (SCHANDLE)ssHandle;
|
|
|
|
/* ############################## CODE STARTS HERE ############################ */
|
|
|
|
status = pISecretStore->lpVtbl->CacheEnumerateKeyChainIDs (
|
|
pISecretStore,
|
|
0,
|
|
ssFlags,
|
|
searchKey,
|
|
kcIDList,
|
|
reserved);
|
|
|
|
return status;
|
|
|
|
/* ############################### CODE ENDS HERE ############################# */
|
|
} //* sscs_CacheEnumerateKeychainIDs
|
|
|
|
|
|
/*
|
|
* NAME - sscs_CacheAddKeychain
|
|
*
|
|
* DESCRIPTION
|
|
*
|
|
*
|
|
*/
|
|
int sscs_CacheAddKeychain
|
|
(
|
|
void *ssHandle,
|
|
unsigned long ssFlags,
|
|
SSCS_KEYCHAIN_ID_T *keyChainID,
|
|
void *reserved
|
|
)
|
|
{ /* beginning of the call */
|
|
/* ########################## DECLARATIONS START HERE ######################### */
|
|
|
|
NCSTATUS status = 0;
|
|
SCHANDLE hSC = (SCHANDLE)ssHandle;
|
|
|
|
/* ############################## CODE STARTS HERE ############################ */
|
|
|
|
status = pISecretStore->lpVtbl->CacheAddKeyChain(
|
|
pISecretStore,
|
|
0, // session
|
|
ssFlags, // flags
|
|
keyChainID, // keychainID
|
|
reserved);
|
|
|
|
return(status);
|
|
|
|
/* ############################### CODE ENDS HERE ############################# */
|
|
} //* sscs_CacheAddKeychain
|
|
|
|
|
|
|
|
/*
|
|
* NAME - sscs_CacheRemoveKeychain
|
|
*
|
|
* DESCRIPTION
|
|
*
|
|
*
|
|
*/
|
|
int sscs_CacheRemoveKeychain
|
|
(
|
|
void *ssHandle,
|
|
unsigned long ssFlags,
|
|
SSCS_KEYCHAIN_ID_T *keyChainID,
|
|
void *reserved
|
|
)
|
|
{
|
|
/* ########################## DECLARATIONS START HERE ######################### */
|
|
|
|
NCSTATUS status = 0;
|
|
SCHANDLE hSC = (SCHANDLE)ssHandle;
|
|
|
|
/* ############################## CODE STARTS HERE ############################ */
|
|
|
|
status = pISecretStore->lpVtbl->CacheRemoveKeyChain(
|
|
pISecretStore,
|
|
0, // session
|
|
ssFlags, // flags
|
|
keyChainID, // keychainID
|
|
reserved);
|
|
|
|
return(status);
|
|
|
|
/* ############################### CODE ENDS HERE ############################# */
|
|
} //* sscs_CacheRemoveKeychain
|
|
|
|
|
|
|
|
/*
|
|
* NAME - sscs_CacheEnumerateSecretIDs
|
|
*
|
|
* DESCRIPTION
|
|
*
|
|
*
|
|
*/
|
|
int sscs_CacheEnumerateSecretIDs
|
|
(
|
|
void *ssHandle,
|
|
unsigned long ssFlags,
|
|
SSCS_KEYCHAIN_ID_T *keyChainID,
|
|
SSCS_SRCH_KEY_T *searchKey,
|
|
SSCS_SECRET_ID_LIST_T *secretIDList,
|
|
void *reserved
|
|
)
|
|
{
|
|
/* ########################## DECLARATIONS START HERE ######################### */
|
|
|
|
NCSTATUS status = 0;
|
|
SCHANDLE hSC = (SCHANDLE)ssHandle;
|
|
|
|
/* ############################## CODE STARTS HERE ############################ */
|
|
|
|
status = pISecretStore->lpVtbl->CacheEnumerateSecretIDs(
|
|
pISecretStore,
|
|
0, // session
|
|
ssFlags, // flags
|
|
keyChainID, // keychainID
|
|
searchKey,
|
|
secretIDList,
|
|
reserved);
|
|
|
|
return(status);
|
|
|
|
/* ############################### CODE ENDS HERE ############################# */
|
|
} //* sscs_CacheEnumerateSecretIDs
|
|
|
|
|
|
|
|
/*
|
|
* NAME - sscs_CacheReadSecret
|
|
*
|
|
* DESCRIPTION
|
|
*
|
|
*
|
|
*/
|
|
int sscs_CacheReadSecret
|
|
(
|
|
void *ssHandle,
|
|
unsigned long ssFlags,
|
|
SSCS_KEYCHAIN_ID_T *keyChainID,
|
|
SSCS_SECRET_ID_T *secredID,
|
|
SSCS_SECRET_T *secretData,
|
|
SSCS_PASSWORD_T *epPassword,
|
|
unsigned int *bytesRequired,
|
|
void *reserved
|
|
)
|
|
{
|
|
/* ########################## DECLARATIONS START HERE ######################### */
|
|
|
|
NCSTATUS status = 0;
|
|
SCHANDLE hSC = (SCHANDLE)ssHandle;
|
|
|
|
/* ############################## CODE STARTS HERE ############################ */
|
|
|
|
status = pISecretStore->lpVtbl->CacheReadSecret(
|
|
pISecretStore,
|
|
0, // session
|
|
ssFlags, // flags
|
|
keyChainID, // keychainID
|
|
secredID,
|
|
secretData,
|
|
epPassword,
|
|
bytesRequired,
|
|
reserved);
|
|
|
|
return(status);
|
|
|
|
/* ############################### CODE ENDS HERE ############################# */
|
|
} //* sscs_CacheReadSecret
|
|
|
|
|
|
|
|
/*
|
|
* NAME - sscs_CacheWriteSecret
|
|
*
|
|
* DESCRIPTION
|
|
*
|
|
*
|
|
*/
|
|
int sscs_CacheWriteSecret
|
|
(
|
|
void *ssHandle,
|
|
unsigned long ssFlags,
|
|
SSCS_KEYCHAIN_ID_T *keyChainID,
|
|
SSCS_SECRET_ID_T *secredID,
|
|
SSCS_SECRET_T *secretData,
|
|
SSCS_PASSWORD_T *epPassword,
|
|
void *reserved
|
|
)
|
|
{
|
|
/* ########################## DECLARATIONS START HERE ######################### */
|
|
|
|
NCSTATUS status = 0;
|
|
SCHANDLE hSC = (SCHANDLE)ssHandle;
|
|
|
|
/* ############################## CODE STARTS HERE ############################ */
|
|
|
|
status = pISecretStore->lpVtbl->CacheWriteSecret(
|
|
pISecretStore,
|
|
0, // session
|
|
ssFlags, // flags
|
|
keyChainID, // keychainID
|
|
secredID,
|
|
secretData,
|
|
epPassword,
|
|
reserved);
|
|
|
|
return(status);
|
|
|
|
/* ############################### CODE ENDS HERE ############################# */
|
|
} //* sscs_CacheWriteSecret
|
|
|
|
|
|
|
|
/*
|
|
* NAME - sscs_CacheRemoveSecret
|
|
*
|
|
* DESCRIPTION
|
|
*
|
|
*
|
|
*/
|
|
int sscs_CacheRemoveSecret
|
|
(
|
|
void *ssHandle,
|
|
unsigned long ssFlags,
|
|
SSCS_KEYCHAIN_ID_T *keyChainID,
|
|
SSCS_SECRET_ID_T *secredID,
|
|
SSCS_PASSWORD_T *epPassword,
|
|
void *reserved
|
|
)
|
|
{
|
|
/* ########################## DECLARATIONS START HERE ######################### */
|
|
|
|
NCSTATUS status = 0;
|
|
SCHANDLE hSC = (SCHANDLE)ssHandle;
|
|
|
|
/* ############################## CODE STARTS HERE ############################ */
|
|
|
|
status = pISecretStore->lpVtbl->CacheRemoveSecret(
|
|
pISecretStore,
|
|
0, // session
|
|
ssFlags, // flags
|
|
keyChainID, // keychainID
|
|
secredID,
|
|
epPassword,
|
|
reserved);
|
|
|
|
return(status);
|
|
|
|
/* ############################### CODE ENDS HERE ############################# */
|
|
} //* sscs_CacheRemoveSecret
|
|
|
|
|
|
|
|
/*
|
|
* NAME - sscs_CacheGetSecretStoreInfo
|
|
*
|
|
* DESCRIPTION
|
|
*
|
|
*
|
|
*/
|
|
int sscs_CacheGetSecretStoreInfo
|
|
(
|
|
void *ssHandle,
|
|
unsigned long ssFlags,
|
|
SSCS_SECRETSTORE_INFO_T *ssInfo,
|
|
void *reserved
|
|
)
|
|
{
|
|
/* ########################## DECLARATIONS START HERE ######################### */
|
|
|
|
NCSTATUS status = 0;
|
|
SCHANDLE hSC = (SCHANDLE)ssHandle;
|
|
|
|
/* ############################## CODE STARTS HERE ############################ */
|
|
|
|
status = pISecretStore->lpVtbl->CacheGetSecretStoreInfo(
|
|
pISecretStore,
|
|
0, // session
|
|
ssFlags, // flags
|
|
ssInfo, //
|
|
reserved);
|
|
|
|
return(status);
|
|
|
|
/* ############################### CODE ENDS HERE ############################# */
|
|
} //* sscs_CacheGetSecretStoreInfo
|
|
|
|
|
|
|
|
/*
|
|
* NAME - sscs_GetKeychainInfo
|
|
*
|
|
* DESCRIPTION
|
|
*
|
|
*
|
|
*/
|
|
int sscs_GetKeychainInfo
|
|
(
|
|
void *ssHandle,
|
|
unsigned long ssFlags,
|
|
SSCS_KEYCHAIN_ID_T *keyChainID,
|
|
SSCS_KEYCHAIN_INFO_T *kcInfo,
|
|
void *reserved
|
|
)
|
|
{
|
|
/* ########################## DECLARATIONS START HERE ######################### */
|
|
|
|
NCSTATUS status = 0;
|
|
SCHANDLE hSC = (SCHANDLE)ssHandle;
|
|
|
|
/* ############################## CODE STARTS HERE ############################ */
|
|
|
|
status = pISecretStore->lpVtbl->CacheGetKeychainInfo(
|
|
pISecretStore,
|
|
0, // session
|
|
ssFlags, // flags
|
|
keyChainID, //
|
|
kcInfo,
|
|
reserved);
|
|
|
|
return(status);
|
|
|
|
/* ############################### CODE ENDS HERE ############################# */
|
|
} //* sscs_GetKeychainInfo
|
|
|
|
|
|
|
|
/*
|
|
* NAME - sscs_LockCache
|
|
*
|
|
* DESCRIPTION
|
|
*
|
|
*
|
|
*/
|
|
int sscs_LockCache
|
|
(
|
|
void *ssHandle,
|
|
unsigned long ssFlags,
|
|
void *reserved
|
|
)
|
|
{
|
|
/* ########################## DECLARATIONS START HERE ######################### */
|
|
|
|
NCSTATUS status = 0;
|
|
SCHANDLE hSC = (SCHANDLE)ssHandle;
|
|
|
|
/* ############################## CODE STARTS HERE ############################ */
|
|
|
|
status = pISecretStore->lpVtbl->LockCache(
|
|
pISecretStore,
|
|
0, // session
|
|
ssFlags, // flags
|
|
reserved);
|
|
|
|
return(status);
|
|
|
|
/* ############################### CODE ENDS HERE ############################# */
|
|
} //* sscs_LockCache
|
|
|
|
|
|
/*
|
|
* NAME - sscs_UnlockCache
|
|
*
|
|
* DESCRIPTION
|
|
*
|
|
*
|
|
*/
|
|
int sscs_UnlockCache
|
|
(
|
|
void *ssHandle,
|
|
unsigned long ssFlags,
|
|
SSCS_PASSCODE_T *passcode,
|
|
void *reserved
|
|
)
|
|
{
|
|
/* ########################## DECLARATIONS START HERE ######################### */
|
|
|
|
NCSTATUS status = 0;
|
|
SCHANDLE hSC = (SCHANDLE)ssHandle;
|
|
|
|
/* ############################## CODE STARTS HERE ############################ */
|
|
|
|
status = pISecretStore->lpVtbl->UnLockCache(
|
|
pISecretStore,
|
|
0, // session
|
|
ssFlags, // flags
|
|
passcode,
|
|
reserved);
|
|
|
|
return(status);
|
|
|
|
/* ############################### CODE ENDS HERE ############################# */
|
|
} //* sscs_UnlockCache
|
|
|
|
|