crypt32/tests: Make sure to use return values (LLVM/Clang).
This commit is contained in:
parent
a3c1d4550c
commit
f900a8b035
|
@ -487,6 +487,8 @@ static void testCertProperties(void)
|
||||||
size = sizeof(hashProperty);
|
size = sizeof(hashProperty);
|
||||||
ret = CertGetCertificateContextProperty(context, CERT_HASH_PROP_ID,
|
ret = CertGetCertificateContextProperty(context, CERT_HASH_PROP_ID,
|
||||||
hashProperty, &size);
|
hashProperty, &size);
|
||||||
|
ok(ret, "CertGetCertificateContextProperty failed: %08x\n",
|
||||||
|
GetLastError());
|
||||||
ok(!memcmp(hashProperty, hash, sizeof(hash)), "Unexpected hash\n");
|
ok(!memcmp(hashProperty, hash, sizeof(hash)), "Unexpected hash\n");
|
||||||
/* Delete the (bogus) hash, and get the real one */
|
/* Delete the (bogus) hash, and get the real one */
|
||||||
ret = CertSetCertificateContextProperty(context, CERT_HASH_PROP_ID, 0,
|
ret = CertSetCertificateContextProperty(context, CERT_HASH_PROP_ID, 0,
|
||||||
|
@ -1520,6 +1522,7 @@ static void testGetIssuerCert(void)
|
||||||
/* Adding an issuer allows one (and only one) issuer to be found */
|
/* Adding an issuer allows one (and only one) issuer to be found */
|
||||||
ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
|
ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
|
||||||
chain10_1, sizeof(chain10_1), CERT_STORE_ADD_ALWAYS, &cert1);
|
chain10_1, sizeof(chain10_1), CERT_STORE_ADD_ALWAYS, &cert1);
|
||||||
|
ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
|
||||||
parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags);
|
parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags);
|
||||||
ok(parent == cert1, "Expected cert1 to be the issuer\n");
|
ok(parent == cert1, "Expected cert1 to be the issuer\n");
|
||||||
parent = CertGetIssuerCertificateFromStore(store, child, parent, &flags);
|
parent = CertGetIssuerCertificateFromStore(store, child, parent, &flags);
|
||||||
|
@ -1530,6 +1533,7 @@ static void testGetIssuerCert(void)
|
||||||
*/
|
*/
|
||||||
ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
|
ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
|
||||||
chain10_0, sizeof(chain10_0), CERT_STORE_ADD_ALWAYS, &cert2);
|
chain10_0, sizeof(chain10_0), CERT_STORE_ADD_ALWAYS, &cert2);
|
||||||
|
ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
|
||||||
parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags);
|
parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags);
|
||||||
ok(parent == cert2, "Expected cert2 to be the first issuer\n");
|
ok(parent == cert2, "Expected cert2 to be the first issuer\n");
|
||||||
parent = CertGetIssuerCertificateFromStore(store, child, parent, &flags);
|
parent = CertGetIssuerCertificateFromStore(store, child, parent, &flags);
|
||||||
|
@ -1549,11 +1553,13 @@ static void testGetIssuerCert(void)
|
||||||
/* With only the child certificate, no issuer will be found */
|
/* With only the child certificate, no issuer will be found */
|
||||||
ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
|
ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
|
||||||
chain7_1, sizeof(chain7_1), CERT_STORE_ADD_ALWAYS, &child);
|
chain7_1, sizeof(chain7_1), CERT_STORE_ADD_ALWAYS, &child);
|
||||||
|
ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
|
||||||
parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags);
|
parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags);
|
||||||
ok(parent == NULL, "Expected no issuer\n");
|
ok(parent == NULL, "Expected no issuer\n");
|
||||||
/* Adding an issuer allows one (and only one) issuer to be found */
|
/* Adding an issuer allows one (and only one) issuer to be found */
|
||||||
ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
|
ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
|
||||||
chain10_0, sizeof(chain10_0), CERT_STORE_ADD_ALWAYS, &cert1);
|
chain10_0, sizeof(chain10_0), CERT_STORE_ADD_ALWAYS, &cert1);
|
||||||
|
ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
|
||||||
parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags);
|
parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags);
|
||||||
ok(parent == cert1, "Expected cert1 to be the issuer\n");
|
ok(parent == cert1, "Expected cert1 to be the issuer\n");
|
||||||
parent = CertGetIssuerCertificateFromStore(store, child, parent, &flags);
|
parent = CertGetIssuerCertificateFromStore(store, child, parent, &flags);
|
||||||
|
@ -1564,6 +1570,7 @@ static void testGetIssuerCert(void)
|
||||||
*/
|
*/
|
||||||
ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
|
ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
|
||||||
chain10_1, sizeof(chain10_1), CERT_STORE_ADD_ALWAYS, &cert2);
|
chain10_1, sizeof(chain10_1), CERT_STORE_ADD_ALWAYS, &cert2);
|
||||||
|
ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
|
||||||
parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags);
|
parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags);
|
||||||
ok(parent == cert2, "Expected cert2 to be the first issuer\n");
|
ok(parent == cert2, "Expected cert2 to be the first issuer\n");
|
||||||
parent = CertGetIssuerCertificateFromStore(store, child, parent, &flags);
|
parent = CertGetIssuerCertificateFromStore(store, child, parent, &flags);
|
||||||
|
@ -2015,6 +2022,8 @@ static void testCreateSelfSignCert(void)
|
||||||
CryptReleaseContext(csp, 0);
|
CryptReleaseContext(csp, 0);
|
||||||
ret = pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL,
|
ret = pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL,
|
||||||
CRYPT_DELETEKEYSET);
|
CRYPT_DELETEKEYSET);
|
||||||
|
ok(ret, "CryptAcquireContext failed: %08x\n", GetLastError());
|
||||||
|
|
||||||
|
|
||||||
/* do the same test with AT_KEYEXCHANGE and key info*/
|
/* do the same test with AT_KEYEXCHANGE and key info*/
|
||||||
memset(&info,0,sizeof(info));
|
memset(&info,0,sizeof(info));
|
||||||
|
@ -2083,7 +2092,7 @@ static void testIntendedKeyUsage(void)
|
||||||
if (0)
|
if (0)
|
||||||
{
|
{
|
||||||
/* Crash */
|
/* Crash */
|
||||||
ret = CertGetIntendedKeyUsage(0, NULL, NULL, 0);
|
CertGetIntendedKeyUsage(0, NULL, NULL, 0);
|
||||||
}
|
}
|
||||||
ret = CertGetIntendedKeyUsage(0, &info, NULL, 0);
|
ret = CertGetIntendedKeyUsage(0, &info, NULL, 0);
|
||||||
ok(!ret, "expected failure\n");
|
ok(!ret, "expected failure\n");
|
||||||
|
@ -2093,6 +2102,7 @@ static void testIntendedKeyUsage(void)
|
||||||
ok(!ret, "expected failure\n");
|
ok(!ret, "expected failure\n");
|
||||||
ret = CertGetIntendedKeyUsage(X509_ASN_ENCODING, &info, usage_bytes,
|
ret = CertGetIntendedKeyUsage(X509_ASN_ENCODING, &info, usage_bytes,
|
||||||
sizeof(usage_bytes));
|
sizeof(usage_bytes));
|
||||||
|
ok(!ret, "expected failure\n");
|
||||||
info.cExtension = 1;
|
info.cExtension = 1;
|
||||||
info.rgExtension = &ext;
|
info.rgExtension = &ext;
|
||||||
ret = CertGetIntendedKeyUsage(X509_ASN_ENCODING, &info, NULL, 0);
|
ret = CertGetIntendedKeyUsage(X509_ASN_ENCODING, &info, NULL, 0);
|
||||||
|
@ -2251,6 +2261,8 @@ static void testKeyUsage(void)
|
||||||
SetLastError(0xbaadcafe);
|
SetLastError(0xbaadcafe);
|
||||||
size = sizeof(buf);
|
size = sizeof(buf);
|
||||||
ret = CertGetEnhancedKeyUsage(context, 0, pUsage, &size);
|
ret = CertGetEnhancedKeyUsage(context, 0, pUsage, &size);
|
||||||
|
ok(ret || broken(!ret && GetLastError() == CRYPT_E_NOT_FOUND /* NT4 */),
|
||||||
|
"CertGetEnhancedKeyUsage failed: %08x\n", GetLastError());
|
||||||
ok(GetLastError() == CRYPT_E_NOT_FOUND,
|
ok(GetLastError() == CRYPT_E_NOT_FOUND,
|
||||||
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
|
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
|
||||||
|
|
||||||
|
@ -2656,9 +2668,8 @@ static void testIsRDNAttrsInCertificateName(void)
|
||||||
if (0)
|
if (0)
|
||||||
{
|
{
|
||||||
/* Crash */
|
/* Crash */
|
||||||
ret = CertIsRDNAttrsInCertificateName(0, 0, NULL, NULL);
|
CertIsRDNAttrsInCertificateName(0, 0, NULL, NULL);
|
||||||
ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, 0, &name,
|
CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, 0, &name, NULL);
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
ret = CertIsRDNAttrsInCertificateName(0, 0, &name, NULL);
|
ret = CertIsRDNAttrsInCertificateName(0, 0, &name, NULL);
|
||||||
|
@ -2932,7 +2943,7 @@ static void testHashToBeSigned(void)
|
||||||
/* Crash */
|
/* Crash */
|
||||||
if (0)
|
if (0)
|
||||||
{
|
{
|
||||||
ret = CryptHashToBeSigned(0, 0, NULL, 0, NULL, NULL);
|
CryptHashToBeSigned(0, 0, NULL, 0, NULL, NULL);
|
||||||
}
|
}
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
ret = CryptHashToBeSigned(0, 0, NULL, 0, NULL, &size);
|
ret = CryptHashToBeSigned(0, 0, NULL, 0, NULL, &size);
|
||||||
|
@ -2973,6 +2984,9 @@ static void testHashToBeSigned(void)
|
||||||
|
|
||||||
ret = CryptHashToBeSigned(0, X509_ASN_ENCODING, md5SignedEmptyCert,
|
ret = CryptHashToBeSigned(0, X509_ASN_ENCODING, md5SignedEmptyCert,
|
||||||
sizeof(md5SignedEmptyCert), hash, &size);
|
sizeof(md5SignedEmptyCert), hash, &size);
|
||||||
|
ok(ret || broken(!ret && GetLastError() == NTE_BAD_ALGID) /* NT4 */,
|
||||||
|
"CryptHashToBeSigned failed: %08x\n", GetLastError());
|
||||||
|
|
||||||
ok(!memcmp(hash, md5SignedEmptyCertHash, size), "unexpected value\n");
|
ok(!memcmp(hash, md5SignedEmptyCertHash, size), "unexpected value\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2981,9 +2995,9 @@ static void testCompareCert(void)
|
||||||
CERT_INFO info1 = { 0 }, info2 = { 0 };
|
CERT_INFO info1 = { 0 }, info2 = { 0 };
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
|
||||||
/* Crashes
|
/* Crashes */
|
||||||
ret = CertCompareCertificate(X509_ASN_ENCODING, NULL, NULL);
|
if (0)
|
||||||
*/
|
CertCompareCertificate(X509_ASN_ENCODING, NULL, NULL);
|
||||||
|
|
||||||
/* Certs with the same issuer and serial number are equal, even if they
|
/* Certs with the same issuer and serial number are equal, even if they
|
||||||
* differ in other respects (like subject).
|
* differ in other respects (like subject).
|
||||||
|
|
Loading…
Reference in New Issue