Surface the miCASAReadKey api

This commit is contained in:
Jim Norman 2006-03-27 23:54:26 +00:00
parent cfd31212a9
commit 61ec97b695
5 changed files with 118 additions and 14 deletions

View File

@ -2,8 +2,6 @@ LINK_DEF_BLD = \
echo "$(addprefix $(OBJDIR),$(notdir $(OBJS)))" > $(LINKDEF);\
echo "/LIBPATH:$(MSC)lib" >> $(LINKDEF);\
echo "kernel32.lib" >> $(LINKDEF);\
echo "advapi32.lib" >> $(LINKDEF);\
echo "ole32.lib" >> $(LINKDEF);\
echo "/DLL" >> $(LINKDEF);\
echo "/OUT:$(BINDIR)$(basename $(notdir $@)).dll" >> $(LINKDEF);\
echo "/MAP:$(BINDIR)$(basename $(notdir $@)).map" >> $(LINKDEF);\
@ -42,6 +40,7 @@ LINK_DEF_BLD = \
echo "/EXPORT:sscs_IsSecretPersistent">> $(LINKDEF);\
echo "/EXPORT:sscs_CacheWriteKey">> $(LINKDEF);\
echo "/EXPORT:sscs_CacheWriteBinaryKey">> $(LINKDEF);\
echo "/EXPORT:sscs_CacheReadKey">> $(LINKDEF);\
echo "/EXPORT:sscs_CacheReadBinaryKey">> $(LINKDEF);\
echo "/EXPORT:sscs_CacheCloseSecretStore">> $(LINKDEF);\
echo "/EXPORT:sscs_CacheOpenSecretStore">> $(LINKDEF);

View File

@ -2,17 +2,11 @@ LINK_DEF_BLD = \
echo "$(addprefix $(OBJDIR),$(notdir $(OBJS)))" > $(LINKDEF);\
echo "$(MSC)lib/kernel32.lib" >> $(LINKDEF);\
echo "$(MSC)lib/msvcrt.lib" >> $(LINKDEF);\
echo "$(MSC)lib/user32.lib" >> $(LINKDEF);\
echo "$(MSC)lib/advapi32.lib" >> $(LINKDEF);\
echo "$(MSC)lib/ole32.lib" >> $(LINKDEF);\
echo "/LIBPATH:$(MSC)lib" >> $(LINKDEF);\
echo "/DLL" >> $(LINKDEF);\
echo "/PDBTYPE:con" >> $(LINKDEF);\
echo "/OUT:$(BINDIR)$(basename $(notdir $@)).dll" >> $(LINKDEF);\
echo "/MAP:$(BINDIR)$(basename $(notdir $@)).map" >> $(LINKDEF);\
echo "/PDB:$(BINDIR)$(basename $(notdir $@)).pdb" >> $(LINKDEF);\
echo "/DEBUG" >> $(LINKDEF);\
echo "/DEBUGTYPE:BOTH" >> $(LINKDEF);\
echo "/MACHINE:IX86" >> $(LINKDEF);\
echo "/SUBSYSTEM:WINDOWS" >> $(LINKDEF);\
echo "/INCREMENTAL:NO" >> $(LINKDEF);\
@ -47,8 +41,8 @@ LINK_DEF_BLD = \
echo "/EXPORT:sscs_SetMasterPassword">> $(LINKDEF);\
echo "/EXPORT:sscs_IsSecretPersistent">> $(LINKDEF);\
echo "/EXPORT:sscs_CacheWriteKey">> $(LINKDEF);\
echo "/EXPORT:sscs_CacheReadKey">> $(LINKDEF);\
echo "/EXPORT:sscs_CacheWriteBinaryKey">> $(LINKDEF);\
echo "/EXPORT:sscs_CacheReadKey">> $(LINKDEF);\
echo "/EXPORT:sscs_CacheReadBinaryKey">> $(LINKDEF);\
echo "/EXPORT:sscs_CacheCloseSecretStore">> $(LINKDEF);\
echo "/EXPORT:sscs_CacheOpenSecretStore">> $(LINKDEF);

View File

@ -3,8 +3,6 @@ LINK_DEF_BLD = \
echo "/LIBPATH:$(MSC)lib" >> $(LINKDEF);\
echo "/LIBPATH:../lib/w32" >> $(LINKDEF);\
echo "kernel32.lib" >> $(LINKDEF);\
echo "advapi32.lib" >> $(LINKDEF);\
echo "ole32.lib" >> $(LINKDEF);\
echo "micasacache.lib" >> $(LINKDEF);\
echo "/DLL" >> $(LINKDEF);\
echo "/OUT:$(BINDIR)$(basename $(notdir $@)).dll" >> $(LINKDEF);\
@ -41,6 +39,7 @@ LINK_DEF_BLD = \
echo "/EXPORT:miCASAWriteSecret" >> $(LINKDEF);\
echo "/EXPORT:miCASAWriteKey" >> $(LINKDEF);\
echo "/EXPORT:miCASAWriteBinaryKey" >> $(LINKDEF);\
echo "/EXPORT:miCASAReadKey" >> $(LINKDEF);\
echo "/EXPORT:miCASAReadBinaryKey" >> $(LINKDEF);\
echo "/EXPORT:miCASAGetStoreInformation" >> $(LINKDEF);\
echo "/EXPORT:miCASAEnumerateSecretIDs" >> $(LINKDEF);\

View File

