encode.c tests already do that.
Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/crypt32/tests/cert.c | 40 ++++++++++------------ dlls/crypt32/tests/message.c | 23 ++----------- dlls/crypt32/tests/msg.c | 66 ++++++++++++------------------------ 3 files changed, 40 insertions(+), 89 deletions(-)
diff --git a/dlls/crypt32/tests/cert.c b/dlls/crypt32/tests/cert.c index 15ed98e0e30..b96f94cc662 100644 --- a/dlls/crypt32/tests/cert.c +++ b/dlls/crypt32/tests/cert.c @@ -40,13 +40,9 @@ static BOOL (WINAPI *pCryptHashCertificate2)(LPCWSTR, DWORD, void*, const BYTE*, static BOOL (WINAPI * pCryptVerifyCertificateSignatureEx) (HCRYPTPROV, DWORD, DWORD, void *, DWORD, void *, DWORD, void *);
-static BOOL (WINAPI * pCryptAcquireContextA) - (HCRYPTPROV *, LPCSTR, LPCSTR, DWORD, DWORD); - static void init_function_pointers(void) { HMODULE hCrypt32 = GetModuleHandleA("crypt32.dll"); - HMODULE hAdvapi32 = GetModuleHandleA("advapi32.dll");
#define GET_PROC(dll, func) \ p ## func = (void *)GetProcAddress(dll, #func); \ @@ -59,8 +55,6 @@ static void init_function_pointers(void) GET_PROC(hCrypt32, CryptEncodeObjectEx) GET_PROC(hCrypt32, CryptHashCertificate2) GET_PROC(hCrypt32, CryptVerifyCertificateSignatureEx) - - GET_PROC(hAdvapi32, CryptAcquireContextA) #undef GET_PROC }
@@ -2135,9 +2129,9 @@ static void testCertSigs(void) DWORD sigSize = sizeof(sig);
/* Just in case a previous run failed, delete this thing */ - pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_DELETEKEYSET); - ret = pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + ret = CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_NEWKEYSET); ok(ret, "CryptAcquireContext failed: %08x\n", GetLastError());
@@ -2146,7 +2140,7 @@ static void testCertSigs(void) testVerifyCertSigEx(csp, &toBeSigned, szOID_RSA_SHA1RSA, sig, sigSize);
CryptReleaseContext(csp, 0); - ret = pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + ret = CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_DELETEKEYSET); ok(ret, "CryptAcquireContext failed: %08x\n", GetLastError()); } @@ -2278,9 +2272,9 @@ static void testCreateSelfSignCert(void) */
/* Acquire a CSP */ - pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_DELETEKEYSET); - ret = pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + ret = CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_NEWKEYSET); ok(ret, "CryptAcquireContext failed: %08x\n", GetLastError());
@@ -2335,14 +2329,14 @@ static void testCreateSelfSignCert(void) }
CryptReleaseContext(csp, 0); - ret = pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + ret = CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_DELETEKEYSET); ok(ret, "CryptAcquireContext failed: %08x\n", GetLastError());
/* Do the same test with a CSP, AT_KEYEXCHANGE and key info */ - pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_DELETEKEYSET); - ret = pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + ret = CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_NEWKEYSET); ok(ret, "CryptAcquireContext failed: %08x\n", GetLastError()); ret = CryptGenKey(csp, AT_SIGNATURE, 0, &key); @@ -2407,7 +2401,7 @@ static void testCreateSelfSignCert(void) CryptDestroyKey(key);
CryptReleaseContext(csp, 0); - ret = pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + ret = CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_DELETEKEYSET); ok(ret, "CryptAcquireContext failed: %08x\n", GetLastError());
@@ -2452,13 +2446,13 @@ static void testCreateSelfSignCert(void) CertFreeCertificateContext(context); }
- pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_DELETEKEYSET);
/* Acquire a CSP and generate an AT_KEYEXCHANGE key in it. */ - pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_DELETEKEYSET); - ret = pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + ret = CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_NEWKEYSET); ok(ret, "CryptAcquireContext failed: %08x\n", GetLastError());
@@ -2530,7 +2524,7 @@ static void testCreateSelfSignCert(void) }
CryptReleaseContext(csp, 0); - ret = pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + ret = CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_DELETEKEYSET); ok(ret, "CryptAcquireContext failed: %08x\n", GetLastError());
@@ -3866,7 +3860,7 @@ static void testAcquireCertPrivateKey(void) keyProvInfo.rgProvParam = NULL; keyProvInfo.dwKeySpec = AT_SIGNATURE;
- pCryptAcquireContextA(NULL, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + CryptAcquireContextA(NULL, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_DELETEKEYSET);
cert = CertCreateCertificateContext(X509_ASN_ENCODING, selfSignedCert, @@ -3901,7 +3895,7 @@ static void testAcquireCertPrivateKey(void) GetLastError() == NTE_BAD_PROV_TYPE /* win10 */), "Expected CRYPT_E_NO_KEY_PROPERTY, got %08x\n", GetLastError());
- pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_NEWKEYSET); ret = CryptImportKey(csp, privKey, sizeof(privKey), 0, 0, &key); ok(ret, "CryptImportKey failed: %08x\n", GetLastError()); @@ -4044,7 +4038,7 @@ static void testAcquireCertPrivateKey(void) }
CryptReleaseContext(csp, 0); - pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_DELETEKEYSET);
CertFreeCertificateContext(cert); @@ -4263,7 +4257,7 @@ static void test_VerifySignature(void) ok(ret, "CryptVerifyCertificateSignature error %#x\n", GetLastError());
/* 2. Verify certificate signature with Crypto API manually */ - ret = pCryptAcquireContextA(&prov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); + ret = CryptAcquireContextA(&prov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); ok(ret, "CryptAcquireContext error %#x\n", GetLastError());
ret = CryptImportPublicKeyInfoEx(prov, cert->dwCertEncodingType, &cert->pCertInfo->SubjectPublicKeyInfo, 0, 0, NULL, &key); diff --git a/dlls/crypt32/tests/message.c b/dlls/crypt32/tests/message.c index 7e2e8aa8408..c031718d1cc 100644 --- a/dlls/crypt32/tests/message.c +++ b/dlls/crypt32/tests/message.c @@ -27,23 +27,6 @@
#include "wine/test.h"
-static BOOL (WINAPI * pCryptAcquireContextA) - (HCRYPTPROV *, LPCSTR, LPCSTR, DWORD, DWORD); - -static void init_function_pointers(void) -{ - HMODULE hAdvapi32 = GetModuleHandleA("advapi32.dll"); - -#define GET_PROC(dll, func) \ - p ## func = (void *)GetProcAddress(dll, #func); \ - if(!p ## func) \ - trace("GetProcAddress(%s) failed\n", #func); - - GET_PROC(hAdvapi32, CryptAcquireContextA) - -#undef GET_PROC -} - static const BYTE dataEmptyBareContent[] = { 0x04,0x00 }; static const BYTE dataEmptyContent[] = { 0x30,0x0f,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x01,0xa0,0x02, @@ -1032,7 +1015,7 @@ static void test_sign_message(void) ok(signedBlobSize, "bad size\n");
SetLastError(0xdeadbeef); - ret = pCryptAcquireContextA(&hCryptProv, NULL, NULL, PROV_RSA_FULL, + ret = CryptAcquireContextA(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); ok(ret, "CryptAcquireContextA failed: %08x\n", GetLastError()); SetLastError(0xdeadbeef); @@ -1219,7 +1202,7 @@ static void test_encrypt_message(void) DWORD encryptedBlobSize;
SetLastError(0xdeadbeef); - ret = pCryptAcquireContextA(&hCryptProv, NULL, NULL, PROV_RSA_FULL, + ret = CryptAcquireContextA(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); ok(ret, "CryptAcquireContextA failed: %08x\n", GetLastError());
@@ -1365,8 +1348,6 @@ static void test_encrypt_message(void)
START_TEST(message) { - init_function_pointers(); - test_msg_get_signer_count(); test_verify_detached_message_hash(); test_verify_message_hash(); diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c index b6921273eea..45b923204ba 100644 --- a/dlls/crypt32/tests/msg.c +++ b/dlls/crypt32/tests/msg.c @@ -33,26 +33,6 @@ static BOOL have_nt = TRUE; static BOOL old_crypt32 = FALSE; static char oid_rsa_md5[] = szOID_RSA_MD5;
-static BOOL (WINAPI * pCryptAcquireContextA) - (HCRYPTPROV *, LPCSTR, LPCSTR, DWORD, DWORD); -static BOOL (WINAPI * pCryptAcquireContextW) - (HCRYPTPROV *, LPCWSTR, LPCWSTR, DWORD, DWORD); - -static void init_function_pointers(void) -{ - HMODULE hAdvapi32 = GetModuleHandleA("advapi32.dll"); - -#define GET_PROC(dll, func) \ - p ## func = (void *)GetProcAddress(dll, #func); \ - if(!p ## func) \ - trace("GetProcAddress(%s) failed\n", #func); - - GET_PROC(hAdvapi32, CryptAcquireContextA) - GET_PROC(hAdvapi32, CryptAcquireContextW) - -#undef GET_PROC -} - static void test_msg_open_to_encode(void) { HCRYPTMSG msg; @@ -1149,10 +1129,10 @@ static void test_signed_msg_open(void) "Expected ERROR_INVALID_PARAMETER, got %x\n", GetLastError()); } /* The signer's hCryptProv must also be valid. */ - ret = pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, + ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); if (!ret && GetLastError() == NTE_EXISTS) { - ret = pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, + ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, 0); } ok(ret, "CryptAcquireContext failed: 0x%x\n", GetLastError()); @@ -1182,7 +1162,7 @@ static void test_signed_msg_open(void) CryptMsgClose(msg);
CryptReleaseContext(signer.hCryptProv, 0); - pCryptAcquireContextA(&signer.hCryptProv, cspNameA, MS_DEF_PROV_A, + CryptAcquireContextA(&signer.hCryptProv, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_DELETEKEYSET); }
@@ -1236,10 +1216,10 @@ static void test_signed_msg_update(void) signInfo.cSigners = 1; signInfo.rgSigners = &signer;
- ret = pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, + ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); if (!ret && GetLastError() == NTE_EXISTS) { - ret = pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, + ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, 0); } ok(ret, "CryptAcquireContext failed: 0x%x\n", GetLastError()); @@ -1327,7 +1307,7 @@ static void test_signed_msg_update(void)
CryptDestroyKey(key); CryptReleaseContext(signer.hCryptProv, 0); - pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, + CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, CRYPT_DELETEKEYSET); }
@@ -1674,10 +1654,10 @@ static void test_signed_msg_encoding(void) signInfo.cSigners = 1; signInfo.rgSigners = &signer;
- ret = pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, + ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); if (!ret && GetLastError() == NTE_EXISTS) { - ret = pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, + ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, 0); } ok(ret, "CryptAcquireContext failed: 0x%x\n", GetLastError()); @@ -1844,7 +1824,7 @@ static void test_signed_msg_encoding(void)
CryptDestroyKey(key); CryptReleaseContext(signer.hCryptProv, 0); - pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, + CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, CRYPT_DELETEKEYSET); }
@@ -1910,10 +1890,10 @@ static void test_signed_msg_get_param(void) signInfo.cSigners = 1; signInfo.rgSigners = &signer;
- ret = pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, + ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); if (!ret && GetLastError() == NTE_EXISTS) { - ret = pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, + ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, 0); } ok(ret, "CryptAcquireContext failed: 0x%x\n", GetLastError()); @@ -1961,10 +1941,10 @@ static void test_signed_msg_get_param(void) U(signer.SignerId).IssuerSerialNumber.SerialNumber.cbData = sizeof(serialNum); U(signer.SignerId).IssuerSerialNumber.SerialNumber.pbData = serialNum; - ret = pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, + ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); if (!ret && GetLastError() == NTE_EXISTS) - ret = pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, + ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, 0); ok(ret, "CryptAcquireContextA failed: %x\n", GetLastError()); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, @@ -2003,10 +1983,10 @@ static void test_signed_msg_get_param(void) signer.SignerId.dwIdChoice = CERT_ID_KEY_IDENTIFIER; U(signer.SignerId).KeyId.cbData = sizeof(serialNum); U(signer.SignerId).KeyId.pbData = serialNum; - ret = pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, + ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); if (!ret && GetLastError() == NTE_EXISTS) - ret = pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, + ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, 0); ok(ret, "CryptAcquireContextA failed: %x\n", GetLastError()); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, @@ -2036,7 +2016,7 @@ static void test_signed_msg_get_param(void) CryptMsgClose(msg);
CryptReleaseContext(signer.hCryptProv, 0); - pCryptAcquireContextA(&signer.hCryptProv, cspNameA, MS_DEF_PROV_A, + CryptAcquireContextA(&signer.hCryptProv, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_DELETEKEYSET); }
@@ -2102,7 +2082,7 @@ static void test_enveloped_msg_open(void) ok(msg != NULL, "CryptMsgOpenToEncode failed: %08x\n", GetLastError()); CryptMsgClose(msg); SetLastError(0xdeadbeef); - ret = pCryptAcquireContextA(&envelopedInfo.hCryptProv, NULL, NULL, + ret = CryptAcquireContextA(&envelopedInfo.hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); ok(ret, "CryptAcquireContextA failed: %08x\n", GetLastError()); SetLastError(0xdeadbeef); @@ -3090,7 +3070,7 @@ static void test_decode_msg_get_param(void) check_param("enveloped empty content", msg, CMSG_CONTENT_PARAM, NULL, 0); CryptMsgClose(msg);
- pCryptAcquireContextA(&hCryptProv, NULL, MS_ENHANCED_PROV_A, PROV_RSA_FULL, + CryptAcquireContextA(&hCryptProv, NULL, MS_ENHANCED_PROV_A, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); SetLastError(0xdeadbeef); ret = CryptImportKey(hCryptProv, publicPrivateKeyPair, @@ -3605,9 +3585,6 @@ static BOOL detect_nt(void) CMSG_SIGNER_ENCODE_INFO signer = { sizeof(signer), 0 }; CERT_INFO certInfo = { 0 };
- if (!pCryptAcquireContextW) - return FALSE; - certInfo.SerialNumber.cbData = sizeof(serialNum); certInfo.SerialNumber.pbData = serialNum; certInfo.Issuer.cbData = sizeof(encodedCommonName); @@ -3615,10 +3592,10 @@ static BOOL detect_nt(void) signer.pCertInfo = &certInfo; signer.HashAlgorithm.pszObjId = oid_rsa_md5;
- ret = pCryptAcquireContextW(&signer.hCryptProv, cspNameW, NULL, + ret = CryptAcquireContextW(&signer.hCryptProv, cspNameW, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); if (!ret && GetLastError() == NTE_EXISTS) { - ret = pCryptAcquireContextW(&signer.hCryptProv, cspNameW, NULL, + ret = CryptAcquireContextW(&signer.hCryptProv, cspNameW, NULL, PROV_RSA_FULL, 0); }
@@ -3626,7 +3603,7 @@ static BOOL detect_nt(void)
/* cleanup */ CryptReleaseContext(signer.hCryptProv, 0); - pCryptAcquireContextW(&signer.hCryptProv, cspNameW, NULL, PROV_RSA_FULL, + CryptAcquireContextW(&signer.hCryptProv, cspNameW, NULL, PROV_RSA_FULL, CRYPT_DELETEKEYSET);
return TRUE; @@ -3760,7 +3737,6 @@ static void test_msg_get_and_verify_signer(void)
START_TEST(msg) { - init_function_pointers(); have_nt = detect_nt(); if (!have_nt) win_skip("Win9x crashes on some parameter checks\n");