crypt32: Fix several failing tests in win9x.

This commit is contained in:
James Hawkins 2008-09-28 12:12:46 -05:00 committed by Alexandre Julliard
parent 4d46c99765
commit 5114d652d2
1 changed files with 61 additions and 25 deletions

View File

@ -2535,11 +2535,15 @@ static void testComparePublicKeyInfo(void)
ret = CertComparePublicKeyInfo(0, &info1, &info2);
ok(!ret, "CertComparePublicKeyInfo: as raw binary: keys should be unequal\n");
ret = CertComparePublicKeyInfo(X509_ASN_ENCODING, &info1, &info2);
ok(ret, "CertComparePublicKeyInfo: as ASN.1 encoded: keys should be equal\n");
ok(ret ||
broken(!ret), /* win9x */
"CertComparePublicKeyInfo: as ASN.1 encoded: keys should be equal\n");
info1.PublicKey.cUnusedBits = 1;
info2.PublicKey.cUnusedBits = 5;
ret = CertComparePublicKeyInfo(X509_ASN_ENCODING, &info1, &info2);
ok(ret, "CertComparePublicKeyInfo: ASN.1 encoding should ignore cUnusedBits\n");
ok(ret ||
broken(!ret), /* win9x */
"CertComparePublicKeyInfo: ASN.1 encoding should ignore cUnusedBits\n");
info1.PublicKey.cUnusedBits = 0;
info2.PublicKey.cUnusedBits = 0;
info1.PublicKey.cbData--; /* kill one byte, make ASN.1 encoded data invalid */
@ -2592,7 +2596,11 @@ static void testHashPublicKeyInfo(void)
"Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError());
}
ret = CryptHashPublicKeyInfo(0, 0, 0, X509_ASN_ENCODING, &info, NULL, &len);
ok(ret, "CryptHashPublicKeyInfo failed: %08x\n", GetLastError());
ok(ret ||
broken(!ret), /* win9x */
"CryptHashPublicKeyInfo failed: %08x\n", GetLastError());
if (ret)
{
ok(len == 16, "Expected hash size 16, got %d\n", len);
if (len == 16)
{
@ -2606,6 +2614,7 @@ static void testHashPublicKeyInfo(void)
ok(!memcmp(buf, emptyHash, len), "Unexpected hash\n");
}
}
}
static const BYTE md5SignedEmptyCertHash[] = { 0xfb,0x0f,0x66,0x82,0x66,0xd9,
0xe5,0xf8,0xd8,0xa2,0x55,0x2b,0xe1,0xa5,0xd9,0x04 };
@ -2651,8 +2660,14 @@ static void testHashToBeSigned(void)
/* Signing a cert works */
ret = CryptHashToBeSigned(0, X509_ASN_ENCODING, md5SignedEmptyCert,
sizeof(md5SignedEmptyCert), NULL, &size);
ok(ret, "CryptHashToBeSigned failed: %08x\n", GetLastError());
ok(ret ||
broken(!ret), /* win9x */
"CryptHashToBeSigned failed: %08x\n", GetLastError());
if (ret)
{
ok(size == sizeof(md5SignedEmptyCertHash), "unexpected size %d\n", size);
}
ret = CryptHashToBeSigned(0, X509_ASN_ENCODING, md5SignedEmptyCert,
sizeof(md5SignedEmptyCert), hash, &size);
ok(!memcmp(hash, md5SignedEmptyCertHash, size), "unexpected value\n");
@ -2893,13 +2908,21 @@ static void testAcquireCertPrivateKey(void)
/* Don't cache provider */
ret = pCryptAcquireCertificatePrivateKey(cert, 0, NULL, &certCSP,
&keySpec, &callerFree);
ok(ret, "CryptAcquireCertificatePrivateKey failed: %08x\n",
ok(ret ||
broken(!ret), /* win95 */
"CryptAcquireCertificatePrivateKey failed: %08x\n",
GetLastError());
if (ret)
{
ok(callerFree, "Expected callerFree to be TRUE\n");
CryptReleaseContext(certCSP, 0);
}
ret = pCryptAcquireCertificatePrivateKey(cert, 0, NULL, &certCSP,
NULL, NULL);
ok(ret, "CryptAcquireCertificatePrivateKey failed: %08x\n",
ok(ret ||
broken(!ret), /* win95 */
"CryptAcquireCertificatePrivateKey failed: %08x\n",
GetLastError());
CryptReleaseContext(certCSP, 0);
@ -2907,21 +2930,30 @@ static void testAcquireCertPrivateKey(void)
ret = pCryptAcquireCertificatePrivateKey(cert,
CRYPT_ACQUIRE_USE_PROV_INFO_FLAG, NULL, &certCSP, &keySpec,
&callerFree);
ok(ret, "CryptAcquireCertificatePrivateKey failed: %08x\n",
ok(ret ||
broken(!ret), /* win95 */
"CryptAcquireCertificatePrivateKey failed: %08x\n",
GetLastError());
if (ret)
{
ok(callerFree, "Expected callerFree to be TRUE\n");
CryptReleaseContext(certCSP, 0);
}
/* Cache it (and check that it's cached) */
ret = pCryptAcquireCertificatePrivateKey(cert,
CRYPT_ACQUIRE_CACHE_FLAG, NULL, &certCSP, &keySpec, &callerFree);
ok(ret, "CryptAcquireCertificatePrivateKey failed: %08x\n",
ok(ret ||
broken(!ret), /* win95 */
"CryptAcquireCertificatePrivateKey failed: %08x\n",
GetLastError());
ok(!callerFree, "Expected callerFree to be FALSE\n");
size = sizeof(keyContext);
ret = CertGetCertificateContextProperty(cert, CERT_KEY_CONTEXT_PROP_ID,
&keyContext, &size);
ok(ret, "CertGetCertificateContextProperty failed: %08x\n",
ok(ret ||
broken(!ret), /* win95 */
"CertGetCertificateContextProperty failed: %08x\n",
GetLastError());
/* Remove the cached provider */
@ -2936,13 +2968,17 @@ static void testAcquireCertPrivateKey(void)
ret = pCryptAcquireCertificatePrivateKey(cert,
CRYPT_ACQUIRE_USE_PROV_INFO_FLAG, NULL, &certCSP, &keySpec,
&callerFree);
ok(ret, "CryptAcquireCertificatePrivateKey failed: %08x\n",
ok(ret ||
broken(!ret), /* win95 */
"CryptAcquireCertificatePrivateKey failed: %08x\n",
GetLastError());
ok(!callerFree, "Expected callerFree to be FALSE\n");
size = sizeof(keyContext);
ret = CertGetCertificateContextProperty(cert, CERT_KEY_CONTEXT_PROP_ID,
&keyContext, &size);
ok(ret, "CertGetCertificateContextProperty failed: %08x\n",
ok(ret ||
broken(!ret), /* win95 */
"CertGetCertificateContextProperty failed: %08x\n",
GetLastError());
CryptReleaseContext(certCSP, 0);