crypt32: Implement CryptGetIntendedKeyUsage.

This commit is contained in:
Juan Lang 2009-11-03 10:45:51 -08:00 committed by Alexandre Julliard
parent 6ac162231b
commit f554669286
2 changed files with 31 additions and 6 deletions

View File

@ -2200,9 +2200,38 @@ BOOL WINAPI CryptVerifyCertificateSignatureEx(HCRYPTPROV_LEGACY hCryptProv,
BOOL WINAPI CertGetIntendedKeyUsage(DWORD dwCertEncodingType,
PCERT_INFO pCertInfo, BYTE *pbKeyUsage, DWORD cbKeyUsage)
{
FIXME("(%08x, %p, %p, %d)\n", dwCertEncodingType, pCertInfo, pbKeyUsage,
PCERT_EXTENSION ext;
BOOL ret = FALSE;
TRACE("(%08x, %p, %p, %d)\n", dwCertEncodingType, pCertInfo, pbKeyUsage,
cbKeyUsage);
return FALSE;
ext = CertFindExtension(szOID_KEY_USAGE, pCertInfo->cExtension,
pCertInfo->rgExtension);
if (ext)
{
CRYPT_BIT_BLOB usage;
DWORD size = sizeof(usage);
ret = CryptDecodeObjectEx(dwCertEncodingType, X509_BITS,
ext->Value.pbData, ext->Value.cbData, CRYPT_DECODE_NOCOPY_FLAG, NULL,
&usage, &size);
if (ret)
{
if (cbKeyUsage < usage.cbData)
ret = FALSE;
else
{
memcpy(pbKeyUsage, usage.pbData, usage.cbData);
if (cbKeyUsage > usage.cbData)
memset(pbKeyUsage + usage.cbData, 0,
cbKeyUsage - usage.cbData);
}
}
}
else
SetLastError(0);
return ret;
}
BOOL WINAPI CertGetEnhancedKeyUsage(PCCERT_CONTEXT pCertContext, DWORD dwFlags,

View File

@ -2100,21 +2100,17 @@ static void testIntendedKeyUsage(void)
/* The unused bytes are filled with 0. */
ret = CertGetIntendedKeyUsage(X509_ASN_ENCODING, &info, usage_bytes,
sizeof(usage_bytes));
todo_wine {
ok(ret, "CertGetIntendedKeyUsage failed: %08x\n", GetLastError());
ok(!memcmp(usage_bytes, expected_usage1, sizeof(expected_usage1)),
"unexpected value\n");
}
/* The usage bytes are copied in big-endian order. */
ext.Value.cbData = sizeof(usage2);
ext.Value.pbData = usage2;
ret = CertGetIntendedKeyUsage(X509_ASN_ENCODING, &info, usage_bytes,
sizeof(usage_bytes));
todo_wine {
ok(ret, "CertGetIntendedKeyUsage failed: %08x\n", GetLastError());
ok(!memcmp(usage_bytes, expected_usage2, sizeof(expected_usage2)),
"unexpected value\n");
}
}
static const LPCSTR keyUsages[] = { szOID_PKIX_KP_CODE_SIGNING,