Signed-off-by: Hans Leidekker hans@codeweavers.com --- dlls/crypt32/tests/cert.c | 418 +++------- dlls/crypt32/tests/chain.c | 166 ++-- dlls/crypt32/tests/crl.c | 197 ++--- dlls/crypt32/tests/ctl.c | 52 +- dlls/crypt32/tests/encode.c | 1235 ++++++++++++------------------ dlls/crypt32/tests/message.c | 117 +-- dlls/crypt32/tests/msg.c | 758 +++++++----------- dlls/crypt32/tests/object.c | 37 +- dlls/crypt32/tests/oid.c | 155 ++-- dlls/crypt32/tests/protectdata.c | 76 +- dlls/crypt32/tests/sip.c | 37 +- dlls/crypt32/tests/store.c | 15 +- dlls/crypt32/tests/str.c | 210 ++--- 13 files changed, 1268 insertions(+), 2205 deletions(-)
diff --git a/dlls/crypt32/tests/cert.c b/dlls/crypt32/tests/cert.c index e781045b2c4..3cdb5e5ceea 100644 --- a/dlls/crypt32/tests/cert.c +++ b/dlls/crypt32/tests/cert.c @@ -32,32 +32,6 @@
#include "wine/test.h"
-static PCCERT_CONTEXT (WINAPI *pCertCreateSelfSignCertificate)(HCRYPTPROV_OR_NCRYPT_KEY_HANDLE,PCERT_NAME_BLOB,DWORD,PCRYPT_KEY_PROV_INFO,PCRYPT_ALGORITHM_IDENTIFIER,PSYSTEMTIME,PSYSTEMTIME,PCERT_EXTENSIONS); -static BOOL (WINAPI *pCertGetValidUsages)(DWORD,PCCERT_CONTEXT*,int*,LPSTR*,DWORD*); -static BOOL (WINAPI *pCryptAcquireCertificatePrivateKey)(PCCERT_CONTEXT,DWORD,void*,HCRYPTPROV_OR_NCRYPT_KEY_HANDLE*,DWORD*,BOOL*); -static BOOL (WINAPI *pCryptEncodeObjectEx)(DWORD,LPCSTR,const void*,DWORD,PCRYPT_ENCODE_PARA,void*,DWORD*); -static BOOL (WINAPI *pCryptHashCertificate2)(LPCWSTR, DWORD, void*, const BYTE*, DWORD, BYTE*, DWORD*); -static BOOL (WINAPI * pCryptVerifyCertificateSignatureEx) - (HCRYPTPROV, DWORD, DWORD, void *, DWORD, void *, DWORD, void *); - -static void init_function_pointers(void) -{ - HMODULE hCrypt32 = GetModuleHandleA("crypt32.dll"); - -#define GET_PROC(dll, func) \ - p ## func = (void *)GetProcAddress(dll, #func); \ - if(!p ## func) \ - trace("GetProcAddress(%s) failed\n", #func); - - GET_PROC(hCrypt32, CertCreateSelfSignCertificate) - GET_PROC(hCrypt32, CertGetValidUsages) - GET_PROC(hCrypt32, CryptAcquireCertificatePrivateKey) - GET_PROC(hCrypt32, CryptEncodeObjectEx) - GET_PROC(hCrypt32, CryptHashCertificate2) - GET_PROC(hCrypt32, CryptVerifyCertificateSignatureEx) -#undef GET_PROC -} - static BYTE subjectName[] = { 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00 }; @@ -152,24 +126,18 @@ static void testAddCert(void) if (!store) return;
- /* Weird--bad add disposition leads to an access violation in Windows. - * Both tests crash on some win9x boxes. - */ - if (0) - { - ret = CertAddEncodedCertificateToStore(0, X509_ASN_ENCODING, bigCert, - sizeof(bigCert), 0, NULL); - ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION || - GetLastError() == E_INVALIDARG), - "Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08lx\n", - GetLastError()); - ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, - bigCert, sizeof(bigCert), 0, NULL); - ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION || - GetLastError() == E_INVALIDARG), - "Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08lx\n", - GetLastError()); - } + ret = CertAddEncodedCertificateToStore(0, X509_ASN_ENCODING, bigCert, + sizeof(bigCert), 0, NULL); + ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION || + GetLastError() == E_INVALIDARG), + "Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08lx\n", + GetLastError()); + ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, + bigCert, sizeof(bigCert), 0, NULL); + ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION || + GetLastError() == E_INVALIDARG), + "Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08lx\n", + GetLastError());
/* Weird--can add a cert to the NULL store (does this have special * meaning?) @@ -177,15 +145,8 @@ static void testAddCert(void) context = NULL; ret = CertAddEncodedCertificateToStore(0, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, &context); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* win98 */), - "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); - if (context) - CertFreeCertificateContext(context); - if (!ret && GetLastError() == OSS_DATA_ERROR) - { - skip("bigCert can't be decoded, skipping tests\n"); - return; - } + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); + CertFreeCertificateContext(context);
ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL); @@ -409,14 +370,11 @@ static void testCertProperties(void) CRYPT_DATA_BLOB blob; CERT_KEY_CONTEXT keyContext;
- ok(context != NULL || broken(GetLastError() == OSS_DATA_ERROR /* win98 */), - "CertCreateCertificateContext failed: %08lx\n", GetLastError()); - if (!context) - return; + ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n", GetLastError());
/* This crashes propID = CertEnumCertificateContextProperties(NULL, 0); - */ + */
propID = 0; numProps = 0; @@ -513,10 +471,7 @@ static void testCertProperties(void) size = 0; ret = CertGetCertificateContextProperty(context, CERT_SIGNATURE_HASH_PROP_ID, NULL, &size); - ok(!ret && - (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == CRYPT_E_NOT_FOUND || - GetLastError() == OSS_DATA_ERROR), /* win9x */ + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError());
/* Test key contexts and handles and such */ @@ -646,9 +601,7 @@ static void testCreateCert(void) "expected E_INVALIDARG, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); cert = CertCreateCertificateContext(X509_ASN_ENCODING, NULL, 0); - ok(!cert && - (GetLastError() == CRYPT_E_ASN1_EOD || - broken(GetLastError() == OSS_MORE_INPUT /* NT4 */)), + ok(!cert && GetLastError() == CRYPT_E_ASN1_EOD, "expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
cert = CertCreateCertificateContext(X509_ASN_ENCODING, @@ -687,13 +640,7 @@ static void testDupCert(void)
ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, &context); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* win98 */), - "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); - if (!ret && GetLastError() == OSS_DATA_ERROR) - { - skip("bigCert can't be decoded, skipping tests\n"); - return; - } + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); ok(context != NULL, "Expected a valid cert context\n"); if (context) { @@ -1143,13 +1090,8 @@ static void testFindCert(void)
ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_NEW, NULL); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* win98 */), - "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); - if (!ret && GetLastError() == OSS_DATA_ERROR) - { - skip("bigCert can't be decoded, skipping tests\n"); - return; - } + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); + ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, bigCert2, sizeof(bigCert2), CERT_STORE_ADD_NEW, NULL); ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", @@ -1368,13 +1310,8 @@ static void testGetSubjectCert(void)
ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* win98 */), - "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); - if (!ret && GetLastError() == OSS_DATA_ERROR) - { - skip("bigCert can't be decoded, skipping tests\n"); - return; - } + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); + ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, bigCert2, sizeof(bigCert2), CERT_STORE_ADD_NEW, &context1); ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", @@ -1791,29 +1728,23 @@ static void testCryptHashCert2(void) BYTE hash[20]; DWORD hashLen;
- if (!pCryptHashCertificate2) - { - win_skip("CryptHashCertificate2() is not available\n"); - return; - } - /* Test empty hash */ hashLen = sizeof(hash); - ret = pCryptHashCertificate2(L"SHA1", 0, NULL, NULL, 0, hash, &hashLen); + ret = CryptHashCertificate2(L"SHA1", 0, NULL, NULL, 0, hash, &hashLen); ok(ret, "CryptHashCertificate2 failed: %08lx\n", GetLastError()); ok(hashLen == sizeof(hash), "Got unexpected size of hash %ld\n", hashLen); ok(!memcmp(hash, emptyHash, sizeof(emptyHash)), "Unexpected hash of nothing\n");
/* Test known hash */ hashLen = sizeof(hash); - ret = pCryptHashCertificate2(L"SHA1", 0, NULL, toHash, sizeof(toHash), hash, &hashLen); + ret = CryptHashCertificate2(L"SHA1", 0, NULL, toHash, sizeof(toHash), hash, &hashLen); ok(ret, "CryptHashCertificate2 failed: %08lx\n", GetLastError()); ok(hashLen == sizeof(hash), "Got unexpected size of hash %ld\n", hashLen); ok(!memcmp(hash, knownHash, sizeof(knownHash)), "Unexpected hash\n");
/* Test null hash size pointer just sets hash size */ hashLen = 0; - ret = pCryptHashCertificate2(L"SHA1", 0, NULL, toHash, sizeof(toHash), NULL, &hashLen); + ret = CryptHashCertificate2(L"SHA1", 0, NULL, toHash, sizeof(toHash), NULL, &hashLen); ok(ret, "CryptHashCertificate2 failed: %08lx\n", GetLastError()); ok(hashLen == sizeof(hash), "Hash size not set correctly (%ld)\n", hashLen);
@@ -1821,30 +1752,30 @@ static void testCryptHashCert2(void) if (0) { /* Test null algorithm ID */ hashLen = sizeof(hash); - ret = pCryptHashCertificate2(NULL, 0, NULL, toHash, sizeof(toHash), hash, &hashLen); + ret = CryptHashCertificate2(NULL, 0, NULL, toHash, sizeof(toHash), hash, &hashLen); }
/* Test invalid algorithm */ hashLen = sizeof(hash); SetLastError(0xdeadbeef); - ret = pCryptHashCertificate2(L"_SHOULDNOTEXIST_", 0, NULL, toHash, sizeof(toHash), hash, &hashLen); + ret = CryptHashCertificate2(L"_SHOULDNOTEXIST_", 0, NULL, toHash, sizeof(toHash), hash, &hashLen); ok(!ret && GetLastError() == STATUS_NOT_FOUND, "Expected STATUS_NOT_FOUND (0x%08lx), got 0x%08lx\n", STATUS_NOT_FOUND, GetLastError());
/* Test hash buffer too small */ hashLen = sizeof(hash) / 2; SetLastError(0xdeadbeef); - ret = pCryptHashCertificate2(L"SHA1", 0, NULL, toHash, sizeof(toHash), hash, &hashLen); + ret = CryptHashCertificate2(L"SHA1", 0, NULL, toHash, sizeof(toHash), hash, &hashLen); ok(!ret && GetLastError() == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA (%d), got %ld\n", ERROR_MORE_DATA, GetLastError());
/* Null hash length crashes Windows implementations */ if (0) { /* Test hashLen null with hash */ - ret = pCryptHashCertificate2(L"SHA1", 0, NULL, toHash, sizeof(toHash), hash, NULL); + ret = CryptHashCertificate2(L"SHA1", 0, NULL, toHash, sizeof(toHash), hash, NULL);
/* Test hashLen null with no hash */ - ret = pCryptHashCertificate2(L"SHA1", 0, NULL, toHash, sizeof(toHash), NULL, NULL); + ret = CryptHashCertificate2(L"SHA1", 0, NULL, toHash, sizeof(toHash), NULL, NULL); } }
@@ -1862,7 +1793,6 @@ static void verifySig(HCRYPTPROV csp, const BYTE *toSign, size_t toSignLen,
ret = CryptHashData(hash, toSign, toSignLen, 0); ok(ret, "CryptHashData failed: %08lx\n", GetLastError()); - /* use the A variant so the test can run on Win9x */ ret = CryptSignHashA(hash, AT_SIGNATURE, NULL, 0, mySig, &mySigSize); ok(ret, "CryptSignHash failed: %08lx\n", GetLastError()); if (ret) @@ -1950,11 +1880,6 @@ static void testVerifyCertSig(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigned, DWORD size = 0; BOOL ret;
- if (!pCryptEncodeObjectEx) - { - win_skip("no CryptEncodeObjectEx support\n"); - return; - } ret = CryptVerifyCertificateSignature(0, 0, NULL, 0, NULL); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); @@ -1963,9 +1888,8 @@ static void testVerifyCertSig(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigned, "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); ret = CryptVerifyCertificateSignature(csp, X509_ASN_ENCODING, NULL, 0, NULL); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_BAD_ARG), - "Expected CRYPT_E_ASN1_EOD or OSS_BAD_ARG, got %08lx\n", GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); info.ToBeSigned.cbData = toBeSigned->cbData; info.ToBeSigned.pbData = toBeSigned->pbData; info.SignatureAlgorithm.pszObjId = (LPSTR)sigOID; @@ -1973,7 +1897,7 @@ static void testVerifyCertSig(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigned, info.Signature.cbData = sigLen; info.Signature.pbData = (BYTE *)sig; info.Signature.cUnusedBits = 0; - ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, X509_CERT, &info, + ret = CryptEncodeObjectEx(X509_ASN_ENCODING, X509_CERT, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &cert, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (cert) @@ -2017,28 +1941,18 @@ static void testVerifyCertSigEx(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigne DWORD size = 0; BOOL ret;
- if (!pCryptVerifyCertificateSignatureEx) - { - win_skip("no CryptVerifyCertificateSignatureEx support\n"); - return; - } - if (!pCryptEncodeObjectEx) - { - win_skip("no CryptEncodeObjectEx support\n"); - return; - } - ret = pCryptVerifyCertificateSignatureEx(0, 0, 0, NULL, 0, NULL, 0, NULL); + ret = CryptVerifyCertificateSignatureEx(0, 0, 0, NULL, 0, NULL, 0, NULL); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError()); - ret = pCryptVerifyCertificateSignatureEx(csp, 0, 0, NULL, 0, NULL, 0, NULL); + ret = CryptVerifyCertificateSignatureEx(csp, 0, 0, NULL, 0, NULL, 0, NULL); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError()); - ret = pCryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, 0, NULL, 0, + ret = CryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, 0, NULL, 0, NULL, 0, NULL); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* This crashes - ret = pCryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, + ret = CryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB, NULL, 0, NULL, 0, NULL); */ info.ToBeSigned.cbData = toBeSigned->cbData; @@ -2048,7 +1962,7 @@ static void testVerifyCertSigEx(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigne info.Signature.cbData = sigLen; info.Signature.pbData = (BYTE *)sig; info.Signature.cUnusedBits = 0; - ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, X509_CERT, &info, + ret = CryptEncodeObjectEx(X509_ASN_ENCODING, X509_CERT, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &cert, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (cert) @@ -2056,33 +1970,31 @@ static void testVerifyCertSigEx(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigne CRYPT_DATA_BLOB certBlob = { 0, NULL }; PCERT_PUBLIC_KEY_INFO pubKeyInfo = NULL;
- ret = pCryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, + ret = CryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB, &certBlob, 0, NULL, 0, NULL); ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); certBlob.cbData = 1; certBlob.pbData = (void *)0xdeadbeef; - ret = pCryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, + ret = CryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB, &certBlob, 0, NULL, 0, NULL); - ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION || - GetLastError() == CRYPT_E_ASN1_EOD /* Win9x */ || - GetLastError() == CRYPT_E_ASN1_BADTAG /* Win98 */), + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, CRYPT_E_ASN1_EOD, OR CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError());
certBlob.cbData = size; certBlob.pbData = cert; - ret = pCryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, + ret = CryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB, &certBlob, 0, NULL, 0, NULL); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError()); - ret = pCryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, + ret = CryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB, &certBlob, CRYPT_VERIFY_CERT_SIGN_ISSUER_NULL, NULL, 0, NULL); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* This crashes - ret = pCryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, + ret = CryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB, &certBlob, CRYPT_VERIFY_CERT_SIGN_ISSUER_PUBKEY, NULL, 0, NULL); */ @@ -2096,7 +2008,7 @@ static void testVerifyCertSigEx(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigne ok(ret, "CryptExportKey failed: %08lx\n", GetLastError()); if (ret) { - ret = pCryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, + ret = CryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB, &certBlob, CRYPT_VERIFY_CERT_SIGN_ISSUER_PUBKEY, pubKeyInfo, 0, NULL); ok(ret, "CryptVerifyCertificateSignatureEx failed: %08lx\n", @@ -2177,31 +2089,23 @@ static void testSignAndEncodeCert(void) &algID, NULL, NULL, &size); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); - /* Crashes on some win9x boxes */ - if (0) - { - ret = CryptSignAndEncodeCertificate(0, 0, X509_ASN_ENCODING, - X509_CERT_TO_BE_SIGNED, NULL, &algID, NULL, NULL, &size); - ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); - } + ret = CryptSignAndEncodeCertificate(0, 0, X509_ASN_ENCODING, + X509_CERT_TO_BE_SIGNED, NULL, &algID, NULL, NULL, &size); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + /* Crashes ret = CryptSignAndEncodeCertificate(0, 0, X509_ASN_ENCODING, X509_CERT_TO_BE_SIGNED, &info, NULL, NULL, NULL, &size); */ ret = CryptSignAndEncodeCertificate(0, 0, X509_ASN_ENCODING, X509_CERT_TO_BE_SIGNED, &info, &algID, NULL, NULL, &size); - ok(!ret && - (GetLastError() == NTE_BAD_ALGID || - GetLastError() == OSS_BAD_PTR), /* win9x */ + ok(!ret && GetLastError() == NTE_BAD_ALGID, "Expected NTE_BAD_ALGID, got %08lx\n", GetLastError()); algID.pszObjId = oid_rsa_md5rsa; ret = CryptSignAndEncodeCertificate(0, 0, X509_ASN_ENCODING, X509_CERT_TO_BE_SIGNED, &info, &algID, NULL, NULL, &size); - ok(!ret && - (GetLastError() == ERROR_INVALID_PARAMETER || - GetLastError() == NTE_BAD_ALGID || - GetLastError() == OSS_BAD_PTR), /* Win9x */ + ok(!ret && (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == NTE_BAD_ALGID), "Expected ERROR_INVALID_PARAMETER or NTE_BAD_ALGID, got %08lx\n", GetLastError()); algID.pszObjId = oid_rsa_md5; @@ -2245,19 +2149,13 @@ static void testCreateSelfSignCert(void) HCRYPTKEY key; CRYPT_KEY_PROV_INFO info;
- if (!pCertCreateSelfSignCertificate) - { - win_skip("CertCreateSelfSignCertificate() is not available\n"); - return; - } - /* This crashes: - context = pCertCreateSelfSignCertificate(0, NULL, 0, NULL, NULL, NULL, NULL, + context = CertCreateSelfSignCertificate(0, NULL, 0, NULL, NULL, NULL, NULL, NULL); * Calling this with no first parameter creates a new key container, which * lasts beyond the test, so I don't test that. Nb: the generated key * name is a GUID. - context = pCertCreateSelfSignCertificate(0, &name, 0, NULL, NULL, NULL, NULL, + context = CertCreateSelfSignCertificate(0, &name, 0, NULL, NULL, NULL, NULL, NULL); */
@@ -2268,7 +2166,7 @@ static void testCreateSelfSignCert(void) CRYPT_NEWKEYSET); ok(ret, "CryptAcquireContext failed: %08lx\n", GetLastError());
- context = pCertCreateSelfSignCertificate(csp, &name, 0, NULL, NULL, NULL, + context = CertCreateSelfSignCertificate(csp, &name, 0, NULL, NULL, NULL, NULL, NULL); ok(!context && GetLastError() == NTE_NO_KEY, "Expected NTE_NO_KEY, got %08lx\n", GetLastError()); @@ -2276,7 +2174,7 @@ static void testCreateSelfSignCert(void) ok(ret, "CryptGenKey failed: %08lx\n", GetLastError()); if (ret) { - context = pCertCreateSelfSignCertificate(csp, &name, 0, NULL, NULL, NULL, + context = CertCreateSelfSignCertificate(csp, &name, 0, NULL, NULL, NULL, NULL, NULL); ok(context != NULL, "CertCreateSelfSignCertificate failed: %08lx\n", GetLastError()); @@ -2339,7 +2237,7 @@ static void testCreateSelfSignCert(void) info.pwszContainerName = (WCHAR *)L"WineCryptTemp"; /* This should fail because the CSP doesn't have the specified key. */ SetLastError(0xdeadbeef); - context = pCertCreateSelfSignCertificate(csp, &name, 0, &info, NULL, NULL, + context = CertCreateSelfSignCertificate(csp, &name, 0, &info, NULL, NULL, NULL, NULL); ok(context == NULL, "expected failure\n"); if (context != NULL) @@ -2350,7 +2248,7 @@ static void testCreateSelfSignCert(void) /* Again, with a CSP, AT_SIGNATURE and key info */ info.dwKeySpec = AT_SIGNATURE; SetLastError(0xdeadbeef); - context = pCertCreateSelfSignCertificate(csp, &name, 0, &info, NULL, NULL, + context = CertCreateSelfSignCertificate(csp, &name, 0, &info, NULL, NULL, NULL, NULL); ok(context != NULL, "CertCreateSelfSignCertificate failed: %08lx\n", GetLastError()); @@ -2397,7 +2295,7 @@ static void testCreateSelfSignCert(void)
/* Do the same test with no CSP, AT_KEYEXCHANGE and key info */ info.dwKeySpec = AT_KEYEXCHANGE; - context = pCertCreateSelfSignCertificate(0, &name, 0, &info, NULL, NULL, + context = CertCreateSelfSignCertificate(0, &name, 0, &info, NULL, NULL, NULL, NULL); ok(context != NULL, "CertCreateSelfSignCertificate failed: %08lx\n", GetLastError()); @@ -2446,7 +2344,7 @@ static void testCreateSelfSignCert(void) CRYPT_NEWKEYSET); ok(ret, "CryptAcquireContext failed: %08lx\n", GetLastError());
- context = pCertCreateSelfSignCertificate(csp, &name, 0, NULL, NULL, NULL, + context = CertCreateSelfSignCertificate(csp, &name, 0, NULL, NULL, NULL, NULL, NULL); ok(!context && GetLastError() == NTE_NO_KEY, "Expected NTE_NO_KEY, got %08lx\n", GetLastError()); @@ -2461,7 +2359,7 @@ static void testCreateSelfSignCert(void) info.pwszContainerName = (WCHAR *)L"WineCryptTemp"; /* This should fail because the CSP doesn't have the specified key. */ SetLastError(0xdeadbeef); - context = pCertCreateSelfSignCertificate(csp, &name, 0, &info, NULL, NULL, + context = CertCreateSelfSignCertificate(csp, &name, 0, &info, NULL, NULL, NULL, NULL); ok(context == NULL, "expected failure\n"); if (context != NULL) @@ -2474,7 +2372,7 @@ static void testCreateSelfSignCert(void) */ info.dwKeySpec = AT_KEYEXCHANGE; SetLastError(0xdeadbeef); - context = pCertCreateSelfSignCertificate(csp, &name, 0, &info, NULL, NULL, + context = CertCreateSelfSignCertificate(csp, &name, 0, &info, NULL, NULL, NULL, NULL); ok(context != NULL, "CertCreateSelfSignCertificate failed: %08lx\n", GetLastError()); @@ -2707,8 +2605,7 @@ static void testKeyUsage(void) SetLastError(0xbaadcafe); size = sizeof(buf); ret = CertGetEnhancedKeyUsage(context, 0, pUsage, &size); - ok(ret || broken(!ret && GetLastError() == CRYPT_E_NOT_FOUND /* NT4 */), - "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError()); + ok(ret, "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError()); ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
@@ -2882,20 +2779,14 @@ static void testGetValidUsages(void) LPSTR *oids = NULL; PCCERT_CONTEXT contexts[3];
- if (!pCertGetValidUsages) - { - win_skip("CertGetValidUsages() is not available\n"); - return; - } - /* Crash - ret = pCertGetValidUsages(0, NULL, NULL, NULL, NULL); - ret = pCertGetValidUsages(0, NULL, NULL, NULL, &size); + ret = CertGetValidUsages(0, NULL, NULL, NULL, NULL); + ret = CertGetValidUsages(0, NULL, NULL, NULL, &size); */ contexts[0] = NULL; size = numOIDs = 0xdeadbeef; SetLastError(0xdeadbeef); - ret = pCertGetValidUsages(1, &contexts[0], &numOIDs, NULL, &size); + ret = CertGetValidUsages(1, &contexts[0], &numOIDs, NULL, &size); ok(ret, "CertGetValidUsages failed: %ld\n", GetLastError()); ok(numOIDs == -1, "Expected -1, got %d\n", numOIDs); ok(size == 0, "Expected size 0, got %ld\n", size); @@ -2906,16 +2797,16 @@ static void testGetValidUsages(void) contexts[2] = CertCreateCertificateContext(X509_ASN_ENCODING, cert2WithUsage, sizeof(cert2WithUsage)); size = numOIDs = 0xdeadbeef; - ret = pCertGetValidUsages(0, NULL, &numOIDs, NULL, &size); + ret = CertGetValidUsages(0, NULL, &numOIDs, NULL, &size); ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError()); ok(numOIDs == -1, "Expected -1, got %d\n", numOIDs); ok(size == 0, "Expected size 0, got %ld\n", size); size = numOIDs = 0xdeadbeef; - ret = pCertGetValidUsages(1, contexts, &numOIDs, NULL, &size); + ret = CertGetValidUsages(1, contexts, &numOIDs, NULL, &size); ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError()); ok(numOIDs == -1, "Expected -1, got %d\n", numOIDs); ok(size == 0, "Expected size 0, got %ld\n", size); - ret = pCertGetValidUsages(1, &contexts[1], &numOIDs, NULL, &size); + ret = CertGetValidUsages(1, &contexts[1], &numOIDs, NULL, &size); ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError()); ok(numOIDs == 3, "Expected 3, got %d\n", numOIDs); ok(size, "Expected non-zero size\n"); @@ -2926,10 +2817,10 @@ static void testGetValidUsages(void) DWORD smallSize = 1;
SetLastError(0xdeadbeef); - ret = pCertGetValidUsages(1, &contexts[1], &numOIDs, oids, &smallSize); + ret = CertGetValidUsages(1, &contexts[1], &numOIDs, oids, &smallSize); ok(!ret && GetLastError() == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %ld\n", GetLastError()); - ret = pCertGetValidUsages(1, &contexts[1], &numOIDs, oids, &size); + ret = CertGetValidUsages(1, &contexts[1], &numOIDs, oids, &size); ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError()); for (i = 0; i < numOIDs; i++) ok(!lstrcmpA(oids[i], expectedOIDs[i]), "unexpected OID %s\n", @@ -2938,11 +2829,11 @@ static void testGetValidUsages(void) } numOIDs = 0xdeadbeef; /* Oddly enough, this crashes when the number of contexts is not 1: - ret = pCertGetValidUsages(2, contexts, &numOIDs, NULL, &size); + ret = CertGetValidUsages(2, contexts, &numOIDs, NULL, &size); * but setting size to 0 allows it to succeed: */ size = 0; - ret = pCertGetValidUsages(2, contexts, &numOIDs, NULL, &size); + ret = CertGetValidUsages(2, contexts, &numOIDs, NULL, &size); ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError()); ok(numOIDs == 3, "Expected 3, got %d\n", numOIDs); ok(size, "Expected non-zero size\n"); @@ -2951,7 +2842,7 @@ static void testGetValidUsages(void) { int i;
- ret = pCertGetValidUsages(1, &contexts[1], &numOIDs, oids, &size); + ret = CertGetValidUsages(1, &contexts[1], &numOIDs, oids, &size); ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError()); for (i = 0; i < numOIDs; i++) ok(!lstrcmpA(oids[i], expectedOIDs[i]), "unexpected OID %s\n", @@ -2960,7 +2851,7 @@ static void testGetValidUsages(void) } numOIDs = 0xdeadbeef; size = 0; - ret = pCertGetValidUsages(1, &contexts[2], &numOIDs, NULL, &size); + ret = CertGetValidUsages(1, &contexts[2], &numOIDs, NULL, &size); ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError()); ok(numOIDs == 2, "Expected 2, got %d\n", numOIDs); ok(size, "Expected non-zero size\n"); @@ -2969,7 +2860,7 @@ static void testGetValidUsages(void) { int i;
- ret = pCertGetValidUsages(1, &contexts[2], &numOIDs, oids, &size); + ret = CertGetValidUsages(1, &contexts[2], &numOIDs, oids, &size); ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError()); for (i = 0; i < numOIDs; i++) ok(!lstrcmpA(oids[i], expectedOIDs2[i]), "unexpected OID %s\n", @@ -2978,7 +2869,7 @@ static void testGetValidUsages(void) } numOIDs = 0xdeadbeef; size = 0; - ret = pCertGetValidUsages(3, contexts, &numOIDs, NULL, &size); + ret = CertGetValidUsages(3, contexts, &numOIDs, NULL, &size); ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError()); ok(numOIDs == 2, "Expected 2, got %d\n", numOIDs); ok(size, "Expected non-zero size\n"); @@ -2987,7 +2878,7 @@ static void testGetValidUsages(void) { int i;
- ret = pCertGetValidUsages(3, contexts, &numOIDs, oids, &size); + ret = CertGetValidUsages(3, contexts, &numOIDs, oids, &size); ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError()); for (i = 0; i < numOIDs; i++) ok(!lstrcmpA(oids[i], expectedOIDs2[i]), "unexpected OID %s\n", @@ -3396,17 +3287,15 @@ static void testHashPublicKeyInfo(void) ret = CryptHashPublicKeyInfo(0, 0, 0, 0, NULL, NULL, &len); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); - /* Crashes on some win9x boxes */ - if (0) + + if (0) /* crash */ { ret = CryptHashPublicKeyInfo(0, 0, 0, X509_ASN_ENCODING, NULL, NULL, &len); ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); } ret = CryptHashPublicKeyInfo(0, 0, 0, X509_ASN_ENCODING, &info, NULL, &len); - ok(ret || - broken(!ret), /* win9x */ - "CryptHashPublicKeyInfo failed: %08lx\n", GetLastError()); + ok(ret, "CryptHashPublicKeyInfo failed: %08lx\n", GetLastError()); if (ret) { ok(len == 16, "Expected hash size 16, got %ld\n", len); @@ -3444,32 +3333,24 @@ static void testHashToBeSigned(void) "expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptHashToBeSigned(0, X509_ASN_ENCODING, NULL, 0, NULL, &size); - ok(!ret && - (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_BAD_ARG), /* win9x */ + ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, "expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); /* Can't sign anything: has to be asn.1 encoded, at least */ SetLastError(0xdeadbeef); ret = CryptHashToBeSigned(0, X509_ASN_ENCODING, int1, sizeof(int1), NULL, &size); - ok(!ret && - (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_MORE_INPUT), /* win9x */ + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, "expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); /* Can't be empty, either */ SetLastError(0xdeadbeef); ret = CryptHashToBeSigned(0, X509_ASN_ENCODING, emptyCert, sizeof(emptyCert), NULL, &size); - ok(!ret && - (GetLastError() == CRYPT_E_ASN1_CORRUPT || - GetLastError() == OSS_DATA_ERROR), /* win9x */ + ok(!ret && GetLastError() == CRYPT_E_ASN1_CORRUPT, "expected CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError()); /* Signing a cert works */ ret = CryptHashToBeSigned(0, X509_ASN_ENCODING, md5SignedEmptyCert, sizeof(md5SignedEmptyCert), NULL, &size); - ok(ret || - broken(!ret), /* win9x */ - "CryptHashToBeSigned failed: %08lx\n", GetLastError()); + ok(ret, "CryptHashToBeSigned failed: %08lx\n", GetLastError()); if (ret) { ok(size == sizeof(md5SignedEmptyCertHash), "unexpected size %ld\n", size); @@ -3477,9 +3358,7 @@ static void testHashToBeSigned(void)
ret = CryptHashToBeSigned(0, X509_ASN_ENCODING, md5SignedEmptyCert, sizeof(md5SignedEmptyCert), hash, &size); - ok(ret || broken(!ret && GetLastError() == NTE_BAD_ALGID) /* NT4 */, - "CryptHashToBeSigned failed: %08lx\n", GetLastError()); - + ok(ret, "CryptHashToBeSigned failed: %08lx\n", GetLastError()); ok(!memcmp(hash, md5SignedEmptyCertHash, size), "unexpected value\n"); }
@@ -3700,11 +3579,6 @@ static void testVerifyRevocation(void) SetLastError(0xdeadbeef); ret = CertVerifyRevocation(X509_ASN_ENCODING, CERT_CONTEXT_REVOCATION_TYPE, 1, (void **)certs, 0, NULL, &status); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - win_skip("CERT_CONTEXT_REVOCATION_TYPE unsupported, skipping\n"); - return; - } ok(!ret && GetLastError() == CRYPT_E_NO_REVOCATION_CHECK, "expected CRYPT_E_NO_REVOCATION_CHECK, got %08lx\n", GetLastError()); ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK, @@ -3714,12 +3588,10 @@ static void testVerifyRevocation(void) SetLastError(0xdeadbeef); ret = CertVerifyRevocation(X509_ASN_ENCODING, CERT_CONTEXT_REVOCATION_TYPE, 1, (void **)&certs[1], 0, NULL, &status); - ok(!ret && (GetLastError() == CRYPT_E_NO_REVOCATION_CHECK /* Win9x */ || - GetLastError() == CRYPT_E_REVOCATION_OFFLINE), + ok(!ret && (GetLastError() == CRYPT_E_REVOCATION_OFFLINE || GetLastError() == CRYPT_E_NO_REVOCATION_CHECK), "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08lx\n", GetLastError()); - ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK /* Win9x */ || - status.dwError == CRYPT_E_REVOCATION_OFFLINE, + ok(status.dwError == CRYPT_E_REVOCATION_OFFLINE || status.dwError == CRYPT_E_NO_REVOCATION_CHECK, "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08lx\n", status.dwError); ok(status.dwIndex == 0, "expected index 0, got %ld\n", status.dwIndex); @@ -3727,12 +3599,10 @@ static void testVerifyRevocation(void) SetLastError(0xdeadbeef); ret = CertVerifyRevocation(X509_ASN_ENCODING, CERT_CONTEXT_REVOCATION_TYPE, 2, (void **)certs, 0, NULL, &status); - ok(!ret && (GetLastError() == CRYPT_E_NO_REVOCATION_CHECK || - GetLastError() == CRYPT_E_REVOCATION_OFFLINE /* WinME */), + ok(!ret && GetLastError() == CRYPT_E_NO_REVOCATION_CHECK, "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08lx\n", GetLastError()); - ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK || - status.dwError == CRYPT_E_REVOCATION_OFFLINE /* WinME */, + ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK, "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08lx\n", status.dwError); ok(status.dwIndex == 0, "expected index 0, got %ld\n", status.dwIndex); @@ -3744,12 +3614,10 @@ static void testVerifyRevocation(void) SetLastError(0xdeadbeef); ret = CertVerifyRevocation(X509_ASN_ENCODING, CERT_CONTEXT_REVOCATION_TYPE, 2, (void **)certs, 0, &revPara, &status); - ok(!ret && (GetLastError() == CRYPT_E_NO_REVOCATION_CHECK || - GetLastError() == CRYPT_E_REVOCATION_OFFLINE /* WinME */), + ok(!ret && GetLastError() == CRYPT_E_NO_REVOCATION_CHECK, "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08lx\n", GetLastError()); - ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK || - status.dwError == CRYPT_E_REVOCATION_OFFLINE /* WinME */, + ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK, "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08lx\n", status.dwError); ok(status.dwIndex == 0, "expected index 0, got %ld\n", status.dwIndex); @@ -3767,14 +3635,9 @@ static void testVerifyRevocation(void) SetLastError(0xdeadbeef); ret = CertVerifyRevocation(X509_ASN_ENCODING, CERT_CONTEXT_REVOCATION_TYPE, 1, (void **)&certs[1], 0, &revPara, &status); - /* Win2k thinks the cert is revoked, and it is, except the CRL is out of - * date, hence the revocation status should be unknown. - */ - ok(!ret && (GetLastError() == CRYPT_E_NO_REVOCATION_CHECK || - broken(GetLastError() == CRYPT_E_REVOKED /* Win2k */)), + ok(!ret && GetLastError() == CRYPT_E_NO_REVOCATION_CHECK, "expected CRYPT_E_NO_REVOCATION_CHECK, got %08lx\n", GetLastError()); - ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK || - broken(status.dwError == CRYPT_E_REVOKED /* Win2k */), + ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK, "expected CRYPT_E_NO_REVOCATION_CHECK, got %08lx\n", status.dwError); ok(status.dwIndex == 0, "expected index 0, got %ld\n", status.dwIndex); CertCloseStore(revPara.hCrlStore, 0); @@ -3834,12 +3697,6 @@ static void testAcquireCertPrivateKey(void) HCRYPTKEY key; WCHAR ms_def_prov_w[MAX_PATH];
- if (!pCryptAcquireCertificatePrivateKey) - { - win_skip("CryptAcquireCertificatePrivateKey() is not available\n"); - return; - } - lstrcpyW(ms_def_prov_w, MS_DEF_PROV_W);
keyProvInfo.pwszContainerName = (WCHAR *)L"WineCryptTemp"; @@ -3857,28 +3714,28 @@ static void testAcquireCertPrivateKey(void) sizeof(selfSignedCert));
/* Crash - ret = pCryptAcquireCertificatePrivateKey(NULL, 0, NULL, NULL, NULL, NULL); - ret = pCryptAcquireCertificatePrivateKey(NULL, 0, NULL, NULL, NULL, + ret = CryptAcquireCertificatePrivateKey(NULL, 0, NULL, NULL, NULL, NULL); + ret = CryptAcquireCertificatePrivateKey(NULL, 0, NULL, NULL, NULL, &callerFree); - ret = pCryptAcquireCertificatePrivateKey(NULL, 0, NULL, NULL, &keySpec, + ret = CryptAcquireCertificatePrivateKey(NULL, 0, NULL, NULL, &keySpec, NULL); - ret = pCryptAcquireCertificatePrivateKey(NULL, 0, NULL, &csp, NULL, NULL); - ret = pCryptAcquireCertificatePrivateKey(NULL, 0, NULL, &csp, &keySpec, + ret = CryptAcquireCertificatePrivateKey(NULL, 0, NULL, &csp, NULL, NULL); + ret = CryptAcquireCertificatePrivateKey(NULL, 0, NULL, &csp, &keySpec, &callerFree); - ret = pCryptAcquireCertificatePrivateKey(cert, 0, NULL, NULL, NULL, NULL); + ret = CryptAcquireCertificatePrivateKey(cert, 0, NULL, NULL, NULL, NULL); */
/* Missing private key */ - ret = pCryptAcquireCertificatePrivateKey(cert, 0, NULL, &csp, NULL, NULL); + ret = CryptAcquireCertificatePrivateKey(cert, 0, NULL, &csp, NULL, NULL); ok(!ret && (GetLastError() == CRYPT_E_NO_KEY_PROPERTY || GetLastError() == NTE_BAD_PROV_TYPE /* win10 */), "Expected CRYPT_E_NO_KEY_PROPERTY, got %08lx\n", GetLastError()); - ret = pCryptAcquireCertificatePrivateKey(cert, 0, NULL, &csp, &keySpec, + ret = CryptAcquireCertificatePrivateKey(cert, 0, NULL, &csp, &keySpec, &callerFree); ok(!ret && (GetLastError() == CRYPT_E_NO_KEY_PROPERTY || GetLastError() == NTE_BAD_PROV_TYPE /* win10 */), "Expected CRYPT_E_NO_KEY_PROPERTY, got %08lx\n", GetLastError()); CertSetCertificateContextProperty(cert, CERT_KEY_PROV_INFO_PROP_ID, 0, &keyProvInfo); - ret = pCryptAcquireCertificatePrivateKey(cert, 0, NULL, &csp, &keySpec, + ret = CryptAcquireCertificatePrivateKey(cert, 0, NULL, &csp, &keySpec, &callerFree); ok(!ret && (GetLastError() == CRYPT_E_NO_KEY_PROPERTY || GetLastError() == NTE_BAD_KEYSET /* win8 */ || @@ -3896,11 +3753,9 @@ static void testAcquireCertPrivateKey(void) CERT_KEY_CONTEXT keyContext;
/* Don't cache provider */ - ret = pCryptAcquireCertificatePrivateKey(cert, 0, NULL, &certCSP, + ret = CryptAcquireCertificatePrivateKey(cert, 0, NULL, &certCSP, &keySpec, &callerFree); - ok(ret || - broken(!ret), /* win95 */ - "CryptAcquireCertificatePrivateKey failed: %08lx\n", + ok(ret, "CryptAcquireCertificatePrivateKey failed: %08lx\n", GetLastError()); if (ret) { @@ -3908,21 +3763,17 @@ static void testAcquireCertPrivateKey(void) CryptReleaseContext(certCSP, 0); }
- ret = pCryptAcquireCertificatePrivateKey(cert, 0, NULL, &certCSP, + ret = CryptAcquireCertificatePrivateKey(cert, 0, NULL, &certCSP, NULL, NULL); - ok(ret || - broken(!ret), /* win95 */ - "CryptAcquireCertificatePrivateKey failed: %08lx\n", + ok(ret, "CryptAcquireCertificatePrivateKey failed: %08lx\n", GetLastError()); CryptReleaseContext(certCSP, 0);
/* Use the key prov info's caching (there shouldn't be any) */ - ret = pCryptAcquireCertificatePrivateKey(cert, + ret = CryptAcquireCertificatePrivateKey(cert, CRYPT_ACQUIRE_USE_PROV_INFO_FLAG, NULL, &certCSP, &keySpec, &callerFree); - ok(ret || - broken(!ret), /* win95 */ - "CryptAcquireCertificatePrivateKey failed: %08lx\n", + ok(ret, "CryptAcquireCertificatePrivateKey failed: %08lx\n", GetLastError()); if (ret) { @@ -3931,19 +3782,15 @@ static void testAcquireCertPrivateKey(void) }
/* Cache it (and check that it's cached) */ - ret = pCryptAcquireCertificatePrivateKey(cert, + ret = CryptAcquireCertificatePrivateKey(cert, CRYPT_ACQUIRE_CACHE_FLAG, NULL, &certCSP, &keySpec, &callerFree); - ok(ret || - broken(!ret), /* win95 */ - "CryptAcquireCertificatePrivateKey failed: %08lx\n", + ok(ret, "CryptAcquireCertificatePrivateKey failed: %08lx\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 || - broken(!ret), /* win95 */ - "CertGetCertificateContextProperty failed: %08lx\n", + ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError());
/* Remove the cached provider */ @@ -3955,20 +3802,16 @@ static void testAcquireCertPrivateKey(void) CertSetCertificateContextProperty(cert, CERT_KEY_PROV_INFO_PROP_ID, 0, &keyProvInfo); /* Now use the key prov info's caching */ - ret = pCryptAcquireCertificatePrivateKey(cert, + ret = CryptAcquireCertificatePrivateKey(cert, CRYPT_ACQUIRE_USE_PROV_INFO_FLAG, NULL, &certCSP, &keySpec, &callerFree); - ok(ret || - broken(!ret), /* win95 */ - "CryptAcquireCertificatePrivateKey failed: %08lx\n", + ok(ret, "CryptAcquireCertificatePrivateKey failed: %08lx\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 || - broken(!ret), /* win95 */ - "CertGetCertificateContextProperty failed: %08lx\n", + ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError()); CryptReleaseContext(certCSP, 0);
@@ -3992,7 +3835,7 @@ static void testAcquireCertPrivateKey(void) ok(size == sizeof(exportedPublicKeyBlob), "Unexpected size %ld\n", size); ok(!memcmp(buf, exportedPublicKeyBlob, size), "Unexpected value\n"); - ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, RSA_CSP_PUBLICKEYBLOB, + ret = CryptEncodeObjectEx(X509_ASN_ENCODING, RSA_CSP_PUBLICKEYBLOB, buf, CRYPT_ENCODE_ALLOC_FLAG, NULL, &encodedKey, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -4056,9 +3899,7 @@ static void testGetPublicKeyLength(void) ret, GetLastError()); SetLastError(0xdeadbeef); ret = CertGetPublicKeyLength(X509_ASN_ENCODING, &info); - ok(ret == 0 && - (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_BAD_ARG), /* win9x */ + ok(ret == 0 && GetLastError() == CRYPT_E_ASN1_EOD, "Expected length 0 and CRYPT_E_ASN1_EOD, got length %ld, %08lx\n", ret, GetLastError()); /* With a nearly-empty public key info */ @@ -4070,9 +3911,7 @@ static void testGetPublicKeyLength(void) ret, GetLastError()); SetLastError(0xdeadbeef); ret = CertGetPublicKeyLength(X509_ASN_ENCODING, &info); - ok(ret == 0 && - (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_BAD_ARG), /* win9x */ + ok(ret == 0 && GetLastError() == CRYPT_E_ASN1_EOD, "Expected length 0 and CRYPT_E_ASN1_EOD, got length %ld, %08lx\n", ret, GetLastError()); /* With a bogus key */ @@ -4085,9 +3924,7 @@ static void testGetPublicKeyLength(void) ret, GetLastError()); SetLastError(0xdeadbeef); ret = CertGetPublicKeyLength(X509_ASN_ENCODING, &info); - ok(ret == 0 && - (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH), /* win9x */ + ok(ret == 0 && GetLastError() == CRYPT_E_ASN1_BADTAG, "Expected length 0 and CRYPT_E_ASN1_BADTAGTAG, got length %ld, %08lx\n", ret, GetLastError()); /* With a believable RSA key but a bogus OID */ @@ -4107,9 +3944,7 @@ static void testGetPublicKeyLength(void) info.Algorithm.pszObjId = oid_rsa_dh; SetLastError(0xdeadbeef); ret = CertGetPublicKeyLength(X509_ASN_ENCODING, &info); - ok(ret == 0 && - (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == E_INVALIDARG), /* win9x */ + ok(ret == 0 && GetLastError() == CRYPT_E_ASN1_BADTAG, "Expected length 0 and CRYPT_E_ASN1_BADTAG, got length %ld, %08lx\n", ret, GetLastError()); /* With the RSA OID */ @@ -4278,12 +4113,7 @@ static void test_VerifySignature(void) ok(!status, "got %#lx\n", status);
status = BCryptCreateHash(alg, &bhash, NULL, 0, NULL, 0, 0); - ok(!status || broken(status == STATUS_INVALID_PARAMETER) /* Vista */, "got %#lx\n", status); - if (status == STATUS_INVALID_PARAMETER) - { - win_skip("broken BCryptCreateHash\n"); - goto done; - } + ok(!status, "got %#lx\n", status);
status = BCryptHashData(bhash, info->ToBeSigned.pbData, info->ToBeSigned.cbData, 0); ok(!status, "got %#lx\n", status); @@ -4306,18 +4136,14 @@ static void test_VerifySignature(void)
HeapFree(GetProcessHeap(), 0, sig_value); BCryptDestroyHash(bhash); -done: BCryptCloseAlgorithmProvider(alg, 0); BCryptDestroyKey(bkey); - LocalFree(info); CertFreeCertificateContext(cert); }
START_TEST(cert) { - init_function_pointers(); - testAddCert(); testCertProperties(); testCreateCert(); diff --git a/dlls/crypt32/tests/chain.c b/dlls/crypt32/tests/chain.c index bcf51c6c811..9ed1b28bf70 100644 --- a/dlls/crypt32/tests/chain.c +++ b/dlls/crypt32/tests/chain.c @@ -54,12 +54,6 @@ static const BYTE selfSignedCert[] = { 0x0a, 0x8c, 0xb4, 0x5c, 0x34, 0x78, 0xe0, 0x3c, 0x9c, 0xe9, 0xf3, 0x30, 0x9f, 0xa8, 0x76, 0x57, 0x92, 0x36 };
-static BOOL (WINAPI *pCertCreateCertificateChainEngine)(PCERT_CHAIN_ENGINE_CONFIG,HCERTCHAINENGINE*); -static BOOL (WINAPI *pCertGetCertificateChain)(HCERTCHAINENGINE,PCCERT_CONTEXT,LPFILETIME,HCERTSTORE,PCERT_CHAIN_PARA,DWORD,LPVOID,PCCERT_CHAIN_CONTEXT*); -static VOID (WINAPI *pCertFreeCertificateChain)(PCCERT_CHAIN_CONTEXT); -static VOID (WINAPI *pCertFreeCertificateChainEngine)(HCERTCHAINENGINE); -static BOOL (WINAPI *pCertVerifyCertificateChainPolicy)(LPCSTR,PCCERT_CHAIN_CONTEXT,PCERT_CHAIN_POLICY_PARA,PCERT_CHAIN_POLICY_STATUS); - #define IS_INTOID(x) (((ULONG_PTR)(x) >> 16) == 0)
typedef struct _CERT_CHAIN_ENGINE_CONFIG_NO_EXCLUSIVE_ROOT @@ -84,47 +78,41 @@ static void testCreateCertChainEngine(void) HCERTCHAINENGINE engine; HCERTSTORE store;
- if (!pCertCreateCertificateChainEngine || !pCertFreeCertificateChainEngine) - { - win_skip("Cert*CertificateChainEngine() functions are not available\n"); - return; - } - /* Crash - ret = pCertCreateCertificateChainEngine(NULL, NULL); - ret = pCertCreateCertificateChainEngine(NULL, &engine); - ret = pCertCreateCertificateChainEngine(pConfig, NULL); + ret = CertCreateCertificateChainEngine(NULL, NULL); + ret = CertCreateCertificateChainEngine(NULL, &engine); + ret = CertCreateCertificateChainEngine(pConfig, NULL); */ - ret = pCertCreateCertificateChainEngine(pConfig, &engine); + ret = CertCreateCertificateChainEngine(pConfig, &engine); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* Crashes config.cbSize = sizeof(config); - ret = pCertCreateCertificateChainEngine(pConfig, NULL); + ret = CertCreateCertificateChainEngine(pConfig, NULL); */ config.cbSize = sizeof(config); - ret = pCertCreateCertificateChainEngine(pConfig, &engine); + ret = CertCreateCertificateChainEngine(pConfig, &engine); ok(ret, "CertCreateCertificateChainEngine failed: %08lx\n", GetLastError()); - pCertFreeCertificateChainEngine(engine); + CertFreeCertificateChainEngine(engine); config.dwFlags = 0xff000000; - ret = pCertCreateCertificateChainEngine(pConfig, &engine); + ret = CertCreateCertificateChainEngine(pConfig, &engine); ok(ret, "CertCreateCertificateChainEngine failed: %08lx\n", GetLastError()); - pCertFreeCertificateChainEngine(engine); + CertFreeCertificateChainEngine(engine);
/* Creating a cert with no root certs at all is allowed.. */ store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); config.hRestrictedRoot = store; - ret = pCertCreateCertificateChainEngine(pConfig, &engine); + ret = CertCreateCertificateChainEngine(pConfig, &engine); ok(ret, "CertCreateCertificateChainEngine failed: %08lx\n", GetLastError()); - pCertFreeCertificateChainEngine(engine); + CertFreeCertificateChainEngine(engine);
/* but creating one with a restricted root with a cert that isn't a member * of the Root store isn't allowed. */ CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, selfSignedCert, sizeof(selfSignedCert), CERT_STORE_ADD_ALWAYS, NULL); - ret = pCertCreateCertificateChainEngine(pConfig, &engine); + ret = CertCreateCertificateChainEngine(pConfig, &engine); /* ERROR_FILE_NOT_FOUND used in Windows 10 */ ok(!ret && ((GetLastError() == CRYPT_E_NOT_FOUND) || (GetLastError() == ERROR_FILE_NOT_FOUND)), @@ -3399,7 +3387,7 @@ static PCCERT_CHAIN_CONTEXT getChain(HCERTCHAINENGINE engine, ok(SystemTimeToFileTime(checkTime, &fileTime), "SystemTimeToFileTime failed for day %d, month %d, year %d\n", checkTime->wDay, checkTime->wMonth, checkTime->wYear); - ret = pCertGetCertificateChain(engine, endCert, &fileTime, + ret = CertGetCertificateChain(engine, endCert, &fileTime, includeStore ? store : NULL, &chainPara, flags, NULL, &chain); todo_wine_if (todo & TODO_CHAIN) ok(ret, "Chain %ld: CertGetCertificateChain failed: %08lx\n", @@ -4356,17 +4344,17 @@ static void testGetCertChain(void) if (0) { /* Crash on Vista */ - ret = pCertGetCertificateChain(NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL); + ret = CertGetCertificateChain(NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError()); } - ret = pCertGetCertificateChain(NULL, NULL, NULL, NULL, NULL, 0, NULL, + ret = CertGetCertificateChain(NULL, NULL, NULL, NULL, NULL, 0, NULL, &chain); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* Crash - ret = pCertGetCertificateChain(NULL, NULL, NULL, NULL, ¶, 0, NULL, NULL); - ret = pCertGetCertificateChain(NULL, NULL, NULL, NULL, ¶, 0, NULL, + ret = CertGetCertificateChain(NULL, NULL, NULL, NULL, ¶, 0, NULL, NULL); + ret = CertGetCertificateChain(NULL, NULL, NULL, NULL, ¶, 0, NULL, &chain); */ cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, @@ -4374,17 +4362,17 @@ static void testGetCertChain(void) if (0) { /* Crash on Vista */ - ret = pCertGetCertificateChain(NULL, cert, NULL, NULL, NULL, 0, NULL, NULL); + ret = CertGetCertificateChain(NULL, cert, NULL, NULL, NULL, 0, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError()); } /* Crash - ret = pCertGetCertificateChain(NULL, cert, NULL, NULL, ¶, 0, NULL, NULL); + ret = CertGetCertificateChain(NULL, cert, NULL, NULL, ¶, 0, NULL, NULL); */
/* Tests with an invalid cert (one whose signature is bad) */ SetLastError(0xdeadbeef); - ret = pCertGetCertificateChain(NULL, cert, NULL, NULL, ¶, 0, NULL, + ret = CertGetCertificateChain(NULL, cert, NULL, NULL, ¶, 0, NULL, &chain); ok(!ret, "Expected failure\n"); ok(GetLastError() == ERROR_INVALID_DATA || @@ -4392,7 +4380,7 @@ static void testGetCertChain(void) "Expected ERROR_INVALID_DATA or CRYPT_E_ASN1_BADTAG, got %ld\n", GetLastError()); para.cbSize = sizeof(para); SetLastError(0xdeadbeef); - ret = pCertGetCertificateChain(NULL, cert, NULL, NULL, ¶, 0, NULL, + ret = CertGetCertificateChain(NULL, cert, NULL, NULL, ¶, 0, NULL, &chain); ok(!ret, "Expected failure\n"); ok(GetLastError() == ERROR_INVALID_DATA || @@ -4401,7 +4389,7 @@ static void testGetCertChain(void)
para.cbSize = 0; SetLastError(0xdeadbeef); - ret = pCertGetCertificateChain(NULL, cert, NULL, NULL, ¶, 0, NULL, + ret = CertGetCertificateChain(NULL, cert, NULL, NULL, ¶, 0, NULL, &chain); ok(!ret, "Expected failure\n"); ok(GetLastError() == ERROR_INVALID_DATA || @@ -4426,39 +4414,39 @@ static void testGetCertChain(void) para.RequestedUsage.dwType = USAGE_MATCH_TYPE_AND; para.RequestedUsage.Usage.rgpszUsageIdentifier = oids; para.RequestedUsage.Usage.cUsageIdentifier = 1; - ret = pCertGetCertificateChain(NULL, cert, &fileTime, store, ¶, + ret = CertGetCertificateChain(NULL, cert, &fileTime, store, ¶, 0, NULL, &chain); ok(ret, "CertGetCertificateChain failed: %08lx\n", GetLastError()); if (ret) { ok(chain->TrustStatus.dwErrorStatus & CERT_TRUST_IS_NOT_VALID_FOR_USAGE, "expected CERT_TRUST_IS_NOT_VALID_FOR_USAGE\n"); - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain); } oids[0] = oid_server_auth; - ret = pCertGetCertificateChain(NULL, cert, &fileTime, store, ¶, + ret = CertGetCertificateChain(NULL, cert, &fileTime, store, ¶, 0, NULL, &chain); ok(ret, "CertGetCertificateChain failed: %08lx\n", GetLastError()); if (ret) { ok(!(chain->TrustStatus.dwErrorStatus & CERT_TRUST_IS_NOT_VALID_FOR_USAGE), "didn't expect CERT_TRUST_IS_NOT_VALID_FOR_USAGE, got %lx\n", chain->TrustStatus.dwErrorStatus); - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain); } oids[1] = one_two_three; para.RequestedUsage.Usage.cUsageIdentifier = 2; para.RequestedUsage.dwType = USAGE_MATCH_TYPE_AND; - ret = pCertGetCertificateChain(NULL, cert, &fileTime, store, ¶, + ret = CertGetCertificateChain(NULL, cert, &fileTime, store, ¶, 0, NULL, &chain); ok(ret, "CertGetCertificateChain failed: %08lx\n", GetLastError()); if (ret) { ok(chain->TrustStatus.dwErrorStatus & CERT_TRUST_IS_NOT_VALID_FOR_USAGE, "expected CERT_TRUST_IS_NOT_VALID_FOR_USAGE\n"); - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain); } para.RequestedUsage.dwType = USAGE_MATCH_TYPE_OR; - ret = pCertGetCertificateChain(NULL, cert, &fileTime, store, ¶, + ret = CertGetCertificateChain(NULL, cert, &fileTime, store, ¶, 0, NULL, &chain); ok(ret, "CertGetCertificateChain failed: %08lx\n", GetLastError()); if (ret) @@ -4466,7 +4454,7 @@ static void testGetCertChain(void) ok(!(chain->TrustStatus.dwErrorStatus & CERT_TRUST_IS_NOT_VALID_FOR_USAGE), "didn't expect CERT_TRUST_IS_NOT_VALID_FOR_USAGE\n"); - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain); } CertCloseStore(store, 0); CertFreeCertificateContext(cert); @@ -4479,7 +4467,7 @@ static void testGetCertChain(void) { checkChainStatus(chain, &chainCheck[i].status, chainCheck[i].todo, "chainCheck", i); - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain); } } chain = getChain(NULL, &opensslChainCheck.certs, 0, TRUE, &oct2007, @@ -4502,7 +4490,7 @@ static void testGetCertChain(void) checkChainStatus(chain, &incompleteOpensslChainCheck.status, incompleteOpensslChainCheck.todo, "incompleteOpensslChainCheck", 0); - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain); } for (i = 0; i < ARRAY_SIZE(chainCheckNoStore); i++) { @@ -4512,7 +4500,7 @@ static void testGetCertChain(void) { checkChainStatus(chain, &chainCheckNoStore[i].status, chainCheckNoStore[i].todo, "chainCheckNoStore", i); - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain); } } chain = getChain(NULL, &chainCheckEmbeddedNull.certs, 0, TRUE, &oct2007, @@ -4535,7 +4523,7 @@ static void testGetCertChain(void) checkChainStatus(chain, &chainCheckEmbeddedNullBroken.status, chainCheckEmbeddedNullBroken.todo, "chainCheckEmbeddedNullBroken", 0); - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain); }
store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); @@ -4556,13 +4544,6 @@ static void testGetCertChain(void) ret = CertGetCertificateChain(NULL, cert, &fileTime, store, ¶, 0, NULL, &chain); ok(ret, "CertGetCertificateChain failed: %lu\n", GetLastError());
- if(chain->TrustStatus.dwErrorStatus == CERT_TRUST_IS_PARTIAL_CHAIN) { /* win2k */ - win_skip("winehq cert reported as partial chain, skipping its tests\n"); - pCertFreeCertificateChain(chain); - CertCloseStore(store, 0); - return; - } - ok(chain->TrustStatus.dwErrorStatus == CERT_TRUST_HAS_EXACT_MATCH_ISSUER, "chain->TrustStatus.dwErrorStatus = %lx\n", chain->TrustStatus.dwErrorStatus); todo_wine @@ -4610,7 +4591,7 @@ static void testGetCertChain(void) test_name_blob(&simple_chain->rgpElement[2]->pCertContext->pCertInfo->Subject, "US, New Jersey, Jersey City, The USERTRUST Network, USERTrust RSA Certification Authority");
- pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain);
/* Test revocation flags */ ret = CertGetCertificateChain(NULL, cert, &fileTime, store, ¶, CERT_CHAIN_REVOCATION_CHECK_END_CERT, NULL, @@ -4618,26 +4599,25 @@ static void testGetCertChain(void) ok(ret, "CertGetCertificateChain failed: %lu\n", GetLastError()); ok(chain->TrustStatus.dwErrorStatus == CERT_TRUST_HAS_EXACT_MATCH_ISSUER, "chain->TrustStatus.dwErrorStatus = %lx\n", chain->TrustStatus.dwErrorStatus); - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain);
ret = CertGetCertificateChain(NULL, cert, &fileTime, store, ¶, CERT_CHAIN_REVOCATION_CHECK_CHAIN, NULL, &chain); ok(ret, "CertGetCertificateChain failed: %lu\n", GetLastError()); - ok(chain->TrustStatus.dwErrorStatus == CERT_TRUST_HAS_EXACT_MATCH_ISSUER || - broken(chain->TrustStatus.dwErrorStatus == (CERT_TRUST_IS_NOT_TIME_VALID|CERT_TRUST_REVOCATION_STATUS_UNKNOWN)), /* XP */ + ok(chain->TrustStatus.dwErrorStatus == CERT_TRUST_HAS_EXACT_MATCH_ISSUER, "chain->TrustStatus.dwErrorStatus = %lx\n", chain->TrustStatus.dwErrorStatus); - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain);
ret = CertGetCertificateChain(NULL, cert, &fileTime, store, ¶, CERT_CHAIN_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT, NULL, &chain); ok(ret, "CertGetCertificateChain failed: %lu\n", GetLastError()); ok(chain->TrustStatus.dwErrorStatus == CERT_TRUST_HAS_EXACT_MATCH_ISSUER, "chain->TrustStatus.dwErrorStatus = %lx\n", chain->TrustStatus.dwErrorStatus); - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain);
/* Test HCCE_LOCAL_MACHINE */ ret = CertGetCertificateChain(HCCE_LOCAL_MACHINE, cert, &fileTime, store, ¶, 0, NULL, &chain); ok(ret, "CertGetCertificateChain failed: %lu\n", GetLastError()); - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain);
CertFreeCertificateContext(cert); CertCloseStore(store, 0); @@ -4671,10 +4651,10 @@ static void test_CERT_CHAIN_PARA_cbSize(void) SystemTimeToFileTime(&oct2007, &fileTime);
para.cbSize = i; - ret = pCertGetCertificateChain(NULL, cert, &fileTime, + ret = CertGetCertificateChain(NULL, cert, &fileTime, NULL, ¶, 0, NULL, &chain); ok(ret, "CertGetCertificateChain failed %lu\n", GetLastError()); - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain); }
CertFreeCertificateContext(cert); @@ -4996,7 +4976,7 @@ static void checkChainPolicyStatus(LPCSTR policy, HCERTCHAINENGINE engine, if (chain) { CERT_CHAIN_POLICY_STATUS policyStatus = { 0 }; - BOOL ret = pCertVerifyCertificateChainPolicy(policy, chain, para, + BOOL ret = CertVerifyCertificateChainPolicy(policy, chain, para, &policyStatus);
if (check->todo & TODO_POLICY) @@ -5012,7 +4992,7 @@ static void checkChainPolicyStatus(LPCSTR policy, HCERTCHAINENGINE engine, skip("%s[%ld]: missing policy %s, skipping test\n", testName, testIndex, IS_INTOID(policy) ? num_to_str(LOWORD(policy)) : policy); - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain); return; } ok(ret, "%s[%ld](%s): CertVerifyCertificateChainPolicy failed: %08lx\n", @@ -5037,7 +5017,7 @@ static void checkChainPolicyStatus(LPCSTR policy, HCERTCHAINENGINE engine, testName, testIndex, IS_INTOID(policy) ? num_to_str(LOWORD(policy)) : policy, policyStatus.dwError, check->status.dwError); - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain); return; } todo_wine_if (check->todo & TODO_CHAINS) @@ -5057,7 +5037,7 @@ static void checkChainPolicyStatus(LPCSTR policy, HCERTCHAINENGINE engine, IS_INTOID(policy) ? num_to_str(LOWORD(policy)) : policy, check->status.lElementIndex, policyStatus.lElementIndex); } - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain); } }
@@ -5262,7 +5242,7 @@ static void check_ssl_policy(void) CertAddEncodedCertificateToStore(testRoot, X509_ASN_ENCODING, chain0_0, sizeof(chain0_0), CERT_STORE_ADD_ALWAYS, NULL); engineConfig.hExclusiveRoot = testRoot; - if (!pCertCreateCertificateChainEngine(&engineConfig, &engine)) + if (!CertCreateCertificateChainEngine(&engineConfig, &engine)) { skip("Couldn't create chain engine\n"); return; @@ -5283,7 +5263,7 @@ static void check_ssl_policy(void) sslPolicyPara.fdwChecks |= SECURITY_FLAG_IGNORE_CERT_CN_INVALID; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, engine, winehqPolicyCheckWithMatchingName, &oct2007, &policyPara); - pCertFreeCertificateChainEngine(engine); + CertFreeCertificateChainEngine(engine); CertCloseStore(testRoot, 0); /* Test chain30, which has an invalid critical extension in an intermediate * cert, against the SSL policy. @@ -5328,40 +5308,34 @@ static void testVerifyCertChainPolicy(void) CERT_CHAIN_POLICY_STATUS policyStatus = { 0 }; CERT_CHAIN_POLICY_PARA policyPara = { 0 };
- if (!pCertVerifyCertificateChainPolicy) - { - win_skip("CertVerifyCertificateChainPolicy() is not available\n"); - return; - } - /* Crash - ret = pCertVerifyCertificateChainPolicy(NULL, NULL, NULL, NULL); - ret = pCertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, NULL, NULL, + ret = CertVerifyCertificateChainPolicy(NULL, NULL, NULL, NULL); + ret = CertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, NULL, NULL, NULL); - ret = pCertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, NULL, + ret = CertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, NULL, &chainPara, NULL); */ SetLastError(0xdeadbeef); - ret = pCertVerifyCertificateChainPolicy(NULL, NULL, NULL, &policyStatus); + ret = CertVerifyCertificateChainPolicy(NULL, NULL, NULL, &policyStatus); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); /* Crashes - ret = pCertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, NULL, NULL, + ret = CertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, NULL, NULL, &policyStatus); */ cert = CertCreateCertificateContext(X509_ASN_ENCODING, selfSignedCert, sizeof(selfSignedCert)); - pCertGetCertificateChain(NULL, cert, NULL, NULL, &chainPara, 0, NULL, + CertGetCertificateChain(NULL, cert, NULL, NULL, &chainPara, 0, NULL, &chain); /* Crash - ret = pCertVerifyCertificateChainPolicy(NULL, chain, NULL, NULL); - ret = pCertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, chain, NULL, + ret = CertVerifyCertificateChainPolicy(NULL, chain, NULL, NULL); + ret = CertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, chain, NULL, NULL); - ret = pCertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, chain, + ret = CertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, chain, &chainPara, NULL); */ /* Size of policy status is apparently ignored, as is pChainPolicyPara */ - ret = pCertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, chain, NULL, + ret = CertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, chain, NULL, &policyStatus); ok(ret, "CertVerifyCertificateChainPolicy failed: %08lx\n", GetLastError()); ok(policyStatus.dwError == CERT_E_UNTRUSTEDROOT || @@ -5370,7 +5344,7 @@ static void testVerifyCertChainPolicy(void) ok(policyStatus.lChainIndex == 0 && policyStatus.lElementIndex == 0, "Expected both indexes 0, got %ld, %ld\n", policyStatus.lChainIndex, policyStatus.lElementIndex); - ret = pCertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, chain, + ret = CertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, chain, &policyPara, &policyStatus); ok(ret, "CertVerifyCertificateChainPolicy failed: %08lx\n", GetLastError()); ok(policyStatus.dwError == CERT_E_UNTRUSTEDROOT || @@ -5379,7 +5353,7 @@ static void testVerifyCertChainPolicy(void) ok(policyStatus.lChainIndex == 0 && policyStatus.lElementIndex == 0, "Expected both indexes 0, got %ld, %ld\n", policyStatus.lChainIndex, policyStatus.lElementIndex); - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain); CertFreeCertificateContext(cert);
check_base_policy(); @@ -5392,22 +5366,8 @@ static void testVerifyCertChainPolicy(void)
START_TEST(chain) { - HMODULE hCrypt32 = GetModuleHandleA("crypt32.dll"); - pCertCreateCertificateChainEngine = (void*)GetProcAddress(hCrypt32, "CertCreateCertificateChainEngine"); - pCertGetCertificateChain = (void*)GetProcAddress(hCrypt32, "CertGetCertificateChain"); - pCertFreeCertificateChain = (void*)GetProcAddress(hCrypt32, "CertFreeCertificateChain"); - pCertFreeCertificateChainEngine = (void*)GetProcAddress(hCrypt32, "CertFreeCertificateChainEngine"); - pCertVerifyCertificateChainPolicy = (void*)GetProcAddress(hCrypt32, "CertVerifyCertificateChainPolicy"); - testCreateCertChainEngine(); - if (!pCertGetCertificateChain || !pCertFreeCertificateChain) - { - win_skip("Cert*CertificateChain functions not available\n"); - } - else - { - testVerifyCertChainPolicy(); - testGetCertChain(); - test_CERT_CHAIN_PARA_cbSize(); - } + testVerifyCertChainPolicy(); + testGetCertChain(); + test_CERT_CHAIN_PARA_cbSize(); } diff --git a/dlls/crypt32/tests/crl.c b/dlls/crypt32/tests/crl.c index 3797fc4cfbf..06cfc52fece 100644 --- a/dlls/crypt32/tests/crl.c +++ b/dlls/crypt32/tests/crl.c @@ -77,18 +77,6 @@ static const BYTE signedCRL[] = { 0x30, 0x45, 0x30, 0x2c, 0x30, 0x02, 0x06, 0x30, 0x5a, 0x30, 0x02, 0x06, 0x00, 0x03, 0x11, 0x00, 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 };
-static BOOL (WINAPI *pCertFindCertificateInCRL)(PCCERT_CONTEXT,PCCRL_CONTEXT,DWORD,void*,PCRL_ENTRY*); -static PCCRL_CONTEXT (WINAPI *pCertFindCRLInStore)(HCERTSTORE,DWORD,DWORD,DWORD,const void*,PCCRL_CONTEXT); -static BOOL (WINAPI *pCertIsValidCRLForCertificate)(PCCERT_CONTEXT, PCCRL_CONTEXT, DWORD, void*); - -static void init_function_pointers(void) -{ - HMODULE hdll = GetModuleHandleA("crypt32.dll"); - pCertFindCertificateInCRL = (void*)GetProcAddress(hdll, "CertFindCertificateInCRL"); - pCertFindCRLInStore = (void*)GetProcAddress(hdll, "CertFindCRLInStore"); - pCertIsValidCRLForCertificate = (void*)GetProcAddress(hdll, "CertIsValidCRLForCertificate"); -} - static void testCreateCRL(void) { PCCRL_CONTEXT context; @@ -99,8 +87,8 @@ static void testCreateCRL(void) "Expected E_INVALIDARG, got %08lx\n", GetLastError()); context = CertCreateCRLContext(X509_ASN_ENCODING, NULL, 0); GLE = GetLastError(); - ok(!context && (GLE == CRYPT_E_ASN1_EOD || GLE == OSS_MORE_INPUT), - "Expected CRYPT_E_ASN1_EOD or OSS_MORE_INPUT, got %08lx\n", GLE); + ok(!context && GLE == CRYPT_E_ASN1_EOD, + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GLE); context = CertCreateCRLContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert)); ok(!context, "Expected failure\n"); context = CertCreateCRLContext(X509_ASN_ENCODING, signedCRL, @@ -177,29 +165,23 @@ static void testAddCRL(void) /* No CRL */ ret = CertAddEncodedCRLToStore(0, X509_ASN_ENCODING, NULL, 0, 0, NULL); GLE = GetLastError(); - ok(!ret && (GLE == CRYPT_E_ASN1_EOD || GLE == OSS_MORE_INPUT), - "Expected CRYPT_E_ASN1_EOD or OSS_MORE_INPUT, got %08lx\n", GLE); + ok(!ret && GLE == CRYPT_E_ASN1_EOD, + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GLE); ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, NULL, 0, 0, NULL); GLE = GetLastError(); - ok(!ret && (GLE == CRYPT_E_ASN1_EOD || GLE == OSS_MORE_INPUT), - "Expected CRYPT_E_ASN1_EOD or OSS_MORE_INPUT, got %08lx\n", GLE); + ok(!ret && GLE == CRYPT_E_ASN1_EOD, + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GLE);
- /* Weird--bad add disposition leads to an access violation in Windows. - * Both tests crash on some win9x boxes. - */ - if (0) - { - ret = CertAddEncodedCRLToStore(0, X509_ASN_ENCODING, signedCRL, - sizeof(signedCRL), 0, NULL); - ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION || - GetLastError() == E_INVALIDARG /* Vista */), - "Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08lx\n", GetLastError()); - ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, signedCRL, - sizeof(signedCRL), 0, NULL); - ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION || - GetLastError() == E_INVALIDARG /* Vista */), + ret = CertAddEncodedCRLToStore(0, X509_ASN_ENCODING, signedCRL, + sizeof(signedCRL), 0, NULL); + ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION || + GetLastError() == E_INVALIDARG /* Vista */), "Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08lx\n", GetLastError()); - } + ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, signedCRL, + sizeof(signedCRL), 0, NULL); + ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION || + GetLastError() == E_INVALIDARG /* Vista */), + "Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08lx\n", GetLastError());
/* Weird--can add a CRL to the NULL store (does this have special meaning?) */ @@ -433,12 +415,6 @@ static void testFindCRL(void) DWORD count, revoked_count; BOOL ret;
- if (!pCertFindCRLInStore || !pCertFindCertificateInCRL) - { - win_skip("CertFindCRLInStore or CertFindCertificateInCRL not available\n"); - return; - } - store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); @@ -449,27 +425,27 @@ static void testFindCRL(void) ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
/* Crashes - context = pCertFindCRLInStore(NULL, 0, 0, 0, NULL, NULL); + context = CertFindCRLInStore(NULL, 0, 0, 0, NULL, NULL); */
/* Find any context */ - context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ANY, NULL, NULL); + context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ANY, NULL, NULL); ok(context != NULL, "Expected a context\n"); if (context) CertFreeCRLContext(context); /* Bogus flags are ignored */ - context = pCertFindCRLInStore(store, 0, 1234, CRL_FIND_ANY, NULL, NULL); + context = CertFindCRLInStore(store, 0, 1234, CRL_FIND_ANY, NULL, NULL); ok(context != NULL, "Expected a context\n"); if (context) CertFreeCRLContext(context); /* CRL encoding type is ignored too */ - context = pCertFindCRLInStore(store, 1234, 0, CRL_FIND_ANY, NULL, NULL); + context = CertFindCRLInStore(store, 1234, 0, CRL_FIND_ANY, NULL, NULL); ok(context != NULL, "Expected a context\n"); if (context) CertFreeCRLContext(context);
/* This appears to match any cert */ - context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, NULL, NULL); + context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, NULL, NULL); ok(context != NULL, "Expected a context\n"); if (context) CertFreeCRLContext(context); @@ -479,7 +455,7 @@ static void testFindCRL(void) sizeof(bigCert2)); ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n", GetLastError()); - context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, cert, NULL); + context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, cert, NULL); ok(context == NULL, "Expected no matching context\n"); CertFreeCertificateContext(cert);
@@ -488,17 +464,17 @@ static void testFindCRL(void) sizeof(bigCert)); ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n", GetLastError()); - context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, cert, NULL); + context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, cert, NULL); ok(context != NULL, "Expected a context\n"); if (context) CertFreeCRLContext(context);
/* Try various find flags */ - context = pCertFindCRLInStore(store, 0, CRL_FIND_ISSUED_BY_SIGNATURE_FLAG, + context = CertFindCRLInStore(store, 0, CRL_FIND_ISSUED_BY_SIGNATURE_FLAG, CRL_FIND_ISSUED_BY, cert, NULL); - ok(!context || broken(context != NULL /* Win9x */), "unexpected context\n"); + ok(!context, "unexpected context\n"); /* The CRL doesn't have an AKI extension, so it matches any cert */ - context = pCertFindCRLInStore(store, 0, CRL_FIND_ISSUED_BY_AKI_FLAG, + context = CertFindCRLInStore(store, 0, CRL_FIND_ISSUED_BY_AKI_FLAG, CRL_FIND_ISSUED_BY, cert, NULL); ok(context != NULL, "Expected a context\n"); if (context) @@ -507,18 +483,17 @@ static void testFindCRL(void) if (0) { /* Crash or return NULL/STATUS_ACCESS_VIOLATION */ - pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, NULL, + CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, NULL, NULL); - pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, + CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, &issuedForPara, NULL); } /* Test whether the cert matches the CRL in the store */ issuedForPara.pSubjectCert = cert; issuedForPara.pIssuerCert = cert; - context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, + context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, &issuedForPara, NULL); - ok(context != NULL || broken(!context /* Win9x, NT4 */), - "Expected a context\n"); + ok(context != NULL, "Expected a context\n"); if (context) { ok(context->cbCrlEncoded == sizeof(signedCRL), @@ -544,14 +519,14 @@ static void testFindCRL(void) context = NULL; count = revoked_count = 0; do { - context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, + context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, &issuedForPara, context); if (context) { PCRL_ENTRY entry;
count++; - if (pCertFindCertificateInCRL(cert, context, 0, NULL, &entry) && + if (CertFindCertificateInCRL(cert, context, 0, NULL, &entry) && entry) revoked_count++; } @@ -560,13 +535,11 @@ static void testFindCRL(void) * match cert's issuer, but verisignCRL does not, so the expected count * is 0. */ - ok(count == 3 || broken(count == 0 /* NT4, Win9x */), - "expected 3 matching CRLs, got %ld\n", count); + ok(count == 3, "expected 3 matching CRLs, got %ld\n", count); /* Only v1CRLWithIssuerAndEntry and v2CRLWithIssuingDistPoint contain * entries, so the count of CRL entries that match cert is 2. */ - ok(revoked_count == 2 || broken(revoked_count == 0 /* NT4, Win9x */), - "expected 2 matching CRL entries, got %ld\n", revoked_count); + ok(revoked_count == 2, "expected 2 matching CRL entries, got %ld\n", revoked_count);
CertFreeCertificateContext(cert);
@@ -580,14 +553,14 @@ static void testFindCRL(void) context = NULL; count = revoked_count = 0; do { - context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, + context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, &issuedForPara, context); if (context) { PCRL_ENTRY entry;
count++; - if (pCertFindCertificateInCRL(cert, context, 0, NULL, &entry) && + if (CertFindCertificateInCRL(cert, context, 0, NULL, &entry) && entry) revoked_count++; } @@ -609,20 +582,19 @@ static void testFindCRL(void) context = NULL; count = revoked_count = 0; do { - context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, + context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, &issuedForPara, context); if (context) { PCRL_ENTRY entry;
count++; - if (pCertFindCertificateInCRL(cert, context, 0, NULL, &entry) && + if (CertFindCertificateInCRL(cert, context, 0, NULL, &entry) && entry) revoked_count++; } } while (context); - ok(count == 1 || broken(count == 0 /* Win9x, NT4 */), - "expected 1 matching CRLs, got %ld\n", count); + ok(count == 1, "expected 1 matching CRLs, got %ld\n", count); ok(revoked_count == 0, "expected 0 matching CRL entries, got %ld\n", revoked_count); CertFreeCertificateContext(cert); @@ -649,34 +621,32 @@ static void testFindCRL(void) context = NULL; count = revoked_count = 0; do { - context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, + context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, &issuedForPara, context); if (context) { PCRL_ENTRY entry;
count++; - if (pCertFindCertificateInCRL(endCert, context, 0, NULL, &entry) && + if (CertFindCertificateInCRL(endCert, context, 0, NULL, &entry) && entry) revoked_count++; } } while (context); - ok(count == 1 || broken(count == 0 /* Win9x, NT4 */), - "expected 1 matching CRLs, got %ld\n", count); - ok(revoked_count == 1 || broken(revoked_count == 0 /* Win9x, NT4 */), - "expected 1 matching CRL entries, got %ld\n", revoked_count); + ok(count == 1, "expected 1 matching CRLs, got %ld\n", count); + ok(revoked_count == 1, "expected 1 matching CRL entries, got %ld\n", revoked_count);
/* Test CRL_FIND_ISSUED_BY flags */ count = revoked_count = 0; do { - context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, + context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, endCert, context); if (context) { PCRL_ENTRY entry;
count++; - if (pCertFindCertificateInCRL(endCert, context, 0, NULL, &entry) && + if (CertFindCertificateInCRL(endCert, context, 0, NULL, &entry) && entry) revoked_count++; } @@ -686,14 +656,14 @@ static void testFindCRL(void) revoked_count); count = revoked_count = 0; do { - context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, + context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, rootCert, context); if (context) { PCRL_ENTRY entry;
count++; - if (pCertFindCertificateInCRL(endCert, context, 0, NULL, &entry) && + if (CertFindCertificateInCRL(endCert, context, 0, NULL, &entry) && entry) revoked_count++; } @@ -703,14 +673,14 @@ static void testFindCRL(void) revoked_count); count = revoked_count = 0; do { - context = pCertFindCRLInStore(store, 0, CRL_FIND_ISSUED_BY_AKI_FLAG, + context = CertFindCRLInStore(store, 0, CRL_FIND_ISSUED_BY_AKI_FLAG, CRL_FIND_ISSUED_BY, endCert, context); if (context) { PCRL_ENTRY entry;
count++; - if (pCertFindCertificateInCRL(endCert, context, 0, NULL, &entry) && + if (CertFindCertificateInCRL(endCert, context, 0, NULL, &entry) && entry) revoked_count++; } @@ -720,25 +690,24 @@ static void testFindCRL(void) revoked_count); count = revoked_count = 0; do { - context = pCertFindCRLInStore(store, 0, CRL_FIND_ISSUED_BY_AKI_FLAG, + context = CertFindCRLInStore(store, 0, CRL_FIND_ISSUED_BY_AKI_FLAG, CRL_FIND_ISSUED_BY, rootCert, context); if (context) { PCRL_ENTRY entry;
count++; - if (pCertFindCertificateInCRL(rootCert, context, 0, NULL, &entry) && + if (CertFindCertificateInCRL(rootCert, context, 0, NULL, &entry) && entry) revoked_count++; } } while (context); - ok(count == 0 || broken(count == 1 /* Win9x */), - "expected 0 matching CRLs, got %ld\n", count); + ok(count == 0, "expected 0 matching CRLs, got %ld\n", count); ok(revoked_count == 0, "expected 0 matching CRL entries, got %ld\n", revoked_count); count = revoked_count = 0; do { - context = pCertFindCRLInStore(store, 0, + context = CertFindCRLInStore(store, 0, CRL_FIND_ISSUED_BY_SIGNATURE_FLAG, CRL_FIND_ISSUED_BY, endCert, context); if (context) @@ -746,7 +715,7 @@ static void testFindCRL(void) PCRL_ENTRY entry;
count++; - if (pCertFindCertificateInCRL(endCert, context, 0, NULL, &entry) && + if (CertFindCertificateInCRL(endCert, context, 0, NULL, &entry) && entry) revoked_count++; } @@ -756,7 +725,7 @@ static void testFindCRL(void) revoked_count); count = revoked_count = 0; do { - context = pCertFindCRLInStore(store, 0, + context = CertFindCRLInStore(store, 0, CRL_FIND_ISSUED_BY_SIGNATURE_FLAG, CRL_FIND_ISSUED_BY, rootCert, context); if (context) @@ -764,7 +733,7 @@ static void testFindCRL(void) PCRL_ENTRY entry;
count++; - if (pCertFindCertificateInCRL(endCert, context, 0, NULL, &entry) && + if (CertFindCertificateInCRL(endCert, context, 0, NULL, &entry) && entry) revoked_count++; } @@ -985,8 +954,6 @@ static void testIsValidCRLForCert(void) PCCRL_CONTEXT crl; HCERTSTORE store;
- if(!pCertIsValidCRLForCertificate) return; - crl = CertCreateCRLContext(X509_ASN_ENCODING, v1CRLWithIssuerAndEntry, sizeof(v1CRLWithIssuerAndEntry)); ok(crl != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError()); @@ -1001,11 +968,11 @@ static void testIsValidCRLForCert(void) */
/* Curiously, any CRL is valid for the NULL certificate */ - ret = pCertIsValidCRLForCertificate(NULL, crl, 0, NULL); + ret = CertIsValidCRLForCertificate(NULL, crl, 0, NULL); ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
/* Same issuer for both cert and CRL, this CRL is valid for that cert */ - ret = pCertIsValidCRLForCertificate(cert1, crl, 0, NULL); + ret = CertIsValidCRLForCertificate(cert1, crl, 0, NULL); ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
cert2 = CertCreateCertificateContext(X509_ASN_ENCODING, @@ -1017,7 +984,7 @@ static void testIsValidCRLForCert(void) * that cert. According to MSDN, the relevant bit to check is whether the * CRL has a CRL_ISSUING_DIST_POINT extension. */ - ret = pCertIsValidCRLForCertificate(cert2, crl, 0, NULL); + ret = CertIsValidCRLForCertificate(cert2, crl, 0, NULL); ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
CertFreeCRLContext(crl); @@ -1029,10 +996,10 @@ static void testIsValidCRLForCert(void) sizeof(v2CRLWithIssuingDistPoint)); ok(crl != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError());
- ret = pCertIsValidCRLForCertificate(cert1, crl, 0, NULL); + ret = CertIsValidCRLForCertificate(cert1, crl, 0, NULL); ok(!ret && GetLastError() == CRYPT_E_NO_MATCH, "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError()); - ret = pCertIsValidCRLForCertificate(cert2, crl, 0, NULL); + ret = CertIsValidCRLForCertificate(cert2, crl, 0, NULL); ok(!ret && GetLastError() == CRYPT_E_NO_MATCH, "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
@@ -1043,7 +1010,7 @@ static void testIsValidCRLForCert(void) bigCertWithCRLDistPoints, sizeof(bigCertWithCRLDistPoints)); ok(cert3 != NULL, "CertCreateCertificateContext failed: %08lx\n", GetLastError()); - ret = pCertIsValidCRLForCertificate(cert3, crl, 0, NULL); + ret = CertIsValidCRLForCertificate(cert3, crl, 0, NULL); ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
CertFreeCRLContext(crl); @@ -1053,11 +1020,11 @@ static void testIsValidCRLForCert(void) sizeof(verisignCRL)); ok(crl != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError());
- ret = pCertIsValidCRLForCertificate(cert1, crl, 0, NULL); + ret = CertIsValidCRLForCertificate(cert1, crl, 0, NULL); ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError()); - ret = pCertIsValidCRLForCertificate(cert2, crl, 0, NULL); + ret = CertIsValidCRLForCertificate(cert2, crl, 0, NULL); ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError()); - ret = pCertIsValidCRLForCertificate(cert3, crl, 0, NULL); + ret = CertIsValidCRLForCertificate(cert3, crl, 0, NULL); ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
CertFreeCRLContext(crl); @@ -1073,11 +1040,11 @@ static void testIsValidCRLForCert(void) sizeof(verisignCRL), CERT_STORE_ADD_ALWAYS, &crl); ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
- ret = pCertIsValidCRLForCertificate(cert1, crl, 0, NULL); + ret = CertIsValidCRLForCertificate(cert1, crl, 0, NULL); ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError()); - ret = pCertIsValidCRLForCertificate(cert2, crl, 0, NULL); + ret = CertIsValidCRLForCertificate(cert2, crl, 0, NULL); ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError()); - ret = pCertIsValidCRLForCertificate(cert3, crl, 0, NULL); + ret = CertIsValidCRLForCertificate(cert3, crl, 0, NULL); ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
CertFreeCRLContext(crl); @@ -1103,37 +1070,31 @@ static void testFindCertInCRL(void) PCCRL_CONTEXT crl; PCRL_ENTRY entry;
- if (!pCertFindCertificateInCRL) - { - win_skip("CertFindCertificateInCRL() is not available\n"); - return; - } - cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert)); ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n", GetLastError());
/* Crash - ret = pCertFindCertificateInCRL(NULL, NULL, 0, NULL, NULL); - ret = pCertFindCertificateInCRL(NULL, crl, 0, NULL, NULL); - ret = pCertFindCertificateInCRL(cert, NULL, 0, NULL, NULL); - ret = pCertFindCertificateInCRL(cert, crl, 0, NULL, NULL); - ret = pCertFindCertificateInCRL(NULL, NULL, 0, NULL, &entry); - ret = pCertFindCertificateInCRL(NULL, crl, 0, NULL, &entry); - ret = pCertFindCertificateInCRL(cert, NULL, 0, NULL, &entry); + ret = CertFindCertificateInCRL(NULL, NULL, 0, NULL, NULL); + ret = CertFindCertificateInCRL(NULL, crl, 0, NULL, NULL); + ret = CertFindCertificateInCRL(cert, NULL, 0, NULL, NULL); + ret = CertFindCertificateInCRL(cert, crl, 0, NULL, NULL); + ret = CertFindCertificateInCRL(NULL, NULL, 0, NULL, &entry); + ret = CertFindCertificateInCRL(NULL, crl, 0, NULL, &entry); + ret = CertFindCertificateInCRL(cert, NULL, 0, NULL, &entry); */
crl = CertCreateCRLContext(X509_ASN_ENCODING, verisignCRL, sizeof(verisignCRL)); - ret = pCertFindCertificateInCRL(cert, crl, 0, NULL, &entry); + ret = CertFindCertificateInCRL(cert, crl, 0, NULL, &entry); ok(ret, "CertFindCertificateInCRL failed: %08lx\n", GetLastError()); ok(entry == NULL, "Expected not to find an entry in CRL\n"); CertFreeCRLContext(crl);
crl = CertCreateCRLContext(X509_ASN_ENCODING, v1CRLWithIssuerAndEntry, sizeof(v1CRLWithIssuerAndEntry)); - ret = pCertFindCertificateInCRL(cert, crl, 0, NULL, &entry); + ret = CertFindCertificateInCRL(cert, crl, 0, NULL, &entry); ok(ret, "CertFindCertificateInCRL failed: %08lx\n", GetLastError()); ok(entry != NULL, "Expected to find an entry in CRL\n"); CertFreeCRLContext(crl); @@ -1141,7 +1102,7 @@ static void testFindCertInCRL(void) /* Entry found even though CRL issuer doesn't match cert issuer */ crl = CertCreateCRLContext(X509_ASN_ENCODING, crlWithDifferentIssuer, sizeof(crlWithDifferentIssuer)); - ret = pCertFindCertificateInCRL(cert, crl, 0, NULL, &entry); + ret = CertFindCertificateInCRL(cert, crl, 0, NULL, &entry); ok(ret, "CertFindCertificateInCRL failed: %08lx\n", GetLastError()); ok(entry != NULL, "Expected to find an entry in CRL\n"); CertFreeCRLContext(crl); @@ -1205,16 +1166,12 @@ static void testVerifyCRLRevocation(void)
START_TEST(crl) { - init_function_pointers(); - testCreateCRL(); testDupCRL(); testAddCRL(); testFindCRL(); testGetCRLFromStore(); - testCRLProperties(); - testIsValidCRLForCert(); testFindCertInCRL(); testVerifyCRLRevocation(); diff --git a/dlls/crypt32/tests/ctl.c b/dlls/crypt32/tests/ctl.c index c94727cda04..05dc079ff64 100644 --- a/dlls/crypt32/tests/ctl.c +++ b/dlls/crypt32/tests/ctl.c @@ -117,17 +117,13 @@ static void testCreateCTL(void) "expected E_INVALIDARG, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); ctl = CertCreateCTLContext(X509_ASN_ENCODING, NULL, 0); - ok(!ctl && - (GetLastError() == ERROR_INVALID_DATA || - GetLastError() == OSS_MORE_INPUT), /* win9x */ + ok(!ctl && GetLastError() == ERROR_INVALID_DATA, "expected ERROR_INVALID_DATA, got %ld (0x%08lx)\n", GetLastError(), GetLastError()); /* An empty CTL can't be created.. */ SetLastError(0xdeadbeef); ctl = CertCreateCTLContext(X509_ASN_ENCODING, emptyCTL, sizeof(emptyCTL)); - ok(!ctl && - (GetLastError() == ERROR_INVALID_DATA || - GetLastError() == OSS_DATA_ERROR), /* win9x */ + ok(!ctl && GetLastError() == ERROR_INVALID_DATA, "expected ERROR_INVALID_DATA, got %ld (0x%08lx)\n", GetLastError(), GetLastError()); /* Nor can any of these "signed" CTLs whose inner content OID isn't @@ -135,29 +131,20 @@ static void testCreateCTL(void) */ SetLastError(0xdeadbeef); ctl = CertCreateCTLContext(X509_ASN_ENCODING, signedCTL, sizeof(signedCTL)); - ok(!ctl && - (GetLastError() == ERROR_INVALID_DATA || - GetLastError() == CRYPT_E_UNEXPECTED_MSG_TYPE /* win9x */ || - GetLastError() == ERROR_SUCCESS /* some win98 */), - "expected ERROR_INVALID_DATA, CRYPT_E_UNEXPECTED_MSG_TYPE, or ERROR_SUCCESS, got %ld (0x%08lx)\n", GetLastError(), + ok(!ctl && GetLastError() == ERROR_INVALID_DATA, + "expected ERROR_INVALID_DATA, got %ld (0x%08lx)\n", + GetLastError(), GetLastError()); SetLastError(0xdeadbeef); ctl = CertCreateCTLContext(X509_ASN_ENCODING, ctlWithOneEntry, sizeof(ctlWithOneEntry)); - ok(!ctl && - (GetLastError() == ERROR_INVALID_DATA || - GetLastError() == CRYPT_E_UNEXPECTED_MSG_TYPE /* win9x */ || - GetLastError() == OSS_DATA_ERROR /* some win98 */ || - GetLastError() == ERROR_SUCCESS /* some win98 */), - "expected ERROR_INVALID_DATA, CRYPT_E_UNEXPECTED_MSG_TYPE, OSS_DATA_ERROR, or ERROR_SUCCESS, got %ld (0x%08lx)\n", GetLastError(), + ok(!ctl && GetLastError() == ERROR_INVALID_DATA, + "expected ERROR_INVALID_DATA, got %ld (0x%08lx)\n", GetLastError(), GetLastError()); SetLastError(0xdeadbeef); ctl = CertCreateCTLContext(X509_ASN_ENCODING, signedCTLWithSubjectAlgorithm, sizeof(signedCTLWithSubjectAlgorithm)); - ok(!ctl && - (GetLastError() == ERROR_INVALID_DATA || - GetLastError() == CRYPT_E_UNEXPECTED_MSG_TYPE /* win9x */ || - GetLastError() == ERROR_SUCCESS /* some win98 */), + ok(!ctl && GetLastError() == ERROR_INVALID_DATA, "expected ERROR_INVALID_DATA, got %ld (0x%08lx)\n", GetLastError(), GetLastError()); /* This signed CTL with the appropriate inner content type can be decoded. @@ -237,11 +224,6 @@ static void testCTLProperties(void)
ctl = CertCreateCTLContext(X509_ASN_ENCODING, signedCTLWithCTLInnerContent, sizeof(signedCTLWithCTLInnerContent)); - if (!ctl) - { - skip("CertCreateCTLContext failed: %08lx\n", GetLastError()); - return; - }
/* No properties as yet */ propID = 0; @@ -256,12 +238,10 @@ static void testCTLProperties(void) /* An implicit property */ ret = CertGetCTLContextProperty(ctl, CERT_ACCESS_STATE_PROP_ID, NULL, &size); - ok(ret || broken(GetLastError() == CRYPT_E_NOT_FOUND /* some win98 */), - "CertGetCTLContextProperty failed: %08lx\n", GetLastError()); + ok(ret, "CertGetCTLContextProperty failed: %08lx\n", GetLastError()); ret = CertGetCTLContextProperty(ctl, CERT_ACCESS_STATE_PROP_ID, &access, &size); - ok(ret || broken(GetLastError() == CRYPT_E_NOT_FOUND /* some win98 */), - "CertGetCTLContextProperty failed: %08lx\n", GetLastError()); + ok(ret, "CertGetCTLContextProperty failed: %08lx\n", GetLastError()); if (ret) ok(!(access & CERT_ACCESS_STATE_WRITE_PERSIST_FLAG), "Didn't expect a persisted cert\n"); @@ -390,8 +370,8 @@ static void testAddCTLToStore(void) signedCTLWithCTLInnerContentAndBadSig, sizeof(signedCTLWithCTLInnerContentAndBadSig), CERT_STORE_ADD_NEW, NULL); - ok(!ret && (GetLastError() == CRYPT_E_EXISTS || GetLastError() == OSS_DATA_ERROR), - "expected CRYPT_E_EXISTS or OSS_DATA_ERROR, got %d %08lx\n", ret, GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_EXISTS, + "expected CRYPT_E_EXISTS, got %d %08lx\n", ret, GetLastError()); CertCloseStore(store, 0);
store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, @@ -407,8 +387,7 @@ static void testAddCTLToStore(void) ret = CertAddEncodedCTLToStore(store, X509_ASN_ENCODING, signedCTLWithUsage, sizeof(signedCTLWithUsage), CERT_STORE_ADD_NEW, NULL); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* some win98 */), - "CertAddEncodedCTLToStore failed: %08lx\n", GetLastError()); + ok(ret, "CertAddEncodedCTLToStore failed: %08lx\n", GetLastError()); if (ret) expectedCTLs++; /* Check that two exist */ @@ -431,11 +410,6 @@ static void testAddCTLToStore(void) ret = CertAddEncodedCTLToStore(store, X509_ASN_ENCODING, signedCTLWithListID1, sizeof(signedCTLWithListID1), CERT_STORE_ADD_NEW, NULL); - if (!ret) - { - skip("adding a CTL with an empty usage not supported\n"); - return; - } ok(ret, "CertAddEncodedCTLToStore failed: %08lx\n", GetLastError()); ret = CertAddEncodedCTLToStore(store, X509_ASN_ENCODING, signedCTLWithListID2, sizeof(signedCTLWithListID2), CERT_STORE_ADD_NEW, diff --git a/dlls/crypt32/tests/encode.c b/dlls/crypt32/tests/encode.c index 8b1959fbef8..9dabe58efba 100644 --- a/dlls/crypt32/tests/encode.c +++ b/dlls/crypt32/tests/encode.c @@ -27,10 +27,6 @@
#include "wine/test.h"
- -static BOOL (WINAPI *pCryptDecodeObjectEx)(DWORD,LPCSTR,const BYTE*,DWORD,DWORD,PCRYPT_DECODE_PARA,void*,DWORD*); -static BOOL (WINAPI *pCryptEncodeObjectEx)(DWORD,LPCSTR,const void*,DWORD,PCRYPT_ENCODE_PARA,void*,DWORD*); - void CRYPT_CopyReversed(BYTE *dst, const BYTE *src, size_t len) { DWORD i; @@ -103,31 +99,27 @@ static void test_encodeInt(DWORD dwEncoding) BYTE *buf = NULL;
/* CryptEncodeObjectEx with NULL bufSize crashes.. - ret = pCryptEncodeObjectEx(3, X509_INTEGER, &ints[0].val, 0, NULL, NULL, + ret = CryptEncodeObjectEx(3, X509_INTEGER, &ints[0].val, 0, NULL, NULL, NULL); */ /* check bogus encoding */ - ret = pCryptEncodeObjectEx(0, X509_INTEGER, &ints[0].val, 0, NULL, NULL, + ret = CryptEncodeObjectEx(0, X509_INTEGER, &ints[0].val, 0, NULL, NULL, &bufSize); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError()); - if (0) - { - /* check with NULL integer buffer. Windows XP incorrectly returns an - * NTSTATUS (crashes on win9x). - */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_INTEGER, NULL, 0, NULL, NULL, - &bufSize); - ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); - } + + ret = CryptEncodeObjectEx(dwEncoding, X509_INTEGER, NULL, 0, NULL, NULL, + &bufSize); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + for (i = 0; i < ARRAY_SIZE(ints); i++) { /* encode as normal integer */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_INTEGER, &ints[i].val, 0, + ret = CryptEncodeObjectEx(dwEncoding, X509_INTEGER, &ints[i].val, 0, NULL, NULL, &bufSize); ok(ret, "Expected success, got %ld\n", GetLastError()); - ret = pCryptEncodeObjectEx(dwEncoding, X509_INTEGER, &ints[i].val, + ret = CryptEncodeObjectEx(dwEncoding, X509_INTEGER, &ints[i].val, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError()); if (ret) @@ -143,10 +135,10 @@ static void test_encodeInt(DWORD dwEncoding) /* encode as multibyte integer */ blob.cbData = sizeof(ints[i].val); blob.pbData = (BYTE *)&ints[i].val; - ret = pCryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob, + ret = CryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob, 0, NULL, NULL, &bufSize); ok(ret, "Expected success, got %ld\n", GetLastError()); - ret = pCryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob, + ret = CryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError()); if (ret) @@ -167,10 +159,10 @@ static void test_encodeInt(DWORD dwEncoding) { blob.cbData = strlen((const char*)bigInts[i].val); blob.pbData = (BYTE *)bigInts[i].val; - ret = pCryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob, + ret = CryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob, 0, NULL, NULL, &bufSize); ok(ret, "Expected success, got %ld\n", GetLastError()); - ret = pCryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob, + ret = CryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError()); if (ret) @@ -190,10 +182,10 @@ static void test_encodeInt(DWORD dwEncoding) { blob.cbData = strlen((const char*)bigUInts[i].val); blob.pbData = (BYTE*)bigUInts[i].val; - ret = pCryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, &blob, + ret = CryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, &blob, 0, NULL, NULL, &bufSize); ok(ret, "Expected success, got %ld\n", GetLastError()); - ret = pCryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, &blob, + ret = CryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, &blob, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError()); if (ret) @@ -223,43 +215,39 @@ static void test_decodeInt(DWORD dwEncoding) BOOL ret;
/* CryptDecodeObjectEx with NULL bufSize crashes.. - ret = pCryptDecodeObjectEx(3, X509_INTEGER, &ints[0].encoded, + ret = CryptDecodeObjectEx(3, X509_INTEGER, &ints[0].encoded, ints[0].encoded[1] + 2, 0, NULL, NULL, NULL); */ /* check bogus encoding */ - ret = pCryptDecodeObjectEx(3, X509_INTEGER, (BYTE *)&ints[0].encoded, + ret = CryptDecodeObjectEx(3, X509_INTEGER, (BYTE *)&ints[0].encoded, ints[0].encoded[1] + 2, 0, NULL, NULL, &bufSize); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError()); /* check with NULL integer buffer */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_INTEGER, NULL, 0, 0, NULL, NULL, + ret = CryptDecodeObjectEx(dwEncoding, X509_INTEGER, NULL, 0, 0, NULL, NULL, &bufSize); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_BAD_ARG /* Win9x */), - "Expected CRYPT_E_ASN1_EOD or OSS_BAD_ARG, got %08lx\n", GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); /* check with a valid, but too large, integer */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_INTEGER, bigInt, bigInt[1] + 2, + ret = CryptDecodeObjectEx(dwEncoding, X509_INTEGER, bigInt, bigInt[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok((!ret && GetLastError() == CRYPT_E_ASN1_LARGE) || - broken(ret) /* Win9x */, + ok(!ret && GetLastError() == CRYPT_E_ASN1_LARGE, "Expected CRYPT_E_ASN1_LARGE, got %ld\n", GetLastError()); /* check with a DER-encoded string */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_INTEGER, testStr, testStr[1] + 2, + ret = CryptDecodeObjectEx(dwEncoding, X509_INTEGER, testStr, testStr[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH /* Win9x */ ), - "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %08lx\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); for (i = 0; i < ARRAY_SIZE(ints); i++) { /* When the output buffer is NULL, this always succeeds */ SetLastError(0xdeadbeef); - ret = pCryptDecodeObjectEx(dwEncoding, X509_INTEGER, + ret = CryptDecodeObjectEx(dwEncoding, X509_INTEGER, ints[i].encoded, ints[i].encoded[1] + 2, 0, NULL, NULL, &bufSize); ok(ret && GetLastError() == NOERROR, "Expected success and NOERROR, got %ld\n", GetLastError()); - ret = pCryptDecodeObjectEx(dwEncoding, X509_INTEGER, + ret = CryptDecodeObjectEx(dwEncoding, X509_INTEGER, ints[i].encoded, ints[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %ld\n", GetLastError()); @@ -274,12 +262,12 @@ static void test_decodeInt(DWORD dwEncoding) } for (i = 0; i < ARRAY_SIZE(bigInts); i++) { - ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, + ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, bigInts[i].encoded, bigInts[i].encoded[1] + 2, 0, NULL, NULL, &bufSize); ok(ret && GetLastError() == NOERROR, "Expected success and NOERROR, got %ld\n", GetLastError()); - ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, + ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, bigInts[i].encoded, bigInts[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %ld\n", GetLastError()); @@ -299,12 +287,12 @@ static void test_decodeInt(DWORD dwEncoding) } for (i = 0; i < ARRAY_SIZE(bigUInts); i++) { - ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, + ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, bigUInts[i].encoded, bigUInts[i].encoded[1] + 2, 0, NULL, NULL, &bufSize); ok(ret && GetLastError() == NOERROR, "Expected success and NOERROR, got %ld\n", GetLastError()); - ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, + ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, bigUInts[i].encoded, bigUInts[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %ld\n", GetLastError()); @@ -323,7 +311,7 @@ static void test_decodeInt(DWORD dwEncoding) } } /* Decode the value 1 with long-form length */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, longForm, + ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, longForm, sizeof(longForm), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -332,7 +320,7 @@ static void test_decodeInt(DWORD dwEncoding) LocalFree(buf); } /* check with extra bytes at the end */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_INTEGER, extraBytes, + ret = CryptDecodeObjectEx(dwEncoding, X509_INTEGER, extraBytes, sizeof(extraBytes), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -346,7 +334,7 @@ static void test_decodeInt(DWORD dwEncoding) * Under XP it fails with CRYPT_E_ASN1_LARGE, which means there's a limit * on the size decoded, but in ME it fails with CRYPT_E_ASN1_EOD or crashes. * So this test unfortunately isn't useful. - ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, tooBig, + ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, tooBig, 0x7fffffff, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(!ret && GetLastError() == CRYPT_E_ASN1_LARGE, "Expected CRYPT_E_ASN1_LARGE, got %08x\n", GetLastError()); @@ -357,7 +345,7 @@ static void test_decodeInt(DWORD dwEncoding) if (0) { /* a large buffer isn't guaranteed to crash, it depends on memory allocation order */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, bigBogus, + ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, bigBogus, 0x01ffffff, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); @@ -393,7 +381,7 @@ static void test_encodeEnumerated(DWORD dwEncoding) BYTE *buf = NULL; DWORD bufSize = 0;
- ret = pCryptEncodeObjectEx(dwEncoding, enumeratedTypes[i], + ret = CryptEncodeObjectEx(dwEncoding, enumeratedTypes[i], &enums[j].val, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError()); @@ -426,7 +414,7 @@ static void test_decodeEnumerated(DWORD dwEncoding) DWORD bufSize = sizeof(int); int val;
- ret = pCryptDecodeObjectEx(dwEncoding, enumeratedTypes[i], + ret = CryptDecodeObjectEx(dwEncoding, enumeratedTypes[i], enums[j].encoded, enums[j].encoded[1] + 2, 0, NULL, &val, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -454,7 +442,7 @@ static void testTimeEncoding(DWORD dwEncoding, LPCSTR structType,
ret = SystemTimeToFileTime(&time->sysTime, &ft); ok(ret, "SystemTimeToFileTime failed: %ld\n", GetLastError()); - ret = pCryptEncodeObjectEx(dwEncoding, structType, &ft, + ret = CryptEncodeObjectEx(dwEncoding, structType, &ft, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); /* years other than 1950-2050 are not allowed for encodings other than * X509_CHOICE_OF_TIME. @@ -478,8 +466,7 @@ static void testTimeEncoding(DWORD dwEncoding, LPCSTR structType, } } else - ok((!ret && GetLastError() == CRYPT_E_BAD_ENCODE) || - broken(GetLastError() == ERROR_SUCCESS), + ok(!ret && GetLastError() == CRYPT_E_BAD_ENCODE, "Expected CRYPT_E_BAD_ENCODE, got 0x%08lx\n", GetLastError()); }
@@ -508,20 +495,13 @@ static void compareTime(const SYSTEMTIME *expected, const FILETIME *got) SYSTEMTIME st;
FileTimeToSystemTime(got, &st); - ok((expected->wYear == st.wYear && + ok(expected->wYear == st.wYear && expected->wMonth == st.wMonth && expected->wDay == st.wDay && expected->wHour == st.wHour && expected->wMinute == st.wMinute && expected->wSecond == st.wSecond && - abs(expected->wMilliseconds - st.wMilliseconds) <= 1) || - /* Some Windows systems only seem to be accurate in their time decoding to - * within about an hour. - */ - broken(expected->wYear == st.wYear && - expected->wMonth == st.wMonth && - expected->wDay == st.wDay && - abs(expected->wHour - st.wHour) <= 1), + abs(expected->wMilliseconds - st.wMilliseconds) <= 1, "Got unexpected value for time decoding:\nexpected %s, got %s\n", printSystemTime(expected), printFileTime(got)); } @@ -533,7 +513,7 @@ static void testTimeDecoding(DWORD dwEncoding, LPCSTR structType, DWORD size = sizeof(ft); BOOL ret;
- ret = pCryptDecodeObjectEx(dwEncoding, structType, time->encodedTime, + ret = CryptDecodeObjectEx(dwEncoding, structType, time->encodedTime, time->encodedTime[1] + 2, 0, NULL, &ft, &size); /* years other than 1950-2050 are not allowed for encodings other than * X509_CHOICE_OF_TIME. @@ -541,17 +521,14 @@ static void testTimeDecoding(DWORD dwEncoding, LPCSTR structType, if (structType == X509_CHOICE_OF_TIME || (time->sysTime.wYear >= 1950 && time->sysTime.wYear <= 2050)) { - ok(ret || broken(GetLastError() == OSS_DATA_ERROR), - "CryptDecodeObjectEx failed: %ld (0x%08lx)\n", GetLastError(), + ok(ret, "CryptDecodeObjectEx failed: %ld (0x%08lx)\n", GetLastError(), GetLastError()); if (ret) compareTime(&time->sysTime, &ft); } else - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH /* Win9x */ ), - "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %08lx\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); }
static const BYTE bin20[] = { @@ -648,7 +625,7 @@ static void test_decodeFiletime(DWORD dwEncoding) ret = SystemTimeToFileTime(×[0].sysTime, &ft1); ok(ret, "SystemTimeToFileTime failed: %ld\n", GetLastError()); size = 1; - ret = pCryptDecodeObjectEx(dwEncoding, X509_CHOICE_OF_TIME, + ret = CryptDecodeObjectEx(dwEncoding, X509_CHOICE_OF_TIME, times[0].encodedTime, times[0].encodedTime[1] + 2, 0, NULL, &ft2, &size); ok(!ret && GetLastError() == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %ld\n", GetLastError()); @@ -668,13 +645,10 @@ static void test_decodeFiletime(DWORD dwEncoding) for (i = 0; i < ARRAY_SIZE(bogusTimes); i++) { size = sizeof(ft1); - ret = pCryptDecodeObjectEx(dwEncoding, X509_CHOICE_OF_TIME, + ret = CryptDecodeObjectEx(dwEncoding, X509_CHOICE_OF_TIME, bogusTimes[i], bogusTimes[i][1] + 2, 0, NULL, &ft1, &size); - ok((!ret && (GetLastError() == CRYPT_E_ASN1_CORRUPT || - GetLastError() == OSS_DATA_ERROR /* Win9x */)) || - broken(ret), /* Win9x and NT4 for bin38 */ - "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08lx\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_CORRUPT, + "Expected CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError()); } }
@@ -760,18 +734,16 @@ static void test_encodeName(DWORD dwEncoding) DWORD size = 0; BOOL ret;
- if (0) - { - /* Test with NULL pvStructInfo (crashes on win9x) */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, NULL, - CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); - } + /* Test with NULL pvStructInfo */ + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, NULL, + CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + /* Test with empty CERT_NAME_INFO */ info.cRDN = 0; info.rgRDN = NULL; - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -780,21 +752,20 @@ static void test_encodeName(DWORD dwEncoding) "Got unexpected encoding for empty name\n"); LocalFree(buf); } - if (0) - { - /* Test with bogus CERT_RDN (crashes on win9x) */ - info.cRDN = 1; - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info, - CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); - } + + /* Test with bogus CERT_RDN */ + info.cRDN = 1; + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + /* Test with empty CERT_RDN */ rdn.cRDNAttr = 0; rdn.rgRDNAttr = NULL; info.cRDN = 1; info.rgRDN = &rdn; - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -803,27 +774,15 @@ static void test_encodeName(DWORD dwEncoding) "Got unexpected encoding for empty RDN array\n"); LocalFree(buf); } - if (0) - { - /* Test with bogus attr array (crashes on win9x) */ - rdn.cRDNAttr = 1; - rdn.rgRDNAttr = NULL; - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info, - CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); - } - /* oddly, a bogus OID is accepted by Windows XP; not testing. - attrs[0].pszObjId = "bogus"; - attrs[0].dwValueType = CERT_RDN_PRINTABLE_STRING; - attrs[0].Value.cbData = sizeof(commonName); - attrs[0].Value.pbData = commonName; + + /* Test with bogus attr array */ rdn.cRDNAttr = 1; - rdn.rgRDNAttr = attrs; - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + rdn.rgRDNAttr = NULL; + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret, "Expected failure, got success\n"); - */ + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + /* Check with two CERT_RDN_ATTRs. Note DER encoding forces the order of * the encoded attributes to be swapped. */ @@ -837,7 +796,7 @@ static void test_encodeName(DWORD dwEncoding) attrs[1].Value.pbData = (BYTE *)surName; rdn.cRDNAttr = 2; rdn.rgRDNAttr = attrs; - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -851,7 +810,7 @@ static void test_encodeName(DWORD dwEncoding) attrs[0].Value.pbData = (LPBYTE)twoRDNs; attrs[0].Value.cbData = sizeof(twoRDNs); rdn.cRDNAttr = 1; - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -864,7 +823,7 @@ static void test_encodeName(DWORD dwEncoding) /* CERT_RDN_ANY_TYPE is too vague for X509_NAMEs, check the return */ rdn.cRDNAttr = 1; attrs[0].dwValueType = CERT_RDN_ANY_TYPE; - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError()); @@ -875,7 +834,7 @@ static void test_encodeName(DWORD dwEncoding) info.rgRDN = &rdn; buf = NULL; size = 0; - ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, X509_NAME, &info, + ret = CryptEncodeObjectEx(X509_ASN_ENCODING, X509_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -907,18 +866,15 @@ static void test_encodeUnicodeName(DWORD dwEncoding) DWORD size = 0; BOOL ret;
- if (0) - { - /* Test with NULL pvStructInfo (crashes on win9x) */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, NULL, - CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); - } + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, NULL, + CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + /* Test with empty CERT_NAME_INFO */ info.cRDN = 0; info.rgRDN = NULL; - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -938,7 +894,7 @@ static void test_encodeUnicodeName(DWORD dwEncoding) rdn.rgRDNAttr = attrs; info.cRDN = 1; info.rgRDN = &rdn; - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_PRINTABLE_STRING, "Expected CRYPT_E_INVALID_PRINTABLE_STRING, got %08lx\n", GetLastError()); @@ -958,7 +914,7 @@ static void test_encodeUnicodeName(DWORD dwEncoding) rdn.rgRDNAttr = attrs; info.cRDN = 1; info.rgRDN = &rdn; - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -972,7 +928,7 @@ static void test_encodeUnicodeName(DWORD dwEncoding) attrs[0].Value.pbData = (LPBYTE)twoRDNs; attrs[0].Value.cbData = sizeof(twoRDNs); rdn.cRDNAttr = 1; - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -985,7 +941,7 @@ static void test_encodeUnicodeName(DWORD dwEncoding) /* Unicode names infer the type for CERT_RDN_ANY_TYPE */ rdn.cRDNAttr = 1; attrs[0].dwValueType = CERT_RDN_ANY_TYPE; - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); todo_wine ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -999,13 +955,6 @@ static void test_encodeUnicodeName(DWORD dwEncoding) static void compareNameValues(const CERT_NAME_VALUE *expected, const CERT_NAME_VALUE *got) { - if (expected->dwValueType == CERT_RDN_UTF8_STRING && - got->dwValueType == CERT_RDN_ENCODED_BLOB) - { - win_skip("Can't handle CERT_RDN_UTF8_STRING\n"); - return; - } - ok(got->dwValueType == expected->dwValueType, "Expected string type %ld, got %ld\n", expected->dwValueType, got->dwValueType); @@ -1080,7 +1029,7 @@ static void test_decodeName(DWORD dwEncoding)
/* test empty name */ bufSize = 0; - ret = pCryptDecodeObjectEx(dwEncoding, X509_NAME, emptySequence, + ret = CryptDecodeObjectEx(dwEncoding, X509_NAME, emptySequence, emptySequence[1] + 2, CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL, &buf, &bufSize); @@ -1097,7 +1046,7 @@ static void test_decodeName(DWORD dwEncoding) LocalFree(buf); } /* test empty name with indefinite-length encoding */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_NAME, emptyIndefiniteSequence, + ret = CryptDecodeObjectEx(dwEncoding, X509_NAME, emptyIndefiniteSequence, sizeof(emptyIndefiniteSequence), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -1111,7 +1060,7 @@ static void test_decodeName(DWORD dwEncoding) } /* test empty RDN */ bufSize = 0; - ret = pCryptDecodeObjectEx(dwEncoding, X509_NAME, emptyRDNs, + ret = CryptDecodeObjectEx(dwEncoding, X509_NAME, emptyRDNs, emptyRDNs[1] + 2, CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL, &buf, &bufSize); @@ -1127,7 +1076,7 @@ static void test_decodeName(DWORD dwEncoding) } /* test two RDN attrs */ bufSize = 0; - ret = pCryptDecodeObjectEx(dwEncoding, X509_NAME, twoRDNs, + ret = CryptDecodeObjectEx(dwEncoding, X509_NAME, twoRDNs, twoRDNs[1] + 2, CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL, &buf, &bufSize); @@ -1151,13 +1100,13 @@ static void test_decodeName(DWORD dwEncoding) } /* test that two RDN attrs with extra bytes succeeds */ bufSize = 0; - ret = pCryptDecodeObjectEx(dwEncoding, X509_NAME, twoRDNsExtraBytes, + ret = CryptDecodeObjectEx(dwEncoding, X509_NAME, twoRDNsExtraBytes, sizeof(twoRDNsExtraBytes), 0, NULL, NULL, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); /* And, a slightly more complicated name */ buf = NULL; bufSize = 0; - ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, X509_NAME, encodedRDNAttrs, + ret = CryptDecodeObjectEx(X509_ASN_ENCODING, X509_NAME, encodedRDNAttrs, sizeof(encodedRDNAttrs), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -1179,7 +1128,7 @@ static void test_decodeUnicodeName(DWORD dwEncoding)
/* test empty name */ bufSize = 0; - ret = pCryptDecodeObjectEx(dwEncoding, X509_UNICODE_NAME, emptySequence, + ret = CryptDecodeObjectEx(dwEncoding, X509_UNICODE_NAME, emptySequence, emptySequence[1] + 2, CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL, &buf, &bufSize); @@ -1195,7 +1144,7 @@ static void test_decodeUnicodeName(DWORD dwEncoding) } /* test empty RDN */ bufSize = 0; - ret = pCryptDecodeObjectEx(dwEncoding, X509_UNICODE_NAME, emptyRDNs, + ret = CryptDecodeObjectEx(dwEncoding, X509_UNICODE_NAME, emptyRDNs, emptyRDNs[1] + 2, CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL, &buf, &bufSize); @@ -1211,7 +1160,7 @@ static void test_decodeUnicodeName(DWORD dwEncoding) } /* test two RDN attrs */ bufSize = 0; - ret = pCryptDecodeObjectEx(dwEncoding, X509_UNICODE_NAME, twoRDNsNoNull, + ret = CryptDecodeObjectEx(dwEncoding, X509_UNICODE_NAME, twoRDNsNoNull, sizeof(twoRDNsNoNull), CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL, &buf, &bufSize); @@ -1326,7 +1275,7 @@ static void test_encodeNameValue(DWORD dwEncoding) value.dwValueType = CERT_RDN_ENCODED_BLOB; value.Value.pbData = printableCommonNameValue; value.Value.cbData = sizeof(printableCommonNameValue); - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_VALUE, &value, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_VALUE, &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -1339,10 +1288,9 @@ static void test_encodeNameValue(DWORD dwEncoding) } for (i = 0; i < ARRAY_SIZE(nameValues); i++) { - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_VALUE, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_VALUE, &nameValues[i].value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret || broken(GetLastError() == OSS_PDU_MISMATCH) /* NT4/Win9x */, - "Type %ld: CryptEncodeObjectEx failed: %08lx\n", + ok(ret, "Type %ld: CryptEncodeObjectEx failed: %08lx\n", nameValues[i].value.dwValueType, GetLastError()); if (ret) { @@ -1353,10 +1301,9 @@ static void test_encodeNameValue(DWORD dwEncoding) LocalFree(buf); } } - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_VALUE, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_VALUE, &embeddedNullNameValue.value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret || broken(GetLastError() == OSS_PDU_MISMATCH) /* NT4/Win9x */, - "Type %ld: CryptEncodeObjectEx failed: %08lx\n", + ok(ret, "Type %ld: CryptEncodeObjectEx failed: %08lx\n", embeddedNullNameValue.value.dwValueType, GetLastError()); if (ret) { @@ -1377,7 +1324,7 @@ static void test_decodeNameValue(DWORD dwEncoding)
for (i = 0; i < ARRAY_SIZE(nameValues); i++) { - ret = pCryptDecodeObjectEx(dwEncoding, X509_NAME_VALUE, + ret = CryptDecodeObjectEx(dwEncoding, X509_NAME_VALUE, nameValues[i].encoded, nameValues[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL, &buf, &bufSize); @@ -1390,7 +1337,7 @@ static void test_decodeNameValue(DWORD dwEncoding) LocalFree(buf); } } - ret = pCryptDecodeObjectEx(dwEncoding, X509_NAME_VALUE, + ret = CryptDecodeObjectEx(dwEncoding, X509_NAME_VALUE, embeddedNullNameValue.encoded, embeddedNullNameValue.encodedSize, CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL, &buf, &bufSize); @@ -1461,7 +1408,7 @@ static void test_encodeAltName(DWORD dwEncoding) char oid[] = "1.2.3";
/* Test with empty info */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { @@ -1472,13 +1419,13 @@ static void test_encodeAltName(DWORD dwEncoding) /* Test with an empty entry */ info.cAltEntry = 1; info.rgAltEntry = &entry; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* Test with an empty pointer */ entry.dwAltNameChoice = CERT_ALT_NAME_URL; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { @@ -1488,7 +1435,7 @@ static void test_encodeAltName(DWORD dwEncoding) } /* Test with a real URL */ U(entry).pwszURL = (LPWSTR)url; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { @@ -1498,7 +1445,7 @@ static void test_encodeAltName(DWORD dwEncoding) } /* Now with the URL containing an invalid IA5 char */ U(entry).pwszURL = (WCHAR *)L"http://%5Cx226f%5Cx575b"; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_IA5_STRING, "Expected CRYPT_E_INVALID_IA5_STRING, got %08lx\n", GetLastError()); @@ -1508,7 +1455,7 @@ static void test_encodeAltName(DWORD dwEncoding) GET_CERT_ALT_NAME_VALUE_ERR_INDEX(size)); /* Now with the URL missing a scheme */ U(entry).pwszURL = (LPWSTR)dnsName; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -1518,7 +1465,7 @@ static void test_encodeAltName(DWORD dwEncoding) } /* Now with a DNS name */ entry.dwAltNameChoice = CERT_ALT_NAME_DNS_NAME; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -1531,7 +1478,7 @@ static void test_encodeAltName(DWORD dwEncoding) entry.dwAltNameChoice = CERT_ALT_NAME_IP_ADDRESS; U(entry).IPAddress.cbData = sizeof(localhost); U(entry).IPAddress.pbData = (LPBYTE)localhost; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { @@ -1542,7 +1489,7 @@ static void test_encodeAltName(DWORD dwEncoding) /* Test with OID */ entry.dwAltNameChoice = CERT_ALT_NAME_REGISTERED_ID; U(entry).pszRegisteredID = oid; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { @@ -1554,7 +1501,7 @@ static void test_encodeAltName(DWORD dwEncoding) entry.dwAltNameChoice = CERT_ALT_NAME_DIRECTORY_NAME; U(entry).DirectoryName.cbData = sizeof(encodedCommonName); U(entry).DirectoryName.pbData = (LPBYTE)encodedCommonName; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { @@ -1582,22 +1529,18 @@ static void test_decodeAltName(DWORD dwEncoding) CERT_ALT_NAME_INFO *info;
/* Test some bogus ones first */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, + ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, unimplementedType, sizeof(unimplementedType), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_DATA_ERROR /* Win9x */), - "Expected CRYPT_E_ASN1_BADTAG or OSS_DATA_ERROR, got %08lx\n", - GetLastError()); - ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); + ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, bogusType, sizeof(bogusType), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_CORRUPT || - GetLastError() == OSS_DATA_ERROR /* Win9x */), - "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08lx\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_CORRUPT, + "Expected CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError()); /* Now expected cases */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, emptySequence, + ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, emptySequence, emptySequence[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -1608,7 +1551,7 @@ static void test_decodeAltName(DWORD dwEncoding) info->cAltEntry); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, emptyURL, + ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, emptyURL, emptyURL[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -1624,10 +1567,10 @@ static void test_decodeAltName(DWORD dwEncoding) "Expected empty URL\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, + ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, emptyURLExtraBytes, sizeof(emptyURLExtraBytes), 0, NULL, NULL, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); - ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedURL, + ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedURL, encodedURL[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -1642,7 +1585,7 @@ static void test_decodeAltName(DWORD dwEncoding) ok(!lstrcmpW(U(info->rgAltEntry[0]).pwszURL, url), "Unexpected URL\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedDnsName, + ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedDnsName, encodedDnsName[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -1658,7 +1601,7 @@ static void test_decodeAltName(DWORD dwEncoding) "Unexpected DNS name\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedIPAddr, + ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedIPAddr, encodedIPAddr[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -1677,7 +1620,7 @@ static void test_decodeAltName(DWORD dwEncoding) sizeof(localhost)), "Unexpected IP address value\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedOidName, + ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedOidName, sizeof(encodedOidName), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -1693,7 +1636,7 @@ static void test_decodeAltName(DWORD dwEncoding) "Expected OID 1.2.3, got %s\n", U(info->rgAltEntry[0]).pszRegisteredID); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, + ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedDirectoryName, sizeof(encodedDirectoryName), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -1714,17 +1657,12 @@ static void test_decodeAltName(DWORD dwEncoding) "Unexpected directory name value\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, + ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, dns_embedded_null, sizeof(dns_embedded_null), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - /* Fails on WinXP with CRYPT_E_ASN1_RULE. I'm not too concerned about the - * particular failure, just that it doesn't decode. - * It succeeds on (broken) Windows versions that haven't addressed - * embedded NULLs in alternate names. - */ - ok(!ret || broken(ret), "expected failure\n"); + ok(!ret, "expected failure\n"); /* An embedded bell character is allowed, however. */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, + ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, dns_embedded_bell, sizeof(dns_embedded_bell), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -1739,15 +1677,10 @@ static void test_decodeAltName(DWORD dwEncoding) info->rgAltEntry[0].dwAltNameChoice); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, + ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, url_embedded_null, sizeof(dns_embedded_null), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - /* Again, fails on WinXP with CRYPT_E_ASN1_RULE. I'm not too concerned - * about the particular failure, just that it doesn't decode. - * It succeeds on (broken) Windows versions that haven't addressed - * embedded NULLs in alternate names. - */ - ok(!ret || broken(ret), "expected failure\n"); + ok(!ret, "expected failure\n"); }
struct UnicodeExpectedError @@ -1822,35 +1755,32 @@ static void test_encodeUnicodeNameValue(DWORD dwEncoding) BOOL ret; CERT_NAME_VALUE value;
- if (0) - { - /* Crashes on win9x */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, NULL, - CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); - } + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, NULL, + CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + /* Have to have a string of some sort */ value.dwValueType = 0; /* aka CERT_RDN_ANY_TYPE */ value.Value.pbData = NULL; value.Value.cbData = 0; - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_CHAR_STRING, "Expected CRYPT_E_NOT_CHAR_STRING, got %08lx\n", GetLastError()); value.dwValueType = CERT_RDN_ENCODED_BLOB; - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_CHAR_STRING, "Expected CRYPT_E_NOT_CHAR_STRING, got %08lx\n", GetLastError()); value.dwValueType = CERT_RDN_ANY_TYPE; value.Value.pbData = (LPBYTE)L"1"; - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_CHAR_STRING, "Expected CRYPT_E_NOT_CHAR_STRING, got %08lx\n", GetLastError()); value.Value.cbData = sizeof(L"1"); - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_CHAR_STRING, "Expected CRYPT_E_NOT_CHAR_STRING, got %08lx\n", GetLastError()); @@ -1858,7 +1788,7 @@ static void test_encodeUnicodeNameValue(DWORD dwEncoding) value.dwValueType = CERT_RDN_ENCODED_BLOB; value.Value.pbData = oneUniversal; value.Value.cbData = sizeof(oneUniversal); - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_CHAR_STRING, "Expected CRYPT_E_NOT_CHAR_STRING, got %08lx\n", GetLastError()); @@ -1868,7 +1798,7 @@ static void test_encodeUnicodeNameValue(DWORD dwEncoding) { value.Value.pbData = (LPBYTE)unicodeErrors[i].str; value.dwValueType = unicodeErrors[i].valueType; - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == unicodeErrors[i].error, "Value type %ld: expected %08lx, got %08lx\n", value.dwValueType, @@ -1883,10 +1813,9 @@ static void test_encodeUnicodeNameValue(DWORD dwEncoding) { value.Value.pbData = (LPBYTE)unicodeResults[i].str; value.dwValueType = unicodeResults[i].valueType; - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret || broken(GetLastError() == OSS_PDU_MISMATCH /* Win9x */), - "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(size == unicodeResults[i].encoded.cbData, @@ -1905,7 +1834,7 @@ static void test_encodeUnicodeNameValue(DWORD dwEncoding) { value.Value.pbData = (LPBYTE)unicodeWeirdness[i].str; value.dwValueType = unicodeWeirdness[i].valueType; - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -1930,11 +1859,10 @@ static void test_decodeUnicodeNameValue(DWORD dwEncoding) BOOL ret; DWORD size = 0;
- ret = pCryptDecodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, + ret = CryptDecodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, unicodeResults[i].encoded.pbData, unicodeResults[i].encoded.cbData, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret || broken(GetLastError() == CRYPT_E_NOT_CHAR_STRING /* Win9x */), - "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret && buf) { PCERT_NAME_VALUE value = (PCERT_NAME_VALUE)buf; @@ -1990,7 +1918,7 @@ static void test_encodeOctets(DWORD dwEncoding)
blob.cbData = tests[i].decoded_size; blob.pbData = (BYTE*)tests[i].decoded; - ret = pCryptEncodeObjectEx(dwEncoding, X509_OCTET_STRING, &blob, + ret = CryptEncodeObjectEx(dwEncoding, X509_OCTET_STRING, &blob, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError()); if (ret) @@ -2062,7 +1990,7 @@ static void test_decodeOctets(DWORD dwEncoding) BOOL ret; DWORD bufSize = 0;
- ret = pCryptDecodeObjectEx(dwEncoding, X509_OCTET_STRING, + ret = CryptDecodeObjectEx(dwEncoding, X509_OCTET_STRING, tests[i].encoded, tests[i].encoded_size, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); if (tests[i].error) @@ -2128,7 +2056,7 @@ static void test_encodeBits(DWORD dwEncoding) blob.cbData = sizeof(bytesToEncode); blob.pbData = (BYTE *)bytesToEncode; blob.cUnusedBits = bits[i].cUnusedBits; - ret = pCryptEncodeObjectEx(dwEncoding, X509_BITS, &blob, + ret = CryptEncodeObjectEx(dwEncoding, X509_BITS, &blob, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -2155,7 +2083,7 @@ static void test_decodeBits(DWORD dwEncoding) /* normal cases */ for (i = 0; i < ARRAY_SIZE(bits); i++) { - ret = pCryptDecodeObjectEx(dwEncoding, X509_BITS, bits[i].encoded, + ret = CryptDecodeObjectEx(dwEncoding, X509_BITS, bits[i].encoded, bits[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -2178,7 +2106,7 @@ static void test_decodeBits(DWORD dwEncoding) /* special case: check that something that's valid in BER but not in DER * decodes successfully */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_BITS, ber, ber[1] + 2, + ret = CryptDecodeObjectEx(dwEncoding, X509_BITS, ber, ber[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -2242,7 +2170,7 @@ static void test_encodeBasicConstraints(DWORD dwEncoding) /* First test with the simpler info2 */ for (i = 0; i < ARRAY_SIZE(constraints2); i++) { - ret = pCryptEncodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, + ret = CryptEncodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, &constraints2[i].info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); @@ -2260,10 +2188,9 @@ static void test_encodeBasicConstraints(DWORD dwEncoding) info.SubjectType.cbData = 0; info.fPathLenConstraint = FALSE; info.cSubtreesConstraint = 0; - ret = pCryptEncodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret || GetLastError() == OSS_BAD_PTR /* Win9x */, - "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(bufSize == sizeof(emptyConstraint), "Wrong size %ld\n", bufSize); @@ -2276,10 +2203,9 @@ static void test_encodeBasicConstraints(DWORD dwEncoding) */ info.cSubtreesConstraint = 1; info.rgSubtreesConstraint = &nameBlob; - ret = pCryptEncodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret || GetLastError() == OSS_BAD_PTR /* Win9x */, - "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(bufSize == sizeof(constraintWithDomainName), "Wrong size %ld\n", bufSize); @@ -2305,7 +2231,7 @@ static void test_decodeBasicConstraints(DWORD dwEncoding) /* First test with simpler info2 */ for (i = 0; i < ARRAY_SIZE(constraints2); i++) { - ret = pCryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, + ret = CryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, constraints2[i].encoded, constraints2[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed for item %ld: %08lx\n", i, @@ -2322,16 +2248,14 @@ static void test_decodeBasicConstraints(DWORD dwEncoding) } /* Check with the order of encoded elements inverted */ buf = (PBYTE)1; - ret = pCryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, + ret = CryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, inverted, inverted[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_CORRUPT || - GetLastError() == OSS_DATA_ERROR /* Win9x */), - "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08lx\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_CORRUPT, + "Expected CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError()); ok(!buf, "Expected buf to be set to NULL\n"); /* Check with a non-DER bool */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, + ret = CryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, badBool.encoded, badBool.encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -2344,15 +2268,13 @@ static void test_decodeBasicConstraints(DWORD dwEncoding) LocalFree(buf); } /* Check with a non-basic constraints value */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, + ret = CryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, encodedCommonName, encodedCommonName[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_CORRUPT || - GetLastError() == OSS_DATA_ERROR /* Win9x */), - "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08lx\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_CORRUPT, + "Expected CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError()); /* Now check with the more complex CERT_BASIC_CONSTRAINTS_INFO */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS, + ret = CryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS, emptyConstraint, sizeof(emptyConstraint), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -2365,7 +2287,7 @@ static void test_decodeBasicConstraints(DWORD dwEncoding) ok(info->cSubtreesConstraint == 0, "Expected no subtree constraints\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS, + ret = CryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS, constraintWithDomainName, sizeof(constraintWithDomainName), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -2433,14 +2355,14 @@ static void test_encodeRsaPublicKey(DWORD dwEncoding) memcpy(toEncode + sizeof(BLOBHEADER) + sizeof(RSAPUBKEY), modulus1, sizeof(modulus1));
- ret = pCryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, + ret = CryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* Now with a bogus reserved field */ hdr->bType = PUBLICKEYBLOB; hdr->reserved = 1; - ret = pCryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, + ret = CryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); if (ret) { @@ -2452,7 +2374,7 @@ static void test_encodeRsaPublicKey(DWORD dwEncoding) /* Now with a bogus blob version */ hdr->reserved = 0; hdr->bVersion = 0; - ret = pCryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, + ret = CryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); if (ret) { @@ -2464,7 +2386,7 @@ static void test_encodeRsaPublicKey(DWORD dwEncoding) /* And with a bogus alg ID */ hdr->bVersion = CUR_BLOB_VERSION; hdr->aiKeyAlg = CALG_DES; - ret = pCryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, + ret = CryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); if (ret) { @@ -2475,11 +2397,11 @@ static void test_encodeRsaPublicKey(DWORD dwEncoding) } /* Check a couple of RSA-related OIDs */ hdr->aiKeyAlg = CALG_RSA_KEYX; - ret = pCryptEncodeObjectEx(dwEncoding, szOID_RSA_RSA, + ret = CryptEncodeObjectEx(dwEncoding, szOID_RSA_RSA, toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); - ret = pCryptEncodeObjectEx(dwEncoding, szOID_RSA_SHA1RSA, + ret = CryptEncodeObjectEx(dwEncoding, szOID_RSA_SHA1RSA, toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); @@ -2489,7 +2411,7 @@ static void test_encodeRsaPublicKey(DWORD dwEncoding) { memcpy(toEncode + sizeof(BLOBHEADER) + sizeof(RSAPUBKEY), rsaPubKeys[i].modulus, rsaPubKeys[i].modulusLen); - ret = pCryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, + ret = CryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -2512,20 +2434,18 @@ static void test_decodeRsaPublicKey(DWORD dwEncoding) BOOL ret;
/* Try with a bad length */ - ret = pCryptDecodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, + ret = CryptDecodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, rsaPubKeys[0].encoded, rsaPubKeys[0].encoded[1], CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_MORE_INPUT /* Win9x/NT4 */), - "Expected CRYPT_E_ASN1_EOD or OSS_MORE_INPUT, got %08lx\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); /* Try with a couple of RSA-related OIDs */ - ret = pCryptDecodeObjectEx(dwEncoding, szOID_RSA_RSA, + ret = CryptDecodeObjectEx(dwEncoding, szOID_RSA_RSA, rsaPubKeys[0].encoded, rsaPubKeys[0].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); - ret = pCryptDecodeObjectEx(dwEncoding, szOID_RSA_SHA1RSA, + ret = CryptDecodeObjectEx(dwEncoding, szOID_RSA_SHA1RSA, rsaPubKeys[0].encoded, rsaPubKeys[0].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, @@ -2534,7 +2454,7 @@ static void test_decodeRsaPublicKey(DWORD dwEncoding) for (i = 0; i < ARRAY_SIZE(rsaPubKeys); i++) { bufSize = 0; - ret = pCryptDecodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, + ret = CryptDecodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, rsaPubKeys[i].encoded, rsaPubKeys[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -2594,7 +2514,7 @@ static void test_encodeRsaPublicKey_Bcrypt(DWORD dwEncoding) CRYPT_CopyReversed(toEncode + sizeof(BCRYPT_RSAKEY_BLOB), pubexp, sizeof(pubexp)); CRYPT_CopyReversed(toEncode + sizeof(BCRYPT_RSAKEY_BLOB) + sizeof(pubexp), modulus1, sizeof(modulus1));
- ret = pCryptEncodeObjectEx(dwEncoding, CNG_RSA_PUBLIC_KEY_BLOB, + ret = CryptEncodeObjectEx(dwEncoding, CNG_RSA_PUBLIC_KEY_BLOB, toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
@@ -2608,7 +2528,7 @@ static void test_encodeRsaPublicKey_Bcrypt(DWORD dwEncoding) CRYPT_CopyReversed(toEncode + sizeof(BCRYPT_RSAKEY_BLOB) + sizeof(DWORD), rsaPubKeys[i].modulus, rsaPubKeys[i].modulusLen);
- ret = pCryptEncodeObjectEx(dwEncoding, CNG_RSA_PUBLIC_KEY_BLOB, + ret = CryptEncodeObjectEx(dwEncoding, CNG_RSA_PUBLIC_KEY_BLOB, toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -2632,18 +2552,16 @@ static void test_decodeRsaPublicKey_Bcrypt(DWORD dwEncoding) BOOL ret;
/* Try with a bad length */ - ret = pCryptDecodeObjectEx(dwEncoding, CNG_RSA_PUBLIC_KEY_BLOB, + ret = CryptDecodeObjectEx(dwEncoding, CNG_RSA_PUBLIC_KEY_BLOB, rsaPubKeys[0].encoded, rsaPubKeys[0].encoded[1], CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_MORE_INPUT /* Win9x/NT4 */), - "Expected CRYPT_E_ASN1_EOD or OSS_MORE_INPUT, got %08lx\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); /* Now try success cases */ for (i = 0; i < ARRAY_SIZE(rsaPubKeys); i++) { bufSize = 0; - ret = pCryptDecodeObjectEx(dwEncoding, CNG_RSA_PUBLIC_KEY_BLOB, + ret = CryptDecodeObjectEx(dwEncoding, CNG_RSA_PUBLIC_KEY_BLOB, rsaPubKeys[i].encoded, rsaPubKeys[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -2717,7 +2635,7 @@ static void test_encodeSequenceOfAny(DWORD dwEncoding) seq.cValue = ARRAY_SIZE(ints); seq.rgValue = blobs;
- ret = pCryptEncodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, &seq, + ret = CryptEncodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, &seq, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -2731,7 +2649,7 @@ static void test_encodeSequenceOfAny(DWORD dwEncoding) */ blobs[0].cbData = times[0].encodedTime[1] + 2; blobs[0].pbData = (BYTE *)times[0].encodedTime; - ret = pCryptEncodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, &seq, + ret = CryptEncodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, &seq, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -2749,7 +2667,7 @@ static void test_decodeSequenceOfAny(DWORD dwEncoding) BYTE *buf = NULL; DWORD bufSize = 0;
- ret = pCryptDecodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, intSequence, + ret = CryptDecodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, intSequence, intSequence[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -2768,7 +2686,7 @@ static void test_decodeSequenceOfAny(DWORD dwEncoding) } LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, mixedSequence, + ret = CryptDecodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, mixedSequence, mixedSequence[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -2828,7 +2746,7 @@ static void test_encodeExtensions(DWORD dwEncoding) BYTE *buf = NULL; DWORD bufSize = 0;
- ret = pCryptEncodeObjectEx(dwEncoding, X509_EXTENSIONS, &exts[i].exts, + ret = CryptEncodeObjectEx(dwEncoding, X509_EXTENSIONS, &exts[i].exts, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -2852,7 +2770,7 @@ static void test_decodeExtensions(DWORD dwEncoding) BYTE *buf = NULL; DWORD bufSize = 0;
- ret = pCryptDecodeObjectEx(dwEncoding, X509_EXTENSIONS, + ret = CryptDecodeObjectEx(dwEncoding, X509_EXTENSIONS, exts[i].encoded, exts[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -2878,13 +2796,13 @@ static void test_decodeExtensions(DWORD dwEncoding) } LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_EXTENSIONS, + ret = CryptDecodeObjectEx(dwEncoding, X509_EXTENSIONS, exts[i].encoded, exts[i].encoded[1] + 2, 0, NULL, NULL, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, bufSize); if (buf) { - ret = pCryptDecodeObjectEx(dwEncoding, X509_EXTENSIONS, + ret = CryptDecodeObjectEx(dwEncoding, X509_EXTENSIONS, exts[i].encoded, exts[i].encoded[1] + 2, 0, NULL, buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); HeapFree(GetProcessHeap(), 0, buf); @@ -2966,11 +2884,10 @@ static void test_encodePublicKeyInfo(DWORD dwEncoding) BYTE *buf = NULL; DWORD bufSize = 0;
- ret = pCryptEncodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, + ret = CryptEncodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, &pubKeys[i].info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret || GetLastError() == OSS_BAD_PTR /* Win9x */, - "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(bufSize == pubKeys[i].encoded[1] + 2, @@ -3019,7 +2936,7 @@ static void test_decodePublicKeyInfo(DWORD dwEncoding) for (i = 0; i < ARRAY_SIZE(pubKeys); i++) { /* The NULL form decodes to the decoded member */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, + ret = CryptDecodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, pubKeys[i].encoded, pubKeys[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -3030,7 +2947,7 @@ static void test_decodePublicKeyInfo(DWORD dwEncoding) LocalFree(buf); } /* The non-NULL form decodes to the original */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, + ret = CryptDecodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, pubKeys[i].encodedNoNull, pubKeys[i].encodedNoNull[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -3041,13 +2958,11 @@ static void test_decodePublicKeyInfo(DWORD dwEncoding) } } /* Test with bogus (not valid DER) parameters */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, + ret = CryptDecodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, bogusPubKeyInfo, bogusPubKeyInfo[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_CORRUPT || - GetLastError() == OSS_DATA_ERROR /* Win9x */), - "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08lx\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_CORRUPT, + "Expected CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError()); }
static const BYTE v1Cert[] = { 0x30, 0x33, 0x02, 0x00, 0x30, 0x02, 0x06, 0x00, @@ -3169,19 +3084,16 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding) static char oid_subject_key_identifier[] = szOID_SUBJECT_KEY_IDENTIFIER; CERT_EXTENSION ext;
- if (0) - { - /* Test with NULL pvStructInfo (crashes on win9x) */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, NULL, - CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); - } + /* Test with NULL pvStructInfo */ + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, NULL, + CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + /* Test with a V1 cert */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret || GetLastError() == OSS_BAD_PTR /* Win9x */, - "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(size == v1Cert[1] + 2, "Expected size %d, got %ld\n", @@ -3191,10 +3103,9 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding) } /* Test v2 cert */ info.dwVersion = CERT_V2; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret || GetLastError() == OSS_BAD_PTR /* Win9x */, - "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(size == sizeof(v2Cert), "Wrong size %ld\n", size); @@ -3203,10 +3114,9 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding) } /* Test v3 cert */ info.dwVersion = CERT_V3; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret || GetLastError() == OSS_BAD_PTR /* Win9x */, - "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(size == sizeof(v3Cert), "Wrong size %ld\n", size); @@ -3215,7 +3125,7 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding) } /* A v4 cert? */ info.dwVersion = 3; /* Not a typo, CERT_V3 is 2 */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { @@ -3229,10 +3139,9 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding) info.dwVersion = CERT_V1; info.cExtension = 1; info.rgExtension = &criticalExt; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret || GetLastError() == OSS_BAD_PTR /* Win9x */, - "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(size == sizeof(v1CertWithConstraints), "Wrong size %ld\n", size); @@ -3242,7 +3151,7 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding) /* test v1 cert with a serial number */ info.SerialNumber.cbData = sizeof(serialNum); info.SerialNumber.pbData = (BYTE *)serialNum; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { @@ -3255,10 +3164,9 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding) info.cExtension = 0; info.IssuerUniqueId.cbData = sizeof(serialNum); info.IssuerUniqueId.pbData = (BYTE *)serialNum; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret || broken(GetLastError() == OSS_BAD_PTR /* Win98 */), - "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(size == sizeof(v1CertWithIssuerUniqueId), "Wrong size %ld\n", size); @@ -3275,7 +3183,7 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding) info.Issuer.pbData = (BYTE *)encodedCommonName; info.Subject.cbData = sizeof(encodedCommonName); info.Subject.pbData = (BYTE *)encodedCommonName; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { @@ -3287,7 +3195,7 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding) info.SubjectPublicKeyInfo.Algorithm.pszObjId = oid_rsa_rsa; info.SubjectPublicKeyInfo.PublicKey.cbData = sizeof(aKey); info.SubjectPublicKeyInfo.PublicKey.pbData = (LPBYTE)aKey; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { @@ -3303,7 +3211,7 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding) /* Again add an issuer unique id */ info.IssuerUniqueId.cbData = sizeof(serialNum); info.IssuerUniqueId.pbData = (BYTE *)serialNum; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -3333,7 +3241,7 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding) ext.Value.pbData = octetCommonNameValue; info.cExtension = 1; info.rgExtension = &ext; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { @@ -3352,26 +3260,23 @@ static void test_decodeCertToBeSigned(DWORD dwEncoding) DWORD size = 0, i;
/* Test with NULL pbEncoded */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, NULL, 0, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, NULL, 0, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_BAD_ARG /* Win9x */), - "Expected CRYPT_E_ASN1_EOD or OSS_BAD_ARG, got %08lx\n", GetLastError()); - if (0) - { - /* Crashes on win9x */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, NULL, 1, - CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); - } + ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); + + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, NULL, 1, + CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + /* The following certs all fail with CRYPT_E_ASN1_CORRUPT or * CRYPT_E_ASN1_BADTAG, because at a minimum a cert must have a non-zero * serial number, an issuer, a subject, and a public key. */ for (i = 0; i < ARRAY_SIZE(corruptCerts); i++) { - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, corruptCerts[i], corruptCerts[i][1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret, "Expected failure\n"); @@ -3379,7 +3284,7 @@ static void test_decodeCertToBeSigned(DWORD dwEncoding) /* The following succeeds, even though v1 certs are not allowed to have * extensions. */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, v1CertWithSubjectKeyId, sizeof(v1CertWithSubjectKeyId), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -3397,7 +3302,7 @@ static void test_decodeCertToBeSigned(DWORD dwEncoding) /* The following also succeeds, even though V1 certs are not allowed to * have issuer unique ids. */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, v1CertWithSubjectIssuerSerialAndIssuerUniqueId, sizeof(v1CertWithSubjectIssuerSerialAndIssuerUniqueId), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); @@ -3416,7 +3321,7 @@ static void test_decodeCertToBeSigned(DWORD dwEncoding) LocalFree(buf); } /* Now check with serial number, subject and issuer specified */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, bigCert, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, bigCert, sizeof(bigCert), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -3440,7 +3345,7 @@ static void test_decodeCertToBeSigned(DWORD dwEncoding) LocalFree(buf); } /* Check again with pub key specified */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, v1CertWithPubKey, sizeof(v1CertWithPubKey), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -3560,7 +3465,7 @@ static void test_encodeCert(DWORD dwEncoding) BYTE *buf = NULL; DWORD bufSize = 0;
- ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -3577,7 +3482,7 @@ static void test_decodeCert(DWORD dwEncoding) BYTE *buf = NULL; DWORD size = 0;
- ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT, signedBigCert, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT, signedBigCert, sizeof(signedBigCert), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -3595,7 +3500,7 @@ static void test_decodeCert(DWORD dwEncoding) LocalFree(buf); } /* A signed cert decodes as a CERT_INFO too */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, signedBigCert, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, signedBigCert, sizeof(signedBigCert), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -3618,7 +3523,7 @@ static void test_decodeCert(DWORD dwEncoding) info->Subject.cbData), "Unexpected subject\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, signedBigCertWithIndefiniteSeq, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, signedBigCertWithIndefiniteSeq, sizeof(signedBigCertWithIndefiniteSeq), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -3670,14 +3575,14 @@ static void test_encodeCRLDistPoints(DWORD dwEncoding) DWORD size = 0;
/* Test with an empty info */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* Test with one empty dist point */ info.cDistPoint = 1; info.rgDistPoint = &point; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -3692,7 +3597,7 @@ static void test_encodeCRLDistPoints(DWORD dwEncoding) U(entry).pwszURL = (WCHAR *)L"http://%5Cx226f%5Cx575b"; U(point.DistPointName).FullName.cAltEntry = 1; U(point.DistPointName).FullName.rgAltEntry = &entry; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_IA5_STRING, "Expected CRYPT_E_INVALID_IA5_STRING, got %08lx\n", GetLastError()); @@ -3702,7 +3607,7 @@ static void test_encodeCRLDistPoints(DWORD dwEncoding) GET_CERT_ALT_NAME_VALUE_ERR_INDEX(size)); /* A dist point with (just) a valid name */ U(entry).pwszURL = (LPWSTR)url; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -3715,7 +3620,7 @@ static void test_encodeCRLDistPoints(DWORD dwEncoding) point.DistPointName.dwDistPointNameChoice = CRL_DIST_POINT_NO_NAME; point.ReasonFlags.cbData = sizeof(crlReason); point.ReasonFlags.pbData = (LPBYTE)&crlReason; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -3728,7 +3633,7 @@ static void test_encodeCRLDistPoints(DWORD dwEncoding) point.ReasonFlags.cbData = 0; point.CRLIssuer.cAltEntry = 1; point.CRLIssuer.rgAltEntry = &entry; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -3739,7 +3644,7 @@ static void test_encodeCRLDistPoints(DWORD dwEncoding) } /* A dist point with both a name and an issuer */ point.DistPointName.dwDistPointNameChoice = CRL_DIST_POINT_FULL_NAME; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -3760,7 +3665,7 @@ static void test_decodeCRLDistPoints(DWORD dwEncoding) PCRL_DIST_POINT point; PCERT_ALT_NAME_ENTRY entry;
- ret = pCryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, + ret = CryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, emptyDistPoint, emptyDistPoint[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -3779,7 +3684,7 @@ static void test_decodeCRLDistPoints(DWORD dwEncoding) ok(point->CRLIssuer.cAltEntry == 0, "Expected no issuer\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, + ret = CryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, distPointWithUrl, distPointWithUrl[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -3806,7 +3711,7 @@ static void test_decodeCRLDistPoints(DWORD dwEncoding) ok(point->CRLIssuer.cAltEntry == 0, "Expected no issuer\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, + ret = CryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, distPointWithReason, distPointWithReason[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -3829,7 +3734,7 @@ static void test_decodeCRLDistPoints(DWORD dwEncoding) ok(point->CRLIssuer.cAltEntry == 0, "Expected no issuer\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, + ret = CryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, distPointWithUrlAndIssuer, distPointWithUrlAndIssuer[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -3861,14 +3766,14 @@ static void test_decodeCRLDistPoints(DWORD dwEncoding) ok(!lstrcmpW(U(*entry).pwszURL, url), "Unexpected name\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, + ret = CryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, distPointWithUrlAndIssuer, distPointWithUrlAndIssuer[1] + 2, 0, NULL, NULL, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); if (buf) { - ret = pCryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, + ret = CryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, distPointWithUrlAndIssuer, distPointWithUrlAndIssuer[1] + 2, 0, NULL, buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -3890,16 +3795,11 @@ static void test_encodeCRLIssuingDistPoint(DWORD dwEncoding) CRL_ISSUING_DIST_POINT point = { { 0 } }; CERT_ALT_NAME_ENTRY entry;
- ret = pCryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, NULL, + ret = CryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, NULL, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - skip("no X509_ISSUING_DIST_POINT encode support\n"); - return; - } ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); - ret = pCryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, + ret = CryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -3911,7 +3811,7 @@ static void test_encodeCRLIssuingDistPoint(DWORD dwEncoding) /* nonsensical flags */ point.fOnlyContainsUserCerts = TRUE; point.fOnlyContainsCACerts = TRUE; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, + ret = CryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -3923,14 +3823,14 @@ static void test_encodeCRLIssuingDistPoint(DWORD dwEncoding) /* unimplemented name type */ point.fOnlyContainsCACerts = point.fOnlyContainsUserCerts = FALSE; point.DistPointName.dwDistPointNameChoice = CRL_DIST_POINT_ISSUER_RDN_NAME; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, + ret = CryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* empty name */ point.DistPointName.dwDistPointNameChoice = CRL_DIST_POINT_FULL_NAME; U(point.DistPointName).FullName.cAltEntry = 0; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, + ret = CryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -3944,7 +3844,7 @@ static void test_encodeCRLIssuingDistPoint(DWORD dwEncoding) U(entry).pwszURL = (LPWSTR)url; U(point.DistPointName).FullName.cAltEntry = 1; U(point.DistPointName).FullName.rgAltEntry = &entry; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, + ret = CryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -4029,21 +3929,16 @@ static void test_decodeCRLIssuingDistPoint(DWORD dwEncoding) DWORD size = 0; CRL_ISSUING_DIST_POINT point = { { 0 } };
- ret = pCryptDecodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, + ret = CryptDecodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, emptySequence, emptySequence[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - skip("no X509_ISSUING_DIST_POINT decode support\n"); - return; - } ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { compareCRLIssuingDistPoints(&point, (PCRL_ISSUING_DIST_POINT)buf); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, + ret = CryptDecodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, badFlagsIDP, badFlagsIDP[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -4053,7 +3948,7 @@ static void test_decodeCRLIssuingDistPoint(DWORD dwEncoding) compareCRLIssuingDistPoints(&point, (PCRL_ISSUING_DIST_POINT)buf); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, + ret = CryptDecodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, emptyNameIDP, emptyNameIDP[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -4065,7 +3960,7 @@ static void test_decodeCRLIssuingDistPoint(DWORD dwEncoding) compareCRLIssuingDistPoints(&point, (PCRL_ISSUING_DIST_POINT)buf); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, + ret = CryptDecodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, urlIDP, urlIDP[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -4135,10 +4030,9 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding) CRL_ENTRY entry = { { 0 }, { 0 }, 0, 0 };
/* Test with a V1 CRL */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */), - "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(size == sizeof(v1CRL), "Wrong size %ld\n", size); @@ -4147,10 +4041,9 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding) } /* Test v2 CRL */ info.dwVersion = CRL_V2; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */), - "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(size == v2CRL[1] + 2, "Expected size %d, got %ld\n", @@ -4162,7 +4055,7 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding) info.dwVersion = CRL_V1; info.Issuer.cbData = sizeof(encodedCommonName); info.Issuer.pbData = (BYTE *)encodedCommonName; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -4171,19 +4064,18 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding) ok(!memcmp(buf, v1CRLWithIssuer, size), "Got unexpected value\n"); LocalFree(buf); } - if (0) - { - /* v1 CRL with a name and a NULL entry pointer (crashes on win9x) */ - info.cCRLEntry = 1; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, - CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); - } + + /* v1 CRL with a name and a NULL entry pointer */ + info.cCRLEntry = 1; + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, + CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + /* now set an empty entry */ info.cCRLEntry = 1; info.rgCRLEntry = &entry; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { @@ -4196,7 +4088,7 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding) /* an entry with a serial number */ entry.SerialNumber.cbData = sizeof(serialNum); entry.SerialNumber.pbData = (BYTE *)serialNum; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { @@ -4209,7 +4101,7 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding) /* an entry with an extension */ entry.cExtension = 1; entry.rgExtension = &criticalExt; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -4222,7 +4114,7 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding) entry.cExtension = 0; info.cExtension = 1; info.rgExtension = &criticalExt; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -4234,7 +4126,7 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding) /* a v2 CRL with an extension, this time non-critical */ info.dwVersion = CRL_V2; info.rgExtension = &nonCriticalExt; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -4799,16 +4691,14 @@ static void test_decodeCRLToBeSigned(DWORD dwEncoding)
for (i = 0; i < ARRAY_SIZE(corruptCRLs); i++) { - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, corruptCRLs[i], corruptCRLs[i][1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_CORRUPT || - GetLastError() == OSS_DATA_ERROR /* Win9x */), - "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08lx\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_CORRUPT, + "Expected CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError()); } /* at a minimum, a CRL must contain an issuer: */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, v1CRLWithIssuer, v1CRLWithIssuer[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -4826,16 +4716,14 @@ static void test_decodeCRLToBeSigned(DWORD dwEncoding) LocalFree(buf); } /* check decoding with an empty CRL entry */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, v1CRLWithIssuerAndEmptyEntry, v1CRLWithIssuerAndEmptyEntry[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_CORRUPT || - GetLastError() == OSS_DATA_ERROR /* Win9x */ || - GetLastError() == CRYPT_E_BAD_ENCODE /* Win8 */), - "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08lx\n", + ok(!ret && (GetLastError() == CRYPT_E_ASN1_CORRUPT || GetLastError() == CRYPT_E_BAD_ENCODE), + "Expected CRYPT_E_ASN1_CORRUPT or CRYPT_E_BAD_ENCODE, got %08lx\n", GetLastError()); /* with a real CRL entry */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, v1CRLWithIssuerAndEntry, v1CRLWithIssuerAndEntry[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -4862,7 +4750,7 @@ static void test_decodeCRLToBeSigned(DWORD dwEncoding) LocalFree(buf); } /* a real CRL from verisign that has extensions */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, verisignCRL, sizeof(verisignCRL), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -4879,7 +4767,7 @@ static void test_decodeCRLToBeSigned(DWORD dwEncoding) LocalFree(buf); } /* another real CRL from verisign that has lots of entries */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, verisignCRLWithLotsOfEntries, sizeof(verisignCRLWithLotsOfEntries), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -4895,7 +4783,7 @@ static void test_decodeCRLToBeSigned(DWORD dwEncoding) LocalFree(buf); } /* and finally, with an extension */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, v1CRLWithExt, sizeof(v1CRLWithExt), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -4923,7 +4811,7 @@ static void test_decodeCRLToBeSigned(DWORD dwEncoding) info->cExtension); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, v2CRLWithExt, sizeof(v2CRLWithExt), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -4953,7 +4841,7 @@ static void test_encodeEnhancedKeyUsage(DWORD dwEncoding)
/* Test with empty usage */ usage.cUsageIdentifier = 0; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, &usage, + ret = CryptEncodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, &usage, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -4965,7 +4853,7 @@ static void test_encodeEnhancedKeyUsage(DWORD dwEncoding) /* Test with a few usages */ usage.cUsageIdentifier = ARRAY_SIZE(keyUsages); usage.rgpszUsageIdentifier = (LPSTR *)keyUsages; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, &usage, + ret = CryptEncodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, &usage, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -4982,7 +4870,7 @@ static void test_decodeEnhancedKeyUsage(DWORD dwEncoding) LPBYTE buf = NULL; DWORD size = 0;
- ret = pCryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, + ret = CryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -4996,7 +4884,7 @@ static void test_decodeEnhancedKeyUsage(DWORD dwEncoding) usage->cUsageIdentifier); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, + ret = CryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, encodedUsage, sizeof(encodedUsage), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -5015,13 +4903,13 @@ static void test_decodeEnhancedKeyUsage(DWORD dwEncoding) usage->rgpszUsageIdentifier[i]); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, + ret = CryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, encodedUsage, sizeof(encodedUsage), 0, NULL, NULL, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); if (buf) { - ret = pCryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, + ret = CryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, encodedUsage, sizeof(encodedUsage), 0, NULL, buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); HeapFree(GetProcessHeap(), 0, buf); @@ -5044,7 +4932,7 @@ static void test_encodeAuthorityKeyId(DWORD dwEncoding) DWORD size = 0;
/* Test with empty id */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -5056,7 +4944,7 @@ static void test_encodeAuthorityKeyId(DWORD dwEncoding) /* With just a key id */ info.KeyId.cbData = sizeof(keyId); info.KeyId.pbData = keyId; - ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -5069,7 +4957,7 @@ static void test_encodeAuthorityKeyId(DWORD dwEncoding) info.KeyId.cbData = 0; info.CertIssuer.cbData = sizeof(encodedCommonName); info.CertIssuer.pbData = (BYTE *)encodedCommonName; - ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -5083,7 +4971,7 @@ static void test_encodeAuthorityKeyId(DWORD dwEncoding) info.CertIssuer.cbData = 0; info.CertSerialNumber.cbData = sizeof(serialNum); info.CertSerialNumber.pbData = (BYTE *)serialNum; - ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -5101,7 +4989,7 @@ static void test_decodeAuthorityKeyId(DWORD dwEncoding) LPBYTE buf = NULL; DWORD size = 0;
- ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, + ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -5116,7 +5004,7 @@ static void test_decodeAuthorityKeyId(DWORD dwEncoding) ok(info->CertSerialNumber.cbData == 0, "Expected no serial number\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, + ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, authorityKeyIdWithId, sizeof(authorityKeyIdWithId), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -5133,7 +5021,7 @@ static void test_decodeAuthorityKeyId(DWORD dwEncoding) ok(info->CertSerialNumber.cbData == 0, "Expected no serial number\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, + ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, authorityKeyIdWithIssuer, sizeof(authorityKeyIdWithIssuer), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -5151,7 +5039,7 @@ static void test_decodeAuthorityKeyId(DWORD dwEncoding) ok(info->CertSerialNumber.cbData == 0, "Expected no serial number\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, + ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, authorityKeyIdWithSerial, sizeof(authorityKeyIdWithSerial), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -5184,7 +5072,7 @@ static void test_encodeAuthorityKeyId2(DWORD dwEncoding) DWORD size = 0;
/* Test with empty id */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -5196,7 +5084,7 @@ static void test_encodeAuthorityKeyId2(DWORD dwEncoding) /* With just a key id */ info.KeyId.cbData = sizeof(keyId); info.KeyId.pbData = keyId; - ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -5210,14 +5098,14 @@ static void test_encodeAuthorityKeyId2(DWORD dwEncoding) info.KeyId.cbData = 0; info.AuthorityCertIssuer.cAltEntry = 1; info.AuthorityCertIssuer.rgAltEntry = &entry; - ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* With an issuer name */ entry.dwAltNameChoice = CERT_ALT_NAME_URL; U(entry).pwszURL = (LPWSTR)url; - ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -5232,7 +5120,7 @@ static void test_encodeAuthorityKeyId2(DWORD dwEncoding) info.AuthorityCertIssuer.cAltEntry = 0; info.AuthorityCertSerialNumber.cbData = sizeof(serialNum); info.AuthorityCertSerialNumber.pbData = (BYTE *)serialNum; - ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -5250,7 +5138,7 @@ static void test_decodeAuthorityKeyId2(DWORD dwEncoding) LPBYTE buf = NULL; DWORD size = 0;
- ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, + ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -5267,7 +5155,7 @@ static void test_decodeAuthorityKeyId2(DWORD dwEncoding) "Expected no serial number\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, + ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, authorityKeyIdWithId, sizeof(authorityKeyIdWithId), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -5286,7 +5174,7 @@ static void test_decodeAuthorityKeyId2(DWORD dwEncoding) "Expected no serial number\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, + ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, authorityKeyIdWithIssuerUrl, sizeof(authorityKeyIdWithIssuerUrl), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -5309,7 +5197,7 @@ static void test_decodeAuthorityKeyId2(DWORD dwEncoding) "Expected no serial number\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, + ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, authorityKeyIdWithSerial, sizeof(authorityKeyIdWithSerial), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -5352,7 +5240,7 @@ static void test_encodeAuthorityInfoAccess(DWORD dwEncoding) aia.cAccDescr = 0; aia.rgAccDescr = NULL; /* Having no access descriptions is allowed */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia, + ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -5365,21 +5253,20 @@ static void test_encodeAuthorityInfoAccess(DWORD dwEncoding) /* It can't have an empty access method */ aia.cAccDescr = 1; aia.rgAccDescr = accessDescription; - ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia, + ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && (GetLastError() == E_INVALIDARG || - GetLastError() == OSS_LIMITED /* Win9x */), - "expected E_INVALIDARG or OSS_LIMITED, got %08lx\n", GetLastError()); + ok(!ret && GetLastError() == E_INVALIDARG, + "expected E_INVALIDARG, got %08lx\n", GetLastError()); /* It can't have an empty location */ accessDescription[0].pszAccessMethod = oid1; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia, + ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == E_INVALIDARG, "expected E_INVALIDARG, got %08lx\n", GetLastError()); accessDescription[0].AccessLocation.dwAltNameChoice = CERT_ALT_NAME_URL; U(accessDescription[0].AccessLocation).pwszURL = (LPWSTR)url; - ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia, + ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -5399,7 +5286,7 @@ static void test_encodeAuthorityInfoAccess(DWORD dwEncoding) U(accessDescription[1].AccessLocation).IPAddress.pbData = (LPBYTE)encodedIPAddr; aia.cAccDescr = 2; - ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia, + ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -5441,7 +5328,7 @@ static void test_decodeAuthorityInfoAccess(DWORD dwEncoding) LPBYTE buf = NULL; DWORD size = 0;
- ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, + ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); @@ -5454,7 +5341,7 @@ static void test_decodeAuthorityInfoAccess(DWORD dwEncoding) LocalFree(buf); buf = NULL; } - ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, + ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, authorityInfoAccessWithUrl, sizeof(authorityInfoAccessWithUrl), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); @@ -5473,7 +5360,7 @@ static void test_decodeAuthorityInfoAccess(DWORD dwEncoding) LocalFree(buf); buf = NULL; } - ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, + ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, authorityInfoAccessWithUrlAndIPAddr, sizeof(authorityInfoAccessWithUrlAndIPAddr), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); @@ -5500,14 +5387,14 @@ static void test_decodeAuthorityInfoAccess(DWORD dwEncoding) LocalFree(buf); buf = NULL; } - ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, + ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, authorityInfoAccessWithUrlAndIPAddr, sizeof(authorityInfoAccessWithUrlAndIPAddr), 0, NULL, NULL, &size); ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); if (buf) { - ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, + ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, authorityInfoAccessWithUrlAndIPAddr, sizeof(authorityInfoAccessWithUrlAndIPAddr), 0, NULL, buf, &size); ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); @@ -5570,7 +5457,7 @@ static void test_encodeCTL(DWORD dwEncoding) CRYPT_ATTR_BLOB value1, value2;
memset(&info, 0, sizeof(info)); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -5581,7 +5468,7 @@ static void test_encodeCTL(DWORD dwEncoding) buf = NULL; } info.dwVersion = 1; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -5594,7 +5481,7 @@ static void test_encodeCTL(DWORD dwEncoding) info.dwVersion = 0; info.SubjectUsage.cUsageIdentifier = 1; info.SubjectUsage.rgpszUsageIdentifier = &pOid1; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -5608,7 +5495,7 @@ static void test_encodeCTL(DWORD dwEncoding) info.SubjectUsage.cUsageIdentifier = 0; info.ListIdentifier.cbData = sizeof(serialNum); info.ListIdentifier.pbData = (LPBYTE)serialNum; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -5621,7 +5508,7 @@ static void test_encodeCTL(DWORD dwEncoding) info.ListIdentifier.cbData = 0; info.SequenceNumber.cbData = sizeof(serialNum); info.SequenceNumber.pbData = (LPBYTE)serialNum; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -5634,7 +5521,7 @@ static void test_encodeCTL(DWORD dwEncoding) } info.SequenceNumber.cbData = 0; SystemTimeToFileTime(&thisUpdate, &info.ThisUpdate); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -5645,7 +5532,7 @@ static void test_encodeCTL(DWORD dwEncoding) buf = NULL; } SystemTimeToFileTime(&thisUpdate, &info.NextUpdate); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -5659,7 +5546,7 @@ static void test_encodeCTL(DWORD dwEncoding) info.ThisUpdate.dwLowDateTime = info.ThisUpdate.dwHighDateTime = 0; info.NextUpdate.dwLowDateTime = info.NextUpdate.dwHighDateTime = 0; info.SubjectAlgorithm.pszObjId = oid2; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -5684,7 +5571,7 @@ static void test_encodeCTL(DWORD dwEncoding) ctlEntry[0].rgAttribute = &attr1; info.cCTLEntry = 1; info.rgCTLEntry = ctlEntry; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -5696,7 +5583,7 @@ static void test_encodeCTL(DWORD dwEncoding) } value1.cbData = sizeof(emptySequence); value1.pbData = (LPBYTE)emptySequence; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -5716,7 +5603,7 @@ static void test_encodeCTL(DWORD dwEncoding) ctlEntry[1].cAttribute = 1; ctlEntry[1].rgAttribute = &attr2; info.cCTLEntry = 2; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -5906,7 +5793,7 @@ static void test_decodeCTL(DWORD dwEncoding) CRYPT_ATTR_BLOB value1, value2;
memset(&info, 0, sizeof(info)); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, emptyCTL, sizeof(emptyCTL), + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CTL, emptyCTL, sizeof(emptyCTL), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -5916,7 +5803,7 @@ static void test_decodeCTL(DWORD dwEncoding) buf = NULL; } info.dwVersion = 1; - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, emptyCTLWithVersion1, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CTL, emptyCTLWithVersion1, sizeof(emptyCTLWithVersion1), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -5929,7 +5816,7 @@ static void test_decodeCTL(DWORD dwEncoding) info.dwVersion = 0; info.SubjectUsage.cUsageIdentifier = 1; info.SubjectUsage.rgpszUsageIdentifier = &pOid1; - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithUsageIdentifier, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithUsageIdentifier, sizeof(ctlWithUsageIdentifier), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -5942,7 +5829,7 @@ static void test_decodeCTL(DWORD dwEncoding) info.SubjectUsage.cUsageIdentifier = 0; info.ListIdentifier.cbData = sizeof(serialNum); info.ListIdentifier.pbData = (LPBYTE)serialNum; - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithListIdentifier, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithListIdentifier, sizeof(ctlWithListIdentifier), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -5954,7 +5841,7 @@ static void test_decodeCTL(DWORD dwEncoding) info.ListIdentifier.cbData = 0; info.SequenceNumber.cbData = sizeof(serialNum); info.SequenceNumber.pbData = (LPBYTE)serialNum; - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithSequenceNumber, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithSequenceNumber, sizeof(ctlWithSequenceNumber), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -5965,7 +5852,7 @@ static void test_decodeCTL(DWORD dwEncoding) } info.SequenceNumber.cbData = 0; SystemTimeToFileTime(&thisUpdate, &info.ThisUpdate); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithThisUpdate, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithThisUpdate, sizeof(ctlWithThisUpdate), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -5975,7 +5862,7 @@ static void test_decodeCTL(DWORD dwEncoding) buf = NULL; } SystemTimeToFileTime(&thisUpdate, &info.NextUpdate); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithThisAndNextUpdate, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithThisAndNextUpdate, sizeof(ctlWithThisAndNextUpdate), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -5990,7 +5877,7 @@ static void test_decodeCTL(DWORD dwEncoding) info.SubjectAlgorithm.pszObjId = oid2; info.SubjectAlgorithm.Parameters.cbData = sizeof(nullData); info.SubjectAlgorithm.Parameters.pbData = nullData; - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithAlgId, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithAlgId, sizeof(ctlWithAlgId), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -6000,12 +5887,9 @@ static void test_decodeCTL(DWORD dwEncoding) buf = NULL; } SetLastError(0xdeadbeef); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithBogusEntry, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithBogusEntry, sizeof(ctlWithBogusEntry), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && - (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == CRYPT_E_ASN1_CORRUPT || - GetLastError() == OSS_MORE_INPUT), /* Win9x */ + ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD || GetLastError() == CRYPT_E_ASN1_CORRUPT), "expected CRYPT_E_ASN1_EOD or CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError()); info.SubjectAlgorithm.Parameters.cbData = 0; @@ -6024,7 +5908,7 @@ static void test_decodeCTL(DWORD dwEncoding) info.cCTLEntry = 1; info.rgCTLEntry = ctlEntry; SetLastError(0xdeadbeef); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithOneEntry, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithOneEntry, sizeof(ctlWithOneEntry), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -6043,7 +5927,7 @@ static void test_decodeCTL(DWORD dwEncoding) ctlEntry[1].cAttribute = 1; ctlEntry[1].rgAttribute = &attr2; info.cCTLEntry = 2; - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithTwoEntries, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithTwoEntries, sizeof(ctlWithTwoEntries), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -6054,20 +5938,16 @@ static void test_decodeCTL(DWORD dwEncoding) } /* A signed CTL isn't decodable, even if the inner content is a CTL */ SetLastError(0xdeadbeef); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, signedCTL, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CTL, signedCTL, sizeof(signedCTL), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_DATA_ERROR /* Win9x */), - "expected CRYPT_E_ASN1_BADTAG or OSS_DATA_ERROR, got %08lx\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CTL, signedCTLWithCTLInnerContent, sizeof(signedCTLWithCTLInnerContent), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_DATA_ERROR /* Win9x */), - "expected CRYPT_E_ASN1_BADTAG or OSS_DATA_ERROR, got %08lx\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); }
static const BYTE emptyPKCSContentInfo[] = { 0x30,0x04,0x06,0x02,0x2a,0x03 }; @@ -6087,23 +5967,19 @@ static void test_encodePKCSContentInfo(DWORD dwEncoding) CRYPT_CONTENT_INFO info = { 0 }; char oid1[] = "1.2.3";
- if (0) - { - /* Crashes on win9x */ - SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, NULL, - CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %lx\n", GetLastError()); - } SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, NULL, + CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %lx\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && (GetLastError() == E_INVALIDARG || - GetLastError() == OSS_LIMITED /* Win9x */), - "Expected E_INVALIDARG or OSS_LIMITED, got %lx\n", GetLastError()); + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %lx\n", GetLastError()); info.pszObjId = oid1; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError()); if (ret) @@ -6114,7 +5990,7 @@ static void test_encodePKCSContentInfo(DWORD dwEncoding) } info.Content.pbData = bogusDER; info.Content.cbData = sizeof(bogusDER); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed; %lx\n", GetLastError()); if (ret) @@ -6125,7 +6001,7 @@ static void test_encodePKCSContentInfo(DWORD dwEncoding) } info.Content.pbData = (BYTE *)ints[0].encoded; info.Content.cbData = ints[0].encoded[1] + 2; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { @@ -6220,7 +6096,7 @@ static void test_decodePKCSContentInfo(DWORD dwEncoding)
for (i = 0; i < ARRAY_SIZE(tests); i++) { - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, tests[i].encoded, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, tests[i].encoded, tests[i].encoded_size, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "[%lu] CryptDecodeObjectEx failed: %lx\n", i, GetLastError()); if (!ret) continue; @@ -6238,14 +6114,14 @@ static void test_decodePKCSContentInfo(DWORD dwEncoding) LocalFree(buf); }
- ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, bogusPKCSContentInfo, sizeof(bogusPKCSContentInfo), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); /* Native fails with CRYPT_E_ASN1_EOD, accept also CRYPT_E_ASN1_CORRUPT as * I doubt an app depends on that. */ - ok((!ret && (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == CRYPT_E_ASN1_CORRUPT)) || broken(ret), + ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD || + GetLastError() == CRYPT_E_ASN1_CORRUPT), "Expected CRYPT_E_ASN1_EOD or CRYPT_E_ASN1_CORRUPT, got %lx\n", GetLastError()); } @@ -6266,23 +6142,19 @@ static void test_encodePKCSAttribute(DWORD dwEncoding) CRYPT_ATTR_BLOB blob; char oid[] = "1.2.3";
- if (0) - { - /* Crashes on win9x */ - SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, NULL, - CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %lx\n", GetLastError()); - } SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, NULL, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && (GetLastError() == E_INVALIDARG || - GetLastError() == OSS_LIMITED /* Win9x */), - "Expected E_INVALIDARG or OSS_LIMITED, got %lx\n", GetLastError()); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %lx\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr, + CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %lx\n", GetLastError()); attr.pszObjId = oid; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError()); if (ret) @@ -6295,7 +6167,7 @@ static void test_encodePKCSAttribute(DWORD dwEncoding) blob.pbData = bogusDER; attr.cValue = 1; attr.rgValue = &blob; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError()); if (ret) @@ -6306,7 +6178,7 @@ static void test_encodePKCSAttribute(DWORD dwEncoding) } blob.pbData = (BYTE *)ints[0].encoded; blob.cbData = ints[0].encoded[1] + 2; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { @@ -6323,7 +6195,7 @@ static void test_decodePKCSAttribute(DWORD dwEncoding) DWORD size = 0; CRYPT_ATTRIBUTE *attr;
- ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, emptyPKCSAttr, sizeof(emptyPKCSAttr), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); @@ -6337,18 +6209,16 @@ static void test_decodePKCSAttribute(DWORD dwEncoding) LocalFree(buf); } SetLastError(0xdeadbeef); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, bogusPKCSAttr, sizeof(bogusPKCSAttr), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); /* Native fails with CRYPT_E_ASN1_EOD, accept also CRYPT_E_ASN1_CORRUPT as * I doubt an app depends on that. */ - ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == CRYPT_E_ASN1_CORRUPT || - GetLastError() == OSS_MORE_INPUT /* Win9x */), - "Expected CRYPT_E_ASN1_EOD, CRYPT_E_ASN1_CORRUPT, or OSS_MORE_INPUT, got %lx\n", + ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD || GetLastError() == CRYPT_E_ASN1_CORRUPT), + "Expected CRYPT_E_ASN1_EOD, CRYPT_E_ASN1_CORRUPT, got %lx\n", GetLastError()); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, intPKCSAttr, sizeof(intPKCSAttr), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); @@ -6383,7 +6253,7 @@ static void test_encodePKCSAttributes(DWORD dwEncoding) DWORD size = 0; char oid1[] = "1.2.3", oid2[] = "1.5.6";
- ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError()); if (ret) @@ -6395,13 +6265,12 @@ static void test_encodePKCSAttributes(DWORD dwEncoding) attributes.cAttr = 1; attributes.rgAttr = attr; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && (GetLastError() == E_INVALIDARG || - GetLastError() == OSS_LIMITED /* Win9x */), - "Expected E_INVALIDARG or OSS_LIMITED, got %08lx\n", GetLastError()); + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); attr[0].pszObjId = oid1; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { @@ -6415,7 +6284,7 @@ static void test_encodePKCSAttributes(DWORD dwEncoding) blob.pbData = (BYTE *)ints[0].encoded; blob.cbData = ints[0].encoded[1] + 2; attributes.cAttr = 2; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError()); if (ret) @@ -6433,7 +6302,7 @@ static void test_decodePKCSAttributes(DWORD dwEncoding) DWORD size = 0; CRYPT_ATTRIBUTES *attributes;
- ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, emptyPKCSAttributes, sizeof(emptyPKCSAttributes), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); @@ -6444,7 +6313,7 @@ static void test_decodePKCSAttributes(DWORD dwEncoding) attributes->cAttr); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, singlePKCSAttributes, sizeof(singlePKCSAttributes), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); @@ -6459,7 +6328,7 @@ static void test_decodePKCSAttributes(DWORD dwEncoding) "Expected no attributes, got %ld\n", attributes->rgAttr[0].cValue); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, doublePKCSAttributes, sizeof(doublePKCSAttributes), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); @@ -6482,13 +6351,13 @@ static void test_decodePKCSAttributes(DWORD dwEncoding) attributes->rgAttr[1].rgValue[0].cbData), "Unexpected value\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, doublePKCSAttributes, sizeof(doublePKCSAttributes), 0, NULL, NULL, &size); ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); if (buf) { - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, doublePKCSAttributes, sizeof(doublePKCSAttributes), 0, NULL, buf, &size); ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); HeapFree(GetProcessHeap(), 0, buf); @@ -6513,7 +6382,7 @@ static void test_encodePKCSSMimeCapabilities(DWORD dwEncoding)
/* An empty capabilities is allowed */ capabilities.cCapability = 0; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, &capabilities, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -6530,13 +6399,12 @@ static void test_encodePKCSSMimeCapabilities(DWORD dwEncoding) capabilities.cCapability = 1; capabilities.rgCapability = capability; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, &capabilities, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && (GetLastError() == E_INVALIDARG || - GetLastError() == OSS_LIMITED /* Win9x */), - "Expected E_INVALIDARG or OSS_LIMITED, got %08lx\n", GetLastError()); + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); capability[0].pszObjId = oid1; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, &capabilities, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -6548,7 +6416,7 @@ static void test_encodePKCSSMimeCapabilities(DWORD dwEncoding) capability[1].pszObjId = oid2; capability[1].Parameters.cbData = 0; capabilities.cCapability = 2; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, &capabilities, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -6595,7 +6463,7 @@ static void test_decodePKCSSMimeCapabilities(DWORD dwEncoding) CRYPT_SMIME_CAPABILITIES capabilities, *ptr;
SetLastError(0xdeadbeef); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL, &ptr, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -6606,7 +6474,7 @@ static void test_decodePKCSSMimeCapabilities(DWORD dwEncoding) LocalFree(ptr); } SetLastError(0xdeadbeef); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, singleCapability, sizeof(singleCapability), CRYPT_DECODE_ALLOC_FLAG, NULL, &ptr, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -6620,7 +6488,7 @@ static void test_decodePKCSSMimeCapabilities(DWORD dwEncoding) LocalFree(ptr); } SetLastError(0xdeadbeef); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, singleCapabilitywithNULL, sizeof(singleCapabilitywithNULL), CRYPT_DECODE_ALLOC_FLAG, NULL, &ptr, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -6637,7 +6505,7 @@ static void test_decodePKCSSMimeCapabilities(DWORD dwEncoding) LocalFree(ptr); } SetLastError(0xdeadbeef); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, twoCapabilities, sizeof(twoCapabilities), CRYPT_DECODE_ALLOC_FLAG, NULL, &ptr, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -6651,14 +6519,14 @@ static void test_decodePKCSSMimeCapabilities(DWORD dwEncoding) LocalFree(ptr); } SetLastError(0xdeadbeef); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, twoCapabilities, sizeof(twoCapabilities), 0, NULL, NULL, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); ptr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); if (ptr) { SetLastError(0xdeadbeef); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, twoCapabilities, sizeof(twoCapabilities), 0, NULL, ptr, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); HeapFree(GetProcessHeap(), 0, ptr); @@ -6715,16 +6583,10 @@ static void test_encodePKCSSignerInfo(DWORD dwEncoding) CRYPT_ATTRIBUTE attr = { oid_common_name, 1, &commonName };
SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - skip("no PKCS7_SIGNER_INFO encode support\n"); - return; - } - ok(!ret && (GetLastError() == E_INVALIDARG || - GetLastError() == OSS_LIMITED /* Win9x */), - "Expected E_INVALIDARG or OSS_LIMITED, got %08lx\n", GetLastError()); + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* To be encoded, a signer must have an issuer at least, and the encoding * must include PKCS_7_ASN_ENCODING. (That isn't enough to be decoded, * see decoding tests.) @@ -6732,15 +6594,14 @@ static void test_encodePKCSSignerInfo(DWORD dwEncoding) info.Issuer.cbData = sizeof(encodedCommonNameNoNull); info.Issuer.pbData = encodedCommonNameNoNull; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError()); else { - ok(ret || broken(GetLastError() == OSS_LIMITED /* Win9x */), - "CryptEncodeObjectEx failed: %lx\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError()); if (ret) { ok(size == sizeof(minimalPKCSSigner), "Unexpected size %ld\n", size); @@ -6754,15 +6615,14 @@ static void test_encodePKCSSignerInfo(DWORD dwEncoding) info.SerialNumber.cbData = sizeof(serialNum); info.SerialNumber.pbData = (BYTE *)serialNum; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError()); else { - ok(ret || broken(GetLastError() == OSS_LIMITED /* Win9x */), - "CryptEncodeObjectEx failed: %lx\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError()); if (ret) { ok(size == sizeof(PKCSSignerWithSerial), "Unexpected size %ld\n", @@ -6777,15 +6637,14 @@ static void test_encodePKCSSignerInfo(DWORD dwEncoding) } info.HashAlgorithm.pszObjId = oid1; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError()); else { - ok(ret || broken(GetLastError() == OSS_LIMITED /* Win9x */), - "CryptEncodeObjectEx failed: %lx\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError()); if (ret) { ok(size == sizeof(PKCSSignerWithHashAlgo), "Unexpected size %ld\n", @@ -6800,7 +6659,7 @@ static void test_encodePKCSSignerInfo(DWORD dwEncoding) } info.HashEncryptionAlgorithm.pszObjId = oid2; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, @@ -6823,7 +6682,7 @@ static void test_encodePKCSSignerInfo(DWORD dwEncoding) info.EncryptedHash.cbData = sizeof(hash); info.EncryptedHash.pbData = (BYTE *)hash; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, @@ -6846,7 +6705,7 @@ static void test_encodePKCSSignerInfo(DWORD dwEncoding) info.AuthAttrs.cAttr = 1; info.AuthAttrs.rgAttr = &attr; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, @@ -6877,18 +6736,16 @@ static void test_decodePKCSSignerInfo(DWORD dwEncoding)
/* A PKCS signer can't be decoded without a serial number. */ SetLastError(0xdeadbeef); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, + ret = CryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, minimalPKCSSigner, sizeof(minimalPKCSSigner), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_CORRUPT || - GetLastError() == OSS_DATA_ERROR /* Win9x */), - "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %lx\n", + ok(!ret && GetLastError() == CRYPT_E_ASN1_CORRUPT, + "Expected CRYPT_E_ASN1_CORRUPT, got %lx\n", GetLastError()); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, + ret = CryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, PKCSSignerWithSerial, sizeof(PKCSSignerWithSerial), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR), - "CryptDecodeObjectEx failed: %lx\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); if (ret) { info = (CMSG_SIGNER_INFO *)buf; @@ -6904,7 +6761,7 @@ static void test_decodePKCSSignerInfo(DWORD dwEncoding) "Unexpected value\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, + ret = CryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, PKCSSignerWithHashAlgo, sizeof(PKCSSignerWithHashAlgo), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) @@ -6924,7 +6781,7 @@ static void test_decodePKCSSignerInfo(DWORD dwEncoding) "Expected 1.2.3, got %s\n", info->HashAlgorithm.pszObjId); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, + ret = CryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, PKCSSignerWithHashAndEncryptionAlgo, sizeof(PKCSSignerWithHashAndEncryptionAlgo), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); @@ -6947,7 +6804,7 @@ static void test_decodePKCSSignerInfo(DWORD dwEncoding) "Expected 1.5.6, got %s\n", info->HashEncryptionAlgorithm.pszObjId); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, + ret = CryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, PKCSSignerWithHash, sizeof(PKCSSignerWithHash), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) @@ -6973,7 +6830,7 @@ static void test_decodePKCSSignerInfo(DWORD dwEncoding) "Unexpected value\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, + ret = CryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, PKCSSignerWithAuthAttr, sizeof(PKCSSignerWithAuthAttr), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) @@ -7008,26 +6865,16 @@ static void test_encodeCMSSignerInfo(DWORD dwEncoding) static char oid1[] = "1.2.3", oid2[] = "1.5.6";
SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret, "Expected failure, got %d\n", ret); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - skip("no CMS_SIGNER_INFO encode support\n"); - return; - } ok(GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError()); info.SignerId.dwIdChoice = CERT_ID_ISSUER_SERIAL_NUMBER; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret, "Expected failure, got %d\n", ret); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - skip("no CMS_SIGNER_INFO encode support\n"); - return; - } ok(GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* To be encoded, a signer must have a valid cert ID, where a valid ID may @@ -7039,7 +6886,7 @@ static void test_encodeCMSSignerInfo(DWORD dwEncoding) sizeof(encodedCommonNameNoNull); U(info.SignerId).IssuerSerialNumber.Issuer.pbData = encodedCommonNameNoNull; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, @@ -7057,7 +6904,7 @@ static void test_encodeCMSSignerInfo(DWORD dwEncoding) U(info.SignerId).IssuerSerialNumber.SerialNumber.cbData = sizeof(serialNum); U(info.SignerId).IssuerSerialNumber.SerialNumber.pbData = (BYTE *)serialNum; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, @@ -7077,7 +6924,7 @@ static void test_encodeCMSSignerInfo(DWORD dwEncoding) U(info.SignerId).KeyId.cbData = sizeof(serialNum); U(info.SignerId).KeyId.pbData = (BYTE *)serialNum; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, @@ -7101,7 +6948,7 @@ static void test_encodeCMSSignerInfo(DWORD dwEncoding) U(info.SignerId).HashId.cbData = sizeof(hash); U(info.SignerId).HashId.pbData = (BYTE *)hash; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError()); @@ -7112,7 +6959,7 @@ static void test_encodeCMSSignerInfo(DWORD dwEncoding) U(info.SignerId).IssuerSerialNumber.Issuer.pbData = encodedCommonNameNoNull; info.HashAlgorithm.pszObjId = oid1; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, @@ -7131,7 +6978,7 @@ static void test_encodeCMSSignerInfo(DWORD dwEncoding) } info.HashEncryptionAlgorithm.pszObjId = oid2; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, @@ -7151,7 +6998,7 @@ static void test_encodeCMSSignerInfo(DWORD dwEncoding) info.EncryptedHash.cbData = sizeof(hash); info.EncryptedHash.pbData = (BYTE *)hash; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, @@ -7179,18 +7026,13 @@ static void test_decodeCMSSignerInfo(DWORD dwEncoding)
/* A CMS signer can't be decoded without a serial number. */ SetLastError(0xdeadbeef); - ret = pCryptDecodeObjectEx(dwEncoding, CMS_SIGNER_INFO, + ret = CryptDecodeObjectEx(dwEncoding, CMS_SIGNER_INFO, minimalPKCSSigner, sizeof(minimalPKCSSigner), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret, "expected failure\n"); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - skip("no CMS_SIGNER_INFO decode support\n"); - return; - } ok(GetLastError() == CRYPT_E_ASN1_CORRUPT, "Expected CRYPT_E_ASN1_CORRUPT, got %lx\n", GetLastError()); - ret = pCryptDecodeObjectEx(dwEncoding, CMS_SIGNER_INFO, + ret = CryptDecodeObjectEx(dwEncoding, CMS_SIGNER_INFO, PKCSSignerWithSerial, sizeof(PKCSSignerWithSerial), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); @@ -7216,7 +7058,7 @@ static void test_decodeCMSSignerInfo(DWORD dwEncoding) serialNum, sizeof(serialNum)), "Unexpected value\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, CMS_SIGNER_INFO, + ret = CryptDecodeObjectEx(dwEncoding, CMS_SIGNER_INFO, PKCSSignerWithHashAlgo, sizeof(PKCSSignerWithHashAlgo), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); @@ -7244,7 +7086,7 @@ static void test_decodeCMSSignerInfo(DWORD dwEncoding) "Expected %s, got %s\n", oid1, info->HashAlgorithm.pszObjId); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, CMS_SIGNER_INFO, + ret = CryptDecodeObjectEx(dwEncoding, CMS_SIGNER_INFO, PKCSSignerWithHashAndEncryptionAlgo, sizeof(PKCSSignerWithHashAndEncryptionAlgo), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); @@ -7275,7 +7117,7 @@ static void test_decodeCMSSignerInfo(DWORD dwEncoding) "Expected %s, got %s\n", oid2, info->HashEncryptionAlgorithm.pszObjId); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, CMS_SIGNER_INFO, + ret = CryptDecodeObjectEx(dwEncoding, CMS_SIGNER_INFO, PKCSSignerWithHash, sizeof(PKCSSignerWithHash), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); @@ -7309,7 +7151,7 @@ static void test_decodeCMSSignerInfo(DWORD dwEncoding) "Unexpected value\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, CMS_SIGNER_INFO, + ret = CryptDecodeObjectEx(dwEncoding, CMS_SIGNER_INFO, CMSSignerWithKeyId, sizeof(CMSSignerWithKeyId), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); @@ -7358,13 +7200,8 @@ static void test_encodeNameConstraints(DWORD dwEncoding) LPBYTE buf; DWORD size;
- ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - skip("no X509_NAME_CONSTRAINTS encode support\n"); - return; - } ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { @@ -7375,12 +7212,12 @@ static void test_encodeNameConstraints(DWORD dwEncoding) constraints.cPermittedSubtree = 1; constraints.rgPermittedSubtree = &permitted; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError()); permitted.Base.dwAltNameChoice = CERT_ALT_NAME_DNS_NAME; - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -7394,7 +7231,7 @@ static void test_encodeNameConstraints(DWORD dwEncoding) constraints.cExcludedSubtree = 1; constraints.rgExcludedSubtree = &excluded; excluded.Base.dwAltNameChoice = CERT_ALT_NAME_DNS_NAME; - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -7405,7 +7242,7 @@ static void test_encodeNameConstraints(DWORD dwEncoding) LocalFree(buf); } U(excluded.Base).pwszURL = (LPWSTR)url; - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -7419,7 +7256,7 @@ static void test_encodeNameConstraints(DWORD dwEncoding) U(permitted.Base).IPAddress.cbData = sizeof(encodedIPAddr); U(permitted.Base).IPAddress.pbData = (LPBYTE)encodedIPAddr; constraints.cPermittedSubtree = 1; - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -7431,7 +7268,7 @@ static void test_encodeNameConstraints(DWORD dwEncoding) LocalFree(buf); } permitted.dwMinimum = 5; - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -7445,7 +7282,7 @@ static void test_encodeNameConstraints(DWORD dwEncoding) permitted.fMaximum = TRUE; permitted.dwMaximum = 3; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -7510,15 +7347,10 @@ static void test_decodeNameConstraints(DWORD dwEncoding) { DWORD size;
- ret = pCryptDecodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, + ret = CryptDecodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, encodedNameConstraints[i].encoded.pbData, encodedNameConstraints[i].encoded.cbData, CRYPT_DECODE_ALLOC_FLAG, NULL, &constraints, &size); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - skip("no X509_NAME_CONSTRAINTS decode support\n"); - return; - } ok(ret, "%ld: CryptDecodeObjectEx failed: %08lx\n", i, GetLastError()); if (ret) { @@ -7580,14 +7412,9 @@ static void test_encodePolicyQualifierUserNotice(DWORD dwEncoding) CERT_POLICY_QUALIFIER_NOTICE_REFERENCE reference;
memset(¬ice, 0, sizeof(notice)); - ret = pCryptEncodeObjectEx(dwEncoding, + ret = CryptEncodeObjectEx(dwEncoding, X509_PKIX_POLICY_QUALIFIER_USERNOTICE, ¬ice, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - skip("no X509_PKIX_POLICY_QUALIFIER_USERNOTICE encode support\n"); - return; - } ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { @@ -7596,7 +7423,7 @@ static void test_encodePolicyQualifierUserNotice(DWORD dwEncoding) LocalFree(buf); } notice.pszDisplayText = (WCHAR *)L"This is a notice"; - ret = pCryptEncodeObjectEx(dwEncoding, + ret = CryptEncodeObjectEx(dwEncoding, X509_PKIX_POLICY_QUALIFIER_USERNOTICE, ¬ice, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); @@ -7610,7 +7437,7 @@ static void test_encodePolicyQualifierUserNotice(DWORD dwEncoding) reference.cNoticeNumbers = 2; reference.rgNoticeNumbers = noticeNumbers; notice.pNoticeReference = &reference; - ret = pCryptEncodeObjectEx(dwEncoding, + ret = CryptEncodeObjectEx(dwEncoding, X509_PKIX_POLICY_QUALIFIER_USERNOTICE, ¬ice, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); @@ -7628,15 +7455,10 @@ static void test_decodePolicyQualifierUserNotice(DWORD dwEncoding) CERT_POLICY_QUALIFIER_USER_NOTICE *notice; DWORD size;
- ret = pCryptDecodeObjectEx(dwEncoding, + ret = CryptDecodeObjectEx(dwEncoding, X509_PKIX_POLICY_QUALIFIER_USERNOTICE, emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL, ¬ice, &size); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - skip("no X509_PKIX_POLICY_QUALIFIER_USERNOTICE decode support\n"); - return; - } ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { @@ -7644,7 +7466,7 @@ static void test_decodePolicyQualifierUserNotice(DWORD dwEncoding) ok(notice->pNoticeReference == NULL, "unexpected notice reference\n"); LocalFree(notice); } - ret = pCryptDecodeObjectEx(dwEncoding, + ret = CryptDecodeObjectEx(dwEncoding, X509_PKIX_POLICY_QUALIFIER_USERNOTICE, noticeWithDisplayText, sizeof(noticeWithDisplayText), CRYPT_DECODE_ALLOC_FLAG, NULL, ¬ice, &size); @@ -7656,7 +7478,7 @@ static void test_decodePolicyQualifierUserNotice(DWORD dwEncoding) ok(notice->pNoticeReference == NULL, "unexpected notice reference\n"); LocalFree(notice); } - ret = pCryptDecodeObjectEx(dwEncoding, + ret = CryptDecodeObjectEx(dwEncoding, X509_PKIX_POLICY_QUALIFIER_USERNOTICE, noticeWithReference, sizeof(noticeWithReference), CRYPT_DECODE_ALLOC_FLAG, NULL, ¬ice, &size); @@ -7710,7 +7532,7 @@ static void test_encodeCertPolicies(DWORD dwEncoding) DWORD size;
memset(&info, 0, sizeof(info)); - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_POLICIES, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_POLICIES, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -7722,13 +7544,12 @@ static void test_encodeCertPolicies(DWORD dwEncoding) memset(policy, 0, sizeof(policy)); info.cPolicyInfo = 1; info.rgPolicyInfo = policy; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_POLICIES, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_POLICIES, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && (GetLastError() == E_INVALIDARG || - GetLastError() == OSS_LIMITED /* Win9x/NT4 */), - "expected E_INVALIDARG or OSS_LIMITED, got %08lx\n", GetLastError()); + ok(!ret && GetLastError() == E_INVALIDARG, + "expected E_INVALIDARG, got %08lx\n", GetLastError()); policy[0].pszPolicyIdentifier = oid_any_policy; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_POLICIES, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_POLICIES, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -7745,7 +7566,7 @@ static void test_encodeCertPolicies(DWORD dwEncoding) policy[1].cPolicyQualifier = 1; policy[1].rgPolicyQualifier = &qualifier; info.cPolicyInfo = 2; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_POLICIES, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_POLICIES, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -7762,7 +7583,7 @@ static void test_decodeCertPolicies(DWORD dwEncoding) CERT_POLICIES_INFO *info; DWORD size;
- ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES, emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -7772,7 +7593,7 @@ static void test_decodeCertPolicies(DWORD dwEncoding) info->cPolicyInfo); LocalFree(info); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES, policiesWithAnyPolicy, sizeof(policiesWithAnyPolicy), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -7788,7 +7609,7 @@ static void test_decodeCertPolicies(DWORD dwEncoding) info->rgPolicyInfo[0].cPolicyQualifier); LocalFree(info); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES, twoPolicies, sizeof(twoPolicies), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -7821,13 +7642,13 @@ static void test_decodeCertPolicies(DWORD dwEncoding) "unexpected qualifier value\n"); LocalFree(info); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES, twoPolicies, sizeof(twoPolicies), 0, NULL, NULL, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); if (info) { - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES, twoPolicies, sizeof(twoPolicies), 0, NULL, info, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); HeapFree(GetProcessHeap(), 0, info); @@ -7857,15 +7678,9 @@ static void test_encodeCertPolicyMappings(DWORD dwEncoding) for (i = 0; i < ARRAY_SIZE(mappingOids); i++) { memset(&info, 0, sizeof(info)); - ret = pCryptEncodeObjectEx(dwEncoding, mappingOids[i], &info, + ret = CryptEncodeObjectEx(dwEncoding, mappingOids[i], &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret || broken(GetLastError() == ERROR_FILE_NOT_FOUND), - "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - win_skip("no policy mappings support\n"); - return; - } + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(size == sizeof(emptySequence), "unexpected size %ld\n", size); @@ -7878,13 +7693,13 @@ static void test_encodeCertPolicyMappings(DWORD dwEncoding) info.cPolicyMapping = 1; info.rgPolicyMapping = mapping; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, mappingOids[i], &info, + ret = CryptEncodeObjectEx(dwEncoding, mappingOids[i], &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == E_INVALIDARG, "expected E_INVALIDARG, got %08lx\n", GetLastError()); mapping[0].pszIssuerDomainPolicy = oid1; mapping[0].pszSubjectDomainPolicy = oid2; - ret = pCryptEncodeObjectEx(dwEncoding, mappingOids[i], &info, + ret = CryptEncodeObjectEx(dwEncoding, mappingOids[i], &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -7898,7 +7713,7 @@ static void test_encodeCertPolicyMappings(DWORD dwEncoding) mapping[1].pszIssuerDomainPolicy = oid3; mapping[1].pszSubjectDomainPolicy = oid4; info.cPolicyMapping = 2; - ret = pCryptEncodeObjectEx(dwEncoding, mappingOids[i], &info, + ret = CryptEncodeObjectEx(dwEncoding, mappingOids[i], &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -7921,23 +7736,17 @@ static void test_decodeCertPolicyMappings(DWORD dwEncoding) /* Each of the mapping OIDs is equivalent, so check with all of them */ for (i = 0; i < ARRAY_SIZE(mappingOids); i++) { - ret = pCryptDecodeObjectEx(dwEncoding, mappingOids[i], + ret = CryptDecodeObjectEx(dwEncoding, mappingOids[i], emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); - ok(ret || broken(GetLastError() == ERROR_FILE_NOT_FOUND), - "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - win_skip("no policy mappings support\n"); - return; - } + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(info->cPolicyMapping == 0, "expected 0 policy mappings, got %ld\n", info->cPolicyMapping); LocalFree(info); } - ret = pCryptDecodeObjectEx(dwEncoding, mappingOids[i], + ret = CryptDecodeObjectEx(dwEncoding, mappingOids[i], policyMappingWithOneMapping, sizeof(policyMappingWithOneMapping), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -7953,7 +7762,7 @@ static void test_decodeCertPolicyMappings(DWORD dwEncoding) info->rgPolicyMapping[0].pszSubjectDomainPolicy); LocalFree(info); } - ret = pCryptDecodeObjectEx(dwEncoding, mappingOids[i], + ret = CryptDecodeObjectEx(dwEncoding, mappingOids[i], policyMappingWithTwoMappings, sizeof(policyMappingWithTwoMappings), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -7975,14 +7784,14 @@ static void test_decodeCertPolicyMappings(DWORD dwEncoding) info->rgPolicyMapping[1].pszSubjectDomainPolicy); LocalFree(info); } - ret = pCryptDecodeObjectEx(dwEncoding, mappingOids[i], + ret = CryptDecodeObjectEx(dwEncoding, mappingOids[i], policyMappingWithTwoMappings, sizeof(policyMappingWithTwoMappings), 0, NULL, NULL, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); if (info) { - ret = pCryptDecodeObjectEx(dwEncoding, mappingOids[i], + ret = CryptDecodeObjectEx(dwEncoding, mappingOids[i], policyMappingWithTwoMappings, sizeof(policyMappingWithTwoMappings), 0, NULL, info, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -8008,15 +7817,9 @@ static void test_encodeCertPolicyConstraints(DWORD dwEncoding) /* Even though RFC 5280 explicitly states CAs must not issue empty * policy constraints (section 4.2.1.11), the API doesn't prevent it. */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret || broken(GetLastError() == ERROR_FILE_NOT_FOUND), - "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - win_skip("no policy constraints support\n"); - return; - } + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(size == sizeof(emptySequence), "unexpected size %ld\n", size); @@ -8028,7 +7831,7 @@ static void test_encodeCertPolicyConstraints(DWORD dwEncoding) * is not, then a skip of 0 is encoded. */ info.fRequireExplicitPolicy = TRUE; - ret = pCryptEncodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -8044,7 +7847,7 @@ static void test_encodeCertPolicyConstraints(DWORD dwEncoding) info.dwRequireExplicitPolicySkipCerts = 0; info.fInhibitPolicyMapping = TRUE; info.dwInhibitPolicyMappingSkipCerts = 1; - ret = pCryptEncodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -8058,7 +7861,7 @@ static void test_encodeCertPolicyConstraints(DWORD dwEncoding) /* And with both */ info.fRequireExplicitPolicy = TRUE; info.dwRequireExplicitPolicySkipCerts = 1; - ret = pCryptEncodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) @@ -8080,16 +7883,10 @@ static void test_decodeCertPolicyConstraints(DWORD dwEncoding) /* Again, even though CAs must not issue such constraints, they can be * decoded. */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, + ret = CryptDecodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); - ok(ret || broken(GetLastError() == ERROR_FILE_NOT_FOUND), - "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - win_skip("no policy mappings support\n"); - return; - } + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(!info->fRequireExplicitPolicy, @@ -8098,7 +7895,7 @@ static void test_decodeCertPolicyConstraints(DWORD dwEncoding) "expected implicit mapping = FALSE\n"); LocalFree(info); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, + ret = CryptDecodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, policyConstraintsWithRequireExplicit, sizeof(policyConstraintsWithRequireExplicit), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); @@ -8113,7 +7910,7 @@ static void test_decodeCertPolicyConstraints(DWORD dwEncoding) "expected implicit mapping = FALSE\n"); LocalFree(info); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, + ret = CryptDecodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, policyConstraintsWithInhibitMapping, sizeof(policyConstraintsWithInhibitMapping), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); @@ -8128,7 +7925,7 @@ static void test_decodeCertPolicyConstraints(DWORD dwEncoding) info->dwInhibitPolicyMappingSkipCerts); LocalFree(info); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, + ret = CryptDecodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, policyConstraintsWithBoth, sizeof(policyConstraintsWithBoth), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -8360,7 +8157,7 @@ static void test_decodeRsaPrivateKey(DWORD dwEncoding) DWORD bufSize = 0; BOOL ret;
- ret = pCryptDecodeObjectEx(dwEncoding, PKCS_RSA_PRIVATE_KEY, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_RSA_PRIVATE_KEY, rsaPrivKeyDer, sizeof(rsaPrivKeyDer)-10, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD), @@ -8369,7 +8166,7 @@ static void test_decodeRsaPrivateKey(DWORD dwEncoding)
buf = NULL; bufSize = 0; - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_RSA_PRIVATE_KEY, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_RSA_PRIVATE_KEY, rsaPrivKeyDer, sizeof(rsaPrivKeyDer), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); @@ -8700,7 +8497,7 @@ static void test_encodeOCSPRequestInfo(DWORD dwEncoding)
size = 0; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, OCSP_REQUEST, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); + ret = CryptEncodeObjectEx(dwEncoding, OCSP_REQUEST, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "got %08lx\n", GetLastError()); ok(size == sizeof(expected), "got %lu\n", size); ok(!memcmp(buf, expected, sizeof(expected)), "unexpected value\n"); @@ -8711,7 +8508,7 @@ static void test_encodeOCSPRequestInfo(DWORD dwEncoding) info_signed.pOptionalSignatureInfo = NULL; size = 0; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, OCSP_SIGNED_REQUEST, &info_signed, CRYPT_ENCODE_ALLOC_FLAG, NULL, + ret = CryptEncodeObjectEx(dwEncoding, OCSP_SIGNED_REQUEST, &info_signed, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf2, &size); ok(ret, "got %08lx\n", GetLastError()); ok(size == sizeof(expected4), "got %lu\n", size); @@ -8731,7 +8528,7 @@ static void test_encodeOCSPRequestInfo(DWORD dwEncoding)
size = 0; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, OCSP_REQUEST, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); + ret = CryptEncodeObjectEx(dwEncoding, OCSP_REQUEST, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "got %08lx\n", GetLastError()); ok(size == sizeof(expected2), "got %lu\n", size); ok(!memcmp(buf, expected2, sizeof(expected2)), "unexpected value\n"); @@ -8741,7 +8538,7 @@ static void test_encodeOCSPRequestInfo(DWORD dwEncoding) info.pRequestorName = NULL; size = 0; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, OCSP_REQUEST, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); + ret = CryptEncodeObjectEx(dwEncoding, OCSP_REQUEST, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "got %08lx\n", GetLastError()); ok(size == sizeof(expected3), "got %lu\n", size); ok(!memcmp(buf, expected3, sizeof(expected3)), "unexpected value\n"); @@ -8801,7 +8598,7 @@ static void test_decodeOCSPResponseInfo(DWORD dwEncoding) DWORD size; BOOL ret;
- ret = pCryptDecodeObjectEx(dwEncoding, OCSP_RESPONSE, ocsp_response, sizeof(ocsp_response), + ret = CryptDecodeObjectEx(dwEncoding, OCSP_RESPONSE, ocsp_response, sizeof(ocsp_response), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); ok(ret, "got %08lx\n", GetLastError()); ok(info->dwStatus == OCSP_UNAUTHORIZED_RESPONSE, "got %lu\n", info->dwStatus); @@ -8810,7 +8607,7 @@ static void test_decodeOCSPResponseInfo(DWORD dwEncoding) ok(info->Value.pbData == NULL, "got %p\n", info->Value.pbData); LocalFree(info);
- ret = pCryptDecodeObjectEx(dwEncoding, OCSP_RESPONSE, ocsp_response2, sizeof(ocsp_response2), + ret = CryptDecodeObjectEx(dwEncoding, OCSP_RESPONSE, ocsp_response2, sizeof(ocsp_response2), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); ok(ret, "got %08lx\n", GetLastError()); ok(info->dwStatus == OCSP_SUCCESSFUL_RESPONSE, "got %lu\n", info->dwStatus); @@ -8927,7 +8724,7 @@ static void test_decodeOCSPBasicSignedResponseInfo(DWORD dwEncoding) BOOL ret;
size = 0; - ret = pCryptDecodeObjectEx(dwEncoding, OCSP_BASIC_SIGNED_RESPONSE, ocsp_basic_signed_response, + ret = CryptDecodeObjectEx(dwEncoding, OCSP_BASIC_SIGNED_RESPONSE, ocsp_basic_signed_response, sizeof(ocsp_basic_signed_response), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); ok(ret, "got %08lx\n", GetLastError()); if (sizeof(void *) == 4) todo_wine ok(size == 496, "got %lu\n", size); @@ -8986,8 +8783,8 @@ static void test_decodeOCSPBasicResponseInfo(DWORD dwEncoding)
/* good cert */ size = 0; - ret = pCryptDecodeObjectEx(dwEncoding, OCSP_BASIC_RESPONSE, ocsp_basic_response, - sizeof(ocsp_basic_response), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); + ret = CryptDecodeObjectEx(dwEncoding, OCSP_BASIC_RESPONSE, ocsp_basic_response, + sizeof(ocsp_basic_response), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); ok(ret, "got %08lx\n", GetLastError());
ok(!info->dwVersion, "got %lu\n", info->dwVersion); @@ -9025,8 +8822,8 @@ static void test_decodeOCSPBasicResponseInfo(DWORD dwEncoding)
/* revoked cert */ size = 0; - ret = pCryptDecodeObjectEx(dwEncoding, OCSP_BASIC_RESPONSE, ocsp_basic_response_revoked, - sizeof(ocsp_basic_response_revoked), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); + ret = CryptDecodeObjectEx(dwEncoding, OCSP_BASIC_RESPONSE, ocsp_basic_response_revoked, + sizeof(ocsp_basic_response_revoked), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); todo_wine ok(ret, "got %08lx\n", GetLastError());
if (ret) { @@ -9075,18 +8872,8 @@ START_TEST(encode) { static const DWORD encodings[] = { X509_ASN_ENCODING, PKCS_7_ASN_ENCODING, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING }; - HMODULE hCrypt32; DWORD i;
- hCrypt32 = GetModuleHandleA("crypt32.dll"); - pCryptDecodeObjectEx = (void*)GetProcAddress(hCrypt32, "CryptDecodeObjectEx"); - pCryptEncodeObjectEx = (void*)GetProcAddress(hCrypt32, "CryptEncodeObjectEx"); - if (!pCryptDecodeObjectEx || !pCryptEncodeObjectEx) - { - win_skip("CryptDecodeObjectEx() is not available\n"); - return; - } - for (i = 0; i < ARRAY_SIZE(encodings); i++) { test_encodeInt(encodings[i]); diff --git a/dlls/crypt32/tests/message.c b/dlls/crypt32/tests/message.c index 6958c15ee36..fa4790a2a6b 100644 --- a/dlls/crypt32/tests/message.c +++ b/dlls/crypt32/tests/message.c @@ -59,15 +59,13 @@ static void test_msg_get_signer_count(void) SetLastError(0xdeadbeef); count = CryptGetMessageSignerCount(PKCS_7_ASN_ENCODING, NULL, 0); ok(count == -1, "Expected -1, got %ld\n", count); - ok(GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_BAD_ARG, /* win9x */ + ok(GetLastError() == CRYPT_E_ASN1_EOD, "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); count = CryptGetMessageSignerCount(PKCS_7_ASN_ENCODING, dataEmptyBareContent, sizeof(dataEmptyBareContent)); ok(count == -1, "Expected -1, got %ld\n", count); - ok(GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH, /* win9x */ + ok(GetLastError() == CRYPT_E_ASN1_BADTAG, "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); count = CryptGetMessageSignerCount(PKCS_7_ASN_ENCODING, @@ -79,14 +77,11 @@ static void test_msg_get_signer_count(void) count = CryptGetMessageSignerCount(PKCS_7_ASN_ENCODING, signedEmptyBareContent, sizeof(signedEmptyBareContent)); ok(count == -1, "Expected -1, got %ld\n", count); - ok(GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_DATA_ERROR, /* win9x */ + ok(GetLastError() == CRYPT_E_ASN1_BADTAG, "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); count = CryptGetMessageSignerCount(PKCS_7_ASN_ENCODING, signedEmptyContent, sizeof(signedEmptyContent)); - ok(count == 1 || - broken(count == -1), /* win9x */ - "Expected 1, got %ld\n", count); + ok(count == 1, "Expected 1, got %ld\n", count); }
static BYTE detachedHashContent[] = { @@ -126,9 +121,7 @@ static void test_verify_detached_message_hash(void) SetLastError(0xdeadbeef); ret = CryptVerifyDetachedMessageHash(¶, NULL, 0, 0, NULL, NULL, NULL, NULL); - ok(!ret && - (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_BAD_ARG), /* win9x */ + ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, "expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); para.dwMsgEncodingType = X509_ASN_ENCODING; SetLastError(0xdeadbeef); @@ -140,9 +133,7 @@ static void test_verify_detached_message_hash(void) SetLastError(0xdeadbeef); ret = CryptVerifyDetachedMessageHash(¶, NULL, 0, 0, NULL, NULL, NULL, NULL); - ok(!ret && - (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_BAD_ARG), /* win9x */ + ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, "expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); /* Curiously, passing no data to hash succeeds.. */ ret = CryptVerifyDetachedMessageHash(¶, detachedHashContent, @@ -221,9 +212,8 @@ static void test_verify_message_hash(void) SetLastError(0xdeadbeef); ret = CryptVerifyMessageHash(¶, NULL, 0, NULL, NULL, NULL, NULL); ok(!ret, "Expected 0, got %d\n", ret); - ok(GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_BAD_ARG, /* win98 */ - "Expected CRYPT_E_ASN1_EOD or OSS_BAD_ARG, got %08lx\n", GetLastError()); + ok(GetLastError() == CRYPT_E_ASN1_EOD, + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); /* Verifying the hash of a detached message succeeds? */ ret = CryptVerifyMessageHash(¶, detachedHashContent, sizeof(detachedHashContent), NULL, NULL, NULL, NULL); @@ -361,9 +351,8 @@ static void test_verify_detached_message_signature(void) ret = CryptVerifyDetachedMessageSignature(¶, 0, NULL, 0, 0, NULL, NULL, NULL); ok(!ret, "Expected 0, got %d\n", ret); - ok(GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_BAD_ARG, /* win98 */ - "Expected CRYPT_E_ASN1_EOD or OSS_BAD_ARG, got %08lx\n", GetLastError()); + ok(GetLastError() == CRYPT_E_ASN1_EOD, + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); /* None of these messages contains a cert in the message itself, so the * default callback isn't able to verify their signature. */ @@ -372,39 +361,33 @@ static void test_verify_detached_message_signature(void) sizeof(signedWithCertContent), 0, NULL, NULL, NULL); ok(!ret, "Expected 0, got %d\n", ret); todo_wine - ok(GetLastError() == CRYPT_E_NOT_FOUND || - GetLastError() == OSS_DATA_ERROR, /* win98 */ - "Expected CRYPT_E_NOT_FOUND or OSS_DATA_ERROR, got %08lx\n", GetLastError()); + ok(GetLastError() == CRYPT_E_NOT_FOUND, + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptVerifyDetachedMessageSignature(¶, 0, signedContent, sizeof(signedContent), 0, NULL, NULL, NULL); ok(!ret, "Expected 0, got %d\n", ret); - ok(GetLastError() == CRYPT_E_NOT_FOUND || - GetLastError() == OSS_DATA_ERROR, /* win98 */ - "Expected CRYPT_E_NOT_FOUND or OSS_DATA_ERROR, got %08lx\n", GetLastError()); + ok(GetLastError() == CRYPT_E_NOT_FOUND, + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptVerifyDetachedMessageSignature(¶, 0, detachedSignedContent, sizeof(detachedSignedContent), 0, NULL, NULL, NULL); ok(!ret, "Expected 0, got %d\n", ret); - ok(GetLastError() == CRYPT_E_NOT_FOUND || - GetLastError() == OSS_DATA_ERROR, /* win98 */ - "Expected CRYPT_E_NOT_FOUND or OSS_DATA_ERROR, got %08lx\n", GetLastError()); + ok(GetLastError() == CRYPT_E_NOT_FOUND, + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); pContent = msgData; cbContent = sizeof(msgData); ret = CryptVerifyDetachedMessageSignature(¶, 0, detachedSignedContent, sizeof(detachedSignedContent), 1, &pContent, &cbContent, NULL); ok(!ret, "Expected 0, got %d\n", ret); - ok(GetLastError() == CRYPT_E_NOT_FOUND || - GetLastError() == OSS_DATA_ERROR, /* win98 */ - "Expected CRYPT_E_NOT_FOUND or OSS_DATA_ERROR, got %08lx\n", GetLastError()); + ok(GetLastError() == CRYPT_E_NOT_FOUND, + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); /* Passing the correct callback results in success */ para.pfnGetSignerCertificate = msg_get_signer_callback; ret = CryptVerifyDetachedMessageSignature(¶, 0, detachedSignedContent, sizeof(detachedSignedContent), 1, &pContent, &cbContent, NULL); - ok(ret || - broken(!ret), /* win98 */ - "CryptVerifyDetachedMessageSignature failed: %08lx\n", + ok(ret, "CryptVerifyDetachedMessageSignature failed: %08lx\n", GetLastError()); /* Not passing the correct data to be signed results in the signature not * matching. @@ -413,9 +396,8 @@ static void test_verify_detached_message_signature(void) ret = CryptVerifyDetachedMessageSignature(¶, 0, detachedSignedContent, sizeof(detachedSignedContent), 0, NULL, NULL, NULL); ok(!ret, "Expected 0, got %d\n", ret); - ok(GetLastError() == NTE_BAD_SIGNATURE || - GetLastError() == OSS_DATA_ERROR, /* win98 */ - "Expected NTE_BAD_SIGNATURE or OSS_DATA_ERROR, got %08lx\n", GetLastError()); + ok(GetLastError() == NTE_BAD_SIGNATURE, + "Expected NTE_BAD_SIGNATURE, got %08lx\n", GetLastError()); }
static const BYTE signedWithCertEmptyContent[] = { @@ -519,33 +501,27 @@ static void test_verify_message_signature(void) para.cbSize = sizeof(para); SetLastError(0xdeadbeef); ret = CryptVerifyMessageSignature(¶, 0, NULL, 0, NULL, 0, NULL); - ok(!ret && - (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_BAD_ARG), /* win9x */ + ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); /* Check whether cert is set on error */ cert = (PCCERT_CONTEXT)0xdeadbeef; ret = CryptVerifyMessageSignature(¶, 0, NULL, 0, NULL, 0, &cert); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_BAD_ARG /* NT40 */), + ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); ok(cert == NULL, "Expected NULL cert\n"); /* Check whether cbDecoded is set on error */ cbDecoded = 0xdeadbeef; ret = CryptVerifyMessageSignature(¶, 0, NULL, 0, NULL, &cbDecoded, NULL); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_BAD_ARG /* NT40 */), + ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); ok(!cbDecoded, "Expected 0\n"); SetLastError(0xdeadbeef); ret = CryptVerifyMessageSignature(¶, 0, dataEmptyBareContent, sizeof(dataEmptyBareContent), NULL, 0, NULL); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH /* NT40 */), + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); - ok(GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH, /* win9x */ + ok(GetLastError() == CRYPT_E_ASN1_BADTAG, "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptVerifyMessageSignature(¶, 0, dataEmptyContent, @@ -555,23 +531,17 @@ static void test_verify_message_signature(void) SetLastError(0xdeadbeef); ret = CryptVerifyMessageSignature(¶, 0, signedEmptyBareContent, sizeof(signedEmptyBareContent), NULL, 0, NULL); - ok(!ret && - (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_DATA_ERROR), /* win9x */ + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptVerifyMessageSignature(¶, 0, signedEmptyContent, sizeof(signedEmptyContent), NULL, 0, NULL); - ok(!ret && - (GetLastError() == CRYPT_E_NOT_FOUND || - GetLastError() == OSS_DATA_ERROR), /* win9x */ + ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptVerifyMessageSignature(¶, 0, signedContent, sizeof(signedContent), NULL, 0, NULL); - ok(!ret && - (GetLastError() == CRYPT_E_NOT_FOUND || - GetLastError() == OSS_DATA_ERROR), /* win9x */ + ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); /* FIXME: Windows fails with CRYPT_E_NOT_FOUND for these messages, but * their signer certs have invalid public keys that fail to decode. In @@ -1021,13 +991,6 @@ static void test_sign_message(void) SetLastError(0xdeadbeef); ret = CryptImportKey(hCryptProv, publicPrivateKeyPair, sizeof(publicPrivateKeyPair), 0, 0, &hKey); - if (!ret && GetLastError() == NTE_PERM) /* Win9x */ - { - skip("Failed to import a key\n"); - if (hCryptProv) - CryptReleaseContext(hCryptProv, 0); - return; - } ok(ret, "CryptImportKey failed: %08lx\n", GetLastError());
para.dwMsgEncodingType = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING; @@ -1239,9 +1202,7 @@ static void test_encrypt_message(void) encryptedBlobSize = 255; ret = CryptEncryptMessage(¶, 0, NULL, NULL, 0, NULL, &encryptedBlobSize); - ok(!ret && - (GetLastError() == CRYPT_E_UNKNOWN_ALGO || - GetLastError() == E_INVALIDARG), /* Win9x */ + ok(!ret && GetLastError() == CRYPT_E_UNKNOWN_ALGO, "expected CRYPT_E_UNKNOWN_ALGO or E_INVALIDARG, got %08lx\n", GetLastError()); ok(!encryptedBlobSize, "unexpected size %ld\n", encryptedBlobSize); @@ -1253,9 +1214,7 @@ static void test_encrypt_message(void) encryptedBlobSize = 0; ret = CryptEncryptMessage(¶, 0, NULL, NULL, 0, NULL, &encryptedBlobSize); - ok(ret || - broken(!ret) /* Win9x */, - "CryptEncryptMessage failed: %08lx\n", GetLastError()); + ok(ret, "CryptEncryptMessage failed: %08lx\n", GetLastError()); if (ret) { encryptedBlob = CryptMemAlloc(encryptedBlobSize); @@ -1265,7 +1224,7 @@ static void test_encrypt_message(void) ret = CryptEncryptMessage(¶, 0, NULL, NULL, 0, encryptedBlob, &encryptedBlobSize); ok(ret, "CryptEncryptMessage failed: %08lx\n", GetLastError()); - ok(encryptedBlobSize == sizeof(encryptedMessage), + ok(encryptedBlobSize == sizeof(encryptedMessage), "unexpected size of encrypted blob %ld\n", encryptedBlobSize); ok(!memcmp(encryptedBlob, encryptedMessage, encryptedBlobSize), "unexpected value\n"); @@ -1295,9 +1254,7 @@ static void test_encrypt_message(void) encryptedBlobSize = 0; ret = CryptEncryptMessage(¶, 0, NULL, blob, sizeof(blob), NULL, &encryptedBlobSize); - ok(ret || - broken(!ret) /* Win9x */, - "CryptEncryptMessage failed: %08lx\n", GetLastError()); + ok(ret, "CryptEncryptMessage failed: %08lx\n", GetLastError()); if (ret) { encryptedBlob = CryptMemAlloc(encryptedBlobSize); @@ -1306,9 +1263,7 @@ static void test_encrypt_message(void) SetLastError(0xdeadbeef); ret = CryptEncryptMessage(¶, 0, NULL, blob, sizeof(blob), encryptedBlob, &encryptedBlobSize); - ok(ret || - broken(!ret && GetLastError() == NTE_PERM), /* some NT4 */ - "CryptEncryptMessage failed: %08lx\n", GetLastError()); + ok(ret, "CryptEncryptMessage failed: %08lx\n", GetLastError()); if (ret) { ok(encryptedBlobSize == 55, @@ -1331,9 +1286,7 @@ static void test_encrypt_message(void) SetLastError(0xdeadbeef); ret = CryptEncryptMessage(¶, 2, certs, blob, sizeof(blob), encryptedBlob, &encryptedBlobSize); - ok(ret || - broken(!ret), /* some Win95 and some NT4 */ - "CryptEncryptMessage failed: %08lx\n", GetLastError()); + ok(ret, "CryptEncryptMessage failed: %08lx\n", GetLastError()); CryptMemFree(encryptedBlob); } } diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c index d66a972da05..f779d70695e 100644 --- a/dlls/crypt32/tests/msg.c +++ b/dlls/crypt32/tests/msg.c @@ -29,7 +29,6 @@
#include "wine/test.h"
-static BOOL old_crypt32 = FALSE; static char oid_rsa_md5[] = szOID_RSA_MD5;
static void test_msg_open_to_encode(void) @@ -174,7 +173,7 @@ static void test_msg_get_param(void) ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, &value, &size); ok(ret, "CryptMsgGetParam failed: %lx\n", GetLastError()); ok(value == CMSG_DATA, "Expected CMSG_DATA, got %ld\n", value); - for (i = CMSG_CONTENT_PARAM; !old_crypt32 && (i <= CMSG_CMS_SIGNER_INFO_PARAM); i++) + for (i = CMSG_CONTENT_PARAM; i <= CMSG_CMS_SIGNER_INFO_PARAM; i++) { size = 0; ret = CryptMsgGetParam(msg, i, 0, NULL, &size); @@ -189,7 +188,7 @@ static void test_msg_get_param(void) ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, &value, &size); ok(ret, "CryptMsgGetParam failed: %lx\n", GetLastError()); ok(value == CMSG_ENVELOPED, "Expected CMSG_ENVELOPED, got %ld\n", value); - for (i = CMSG_CONTENT_PARAM; !old_crypt32 && (i <= CMSG_CMS_SIGNER_INFO_PARAM); i++) + for (i = CMSG_CONTENT_PARAM; i <= CMSG_CMS_SIGNER_INFO_PARAM; i++) { size = 0; ret = CryptMsgGetParam(msg, i, 0, NULL, &size); @@ -204,7 +203,7 @@ static void test_msg_get_param(void) ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, &value, &size); ok(ret, "CryptMsgGetParam failed: %lx\n", GetLastError()); ok(value == CMSG_HASHED, "Expected CMSG_HASHED, got %ld\n", value); - for (i = CMSG_CONTENT_PARAM; !old_crypt32 && (i <= CMSG_CMS_SIGNER_INFO_PARAM); i++) + for (i = CMSG_CONTENT_PARAM; i <= CMSG_CMS_SIGNER_INFO_PARAM; i++) { size = 0; ret = CryptMsgGetParam(msg, i, 0, NULL, &size); @@ -219,7 +218,7 @@ static void test_msg_get_param(void) ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, &value, &size); ok(ret, "CryptMsgGetParam failed: %lx\n", GetLastError()); ok(value == CMSG_SIGNED, "Expected CMSG_SIGNED, got %ld\n", value); - for (i = CMSG_CONTENT_PARAM; !old_crypt32 && (i <= CMSG_CMS_SIGNER_INFO_PARAM); i++) + for (i = CMSG_CONTENT_PARAM; i <= CMSG_CMS_SIGNER_INFO_PARAM; i++) { size = 0; ret = CryptMsgGetParam(msg, i, 0, NULL, &size); @@ -273,14 +272,8 @@ static void check_param(LPCSTR test, HCRYPTMSG msg, DWORD param,
size = 0xdeadbeef; ret = CryptMsgGetParam(msg, param, 0, NULL, &size); - ok(ret || broken(GetLastError() == OSS_LIMITED /* Win9x */ || - GetLastError() == CRYPT_E_INVALID_MSG_TYPE /* Win9x, for some params */), - "%s: CryptMsgGetParam failed: %08lx\n", test, GetLastError()); - if (!ret) - { - win_skip("parameter %ld not supported, skipping tests\n", param); - return; - } + ok(ret, "%s: CryptMsgGetParam failed: %08lx\n", test, GetLastError()); + buf = HeapAlloc(GetProcessHeap(), 0, size); ret = CryptMsgGetParam(msg, param, 0, buf, &size); ok(ret, "%s: CryptMsgGetParam failed: %08lx\n", test, GetLastError()); @@ -371,7 +364,7 @@ static void test_data_msg_update(void) NULL); /* Starting with Vista, can update a message with no data. */ ret = CryptMsgUpdate(msg, NULL, 0, TRUE); - ok(ret || broken(!ret), "CryptMsgUpdate failed: %08lx\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); if (ret) { DWORD size; @@ -405,37 +398,28 @@ static void test_data_msg_update(void)
SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, NULL, 0, FALSE); - ok(!ret && - (GetLastError() == E_INVALIDARG || - broken(GetLastError() == ERROR_SUCCESS)), /* Older NT4 */ + ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); - ok(!ret && - (GetLastError() == E_INVALIDARG || - broken(GetLastError() == ERROR_SUCCESS)), /* Older NT4 */ + ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %lx\n", GetLastError());
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); CryptMsgClose(msg);
- if (!old_crypt32) - { - /* Calling update after opening with an empty stream info (with a bogus - * output function) yields an error: - */ - /* Crashes on some Win9x */ - msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL, - &streamInfo); - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); - ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION || - GetLastError() == STATUS_ILLEGAL_INSTRUCTION /* WinME */), - "Expected STATUS_ACCESS_VIOLATION or STATUS_ILLEGAL_INSTRUCTION, got %lx\n", - GetLastError()); - CryptMsgClose(msg); - } + /* Calling update after opening with an empty stream info (with a bogus + * output function) yields an error: + */ + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL, + &streamInfo); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %lx\n", GetLastError()); + CryptMsgClose(msg); + /* Calling update with a valid output function succeeds, even if the data * exceeds the size specified in the stream info. */ @@ -488,11 +472,11 @@ static void test_data_msg_get_param(void) NULL, &streamInfo); SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, NULL, &size); - ok((!ret && GetLastError() == E_INVALIDARG) || broken(ret /* Win9x */), + ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, NULL, &size); - ok((!ret && GetLastError() == E_INVALIDARG) || broken(ret /* Win9x */), + ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %lx\n", GetLastError()); CryptMsgClose(msg); } @@ -804,18 +788,15 @@ static void test_hash_msg_get_param(void) /* Content and bare content are always gettable for non-streamed messages */ size = 0; ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, NULL, &size); - ok(ret || broken(GetLastError() == OSS_LIMITED /* Win9x */), - "CryptMsgGetParam failed: %08lx\n", GetLastError()); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); size = 0; ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, NULL, &size); - ok(ret || broken(GetLastError() == OSS_LIMITED /* Win9x */), - "CryptMsgGetParam failed: %08lx\n", GetLastError()); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); /* For an encoded hash message, the hash data aren't available */ SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_HASH_DATA_PARAM, 0, NULL, &size); - ok(!ret && (GetLastError() == CRYPT_E_INVALID_MSG_TYPE || - GetLastError() == OSS_LIMITED /* Win9x */), - "Expected CRYPT_E_INVALID_MSG_TYPE or OSS_LIMITED, got %08lx\n", + ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, + "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError()); /* The hash is also available. */ size = 0; @@ -830,12 +811,8 @@ static void test_hash_msg_get_param(void) /* By getting the hash, further updates are not allowed */ SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(!ret && - (GetLastError() == NTE_BAD_HASH_STATE /* NT */ || - GetLastError() == NTE_BAD_ALGID /* 9x */ || - GetLastError() == CRYPT_E_MSG_ERROR /* Vista */ || - broken(GetLastError() == ERROR_SUCCESS) /* Some Win9x */), - "Expected NTE_BAD_HASH_STATE or NTE_BAD_ALGID or CRYPT_E_MSG_ERROR, got 0x%lx\n", GetLastError()); + ok(!ret && (GetLastError() == NTE_BAD_HASH_STATE || GetLastError() == CRYPT_E_MSG_ERROR), + "Expected CRYPT_E_MSG_ERROR, got 0x%lx\n", GetLastError());
/* Even after a final update, the hash data aren't available */ SetLastError(0xdeadbeef); @@ -845,12 +822,10 @@ static void test_hash_msg_get_param(void) /* The version is also available, and should be zero for this message. */ size = 0; ret = CryptMsgGetParam(msg, CMSG_VERSION_PARAM, 0, NULL, &size); - ok(ret || broken(GetLastError() == CRYPT_E_INVALID_MSG_TYPE /* Win9x */), - "CryptMsgGetParam failed: %08lx\n", GetLastError()); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); size = sizeof(value); ret = CryptMsgGetParam(msg, CMSG_VERSION_PARAM, 0, &value, &size); - ok(ret || broken(GetLastError() == CRYPT_E_INVALID_MSG_TYPE /* Win9x */), - "CryptMsgGetParam failed: %08lx\n", GetLastError()); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); if (ret) ok(value == 0, "Expected version 0, got %ld\n", value); /* As usual, the type isn't available. */ @@ -863,14 +838,12 @@ static void test_hash_msg_get_param(void) /* Streamed messages don't allow you to get the content or bare content. */ SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, NULL, &size); - ok(!ret && (GetLastError() == E_INVALIDARG || - GetLastError() == OSS_LIMITED /* Win9x */), - "Expected E_INVALIDARG or OSS_LIMITED, got %lx\n", GetLastError()); + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, NULL, &size); - ok(!ret && (GetLastError() == E_INVALIDARG || - GetLastError() == OSS_LIMITED /* Win9x */), - "Expected E_INVALIDARG or OSS_LIMITED, got %lx\n", GetLastError()); + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %lx\n", GetLastError()); /* The hash is still available. */ size = 0; ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size); @@ -885,12 +858,8 @@ static void test_hash_msg_get_param(void) */ SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(!ret && - (GetLastError() == NTE_BAD_HASH_STATE /* NT */ || - GetLastError() == NTE_BAD_ALGID /* 9x */ || - GetLastError() == CRYPT_E_MSG_ERROR /* Vista */ || - broken(GetLastError() == ERROR_SUCCESS) /* Some Win9x */), - "Expected NTE_BAD_HASH_STATE or NTE_BAD_ALGID or CRYPT_E_MSG_ERROR, got 0x%lx\n", GetLastError()); + ok(!ret && (GetLastError() == NTE_BAD_HASH_STATE || GetLastError() == CRYPT_E_MSG_ERROR), + "Expected CRYPT_E_MSG_ERROR, got 0x%lx\n", GetLastError());
CryptMsgClose(msg); } @@ -1083,19 +1052,15 @@ static void test_signed_msg_open(void) SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); - /* NT: E_INVALIDARG, 9x: unchanged or CRYPT_E_UNKNOWN_ALGO */ - ok(!msg && (GetLastError() == E_INVALIDARG || GetLastError() == 0xdeadbeef - || GetLastError() == CRYPT_E_UNKNOWN_ALGO), - "Expected E_INVALIDARG or 0xdeadbeef or CRYPT_E_UNKNOWN_ALGO, got 0x%lx\n", - GetLastError()); + ok(!msg && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got 0x%lx\n", GetLastError());
certInfo.Issuer.cbData = sizeof(encodedCommonName); certInfo.Issuer.pbData = encodedCommonName; SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); - ok(!msg && (GetLastError() == E_INVALIDARG || - GetLastError() == CRYPT_E_UNKNOWN_ALGO), + ok(!msg && (GetLastError() == E_INVALIDARG || GetLastError() == CRYPT_E_UNKNOWN_ALGO), "Expected E_INVALIDARG or CRYPT_E_UNKNOWN_ALGO, got %lx\n", GetLastError());
/* The signer's hCryptProv must be set to something. Whether it's usable @@ -1214,11 +1179,6 @@ static void test_signed_msg_update(void) } ok(ret, "CryptAcquireContext failed: 0x%lx\n", GetLastError());
- if (!ret) { - skip("No context for tests\n"); - return; - } - msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, CMSG_SIGNED, &signInfo, NULL, NULL); ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); @@ -1233,10 +1193,7 @@ static void test_signed_msg_update(void) */ SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, NULL, 0, TRUE); - ok(!ret && - (GetLastError() == NTE_BAD_KEYSET || - GetLastError() == NTE_NO_KEY || - broken(GetLastError() == ERROR_SUCCESS)), /* Some Win9x */ + ok(!ret && (GetLastError() == NTE_BAD_KEYSET || GetLastError() == NTE_NO_KEY), "Expected NTE_BAD_KEYSET or NTE_NO_KEY, got %lx\n", GetLastError()); ret = CryptImportKey(signer.hCryptProv, privKey, sizeof(privKey), 0, 0, &key); @@ -1652,11 +1609,6 @@ static void test_signed_msg_encoding(void) } ok(ret, "CryptAcquireContext failed: 0x%lx\n", GetLastError());
- if (!ret) { - skip("No context for tests\n"); - return; - } - ret = CryptImportKey(signer.hCryptProv, privKey, sizeof(privKey), 0, 0, &key); ok(ret, "CryptImportKey failed: %08lx\n", GetLastError()); @@ -1680,8 +1632,7 @@ static void test_signed_msg_encoding(void) detachedSignedContent, sizeof(detachedSignedContent)); SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 1, NULL, &size); - ok(!ret && (GetLastError() == CRYPT_E_INVALID_INDEX || - broken(GetLastError() == CRYPT_E_INVALID_MSG_TYPE /* Win9x */)), + ok(!ret && GetLastError() == CRYPT_E_INVALID_INDEX, "Expected CRYPT_E_INVALID_INDEX, got %lx\n", GetLastError()); check_param("detached signed encoded signer", msg, CMSG_ENCODED_SIGNER, signedEncodedSigner, sizeof(signedEncodedSigner)); @@ -1834,13 +1785,8 @@ static void test_signed_msg_get_param(void) /* Content and bare content are always gettable */ size = 0; ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, NULL, &size); - ok(ret || broken(!ret /* Win9x */), "CryptMsgGetParam failed: %08lx\n", - GetLastError()); - if (!ret) - { - skip("message parameters are broken, skipping tests\n"); - return; - } + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); + size = 0; ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, NULL, &size); ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); @@ -1888,11 +1834,6 @@ static void test_signed_msg_get_param(void) } ok(ret, "CryptAcquireContext failed: 0x%lx\n", GetLastError());
- if (!ret) { - skip("No context for tests\n"); - return; - } - msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); @@ -1945,8 +1886,7 @@ static void test_signed_msg_get_param(void) */ size = sizeof(value); ret = CryptMsgGetParam(msg, CMSG_VERSION_PARAM, 0, &value, &size); - ok(ret || broken(GetLastError() == CRYPT_E_INVALID_MSG_TYPE), - "CryptMsgGetParam failed: %08lx\n", GetLastError()); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); if (ret) ok(value == CMSG_SIGNED_DATA_V1, "expected version 1, got %ld\n", value); /* Apparently the encoded signer can be retrieved.. */ @@ -2037,54 +1977,43 @@ static void test_enveloped_msg_open(void) SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, &envelopedInfo, NULL, NULL); - ok(!msg && - (GetLastError() == CRYPT_E_UNKNOWN_ALGO || - GetLastError() == E_INVALIDARG), /* Win9x */ - "expected CRYPT_E_UNKNOWN_ALGO or E_INVALIDARG, got %08lx\n", GetLastError()); + ok(!msg && GetLastError() == CRYPT_E_UNKNOWN_ALGO, + "expected CRYPT_E_UNKNOWN_ALGO, got %08lx\n", GetLastError());
envelopedInfo.ContentEncryptionAlgorithm.pszObjId = oid_rsa_rc4; SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, &envelopedInfo, NULL, NULL); - ok(msg != NULL || - broken(!msg), /* Win9x */ - "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); CryptMsgClose(msg);
envelopedInfo.cRecipients = 1; - if (!old_crypt32) - { - SetLastError(0xdeadbeef); - msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, - &envelopedInfo, NULL, NULL); - ok(!msg && GetLastError() == E_INVALIDARG, - "expected E_INVALIDARG, got %08lx\n", GetLastError()); - } + SetLastError(0xdeadbeef); + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, + &envelopedInfo, NULL, NULL); + ok(!msg && GetLastError() == E_INVALIDARG, + "expected E_INVALIDARG, got %08lx\n", GetLastError());
context = CertCreateCertificateContext(X509_ASN_ENCODING, v1CertWithValidPubKey, sizeof(v1CertWithValidPubKey)); - if (context) - { - envelopedInfo.rgpRecipientCert = (PCERT_INFO *)&context->pCertInfo; - SetLastError(0xdeadbeef); - msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, - &envelopedInfo, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); - CryptMsgClose(msg); - SetLastError(0xdeadbeef); - ret = CryptAcquireContextA(&envelopedInfo.hCryptProv, NULL, NULL, - PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); - ok(ret, "CryptAcquireContextA failed: %08lx\n", GetLastError()); - SetLastError(0xdeadbeef); - msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, - &envelopedInfo, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); - CryptMsgClose(msg); - CryptReleaseContext(envelopedInfo.hCryptProv, 0); - CertFreeCertificateContext(context); - } - else - win_skip("failed to create certificate context, skipping tests\n"); + + envelopedInfo.rgpRecipientCert = (PCERT_INFO *)&context->pCertInfo; + SetLastError(0xdeadbeef); + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, + &envelopedInfo, NULL, NULL); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); + CryptMsgClose(msg); + SetLastError(0xdeadbeef); + ret = CryptAcquireContextA(&envelopedInfo.hCryptProv, NULL, NULL, + PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); + ok(ret, "CryptAcquireContextA failed: %08lx\n", GetLastError()); + SetLastError(0xdeadbeef); + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, + &envelopedInfo, NULL, NULL); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); + CryptMsgClose(msg); + CryptReleaseContext(envelopedInfo.hCryptProv, 0); + CertFreeCertificateContext(context); }
static void test_enveloped_msg_update(void) @@ -2098,117 +2027,92 @@ static void test_enveloped_msg_update(void) SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, &envelopedInfo, NULL, NULL); - ok(msg != NULL || - broken(!msg), /* Win9x */ - "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); - if (msg) - { - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, NULL, 0, FALSE); - ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, - "expected CRYPT_E_MSG_ERROR, got %08lx\n", GetLastError()); - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, NULL, 0, TRUE); - ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, NULL, 0, TRUE); - ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, - "expected CRYPT_E_MSG_ERROR, got %08lx\n", GetLastError()); - CryptMsgClose(msg); - } + ok(msg != NULL, "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, NULL, 0, FALSE); + ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, + "expected CRYPT_E_MSG_ERROR, got %08lx\n", GetLastError()); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, NULL, 0, TRUE); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, NULL, 0, TRUE); + ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, + "expected CRYPT_E_MSG_ERROR, got %08lx\n", GetLastError()); + CryptMsgClose(msg); + SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, &envelopedInfo, NULL, NULL); - ok(msg != NULL || - broken(!msg), /* Win9x */ - "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); - if (msg) - { - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); - ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, - "expected CRYPT_E_MSG_ERROR, got %08lx\n", GetLastError()); - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(ret || - broken(!ret && GetLastError() == NTE_PERM), /* some NT4 */ - "CryptMsgUpdate failed: %08lx\n", GetLastError()); - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, NULL, 0, TRUE); - ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, - "expected CRYPT_E_MSG_ERROR, got %08lx\n", GetLastError()); - CryptMsgClose(msg); - } + ok(msg != NULL, "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); + ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, + "expected CRYPT_E_MSG_ERROR, got %08lx\n", GetLastError()); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, NULL, 0, TRUE); + ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, + "expected CRYPT_E_MSG_ERROR, got %08lx\n", GetLastError()); + CryptMsgClose(msg); + SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, CMSG_ENVELOPED, &envelopedInfo, NULL, NULL); - ok(msg != NULL || - broken(!msg), /* Win9x */ - "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); - if (msg) - { - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, NULL, 0, FALSE); - ok(!ret && GetLastError() == E_INVALIDARG, - "expected E_INVALIDARG, got %08lx\n", GetLastError()); - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, NULL, 0, TRUE); - ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); - CryptMsgClose(msg); - } + ok(msg != NULL, "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, NULL, 0, FALSE); + ok(!ret && GetLastError() == E_INVALIDARG, + "expected E_INVALIDARG, got %08lx\n", GetLastError()); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, NULL, 0, TRUE); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); + CryptMsgClose(msg); + SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, CMSG_ENVELOPED, &envelopedInfo, NULL, NULL); - ok(msg != NULL || - broken(!msg), /* Win9x */ - "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); - if (msg) - { - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); - ok(!ret && GetLastError() == E_INVALIDARG, - "expected E_INVALIDARG, got %08lx\n", GetLastError()); - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(ret || - broken(!ret && GetLastError() == NTE_PERM), /* some NT4 */ - "CryptMsgUpdate failed: %08lx\n", GetLastError()); - CryptMsgClose(msg); - } + ok(msg != NULL, "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); + ok(!ret && GetLastError() == E_INVALIDARG, + "expected E_INVALIDARG, got %08lx\n", GetLastError()); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); + CryptMsgClose(msg); + SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, &envelopedInfo, NULL, &streamInfo); - ok(msg != NULL || - broken(!msg), /* Win9x */ - "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); - if (msg) - { - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, NULL, 0, FALSE); - ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, NULL, 0, TRUE); - ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); - CryptMsgClose(msg); - } + ok(msg != NULL, "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, NULL, 0, FALSE); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, NULL, 0, TRUE); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); + CryptMsgClose(msg); + SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, &envelopedInfo, NULL, &streamInfo); - ok(msg != NULL || - broken(!msg), /* Win9x */ - "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); - if (msg) - { - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); - ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(ret || - broken(!ret && GetLastError() == NTE_PERM), /* some NT4 */ - "CryptMsgUpdate failed: %08lx\n", GetLastError()); - CryptMsgClose(msg); - } + ok(msg != NULL, "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); + CryptMsgClose(msg); }
static const BYTE envelopedEmptyBareContent[] = { @@ -2230,18 +2134,13 @@ static void test_enveloped_msg_encoding(void) SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, &envelopedInfo, NULL, NULL); - ok(msg != NULL || - broken(!msg), /* Win9x */ - "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); - if (msg) - { - check_param("enveloped empty bare content", msg, - CMSG_BARE_CONTENT_PARAM, envelopedEmptyBareContent, - sizeof(envelopedEmptyBareContent)); - check_param("enveloped empty content", msg, CMSG_CONTENT_PARAM, - envelopedEmptyContent, sizeof(envelopedEmptyContent)); - CryptMsgClose(msg); - } + ok(msg != NULL, "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); + check_param("enveloped empty bare content", msg, + CMSG_BARE_CONTENT_PARAM, envelopedEmptyBareContent, + sizeof(envelopedEmptyBareContent)); + check_param("enveloped empty content", msg, CMSG_CONTENT_PARAM, + envelopedEmptyContent, sizeof(envelopedEmptyContent)); + CryptMsgClose(msg); }
static void test_enveloped_msg(void) @@ -2311,33 +2210,23 @@ static void test_decode_msg_update(void) ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); CryptMsgClose(msg);
- if (!old_crypt32) - { - msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, &streamInfo); - /* Updating a message that has a NULL stream callback fails */ - SetLastError(0xdeadbeef); - /* Crashes on some Win9x */ - ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), - FALSE); - todo_wine - ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION || - GetLastError() == STATUS_ILLEGAL_INSTRUCTION /* WinME */), - "Expected STATUS_ACCESS_VIOLATION or STATUS_ILLEGAL_INSTRUCTION, got %lx\n", - GetLastError()); - /* Changing the callback pointer after the fact yields the same error (so - * the message must copy the stream info, not just store a pointer to it) - */ - streamInfo.pfnStreamOutput = nop_stream_output; - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), - FALSE); - todo_wine - ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION || - GetLastError() == STATUS_ILLEGAL_INSTRUCTION /* WinME */), - "Expected STATUS_ACCESS_VIOLATION or STATUS_ILLEGAL_INSTRUCTION, got %lx\n", - GetLastError()); - CryptMsgClose(msg); - } + msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, &streamInfo); + /* Updating a message that has a NULL stream callback fails */ + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), FALSE); + todo_wine + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %lx\n", GetLastError()); + /* Changing the callback pointer after the fact yields the same error (so + * the message must copy the stream info, not just store a pointer to it) + */ + streamInfo.pfnStreamOutput = nop_stream_output; + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), FALSE); + todo_wine + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION or STATUS_ILLEGAL_INSTRUCTION, got %lx\n", GetLastError()); + CryptMsgClose(msg);
/* Empty non-final updates are allowed when streaming.. */ msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, &streamInfo); @@ -2369,9 +2258,8 @@ static void test_decode_msg_update(void) msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH /* Win9x */), - "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %lx\n", + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %lx\n", GetLastError()); CryptMsgClose(msg); /* and as the final update in streaming mode.. */ @@ -2379,9 +2267,8 @@ static void test_decode_msg_update(void) msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, &streamInfo); SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH /* Win9x */), - "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %lx\n", + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %lx\n", GetLastError()); CryptMsgClose(msg); /* and even as a non-final update in streaming mode. */ @@ -2390,10 +2277,8 @@ static void test_decode_msg_update(void) SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); todo_wine - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH /* Win9x */), - "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %lx\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %lx\n", GetLastError()); CryptMsgClose(msg);
/* An empty message can be opened with undetermined type.. */ @@ -2408,10 +2293,8 @@ static void test_decode_msg_update(void) SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), TRUE); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH /* Win9x */), - "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %lx\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %lx\n", GetLastError()); CryptMsgClose(msg); /* On the other hand, decoding the bare content of an empty message fails * with unspecified type.. @@ -2420,10 +2303,8 @@ static void test_decode_msg_update(void) SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, dataEmptyBareContent, sizeof(dataEmptyBareContent), TRUE); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH /* Win9x */), - "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %lx\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %lx\n", GetLastError()); CryptMsgClose(msg); /* but succeeds with explicit type. */ msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, 0, NULL, @@ -2445,19 +2326,15 @@ static void test_decode_msg_update(void) msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, hashEmptyContent, sizeof(hashEmptyContent), TRUE); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */), - "CryptMsgUpdate failed: %08lx\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); CryptMsgClose(msg); /* while with specified type it fails. */ msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL, NULL); SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, hashEmptyContent, sizeof(hashEmptyContent), TRUE); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH /* some Win9x */ || - GetLastError() == OSS_DATA_ERROR /* some Win9x */), - "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH or OSS_DATA_ERROR, got %lx\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %lx\n", GetLastError()); CryptMsgClose(msg); /* On the other hand, decoding the bare content of an empty hash message * fails with unspecified type.. @@ -2466,19 +2343,15 @@ static void test_decode_msg_update(void) SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, hashEmptyBareContent, sizeof(hashEmptyBareContent), TRUE); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH /* some Win9x */ || - GetLastError() == OSS_DATA_ERROR /* some Win9x */), - "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH or OSS_DATA_ERROR, got %lx\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %lx\n", GetLastError()); CryptMsgClose(msg); /* but succeeds with explicit type. */ msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL, NULL); ret = CryptMsgUpdate(msg, hashEmptyBareContent, sizeof(hashEmptyBareContent), TRUE); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* win9x */), - "CryptMsgUpdate failed: %lx\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); CryptMsgClose(msg);
/* And again, opening a (non-empty) hash message with unspecified type @@ -2494,11 +2367,8 @@ static void test_decode_msg_update(void) NULL); SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, hashContent, sizeof(hashContent), TRUE); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH /* some Win9x */ || - GetLastError() == OSS_DATA_ERROR /* some Win9x */), - "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH or OSS_DATA_ERROR, got %lx\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %lx\n", GetLastError()); CryptMsgClose(msg); /* and decoding the bare content of a non-empty hash message fails with * unspecified type.. @@ -2506,10 +2376,8 @@ static void test_decode_msg_update(void) msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, hashBareContent, sizeof(hashBareContent), TRUE); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH /* some Win9x */ || - GetLastError() == OSS_DATA_ERROR /* some Win9x */), - "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH or OSS_DATA_ERROR, got %lx\n", + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %lx\n", GetLastError()); CryptMsgClose(msg); /* but succeeds with explicit type. */ @@ -2536,10 +2404,8 @@ static void test_decode_msg_update(void) SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, signedWithCertAndCrlBareContent, sizeof(signedWithCertAndCrlBareContent), TRUE); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_DATA_ERROR /* Win9x */), - "Expected CRYPT_E_ASN1_BADTAG or OSS_DATA_ERROR, got %08lx\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, 0, NULL, NULL); @@ -2593,9 +2459,7 @@ static void test_decode_msg_update(void) SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, envelopedEmptyContent, sizeof(envelopedEmptyContent), TRUE); - ok(!ret && - (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_DATA_ERROR), /* Win9x */ + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, "expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); CryptMsgClose(msg);
@@ -2603,9 +2467,7 @@ static void test_decode_msg_update(void) SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, envelopedEmptyBareContent, sizeof(envelopedEmptyBareContent), TRUE); - ok(!ret && - (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_DATA_ERROR), /* Win9x */ + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, "expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); CryptMsgClose(msg);
@@ -2844,14 +2706,12 @@ static void test_decode_msg_get_param(void)
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); ret = CryptMsgUpdate(msg, hashEmptyContent, sizeof(hashEmptyContent), TRUE); - if (ret) - { - /* Crashes on some Win9x */ - check_param("empty hash content", msg, CMSG_CONTENT_PARAM, NULL, 0); - check_param("empty hash hash data", msg, CMSG_HASH_DATA_PARAM, NULL, 0); - check_param("empty hash computed hash", msg, CMSG_COMPUTED_HASH_PARAM, - emptyHashParam, sizeof(emptyHashParam)); - } + + check_param("empty hash content", msg, CMSG_CONTENT_PARAM, NULL, 0); + check_param("empty hash hash data", msg, CMSG_HASH_DATA_PARAM, NULL, 0); + check_param("empty hash computed hash", msg, CMSG_COMPUTED_HASH_PARAM, + emptyHashParam, sizeof(emptyHashParam)); + CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); ret = CryptMsgUpdate(msg, hashContent, sizeof(hashContent), TRUE); @@ -2862,16 +2722,10 @@ static void test_decode_msg_get_param(void) sizeof(hashParam)); check_param("hash computed hash", msg, CMSG_COMPUTED_HASH_PARAM, hashParam, sizeof(hashParam)); - /* Curiously, on NT-like systems, getting the hash of index 1 succeeds, - * even though there's only one hash. - */ + ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 1, NULL, &size); - ok(ret || GetLastError() == OSS_DATA_ERROR /* Win9x */, - "CryptMsgGetParam failed: %08lx\n", GetLastError()); - if (ret) - buf = CryptMemAlloc(size); - else - buf = NULL; + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); + buf = CryptMemAlloc(size); if (buf) { ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 1, buf, &size); @@ -2901,12 +2755,8 @@ static void test_decode_msg_get_param(void) ok(value == 1, "Expected 1 signer, got %ld\n", value); size = 0; ret = CryptMsgGetParam(msg, CMSG_SIGNER_INFO_PARAM, 0, NULL, &size); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */), - "CryptMsgGetParam failed: %08lx\n", GetLastError()); - if (ret) - buf = CryptMemAlloc(size); - else - buf = NULL; + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); + buf = CryptMemAlloc(size); if (buf) { CMSG_SIGNER_INFO signer = { 0 }; @@ -2927,12 +2777,8 @@ static void test_decode_msg_get_param(void) /* Getting the CMS signer info of a PKCS7 message is possible. */ size = 0; ret = CryptMsgGetParam(msg, CMSG_CMS_SIGNER_INFO_PARAM, 0, NULL, &size); - ok(ret || broken(GetLastError() == CRYPT_E_INVALID_MSG_TYPE /* Win9x */), - "CryptMsgGetParam failed: %08lx\n", GetLastError()); - if (ret) - buf = CryptMemAlloc(size); - else - buf = NULL; + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); + buf = CryptMemAlloc(size); if (buf) { CMSG_CMS_SIGNER_INFO signer = { 0 }; @@ -2983,12 +2829,6 @@ static void test_decode_msg_get_param(void) msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); ret = CryptMsgUpdate(msg, signedKeyIdEmptyContent, sizeof(signedKeyIdEmptyContent), TRUE); - if (!ret && GetLastError() == OSS_DATA_ERROR) - { - CryptMsgClose(msg); - win_skip("Subsequent tests crash on some Win9x\n"); - return; - } ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); size = sizeof(value); ret = CryptMsgGetParam(msg, CMSG_SIGNER_COUNT_PARAM, 0, &value, &size); @@ -3000,10 +2840,7 @@ static void test_decode_msg_get_param(void) size = 0; ret = CryptMsgGetParam(msg, CMSG_SIGNER_INFO_PARAM, 0, NULL, &size); ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); - if (ret) - buf = CryptMemAlloc(size); - else - buf = NULL; + buf = CryptMemAlloc(size); if (buf) { CMSG_SIGNER_INFO signer; @@ -3027,10 +2864,7 @@ static void test_decode_msg_get_param(void) size = 0; ret = CryptMsgGetParam(msg, CMSG_CMS_SIGNER_INFO_PARAM, 0, NULL, &size); ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); - if (ret) - buf = CryptMemAlloc(size); - else - buf = NULL; + buf = CryptMemAlloc(size); if (buf) { CMSG_CMS_SIGNER_INFO signer = { 0 }; @@ -3065,30 +2899,23 @@ static void test_decode_msg_get_param(void) SetLastError(0xdeadbeef); ret = CryptImportKey(hCryptProv, publicPrivateKeyPair, sizeof(publicPrivateKeyPair), 0, 0, &key); - ok(ret || - broken(!ret && GetLastError() == NTE_PERM), /* WinME and some NT4 */ - "CryptImportKey failed: %08lx\n", GetLastError()); + ok(ret, "CryptImportKey failed: %08lx\n", GetLastError());
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); CryptMsgUpdate(msg, envelopedMessage, sizeof(envelopedMessage), TRUE); check_param("enveloped message before decrypting", msg, CMSG_CONTENT_PARAM, envelopedMessage + sizeof(envelopedMessage) - 4, 4); - if (key) - { - decryptPara.hCryptProv = hCryptProv; - SetLastError(0xdeadbeef); - ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara); - ok(ret, "CryptMsgControl failed: %08lx\n", GetLastError()); - decryptPara.hCryptProv = 0; - SetLastError(0xdeadbeef); - ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara); - ok(!ret && GetLastError() == CRYPT_E_ALREADY_DECRYPTED, - "expected CRYPT_E_ALREADY_DECRYPTED, got %08lx\n", GetLastError()); - check_param("enveloped message", msg, CMSG_CONTENT_PARAM, msgData, - sizeof(msgData)); - } - else - win_skip("failed to import a key, skipping tests\n"); + + decryptPara.hCryptProv = hCryptProv; + SetLastError(0xdeadbeef); + ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara); + ok(ret, "CryptMsgControl failed: %08lx\n", GetLastError()); + decryptPara.hCryptProv = 0; + SetLastError(0xdeadbeef); + ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara); + ok(!ret && GetLastError() == CRYPT_E_ALREADY_DECRYPTED, + "expected CRYPT_E_ALREADY_DECRYPTED, got %08lx\n", GetLastError()); + check_param("enveloped message", msg, CMSG_CONTENT_PARAM, msgData, sizeof(msgData)); CryptMsgClose(msg);
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, 0, NULL, @@ -3098,17 +2925,12 @@ static void test_decode_msg_get_param(void) check_param("enveloped bare message before decrypting", msg, CMSG_CONTENT_PARAM, envelopedBareMessage + sizeof(envelopedBareMessage) - 4, 4); - if (key) - { - decryptPara.hCryptProv = hCryptProv; - SetLastError(0xdeadbeef); - ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara); - ok(ret, "CryptMsgControl failed: %08lx\n", GetLastError()); - check_param("enveloped bare message", msg, CMSG_CONTENT_PARAM, msgData, - sizeof(msgData)); - } - else - win_skip("failed to import a key, skipping tests\n"); + + decryptPara.hCryptProv = hCryptProv; + SetLastError(0xdeadbeef); + ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara); + ok(ret, "CryptMsgControl failed: %08lx\n", GetLastError()); + check_param("enveloped bare message", msg, CMSG_CONTENT_PARAM, msgData, sizeof(msgData)); CryptMsgClose(msg);
if (key) @@ -3191,7 +3013,7 @@ static void test_msg_control(void) msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL, NULL); /* either with no prior update.. */ - for (i = 1; !old_crypt32 && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++) + for (i = 1; i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO; i++) { SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, i, NULL); @@ -3201,7 +3023,7 @@ static void test_msg_control(void) ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); /* or after an update. */ - for (i = 1; !old_crypt32 && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++) + for (i = 1; i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO; i++) { SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, i, NULL); @@ -3216,7 +3038,7 @@ static void test_msg_control(void) msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo, NULL, NULL); /* either with no prior update.. */ - for (i = 1; !old_crypt32 && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++) + for (i = 1; i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO; i++) { SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, i, NULL); @@ -3226,7 +3048,7 @@ static void test_msg_control(void) ret = CryptMsgUpdate(msg, NULL, 0, TRUE); ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); /* or after an update. */ - for (i = 1; !old_crypt32 && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++) + for (i = 1; i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO; i++) { SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, i, NULL); @@ -3240,7 +3062,7 @@ static void test_msg_control(void) msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); /* either before an update.. */ - for (i = 1; !old_crypt32 && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++) + for (i = 1; i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO; i++) { SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, i, NULL); @@ -3250,7 +3072,7 @@ static void test_msg_control(void) ret = CryptMsgUpdate(msg, NULL, 0, TRUE); ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); /* or after an update. */ - for (i = 1; !old_crypt32 && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++) + for (i = 1; i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO; i++) { SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, i, NULL); @@ -3284,31 +3106,25 @@ static void test_msg_control(void) "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError()); CryptMsgClose(msg);
- if (!old_crypt32) - { - msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL, - NULL); - /* Can't verify the hash of an empty message */ - SetLastError(0xdeadbeef); - /* Crashes on some Win9x */ - ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL); - todo_wine - ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); - /* Crashes - ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, NULL); - */ - /* Can't verify the signature of a hash message */ - ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo); - ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError()); - CryptMsgUpdate(msg, hashEmptyBareContent, sizeof(hashEmptyBareContent), - TRUE); - /* Oddly enough, this fails, crashes on some Win9x */ - ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL); - ok(!ret, "Expected failure\n"); - CryptMsgClose(msg); - } + msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL, NULL); + /* Can't verify the hash of an empty message */ + SetLastError(0xdeadbeef); + ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL); + todo_wine + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + /* Crashes + ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, NULL); + */ + /* Can't verify the signature of a hash message */ + ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo); + ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, + "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError()); + CryptMsgUpdate(msg, hashEmptyBareContent, sizeof(hashEmptyBareContent), TRUE); + ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL); + ok(!ret, "Expected failure\n"); + CryptMsgClose(msg); + msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL, NULL); CryptMsgUpdate(msg, hashBareContent, sizeof(hashBareContent), TRUE); @@ -3344,10 +3160,7 @@ static void test_msg_control(void) SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); todo_wine - ok(!ret && - (GetLastError() == NTE_BAD_HASH_STATE || - GetLastError() == NTE_BAD_ALGID || /* Win9x */ - GetLastError() == CRYPT_E_MSG_ERROR), /* Vista */ + ok(!ret && (GetLastError() == NTE_BAD_HASH_STATE || GetLastError() == CRYPT_E_MSG_ERROR), /* Vista */ "Expected NTE_BAD_HASH_STATE or NTE_BAD_ALGID or CRYPT_E_MSG_ERROR, " "got %08lx\n", GetLastError()); CryptMsgClose(msg); @@ -3393,10 +3206,8 @@ static void test_msg_control(void) */ SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo); - ok(!ret && (GetLastError() == CRYPT_E_SIGNER_NOT_FOUND || - GetLastError() == OSS_DATA_ERROR /* Win9x */), - "Expected CRYPT_E_SIGNER_NOT_FOUND or OSS_DATA_ERROR, got %08lx\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_SIGNER_NOT_FOUND, + "Expected CRYPT_E_SIGNER_NOT_FOUND, got %08lx\n", GetLastError()); /* The cert info is expected to have an issuer, serial number, and public * key info set. */ @@ -3406,9 +3217,8 @@ static void test_msg_control(void) certInfo.Issuer.pbData = encodedCommonName; SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_DATA_ERROR /* Win9x */), - "Expected CRYPT_E_ASN1_EOD or OSS_DATA_ERROR, got %08lx\n", GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); CryptMsgClose(msg); /* This cert has a public key, but it's not in a usable form */ msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, 0, NULL, @@ -3417,7 +3227,6 @@ static void test_msg_control(void) sizeof(signedWithCertWithPubKeyBareContent), TRUE); if (ret) { - /* Crashes on some Win9x */ /* Again, cert info needs to have a public key set */ SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo); @@ -3471,7 +3280,6 @@ static void test_msg_control(void) certInfo.SubjectPublicKeyInfo.PublicKey.cbData = sizeof(pubKey); certInfo.SubjectPublicKeyInfo.PublicKey.pbData = pubKey; SetLastError(0xdeadbeef); - /* Crashes on some Win9x */ ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo); ok(!ret && (GetLastError() == NTE_BAD_SIGNATURE || @@ -3484,8 +3292,7 @@ static void test_msg_control(void) CryptMsgUpdate(msg, signedWithCertWithValidPubKeyContent, sizeof(signedWithCertWithValidPubKeyContent), TRUE); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */), - "CryptMsgControl failed: %08lx\n", GetLastError()); + ok(ret, "CryptMsgControl failed: %08lx\n", GetLastError()); CryptMsgClose(msg);
/* Test verifying signature of a detached signed message */ @@ -3497,21 +3304,15 @@ static void test_msg_control(void) /* Can't verify the sig without having updated the data */ SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo); - ok(!ret && (GetLastError() == NTE_BAD_SIGNATURE || - GetLastError() == OSS_DATA_ERROR /* Win9x */), - "expected NTE_BAD_SIGNATURE or OSS_DATA_ERROR, got %08lx\n", + ok(!ret && GetLastError() == NTE_BAD_SIGNATURE, + "expected NTE_BAD_SIGNATURE, got %08lx\n", GetLastError()); /* Now that the signature's been checked, can't do the final update */ SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); todo_wine - ok((!ret && - (GetLastError() == NTE_BAD_HASH_STATE || - GetLastError() == NTE_BAD_ALGID || /* Win9x */ - GetLastError() == CRYPT_E_MSG_ERROR)) || /* Vista */ - broken(ret), /* Win9x */ - "expected NTE_BAD_HASH_STATE or NTE_BAD_ALGID or CRYPT_E_MSG_ERROR, " - "got %08lx\n", GetLastError()); + ok(!ret && (GetLastError() == NTE_BAD_HASH_STATE || GetLastError() == CRYPT_E_MSG_ERROR), /* Vista */ + "expected NTE_BAD_HASH_STATE or CRYPT_E_MSG_ERROR, got %08lx\n", GetLastError()); CryptMsgClose(msg); /* Updating with the detached portion of the message and the data of the * the message allows the sig to be verified. @@ -3524,8 +3325,7 @@ static void test_msg_control(void) ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */), - "CryptMsgControl failed: %08lx\n", GetLastError()); + ok(ret, "CryptMsgControl failed: %08lx\n", GetLastError()); CryptMsgClose(msg);
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, 0, NULL, @@ -3536,13 +3336,12 @@ static void test_msg_control(void) ok(!ret && GetLastError() == E_INVALIDARG, "expected E_INVALIDARG, got %08lx\n", GetLastError()); decryptPara.cbSize = sizeof(decryptPara); - if (!old_crypt32) - { - SetLastError(0xdeadbeef); - ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara); - ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError()); - } + + SetLastError(0xdeadbeef); + ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara); + ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, + "expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError()); + SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, envelopedEmptyBareContent, sizeof(envelopedEmptyBareContent), TRUE); @@ -3616,7 +3415,6 @@ static void test_msg_get_and_verify_signer(void) ret = CryptMsgUpdate(msg, signedEmptyContent, sizeof(signedEmptyContent), TRUE); if (ret) { - /* Crashes on most Win9x */ ret = CryptMsgGetAndVerifySigner(msg, 0, NULL, 0, NULL, NULL); ok(!ret && GetLastError() == CRYPT_E_NO_TRUSTED_SIGNER, "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08lx\n", GetLastError()); @@ -3628,20 +3426,17 @@ static void test_msg_get_and_verify_signer(void) CryptMsgUpdate(msg, signedWithCertWithValidPubKeyContent, sizeof(signedWithCertWithValidPubKeyContent), TRUE); ret = CryptMsgGetAndVerifySigner(msg, 0, NULL, 0, NULL, NULL); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */), - "CryptMsgGetAndVerifySigner failed: 0x%08lx\n", GetLastError()); + ok(ret, "CryptMsgGetAndVerifySigner failed: 0x%08lx\n", GetLastError()); /* the signer index can be retrieved, .. */ signerIndex = 0xdeadbeef; ret = CryptMsgGetAndVerifySigner(msg, 0, NULL, 0, NULL, &signerIndex); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */), - "CryptMsgGetAndVerifySigner failed: 0x%08lx\n", GetLastError()); + ok(ret, "CryptMsgGetAndVerifySigner failed: 0x%08lx\n", GetLastError()); if (ret) ok(signerIndex == 0, "expected 0, got %ld\n", signerIndex); /* as can the signer cert. */ signer = (PCCERT_CONTEXT)0xdeadbeef; ret = CryptMsgGetAndVerifySigner(msg, 0, NULL, 0, &signer, NULL); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */), - "CryptMsgGetAndVerifySigner failed: 0x%08lx\n", GetLastError()); + ok(ret, "CryptMsgGetAndVerifySigner failed: 0x%08lx\n", GetLastError()); if (ret) ok(signer != NULL && signer != (PCCERT_CONTEXT)0xdeadbeef, "expected a valid signer\n"); @@ -3661,8 +3456,7 @@ static void test_msg_get_and_verify_signer(void) SetLastError(0xdeadbeef); ret = CryptMsgGetAndVerifySigner(msg, 0, NULL, CMSG_TRUSTED_SIGNER_FLAG, NULL, NULL); - ok(!ret && (GetLastError() == CRYPT_E_NO_TRUSTED_SIGNER || - broken(GetLastError() == OSS_DATA_ERROR /* Win9x */)), + ok(!ret && GetLastError() == CRYPT_E_NO_TRUSTED_SIGNER, "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08lx\n", GetLastError()); /* Specifying CMSG_TRUSTED_SIGNER_FLAG and an empty cert store also causes * the message signer not to be found. @@ -3672,35 +3466,25 @@ static void test_msg_get_and_verify_signer(void) SetLastError(0xdeadbeef); ret = CryptMsgGetAndVerifySigner(msg, 1, &store, CMSG_TRUSTED_SIGNER_FLAG, NULL, NULL); - ok(!ret && (GetLastError() == CRYPT_E_NO_TRUSTED_SIGNER || - broken(GetLastError() == OSS_DATA_ERROR /* Win9x */)), + ok(!ret && GetLastError() == CRYPT_E_NO_TRUSTED_SIGNER, "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08lx\n", GetLastError()); ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, v1CertWithValidPubKey, sizeof(v1CertWithValidPubKey), CERT_STORE_ADD_ALWAYS, NULL); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win98 */), - "CertAddEncodedCertificateToStore failed: 0x%08lx\n", GetLastError()); + ok(ret, "CertAddEncodedCertificateToStore failed: 0x%08lx\n", GetLastError()); /* Specifying CMSG_TRUSTED_SIGNER_FLAG with a cert store that contains * the signer succeeds. */ SetLastError(0xdeadbeef); ret = CryptMsgGetAndVerifySigner(msg, 1, &store, CMSG_TRUSTED_SIGNER_FLAG, NULL, NULL); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */), - "CryptMsgGetAndVerifySigner failed: 0x%08lx\n", GetLastError()); + ok(ret, "CryptMsgGetAndVerifySigner failed: 0x%08lx\n", GetLastError()); CertCloseStore(store, 0); CryptMsgClose(msg); }
START_TEST(msg) { - /* I_CertUpdateStore can be used for verification if crypt32 is new enough */ - if (!GetProcAddress(GetModuleHandleA("crypt32.dll"), "I_CertUpdateStore")) - { - win_skip("Some tests will crash on older crypt32 implementations\n"); - old_crypt32 = TRUE; - } - /* Basic parameter checking tests */ test_msg_open_to_encode(); test_msg_open_to_decode(); diff --git a/dlls/crypt32/tests/object.c b/dlls/crypt32/tests/object.c index 8fbba2cd83c..a3c7c8c0743 100644 --- a/dlls/crypt32/tests/object.c +++ b/dlls/crypt32/tests/object.c @@ -26,9 +26,6 @@
#include "wine/test.h"
-static BOOL (WINAPI * pCryptQueryObject)(DWORD, const void *, DWORD, DWORD, - DWORD, DWORD *, DWORD *, DWORD *, HCERTSTORE *, HCRYPTMSG *, const void **); - static BYTE bigCert[] = { 0x30,0x7a,0x02,0x01,0x01,0x30,0x02,0x06,0x00,0x30,0x15,0x31, 0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75, @@ -105,12 +102,12 @@ static void test_query_object(void)
/* Test the usual invalid arguments */ SetLastError(0xdeadbeef); - ret = pCryptQueryObject(0, NULL, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, + ret = CryptQueryObject(0, NULL, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, "expected E_INVALIDARG, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); - ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, NULL, 0, 0, 0, NULL, NULL, + ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, NULL, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, "expected E_INVALIDARG, got %08lx\n", GetLastError()); @@ -118,7 +115,7 @@ static void test_query_object(void) blob.pbData = bigCert; blob.cbData = sizeof(bigCert); SetLastError(0xdeadbeef); - ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, + ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL, NULL, NULL, NULL, NULL); ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError()); @@ -126,19 +123,19 @@ static void test_query_object(void) blob.pbData = (BYTE *)bigCertBase64; blob.cbData = sizeof(bigCertBase64); SetLastError(0xdeadbeef); - ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, + ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL, NULL, NULL, NULL, NULL); ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError()); /* The same base64-encoded cert, restricting the format types */ SetLastError(0xdeadbeef); - ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, + ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_BINARY, 0, NULL, NULL, NULL, NULL, NULL, NULL); ok(!ret && GetLastError() == CRYPT_E_NO_MATCH, "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); - ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, + ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED, 0, NULL, NULL, NULL, NULL, NULL, NULL); ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError()); @@ -146,7 +143,7 @@ static void test_query_object(void) blob.pbData = (BYTE *)bigCertBase64W; blob.cbData = sizeof(bigCertBase64W); SetLastError(0xdeadbeef); - ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, + ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL, NULL, NULL, NULL, NULL); ok(!ret && GetLastError() == CRYPT_E_NO_MATCH, @@ -159,14 +156,14 @@ static void test_query_object(void) blob.pbData = signedWithCertWithValidPubKeyContent; blob.cbData = sizeof(signedWithCertWithValidPubKeyContent); SetLastError(0xdeadbeef); - ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, + ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL, NULL, NULL, NULL, NULL); ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError()); blob.pbData = (BYTE *)signedWithCertWithValidPubKeyContentBase64; blob.cbData = sizeof(signedWithCertWithValidPubKeyContentBase64); SetLastError(0xdeadbeef); - ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, + ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL, NULL, NULL, NULL, NULL); ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError()); @@ -176,18 +173,18 @@ static void test_query_object(void) blob.pbData = (BYTE *)signedWithCertWithValidPubKeyContentBase64W; blob.cbData = sizeof(signedWithCertWithValidPubKeyContentBase64W); SetLastError(0xdeadbeef); - ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, + ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL, NULL, NULL, NULL, NULL); ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError()); SetLastError(0xdeadbeef); - ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, + ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_BINARY, 0, NULL, NULL, NULL, NULL, NULL, NULL); ok(!ret && GetLastError() == CRYPT_E_NO_MATCH, "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); - ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, + ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED, 0, NULL, NULL, NULL, NULL, NULL, NULL); ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError()); @@ -195,15 +192,5 @@ static void test_query_object(void)
START_TEST(object) { - HMODULE mod = GetModuleHandleA("crypt32.dll"); - - pCryptQueryObject = (void *)GetProcAddress(mod, "CryptQueryObject"); - - if (!pCryptQueryObject) - { - win_skip("CryptQueryObject is not available\n"); - return; - } - test_query_object(); } diff --git a/dlls/crypt32/tests/oid.c b/dlls/crypt32/tests/oid.c index 291636be388..9520e8c5a4a 100644 --- a/dlls/crypt32/tests/oid.c +++ b/dlls/crypt32/tests/oid.c @@ -29,73 +29,68 @@
#include "wine/test.h"
- -static BOOL (WINAPI *pCryptEnumOIDInfo)(DWORD,DWORD,void*,PFN_CRYPT_ENUM_OID_INFO); - - struct OIDToAlgID { LPCSTR oid; - LPCSTR altOid; DWORD algID; DWORD altAlgID; };
static const struct OIDToAlgID oidToAlgID[] = { - { szOID_RSA_RSA, NULL, CALG_RSA_KEYX }, - { szOID_RSA_MD2RSA, NULL, CALG_MD2 }, - { szOID_RSA_MD4RSA, NULL, CALG_MD4 }, - { szOID_RSA_MD5RSA, NULL, CALG_MD5 }, - { szOID_RSA_SHA1RSA, NULL, CALG_SHA }, - { szOID_RSA_DH, NULL, CALG_DH_SF }, - { szOID_RSA_SMIMEalgESDH, NULL, CALG_DH_EPHEM }, - { szOID_RSA_SMIMEalgCMS3DESwrap, NULL, CALG_3DES }, - { szOID_RSA_SMIMEalgCMSRC2wrap, NULL, CALG_RC2 }, - { szOID_RSA_MD2, NULL, CALG_MD2 }, - { szOID_RSA_MD4, NULL, CALG_MD4 }, - { szOID_RSA_MD5, NULL, CALG_MD5 }, - { szOID_RSA_RC2CBC, NULL, CALG_RC2 }, - { szOID_RSA_RC4, NULL, CALG_RC4 }, - { szOID_RSA_DES_EDE3_CBC, NULL, CALG_3DES }, - { szOID_ANSI_X942_DH, NULL, CALG_DH_SF }, - { szOID_X957_DSA, NULL, CALG_DSS_SIGN }, - { szOID_X957_SHA1DSA, NULL, CALG_SHA }, - { szOID_OIWSEC_md4RSA, NULL, CALG_MD4 }, - { szOID_OIWSEC_md5RSA, NULL, CALG_MD5 }, - { szOID_OIWSEC_md4RSA2, NULL, CALG_MD4 }, - { szOID_OIWSEC_desCBC, NULL, CALG_DES }, - { szOID_OIWSEC_dsa, NULL, CALG_DSS_SIGN }, - { szOID_OIWSEC_shaDSA, NULL, CALG_SHA }, - { szOID_OIWSEC_shaRSA, NULL, CALG_SHA }, - { szOID_OIWSEC_sha, NULL, CALG_SHA }, - { szOID_OIWSEC_rsaXchg, NULL, CALG_RSA_KEYX }, - { szOID_OIWSEC_sha1, NULL, CALG_SHA }, - { szOID_OIWSEC_dsaSHA1, NULL, CALG_SHA }, - { szOID_OIWSEC_sha1RSASign, NULL, CALG_SHA }, - { szOID_OIWDIR_md2RSA, NULL, CALG_MD2 }, - { szOID_INFOSEC_mosaicUpdatedSig, NULL, CALG_SHA }, - { szOID_INFOSEC_mosaicKMandUpdSig, NULL, CALG_DSS_SIGN }, - { szOID_NIST_sha256, NULL, CALG_SHA_256, -1 }, - { szOID_NIST_sha384, NULL, CALG_SHA_384, -1 }, - { szOID_NIST_sha512, NULL, CALG_SHA_512, -1 } + { szOID_RSA_RSA, CALG_RSA_KEYX }, + { szOID_RSA_MD2RSA, CALG_MD2 }, + { szOID_RSA_MD4RSA, CALG_MD4 }, + { szOID_RSA_MD5RSA, CALG_MD5 }, + { szOID_RSA_SHA1RSA, CALG_SHA }, + { szOID_RSA_DH, CALG_DH_SF }, + { szOID_RSA_SMIMEalgESDH, CALG_DH_EPHEM }, + { szOID_RSA_SMIMEalgCMS3DESwrap, CALG_3DES }, + { szOID_RSA_SMIMEalgCMSRC2wrap, CALG_RC2 }, + { szOID_RSA_MD2, CALG_MD2 }, + { szOID_RSA_MD4, CALG_MD4 }, + { szOID_RSA_MD5, CALG_MD5 }, + { szOID_RSA_RC2CBC, CALG_RC2 }, + { szOID_RSA_RC4, CALG_RC4 }, + { szOID_RSA_DES_EDE3_CBC, CALG_3DES }, + { szOID_ANSI_X942_DH, CALG_DH_SF }, + { szOID_X957_DSA, CALG_DSS_SIGN }, + { szOID_X957_SHA1DSA, CALG_SHA }, + { szOID_OIWSEC_md4RSA, CALG_MD4 }, + { szOID_OIWSEC_md5RSA, CALG_MD5 }, + { szOID_OIWSEC_md4RSA2, CALG_MD4 }, + { szOID_OIWSEC_desCBC, CALG_DES }, + { szOID_OIWSEC_dsa, CALG_DSS_SIGN }, + { szOID_OIWSEC_shaDSA, CALG_SHA }, + { szOID_OIWSEC_shaRSA, CALG_SHA }, + { szOID_OIWSEC_sha, CALG_SHA }, + { szOID_OIWSEC_rsaXchg, CALG_RSA_KEYX }, + { szOID_OIWSEC_sha1, CALG_SHA }, + { szOID_OIWSEC_dsaSHA1, CALG_SHA }, + { szOID_OIWSEC_sha1RSASign, CALG_SHA }, + { szOID_OIWDIR_md2RSA, CALG_MD2 }, + { szOID_INFOSEC_mosaicUpdatedSig, CALG_SHA }, + { szOID_INFOSEC_mosaicKMandUpdSig, CALG_DSS_SIGN }, + { szOID_NIST_sha256, CALG_SHA_256, -1 }, + { szOID_NIST_sha384, CALG_SHA_384, -1 }, + { szOID_NIST_sha512, CALG_SHA_512, -1 } };
static const struct OIDToAlgID algIDToOID[] = { - { szOID_RSA_RSA, NULL, CALG_RSA_KEYX }, - { szOID_RSA_SMIMEalgESDH, NULL, CALG_DH_EPHEM }, - { szOID_RSA_MD2, NULL, CALG_MD2 }, - { szOID_RSA_MD4, NULL, CALG_MD4 }, - { szOID_RSA_MD5, NULL, CALG_MD5 }, - { szOID_RSA_RC2CBC, NULL, CALG_RC2 }, - { szOID_RSA_RC4, NULL, CALG_RC4 }, - { szOID_RSA_DES_EDE3_CBC, NULL, CALG_3DES }, - { szOID_ANSI_X942_DH, NULL, CALG_DH_SF }, - { szOID_X957_DSA, szOID_OIWSEC_dsa /* some Win98 */, CALG_DSS_SIGN }, - { szOID_OIWSEC_desCBC, NULL, CALG_DES }, - { szOID_OIWSEC_sha1, NULL, CALG_SHA }, + { szOID_RSA_RSA, CALG_RSA_KEYX }, + { szOID_RSA_SMIMEalgESDH, CALG_DH_EPHEM }, + { szOID_RSA_MD2, CALG_MD2 }, + { szOID_RSA_MD4, CALG_MD4 }, + { szOID_RSA_MD5, CALG_MD5 }, + { szOID_RSA_RC2CBC, CALG_RC2 }, + { szOID_RSA_RC4, CALG_RC4 }, + { szOID_RSA_DES_EDE3_CBC, CALG_3DES }, + { szOID_ANSI_X942_DH, CALG_DH_SF }, + { szOID_X957_DSA, CALG_DSS_SIGN }, + { szOID_OIWSEC_desCBC, CALG_DES }, + { szOID_OIWSEC_sha1, CALG_SHA }, };
-static void testOIDToAlgID(void) +static void test_OIDToAlgID(void) { int i; DWORD alg; @@ -112,7 +107,7 @@ static void testOIDToAlgID(void) } }
-static void testAlgIDToOID(void) +static void test_AlgIDToOID(void) { int i; LPCSTR oid; @@ -126,27 +121,9 @@ static void testAlgIDToOID(void) { oid = CertAlgIdToOID(algIDToOID[i].algID); /* Allow failure, not every version of Windows supports every algo */ - ok(oid != NULL || broken(!oid), "CertAlgIdToOID failed, expected %s\n", algIDToOID[i].oid); + ok(oid != NULL, "CertAlgIdToOID failed, expected %s\n", algIDToOID[i].oid); if (oid) - { - if (strcmp(oid, algIDToOID[i].oid)) - { - if (algIDToOID[i].altOid) - ok(!strcmp(oid, algIDToOID[i].altOid), - "Expected %s or %s, got %s\n", algIDToOID[i].oid, - algIDToOID[i].altOid, oid); - else - { - /* No need to rerun the test, we already know it failed. */ - ok(0, "Expected %s, got %s\n", algIDToOID[i].oid, oid); - } - } - else - { - /* No need to rerun the test, we already know it succeeded. */ - ok(1, "Expected %s, got %s\n", algIDToOID[i].oid, oid); - } - } + ok(!strcmp(oid, algIDToOID[i].oid), "Expected %s, got %s\n", algIDToOID[i].oid, oid); } }
@@ -213,8 +190,7 @@ static void test_oidFunctionSet(void)
ret = CryptGetOIDFunctionAddress(set1, X509_ASN_ENCODING, X509_CERT, 0, &funcAddr, &hFuncAddr); - ok((!ret && GetLastError() == ERROR_FILE_NOT_FOUND) || - broken(ret) /* some Win98 */, + ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); } } @@ -266,10 +242,8 @@ static void test_installOIDFunctionAddress(void) */ ret = CryptGetOIDFunctionAddress(set, X509_ASN_ENCODING, 0, 0, (void **)&funcAddr, &hFuncAddr); - ok(!ret && (GetLastError() == ERROR_FILE_NOT_FOUND || - GetLastError() == E_INVALIDARG /* some Win98 */), - "Expected ERROR_FILE_NOT_FOUND or E_INVALIDARG, got %ld\n", - GetLastError()); + ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, + "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError()); ret = CryptGetOIDFunctionAddress(set, X509_ASN_ENCODING, X509_CERT, 0, (void **)&funcAddr, &hFuncAddr); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, @@ -520,20 +494,14 @@ static void test_enumOIDInfo(void) BOOL ret; DWORD count = 0;
- if (!pCryptEnumOIDInfo) - { - win_skip("CryptEnumOIDInfo() is not available\n"); - return; - } - /* This crashes - ret = pCryptEnumOIDInfo(7, 0, NULL, NULL); + ret = CryptEnumOIDInfo(7, 0, NULL, NULL); */
/* Silly tests, check that more than one thing is enumerated */ - ret = pCryptEnumOIDInfo(0, 0, &count, countOidInfo); + ret = CryptEnumOIDInfo(0, 0, &count, countOidInfo); ok(ret && count > 0, "Expected more than item enumerated\n"); - ret = pCryptEnumOIDInfo(0, 0, NULL, noOidInfo); + ret = CryptEnumOIDInfo(0, 0, NULL, noOidInfo); ok(!ret, "Expected FALSE\n"); }
@@ -700,11 +668,8 @@ static void test_registerOIDInfo(void)
START_TEST(oid) { - HMODULE hCrypt32 = GetModuleHandleA("crypt32.dll"); - pCryptEnumOIDInfo = (void*)GetProcAddress(hCrypt32, "CryptEnumOIDInfo"); - - testOIDToAlgID(); - testAlgIDToOID(); + test_OIDToAlgID(); + test_AlgIDToOID(); test_enumOIDInfo(); test_findOIDInfo(); test_registerOIDInfo(); diff --git a/dlls/crypt32/tests/protectdata.c b/dlls/crypt32/tests/protectdata.c index 162dab090e2..362f1faddb4 100644 --- a/dlls/crypt32/tests/protectdata.c +++ b/dlls/crypt32/tests/protectdata.c @@ -27,9 +27,6 @@
#include "wine/test.h"
-static BOOL (WINAPI *pCryptProtectData)(DATA_BLOB*,LPCWSTR,DATA_BLOB*,PVOID,CRYPTPROTECT_PROMPTSTRUCT*,DWORD,DATA_BLOB*); -static BOOL (WINAPI *pCryptUnprotectData)(DATA_BLOB*,LPWSTR*,DATA_BLOB*,PVOID,CRYPTPROTECT_PROMPTSTRUCT*,DWORD,DATA_BLOB*); - static char secret[] = "I am a super secret string that no one can see!"; static char secret2[] = "I am a super secret string indescribable string"; static char key[] = "Wibble wibble wibble"; @@ -51,13 +48,13 @@ static void test_cryptprotectdata(void) entropy.cbData=strlen(key)+1;
SetLastError(0xDEADBEEF); - protected = pCryptProtectData(NULL, L"Ultra secret test message", NULL, NULL, NULL, 0, &cipher); + protected = CryptProtectData(NULL, L"Ultra secret test message", NULL, NULL, NULL, 0, &cipher); ok(!protected, "Encrypting without plain data source.\n"); r = GetLastError(); ok(r == ERROR_INVALID_PARAMETER, "Wrong (%lu) GetLastError seen\n",r);
SetLastError(0xDEADBEEF); - protected = pCryptProtectData(&plain, L"Ultra secret test message", NULL, NULL, NULL, 0, NULL); + protected = CryptProtectData(&plain, L"Ultra secret test message", NULL, NULL, NULL, 0, NULL); ok(!protected, "Encrypting without cipher destination.\n"); r = GetLastError(); ok(r == ERROR_INVALID_PARAMETER, "Wrong (%lu) GetLastError seen\n",r); @@ -67,16 +64,12 @@ static void test_cryptprotectdata(void)
/* without entropy */ SetLastError(0xDEADBEEF); - protected = pCryptProtectData(&plain, L"Ultra secret test message", NULL, NULL, NULL, 0, &cipher); - ok(protected || - broken(!protected), /* Win9x/NT4 */ - "Encrypting without entropy.\n"); + protected = CryptProtectData(&plain, L"Ultra secret test message", NULL, NULL, NULL, 0, &cipher); + ok(protected, "Encrypting without entropy.\n"); if (protected) { r = GetLastError(); - ok(r == ERROR_SUCCESS || - r == ERROR_IO_PENDING, /* win2k */ - "Expected ERROR_SUCCESS or ERROR_IO_PENDING, got %ld\n",r); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n",r); }
cipher_entropy.pbData=NULL; @@ -84,10 +77,8 @@ static void test_cryptprotectdata(void)
/* with entropy */ SetLastError(0xDEADBEEF); - protected = pCryptProtectData(&plain, L"Ultra secret test message", &entropy, NULL, NULL, 0, &cipher_entropy); - ok(protected || - broken(!protected), /* Win9x/NT4 */ - "Encrypting with entropy.\n"); + protected = CryptProtectData(&plain, L"Ultra secret test message", &entropy, NULL, NULL, 0, &cipher_entropy); + ok(protected, "Encrypting with entropy.\n");
cipher_no_desc.pbData=NULL; cipher_no_desc.cbData=0; @@ -96,13 +87,8 @@ static void test_cryptprotectdata(void) plain.pbData=(void*)secret2; plain.cbData=strlen(secret2)+1; SetLastError(0xDEADBEEF); - protected = pCryptProtectData(&plain,NULL,&entropy,NULL,NULL,0,&cipher_no_desc); - if (!protected) - { - /* fails in win2k */ - ok(GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError()); - } + protected = CryptProtectData(&plain,NULL,&entropy,NULL,NULL,0,&cipher_no_desc); + ok(protected, "Encrypting with entropy.\n"); }
static void test_cryptunprotectdata(void) @@ -116,24 +102,17 @@ static void test_cryptunprotectdata(void) entropy.pbData=(void*)key; entropy.cbData=strlen(key)+1;
- /* fails in win2k */ - if (!protected) - { - skip("CryptProtectData failed to run\n"); - return; - } - plain.pbData=NULL; plain.cbData=0;
SetLastError(0xDEADBEEF); - okay = pCryptUnprotectData(&cipher,NULL,NULL,NULL,NULL,0,NULL); + okay = CryptUnprotectData(&cipher,NULL,NULL,NULL,NULL,0,NULL); ok(!okay,"Decrypting without destination\n"); r = GetLastError(); ok(r == ERROR_INVALID_PARAMETER, "Wrong (%lu) GetLastError seen\n",r);
SetLastError(0xDEADBEEF); - okay = pCryptUnprotectData(NULL,NULL,NULL,NULL,NULL,0,&plain); + okay = CryptUnprotectData(NULL,NULL,NULL,NULL,NULL,0,&plain); ok(!okay,"Decrypting without source\n"); r = GetLastError(); ok(r == ERROR_INVALID_PARAMETER, "Wrong (%lu) GetLastError seen\n",r); @@ -142,7 +121,7 @@ static void test_cryptunprotectdata(void) plain.cbData=0;
SetLastError(0xDEADBEEF); - okay = pCryptUnprotectData(&cipher_entropy,NULL,NULL,NULL,NULL,0,&plain); + okay = CryptUnprotectData(&cipher_entropy,NULL,NULL,NULL,NULL,0,&plain); ok(!okay,"Decrypting without needed entropy\n"); r = GetLastError(); ok(r == ERROR_INVALID_DATA, "Wrong (%lu) GetLastError seen\n", r); @@ -153,7 +132,7 @@ static void test_cryptunprotectdata(void)
/* without entropy */ SetLastError(0xDEADBEEF); - okay = pCryptUnprotectData(&cipher,&data_desc,NULL,NULL,NULL,0,&plain); + okay = CryptUnprotectData(&cipher,&data_desc,NULL,NULL,NULL,0,&plain); ok(okay,"Decrypting without entropy\n");
ok(plain.pbData!=NULL,"Plain DATA_BLOB missing data\n"); @@ -171,14 +150,14 @@ static void test_cryptunprotectdata(void)
/* with wrong entropy */ SetLastError(0xDEADBEEF); - okay = pCryptUnprotectData(&cipher_entropy,&data_desc,&cipher_entropy,NULL,NULL,0,&plain); + okay = CryptUnprotectData(&cipher_entropy,&data_desc,&cipher_entropy,NULL,NULL,0,&plain); ok(!okay,"Decrypting with wrong entropy\n"); r = GetLastError(); ok(r == ERROR_INVALID_DATA, "Wrong (%lu) GetLastError seen\n",r);
/* with entropy */ SetLastError(0xDEADBEEF); - okay = pCryptUnprotectData(&cipher_entropy,&data_desc,&entropy,NULL,NULL,0,&plain); + okay = CryptUnprotectData(&cipher_entropy,&data_desc,&entropy,NULL,NULL,0,&plain); ok(okay,"Decrypting with entropy\n");
ok(plain.pbData!=NULL,"Plain DATA_BLOB missing data\n"); @@ -196,7 +175,7 @@ static void test_cryptunprotectdata(void)
/* with entropy but no description */ SetLastError(0xDEADBEEF); - okay = pCryptUnprotectData(&cipher_no_desc,&data_desc,&entropy,NULL,NULL,0,&plain); + okay = CryptUnprotectData(&cipher_no_desc,&data_desc,&entropy,NULL,NULL,0,&plain); ok(okay,"Decrypting with entropy and no description\n");
ok(plain.pbData!=NULL,"Plain DATA_BLOB missing data\n"); @@ -223,16 +202,10 @@ static void test_simpleroundtrip(const char *plaintext) emptyW[0] = 0; input.pbData = (unsigned char *)plaintext; input.cbData = strlen(plaintext); - res = pCryptProtectData(&input, emptyW, NULL, NULL, NULL, 0, &encrypted); - ok(res != 0 || broken(!res), "can't protect\n"); - if (!res) - { - /* Fails on Win9x, NT4 */ - win_skip("CryptProtectData failed\n"); - return; - } + res = CryptProtectData(&input, emptyW, NULL, NULL, NULL, 0, &encrypted); + ok(res != 0, "can't protect\n");
- res = pCryptUnprotectData(&encrypted, NULL, NULL, NULL, NULL, 0, &output); + res = CryptUnprotectData(&encrypted, NULL, NULL, NULL, NULL, 0, &output); ok(res != 0, "can't unprotect; last error %lu\n", GetLastError()); ok(output.cbData == strlen(plaintext), "output wrong length %ld for input '%s', wanted %d\n", output.cbData, plaintext, lstrlenA(plaintext)); ok(!memcmp(plaintext, (char *)output.pbData, output.cbData), "output wrong contents for input '%s'\n", plaintext); @@ -242,16 +215,7 @@ static void test_simpleroundtrip(const char *plaintext)
START_TEST(protectdata) { - HMODULE hCrypt32 = GetModuleHandleA("crypt32.dll"); - pCryptProtectData = (void*)GetProcAddress(hCrypt32, "CryptProtectData"); - pCryptUnprotectData = (void*)GetProcAddress(hCrypt32, "CryptUnprotectData"); - if (!pCryptProtectData || !pCryptUnprotectData) - { - win_skip("Crypt(Un)ProtectData() is not available\n"); - return; - } - - protected=FALSE; + protected = FALSE; test_cryptprotectdata(); test_cryptunprotectdata(); test_simpleroundtrip(""); diff --git a/dlls/crypt32/tests/sip.c b/dlls/crypt32/tests/sip.c index 4a89393484e..1a61c558dd0 100644 --- a/dlls/crypt32/tests/sip.c +++ b/dlls/crypt32/tests/sip.c @@ -57,17 +57,6 @@ static void test_AddRemoveProvider(void) /* Apparently the needed rights are checked before the existence of the provider */ skip("Need admin rights\n"); } - else - { - /* On some Win98 systems, CryptSIPRemoveProvider always succeeds if - * the arguments are correct, whether or not the registry key is - * present, so don't test ret, just check the last error if it does - * return FALSE. - */ - if (!ret) - ok (GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %ld.\n", GetLastError()); - }
/* Everything OK, pwszIsFunctionName and pwszIsFunctionNameFmt2 are left NULL * as allowed */ @@ -96,14 +85,8 @@ static void test_AddRemoveProvider(void) */ SetLastError(0xdeadbeef); ret = CryptSIPRemoveProvider(&actionid); - /* On some Win98 systems, CryptSIPRemoveProvider always succeeds if - * the arguments are correct, whether or not the registry key is - * present, so don't test ret, just check the last error if it does - * return FALSE. - */ - if (!ret) - ok (GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %ld.\n", GetLastError()); + ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, + "Expected ERROR_FILE_NOT_FOUND, got %ld.\n", GetLastError());
/* Everything OK */ memset(&newprov, 0, sizeof(SIP_ADD_NEWPROVIDER)); @@ -223,11 +206,8 @@ static void test_SIPRetrieveSubjectGUID(void) memset(&subject, 1, sizeof(GUID)); ret = CryptSIPRetrieveSubjectGuid(tempfileW, NULL, &subject); ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n"); - ok ( GetLastError() == ERROR_FILE_INVALID || - GetLastError() == ERROR_INVALID_PARAMETER /* Vista */ || - GetLastError() == ERROR_SUCCESS /* most Win98 */ || - GetLastError() == TRUST_E_SUBJECT_FORM_UNKNOWN /* some Win98 */, - "Expected ERROR_FILE_INVALID, ERROR_INVALID_PARAMETER, ERROR_SUCCESS or TRUST_E_SUBJECT_FORM_UNKNOWN, got 0x%08lx\n", GetLastError()); + ok ( GetLastError() == ERROR_FILE_INVALID || GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_FILE_INVALID, ERROR_INVALID_PARAMETER, got 0x%08lx\n", GetLastError()); ok(IsEqualGUID(&subject, &nullSubject), "Expected a NULL GUID for empty file %s, not %s\n", tempfile, wine_dbgstr_guid(&subject));
@@ -240,10 +220,8 @@ static void test_SIPRetrieveSubjectGUID(void) memset(&subject, 1, sizeof(GUID)); ret = CryptSIPRetrieveSubjectGuid(tempfileW, NULL, &subject); ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n"); - ok ( GetLastError() == ERROR_INVALID_PARAMETER || - GetLastError() == ERROR_SUCCESS /* most Win98 */ || - GetLastError() == TRUST_E_SUBJECT_FORM_UNKNOWN /* some Win98 */, - "Expected ERROR_INVALID_PARAMETER, ERROR_SUCCESS or TRUST_E_SUBJECT_FORM_UNKNOWN, got 0x%08lx\n", GetLastError()); + ok ( GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got 0x%08lx\n", GetLastError()); ok(IsEqualGUID(&subject, &nullSubject), "Expected a NULL GUID for empty file %s, not %s\n", tempfile, wine_dbgstr_guid(&subject));
@@ -256,8 +234,7 @@ static void test_SIPRetrieveSubjectGUID(void) memset(&subject, 1, sizeof(GUID)); ret = CryptSIPRetrieveSubjectGuid(tempfileW, NULL, &subject); ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n"); - ok ( GetLastError() == TRUST_E_SUBJECT_FORM_UNKNOWN || - GetLastError() == ERROR_SUCCESS /* Win98 */, + ok ( GetLastError() == TRUST_E_SUBJECT_FORM_UNKNOWN, "Expected TRUST_E_SUBJECT_FORM_UNKNOWN or ERROR_SUCCESS, got 0x%08lx\n", GetLastError()); ok(IsEqualGUID(&subject, &nullSubject), "Expected a NULL GUID for empty file %s, not %s\n", tempfile, wine_dbgstr_guid(&subject)); diff --git a/dlls/crypt32/tests/store.c b/dlls/crypt32/tests/store.c index f1124459d6a..00c2cae19e0 100644 --- a/dlls/crypt32/tests/store.c +++ b/dlls/crypt32/tests/store.c @@ -157,14 +157,13 @@ static void testMemStore(void) context = NULL; ret = CertAddEncodedCertificateToStore(store1, X509_ASN_ENCODING, emptyCert, sizeof(emptyCert), CERT_STORE_ADD_ALWAYS, &context); - /* Windows returns CRYPT_E_ASN1_EOD or OSS_DATA_ERROR, but accept + /* Windows returns CRYPT_E_ASN1_EOD, but accept * CRYPT_E_ASN1_CORRUPT as well (because matching errors is tough in this * case) */ GLE = GetLastError(); - ok(!ret && (GLE == CRYPT_E_ASN1_EOD || GLE == CRYPT_E_ASN1_CORRUPT || - GLE == OSS_DATA_ERROR), - "Expected CRYPT_E_ASN1_EOD or CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08lx\n", + ok(!ret && (GLE == CRYPT_E_ASN1_EOD || GLE == CRYPT_E_ASN1_CORRUPT), + "Expected CRYPT_E_ASN1_EOD or CRYPT_E_ASN1_CORRUPT, got %08lx\n", GLE); /* add a "signed" cert--the signature isn't a real signature, so this adds * without any check of the signature's validity @@ -188,9 +187,8 @@ static void testMemStore(void) ret = CertAddEncodedCertificateToStore(store1, X509_ASN_ENCODING, signedCRL, sizeof(signedCRL), CERT_STORE_ADD_ALWAYS, &context); GLE = GetLastError(); - ok(!ret && (GLE == CRYPT_E_ASN1_BADTAG || GLE == CRYPT_E_ASN1_CORRUPT || - GLE == OSS_DATA_ERROR), - "Expected CRYPT_E_ASN1_BADTAG or CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08lx\n", + ok(!ret && (GLE == CRYPT_E_ASN1_BADTAG || GLE == CRYPT_E_ASN1_CORRUPT), + "Expected CRYPT_E_ASN1_BADTAG or CRYPT_E_ASN1_CORRUPT, got %08lx\n", GLE); /* add a cert to store1 */ ret = CertAddEncodedCertificateToStore(store1, X509_ASN_ENCODING, bigCert, @@ -3232,8 +3230,7 @@ static void test_PFXImportCertStore(void) pfx.pbData = (BYTE *)pfxdata; pfx.cbData = sizeof(pfxdata); store = PFXImportCertStore( &pfx, NULL, CRYPT_EXPORTABLE|CRYPT_USER_KEYSET|PKCS12_NO_PERSIST_KEY ); - ok( store != NULL || broken(store == NULL) /* winxp */, "got %lu\n", GetLastError() ); - if (!store) return; + ok( store != NULL, "got %lu\n", GetLastError() ); count = countCertsInStore( store ); ok( count == 1, "got %lu\n", count );
diff --git a/dlls/crypt32/tests/str.c b/dlls/crypt32/tests/str.c index 6a19d264c14..a94381591c0 100644 --- a/dlls/crypt32/tests/str.c +++ b/dlls/crypt32/tests/str.c @@ -130,23 +130,6 @@ static char subjectStrCRLF[] = static char x500SubjectStr[] = "C=US, S=Minnesota, L=Minneapolis, O=CodeWeavers, OU=Wine Development, CN=localhost, E=aric@codeweavers.com"; static char x500SubjectStrSemicolonReverse[] = "E=aric@codeweavers.com; CN=localhost; OU=Wine Development; O=CodeWeavers; L=Minneapolis; S=Minnesota; C=US";
-static HMODULE dll; -static DWORD (WINAPI *pCertNameToStrA)(DWORD,LPVOID,DWORD,LPSTR,DWORD); -static DWORD (WINAPI *pCertNameToStrW)(DWORD,LPVOID,DWORD,LPWSTR,DWORD); -static DWORD (WINAPI *pCertRDNValueToStrA)(DWORD, PCERT_RDN_VALUE_BLOB, - LPSTR, DWORD); -static DWORD (WINAPI *pCertRDNValueToStrW)(DWORD, PCERT_RDN_VALUE_BLOB, - LPWSTR, DWORD); -static BOOL (WINAPI *pCertStrToNameA)(DWORD dwCertEncodingType, - LPCSTR pszX500, DWORD dwStrType, void *pvReserved, BYTE *pbEncoded, - DWORD *pcbEncoded, LPCSTR *ppszError); -static BOOL (WINAPI *pCertStrToNameW)(DWORD dwCertEncodingType, - LPCWSTR pszX500, DWORD dwStrType, void *pvReserved, BYTE *pbEncoded, - DWORD *pcbEncoded, LPCWSTR *ppszError); -static DWORD (WINAPI *pCertGetNameStringA)(PCCERT_CONTEXT cert, DWORD type, - DWORD flags, void *typePara, LPSTR str, DWORD cch); - - static void test_CertRDNValueToStrA(void) { CertRDNAttrEncoding attrs[] = { @@ -182,22 +165,20 @@ static void test_CertRDNValueToStrA(void) CERT_RDN_VALUE_BLOB blob = { 0, NULL }; static const char ePKI[] = "ePKI Root Certification Authority";
- if (!pCertRDNValueToStrA) return; - /* This crashes - ret = pCertRDNValueToStrA(0, NULL, NULL, 0); + ret = CertRDNValueToStrA(0, NULL, NULL, 0); */ /* With empty input, it generates the empty string */ SetLastError(0xdeadbeef); - ret = pCertRDNValueToStrA(0, &blob, NULL, 0); + ret = CertRDNValueToStrA(0, &blob, NULL, 0); ok(ret == 1 && GetLastError() == 0xdeadbeef, "Expected empty string\n"); - ret = pCertRDNValueToStrA(0, &blob, buffer, sizeof(buffer)); + ret = CertRDNValueToStrA(0, &blob, buffer, sizeof(buffer)); ok(ret == 1 && GetLastError() == 0xdeadbeef, "Expected empty string\n"); ok(!buffer[0], "Expected empty string\n");
for (i = 0; i < ARRAY_SIZE(attrs); i++) { - ret = pCertRDNValueToStrA(attrs[i].dwValueType, &attrs[i].Value, + ret = CertRDNValueToStrA(attrs[i].dwValueType, &attrs[i].Value, buffer, sizeof(buffer)); todo_wine_if (attrs[i].todo) { @@ -209,10 +190,9 @@ static void test_CertRDNValueToStrA(void) } blob.pbData = bin8; blob.cbData = sizeof(bin8); - ret = pCertRDNValueToStrA(CERT_RDN_UTF8_STRING, &blob, buffer, + ret = CertRDNValueToStrA(CERT_RDN_UTF8_STRING, &blob, buffer, sizeof(buffer)); - ok(ret == strlen(ePKI) + 1 || broken(ret != strlen(ePKI) + 1), - "Expected length %d, got %ld\n", lstrlenA(ePKI), ret); + ok(ret == strlen(ePKI) + 1, "Expected length %d, got %ld\n", lstrlenA(ePKI), ret); if (ret == strlen(ePKI) + 1) ok(!strcmp(buffer, ePKI), "Expected %s, got %s\n", ePKI, buffer); } @@ -252,26 +232,20 @@ static void test_CertRDNValueToStrW(void) WCHAR buffer[2000]; CERT_RDN_VALUE_BLOB blob = { 0, NULL };
- if (!pCertRDNValueToStrW) - { - win_skip("CertRDNValueToStrW is not available\n"); - return; - } - /* This crashes - ret = pCertRDNValueToStrW(0, NULL, NULL, 0); + ret = CertRDNValueToStrW(0, NULL, NULL, 0); */ /* With empty input, it generates the empty string */ SetLastError(0xdeadbeef); - ret = pCertRDNValueToStrW(0, &blob, NULL, 0); + ret = CertRDNValueToStrW(0, &blob, NULL, 0); ok(ret == 1 && GetLastError() == 0xdeadbeef, "Expected empty string\n"); - ret = pCertRDNValueToStrW(0, &blob, buffer, ARRAY_SIZE(buffer)); + ret = CertRDNValueToStrW(0, &blob, buffer, ARRAY_SIZE(buffer)); ok(ret == 1 && GetLastError() == 0xdeadbeef, "Expected empty string\n"); ok(!buffer[0], "Expected empty string\n");
for (i = 0; i < ARRAY_SIZE(attrs); i++) { - ret = pCertRDNValueToStrW(attrs[i].dwValueType, &attrs[i].Value, buffer, ARRAY_SIZE(buffer)); + ret = CertRDNValueToStrW(attrs[i].dwValueType, &attrs[i].Value, buffer, ARRAY_SIZE(buffer)); todo_wine_if (attrs[i].todo) { ok(ret == lstrlenW(attrs[i].str) + 1, @@ -282,10 +256,9 @@ static void test_CertRDNValueToStrW(void) } blob.pbData = bin8; blob.cbData = sizeof(bin8); - ret = pCertRDNValueToStrW(CERT_RDN_UTF8_STRING, &blob, buffer, + ret = CertRDNValueToStrW(CERT_RDN_UTF8_STRING, &blob, buffer, sizeof(buffer)); - ok(ret == lstrlenW(ePKIW) + 1 || broken(ret != lstrlenW(ePKIW) + 1), - "Expected length %d, got %ld\n", lstrlenW(ePKIW), ret); + ok(ret == lstrlenW(ePKIW) + 1, "Expected length %d, got %ld\n", lstrlenW(ePKIW), ret); if (ret == lstrlenW(ePKIW) + 1) ok(!lstrcmpW(buffer, ePKIW), "Expected %s, got %s\n", wine_dbgstr_w(ePKIW), wine_dbgstr_w(buffer)); @@ -297,11 +270,11 @@ static void test_NameToStrConversionA(PCERT_NAME_BLOB pName, DWORD dwStrType, char buffer[2000] = { 0 }; DWORD i;
- i = pCertNameToStrA(X509_ASN_ENCODING, pName, dwStrType, NULL, 0); + i = CertNameToStrA(X509_ASN_ENCODING, pName, dwStrType, NULL, 0); todo_wine_if (todo) ok(i == strlen(expected) + 1, "Expected %d chars, got %ld\n", lstrlenA(expected) + 1, i); - i = pCertNameToStrA(X509_ASN_ENCODING,pName, dwStrType, buffer, + i = CertNameToStrA(X509_ASN_ENCODING,pName, dwStrType, buffer, sizeof(buffer)); todo_wine_if (todo) ok(i == strlen(expected) + 1, "Expected %d chars, got %ld\n", @@ -357,12 +330,6 @@ static void test_CertNameToStrA(void) PCCERT_CONTEXT context; CERT_NAME_BLOB blob;
- if (!pCertNameToStrA) - { - win_skip("CertNameToStrA is not available\n"); - return; - } - context = CertCreateCertificateContext(X509_ASN_ENCODING, cert, sizeof(cert)); ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n", @@ -372,16 +339,16 @@ static void test_CertNameToStrA(void) DWORD ret;
/* This crashes - ret = pCertNameToStrA(0, NULL, 0, NULL, 0); + ret = CertNameToStrA(0, NULL, 0, NULL, 0); */ /* Test with a bogus encoding type */ SetLastError(0xdeadbeef); - ret = pCertNameToStrA(0, &context->pCertInfo->Issuer, 0, NULL, 0); + ret = CertNameToStrA(0, &context->pCertInfo->Issuer, 0, NULL, 0); ok(ret == 1 && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected retval 1 and ERROR_FILE_NOT_FOUND, got %ld - %08lx\n", ret, GetLastError()); SetLastError(0xdeadbeef); - ret = pCertNameToStrA(X509_ASN_ENCODING, &context->pCertInfo->Issuer, + ret = CertNameToStrA(X509_ASN_ENCODING, &context->pCertInfo->Issuer, 0, NULL, 0); ok(ret && GetLastError() == ERROR_SUCCESS, "Expected positive return and ERROR_SUCCESS, got %ld - %08lx\n", @@ -468,11 +435,11 @@ static void test_NameToStrConversionW(PCERT_NAME_BLOB pName, DWORD dwStrType, WCHAR buffer[2000] = { 0 }; DWORD i;
- i = pCertNameToStrW(X509_ASN_ENCODING,pName, dwStrType, NULL, 0); + i = CertNameToStrW(X509_ASN_ENCODING,pName, dwStrType, NULL, 0); todo_wine_if (todo) ok(i == lstrlenW(expected) + 1, "Expected %d chars, got %ld\n", lstrlenW(expected) + 1, i); - i = pCertNameToStrW(X509_ASN_ENCODING,pName, dwStrType, buffer, ARRAY_SIZE(buffer)); + i = CertNameToStrW(X509_ASN_ENCODING,pName, dwStrType, buffer, ARRAY_SIZE(buffer)); todo_wine_if (todo) ok(i == lstrlenW(expected) + 1, "Expected %d chars, got %ld\n", lstrlenW(expected) + 1, i); @@ -486,12 +453,6 @@ static void test_CertNameToStrW(void) PCCERT_CONTEXT context; CERT_NAME_BLOB blob;
- if (!pCertNameToStrW) - { - win_skip("CertNameToStrW is not available\n"); - return; - } - context = CertCreateCertificateContext(X509_ASN_ENCODING, cert, sizeof(cert)); ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n", @@ -501,16 +462,16 @@ static void test_CertNameToStrW(void) DWORD ret;
/* This crashes - ret = pCertNameToStrW(0, NULL, 0, NULL, 0); + ret = CertNameToStrW(0, NULL, 0, NULL, 0); */ /* Test with a bogus encoding type */ SetLastError(0xdeadbeef); - ret = pCertNameToStrW(0, &context->pCertInfo->Issuer, 0, NULL, 0); + ret = CertNameToStrW(0, &context->pCertInfo->Issuer, 0, NULL, 0); ok(ret == 1 && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected retval 1 and ERROR_FILE_NOT_FOUND, got %ld - %08lx\n", ret, GetLastError()); SetLastError(0xdeadbeef); - ret = pCertNameToStrW(X509_ASN_ENCODING, &context->pCertInfo->Issuer, + ret = CertNameToStrW(X509_ASN_ENCODING, &context->pCertInfo->Issuer, 0, NULL, 0); ok(ret && GetLastError() == ERROR_SUCCESS, "Expected positive return and ERROR_SUCCESS, got %ld - %08lx\n", @@ -640,69 +601,63 @@ static void test_CertStrToNameA(void) DWORD size, i; BYTE buf[100];
- if (!pCertStrToNameA) - { - win_skip("CertStrToNameA is not available\n"); - return; - } - /* Crash - ret = pCertStrToNameA(0, NULL, 0, NULL, NULL, NULL, NULL); + ret = CertStrToNameA(0, NULL, 0, NULL, NULL, NULL, NULL); */ - ret = pCertStrToNameA(0, NULL, 0, NULL, NULL, &size, NULL); + ret = CertStrToNameA(0, NULL, 0, NULL, NULL, &size, NULL); ok(!ret, "Expected failure\n"); - ret = pCertStrToNameA(0, "bogus", 0, NULL, NULL, &size, NULL); + ret = CertStrToNameA(0, "bogus", 0, NULL, NULL, &size, NULL); ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING, "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError()); - ret = pCertStrToNameA(0, "foo=1", 0, NULL, NULL, &size, NULL); + ret = CertStrToNameA(0, "foo=1", 0, NULL, NULL, &size, NULL); ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING, "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError()); - ret = pCertStrToNameA(0, "CN=1", 0, NULL, NULL, &size, NULL); + ret = CertStrToNameA(0, "CN=1", 0, NULL, NULL, &size, NULL); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); - ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=1", 0, NULL, NULL, &size, NULL); + ret = CertStrToNameA(X509_ASN_ENCODING, "CN=1", 0, NULL, NULL, &size, NULL); ok(ret, "CertStrToNameA failed: %08lx\n", GetLastError()); size = sizeof(buf); - ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=""1""", 0, NULL, buf, &size, + ret = CertStrToNameA(X509_ASN_ENCODING, "CN=""1""", 0, NULL, buf, &size, NULL); ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING, "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError()); - ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=1+2", 0, NULL, buf, + ret = CertStrToNameA(X509_ASN_ENCODING, "CN=1+2", 0, NULL, buf, &size, NULL); ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING, "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError()); - ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=1+2", CERT_NAME_STR_NO_PLUS_FLAG, NULL, buf, + ret = CertStrToNameA(X509_ASN_ENCODING, "CN=1+2", CERT_NAME_STR_NO_PLUS_FLAG, NULL, buf, &size, NULL); ok(ret && GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %08lx\n", GetLastError()); - ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=1,2", CERT_NAME_STR_NO_QUOTING_FLAG, NULL, buf, + ret = CertStrToNameA(X509_ASN_ENCODING, "CN=1,2", CERT_NAME_STR_NO_QUOTING_FLAG, NULL, buf, &size, NULL); ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING, "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError()); - ret = pCertStrToNameA(X509_ASN_ENCODING, "CN="1,2;3,4"", CERT_NAME_STR_NO_QUOTING_FLAG, NULL, buf, + ret = CertStrToNameA(X509_ASN_ENCODING, "CN="1,2;3,4"", CERT_NAME_STR_NO_QUOTING_FLAG, NULL, buf, &size, NULL); ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING, "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError()); - ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=abc", 0, NULL, buf, + ret = CertStrToNameA(X509_ASN_ENCODING, "CN=abc", 0, NULL, buf, &size, NULL); ok(ret && GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %08lx\n", GetLastError()); - ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=abc", CERT_NAME_STR_NO_QUOTING_FLAG, NULL, buf, + ret = CertStrToNameA(X509_ASN_ENCODING, "CN=abc", CERT_NAME_STR_NO_QUOTING_FLAG, NULL, buf, &size, NULL); ok(ret && GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %08lx\n", GetLastError()); - ret = pCertStrToNameA(X509_ASN_ENCODING, "CN="abc"", 0, NULL, buf, + ret = CertStrToNameA(X509_ASN_ENCODING, "CN="abc"", 0, NULL, buf, &size, NULL); ok(ret && GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %08lx\n", GetLastError()); - ret = pCertStrToNameA(X509_ASN_ENCODING, "CN="abc"", CERT_NAME_STR_NO_QUOTING_FLAG, NULL, buf, + ret = CertStrToNameA(X509_ASN_ENCODING, "CN="abc"", CERT_NAME_STR_NO_QUOTING_FLAG, NULL, buf, &size, NULL); ok(!ret && GetLastError() == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %08lx\n", GetLastError()); for (i = 0; i < ARRAY_SIZE(namesA); i++) { size = sizeof(buf); - ret = pCertStrToNameA(X509_ASN_ENCODING, namesA[i].x500, 0, NULL, buf, + ret = CertStrToNameA(X509_ASN_ENCODING, namesA[i].x500, 0, NULL, buf, &size, NULL); ok(ret, "CertStrToNameA failed on string %s: %08lx\n", namesA[i].x500, GetLastError()); @@ -750,35 +705,29 @@ static void test_CertStrToNameW(void) LPCWSTR errorPtr; BYTE buf[100];
- if (!pCertStrToNameW) - { - win_skip("CertStrToNameW is not available\n"); - return; - } - /* Crash - ret = pCertStrToNameW(0, NULL, 0, NULL, NULL, NULL, NULL); + ret = CertStrToNameW(0, NULL, 0, NULL, NULL, NULL, NULL); */ - ret = pCertStrToNameW(0, NULL, 0, NULL, NULL, &size, NULL); + ret = CertStrToNameW(0, NULL, 0, NULL, NULL, &size, NULL); ok(!ret, "Expected failure\n"); - ret = pCertStrToNameW(0, L"bogus", 0, NULL, NULL, &size, NULL); + ret = CertStrToNameW(0, L"bogus", 0, NULL, NULL, &size, NULL); ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING, "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError()); - ret = pCertStrToNameW(0, L"foo=1", 0, NULL, NULL, &size, NULL); + ret = CertStrToNameW(0, L"foo=1", 0, NULL, NULL, &size, NULL); ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING, "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError()); - ret = pCertStrToNameW(0, L"CN=1", 0, NULL, NULL, &size, NULL); + ret = CertStrToNameW(0, L"CN=1", 0, NULL, NULL, &size, NULL); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); - ret = pCertStrToNameW(X509_ASN_ENCODING, L"CN=1", 0, NULL, NULL, &size, + ret = CertStrToNameW(X509_ASN_ENCODING, L"CN=1", 0, NULL, NULL, &size, NULL); ok(ret, "CertStrToNameW failed: %08lx\n", GetLastError()); size = sizeof(buf); - ret = pCertStrToNameW(X509_ASN_ENCODING, L"CN=""1""", 0, NULL, buf, + ret = CertStrToNameW(X509_ASN_ENCODING, L"CN=""1""", 0, NULL, buf, &size, NULL); ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING, "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError()); - ret = pCertStrToNameW(X509_ASN_ENCODING, L"CN=""1""", 0, NULL, buf, + ret = CertStrToNameW(X509_ASN_ENCODING, L"CN=""1""", 0, NULL, buf, &size, &errorPtr); ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING, "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError()); @@ -786,7 +735,7 @@ static void test_CertStrToNameW(void) for (i = 0; i < ARRAY_SIZE(namesW); i++) { size = sizeof(buf); - ret = pCertStrToNameW(X509_ASN_ENCODING, namesW[i].x500, 0, NULL, buf, + ret = CertStrToNameW(X509_ASN_ENCODING, namesW[i].x500, 0, NULL, buf, &size, NULL); ok(ret, "Index %ld: CertStrToNameW failed: %08lx\n", i, GetLastError()); ok(size == namesW[i].encodedSize, @@ -802,12 +751,6 @@ static void test_CertGetNameStringA(void) { PCCERT_CONTEXT context;
- if (!pCertGetNameStringA) - { - win_skip("CertGetNameStringA is not available\n"); - return; - } - context = CertCreateCertificateContext(X509_ASN_ENCODING, cert, sizeof(cert)); ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n", @@ -820,130 +763,129 @@ static void test_CertGetNameStringA(void) LPSTR str;
/* Bad string types/types missing from the cert */ - len = pCertGetNameStringA(NULL, 0, 0, NULL, NULL, 0); + len = CertGetNameStringA(NULL, 0, 0, NULL, NULL, 0); ok(len == 1, "expected 1, got %ld\n", len); - len = pCertGetNameStringA(context, 0, 0, NULL, NULL, 0); + len = CertGetNameStringA(context, 0, 0, NULL, NULL, 0); ok(len == 1, "expected 1, got %ld\n", len); - len = pCertGetNameStringA(context, CERT_NAME_URL_TYPE, 0, NULL, NULL, + len = CertGetNameStringA(context, CERT_NAME_URL_TYPE, 0, NULL, NULL, 0); ok(len == 1, "expected 1, got %ld\n", len);
- len = pCertGetNameStringA(context, CERT_NAME_EMAIL_TYPE, 0, NULL, NULL, + len = CertGetNameStringA(context, CERT_NAME_EMAIL_TYPE, 0, NULL, NULL, 0); ok(len == strlen(aric) + 1, "unexpected length %ld\n", len); str = HeapAlloc(GetProcessHeap(), 0, len); if (str) { - len = pCertGetNameStringA(context, CERT_NAME_EMAIL_TYPE, 0, NULL, + len = CertGetNameStringA(context, CERT_NAME_EMAIL_TYPE, 0, NULL, str, len); ok(!strcmp(str, aric), "unexpected value %s\n", str); HeapFree(GetProcessHeap(), 0, str); }
- len = pCertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, NULL, NULL, + len = CertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, NULL, NULL, 0); ok(len == strlen(issuerStr) + 1, "unexpected length %ld\n", len); str = HeapAlloc(GetProcessHeap(), 0, len); if (str) { - len = pCertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, NULL, + len = CertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, NULL, str, len); ok(!strcmp(str, issuerStr), "unexpected value %s\n", str); HeapFree(GetProcessHeap(), 0, str); } type = 0; - len = pCertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, &type, NULL, + len = CertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, &type, NULL, 0); ok(len == strlen(issuerStr) + 1, "unexpected length %ld\n", len); str = HeapAlloc(GetProcessHeap(), 0, len); if (str) { - len = pCertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, &type, + len = CertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, &type, str, len); ok(!strcmp(str, issuerStr), "unexpected value %s\n", str); HeapFree(GetProcessHeap(), 0, str); } type = CERT_OID_NAME_STR; - len = pCertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, &type, NULL, + len = CertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, &type, NULL, 0); ok(len == strlen(subjectStr) + 1, "unexpected length %ld\n", len); str = HeapAlloc(GetProcessHeap(), 0, len); if (str) { - len = pCertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, &type, + len = CertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, &type, str, len); ok(!strcmp(str, subjectStr), "unexpected value %s\n", str); HeapFree(GetProcessHeap(), 0, str); }
- len = pCertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0, NULL, NULL, + len = CertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0, NULL, NULL, 0); ok(len == strlen(aric) + 1, "unexpected length %ld\n", len); str = HeapAlloc(GetProcessHeap(), 0, len); if (str) { - len = pCertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0, NULL, + len = CertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0, NULL, str, len); ok(!strcmp(str, aric), "unexpected value %s\n", str); HeapFree(GetProcessHeap(), 0, str); } - len = pCertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0, + len = CertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0, (void *)szOID_RSA_emailAddr, NULL, 0); ok(len == strlen(aric) + 1, "unexpected length %ld\n", len); str = HeapAlloc(GetProcessHeap(), 0, len); if (str) { - len = pCertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0, + len = CertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0, (void *)szOID_RSA_emailAddr, str, len); ok(!strcmp(str, aric), "unexpected value %s\n", str); HeapFree(GetProcessHeap(), 0, str); } - len = pCertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0, + len = CertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0, (void *)szOID_COMMON_NAME, NULL, 0); ok(len == strlen(localhost) + 1, "unexpected length %ld\n", len); str = HeapAlloc(GetProcessHeap(), 0, len); if (str) { - len = pCertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0, + len = CertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0, (void *)szOID_COMMON_NAME, str, len); ok(!strcmp(str, localhost), "unexpected value %s\n", str); HeapFree(GetProcessHeap(), 0, str); }
- len = pCertGetNameStringA(context, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, + len = CertGetNameStringA(context, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, NULL, 0); ok(len == strlen(localhost) + 1, "unexpected length %ld\n", len); str = HeapAlloc(GetProcessHeap(), 0, len); if (str) { - len = pCertGetNameStringA(context, CERT_NAME_SIMPLE_DISPLAY_TYPE, + len = CertGetNameStringA(context, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, str, len); ok(!strcmp(str, localhost), "unexpected value %s\n", str); HeapFree(GetProcessHeap(), 0, str); }
- len = pCertGetNameStringA(context, CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0, + len = CertGetNameStringA(context, CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0, NULL, NULL, 0); ok(len == strlen(localhost) + 1, "unexpected length %ld\n", len); str = HeapAlloc(GetProcessHeap(), 0, len); if (str) { - len = pCertGetNameStringA(context, CERT_NAME_FRIENDLY_DISPLAY_TYPE, + len = CertGetNameStringA(context, CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0, NULL, str, len); ok(!strcmp(str, localhost), "unexpected value %s\n", str); HeapFree(GetProcessHeap(), 0, str); }
- len = pCertGetNameStringA(context, CERT_NAME_DNS_TYPE, 0, NULL, NULL, + len = CertGetNameStringA(context, CERT_NAME_DNS_TYPE, 0, NULL, NULL, 0); - ok(len == strlen(localhost) + 1 || broken(len == 1) /* NT4 */, - "unexpected length %ld\n", len); + ok(len == strlen(localhost) + 1, "unexpected length %ld\n", len); if (len > 1) { str = HeapAlloc(GetProcessHeap(), 0, len); if (str) { - len = pCertGetNameStringA(context, CERT_NAME_DNS_TYPE, 0, NULL, + len = CertGetNameStringA(context, CERT_NAME_DNS_TYPE, 0, NULL, str, len); ok(!strcmp(str, localhost), "unexpected value %s\n", str); HeapFree(GetProcessHeap(), 0, str); @@ -956,16 +898,6 @@ static void test_CertGetNameStringA(void)
START_TEST(str) { - dll = GetModuleHandleA("Crypt32.dll"); - - pCertNameToStrA = (void*)GetProcAddress(dll,"CertNameToStrA"); - pCertNameToStrW = (void*)GetProcAddress(dll,"CertNameToStrW"); - pCertRDNValueToStrA = (void*)GetProcAddress(dll, "CertRDNValueToStrA"); - pCertRDNValueToStrW = (void*)GetProcAddress(dll, "CertRDNValueToStrW"); - pCertStrToNameA = (void*)GetProcAddress(dll,"CertStrToNameA"); - pCertStrToNameW = (void*)GetProcAddress(dll,"CertStrToNameW"); - pCertGetNameStringA = (void*)GetProcAddress(dll, "CertGetNameStringA"); - test_CertRDNValueToStrA(); test_CertRDNValueToStrW(); test_CertNameToStrA();