crypt32/tests: Add some tests for CryptDecodeObjectEx without CRYPT_DECODE_ALLOC_FLAG.

This commit is contained in:
Alexander Morozov 2011-11-21 19:47:32 +04:00 committed by Alexandre Julliard
parent c360ee0b66
commit fc78c2242e

View file

@ -2710,6 +2710,21 @@ static void test_decodeExtensions(DWORD dwEncoding)
}
LocalFree(buf);
}
ret = pCryptDecodeObjectEx(dwEncoding, X509_EXTENSIONS,
exts[i].encoded, exts[i].encoded[1] + 2, 0, NULL, NULL, &bufSize);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, bufSize);
if (buf)
{
ret = pCryptDecodeObjectEx(dwEncoding, X509_EXTENSIONS,
exts[i].encoded, exts[i].encoded[1] + 2, 0, NULL, buf, &bufSize);
if (!i)
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
else
todo_wine
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
HeapFree(GetProcessHeap(), 0, buf);
}
}
}
@ -3601,6 +3616,20 @@ static void test_decodeCRLDistPoints(DWORD dwEncoding)
ok(!lstrcmpW(U(*entry).pwszURL, url), "Unexpected name\n");
LocalFree(buf);
}
ret = pCryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS,
distPointWithUrlAndIssuer, distPointWithUrlAndIssuer[1] + 2, 0,
NULL, NULL, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
if (buf)
{
ret = pCryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS,
distPointWithUrlAndIssuer, distPointWithUrlAndIssuer[1] + 2, 0,
NULL, buf, &size);
todo_wine
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
HeapFree(GetProcessHeap(), 0, buf);
}
}
static const BYTE badFlagsIDP[] = { 0x30,0x06,0x81,0x01,0xff,0x82,0x01,0xff };
@ -4741,6 +4770,18 @@ static void test_decodeEnhancedKeyUsage(DWORD dwEncoding)
usage->rgpszUsageIdentifier[i]);
LocalFree(buf);
}
ret = pCryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE,
encodedUsage, sizeof(encodedUsage), 0, NULL, NULL, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
if (buf)
{
ret = pCryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE,
encodedUsage, sizeof(encodedUsage), 0, NULL, buf, &size);
todo_wine
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
HeapFree(GetProcessHeap(), 0, buf);
}
}
static BYTE keyId[] = { 1,2,3,4 };
@ -5215,6 +5256,20 @@ static void test_decodeAuthorityInfoAccess(DWORD dwEncoding)
LocalFree(buf);
buf = NULL;
}
ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS,
authorityInfoAccessWithUrlAndIPAddr,
sizeof(authorityInfoAccessWithUrlAndIPAddr), 0, NULL, NULL, &size);
ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
if (buf)
{
ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS,
authorityInfoAccessWithUrlAndIPAddr,
sizeof(authorityInfoAccessWithUrlAndIPAddr), 0, NULL, buf, &size);
todo_wine
ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
HeapFree(GetProcessHeap(), 0, buf);
}
}
static const BYTE emptyCTL[] = {
@ -6168,6 +6223,18 @@ static void test_decodePKCSAttributes(DWORD dwEncoding)
attributes->rgAttr[1].rgValue[0].cbData), "Unexpected value\n");
LocalFree(buf);
}
ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES,
doublePKCSAttributes, sizeof(doublePKCSAttributes), 0, NULL, NULL, &size);
ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
if (buf)
{
ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES,
doublePKCSAttributes, sizeof(doublePKCSAttributes), 0, NULL, buf, &size);
todo_wine
ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
HeapFree(GetProcessHeap(), 0, buf);
}
}
static const BYTE singleCapability[] = {
@ -6325,6 +6392,20 @@ static void test_decodePKCSSMimeCapabilities(DWORD dwEncoding)
compareSMimeCapabilities("two capabilities", &capabilities, ptr);
LocalFree(ptr);
}
SetLastError(0xdeadbeef);
ret = pCryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES,
twoCapabilities, sizeof(twoCapabilities), 0, NULL, NULL, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
ptr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
if (ptr)
{
SetLastError(0xdeadbeef);
ret = pCryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES,
twoCapabilities, sizeof(twoCapabilities), 0, NULL, ptr, &size);
todo_wine
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
HeapFree(GetProcessHeap(), 0, ptr);
}
}
static BYTE encodedCommonNameNoNull[] = { 0x30,0x14,0x31,0x12,0x30,0x10,
@ -7487,6 +7568,18 @@ static void test_decodeCertPolicies(DWORD dwEncoding)
"unexpected qualifier value\n");
LocalFree(info);
}
ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES,
twoPolicies, sizeof(twoPolicies), 0, NULL, NULL, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
if (info)
{
ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES,
twoPolicies, sizeof(twoPolicies), 0, NULL, info, &size);
todo_wine
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
HeapFree(GetProcessHeap(), 0, info);
}
}
static const BYTE policyMappingWithOneMapping[] = {
@ -7630,6 +7723,20 @@ static void test_decodeCertPolicyMappings(DWORD dwEncoding)
info->rgPolicyMapping[1].pszSubjectDomainPolicy);
LocalFree(info);
}
ret = pCryptDecodeObjectEx(dwEncoding, mappingOids[i],
policyMappingWithTwoMappings, sizeof(policyMappingWithTwoMappings), 0,
NULL, NULL, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
if (info)
{
ret = pCryptDecodeObjectEx(dwEncoding, mappingOids[i],
policyMappingWithTwoMappings, sizeof(policyMappingWithTwoMappings), 0,
NULL, info, &size);
todo_wine
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
HeapFree(GetProcessHeap(), 0, info);
}
}
}