Author: cwittich Date: Thu Aug 20 19:39:08 2009 New Revision: 42813 URL: http://svn.reactos.org/svn/reactos?rev=42813&view=rev Log: sync wintrust with wine 1.1.27
Modified: trunk/reactos/dll/win32/wintrust/asn.c trunk/reactos/dll/win32/wintrust/crypt.c trunk/reactos/dll/win32/wintrust/softpub.c trunk/reactos/dll/win32/wintrust/wintrust.spec trunk/reactos/dll/win32/wintrust/wintrust_main.c Modified: trunk/reactos/dll/win32/wintrust/asn.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wintrust/asn.c?rev=42813&r1=42812&r2=42813&view=diff ============================================================================== --- trunk/reactos/dll/win32/wintrust/asn.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wintrust/asn.c [iso-8859-1] Thu Aug 20 19:39:08 2009 @@ -2079,15 +2079,6 @@ return ret; } -BOOL WINAPI WVTAsn1SpcSpOpusInfoDecode(DWORD dwCertEncodingType, - LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, - void *pvStructInfo, DWORD *pcbStructInfo) -{ - FIXME("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags, - pvStructInfo, *pcbStructInfo); - return FALSE; -} - static BOOL WINAPI CRYPT_AsnDecodeBMPString(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo) @@ -2123,6 +2114,66 @@ str[i] = '\0'; } } + return ret; +} + +static BOOL WINAPI CRYPT_AsnDecodeProgramName(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + void *pvStructInfo, DWORD *pcbStructInfo) +{ + BOOL ret = FALSE; + DWORD dataLen; + + TRACE("(%p, %d, %08x, %p, %d)\n", pbEncoded, cbEncoded, dwFlags, + pvStructInfo, pvStructInfo ? *pcbStructInfo : 0); + + if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen))) + { + BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); + + ret = CRYPT_AsnDecodeBMPString(dwCertEncodingType, lpszStructType, + pbEncoded + 1 + lenBytes, dataLen, dwFlags, pvStructInfo, + pcbStructInfo); + } + return ret; +} + +BOOL WINAPI WVTAsn1SpcSpOpusInfoDecode(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + void *pvStructInfo, DWORD *pcbStructInfo) +{ + BOOL ret = FALSE; + + TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags, + pvStructInfo, *pcbStructInfo); + + __TRY + { + struct AsnDecodeSequenceItem items[] = { + { ASN_CONSTRUCTOR | ASN_CONTEXT, + offsetof(SPC_SP_OPUS_INFO, pwszProgramName), + CRYPT_AsnDecodeProgramName, sizeof(LPCWSTR), TRUE, TRUE, + offsetof(SPC_SP_OPUS_INFO, pwszProgramName), 0 }, + { ASN_CONSTRUCTOR | ASN_CONTEXT | 1, + offsetof(SPC_SP_OPUS_INFO, pMoreInfo), + CRYPT_AsnDecodeSPCLinkPointer, sizeof(PSPC_LINK), TRUE, TRUE, + offsetof(SPC_SP_OPUS_INFO, pMoreInfo), 0 }, + { ASN_CONSTRUCTOR | ASN_CONTEXT | 2, + offsetof(SPC_SP_OPUS_INFO, pPublisherInfo), + CRYPT_AsnDecodeSPCLinkPointer, sizeof(PSPC_LINK), TRUE, TRUE, + offsetof(SPC_SP_OPUS_INFO, pPublisherInfo), 0 }, + }; + + ret = CRYPT_AsnDecodeSequence(dwCertEncodingType, items, + sizeof(items) / sizeof(items[0]), pbEncoded, cbEncoded, dwFlags, + pvStructInfo, pcbStructInfo, NULL); + } + __EXCEPT_PAGE_FAULT + { + SetLastError(STATUS_ACCESS_VIOLATION); + } + __ENDTRY + TRACE("returning %d\n", ret); return ret; } Modified: trunk/reactos/dll/win32/wintrust/crypt.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wintrust/crypt.c?rev=42813&r1=42812&r2=42813&view=diff ============================================================================== --- trunk/reactos/dll/win32/wintrust/crypt.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wintrust/crypt.c [iso-8859-1] Thu Aug 20 19:39:08 2009 @@ -1121,36 +1121,6 @@ TRACE("(%p %p %d %p %p)\n", pSubjectInfo, pdwEncodingType, dwIndex, pcbSignedDataMsg, pbSignedDataMsg); - /* - * FIXME: I just noticed that I am memorizing the initial file pointer - * offset and restoring it before reading in the rest of the header - * information in the cabinet. Perhaps that's correct -- that is, perhaps - * this API is supposed to support "streaming" cabinets which are embedded - * in other files, or cabinets which begin at file offsets other than zero. - * Otherwise, I should instead go to the absolute beginning of the file. - * (Either way, the semantics of wine's FDICopy require me to leave the - * file pointer where it is afterwards -- If Windows does not do so, we - * ought to duplicate the native behavior in the FDIIsCabinet API, not here. - * - * So, the answer lies in Windows; will native cabinet.dll recognize a - * cabinet "file" embedded in another file? Note that cabextract.c does - * support this, which implies that Microsoft's might. I haven't tried it - * yet so I don't know. ATM, most of wine's FDI cabinet routines (except - * this one) would not work in this way. To fix it, we could just make the - * various references to absolute file positions in the code relative to an - * initial "beginning" offset. Because the FDICopy API doesn't take a - * file-handle like this one, we would therein need to search through the - * file for the beginning of the cabinet (as we also do in cabextract.c). - * Note that this limits us to a maximum of one cabinet per. file: the first. - * - * So, in summary: either the code below is wrong, or the rest of fdi.c is - * wrong... I cannot imagine that both are correct ;) One of these flaws - * should be fixed after determining the behavior on Windows. We ought - * to check both FDIIsCabinet and FDICopy for the right behavior. - * - * -gmt - */ - /* get basic offset & size info */ base_offset = SetFilePointer(pSubjectInfo->hFile, 0L, NULL, SEEK_CUR); @@ -1162,7 +1132,7 @@ cabsize = SetFilePointer(pSubjectInfo->hFile, 0L, NULL, SEEK_CUR); if ((cabsize == -1) || (base_offset == -1) || - (SetFilePointer(pSubjectInfo->hFile, base_offset, NULL, SEEK_SET) == INVALID_SET_FILE_POINTER)) + (SetFilePointer(pSubjectInfo->hFile, 0, NULL, SEEK_SET) == INVALID_SET_FILE_POINTER)) { TRACE("seek error\n"); return FALSE; @@ -1267,6 +1237,7 @@ NULL) || dwRead != cert_size) { ERR("couldn't read cert\n"); + SetFilePointer(pSubjectInfo->hFile, base_offset, NULL, SEEK_SET); return FALSE; } /* The encoding of the files I've seen appears to be in ASN.1 @@ -1274,6 +1245,8 @@ * always is. */ *pdwEncodingType = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING; + /* Restore base offset */ + SetFilePointer(pSubjectInfo->hFile, base_offset, NULL, SEEK_SET); return TRUE; } Modified: trunk/reactos/dll/win32/wintrust/softpub.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wintrust/softpub.c?rev=42813&r1=42812&r2=42813&view=diff ============================================================================== --- trunk/reactos/dll/win32/wintrust/softpub.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wintrust/softpub.c [iso-8859-1] Thu Aug 20 19:39:08 2009 @@ -90,7 +90,9 @@ { BOOL ret; - if (!data->pWintrustData->u.pFile->pgKnownSubject) + if (!WVT_ISINSTRUCT(WINTRUST_FILE_INFO, + data->pWintrustData->u.pFile->cbStruct, pgKnownSubject) || + !data->pWintrustData->u.pFile->pgKnownSubject) { ret = CryptSIPRetrieveSubjectGuid( data->pWintrustData->u.pFile->pcwszFilePath, @@ -254,7 +256,8 @@ BOOL ret; if (data->pWintrustData->u.pCert && - data->pWintrustData->u.pCert->cbStruct == sizeof(WINTRUST_CERT_INFO)) + WVT_IS_CBSTRUCT_GT_MEMBEROFFSET(WINTRUST_CERT_INFO, + data->pWintrustData->u.pCert->cbStruct, psCertContext)) { if (data->psPfns) { @@ -264,7 +267,9 @@ /* Add a signer with nothing but the time to verify, so we can * add a cert to it */ - if (data->pWintrustData->u.pCert->psftVerifyAsOf) + if (WVT_ISINSTRUCT(WINTRUST_CERT_INFO, + data->pWintrustData->u.pCert->cbStruct, psftVerifyAsOf) && + data->pWintrustData->u.pCert->psftVerifyAsOf) data->sftSystemTime = signer.sftVerifyAsOf; else { @@ -278,10 +283,12 @@ { ret = data->psPfns->pfnAddCert2Chain(data, 0, FALSE, 0, data->pWintrustData->u.pCert->psCertContext); - for (i = 0; ret && i < data->pWintrustData->u.pCert->chStores; - i++) - ret = data->psPfns->pfnAddStore2Chain(data, - data->pWintrustData->u.pCert->pahStores[i]); + if (WVT_ISINSTRUCT(WINTRUST_CERT_INFO, + data->pWintrustData->u.pCert->cbStruct, pahStores)) + for (i = 0; + ret && i < data->pWintrustData->u.pCert->chStores; i++) + ret = data->psPfns->pfnAddStore2Chain(data, + data->pWintrustData->u.pCert->pahStores[i]); } } else @@ -1058,3 +1065,15 @@ return S_OK; } + +HRESULT WINAPI HTTPSCertificateTrust(CRYPT_PROVIDER_DATA *data) +{ + FIXME("(%p)\n", data); + return S_OK; +} + +HRESULT WINAPI HTTPSFinalProv(CRYPT_PROVIDER_DATA *data) +{ + FIXME("(%p)\n", data); + return S_OK; +} Modified: trunk/reactos/dll/win32/wintrust/wintrust.spec URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wintrust/wintrust.spec?rev=42813&r1=42812&r2=42813&view=diff ============================================================================== --- trunk/reactos/dll/win32/wintrust/wintrust.spec [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wintrust/wintrust.spec [iso-8859-1] Thu Aug 20 19:39:08 2009 @@ -48,8 +48,8 @@ @ stub FindCertsByIssuer @ stdcall GenericChainCertificateTrust(ptr) @ stdcall GenericChainFinalProv(ptr) -@ stub HTTPSCertificateTrust -@ stub HTTPSFinalProv +@ stdcall HTTPSCertificateTrust(ptr) +@ stdcall HTTPSFinalProv(ptr) @ stub IsCatalogFile @ stub MsCatConstructHashTag @ stub MsCatFreeHashTag @@ -73,6 +73,7 @@ @ stub TrustFreeDecode @ stdcall TrustIsCertificateSelfSigned(ptr) @ stub TrustOpenStores +@ stdcall WTHelperCertCheckValidSignature(ptr) @ stub WTHelperCertFindIssuerCertificate @ stub WTHelperCertIsSelfSigned @ stub WTHelperCheckCertUsage Modified: trunk/reactos/dll/win32/wintrust/wintrust_main.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wintrust/wintrust_main.c?rev=42813&r1=42812&r2=42813&view=diff ============================================================================== --- trunk/reactos/dll/win32/wintrust/wintrust_main.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wintrust/wintrust_main.c [iso-8859-1] Thu Aug 20 19:39:08 2009 @@ -303,7 +303,8 @@ { case WTD_CHOICE_BLOB: if (data->pWintrustData->u.pBlob && - data->pWintrustData->u.pBlob->cbStruct == sizeof(WINTRUST_BLOB_INFO) && + WVT_IS_CBSTRUCT_GT_MEMBEROFFSET(WINTRUST_BLOB_INFO, + data->pWintrustData->u.pBlob->cbStruct, pbMemObject) && data->pWintrustData->u.pBlob->cbMemObject == sizeof(CERT_VERIFY_CERTIFICATE_TRUST) && data->pWintrustData->u.pBlob->pbMemObject) @@ -1084,3 +1085,12 @@ uiCertMgr.pszInitUsageOID = NULL; return CryptUIDlgCertMgr(&uiCertMgr); } + +/*********************************************************************** + * WTHelperCertCheckValidSignature + */ +HRESULT WINAPI WTHelperCertCheckValidSignature(CRYPT_PROVIDER_DATA *pProvData) +{ + FIXME("Stub\n"); + return S_OK; +}