Signed-off-by: Hans Leidekker hans@codeweavers.com --- dlls/crypt32/tests/cert.c | 52 +++---- dlls/crypt32/tests/chain.c | 59 +++----- dlls/crypt32/tests/encode.c | 88 +++++------ dlls/crypt32/tests/main.c | 16 +- dlls/crypt32/tests/object.c | 54 ++----- dlls/crypt32/tests/oid.c | 65 ++++---- dlls/crypt32/tests/protectdata.c | 13 +- dlls/crypt32/tests/sip.c | 35 ++--- dlls/crypt32/tests/store.c | 222 ++++++++++----------------- dlls/crypt32/tests/str.c | 249 +++++++++---------------------- 10 files changed, 294 insertions(+), 559 deletions(-)
diff --git a/dlls/crypt32/tests/cert.c b/dlls/crypt32/tests/cert.c index 608d2c8c1b7..e781045b2c4 100644 --- a/dlls/crypt32/tests/cert.c +++ b/dlls/crypt32/tests/cert.c @@ -348,7 +348,6 @@ static void checkHash(const BYTE *data, DWORD dataLen, ALG_ID algID, }
static const CHAR cspNameA[] = "WineCryptTemp"; -static WCHAR cspNameW[] = { 'W','i','n','e','C','r','y','p','t','T','e','m','p',0 }; static const BYTE v1CertWithPubKey[] = { 0x30,0x81,0x95,0x02,0x01,0x01,0x30,0x02,0x06,0x00,0x30,0x15,0x31,0x13,0x30, 0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61, @@ -1135,9 +1134,6 @@ static void testFindCert(void) CRYPT_HASH_BLOB blob; BYTE otherSerialNumber[] = { 2 }; DWORD count; - static const WCHAR juan[] = { 'j','u','a','n',0 }; - static const WCHAR lang[] = { 'L','A','N','G',0 }; - static const WCHAR malcolm[] = { 'm','a','l','c','o','l','m',0 };
store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); @@ -1272,7 +1268,7 @@ static void testFindCert(void) context = NULL; do { context = CertFindCertificateInStore(store, X509_ASN_ENCODING, 0, - CERT_FIND_ISSUER_STR, juan, context); + CERT_FIND_ISSUER_STR, L"juan", context); if (context) count++; } while (context); @@ -1281,14 +1277,14 @@ static void testFindCert(void) context = NULL; do { context = CertFindCertificateInStore(store, X509_ASN_ENCODING, 0, - CERT_FIND_ISSUER_STR, lang, context); + CERT_FIND_ISSUER_STR, L"LANG", context); if (context) count++; } while (context); ok(count == 3, "expected 3 contexts\n"); SetLastError(0xdeadbeef); context = CertFindCertificateInStore(store, X509_ASN_ENCODING, 0, - CERT_FIND_ISSUER_STR, malcolm, NULL); + CERT_FIND_ISSUER_STR, L"malcolm", NULL); ok(!context, "expected no certs\n"); ok(GetLastError() == CRYPT_E_NOT_FOUND, "expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); @@ -1564,8 +1560,6 @@ static void testGetIssuerCert(void) DWORD flags = 0xffffffff, size; CERT_NAME_BLOB certsubject; BYTE *certencoded; - WCHAR rootW[] = {'R', 'O', 'O', 'T', '\0'}, - certname[] = {'C', 'N', '=', 'd', 'u', 'm', 'm', 'y', ',', ' ', 'T', '=', 'T', 'e', 's', 't', '\0'}; HCERTSTORE store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL);
@@ -1707,10 +1701,10 @@ static void testGetIssuerCert(void)
/* Self-sign a certificate, add to the store and test getting the issuer */ size = 0; - ok(CertStrToNameW(X509_ASN_ENCODING, certname, CERT_X500_NAME_STR, NULL, NULL, &size, NULL), + ok(CertStrToNameW(X509_ASN_ENCODING, L"CN=dummy, T=Test", CERT_X500_NAME_STR, NULL, NULL, &size, NULL), "CertStrToName should have worked\n"); certencoded = HeapAlloc(GetProcessHeap(), 0, size); - ok(CertStrToNameW(X509_ASN_ENCODING, certname, CERT_X500_NAME_STR, NULL, certencoded, &size, NULL), + ok(CertStrToNameW(X509_ASN_ENCODING, L"CN=dummy, T=Test", CERT_X500_NAME_STR, NULL, certencoded, &size, NULL), "CertStrToName should have worked\n"); certsubject.pbData = certencoded; certsubject.cbData = size; @@ -1735,7 +1729,7 @@ static void testGetIssuerCert(void) HeapFree(GetProcessHeap(), 0, certencoded);
/* Test root storage self-signed certificate */ - store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, CERT_SYSTEM_STORE_CURRENT_USER, rootW); + store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, CERT_SYSTEM_STORE_CURRENT_USER, L"ROOT"); ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); flags = 0; cert1 = CertEnumCertificatesInStore(store, NULL); @@ -1796,10 +1790,6 @@ static void testCryptHashCert2(void) BOOL ret; BYTE hash[20]; DWORD hashLen; - const WCHAR SHA1[] = { 'S', 'H', 'A', '1', '\0' }; - const WCHAR invalidAlgorithm[] = { '_', 'S', 'H', 'O', 'U', 'L', 'D', - 'N', 'O', 'T', - 'E', 'X', 'I', 'S', 'T', '_', '\0' };
if (!pCryptHashCertificate2) { @@ -1809,21 +1799,21 @@ static void testCryptHashCert2(void)
/* Test empty hash */ hashLen = sizeof(hash); - ret = pCryptHashCertificate2(SHA1, 0, NULL, NULL, 0, hash, &hashLen); + ret = pCryptHashCertificate2(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(SHA1, 0, NULL, toHash, sizeof(toHash), hash, &hashLen); + ret = pCryptHashCertificate2(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(SHA1, 0, NULL, toHash, sizeof(toHash), NULL, &hashLen); + ret = pCryptHashCertificate2(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);
@@ -1837,24 +1827,24 @@ static void testCryptHashCert2(void) /* Test invalid algorithm */ hashLen = sizeof(hash); SetLastError(0xdeadbeef); - ret = pCryptHashCertificate2(invalidAlgorithm, 0, NULL, toHash, sizeof(toHash), hash, &hashLen); + ret = pCryptHashCertificate2(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(SHA1, 0, NULL, toHash, sizeof(toHash), hash, &hashLen); + ret = pCryptHashCertificate2(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(SHA1, 0, NULL, toHash, sizeof(toHash), hash, NULL); + ret = pCryptHashCertificate2(L"SHA1", 0, NULL, toHash, sizeof(toHash), hash, NULL);
/* Test hashLen null with no hash */ - ret = pCryptHashCertificate2(SHA1, 0, NULL, toHash, sizeof(toHash), NULL, NULL); + ret = pCryptHashCertificate2(L"SHA1", 0, NULL, toHash, sizeof(toHash), NULL, NULL); } }
@@ -2311,7 +2301,7 @@ static void testCreateSelfSignCert(void) if (ret) { /* Sanity-check the key provider */ - ok(!lstrcmpW(pInfo->pwszContainerName, cspNameW), + ok(!lstrcmpW(pInfo->pwszContainerName, L"WineCryptTemp"), "Unexpected key container\n"); ok(!lstrcmpW(pInfo->pwszProvName, MS_DEF_PROV_W), "Unexpected provider\n"); @@ -2346,7 +2336,7 @@ static void testCreateSelfSignCert(void) info.dwProvType = PROV_RSA_FULL; info.dwKeySpec = AT_KEYEXCHANGE; info.pwszProvName = (LPWSTR) MS_DEF_PROV_W; - info.pwszContainerName = cspNameW; + 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, @@ -2385,7 +2375,7 @@ static void testCreateSelfSignCert(void) if (ret) { /* Sanity-check the key provider */ - ok(!lstrcmpW(pInfo->pwszContainerName, cspNameW), + ok(!lstrcmpW(pInfo->pwszContainerName, L"WineCryptTemp"), "Unexpected key container\n"); ok(!lstrcmpW(pInfo->pwszProvName, MS_DEF_PROV_W), "Unexpected provider\n"); @@ -2432,7 +2422,7 @@ static void testCreateSelfSignCert(void) if (ret) { /* Sanity-check the key provider */ - ok(!lstrcmpW(pInfo->pwszContainerName, cspNameW), + ok(!lstrcmpW(pInfo->pwszContainerName, L"WineCryptTemp"), "Unexpected key container\n"); ok(!lstrcmpW(pInfo->pwszProvName, MS_DEF_PROV_W), "Unexpected provider\n"); @@ -2468,7 +2458,7 @@ static void testCreateSelfSignCert(void) info.dwProvType = PROV_RSA_FULL; info.dwKeySpec = AT_SIGNATURE; info.pwszProvName = (LPWSTR) MS_DEF_PROV_W; - info.pwszContainerName = cspNameW; + 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, @@ -2509,7 +2499,7 @@ static void testCreateSelfSignCert(void) if (ret) { /* Sanity-check the key provider */ - ok(!lstrcmpW(pInfo->pwszContainerName, cspNameW), + ok(!lstrcmpW(pInfo->pwszContainerName, L"WineCryptTemp"), "Unexpected key container\n"); ok(!lstrcmpW(pInfo->pwszProvName, MS_DEF_PROV_W), "Unexpected provider\n"); @@ -3112,7 +3102,7 @@ static void testIsRDNAttrsInCertificateName(void) static char juan_with_intermediate_space[] = "Juan Lang"; static char juan_with_trailing_space[] = "Juan Lang "; static char juan_lower_case[] = "juan lang"; - static WCHAR juanW[] = { 'J','u','a','n',' ','L','a','n','g',0 }; + static WCHAR juanW[] = L"Juan Lang"; static char the_wine_project[] = "The Wine Project"; BOOL ret; CERT_NAME_BLOB name; @@ -3852,7 +3842,7 @@ static void testAcquireCertPrivateKey(void)
lstrcpyW(ms_def_prov_w, MS_DEF_PROV_W);
- keyProvInfo.pwszContainerName = cspNameW; + keyProvInfo.pwszContainerName = (WCHAR *)L"WineCryptTemp"; keyProvInfo.pwszProvName = ms_def_prov_w; keyProvInfo.dwProvType = PROV_RSA_FULL; keyProvInfo.dwFlags = 0; diff --git a/dlls/crypt32/tests/chain.c b/dlls/crypt32/tests/chain.c index 9165e87249f..bcf51c6c811 100644 --- a/dlls/crypt32/tests/chain.c +++ b/dlls/crypt32/tests/chain.c @@ -5140,31 +5140,6 @@ static void check_ssl_policy(void) { CERT_CHAIN_POLICY_PARA policyPara = { 0 }; SSL_EXTRA_CERT_CHAIN_POLICY_PARA sslPolicyPara = { { 0 } }; - WCHAR winehq[] = { 'w','i','n','e','h','q','.','o','r','g',0 }; - WCHAR google_dot_com[] = { 'w','w','w','.','g','o','o','g','l','e','.', - 'c','o','m',0 }; - WCHAR battle_dot_net[] = { 'w','w','w','.','b','a','t','t','l','e','.', - 'n','e','t',0 }; - WCHAR a_dot_openssl_dot_org[] = { 'a','.','o','p','e','n','s','s','l','.', - 'o','r','g',0 }; - WCHAR openssl_dot_org[] = { 'o','p','e','n','s','s','l','.','o','r','g',0 }; - WCHAR fopenssl_dot_org[] = { 'f','o','p','e','n','s','s','l','.', - 'o','r','g',0 }; - WCHAR a_dot_b_dot_openssl_dot_org[] = { 'a','.','b','.', - 'o','p','e','n','s','s','l','.','o','r','g',0 }; - WCHAR cs_dot_stanford_dot_edu[] = { 'c','s','.', - 's','t','a','n','f','o','r','d','.','e','d','u',0 }; - WCHAR www_dot_cs_dot_stanford_dot_edu[] = { 'w','w','w','.','c','s','.', - 's','t','a','n','f','o','r','d','.','e','d','u',0 }; - WCHAR a_dot_cs_dot_stanford_dot_edu[] = { 'a','.','c','s','.', - 's','t','a','n','f','o','r','d','.','e','d','u',0 }; - WCHAR test_dot_winehq_dot_org[] = { 't','e','s','t','.', - 'w','i','n','e','h','q','.','o','r','g',0 }; - WCHAR a_dot_b_dot_winehq_dot_org[] = { 'a','.','b','.', - 'w','i','n','e','h','q','.','o','r','g',0 }; - WCHAR foo_dot_com[] = { 'f','o','o','.','c','o','m',0 }; - WCHAR afoo_dot_com[] = { 'a','f','o','o','.','c','o','m',0 }; - WCHAR a_dot_foo_dot_com[] = { 'a','.','f','o','o','.','c','o','m',0 }; HCERTSTORE testRoot; CERT_CHAIN_ENGINE_CONFIG engineConfig = { sizeof(engineConfig), 0 }; HCERTCHAINENGINE engine; @@ -5199,7 +5174,7 @@ static void check_ssl_policy(void) /* One more time authenticating a client, but specify winehq.org as the * server name. */ - sslPolicyPara.pwszServerName = winehq; + sslPolicyPara.pwszServerName = (WCHAR *)L"winehq.org"; CHECK_CHAIN_POLICY_STATUS_ARRAY(CERT_CHAIN_POLICY_SSL, NULL, sslPolicyCheck, &oct2007, &policyPara); /* And again authenticating a server, still specifying winehq.org as the @@ -5226,7 +5201,7 @@ static void check_ssl_policy(void) CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, ignoredUnknownCAPolicyCheck, &oct2007, &policyPara); /* And again, but checking the Google chain at a bad date */ - sslPolicyPara.pwszServerName = google_dot_com; + sslPolicyPara.pwszServerName = (WCHAR *)L"www.google.com"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, googlePolicyCheckWithMatchingNameExpired, &oct2007, &policyPara); policyPara.dwFlags = 0; @@ -5239,7 +5214,7 @@ static void check_ssl_policy(void) googlePolicyCheckWithMatchingName, &oct2007, &policyPara); /* And again, but checking the Google chain at a good date */ sslPolicyPara.fdwChecks = SECURITY_FLAG_IGNORE_UNKNOWN_CA; - sslPolicyPara.pwszServerName = google_dot_com; + sslPolicyPara.pwszServerName = (WCHAR *)L"www.google.com"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, googlePolicyCheckWithMatchingName, &nov2016, &policyPara); sslPolicyPara.fdwChecks = 0; @@ -5248,34 +5223,34 @@ static void check_ssl_policy(void) * with various combinations of matching and non-matching names. * With "a.openssl.org": match */ - sslPolicyPara.pwszServerName = a_dot_openssl_dot_org; + sslPolicyPara.pwszServerName = (WCHAR *)L"a.openssl.org"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, opensslPolicyCheckWithMatchingName, &oct2009, &policyPara); /* With "openssl.org": no match */ - sslPolicyPara.pwszServerName = openssl_dot_org; + sslPolicyPara.pwszServerName = (WCHAR *)L"openssl.org"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, opensslPolicyCheckWithoutMatchingName, &oct2009, &policyPara); /* With "fopenssl.org": no match */ - sslPolicyPara.pwszServerName = fopenssl_dot_org; + sslPolicyPara.pwszServerName = (WCHAR *)L"fopenssl.org"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, opensslPolicyCheckWithoutMatchingName, &oct2009, &policyPara); /* with "a.b.openssl.org": no match */ - sslPolicyPara.pwszServerName = a_dot_b_dot_openssl_dot_org; + sslPolicyPara.pwszServerName = (WCHAR *)L"a.b.openssl.org"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, opensslPolicyCheckWithoutMatchingName, &oct2009, &policyPara); /* Check again with the cs.stanford.edu, which has both cs.stanford.edu * and www.cs.stanford.edu in its subject alternative name. * With "cs.stanford.edu": match */ - sslPolicyPara.pwszServerName = cs_dot_stanford_dot_edu; + sslPolicyPara.pwszServerName = (WCHAR *)L"cs.stanford.edu"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, stanfordPolicyCheckWithMatchingName, &nov2016, &policyPara); /* With "www.cs.stanford.edu": match */ - sslPolicyPara.pwszServerName = www_dot_cs_dot_stanford_dot_edu; + sslPolicyPara.pwszServerName = (WCHAR *)L"www.cs.stanford.edu"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, stanfordPolicyCheckWithMatchingName, &nov2016, &policyPara); /* With "a.cs.stanford.edu": no match */ - sslPolicyPara.pwszServerName = a_dot_cs_dot_stanford_dot_edu; + sslPolicyPara.pwszServerName = (WCHAR *)L"a.cs.stanford.edu"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, stanfordPolicyCheckWithoutMatchingName, &nov2016, &policyPara); /* Check chain29, which has a wildcard in its subject alternative name, @@ -5293,15 +5268,15 @@ static void check_ssl_policy(void) return; } /* With "winehq.org": no match */ - sslPolicyPara.pwszServerName = winehq; + sslPolicyPara.pwszServerName = (WCHAR *)L"winehq.org"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, engine, winehqPolicyCheckWithoutMatchingName, &oct2007, &policyPara); /* With "test.winehq.org": match */ - sslPolicyPara.pwszServerName = test_dot_winehq_dot_org; + sslPolicyPara.pwszServerName = (WCHAR *)L"test.winehq.org"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, engine, winehqPolicyCheckWithMatchingName, &oct2007, &policyPara); /* With "a.b.winehq.org": no match */ - sslPolicyPara.pwszServerName = a_dot_b_dot_winehq_dot_org; + sslPolicyPara.pwszServerName = (WCHAR *)L"a.b.winehq.org"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, engine, winehqPolicyCheckWithoutMatchingName, &oct2007, &policyPara); /* When specifying to ignore name mismatch: match */ @@ -5320,20 +5295,20 @@ static void check_ssl_policy(void) /* Test chain31, which has two CNs, "*.foo.com" and "foo.com", against * some names that match one of the CNs: */ - sslPolicyPara.pwszServerName = foo_dot_com; + sslPolicyPara.pwszServerName = (WCHAR *)L"foo.com"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, fooPolicyCheckWithMatchingName, &oct2007, &policyPara); - sslPolicyPara.pwszServerName = a_dot_foo_dot_com; + sslPolicyPara.pwszServerName = (WCHAR *)L"a.foo.com"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, fooPolicyCheckWithMatchingName, &oct2007, &policyPara); /* and against a name that doesn't match either CN: */ - sslPolicyPara.pwszServerName = afoo_dot_com; + sslPolicyPara.pwszServerName = (WCHAR *)L"afoo.com"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, fooPolicyCheckWithoutMatchingName, &oct2007, &policyPara); /* The Battle.Net chain checks a certificate with a domain component * containing a terminating NULL. */ - sslPolicyPara.pwszServerName = battle_dot_net; + sslPolicyPara.pwszServerName = (WCHAR *)L"www.battle.net"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, nullTerminatedDomainComponentPolicyCheck, &oct2010, &policyPara); } diff --git a/dlls/crypt32/tests/encode.c b/dlls/crypt32/tests/encode.c index b6325efd518..f25c779a9ce 100644 --- a/dlls/crypt32/tests/encode.c +++ b/dlls/crypt32/tests/encode.c @@ -886,9 +886,6 @@ static void test_encodeName(DWORD dwEncoding) } }
-static WCHAR commonNameW[] = { 'J','u','a','n',' ','L','a','n','g',0 }; -static WCHAR surNameW[] = { 'L','a','n','g',0 }; - static const BYTE twoRDNsNoNull[] = { 0x30,0x21,0x31,0x1f,0x30,0x0b,0x06,0x03,0x55,0x04,0x04,0x13,0x04,0x4c,0x61, 0x6e,0x67,0x30,0x10,0x06,0x03,0x55,0x04,0x03,0x13,0x09,0x4a,0x75,0x61,0x6e, @@ -935,8 +932,8 @@ static void test_encodeUnicodeName(DWORD dwEncoding) */ attrs[0].pszObjId = oid_common_name; attrs[0].dwValueType = CERT_RDN_PRINTABLE_STRING; - attrs[0].Value.cbData = sizeof(commonNameW); - attrs[0].Value.pbData = (BYTE *)commonNameW; + attrs[0].Value.cbData = sizeof(L"Juan Lang"); + attrs[0].Value.pbData = (BYTE *)L"Juan Lang"; rdn.cRDNAttr = 1; rdn.rgRDNAttr = attrs; info.cRDN = 1; @@ -952,11 +949,11 @@ static void test_encodeUnicodeName(DWORD dwEncoding) attrs[0].pszObjId = oid_common_name; attrs[0].dwValueType = CERT_RDN_PRINTABLE_STRING; attrs[0].Value.cbData = 0; - attrs[0].Value.pbData = (BYTE *)commonNameW; + attrs[0].Value.pbData = (BYTE *)L"Juan Lang"; attrs[1].pszObjId = oid_sur_name; attrs[1].dwValueType = CERT_RDN_PRINTABLE_STRING; attrs[1].Value.cbData = 0; - attrs[1].Value.pbData = (BYTE *)surNameW; + attrs[1].Value.pbData = (BYTE *)L"Lang"; rdn.cRDNAttr = 2; rdn.rgRDNAttr = attrs; info.cRDN = 1; @@ -1226,9 +1223,9 @@ static void test_decodeUnicodeName(DWORD dwEncoding)
CERT_RDN_ATTR attrs[] = { { oid_sur_name, CERT_RDN_PRINTABLE_STRING, - { lstrlenW(surNameW) * sizeof(WCHAR), (BYTE *)surNameW } }, + { lstrlenW(L"Lang") * sizeof(WCHAR), (BYTE *)L"Lang" } }, { oid_common_name, CERT_RDN_PRINTABLE_STRING, - { lstrlenW(commonNameW) * sizeof(WCHAR), (BYTE *)commonNameW } }, + { lstrlenW(L"Juan Lang") * sizeof(WCHAR), (BYTE *)L"Juan Lang" } }, };
rdn.cRDNAttr = ARRAY_SIZE(attrs); @@ -1297,9 +1294,9 @@ static struct EncodedNameValue nameValues[] = { visibleCommonNameValue, sizeof(visibleCommonNameValue) }, { { CERT_RDN_GENERAL_STRING, { sizeof(commonName), (BYTE *)commonName } }, generalCommonNameValue, sizeof(generalCommonNameValue) }, - { { CERT_RDN_BMP_STRING, { sizeof(commonNameW), (BYTE *)commonNameW } }, + { { CERT_RDN_BMP_STRING, { sizeof(L"Juan Lang"), (BYTE *)L"Juan Lang" } }, bmpCommonNameValue, sizeof(bmpCommonNameValue) }, - { { CERT_RDN_UTF8_STRING, { sizeof(commonNameW), (BYTE *)commonNameW } }, + { { CERT_RDN_UTF8_STRING, { sizeof(L"Juan Lang"), (BYTE *)L"Juan Lang" } }, utf8CommonNameValue, sizeof(utf8CommonNameValue) }, /* The following tests succeed under Windows, but really should fail, * they contain characters that are illegal for the encoding. I'm @@ -1437,14 +1434,11 @@ static void test_decodeNameValue(DWORD dwEncoding)
static const BYTE emptyURL[] = { 0x30, 0x02, 0x86, 0x00 }; static const BYTE emptyURLExtraBytes[] = { 0x30, 0x02, 0x86, 0x00, 0, 0, 0 }; -static const WCHAR url[] = { 'h','t','t','p',':','/','/','w','i','n','e', - 'h','q','.','o','r','g',0 }; +static const WCHAR url[] = L"http://winehq.org"; static const BYTE encodedURL[] = { 0x30, 0x13, 0x86, 0x11, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x69, 0x6e, 0x65, 0x68, 0x71, 0x2e, 0x6f, 0x72, 0x67 }; -static const WCHAR nihongoURL[] = { 'h','t','t','p',':','/','/',0x226f, - 0x575b, 0 }; -static const WCHAR dnsName[] = { 'w','i','n','e','h','q','.','o','r','g',0 }; +static const WCHAR dnsName[] = L"winehq.org"; static const BYTE encodedDnsName[] = { 0x30, 0x0c, 0x82, 0x0a, 0x77, 0x69, 0x6e, 0x65, 0x68, 0x71, 0x2e, 0x6f, 0x72, 0x67 }; static const BYTE localhost[] = { 127, 0, 0, 1 }; @@ -1503,7 +1497,7 @@ static void test_encodeAltName(DWORD dwEncoding) LocalFree(buf); } /* Now with the URL containing an invalid IA5 char */ - U(entry).pwszURL = (LPWSTR)nihongoURL; + U(entry).pwszURL = (WCHAR *)L"http://%5Cx226f%5Cx575b"; ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_IA5_STRING, @@ -1764,17 +1758,13 @@ struct UnicodeExpectedError DWORD error; };
-static const WCHAR oneW[] = { '1',0 }; -static const WCHAR aW[] = { 'a',0 }; -static const WCHAR quoteW[] = { '"', 0 }; - static struct UnicodeExpectedError unicodeErrors[] = { - { CERT_RDN_ANY_TYPE, oneW, 0, CRYPT_E_NOT_CHAR_STRING }, - { CERT_RDN_ENCODED_BLOB, oneW, 0, CRYPT_E_NOT_CHAR_STRING }, - { CERT_RDN_OCTET_STRING, oneW, 0, CRYPT_E_NOT_CHAR_STRING }, - { CERT_RDN_NUMERIC_STRING, aW, 0, CRYPT_E_INVALID_NUMERIC_STRING }, - { CERT_RDN_PRINTABLE_STRING, quoteW, 0, CRYPT_E_INVALID_PRINTABLE_STRING }, - { CERT_RDN_IA5_STRING, nihongoURL, 7, CRYPT_E_INVALID_IA5_STRING }, + { CERT_RDN_ANY_TYPE, L"1", 0, CRYPT_E_NOT_CHAR_STRING }, + { CERT_RDN_ENCODED_BLOB, L"1", 0, CRYPT_E_NOT_CHAR_STRING }, + { CERT_RDN_OCTET_STRING, L"1", 0, CRYPT_E_NOT_CHAR_STRING }, + { CERT_RDN_NUMERIC_STRING, L"a", 0, CRYPT_E_INVALID_NUMERIC_STRING }, + { CERT_RDN_PRINTABLE_STRING, L""", 0, CRYPT_E_INVALID_PRINTABLE_STRING }, + { CERT_RDN_IA5_STRING, L"http://%5Cx226f%5Cx575b", 7, CRYPT_E_INVALID_IA5_STRING }, };
struct UnicodeExpectedResult @@ -1805,24 +1795,24 @@ static BYTE nihongoUTF8[] = { 0x0c,0x0d,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f, 0xe2,0x89,0xaf,0xe5,0x9d,0x9b };
static struct UnicodeExpectedResult unicodeResults[] = { - { CERT_RDN_NUMERIC_STRING, oneW, { sizeof(oneNumeric), oneNumeric } }, - { CERT_RDN_PRINTABLE_STRING, oneW, { sizeof(onePrintable), onePrintable } }, - { CERT_RDN_TELETEX_STRING, oneW, { sizeof(oneTeletex), oneTeletex } }, - { CERT_RDN_VIDEOTEX_STRING, oneW, { sizeof(oneVideotex), oneVideotex } }, - { CERT_RDN_IA5_STRING, oneW, { sizeof(oneIA5), oneIA5 } }, - { CERT_RDN_GRAPHIC_STRING, oneW, { sizeof(oneGraphic), oneGraphic } }, - { CERT_RDN_VISIBLE_STRING, oneW, { sizeof(oneVisible), oneVisible } }, - { CERT_RDN_UNIVERSAL_STRING, oneW, { sizeof(oneUniversal), oneUniversal } }, - { CERT_RDN_GENERAL_STRING, oneW, { sizeof(oneGeneral), oneGeneral } }, - { CERT_RDN_BMP_STRING, oneW, { sizeof(oneBMP), oneBMP } }, - { CERT_RDN_UTF8_STRING, oneW, { sizeof(oneUTF8), oneUTF8 } }, - { CERT_RDN_BMP_STRING, nihongoURL, { sizeof(nihongoBMP), nihongoBMP } }, - { CERT_RDN_UTF8_STRING, nihongoURL, { sizeof(nihongoUTF8), nihongoUTF8 } }, + { CERT_RDN_NUMERIC_STRING, L"1", { sizeof(oneNumeric), oneNumeric } }, + { CERT_RDN_PRINTABLE_STRING, L"1", { sizeof(onePrintable), onePrintable } }, + { CERT_RDN_TELETEX_STRING, L"1", { sizeof(oneTeletex), oneTeletex } }, + { CERT_RDN_VIDEOTEX_STRING, L"1", { sizeof(oneVideotex), oneVideotex } }, + { CERT_RDN_IA5_STRING, L"1", { sizeof(oneIA5), oneIA5 } }, + { CERT_RDN_GRAPHIC_STRING, L"1", { sizeof(oneGraphic), oneGraphic } }, + { CERT_RDN_VISIBLE_STRING, L"1", { sizeof(oneVisible), oneVisible } }, + { CERT_RDN_UNIVERSAL_STRING, L"1", { sizeof(oneUniversal), oneUniversal } }, + { CERT_RDN_GENERAL_STRING, L"1", { sizeof(oneGeneral), oneGeneral } }, + { CERT_RDN_BMP_STRING, L"1", { sizeof(oneBMP), oneBMP } }, + { CERT_RDN_UTF8_STRING, L"1", { sizeof(oneUTF8), oneUTF8 } }, + { CERT_RDN_BMP_STRING, L"http://%5Cx226f%5Cx575b", { sizeof(nihongoBMP), nihongoBMP } }, + { CERT_RDN_UTF8_STRING, L"http://%5Cx226f%5Cx575b", { sizeof(nihongoUTF8), nihongoUTF8 } }, };
static struct UnicodeExpectedResult unicodeWeirdness[] = { - { CERT_RDN_TELETEX_STRING, nihongoURL, { sizeof(nihongoT61), nihongoT61 } }, - { CERT_RDN_GENERAL_STRING, nihongoURL, { sizeof(nihongoGeneral), nihongoGeneral } }, + { CERT_RDN_TELETEX_STRING, L"http://%5Cx226f%5Cx575b", { sizeof(nihongoT61), nihongoT61 } }, + { CERT_RDN_GENERAL_STRING, L"http://%5Cx226f%5Cx575b", { sizeof(nihongoGeneral), nihongoGeneral } }, };
static void test_encodeUnicodeNameValue(DWORD dwEncoding) @@ -1854,12 +1844,12 @@ static void test_encodeUnicodeNameValue(DWORD dwEncoding) 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)oneW; + value.Value.pbData = (LPBYTE)L"1"; ret = pCryptEncodeObjectEx(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(oneW); + value.Value.cbData = sizeof(L"1"); ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_CHAR_STRING, @@ -3699,7 +3689,7 @@ static void test_encodeCRLDistPoints(DWORD dwEncoding) /* A dist point with an invalid name */ point.DistPointName.dwDistPointNameChoice = CRL_DIST_POINT_FULL_NAME; entry.dwAltNameChoice = CERT_ALT_NAME_URL; - U(entry).pwszURL = (LPWSTR)nihongoURL; + 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, @@ -7567,8 +7557,6 @@ static void test_decodeNameConstraints(DWORD dwEncoding) } }
-static WCHAR noticeText[] = { 'T','h','i','s',' ','i','s',' ','a',' ', - 'n','o','t','i','c','e',0 }; static const BYTE noticeWithDisplayText[] = { 0x30,0x22,0x1e,0x20,0x00,0x54,0x00,0x68,0x00,0x69,0x00,0x73,0x00,0x20,0x00, 0x69,0x00,0x73,0x00,0x20,0x00,0x61,0x00,0x20,0x00,0x6e,0x00,0x6f,0x00,0x74, @@ -7607,7 +7595,7 @@ static void test_encodePolicyQualifierUserNotice(DWORD dwEncoding) ok(!memcmp(buf, emptySequence, size), "unexpected value\n"); LocalFree(buf); } - notice.pszDisplayText = noticeText; + notice.pszDisplayText = (WCHAR *)L"This is a notice"; ret = pCryptEncodeObjectEx(dwEncoding, X509_PKIX_POLICY_QUALIFIER_USERNOTICE, ¬ice, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); @@ -7663,7 +7651,7 @@ static void test_decodePolicyQualifierUserNotice(DWORD dwEncoding) ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(!lstrcmpW(notice->pszDisplayText, noticeText), + ok(!lstrcmpW(notice->pszDisplayText, L"This is a notice"), "unexpected display text\n"); ok(notice->pNoticeReference == NULL, "unexpected notice reference\n"); LocalFree(notice); @@ -7675,7 +7663,7 @@ static void test_decodePolicyQualifierUserNotice(DWORD dwEncoding) ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(!lstrcmpW(notice->pszDisplayText, noticeText), + ok(!lstrcmpW(notice->pszDisplayText, L"This is a notice"), "unexpected display text\n"); ok(notice->pNoticeReference != NULL, "expected a notice reference\n"); if (notice->pNoticeReference) diff --git a/dlls/crypt32/tests/main.c b/dlls/crypt32/tests/main.c index 640a50399e5..19dde3fb28f 100644 --- a/dlls/crypt32/tests/main.c +++ b/dlls/crypt32/tests/main.c @@ -272,31 +272,23 @@ static void test_readTrustedPublisherDWORD(void) pReadDWORD = (void *)GetProcAddress(hCrypt, "I_CryptReadTrustedPublisherDWORDValueFromRegistry"); if (pReadDWORD) { - static const WCHAR safer[] = { - 'S','o','f','t','w','a','r','e','\', - 'P','o','l','i','c','i','e','s','\', - 'M','i','c','r','o','s','o','f','t','\','S','y','s','t','e','m', - 'C','e','r','t','i','f','i','c','a','t','e','s','\', - 'T','r','u','s','t','e','d','P','u','b','l','i','s','h','e','r', - '\','S','a','f','e','r',0 }; - static const WCHAR authenticodeFlags[] = { 'A','u','t','h','e','n', - 't','i','c','o','d','e','F','l','a','g','s',0 }; BOOL ret, exists = FALSE; DWORD size, readFlags = 0, returnedFlags; HKEY key; LONG rc;
- rc = RegOpenKeyW(HKEY_LOCAL_MACHINE, safer, &key); + rc = RegOpenKeyW(HKEY_LOCAL_MACHINE, + L"Software\Policies\Microsoft\SystemCertificates\TrustedPublisher\Safer", &key); if (rc == ERROR_SUCCESS) { size = sizeof(readFlags); - rc = RegQueryValueExW(key, authenticodeFlags, NULL, NULL, + rc = RegQueryValueExW(key, L"AuthenticodeFlags", NULL, NULL, (LPBYTE)&readFlags, &size); if (rc == ERROR_SUCCESS) exists = TRUE; } returnedFlags = 0xdeadbeef; - ret = pReadDWORD(authenticodeFlags, &returnedFlags); + ret = pReadDWORD(L"AuthenticodeFlags", &returnedFlags); ok(ret == exists, "Unexpected return value\n"); ok(readFlags == returnedFlags, "Expected flags %08lx, got %08lx\n", readFlags, returnedFlags); diff --git a/dlls/crypt32/tests/object.c b/dlls/crypt32/tests/object.c index 8e77709b970..8fbba2cd83c 100644 --- a/dlls/crypt32/tests/object.c +++ b/dlls/crypt32/tests/object.c @@ -45,18 +45,10 @@ static char bigCertBase64[] = "MHoCAQEwAgYAMBUxEzARBgNVBAMTCkp1YW4gTGFuZwAwIhgPMTYwMTAxMDEwMDAw\n" "MDBaGA8xNjAxMDEwMTAwMDAwMFowFTETMBEGA1UEAxMKSnVhbiBMYW5nADAHMAIG\n" "AAMBAKMWMBQwEgYDVR0TAQH/BAgwBgEB/wIBAQ==\n"; -static WCHAR bigCertBase64W[] = { -'M','H','o','C','A','Q','E','w','A','g','Y','A','M','B','U','x','E','z','A', -'R','B','g','N','V','B','A','M','T','C','k','p','1','Y','W','4','g','T','G', -'F','u','Z','w','A','w','I','h','g','P','M','T','Y','w','M','T','A','x','M', -'D','E','w',',','D','A','w','\n', -'M','D','B','a','G','A','8','x','N','j','A','x','M','D','E','w','M','T','A', -'w','M','D','A','w','M','F','o','w','F','T','E','T','M','B','E','G','A','1', -'U','E','A','x','M','K','S','n','V','h','b','i','B','M','Y','W','5','n','A', -'D','A','H','M','A','I','G','\n', -'A','A','M','B','A','K','M','W','M','B','Q','w','E','g','Y','D','V','R','0', -'T','A','Q','H','/','B','A','g','w','B','g','E','B','/','w','I','B','A','Q', -'=','=','\n',0 }; +static WCHAR bigCertBase64W[] = +L"MHoCAQEwAgYAMBUxEzARBgNVBAMTCkp1YW4gTGFuZwAwIhgPMTYwMTAxMDEw,DAw\n" +"MDBaGA8xNjAxMDEwMTAwMDAwMFowFTETMBEGA1UEAxMKSnVhbiBMYW5nADAHMAIG\n" +"AAMBAKMWMBQwEgYDVR0TAQH/BAgwBgEB/wIBAQ==\n"; static BYTE signedWithCertWithValidPubKeyContent[] = { 0x30,0x82,0x01,0x89,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x02, 0xa0,0x82,0x01,0x7a,0x30,0x82,0x01,0x76,0x02,0x01,0x01,0x31,0x0e,0x30,0x0c, @@ -95,34 +87,16 @@ static char signedWithCertWithValidPubKeyContentBase64[] = "EzARBgNVBAMTCkp1YW4gTGFuZwACAQEwDAYIKoZIhvcNAgUFADAEBgAFAARAgaZw" "s+9Z0WbRm8CatppebW9tDVmpqm7pLKAe7sJgvFm+P2MGjckRHSNkku8u/FcppK/g" "7pMZOVHkRLgLKPSoDQ=="; -static WCHAR signedWithCertWithValidPubKeyContentBase64W[] = { -'M','I','I','B','i','Q','Y','J','K','o','Z','I','h','v','c','N','A','Q','c','C', -'o','I','I','B','e','j','C','C','A','X','Y','C','A','Q','E','x','D','j','A','M', -'B','g','g','q','h','k','i','G','9','w','0','C','B','Q','U','A','M','B','M','G', -'C','S','q','G','S','I','b','3','D','Q','E','H','A','a','A','G','B','A','Q','B', -'A','g','M','E','o','I','H','S','M','I','H','P','A','g','E','B','M','A','I','G', -'A','D','A','V','M','R','M','w','E','Q','Y','D','V','Q','Q','D','E','w','p','K', -'d','W','F','u','I','E','x','h','b','m','c','A','M','C','I','Y','D','z','E','2', -'M','D','E','w','M','T','A','x','M','D','A','w','M','D','A','w','W','h','g','P', -'M','T','Y','w','M','T','A','x','M','D','E','w','M','D','A','w','M','D','B','a', -'M','B','U','x','E','z','A','R','B','g','N','V','B','A','M','T','C','k','p','1', -'Y','W','4','g','T','G','F','u','Z','w','A','w','X','D','A','N','B','g','k','q', -'h','k','i','G','9','w','0','B','A','Q','E','F','A','A','N','L','A','D','B','I', -'A','k','E','A','4','l','Q','6','p','4','O','x','J','x','Q','+','W','b','u','0', -'U','+','Y','f','5','1','3','x','I','W','i','t','h','V','P','b','a','x','7','r', -'Z','Z','c','D','h','m','D','e','8','2','w','4','d','e','B','M','Y','b','u','8', -'Y','h','e','p','z','X','k','/','I','U','6','W','y','w','7','c','Y','Z','Q','w', -'G','B','B','r','0','B','w','Q','e','Q','I','D','A','Q','A','B','o','x','Y','w', -'F','D','A','S','B','g','N','V','H','R','M','B','A','f','8','E','C','D','A','G', -'A','Q','H','/','A','g','E','B','M','X','c','w','d','Q','I','B','A','T','A','a', -'M','B','U','x','E','z','A','R','B','g','N','V','B','A','M','T','C','k','p','1', -'Y','W','4','g','T','G','F','u','Z','w','A','C','A','Q','E','w','D','A','Y','I', -'K','o','Z','I','h','v','c','N','A','g','U','F','A','D','A','E','B','g','A','F', -'A','A','R','A','g','a','Z','w','s','+','9','Z','0','W','b','R','m','8','C','a', -'t','p','p','e','b','W','9','t','D','V','m','p','q','m','7','p','L','K','A','e', -'7','s','J','g','v','F','m','+','P','2','M','G','j','c','k','R','H','S','N','k', -'k','u','8','u','/','F','c','p','p','K','/','g','7','p','M','Z','O','V','H','k', -'R','L','g','L','K','P','S','o','D','Q','=','=',0 }; +static WCHAR signedWithCertWithValidPubKeyContentBase64W[] = +L"MIIBiQYJKoZIhvcNAQcCoIIBejCCAXYCAQExDjAMBggqhkiG9w0CBQUAMBMGCSqG" +"SIb3DQEHAaAGBAQBAgMEoIHSMIHPAgEBMAIGADAVMRMwEQYDVQQDEwpKdWFuIExh" +"bmcAMCIYDzE2MDEwMTAxMDAwMDAwWhgPMTYwMTAxMDEwMDAwMDBaMBUxEzARBgNV" +"BAMTCkp1YW4gTGFuZwAwXDANBgkqhkiG9w0BAQEFAANLADBIAkEA4lQ6p4OxJxQ+" +"Wbu0U+Yf513xIWithVPbax7rZZcDhmDe82w4deBMYbu8YhepzXk/IU6Wyw7cYZQw" +"GBBr0BwQeQIDAQABoxYwFDASBgNVHRMBAf8ECDAGAQH/AgEBMXcwdQIBATAaMBUx" +"EzARBgNVBAMTCkp1YW4gTGFuZwACAQEwDAYIKoZIhvcNAgUFADAEBgAFAARAgaZw" +"s+9Z0WbRm8CatppebW9tDVmpqm7pLKAe7sJgvFm+P2MGjckRHSNkku8u/FcppK/g" +"7pMZOVHkRLgLKPSoDQ==";
static void test_query_object(void) { diff --git a/dlls/crypt32/tests/oid.c b/dlls/crypt32/tests/oid.c index 7ba68b6cceb..291636be388 100644 --- a/dlls/crypt32/tests/oid.c +++ b/dlls/crypt32/tests/oid.c @@ -95,9 +95,6 @@ static const struct OIDToAlgID algIDToOID[] = { { szOID_OIWSEC_sha1, NULL, CALG_SHA }, };
-static const WCHAR bogusDll[] = { 'b','o','g','u','s','.','d','l','l',0 }; -static const WCHAR bogus2Dll[] = { 'b','o','g','u','s','2','.','d','l','l',0 }; - static void testOIDToAlgID(void) { int i; @@ -298,12 +295,12 @@ static void test_registerOIDFunction(void) * omitted. This may be a side effect of the registry code, I don't know. * I don't check it because I doubt anyone would depend on it. ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, NULL, - "1.2.3.4.5.6.7.8.9.10", bogusDll, NULL); + "1.2.3.4.5.6.7.8.9.10", L"bogus.dll", NULL); */ /* On windows XP, GetLastError is incorrectly being set with an HRESULT, * E_INVALIDARG */ - ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, "foo", NULL, bogusDll, + ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, "foo", NULL, L"bogus.dll", NULL); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG: %ld\n", GetLastError()); @@ -313,7 +310,7 @@ static void test_registerOIDFunction(void) ok(ret, "Expected pseudo-success, got %ld\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, "CryptDllEncodeObject", - "1.2.3.4.5.6.7.8.9.10", bogusDll, NULL); + "1.2.3.4.5.6.7.8.9.10", L"bogus.dll", NULL); if (!ret && GetLastError() == ERROR_ACCESS_DENIED) { skip("Need admin rights\n"); @@ -324,7 +321,7 @@ static void test_registerOIDFunction(void) "1.2.3.4.5.6.7.8.9.10"); ok(ret, "CryptUnregisterOIDFunction failed: %ld\n", GetLastError()); ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, "bogus", - "1.2.3.4.5.6.7.8.9.10", bogusDll, NULL); + "1.2.3.4.5.6.7.8.9.10", L"bogus.dll", NULL); ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError()); ret = CryptUnregisterOIDFunction(X509_ASN_ENCODING, "bogus", "1.2.3.4.5.6.7.8.9.10"); @@ -335,14 +332,14 @@ static void test_registerOIDFunction(void) "Could not delete bogus key\n"); /* Shouldn't have effect but registry keys are created */ ret = CryptRegisterOIDFunction(PKCS_7_ASN_ENCODING, "CryptDllEncodeObject", - "1.2.3.4.5.6.7.8.9.10", bogusDll, NULL); + "1.2.3.4.5.6.7.8.9.10", L"bogus.dll", NULL); ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError()); ret = CryptUnregisterOIDFunction(PKCS_7_ASN_ENCODING, "CryptDllEncodeObject", "1.2.3.4.5.6.7.8.9.10"); ok(ret, "CryptUnregisterOIDFunction failed: %ld\n", GetLastError()); /* Check with bogus encoding type. Registry keys are still created */ ret = CryptRegisterOIDFunction(0, "CryptDllEncodeObject", - "1.2.3.4.5.6.7.8.9.10", bogusDll, NULL); + "1.2.3.4.5.6.7.8.9.10", L"bogus.dll", NULL); ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError()); ret = CryptUnregisterOIDFunction(0, "CryptDllEncodeObject", "1.2.3.4.5.6.7.8.9.10"); @@ -357,7 +354,7 @@ static void test_registerOIDFunction(void) * (for now) treated as a mask. Registry keys are created. */ ret = CryptRegisterOIDFunction(3, "CryptDllEncodeObject", - "1.2.3.4.5.6.7.8.9.10", bogusDll, NULL); + "1.2.3.4.5.6.7.8.9.10", L"bogus.dll", NULL); ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError()); ret = CryptUnregisterOIDFunction(3, "CryptDllEncodeObject", "1.2.3.4.5.6.7.8.9.10"); @@ -387,12 +384,12 @@ static void test_registerDefaultOIDFunction(void) ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* This succeeds on WinXP, although the bogus entry is unusable. - ret = CryptRegisterDefaultOIDFunction(0, NULL, 0, bogusDll); + ret = CryptRegisterDefaultOIDFunction(0, NULL, 0, L"bogus.dll"); */ /* Register one at index 0 */ SetLastError(0xdeadbeef); ret = CryptRegisterDefaultOIDFunction(0, "CertDllOpenStoreProv", 0, - bogusDll); + L"bogus.dll"); if (!ret && GetLastError() == ERROR_ACCESS_DENIED) { skip("Need admin rights\n"); @@ -401,66 +398,63 @@ static void test_registerDefaultOIDFunction(void) ok(ret, "CryptRegisterDefaultOIDFunction failed: %08lx\n", GetLastError()); /* Reregistering should fail */ ret = CryptRegisterDefaultOIDFunction(0, "CertDllOpenStoreProv", 0, - bogusDll); + L"bogus.dll"); ok(!ret && GetLastError() == ERROR_FILE_EXISTS, "Expected ERROR_FILE_EXISTS, got %08lx\n", GetLastError()); /* Registering the same one at index 1 should also fail */ ret = CryptRegisterDefaultOIDFunction(0, "CertDllOpenStoreProv", 1, - bogusDll); + L"bogus.dll"); ok(!ret && GetLastError() == ERROR_FILE_EXISTS, "Expected ERROR_FILE_EXISTS, got %08lx\n", GetLastError()); /* Registering a different one at index 1 succeeds */ ret = CryptRegisterDefaultOIDFunction(0, "CertDllOpenStoreProv", 1, - bogus2Dll); + L"bogus2.dll"); ok(ret, "CryptRegisterDefaultOIDFunction failed: %08lx\n", GetLastError()); sprintf(buf, fmt, 0, func); rc = RegOpenKeyA(HKEY_LOCAL_MACHINE, buf, &key); ok(rc == 0, "Expected key to exist, RegOpenKeyA failed: %ld\n", rc); if (rc == 0) { - static const CHAR dllA[] = "Dll"; - static const CHAR bogusDll_A[] = "bogus.dll"; - static const CHAR bogus2Dll_A[] = "bogus2.dll"; CHAR dllBuf[MAX_PATH]; DWORD type, size; LPSTR ptr;
size = ARRAY_SIZE(dllBuf); - rc = RegQueryValueExA(key, dllA, NULL, &type, (LPBYTE)dllBuf, &size); + rc = RegQueryValueExA(key, "Dll", NULL, &type, (LPBYTE)dllBuf, &size); ok(rc == 0, "Expected Dll value to exist, RegQueryValueExA failed: %ld\n", rc); ok(type == REG_MULTI_SZ, "Expected type REG_MULTI_SZ, got %ld\n", type); - /* bogusDll was registered first, so that should be first */ + /* bogus.dll was registered first, so that should be first */ ptr = dllBuf; - ok(!lstrcmpiA(ptr, bogusDll_A), "Unexpected dll\n"); + ok(!lstrcmpiA(ptr, "bogus.dll"), "Unexpected dll\n"); ptr += lstrlenA(ptr) + 1; - ok(!lstrcmpiA(ptr, bogus2Dll_A), "Unexpected dll\n"); + ok(!lstrcmpiA(ptr, "bogus2.dll"), "Unexpected dll\n"); RegCloseKey(key); } /* Unregister both of them */ ret = CryptUnregisterDefaultOIDFunction(0, "CertDllOpenStoreProv", - bogusDll); + L"bogus.dll"); ok(ret, "CryptUnregisterDefaultOIDFunction failed: %08lx\n", GetLastError()); ret = CryptUnregisterDefaultOIDFunction(0, "CertDllOpenStoreProv", - bogus2Dll); + L"bogus2.dll"); ok(ret, "CryptUnregisterDefaultOIDFunction failed: %08lx\n", GetLastError()); /* Now that they're both unregistered, unregistering should fail */ ret = CryptUnregisterDefaultOIDFunction(0, "CertDllOpenStoreProv", - bogusDll); + L"bogus.dll"); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
/* Repeat a few tests on the normal encoding type */ ret = CryptRegisterDefaultOIDFunction(X509_ASN_ENCODING, - "CertDllOpenStoreProv", 0, bogusDll); + "CertDllOpenStoreProv", 0, L"bogus.dll"); ok(ret, "CryptRegisterDefaultOIDFunction failed\n"); ret = CryptUnregisterDefaultOIDFunction(X509_ASN_ENCODING, - "CertDllOpenStoreProv", bogusDll); + "CertDllOpenStoreProv", L"bogus.dll"); ok(ret, "CryptUnregisterDefaultOIDFunction failed\n"); ret = CryptUnregisterDefaultOIDFunction(X509_ASN_ENCODING, - "CertDllOpenStoreProv", bogusDll); + "CertDllOpenStoreProv", L"bogus.dll"); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); } @@ -498,7 +492,7 @@ static void test_getDefaultOIDFunctionAddress(void) /* Even with a registered dll, this fails (since the dll doesn't exist) */ SetLastError(0xdeadbeef); ret = CryptRegisterDefaultOIDFunction(0, "CertDllOpenStoreProv", 0, - bogusDll); + L"bogus.dll"); if (!ret && GetLastError() == ERROR_ACCESS_DENIED) skip("Need admin rights\n"); else @@ -507,7 +501,7 @@ static void test_getDefaultOIDFunctionAddress(void) &hFuncAddr); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError()); - CryptUnregisterDefaultOIDFunction(0, "CertDllOpenStoreProv", bogusDll); + CryptUnregisterDefaultOIDFunction(0, "CertDllOpenStoreProv", L"bogus.dll"); }
static BOOL WINAPI countOidInfo(PCCRYPT_OID_INFO pInfo, void *pvArg) @@ -545,8 +539,6 @@ static void test_enumOIDInfo(void)
static void test_findOIDInfo(void) { - static WCHAR sha256ECDSA[] = { 's','h','a','2','5','6','E','C','D','S','A',0 }; - static WCHAR sha1[] = { 's','h','a','1',0 }; static CHAR oid_rsa_md5[] = szOID_RSA_MD5, oid_sha256[] = szOID_NIST_sha256; static CHAR oid_ecdsa_sha256[] = szOID_ECDSA_SHA256; ALG_ID alg = CALG_SHA1; @@ -561,7 +553,7 @@ static void test_findOIDInfo(void) } oid_test_info [] = { { CRYPT_OID_INFO_OID_KEY, oid_rsa_md5, szOID_RSA_MD5, CALG_MD5 }, - { CRYPT_OID_INFO_NAME_KEY, sha1, szOID_OIWSEC_sha1, CALG_SHA1 }, + { CRYPT_OID_INFO_NAME_KEY, (void *)L"sha1", szOID_OIWSEC_sha1, CALG_SHA1 }, { CRYPT_OID_INFO_ALGID_KEY, &alg, szOID_OIWSEC_sha1, CALG_SHA1 }, { CRYPT_OID_INFO_SIGN_KEY, algs, szOID_RSA_MD5RSA, CALG_MD5 }, { CRYPT_OID_INFO_OID_KEY, oid_sha256, szOID_NIST_sha256, CALG_SHA_256, -1 }, @@ -593,8 +585,8 @@ static void test_findOIDInfo(void)
ok(info->cbSize == sizeof(*info), "Unexpected structure size %ld.\n", info->cbSize); ok(!strcmp(info->pszOID, oid_ecdsa_sha256), "Expected %s, got %s\n", oid_ecdsa_sha256, info->pszOID); - ok(!lstrcmpW(info->pwszName, sha256ECDSA), "Expected %s, got %s\n", - wine_dbgstr_w(sha256ECDSA), wine_dbgstr_w(info->pwszName)); + ok(!lstrcmpW(info->pwszName, L"sha256ECDSA"), "Expected %s, got %s\n", + wine_dbgstr_w(L"sha256ECDSA"), wine_dbgstr_w(info->pwszName)); ok(info->dwGroupId == CRYPT_SIGN_ALG_OID_GROUP_ID, "Expected CRYPT_SIGN_ALG_OID_GROUP_ID, got %lu\n", info->dwGroupId); ok(U(*info).Algid == CALG_OID_INFO_CNG_ONLY, @@ -617,7 +609,6 @@ static void test_findOIDInfo(void)
static void test_registerOIDInfo(void) { - static const WCHAR winetestW[] = { 'w','i','n','e','t','e','s','t',0 }; static char test_oid[] = "1.2.3.4.5.6.7.8.9.10"; CRYPT_OID_INFO info1; const CRYPT_OID_INFO *info2; @@ -665,7 +656,7 @@ static void test_registerOIDInfo(void) info2 = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, (void *)test_oid, 0); ok(!info2, "should fail\n");
- info1.pwszName = winetestW; + info1.pwszName = L"winetest"; info1.dwGroupId = CRYPT_HASH_ALG_OID_GROUP_ID; SetLastError(0xdeadbeef); ret = CryptRegisterOIDInfo(&info1, CRYPT_INSTALL_OID_INFO_BEFORE_FLAG); diff --git a/dlls/crypt32/tests/protectdata.c b/dlls/crypt32/tests/protectdata.c index c4dfcd19a39..162dab090e2 100644 --- a/dlls/crypt32/tests/protectdata.c +++ b/dlls/crypt32/tests/protectdata.c @@ -33,7 +33,6 @@ static BOOL (WINAPI *pCryptUnprotectData)(DATA_BLOB*,LPWSTR*,DATA_BLOB*,PVOID,CR 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"; -static const WCHAR desc[] = {'U','l','t','r','a',' ','s','e','c','r','e','t',' ','t','e','s','t',' ','m','e','s','s','a','g','e',0}; static BOOL protected = FALSE; /* if true, the unprotect tests can run */ static DATA_BLOB cipher; static DATA_BLOB cipher_entropy; @@ -52,13 +51,13 @@ static void test_cryptprotectdata(void) entropy.cbData=strlen(key)+1;
SetLastError(0xDEADBEEF); - protected = pCryptProtectData(NULL,desc,NULL,NULL,NULL,0,&cipher); + protected = pCryptProtectData(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,desc,NULL,NULL,NULL,0,NULL); + protected = pCryptProtectData(&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); @@ -68,7 +67,7 @@ static void test_cryptprotectdata(void)
/* without entropy */ SetLastError(0xDEADBEEF); - protected = pCryptProtectData(&plain,desc,NULL,NULL,NULL,0,&cipher); + protected = pCryptProtectData(&plain, L"Ultra secret test message", NULL, NULL, NULL, 0, &cipher); ok(protected || broken(!protected), /* Win9x/NT4 */ "Encrypting without entropy.\n"); @@ -85,7 +84,7 @@ static void test_cryptprotectdata(void)
/* with entropy */ SetLastError(0xDEADBEEF); - protected = pCryptProtectData(&plain,desc,&entropy,NULL,NULL,0,&cipher_entropy); + protected = pCryptProtectData(&plain, L"Ultra secret test message", &entropy, NULL, NULL, 0, &cipher_entropy); ok(protected || broken(!protected), /* Win9x/NT4 */ "Encrypting with entropy.\n"); @@ -161,7 +160,7 @@ static void test_cryptunprotectdata(void) ok(plain.cbData==strlen(secret)+1,"Plain DATA_BLOB wrong length\n"); ok(!strcmp((const char*)plain.pbData,secret),"Plain does not match secret\n"); ok(data_desc!=NULL,"Description not allocated\n"); - ok(!lstrcmpW(data_desc,desc),"Description does not match\n"); + ok(!lstrcmpW(data_desc, L"Ultra secret test message"),"Description does not match\n");
LocalFree(plain.pbData); LocalFree(data_desc); @@ -186,7 +185,7 @@ static void test_cryptunprotectdata(void) ok(plain.cbData==strlen(secret)+1,"Plain DATA_BLOB wrong length\n"); ok(!strcmp((const char*)plain.pbData,secret),"Plain does not match secret\n"); ok(data_desc!=NULL,"Description not allocated\n"); - ok(!lstrcmpW(data_desc,desc),"Description does not match\n"); + ok(!lstrcmpW(data_desc, L"Ultra secret test message"),"Description does not match\n");
LocalFree(plain.pbData); LocalFree(data_desc); diff --git a/dlls/crypt32/tests/sip.c b/dlls/crypt32/tests/sip.c index 5728065127b..4a89393484e 100644 --- a/dlls/crypt32/tests/sip.c +++ b/dlls/crypt32/tests/sip.c @@ -41,8 +41,6 @@ static void test_AddRemoveProvider(void) BOOL ret; SIP_ADD_NEWPROVIDER newprov; GUID actionid = { 0xdeadbe, 0xefde, 0xadbe, { 0xef,0xde,0xad,0xbe,0xef,0xde,0xad,0xbe }}; - static WCHAR dummydll[] = {'d','e','a','d','b','e','e','f','.','d','l','l',0 }; - static WCHAR dummyfunction[] = {'d','u','m','m','y','f','u','n','c','t','i','o','n',0 };
/* NULL check */ SetLastError(0xdeadbeef); @@ -77,12 +75,12 @@ static void test_AddRemoveProvider(void) memset(&newprov, 0, sizeof(SIP_ADD_NEWPROVIDER)); newprov.cbStruct = sizeof(SIP_ADD_NEWPROVIDER); newprov.pgSubject = &actionid; - newprov.pwszDLLFileName = dummydll; - newprov.pwszGetFuncName = dummyfunction; - newprov.pwszPutFuncName = dummyfunction; - newprov.pwszCreateFuncName = dummyfunction; - newprov.pwszVerifyFuncName = dummyfunction; - newprov.pwszRemoveFuncName = dummyfunction; + newprov.pwszDLLFileName = (WCHAR *)L"deadbeef.dll"; + newprov.pwszGetFuncName = (WCHAR *)L"dummyfunction"; + newprov.pwszPutFuncName = (WCHAR *)L"dummyfunction"; + newprov.pwszCreateFuncName = (WCHAR *)L"dummyfunction"; + newprov.pwszVerifyFuncName = (WCHAR *)L"dummyfunction"; + newprov.pwszRemoveFuncName = (WCHAR *)L"dummyfunction"; SetLastError(0xdeadbeef); ret = CryptSIPAddProvider(&newprov); if (!ret && GetLastError() == ERROR_ACCESS_DENIED) @@ -111,16 +109,16 @@ static void test_AddRemoveProvider(void) memset(&newprov, 0, sizeof(SIP_ADD_NEWPROVIDER)); newprov.cbStruct = sizeof(SIP_ADD_NEWPROVIDER); newprov.pgSubject = &actionid; - newprov.pwszDLLFileName = dummydll; - newprov.pwszGetFuncName = dummyfunction; - newprov.pwszPutFuncName = dummyfunction; - newprov.pwszCreateFuncName = dummyfunction; - newprov.pwszVerifyFuncName = dummyfunction; - newprov.pwszRemoveFuncName = dummyfunction; - newprov.pwszIsFunctionNameFmt2 = dummyfunction; - newprov.pwszIsFunctionName = dummyfunction; + newprov.pwszDLLFileName = (WCHAR *)L"deadbeef.dll"; + newprov.pwszGetFuncName = (WCHAR *)L"dummyfunction"; + newprov.pwszPutFuncName = (WCHAR *)L"dummyfunction"; + newprov.pwszCreateFuncName = (WCHAR *)L"dummyfunction"; + newprov.pwszVerifyFuncName = (WCHAR *)L"dummyfunction"; + newprov.pwszRemoveFuncName = (WCHAR *)L"dummyfunction"; + newprov.pwszIsFunctionNameFmt2 = (WCHAR *)L"dummyfunction"; + newprov.pwszIsFunctionName = (WCHAR *)L"dummyfunction"; /* If GetCapFuncName set to NULL, then CryptSIPRemoveProvider fails on win 8 */ - newprov.pwszGetCapFuncName = dummyfunction; + newprov.pwszGetCapFuncName = (WCHAR *)L"dummyfunction";
SetLastError(0xdeadbeef); ret = CryptSIPAddProvider(&newprov); @@ -148,7 +146,6 @@ static void test_SIPRetrieveSubjectGUID(void) static const CHAR windir[] = "windir"; static const CHAR regeditExe[] = "regedit.exe"; static const GUID nullSubject = { 0x0, 0x0, 0x0, { 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 }}; - static const WCHAR deadbeef[] = { 'c',':','\','d','e','a','d','b','e','e','f','.','d','b','f',0 }; /* Couldn't find a name for this GUID, it's the one used for 95% of the files */ static const GUID unknownGUID = { 0xC689AAB8, 0x8E78, 0x11D0, { 0x8C,0x47,0x00,0xC0,0x4F,0xC2,0x95,0xEE }}; static const GUID cabGUID = { 0xc689aaba, 0x8e78, 0x11d0, {0x8c,0x47,0x00,0xc0,0x4f,0xc2,0x95,0xee }}; @@ -170,7 +167,7 @@ static void test_SIPRetrieveSubjectGUID(void) SetLastError(0xdeadbeef); /* Set subject to something other than zeros */ memset(&subject, 1, sizeof(GUID)); - ret = CryptSIPRetrieveSubjectGuid(deadbeef, NULL, &subject); + ret = CryptSIPRetrieveSubjectGuid(L"c:\deadbeef.dbf", NULL, &subject); ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n"); ok (GetLastError() == ERROR_FILE_NOT_FOUND || GetLastError() == ERROR_PATH_NOT_FOUND, diff --git a/dlls/crypt32/tests/store.c b/dlls/crypt32/tests/store.c index d8669995d68..f1124459d6a 100644 --- a/dlls/crypt32/tests/store.c +++ b/dlls/crypt32/tests/store.c @@ -366,16 +366,6 @@ static const struct */ static void testRegStoreSavedCerts(void) { - static const WCHAR fmt[] = - { '%','s','\','%','s','\','%','s','\','%','s',0}, - ms_certs[] = - { 'M','i','c','r','o','s','o','f','t','\','S','y','s','t','e','m','C','e','r','t','i','f','i','c','a','t','e','s',0}, - certs[] = - {'C','e','r','t','i','f','i','c','a','t','e','s',0}, - bigCert_hash[] = { - '6','E','3','0','9','0','7','1','5','F','D','9','2','3', - '5','6','E','B','A','E','2','5','4','0','E','6','2','2', - 'D','A','1','9','2','6','0','2','A','6','0','8',0}; PCCERT_CONTEXT cert1, cert2; HCERTSTORE store; HANDLE cert_file; @@ -415,8 +405,8 @@ static void testRegStoreSavedCerts(void) CertFreeCertificateContext(cert1); CertCloseStore(store, 0);
- wsprintfW(key_name, fmt, reg_store_saved_certs[i].base_reg_path, - reg_store_saved_certs[i].store_name, certs, bigCert_hash); + wsprintfW(key_name, L"%s\%s\%s\%s", reg_store_saved_certs[i].base_reg_path, + reg_store_saved_certs[i].store_name, L"Certificates", L"6E3090715FD92356EBAE2540E622DA192602A608");
if (!reg_store_saved_certs[i].appdata_file) { @@ -430,10 +420,10 @@ static void testRegStoreSavedCerts(void) "Failed to get app data path at %ld (%lx)\n", pathres, GetLastError()); if (pathres == S_OK) { - PathAppendW(appdata_path, ms_certs); + PathAppendW(appdata_path, L"Microsoft\SystemCertificates"); PathAppendW(appdata_path, reg_store_saved_certs[i].store_name); - PathAppendW(appdata_path, certs); - PathAppendW(appdata_path, bigCert_hash); + PathAppendW(appdata_path, L"Certificates"); + PathAppendW(appdata_path, L"6E3090715FD92356EBAE2540E622DA192602A608");
cert_file = CreateFileW(appdata_path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); @@ -486,9 +476,6 @@ static void testStoresInCollection(void) { PCCERT_CONTEXT cert1, cert2, tcert1; HCERTSTORE collection, ro_store, rw_store, rw_store_2, tstore; - static const WCHAR WineTestRO_W[] = { 'W','i','n','e','T','e','s','t','_','R','O',0 }, - WineTestRW_W[] = { 'W','i','n','e','T','e','s','t','_','R','W',0 }, - WineTestRW2_W[]= { 'W','i','n','e','T','e','s','t','_','R','W','2',0 }; BOOL ret;
collection = CertOpenStore(CERT_STORE_PROV_COLLECTION, 0, 0, @@ -496,7 +483,7 @@ static void testStoresInCollection(void) ok(collection != NULL, "Failed to init collection store, last error %lx\n", GetLastError()); /* Add read-only store to collection with very high priority*/ ro_store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER, WineTestRO_W); + CERT_SYSTEM_STORE_CURRENT_USER, L"WineTest_RO"); ok(ro_store != NULL, "Failed to init ro store %lx\n", GetLastError());
ret = CertAddStoreToCollection(collection, ro_store, 0, 1000); @@ -509,7 +496,7 @@ static void testStoresInCollection(void)
/* Add read-write store to collection with the lowest priority*/ rw_store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER, WineTestRW_W); + CERT_SYSTEM_STORE_CURRENT_USER, L"WineTest_RW"); ok (rw_store != NULL, "Failed to open rw store %lx\n", GetLastError()); ret = CertAddStoreToCollection(collection, rw_store, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0); ok (ret, "Failed to add rw store to collection %lx\n", GetLastError()); @@ -533,7 +520,7 @@ static void testStoresInCollection(void)
/** adding one more rw store with higher priority*/ rw_store_2 = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER, WineTestRW2_W); + CERT_SYSTEM_STORE_CURRENT_USER, L"WineTest_RW2"); ok (rw_store_2 != NULL, "Failed to init second rw store %lx\n", GetLastError()); ret = CertAddStoreToCollection(collection, rw_store_2, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 50); ok (ret, "Failed to add rw_store_2 to collection %lx\n",GetLastError()); @@ -568,8 +555,8 @@ static void testStoresInCollection(void) ok (tcert1==NULL,"Unexpected cert in the collection %p %lx\n",tcert1, GetLastError());
/* checking whether certs had been saved */ - tstore = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W,0,0, - CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, WineTestRW_W); + tstore = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W, 0, 0, + CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, L"WineTest_RW"); ok (tstore!=NULL, "Failed to open existing rw store\n"); tcert1 = CertEnumCertificatesInStore(tstore, NULL); todo_wine @@ -577,8 +564,8 @@ static void testStoresInCollection(void) CertFreeCertificateContext(tcert1); CertCloseStore(tstore,0);
- tstore = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W,0,0, - CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, WineTestRW2_W); + tstore = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W, 0, 0, + CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, L"WineTest_RW2"); ok (tstore!=NULL, "Failed to open existing rw2 store\n"); tcert1 = CertEnumCertificatesInStore(tstore, NULL); todo_wine @@ -592,16 +579,16 @@ static void testStoresInCollection(void) CertCloseStore(rw_store_2,0);
/* reopening registry stores to check whether certs had been saved */ - rw_store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W,0,0, - CERT_SYSTEM_STORE_CURRENT_USER, WineTestRW_W); + rw_store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W, 0, 0, + CERT_SYSTEM_STORE_CURRENT_USER, L"WineTest_RW"); tcert1 = CertEnumCertificatesInStore(rw_store, NULL); ok (tcert1 && tcert1->cbCertEncoded == cert1->cbCertEncoded, "Unexpected cert in store %p\n", tcert1); CertFreeCertificateContext(tcert1); CertCloseStore(rw_store,0);
- rw_store_2 = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W,0,0, - CERT_SYSTEM_STORE_CURRENT_USER, WineTestRW2_W); + rw_store_2 = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W, 0, 0, + CERT_SYSTEM_STORE_CURRENT_USER, L"WineTest_RW2"); tcert1 = CertEnumCertificatesInStore(rw_store_2, NULL); ok (tcert1 && tcert1->cbCertEncoded == cert2->cbCertEncoded, "Unexpected cert in store %p\n", tcert1); @@ -610,12 +597,12 @@ static void testStoresInCollection(void)
CertFreeCertificateContext(cert1); CertFreeCertificateContext(cert2); - CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W,0,0, - CERT_STORE_DELETE_FLAG|CERT_SYSTEM_STORE_CURRENT_USER,WineTestRO_W); - CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W,0,0, - CERT_STORE_DELETE_FLAG|CERT_SYSTEM_STORE_CURRENT_USER,WineTestRW_W); - CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W,0,0, - CERT_STORE_DELETE_FLAG|CERT_SYSTEM_STORE_CURRENT_USER,WineTestRW2_W); + CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W, 0, 0, + CERT_STORE_DELETE_FLAG|CERT_SYSTEM_STORE_CURRENT_USER, L"WineTest_RO"); + CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W, 0, 0, + CERT_STORE_DELETE_FLAG|CERT_SYSTEM_STORE_CURRENT_USER, L"WineTest_RW"); + CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W, 0, 0, + CERT_STORE_DELETE_FLAG|CERT_SYSTEM_STORE_CURRENT_USER, L"WineTest_RW2");
}
@@ -624,8 +611,6 @@ static void testCollectionStore(void) HCERTSTORE store1, store2, collection, collection2; PCCERT_CONTEXT context; BOOL ret; - static const WCHAR szPrefix[] = { 'c','e','r',0 }; - static const WCHAR szDot[] = { '.',0 }; WCHAR filename[MAX_PATH]; HANDLE file;
@@ -949,7 +934,7 @@ static void testCollectionStore(void) /* Test adding a cert to a collection with a file store, committing the * change to the collection, and comparing the resulting file. */ - if (!GetTempFileNameW(szDot, szPrefix, 0, filename)) + if (!GetTempFileNameW(L".", L"cer", 0, filename)) return;
DeleteFileW(filename); @@ -1281,20 +1266,13 @@ static void testRegStore(void) } }
-static const char MyA[] = { 'M','y',0,0 }; -static const WCHAR MyW[] = { 'M','y',0 }; -static const WCHAR BogusW[] = { 'B','o','g','u','s',0 }; -static const WCHAR BogusPathW[] = { 'S','o','f','t','w','a','r','e','\', - 'M','i','c','r','o','s','o','f','t','\','S','y','s','t','e','m','C','e','r', - 't','i','f','i','c','a','t','e','s','\','B','o','g','u','s',0 }; - static void testSystemRegStore(void) { HCERTSTORE store, memStore;
/* Check with a UNICODE name */ store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, MyW); + CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, L"My"); /* Not all OSes support CERT_STORE_PROV_SYSTEM_REGISTRY, so don't continue * testing if they don't. */ @@ -1314,41 +1292,40 @@ static void testSystemRegStore(void)
/* Check opening a bogus store */ store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, BogusW); + CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, L"Bogus"); ok(!store && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER, BogusW); + CERT_SYSTEM_STORE_CURRENT_USER, L"Bogus"); ok(store != 0, "CertOpenStore failed: %08lx\n", GetLastError()); if (store) CertCloseStore(store, 0); /* Now check whether deleting is allowed */ store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_DELETE_FLAG, BogusW); + CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_DELETE_FLAG, L"Bogus"); ok(!store, "CertOpenStore failed: %08lx\n", GetLastError()); - RegDeleteKeyW(HKEY_CURRENT_USER, BogusPathW); + RegDeleteKeyW(HKEY_CURRENT_USER, L"Software\Microsoft\SystemCertificates\Bogus");
store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY, 0, 0, 0, NULL); ok(!store && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError()); store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY, 0, 0, - CERT_SYSTEM_STORE_LOCAL_MACHINE | CERT_SYSTEM_STORE_CURRENT_USER, MyA); + CERT_SYSTEM_STORE_LOCAL_MACHINE | CERT_SYSTEM_STORE_CURRENT_USER, "My"); ok(!store && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError()); store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY, 0, 0, - CERT_SYSTEM_STORE_LOCAL_MACHINE | CERT_SYSTEM_STORE_CURRENT_USER, MyW); + CERT_SYSTEM_STORE_LOCAL_MACHINE | CERT_SYSTEM_STORE_CURRENT_USER, L"My"); ok(!store && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* The name is expected to be UNICODE, check with an ASCII name */ store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, MyA); + CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, "My"); ok(!store && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); }
static void testSystemStore(void) { - static const WCHAR baskslashW[] = { '\',0 }; HCERTSTORE store; WCHAR keyName[MAX_PATH]; HKEY key; @@ -1358,22 +1335,21 @@ static void testSystemStore(void) ok(!store && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, - CERT_SYSTEM_STORE_LOCAL_MACHINE | CERT_SYSTEM_STORE_CURRENT_USER, MyA); + CERT_SYSTEM_STORE_LOCAL_MACHINE | CERT_SYSTEM_STORE_CURRENT_USER, "My"); ok(!store && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, - CERT_SYSTEM_STORE_LOCAL_MACHINE | CERT_SYSTEM_STORE_CURRENT_USER, MyW); + CERT_SYSTEM_STORE_LOCAL_MACHINE | CERT_SYSTEM_STORE_CURRENT_USER, L"My"); ok(!store && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); /* The name is expected to be UNICODE, first check with an ASCII name */ store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, MyA); + CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, "My"); ok(!store && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); /* Create the expected key */ lstrcpyW(keyName, CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH); - lstrcatW(keyName, baskslashW); - lstrcatW(keyName, MyW); + lstrcatW(keyName, L"\My"); rc = RegCreateKeyExW(HKEY_CURRENT_USER, keyName, 0, NULL, 0, KEY_READ, NULL, &key, NULL); ok(!rc, "RegCreateKeyEx failed: %ld\n", rc); @@ -1381,12 +1357,12 @@ static void testSystemStore(void) RegCloseKey(key); /* Check opening with a UNICODE name, specifying the create new flag */ store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_CREATE_NEW_FLAG, MyW); + CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_CREATE_NEW_FLAG, L"My"); ok(!store && GetLastError() == ERROR_FILE_EXISTS, "Expected ERROR_FILE_EXISTS, got %08lx\n", GetLastError()); /* Now check opening with a UNICODE name, this time opening existing */ store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, MyW); + CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, L"My"); ok(store != 0, "CertOpenStore failed: %08lx\n", GetLastError()); if (store) { @@ -1405,18 +1381,18 @@ static void testSystemStore(void)
/* Check opening a bogus store */ store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, BogusW); + CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, L"Bogus"); ok(!store, "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER, BogusW); + CERT_SYSTEM_STORE_CURRENT_USER, L"Bogus"); ok(store != 0, "CertOpenStore failed: %08lx\n", GetLastError()); if (store) CertCloseStore(store, 0); /* Now check whether deleting is allowed */ store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_DELETE_FLAG, BogusW); + CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_DELETE_FLAG, L"Bogus"); ok(!store, "Didn't expect a store to be returned when deleting\n"); - RegDeleteKeyW(HKEY_CURRENT_USER, BogusPathW); + RegDeleteKeyW(HKEY_CURRENT_USER, L"Software\Microsoft\SystemCertificates\Bogus"); }
static const BYTE serializedStoreWithCertAndCRL[] = { @@ -1439,8 +1415,6 @@ static const BYTE serializedStoreWithCertAndCRL[] = {
static void testFileStore(void) { - static const WCHAR szPrefix[] = { 'c','e','r',0 }; - static const WCHAR szDot[] = { '.',0 }; WCHAR filename[MAX_PATH]; HCERTSTORE store; BOOL ret; @@ -1451,7 +1425,7 @@ static void testFileStore(void) ok(!store && GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %08lx\n", GetLastError());
- if (!GetTempFileNameW(szDot, szPrefix, 0, filename)) + if (!GetTempFileNameW(L".", L"cer", 0, filename)) return;
DeleteFileW(filename); @@ -1597,57 +1571,22 @@ static const BYTE base64SPC[] = "G6U1ipFe/q8byWD/9JpiBKMGPi9YlUTgXHfS9d4S/QWO1h9Z7KeipBYhoslQpHXu" "y9bUr8Adqi6SzgHpCnMu53dxgxUD1r4xAA=="; /* Same as base64SPC, but as a wide-char string */ -static const WCHAR utf16Base64SPC[] = { -'M','I','I','C','J','Q','Y','J','K','o','Z','I','h','v','c','N','A', -'Q','c','C','o','I','I','C','F','j','C','C','A','h','I','C','A','Q', -'E','x','A','D','A','L','B','g','k','q','h','k','i','G','9','w','0', -'B','B','w','G','g','g','g','H','6','M','I','I','B','9','j','C','C', -'A','V','+','g','A','w','I','B','A','g','I','Q','n','P','8','+','E', -'F','4','o','p','r','9','O','x','H','7','h','4','u','B','P','W','T', -'A','N','B','g','k','q','h','k','i','G','9','w','0','B','A','Q','Q', -'F','A','D','A','U','M','R','I','w','E','A','Y','D','V','Q','Q','D', -'E','w','l','K','d','W','F','u','I','E','x','h','b','m','c','w','H', -'h','c','N','M','D','g','x','M','j','E','y','M','T','c','x','M','D', -'E','0','W','h','c','N','M','z','k','x','M','j','M','x','M','j','M', -'1','O','T','U','5','W','j','A','U','M','R','I','w','E','A','Y','D', -'V','Q','Q','D','E','w','l','K','d','W','F','u','I','E','x','h','b', -'m','c','w','g','Z','8','w','D','Q','Y','J','K','o','Z','I','h','v', -'c','N','A','Q','E','B','B','Q','A','D','g','Y','0','A','M','I','G', -'J','A','o','G','B','A','L','C','g','N','j','y','N','v','O','i','c', -'0','F','O','f','j','x','v','i','4','3','H','b','M','+','D','5','j', -'o','D','k','h','i','G','S','X','e','+','g','b','Z','l','f','8','f', -'1','6','k','0','7','k','k','O','b','F','E','u','n','z','m','d','B', -'5','c','o','s','c','m','A','7','g','y','q','i','W','N','N','4','Z', -'U','y','r','2','c','A','3','l','C','b','n','p','G','P','A','/','0', -'I','b','l','y','y','O','c','u','G','I','F','m','m','C','z','e','Z', -'a','V','a','5','Z','G','6','x','Z','P','K','7','L','7','o','+','7', -'3','Q','o','6','j','X','V','b','G','h','B','G','n','M','Z','7','Q', -'9','s','A','n','6','s','2','9','3','3','o','l','n','S','t','n','e', -'j','n','q','w','V','0','N','A','g','M','B','A','A','G','j','S','T', -'B','H','M','E','U','G','A','1','U','d','A','Q','Q','+','M','D','y', -'A','E','F','K','b','K','E','d','X','Y','y','x','+','C','W','K','c', -'V','6','v','x','M','6','S','h','F','j','A','U','M','R','I','w','E', -'A','Y','D','V','Q','Q','D','E','w','l','K','d','W','F','u','I','E', -'x','h','b','m','e','C','E','J','z','/','P','h','B','e','K','K','a', -'/','T','s','R','+','4','e','L','g','T','1','k','w','D','Q','Y','J', -'K','o','Z','I','h','v','c','N','A','Q','E','E','B','Q','A','D','g', -'Y','E','A','L','p','k','g','L','g','W','3','m','E','a','K','i','d', -'P','Q','3','i','P','J','Y','L','G','0','U','b','1','w','r','a','q', -'E','l','9','b','d','4','2','h','r','h','z','I','d','c','D','z','l', -'Q','g','x','n','m','8','/','5','c','H','Y','V','x','I','F','/','C', -'2','0','x','/','H','J','p','l','b','1','R','G','6','U','1','i','p', -'F','e','/','q','8','b','y','W','D','/','9','J','p','i','B','K','M', -'G','P','i','9','Y','l','U','T','g','X','H','f','S','9','d','4','S', -'/','Q','W','O','1','h','9','Z','7','K','e','i','p','B','Y','h','o', -'s','l','Q','p','H','X','u','y','9','b','U','r','8','A','d','q','i', -'6','S','z','g','H','p','C','n','M','u','5','3','d','x','g','x','U', -'D','1','r','4','x','A','A','=','=',0 }; +static const WCHAR utf16Base64SPC[] = +L"MIICJQYJKoZIhvcNAQcCoIICFjCCAhICAQExADALBgkqhkiG9w0BBwGgggH6MIIB" +"9jCCAV+gAwIBAgIQnP8+EF4opr9OxH7h4uBPWTANBgkqhkiG9w0BAQQFADAUMRIw" +"EAYDVQQDEwlKdWFuIExhbmcwHhcNMDgxMjEyMTcxMDE0WhcNMzkxMjMxMjM1OTU5" +"WjAUMRIwEAYDVQQDEwlKdWFuIExhbmcwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJ" +"AoGBALCgNjyNvOic0FOfjxvi43HbM+D5joDkhiGSXe+gbZlf8f16k07kkObFEunz" +"mdB5coscmA7gyqiWNN4ZUyr2cA3lCbnpGPA/0IblyyOcuGIFmmCzeZaVa5ZG6xZP" +"K7L7o+73Qo6jXVbGhBGnMZ7Q9sAn6s2933olnStnejnqwV0NAgMBAAGjSTBHMEUG" +"A1UdAQQ+MDyAEFKbKEdXYyx+CWKcV6vxM6ShFjAUMRIwEAYDVQQDEwlKdWFuIExh" +"bmeCEJz/PhBeKKa/TsR+4eLgT1kwDQYJKoZIhvcNAQEEBQADgYEALpkgLgW3mEaK" +"idPQ3iPJYLG0Ub1wraqEl9bd42hrhzIdcDzlQgxnm8/5cHYVxIF/C20x/HJplb1R" +"G6U1ipFe/q8byWD/9JpiBKMGPi9YlUTgXHfS9d4S/QWO1h9Z7KeipBYhoslQpHXu" +"y9bUr8Adqi6SzgHpCnMu53dxgxUD1r4xAA==";
static void testFileNameStore(void) { - static const WCHAR szPrefix[] = { 'c','e','r',0 }; - static const WCHAR spcPrefix[] = { 's','p','c',0 }; - static const WCHAR szDot[] = { '.',0 }; WCHAR filename[MAX_PATH]; HCERTSTORE store; BOOL ret; @@ -1659,7 +1598,7 @@ static void testFileNameStore(void) "Expected ERROR_PATH_NOT_FOUND or ERROR_INVALID_PARAMETER, got %08lx\n", GLE);
- if (!GetTempFileNameW(szDot, szPrefix, 0, filename)) + if (!GetTempFileNameW(L".", L"cer", 0, filename)) return; DeleteFileW(filename);
@@ -1769,7 +1708,7 @@ static void testFileNameStore(void) } DeleteFileW(filename);
- if (!GetTempFileNameW(szDot, spcPrefix, 0, filename)) + if (!GetTempFileNameW(L".", L"spc", 0, filename)) return; DeleteFileW(filename);
@@ -2047,14 +1986,14 @@ static void testCertOpenSystemStore(void) /* This succeeds, and on WinXP at least, the Bogus key is created under * HKCU (but not under HKLM, even when run as an administrator.) */ - store = CertOpenSystemStoreW(0, BogusW); + store = CertOpenSystemStoreW(0, L"Bogus"); ok(store != 0, "CertOpenSystemStore failed: %08lx\n", GetLastError()); if (store) CertCloseStore(store, 0); /* Delete it so other tests succeed next time around */ CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_DELETE_FLAG, BogusW); - RegDeleteKeyW(HKEY_CURRENT_USER, BogusPathW); + CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_DELETE_FLAG, L"Bogus"); + RegDeleteKeyW(HKEY_CURRENT_USER, L"Software\Microsoft\SystemCertificates\Bogus"); }
static const struct @@ -2077,13 +2016,12 @@ static void testCertRegisterSystemStore(void) BOOL ret, cur_flag; DWORD err = 0; HCERTSTORE hstore; - static const WCHAR WineTestW[] = {'W','i','n','e','T','e','s','t',0}; const CERT_CONTEXT *cert, *cert2; unsigned int i;
for (i = 0; i < ARRAY_SIZE(reg_system_store_test_data); i++) { cur_flag = reg_system_store_test_data[i].cert_store; - ret = CertRegisterSystemStore(WineTestW, cur_flag, NULL, NULL); + ret = CertRegisterSystemStore(L"WineTest", cur_flag, NULL, NULL); if (!ret) { err = GetLastError(); @@ -2102,7 +2040,7 @@ static void testCertRegisterSystemStore(void) continue; }
- hstore = CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, 0, CERT_STORE_OPEN_EXISTING_FLAG | cur_flag, WineTestW); + hstore = CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, 0, CERT_STORE_OPEN_EXISTING_FLAG | cur_flag, L"WineTest"); ok (hstore != NULL, "Opening just registered store at %08x failed, last error %lx\n", cur_flag, GetLastError());
cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert)); @@ -2125,7 +2063,7 @@ static void testCertRegisterSystemStore(void) ret = CertCloseStore(hstore, 0); ok (ret, "CertCloseStore failed at %08x, last error %lx\n", cur_flag, GetLastError());
- ret = CertUnregisterSystemStore(WineTestW, cur_flag ); + ret = CertUnregisterSystemStore(L"WineTest", cur_flag ); todo_wine_if (reg_system_store_test_data[i].todo) ok( ret == reg_system_store_test_data[i].expected, "Unregistering failed at %08x, last error %ld\n", cur_flag, GetLastError()); @@ -2238,7 +2176,7 @@ static void testStoreProperty(void) CertCloseStore(store, 0);
/* Recheck on the My store.. */ - store = CertOpenSystemStoreW(0, MyW); + store = CertOpenSystemStoreW(0, L"My"); size = sizeof(state); ret = CertGetStoreProperty(store, CERT_ACCESS_STATE_PROP_ID, &state, &size); ok(ret, "CertGetStoreProperty failed for CERT_ACCESS_STATE_PROP_ID: %08lx\n", @@ -2452,16 +2390,13 @@ static const BYTE serializedStoreWithCertAndHash[] = { static void delete_test_key(void) { HKEY root_key, test_key; - static const WCHAR SysCertW[] = {'S','o','f','t','w','a','r','e','\','M','i','c','r','o','s','o','f','t','\', - 'S','y','s','t','e','m','C','e','r','t','i','f','i','c','a','t','e','s',0}; - static const WCHAR WineTestW[] = {'W','i','n','e','T','e','s','t',0}; WCHAR subkey_name[32]; DWORD num_subkeys, subkey_name_len; int idx;
- if (RegOpenKeyExW(HKEY_CURRENT_USER, SysCertW, 0, KEY_READ, &root_key)) + if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\Microsoft\SystemCertificates", 0, KEY_READ, &root_key)) return; - if (RegOpenKeyExW(root_key, WineTestW, 0, KEY_READ, &test_key)) + if (RegOpenKeyExW(root_key, L"WineTest", 0, KEY_READ, &test_key)) { RegCloseKey(root_key); return; @@ -2474,7 +2409,7 @@ static void delete_test_key(void) RegDeleteKeyW(test_key, subkey_name); } RegCloseKey(test_key); - RegDeleteKeyW(root_key, WineTestW); + RegDeleteKeyW(root_key, L"WineTest"); RegCloseKey(root_key); }
@@ -2486,9 +2421,6 @@ static void testAddCertificateLink(void) DWORD size; LPBYTE buf; CERT_NAME_BLOB blob; - static const WCHAR szPrefix[] = { 'c','e','r',0 }; - static const WCHAR szDot[] = { '.',0 }; - static const WCHAR WineTestW[] = { 'W','i','n','e','T','e','s','t',0 }; WCHAR filename1[MAX_PATH], filename2[MAX_PATH]; HANDLE file;
@@ -2550,8 +2482,8 @@ static void testAddCertificateLink(void) HeapFree(GetProcessHeap(), 0, buf); } /* Set a friendly name on the source certificate... */ - blob.pbData = (LPBYTE)WineTestW; - blob.cbData = sizeof(WineTestW); + blob.pbData = (LPBYTE)L"WineTest"; + blob.cbData = sizeof(L"WineTest"); ret = CertSetCertificateContextProperty(source, CERT_FRIENDLY_NAME_PROP_ID, 0, &blob); ok(ret, "CertSetCertificateContextProperty failed: %08lx\n", @@ -2568,7 +2500,7 @@ static void testAddCertificateLink(void) CERT_FRIENDLY_NAME_PROP_ID, buf, &size); ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError()); - ok(!lstrcmpW((LPCWSTR)buf, WineTestW), + ok(!lstrcmpW((LPCWSTR)buf, L"WineTest"), "unexpected friendly name\n"); HeapFree(GetProcessHeap(), 0, buf); } @@ -2580,7 +2512,7 @@ static void testAddCertificateLink(void) /* Test adding a cert to a file store, committing the change to the store, * and creating a link to the resulting cert. */ - if (!GetTempFileNameW(szDot, szPrefix, 0, filename1)) + if (!GetTempFileNameW(L".", L"cer", 0, filename1)) return;
DeleteFileW(filename1); @@ -2625,8 +2557,8 @@ static void testAddCertificateLink(void) HeapFree(GetProcessHeap(), 0, buf); } /* Set a friendly name on the source certificate... */ - blob.pbData = (LPBYTE)WineTestW; - blob.cbData = sizeof(WineTestW); + blob.pbData = (LPBYTE)L"WineTest"; + blob.cbData = sizeof(L"WineTest"); ret = CertSetCertificateContextProperty(source, CERT_FRIENDLY_NAME_PROP_ID, 0, &blob); ok(ret, "CertSetCertificateContextProperty failed: %08lx\n", @@ -2642,7 +2574,7 @@ static void testAddCertificateLink(void) ret = CertGetCertificateContextProperty(linked, CERT_FRIENDLY_NAME_PROP_ID, buf, &size); ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError()); - ok(!lstrcmpW((LPCWSTR)buf, WineTestW), + ok(!lstrcmpW((LPCWSTR)buf, L"WineTest"), "unexpected friendly name\n"); HeapFree(GetProcessHeap(), 0, buf); } @@ -2650,7 +2582,7 @@ static void testAddCertificateLink(void) } CertCloseStore(store2, 0);
- if (!GetTempFileNameW(szDot, szPrefix, 0, filename2)) + if (!GetTempFileNameW(L".", L"cer", 0, filename2)) return;
DeleteFileW(filename2); @@ -2719,7 +2651,7 @@ static void testAddCertificateLink(void) bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, &source); ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); - if (!GetTempFileNameW(szDot, szPrefix, 0, filename1)) + if (!GetTempFileNameW(L".", L"cer", 0, filename1)) return;
DeleteFileW(filename1); @@ -2754,7 +2686,7 @@ static void testAddCertificateLink(void) * in a system store. */ store2 = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER, WineTestW); + CERT_SYSTEM_STORE_CURRENT_USER, L"WineTest"); ok(store2 != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); ret = CertAddCertificateLinkToStore(store2, source, CERT_STORE_ADD_ALWAYS, &linked); diff --git a/dlls/crypt32/tests/str.c b/dlls/crypt32/tests/str.c index c99b5e35a91..6a19d264c14 100644 --- a/dlls/crypt32/tests/str.c +++ b/dlls/crypt32/tests/str.c @@ -129,61 +129,6 @@ static char subjectStrCRLF[] = "2.5.4.6=US\r\n2.5.4.8=Minnesota\r\n2.5.4.7=Minneapolis\r\n2.5.4.10=CodeWeavers\r\n2.5.4.11=Wine Development\r\n2.5.4.3=localhost\r\n1.2.840.113549.1.9.1=aric@codeweavers.com"; 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 WCHAR issuerStrW[] = { - 'U','S',',',' ','M','i','n','n','e','s','o','t','a',',',' ','M','i','n','n', - 'e','a','p','o','l','i','s',',',' ','C','o','d','e','W','e','a','v','e','r', - 's',',',' ','W','i','n','e',' ','D','e','v','e','l','o','p','m','e','n','t', - ',',' ','l','o','c','a','l','h','o','s','t',',',' ','a','r','i','c','@','c', - 'o','d','e','w','e','a','v','e','r','s','.','c','o','m',0 }; -static WCHAR issuerStrSemicolonW[] = { - 'U','S',';',' ','M','i','n','n','e','s','o','t','a',';',' ','M','i','n','n', - 'e','a','p','o','l','i','s',';',' ','C','o','d','e','W','e','a','v','e','r', - 's',';',' ','W','i','n','e',' ','D','e','v','e','l','o','p','m','e','n','t', - ';',' ','l','o','c','a','l','h','o','s','t',';',' ','a','r','i','c','@','c', - 'o','d','e','w','e','a','v','e','r','s','.','c','o','m',0 }; -static WCHAR issuerStrCRLFW[] = { - 'U','S','\r','\n','M','i','n','n','e','s','o','t','a','\r','\n','M','i','n', - 'n','e','a','p','o','l','i','s','\r','\n','C','o','d','e','W','e','a','v','e', - 'r','s','\r','\n','W','i','n','e',' ','D','e','v','e','l','o','p','m','e','n', - 't','\r','\n','l','o','c','a','l','h','o','s','t','\r','\n','a','r','i','c', - '@','c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',0 }; -static WCHAR subjectStrW[] = { - '2','.','5','.','4','.','6','=','U','S',',',' ','2','.','5','.','4','.','8', - '=','M','i','n','n','e','s','o','t','a',',',' ','2','.','5','.','4','.','7', - '=','M','i','n','n','e','a','p','o','l','i','s',',',' ','2','.','5','.','4', - '.','1','0','=','C','o','d','e','W','e','a','v','e','r','s',',',' ','2','.', - '5','.','4','.','1','1','=','W','i','n','e',' ','D','e','v','e','l','o','p', - 'm','e','n','t',',',' ','2','.','5','.','4','.','3','=','l','o','c','a','l', - 'h','o','s','t',',',' ','1','.','2','.','8','4','0','.','1','1','3','5','4', - '9','.','1','.','9','.','1','=','a','r','i','c','@','c','o','d','e','w','e', - 'a','v','e','r','s','.','c','o','m',0 }; -static WCHAR subjectStrSemicolonW[] = { - '2','.','5','.','4','.','6','=','U','S',';',' ','2','.','5','.','4','.','8', - '=','M','i','n','n','e','s','o','t','a',';',' ','2','.','5','.','4','.','7', - '=','M','i','n','n','e','a','p','o','l','i','s',';',' ','2','.','5','.','4', - '.','1','0','=','C','o','d','e','W','e','a','v','e','r','s',';',' ','2','.', - '5','.','4','.','1','1','=','W','i','n','e',' ','D','e','v','e','l','o','p', - 'm','e','n','t',';',' ','2','.','5','.','4','.','3','=','l','o','c','a','l', - 'h','o','s','t',';',' ','1','.','2','.','8','4','0','.','1','1','3','5','4', - '9','.','1','.','9','.','1','=','a','r','i','c','@','c','o','d','e','w','e', - 'a','v','e','r','s','.','c','o','m',0 }; -static WCHAR subjectStrCRLFW[] = { - '2','.','5','.','4','.','6','=','U','S','\r','\n','2','.','5','.','4','.','8', - '=','M','i','n','n','e','s','o','t','a','\r','\n','2','.','5','.','4','.','7', - '=','M','i','n','n','e','a','p','o','l','i','s','\r','\n','2','.','5','.','4', - '.','1','0','=','C','o','d','e','W','e','a','v','e','r','s','\r','\n','2','.', - '5','.','4','.','1','1','=','W','i','n','e',' ','D','e','v','e','l','o','p', - 'm','e','n','t','\r','\n','2','.','5','.','4','.','3','=','l','o','c','a','l', - 'h','o','s','t','\r','\n','1','.','2','.','8','4','0','.','1','1','3','5','4', - '9','.','1','.','9','.','1','=','a','r','i','c','@','c','o','d','e','w','e', - 'a','v','e','r','s','.','c','o','m',0 }; -static WCHAR x500SubjectStrSemicolonReverseW[] = { - 'E','=','a','r','i','c','@','c','o','d','e','w','e','a','v','e','r','s','.','c', - 'o','m',';',' ','C','N','=','l','o','c','a','l','h','o','s','t',';',' ','O','U', - '=','W','i','n','e',' ','D','e','v','e','l','o','p','m','e','n','t',';',' ','O', - '=','C','o','d','e','W','e','a','v','e','r','s',';',' ','L','=','M','i','n','n', - 'e','a','p','o','l','i','s',';',' ','S','=','M','i','n','n','e','s','o','t','a', - ';',' ','C','=','U','S',0 };
static HMODULE dll; static DWORD (WINAPI *pCertNameToStrA)(DWORD,LPVOID,DWORD,LPSTR,DWORD); @@ -274,55 +219,34 @@ static void test_CertRDNValueToStrA(void)
static void test_CertRDNValueToStrW(void) { - static const WCHAR usW[] = { 'U','S',0 }; - static const WCHAR minnesotaW[] = { 'M','i','n','n','e','s','o','t','a',0 }; - static const WCHAR minneapolisW[] = { 'M','i','n','n','e','a','p','o','l', - 'i','s',0 }; - static const WCHAR codeweaversW[] = { 'C','o','d','e','W','e','a','v','e', - 'r','s',0 }; - static const WCHAR wineDevW[] = { 'W','i','n','e',' ','D','e','v','e','l', - 'o','p','m','e','n','t',0 }; - static const WCHAR localhostW[] = { 'l','o','c','a','l','h','o','s','t',0 }; - static const WCHAR aricW[] = { 'a','r','i','c','@','c','o','d','e','w','e', - 'a','v','e','r','s','.','c','o','m',0 }; - static const WCHAR ePKIW[] = { 'e','P','K','I',' ','R','o','o','t',' ', - 'C','e','r','t','i','f','i','c','a','t','i','o','n',' ','A','u','t','h', - 'o','r','i','t','y',0 }; - static const WCHAR embeddedDoubleQuoteW[] = { 'a','b','c','"','d','e','f', - 0 }; - static const WCHAR embeddedSingleQuoteW[] = { 'a','b','c',''','d','e','f', - 0 }; - static const WCHAR embeddedCommaW[] = { 'a','b','c',',',' ','d','e','f',0 }; - static const WCHAR trailingAndEndingSpaceW[] = { ' ','a','b','c',' ',0 }; - static const WCHAR enclosingQuotesW[] = { '"','d','e','f','"',0 }; - static const WCHAR embeddedSemiW[] = { '1',';','3',0 }; + static const WCHAR ePKIW[] = L"ePKI Root Certification Authority"; CertRDNAttrEncodingW attrs[] = { { "2.5.4.6", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin1), bin1 }, usW, FALSE }, + { sizeof(bin1), bin1 }, L"US", FALSE }, { "2.5.4.8", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin2), bin2 }, minnesotaW, FALSE }, + { sizeof(bin2), bin2 }, L"Minnesota", FALSE }, { "2.5.4.7", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin3), bin3 }, minneapolisW, FALSE }, + { sizeof(bin3), bin3 }, L"Minneapolis", FALSE }, { "2.5.4.10", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin4), bin4 }, codeweaversW, FALSE }, + { sizeof(bin4), bin4 }, L"CodeWeavers", FALSE }, { "2.5.4.11", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin5), bin5 }, wineDevW, FALSE }, + { sizeof(bin5), bin5 }, L"Wine Development", FALSE }, { "2.5.4.3", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin6), bin6 }, localhostW, FALSE }, + { sizeof(bin6), bin6 }, L"localhost", FALSE }, { "1.2.840.113549.1.9.1", CERT_RDN_IA5_STRING, - { sizeof(bin7), bin7 }, aricW, FALSE }, + { sizeof(bin7), bin7 }, L"aric@codeweavers.com", FALSE }, { "0", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin9), bin9 }, embeddedDoubleQuoteW, FALSE }, + { sizeof(bin9), bin9 }, L"abc"def", FALSE }, { "0", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin10), bin10 }, embeddedSingleQuoteW, FALSE }, + { sizeof(bin10), bin10 }, L"abc'def", FALSE }, { "0", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin11), bin11 }, embeddedCommaW, FALSE }, + { sizeof(bin11), bin11 }, L"abc, def", FALSE }, { "0", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin12), bin12 }, trailingAndEndingSpaceW, FALSE }, + { sizeof(bin12), bin12 }, L" abc ", FALSE }, { "0", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin13), bin13 }, enclosingQuotesW, FALSE }, + { sizeof(bin13), bin13 }, L""def"", FALSE }, { "0", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin14), bin14 }, embeddedSemiW, FALSE }, + { sizeof(bin14), bin14 }, L"1;3", FALSE }, }; DWORD i, ret; WCHAR buffer[2000]; @@ -557,30 +481,6 @@ static void test_NameToStrConversionW(PCERT_NAME_BLOB pName, DWORD dwStrType, wine_dbgstr_w(expected), wine_dbgstr_w(buffer)); }
-static const WCHAR simpleCN_W[] = { 'C','N','=','1',0 }; -static const WCHAR singledQuotedCN_W[] = { 'C','N','=',''','1',''',0 }; -static const WCHAR simpleSingleQuotedCN_W[] = { ''','1',''',0 }; -static const WCHAR spacedCN_W[] = { 'C','N','=','"',' ','1',' ','"',0 }; -static const WCHAR simpleSpacedCN_W[] = { '"',' ','1',' ','"',0 }; -static const WCHAR quotedCN_W[] = { 'C','N','=','"','"','"','1','"','"','"',0 }; -static const WCHAR simpleQuotedCN_W[] = { '"','"','"','1','"','"','"',0 }; -static const WCHAR multipleAttrCN_W[] = { 'C','N','=','"','1','+','2','"',0 }; -static const WCHAR simpleMultipleAttrCN_W[] = { '"','1','+','2','"',0 }; -static const WCHAR commaCN_W[] = { 'C','N','=','"','a',',','b','"',0 }; -static const WCHAR simpleCommaCN_W[] = { '"','a',',','b','"',0 }; -static const WCHAR equalCN_W[] = { 'C','N','=','"','a','=','b','"',0 }; -static const WCHAR simpleEqualCN_W[] = { '"','a','=','b','"',0 }; -static const WCHAR lessThanCN_W[] = { 'C','N','=','"','<','"',0 }; -static const WCHAR simpleLessThanCN_W[] = { '"','<','"',0 }; -static const WCHAR greaterThanCN_W[] = { 'C','N','=','"','>','"',0 }; -static const WCHAR simpleGreaterThanCN_W[] = { '"','>','"',0 }; -static const WCHAR hashCN_W[] = { 'C','N','=','"','#','"',0 }; -static const WCHAR simpleHashCN_W[] = { '"','#','"',0 }; -static const WCHAR semiCN_W[] = { 'C','N','=','"',';','"',0 }; -static const WCHAR simpleSemiCN_W[] = { '"',';','"',0 }; -static const WCHAR newlineCN_W[] = { 'C','N','=','"','a','\n','b','"',0 }; -static const WCHAR simpleNewlineCN_W[] = { '"','a','\n','b','"',0 }; - static void test_CertNameToStrW(void) { PCCERT_CONTEXT context; @@ -617,88 +517,95 @@ static void test_CertNameToStrW(void) ret, GetLastError());
test_NameToStrConversionW(&context->pCertInfo->Issuer, - CERT_SIMPLE_NAME_STR, issuerStrW, FALSE); + CERT_SIMPLE_NAME_STR, + L"US, Minnesota, Minneapolis, CodeWeavers, Wine Development, localhost, aric@codeweavers.com", FALSE); test_NameToStrConversionW(&context->pCertInfo->Issuer, CERT_SIMPLE_NAME_STR | CERT_NAME_STR_SEMICOLON_FLAG, - issuerStrSemicolonW, FALSE); + L"US; Minnesota; Minneapolis; CodeWeavers; Wine Development; localhost; aric@codeweavers.com", FALSE); test_NameToStrConversionW(&context->pCertInfo->Issuer, CERT_SIMPLE_NAME_STR | CERT_NAME_STR_CRLF_FLAG, - issuerStrCRLFW, FALSE); + L"US\r\nMinnesota\r\nMinneapolis\r\nCodeWeavers\r\nWine Development\r\nlocalhost\r\naric@codeweavers.com", + FALSE); test_NameToStrConversionW(&context->pCertInfo->Subject, - CERT_OID_NAME_STR, subjectStrW, FALSE); + CERT_OID_NAME_STR, + L"2.5.4.6=US, 2.5.4.8=Minnesota, 2.5.4.7=Minneapolis, 2.5.4.10=CodeWeavers, 2.5.4.11=Wine Development," + " 2.5.4.3=localhost, 1.2.840.113549.1.9.1=aric@codeweavers.com", FALSE); test_NameToStrConversionW(&context->pCertInfo->Subject, CERT_OID_NAME_STR | CERT_NAME_STR_SEMICOLON_FLAG, - subjectStrSemicolonW, FALSE); + L"2.5.4.6=US; 2.5.4.8=Minnesota; 2.5.4.7=Minneapolis; 2.5.4.10=CodeWeavers; 2.5.4.11=Wine Development;" + " 2.5.4.3=localhost; 1.2.840.113549.1.9.1=aric@codeweavers.com", FALSE); test_NameToStrConversionW(&context->pCertInfo->Subject, CERT_OID_NAME_STR | CERT_NAME_STR_CRLF_FLAG, - subjectStrCRLFW, FALSE); + L"2.5.4.6=US\r\n2.5.4.8=Minnesota\r\n2.5.4.7=Minneapolis\r\n2.5.4.10=CodeWeavers\r\n2.5.4.11=Wine " + "Development\r\n2.5.4.3=localhost\r\n1.2.840.113549.1.9.1=aric@codeweavers.com", FALSE); test_NameToStrConversionW(&context->pCertInfo->Subject, CERT_X500_NAME_STR | CERT_NAME_STR_SEMICOLON_FLAG | CERT_NAME_STR_REVERSE_FLAG, - x500SubjectStrSemicolonReverseW, FALSE); + L"E=aric@codeweavers.com; CN=localhost; OU=Wine Development; O=CodeWeavers; L=Minneapolis; S=Minnesota; " + "C=US", FALSE);
CertFreeCertificateContext(context); } blob.pbData = encodedSimpleCN; blob.cbData = sizeof(encodedSimpleCN); - test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, simpleCN_W, FALSE); + test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=1", FALSE); blob.pbData = encodedSingleQuotedCN; blob.cbData = sizeof(encodedSingleQuotedCN); - test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, singledQuotedCN_W, + test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN='1'", FALSE); test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, - simpleSingleQuotedCN_W, FALSE); + L"'1'", FALSE); blob.pbData = encodedSpacedCN; blob.cbData = sizeof(encodedSpacedCN); - test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, spacedCN_W, FALSE); - test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, simpleSpacedCN_W, + test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=" 1 "", FALSE); + test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"" 1 "", FALSE); blob.pbData = encodedQuotedCN; blob.cbData = sizeof(encodedQuotedCN); - test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, quotedCN_W, + test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN="""1"""", FALSE); - test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, simpleQuotedCN_W, + test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L""""1"""", FALSE); blob.pbData = encodedMultipleAttrCN; blob.cbData = sizeof(encodedMultipleAttrCN); - test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, multipleAttrCN_W, + test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN="1+2"", FALSE); test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, - simpleMultipleAttrCN_W, FALSE); + L""1+2"", FALSE); blob.pbData = encodedCommaCN; blob.cbData = sizeof(encodedCommaCN); - test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, commaCN_W, FALSE); - test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, simpleCommaCN_W, + test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN="a,b"", FALSE); + test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L""a,b"", FALSE); blob.pbData = encodedEqualCN; blob.cbData = sizeof(encodedEqualCN); - test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, equalCN_W, FALSE); - test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, simpleEqualCN_W, + test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN="a=b"", FALSE); + test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L""a=b"", FALSE); blob.pbData = encodedLessThanCN; blob.cbData = sizeof(encodedLessThanCN); - test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, lessThanCN_W, FALSE); - test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, simpleLessThanCN_W, + test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN="<"", FALSE); + test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L""<"", FALSE); blob.pbData = encodedGreaterThanCN; blob.cbData = sizeof(encodedGreaterThanCN); - test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, greaterThanCN_W, + test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=">"", FALSE); test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, - simpleGreaterThanCN_W, FALSE); + L"">"", FALSE); blob.pbData = encodedHashCN; blob.cbData = sizeof(encodedHashCN); - test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, hashCN_W, FALSE); - test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, simpleHashCN_W, + test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN="#"", FALSE); + test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L""#"", FALSE); blob.pbData = encodedSemiCN; blob.cbData = sizeof(encodedSemiCN); - test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, semiCN_W, FALSE); - test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, simpleSemiCN_W, + test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=";"", FALSE); + test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"";"", FALSE); blob.pbData = encodedNewlineCN; blob.cbData = sizeof(encodedNewlineCN); - test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, newlineCN_W, FALSE); - test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, simpleNewlineCN_W, + test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN="a\nb"", FALSE); + test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L""a\nb"", FALSE); }
@@ -814,40 +721,30 @@ struct StrToNameW const BYTE *encoded; };
-static const WCHAR badlyQuotedCN_W[] = { 'C','N','=','"','"','1','"','"',0 }; -static const WCHAR simpleCN2_W[] = { 'C','N','=','"','1','"',0 }; -static const WCHAR simpleCN3_W[] = { 'C','N',' ','=',' ','"','1','"',0 }; -static const WCHAR japaneseCN_W[] = { 'C','N','=',0x226f,0x575b,0 }; -static const WCHAR dummyCN_W[] = { 'C','N','=','d','u','m','m','y',',','T','=','t','e','s','t',0 }; -static const WCHAR encodedFields_W[] = { ' ','C','N',' ','=',' ',' ',' ','W','i','n','e',' ','T', - 'e','s','t',',','T',' ','=',' ','1','2','3',',',' ','C', - ' ','=',' ','B','R',0 }; static const BYTE encodedJapaneseCN[] = { 0x30,0x0f,0x31,0x0d,0x30,0x0b,0x06, 0x03,0x55,0x04,0x03,0x1e,0x04,0x22,0x6f,0x57,0x5b };
static const struct StrToNameW namesW[] = { - { simpleCN_W, sizeof(encodedSimpleCN), encodedSimpleCN }, - { simpleCN2_W, sizeof(encodedSimpleCN), encodedSimpleCN }, - { simpleCN3_W, sizeof(encodedSimpleCN), encodedSimpleCN }, - { singledQuotedCN_W, sizeof(encodedSingleQuotedCN), encodedSingleQuotedCN }, - { spacedCN_W, sizeof(encodedSpacedCN), encodedSpacedCN }, - { quotedCN_W, sizeof(encodedQuotedCN), encodedQuotedCN }, - { multipleAttrCN_W, sizeof(encodedMultipleAttrCN), encodedMultipleAttrCN }, - { japaneseCN_W, sizeof(encodedJapaneseCN), encodedJapaneseCN }, - { commaCN_W, sizeof(encodedCommaCN), encodedCommaCN }, - { equalCN_W, sizeof(encodedEqualCN), encodedEqualCN }, - { lessThanCN_W, sizeof(encodedLessThanCN), encodedLessThanCN }, - { greaterThanCN_W, sizeof(encodedGreaterThanCN), encodedGreaterThanCN }, - { hashCN_W, sizeof(encodedHashCN), encodedHashCN }, - { semiCN_W, sizeof(encodedSemiCN), encodedSemiCN }, - { dummyCN_W, sizeof(encodedDummyCN), encodedDummyCN }, - { encodedFields_W, sizeof(encodedFields), encodedFields }, + { L"CN=1", sizeof(encodedSimpleCN), encodedSimpleCN }, + { L"CN="1"", sizeof(encodedSimpleCN), encodedSimpleCN }, + { L"CN = "1"", sizeof(encodedSimpleCN), encodedSimpleCN }, + { L"CN='1'", sizeof(encodedSingleQuotedCN), encodedSingleQuotedCN }, + { L"CN=" 1 "", sizeof(encodedSpacedCN), encodedSpacedCN }, + { L"CN="""1"""", sizeof(encodedQuotedCN), encodedQuotedCN }, + { L"CN="1+2"", sizeof(encodedMultipleAttrCN), encodedMultipleAttrCN }, + { L"CN=\x226f\x575b", sizeof(encodedJapaneseCN), encodedJapaneseCN }, + { L"CN="a,b"", sizeof(encodedCommaCN), encodedCommaCN }, + { L"CN="a=b"", sizeof(encodedEqualCN), encodedEqualCN }, + { L"CN="<"", sizeof(encodedLessThanCN), encodedLessThanCN }, + { L"CN=">"", sizeof(encodedGreaterThanCN), encodedGreaterThanCN }, + { L"CN="#"", sizeof(encodedHashCN), encodedHashCN }, + { L"CN=";"", sizeof(encodedSemiCN), encodedSemiCN }, + { L"CN=dummy,T=test", sizeof(encodedDummyCN), encodedDummyCN }, + { L" CN = Wine Test,T = 123, C = BR", sizeof(encodedFields), encodedFields }, };
static void test_CertStrToNameW(void) { - static const WCHAR bogusW[] = { 'b','o','g','u','s',0 }; - static const WCHAR fooW[] = { 'f','o','o','=','1',0 }; BOOL ret; DWORD size, i; LPCWSTR errorPtr; @@ -864,24 +761,24 @@ static void test_CertStrToNameW(void) */ ret = pCertStrToNameW(0, NULL, 0, NULL, NULL, &size, NULL); ok(!ret, "Expected failure\n"); - ret = pCertStrToNameW(0, bogusW, 0, NULL, NULL, &size, NULL); + ret = pCertStrToNameW(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, fooW, 0, NULL, NULL, &size, NULL); + ret = pCertStrToNameW(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, simpleCN_W, 0, NULL, NULL, &size, NULL); + ret = pCertStrToNameW(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, simpleCN_W, 0, NULL, NULL, &size, + ret = pCertStrToNameW(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, badlyQuotedCN_W, 0, NULL, buf, + ret = pCertStrToNameW(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, badlyQuotedCN_W, 0, NULL, buf, + ret = pCertStrToNameW(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());
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=111653
Your paranoid android.
=== w1064v1507 (64 bit report) ===
Report validation errors: crypt32:store crashed (c0000374)