mirror of
https://github.com/reactos/reactos.git
synced 2025-01-03 21:09:19 +00:00
[crypt32]
sync crypt32 to wine 1.1.35 svn path=/trunk/; revision=44909
This commit is contained in:
parent
009c692de8
commit
869db84457
5 changed files with 149 additions and 18 deletions
|
@ -2854,7 +2854,7 @@ static void CertContext_SetKeyProvInfo(PCCERT_CONTEXT context,
|
||||||
{
|
{
|
||||||
info.pwszContainerName = CryptMemAlloc(len *
|
info.pwszContainerName = CryptMemAlloc(len *
|
||||||
sizeof(WCHAR));
|
sizeof(WCHAR));
|
||||||
len = MultiByteToWideChar(CP_ACP, 0, szContainer, -1,
|
MultiByteToWideChar(CP_ACP, 0, szContainer, -1,
|
||||||
info.pwszContainerName, len);
|
info.pwszContainerName, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2878,7 +2878,7 @@ static void CertContext_SetKeyProvInfo(PCCERT_CONTEXT context,
|
||||||
{
|
{
|
||||||
info.pwszProvName = CryptMemAlloc(len *
|
info.pwszProvName = CryptMemAlloc(len *
|
||||||
sizeof(WCHAR));
|
sizeof(WCHAR));
|
||||||
len = MultiByteToWideChar(CP_ACP, 0, szProvider, -1,
|
MultiByteToWideChar(CP_ACP, 0, szProvider, -1,
|
||||||
info.pwszProvName, len);
|
info.pwszProvName, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2898,7 +2898,7 @@ static void CertContext_SetKeyProvInfo(PCCERT_CONTEXT context,
|
||||||
pInfo = &info;
|
pInfo = &info;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = CertSetCertificateContextProperty(context, CERT_KEY_PROV_INFO_PROP_ID,
|
CertSetCertificateContextProperty(context, CERT_KEY_PROV_INFO_PROP_ID,
|
||||||
0, pInfo);
|
0, pInfo);
|
||||||
|
|
||||||
if (pInfo == &info)
|
if (pInfo == &info)
|
||||||
|
|
|
@ -230,10 +230,118 @@ typedef struct _CertificateChain
|
||||||
LONG ref;
|
LONG ref;
|
||||||
} CertificateChain, *PCertificateChain;
|
} CertificateChain, *PCertificateChain;
|
||||||
|
|
||||||
static inline BOOL CRYPT_IsCertificateSelfSigned(PCCERT_CONTEXT cert)
|
static BOOL CRYPT_IsCertificateSelfSigned(PCCERT_CONTEXT cert)
|
||||||
{
|
{
|
||||||
return CertCompareCertificateName(cert->dwCertEncodingType,
|
PCERT_EXTENSION ext;
|
||||||
&cert->pCertInfo->Subject, &cert->pCertInfo->Issuer);
|
DWORD size;
|
||||||
|
BOOL ret;
|
||||||
|
|
||||||
|
if ((ext = CertFindExtension(szOID_AUTHORITY_KEY_IDENTIFIER2,
|
||||||
|
cert->pCertInfo->cExtension, cert->pCertInfo->rgExtension)))
|
||||||
|
{
|
||||||
|
CERT_AUTHORITY_KEY_ID2_INFO *info;
|
||||||
|
|
||||||
|
ret = CryptDecodeObjectEx(cert->dwCertEncodingType,
|
||||||
|
X509_AUTHORITY_KEY_ID2, ext->Value.pbData, ext->Value.cbData,
|
||||||
|
CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_NOCOPY_FLAG, NULL,
|
||||||
|
&info, &size);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
if (info->AuthorityCertIssuer.cAltEntry &&
|
||||||
|
info->AuthorityCertSerialNumber.cbData)
|
||||||
|
{
|
||||||
|
PCERT_ALT_NAME_ENTRY directoryName = NULL;
|
||||||
|
DWORD i;
|
||||||
|
|
||||||
|
for (i = 0; !directoryName &&
|
||||||
|
i < info->AuthorityCertIssuer.cAltEntry; i++)
|
||||||
|
if (info->AuthorityCertIssuer.rgAltEntry[i].dwAltNameChoice
|
||||||
|
== CERT_ALT_NAME_DIRECTORY_NAME)
|
||||||
|
directoryName =
|
||||||
|
&info->AuthorityCertIssuer.rgAltEntry[i];
|
||||||
|
if (directoryName)
|
||||||
|
{
|
||||||
|
ret = CertCompareCertificateName(cert->dwCertEncodingType,
|
||||||
|
&directoryName->u.DirectoryName, &cert->pCertInfo->Issuer)
|
||||||
|
&& CertCompareIntegerBlob(&info->AuthorityCertSerialNumber,
|
||||||
|
&cert->pCertInfo->SerialNumber);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FIXME("no supported name type in authority key id2\n");
|
||||||
|
ret = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (info->KeyId.cbData)
|
||||||
|
{
|
||||||
|
ret = CertGetCertificateContextProperty(cert,
|
||||||
|
CERT_KEY_IDENTIFIER_PROP_ID, NULL, &size);
|
||||||
|
if (ret && size == info->KeyId.cbData)
|
||||||
|
{
|
||||||
|
LPBYTE buf = CryptMemAlloc(size);
|
||||||
|
|
||||||
|
if (buf)
|
||||||
|
{
|
||||||
|
CertGetCertificateContextProperty(cert,
|
||||||
|
CERT_KEY_IDENTIFIER_PROP_ID, buf, &size);
|
||||||
|
ret = !memcmp(buf, info->KeyId.pbData, size);
|
||||||
|
CryptMemFree(buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = FALSE;
|
||||||
|
}
|
||||||
|
LocalFree(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ((ext = CertFindExtension(szOID_AUTHORITY_KEY_IDENTIFIER,
|
||||||
|
cert->pCertInfo->cExtension, cert->pCertInfo->rgExtension)))
|
||||||
|
{
|
||||||
|
CERT_AUTHORITY_KEY_ID_INFO *info;
|
||||||
|
|
||||||
|
ret = CryptDecodeObjectEx(cert->dwCertEncodingType,
|
||||||
|
X509_AUTHORITY_KEY_ID, ext->Value.pbData, ext->Value.cbData,
|
||||||
|
CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_NOCOPY_FLAG, NULL,
|
||||||
|
&info, &size);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
if (info->CertIssuer.cbData && info->CertSerialNumber.cbData)
|
||||||
|
{
|
||||||
|
ret = CertCompareCertificateName(cert->dwCertEncodingType,
|
||||||
|
&info->CertIssuer, &cert->pCertInfo->Issuer) &&
|
||||||
|
CertCompareIntegerBlob(&info->CertSerialNumber,
|
||||||
|
&cert->pCertInfo->SerialNumber);
|
||||||
|
}
|
||||||
|
else if (info->KeyId.cbData)
|
||||||
|
{
|
||||||
|
ret = CertGetCertificateContextProperty(cert,
|
||||||
|
CERT_KEY_IDENTIFIER_PROP_ID, NULL, &size);
|
||||||
|
if (ret && size == info->KeyId.cbData)
|
||||||
|
{
|
||||||
|
LPBYTE buf = CryptMemAlloc(size);
|
||||||
|
|
||||||
|
if (buf)
|
||||||
|
{
|
||||||
|
CertGetCertificateContextProperty(cert,
|
||||||
|
CERT_KEY_IDENTIFIER_PROP_ID, buf, &size);
|
||||||
|
ret = !memcmp(buf, info->KeyId.pbData, size);
|
||||||
|
CryptMemFree(buf);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = FALSE;
|
||||||
|
LocalFree(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = CertCompareCertificateName(cert->dwCertEncodingType,
|
||||||
|
&cert->pCertInfo->Subject, &cert->pCertInfo->Issuer);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CRYPT_FreeChainElement(PCERT_CHAIN_ELEMENT element)
|
static void CRYPT_FreeChainElement(PCERT_CHAIN_ELEMENT element)
|
||||||
|
@ -619,7 +727,7 @@ static BOOL rfc822_name_matches(LPCWSTR constraint, LPCWSTR name,
|
||||||
*trustErrorStatus |= CERT_TRUST_INVALID_NAME_CONSTRAINTS;
|
*trustErrorStatus |= CERT_TRUST_INVALID_NAME_CONSTRAINTS;
|
||||||
else if (!name)
|
else if (!name)
|
||||||
; /* no match */
|
; /* no match */
|
||||||
else if ((at = strchrW(constraint, '@')))
|
else if (strchrW(constraint, '@'))
|
||||||
match = !lstrcmpiW(constraint, name);
|
match = !lstrcmpiW(constraint, name);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2541,10 +2649,11 @@ static void CRYPT_CheckUsages(PCERT_CHAIN_CONTEXT chain,
|
||||||
* key usage extension be present and that a particular purpose
|
* key usage extension be present and that a particular purpose
|
||||||
* be indicated in order for the certificate to be acceptable to
|
* be indicated in order for the certificate to be acceptable to
|
||||||
* that application."
|
* that application."
|
||||||
* For now I'm being more conservative and disallowing it.
|
* Not all web sites include the extended key usage extension, so
|
||||||
|
* accept chains without it.
|
||||||
*/
|
*/
|
||||||
WARN_(chain)("requested usage from a certificate with no usages\n");
|
TRACE_(chain)("requested usage from certificate with no usages\n");
|
||||||
validForUsage = FALSE;
|
validForUsage = TRUE;
|
||||||
}
|
}
|
||||||
if (!validForUsage)
|
if (!validForUsage)
|
||||||
{
|
{
|
||||||
|
@ -2641,6 +2750,8 @@ BOOL WINAPI CertGetCertificateChain(HCERTCHAINENGINE hChainEngine,
|
||||||
if (!pChain->TrustStatus.dwErrorStatus)
|
if (!pChain->TrustStatus.dwErrorStatus)
|
||||||
CRYPT_VerifyChainRevocation(pChain, pTime, pChainPara, dwFlags);
|
CRYPT_VerifyChainRevocation(pChain, pTime, pChainPara, dwFlags);
|
||||||
CRYPT_CheckUsages(pChain, pChainPara);
|
CRYPT_CheckUsages(pChain, pChainPara);
|
||||||
|
TRACE_(chain)("error status: %08x\n",
|
||||||
|
pChain->TrustStatus.dwErrorStatus);
|
||||||
if (ppChainContext)
|
if (ppChainContext)
|
||||||
*ppChainContext = pChain;
|
*ppChainContext = pChain;
|
||||||
else
|
else
|
||||||
|
|
|
@ -167,14 +167,21 @@ static BOOL compare_crl_issued_by(PCCRL_CONTEXT pCrlContext, DWORD dwType,
|
||||||
}
|
}
|
||||||
else if (info->KeyId.cbData)
|
else if (info->KeyId.cbData)
|
||||||
{
|
{
|
||||||
if ((ext = CertFindExtension(
|
DWORD size;
|
||||||
szOID_SUBJECT_KEY_IDENTIFIER,
|
|
||||||
issuer->pCertInfo->cExtension,
|
ret = CertGetCertificateContextProperty(issuer,
|
||||||
issuer->pCertInfo->rgExtension)))
|
CERT_KEY_IDENTIFIER_PROP_ID, NULL, &size);
|
||||||
|
if (ret && size == info->KeyId.cbData)
|
||||||
{
|
{
|
||||||
if (info->KeyId.cbData == ext->Value.cbData)
|
LPBYTE buf = CryptMemAlloc(size);
|
||||||
ret = !memcmp(info->KeyId.pbData,
|
|
||||||
ext->Value.pbData, info->KeyId.cbData);
|
if (buf)
|
||||||
|
{
|
||||||
|
CertGetCertificateContextProperty(issuer,
|
||||||
|
CERT_KEY_IDENTIFIER_PROP_ID, buf, &size);
|
||||||
|
ret = !memcmp(buf, info->KeyId.pbData, size);
|
||||||
|
CryptMemFree(buf);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,13 @@ BOOL WINAPI CertAddCTLContextToStore(HCERTSTORE hCertStore,
|
||||||
break;
|
break;
|
||||||
case CERT_STORE_ADD_USE_EXISTING:
|
case CERT_STORE_ADD_USE_EXISTING:
|
||||||
if (existing)
|
if (existing)
|
||||||
|
{
|
||||||
CtlContext_CopyProperties(existing, pCtlContext);
|
CtlContext_CopyProperties(existing, pCtlContext);
|
||||||
|
if (ppStoreContext)
|
||||||
|
*ppStoreContext = CertDuplicateCTLContext(existing);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
toAdd = CertDuplicateCTLContext(pCtlContext);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
FIXME("Unimplemented add disposition %d\n", dwAddDisposition);
|
FIXME("Unimplemented add disposition %d\n", dwAddDisposition);
|
||||||
|
|
|
@ -899,7 +899,8 @@ BOOL WINAPI CertAddCertificateContextToStore(HCERTSTORE hCertStore,
|
||||||
if (existing)
|
if (existing)
|
||||||
{
|
{
|
||||||
CertContext_CopyProperties(existing, pCertContext);
|
CertContext_CopyProperties(existing, pCertContext);
|
||||||
*ppStoreContext = CertDuplicateCertificateContext(existing);
|
if (ppStoreContext)
|
||||||
|
*ppStoreContext = CertDuplicateCertificateContext(existing);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
toAdd = CertDuplicateCertificateContext(pCertContext);
|
toAdd = CertDuplicateCertificateContext(pCertContext);
|
||||||
|
@ -1090,7 +1091,13 @@ BOOL WINAPI CertAddCRLContextToStore(HCERTSTORE hCertStore,
|
||||||
break;
|
break;
|
||||||
case CERT_STORE_ADD_USE_EXISTING:
|
case CERT_STORE_ADD_USE_EXISTING:
|
||||||
if (existing)
|
if (existing)
|
||||||
|
{
|
||||||
CrlContext_CopyProperties(existing, pCrlContext);
|
CrlContext_CopyProperties(existing, pCrlContext);
|
||||||
|
if (ppStoreContext)
|
||||||
|
*ppStoreContext = CertDuplicateCRLContext(existing);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
toAdd = CertDuplicateCRLContext(pCrlContext);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
FIXME("Unimplemented add disposition %d\n", dwAddDisposition);
|
FIXME("Unimplemented add disposition %d\n", dwAddDisposition);
|
||||||
|
|
Loading…
Reference in a new issue