/* Assumes data->u.pPDSip has been loaded, and data->u.pPDSip->pSip allocated.
* Calls data->u.pPDSip->pSip->pfGet to construct data->hMsg.
*/
-static BOOL SOFTPUB_GetMessageFromFile(CRYPT_PROVIDER_DATA *data)
+static BOOL SOFTPUB_GetMessageFromFile(CRYPT_PROVIDER_DATA *data, HANDLE file,
+ LPCWSTR filePath)
{
BOOL ret;
LPBYTE buf = NULL;
data->u.pPDSip->psSipSubjectInfo->cbSize = sizeof(SIP_SUBJECTINFO);
data->u.pPDSip->psSipSubjectInfo->pgSubjectType = &data->u.pPDSip->gSubject;
- data->u.pPDSip->psSipSubjectInfo->hFile = data->pWintrustData->u.pFile->hFile;
- data->u.pPDSip->psSipSubjectInfo->pwsFileName =
- data->pWintrustData->u.pFile->pcwszFilePath;
+ data->u.pPDSip->psSipSubjectInfo->hFile = file;
+ data->u.pPDSip->psSipSubjectInfo->pwsFileName = filePath;
data->u.pPDSip->psSipSubjectInfo->hProv = data->hProv;
ret = data->u.pPDSip->pSip->pfGet(data->u.pPDSip->psSipSubjectInfo,
&data->dwEncoding, 0, &size, 0);
ret = SOFTPUB_GetSIP(data);
if (!ret)
goto error;
- ret = SOFTPUB_GetMessageFromFile(data);
+ ret = SOFTPUB_GetMessageFromFile(data, data->pWintrustData->u.pFile->hFile,
+ data->pWintrustData->u.pFile->pcwszFilePath);
if (!ret)
goto error;
ret = SOFTPUB_CreateStoreFromMessage(data);
return ret;
}
+static BOOL SOFTPUB_LoadCatalogMessage(CRYPT_PROVIDER_DATA *data)
+{
+ BOOL ret;
+ HANDLE catalog = INVALID_HANDLE_VALUE;
+
+ if (!data->pWintrustData->u.pCatalog)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+ catalog = CreateFileW(data->pWintrustData->u.pCatalog->pcwszCatalogFilePath,
+ GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ if (catalog == INVALID_HANDLE_VALUE)
+ return FALSE;
+ ret = CryptSIPRetrieveSubjectGuid(
+ data->pWintrustData->u.pCatalog->pcwszCatalogFilePath, catalog,
+ &data->u.pPDSip->gSubject);
+ if (!ret)
+ goto error;
+ ret = SOFTPUB_GetSIP(data);
+ if (!ret)
+ goto error;
+ ret = SOFTPUB_GetMessageFromFile(data, catalog,
+ data->pWintrustData->u.pCatalog->pcwszCatalogFilePath);
+ if (!ret)
+ goto error;
+ ret = SOFTPUB_CreateStoreFromMessage(data);
+ if (!ret)
+ goto error;
+ ret = SOFTPUB_DecodeInnerContent(data);
+ /* FIXME: this loads the catalog file, but doesn't validate the member. */
+error:
+ CloseHandle(catalog);
+ return ret;
+}
+
HRESULT WINAPI SoftpubLoadMessage(CRYPT_PROVIDER_DATA *data)
{
BOOL ret;
case WTD_CHOICE_FILE:
ret = SOFTPUB_LoadFileMessage(data);
break;
+ case WTD_CHOICE_CATALOG:
+ ret = SOFTPUB_LoadCatalogMessage(data);
+ break;
default:
FIXME("unimplemented for %d\n", data->pWintrustData->dwUnionChoice);
SetLastError(ERROR_INVALID_PARAMETER);
{
BOOL ret;
WTD_GENERIC_CHAIN_POLICY_DATA *policyData =
- (WTD_GENERIC_CHAIN_POLICY_DATA *)data->pWintrustData->pPolicyCallbackData;
+ data->pWintrustData->pPolicyCallbackData;
TRACE("(%p)\n", data);
{
HRESULT err = NO_ERROR; /* not a typo, MS confused the types */
WTD_GENERIC_CHAIN_POLICY_DATA *policyData =
- (WTD_GENERIC_CHAIN_POLICY_DATA *)data->pWintrustData->pPolicyCallbackData;
+ data->pWintrustData->pPolicyCallbackData;
TRACE("(%p)\n", data);