@ -44,6 +44,7 @@ LINK_DEF_BLD = \
echo "/EXPORT:miCASAWriteSecret" >> $(LINKDEF);\
echo "/EXPORT:miCASAWriteKey" >> $(LINKDEF);\
echo "/EXPORT:miCASAWriteBinaryKey" >> $(LINKDEF);\
echo "/EXPORT:miCASAReadKey" >> $(LINKDEF);\
echo "/EXPORT:miCASAReadBinaryKey" >> $(LINKDEF);\
echo "/EXPORT:miCASAGetStoreInformation" >> $(LINKDEF);\
echo "/EXPORT:miCASAEnumerateSecretIDs" >> $(LINKDEF);\

View File

@ -1592,7 +1592,7 @@ errorLevel2:
return(rc);
/* ############################### CODE ENDS HERE ############################# */
} //* end of miCASAWriteSecret
} //* end of miCASAWriteKey
/*
@ -1709,10 +1709,121 @@ errorLevel2:
/* ############################### CODE ENDS HERE ############################# */
} //* end of miCASAWriteBinaryKey
/*
* NAME - miCASAReadKey
*
* DESCRIPTION
* NOTE: This assume a SS_CREDSET SecretType
*
*
*/
SSCS_GLOBAL_LIBCALL(int32_t)
miCASAReadKey
(
void * context,
uint32_t ssFlags,
SSCS_KEYCHAIN_ID_T * keyChainID,
SSCS_SECRET_ID_T * sharedSecretID,
SS_UTF8_T * key,
uint32_t keyLen,
uint8_t * val,
uint32_t * valLen,
SSCS_PASSWORD_T * epPassword,
uint32_t * bytesRequired,
SSCS_EXT_T * ext
)
{ /* beginning of the call */
/* ########################## DECLARATIONS START HERE ######################### */
int32_t rc = 0, sidLen = 0, index = 0;
uint32_t escNameLen = 0;
SSCS_SECRET_ID_T secretID = {0};
SS_UTF8_T *escapedSHSName = NULL;
SS_UTF8_T *escapedSHSKey = NULL;
SSCS_CONTEXT_T * storeContext = (SSCS_CONTEXT_T *)context;
/* ############################## CODE STARTS HERE ############################ */
// readData and epPassword are optional parameters
if((context == NULL) || (keyChainID == NULL) || (sharedSecretID == NULL) || (key == NULL))
{
return(NSSCS_E_INVALID_PARAM);
}
secretID.len = NSSCS_MAX_SECRET_ID_LEN;
if((escapedSHSName = (SS_UTF8_T *) malloc(NSSCS_MAX_SECRET_ID_LEN)) == NULL)
{
rc = NSSCS_E_SYSTEM_FAILURE;
goto errorLevel2;
}
if((escapedSHSKey = (SS_UTF8_T *) malloc(NSSCS_MAX_PASSCODE_LEN)) == NULL)
{
rc = NSSCS_E_SYSTEM_FAILURE;
goto errorLevel1;
}
memset(secretID.id, 0, NSSCS_MAX_SECRET_ID_LEN);
memset(escapedSHSName, 0, NSSCS_MAX_SECRET_ID_LEN);
memset(escapedSHSKey, 0, NSSCS_MAX_PASSCODE_LEN);
// escape delimited characters
memcpy(escapedSHSName, sharedSecretID->id, sscs_Utf8StrSize((SS_UTF8_T *)sharedSecretID->id));
sscsshs_ChkEscapeString(escapedSHSName);
memcpy(escapedSHSKey, key, keyLen);
sscsshs_ChkEscapeString(escapedSHSKey);
if((escNameLen = sscs_Utf8Strlen((SS_UTF8_T *)escapedSHSName)) < 1)
{
rc = NSSCS_E_SECRET_ID_TOO_SHORT;
goto errorLevel1;
}
// convert to a SSCS_CRED_SET
sscs_Utf8Strcpy((SS_UTF8_T *)secretID.id, SSCS_CRED_SET_DELIMITED);
sscs_Utf8Strcat((SS_UTF8_T *)secretID.id, (SS_UTF8_T *)escapedSHSName);
secretID.len = sscs_Utf8Strlen((SS_UTF8_T *)secretID.id) + 1;
rc = sscs_CacheReadKey(storeContext->ssHandle,
ssFlags,
keyChainID,
&secretID,
escapedSHSKey,
sscs_Utf8Strlen(escapedSHSKey),
val,
valLen,
epPassword,
bytesRequired,
ext);
/* ############################### CODE EXITS HERE ############################# */
errorLevel1:
if(escapedSHSName)
{
memset(escapedSHSName, 0, NSSCS_MAX_SECRET_ID_LEN);
free(escapedSHSName);
}
if (escapedSHSKey)
{
memset(escapedSHSKey, 0, NSSCS_MAX_PASSCODE_LEN);
free(escapedSHSKey);
}
errorLevel2:
memset(secretID.id, 0, NSSCS_MAX_SECRET_ID_LEN);
return(rc);
/* ############################### CODE ENDS HERE ############################# */
} //* end of miCASAReadKey
/*
* NAME - miCASAWriteKey
* NAME - miCASAReadBinaryKey
*
* DESCRIPTION
* NOTE: This assume a SS_CREDSET SecretType
@ -1822,7 +1933,7 @@ errorLevel2:
return(rc);
/* ############################### CODE ENDS HERE ############################# */
} //* end of miCASAWriteSecret
} //* end of miCASAReadBinaryKey