Commit 6de2e83e authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

crypt32: Use ARRAY_SIZE macro.

parent 9e2415dd
...@@ -987,8 +987,7 @@ static BOOL container_matches_cert(PCCERT_CONTEXT pCert, LPCSTR container, ...@@ -987,8 +987,7 @@ static BOOL container_matches_cert(PCCERT_CONTEXT pCert, LPCSTR container,
WCHAR containerW[MAX_PATH]; WCHAR containerW[MAX_PATH];
BOOL matches; BOOL matches;
MultiByteToWideChar(CP_ACP, 0, container, -1, MultiByteToWideChar(CP_ACP, 0, container, -1, containerW, ARRAY_SIZE(containerW));
containerW, sizeof(containerW) / sizeof(containerW[0]));
/* We make a copy of the CRYPT_KEY_PROV_INFO because the caller expects /* We make a copy of the CRYPT_KEY_PROV_INFO because the caller expects
* keyProvInfo->pwszContainerName to be NULL or a heap-allocated container * keyProvInfo->pwszContainerName to be NULL or a heap-allocated container
* name. * name.
......
...@@ -146,9 +146,9 @@ HCERTCHAINENGINE CRYPT_CreateChainEngine(HCERTSTORE root, DWORD system_store, co ...@@ -146,9 +146,9 @@ HCERTCHAINENGINE CRYPT_CreateChainEngine(HCERTSTORE root, DWORD system_store, co
worldStores[2] = CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, 0, system_store, myW); worldStores[2] = CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, 0, system_store, myW);
worldStores[3] = CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, 0, system_store, trustW); worldStores[3] = CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, 0, system_store, trustW);
CRYPT_AddStoresToCollection(engine->hWorld, sizeof(worldStores) / sizeof(worldStores[0]), worldStores); CRYPT_AddStoresToCollection(engine->hWorld, ARRAY_SIZE(worldStores), worldStores);
CRYPT_AddStoresToCollection(engine->hWorld, config->cAdditionalStore, config->rghAdditionalStore); CRYPT_AddStoresToCollection(engine->hWorld, config->cAdditionalStore, config->rghAdditionalStore);
CRYPT_CloseStores(sizeof(worldStores) / sizeof(worldStores[0]), worldStores); CRYPT_CloseStores(ARRAY_SIZE(worldStores), worldStores);
engine->dwFlags = config->dwFlags; engine->dwFlags = config->dwFlags;
engine->dwUrlRetrievalTimeout = config->dwUrlRetrievalTimeout; engine->dwUrlRetrievalTimeout = config->dwUrlRetrievalTimeout;
...@@ -1688,11 +1688,9 @@ static LPCSTR filetime_to_str(const FILETIME *time) ...@@ -1688,11 +1688,9 @@ static LPCSTR filetime_to_str(const FILETIME *time)
if (!time) return "(null)"; if (!time) return "(null)";
GetLocaleInfoA(LOCALE_SYSTEM_DEFAULT, LOCALE_SSHORTDATE, dateFmt, GetLocaleInfoA(LOCALE_SYSTEM_DEFAULT, LOCALE_SSHORTDATE, dateFmt, ARRAY_SIZE(dateFmt));
sizeof(dateFmt) / sizeof(dateFmt[0]));
FileTimeToSystemTime(time, &sysTime); FileTimeToSystemTime(time, &sysTime);
GetDateFormatA(LOCALE_SYSTEM_DEFAULT, 0, &sysTime, dateFmt, date, GetDateFormatA(LOCALE_SYSTEM_DEFAULT, 0, &sysTime, dateFmt, date, ARRAY_SIZE(date));
sizeof(date) / sizeof(date[0]));
return wine_dbg_sprintf("%s", date); return wine_dbg_sprintf("%s", date);
} }
...@@ -3117,8 +3115,7 @@ static BOOL WINAPI verify_authenticode_policy(LPCSTR szPolicyOID, ...@@ -3117,8 +3115,7 @@ static BOOL WINAPI verify_authenticode_policy(LPCSTR szPolicyOID,
}; };
/* Check whether the root is an MS test root */ /* Check whether the root is an MS test root */
for (i = 0; !isMSTestRoot && i < sizeof(keyBlobs) / sizeof(keyBlobs[0]); for (i = 0; !isMSTestRoot && i < ARRAY_SIZE(keyBlobs); i++)
i++)
{ {
msPubKey.PublicKey.cbData = keyBlobs[i].cbData; msPubKey.PublicKey.cbData = keyBlobs[i].cbData;
msPubKey.PublicKey.pbData = keyBlobs[i].pbData; msPubKey.PublicKey.pbData = keyBlobs[i].pbData;
...@@ -3408,7 +3405,7 @@ static BOOL match_dns_to_subject_dn(PCCERT_CONTEXT cert, LPCWSTR server_name) ...@@ -3408,7 +3405,7 @@ static BOOL match_dns_to_subject_dn(PCCERT_CONTEXT cert, LPCWSTR server_name)
end = dot ? dot : ptr + strlenW(ptr); end = dot ? dot : ptr + strlenW(ptr);
len = end - ptr; len = end - ptr;
if (len >= sizeof(component) / sizeof(component[0])) if (len >= ARRAY_SIZE(component))
{ {
WARN_(chain)("domain component %s too long\n", WARN_(chain)("domain component %s too long\n",
debugstr_wn(ptr, len)); debugstr_wn(ptr, len));
...@@ -3690,8 +3687,7 @@ static BOOL WINAPI verify_ms_root_policy(LPCSTR szPolicyOID, ...@@ -3690,8 +3687,7 @@ static BOOL WINAPI verify_ms_root_policy(LPCSTR szPolicyOID,
PCCERT_CONTEXT root = PCCERT_CONTEXT root =
rootChain->rgpElement[rootChain->cElement - 1]->pCertContext; rootChain->rgpElement[rootChain->cElement - 1]->pCertContext;
for (i = 0; !isMSRoot && i < sizeof(keyBlobs) / sizeof(keyBlobs[0]); for (i = 0; !isMSRoot && i < ARRAY_SIZE(keyBlobs); i++)
i++)
{ {
msPubKey.PublicKey.cbData = keyBlobs[i].cbData; msPubKey.PublicKey.cbData = keyBlobs[i].cbData;
msPubKey.PublicKey.pbData = keyBlobs[i].pbData; msPubKey.PublicKey.pbData = keyBlobs[i].pbData;
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#include "wine/list.h" #include "wine/list.h"
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
/* a few asn.1 tags we need */ /* a few asn.1 tags we need */
#define ASN_BOOL (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x01) #define ASN_BOOL (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x01)
#define ASN_BITSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x03) #define ASN_BITSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x03)
......
...@@ -372,7 +372,7 @@ static BOOL WINAPI CRYPT_AsnEncodeValidity(DWORD dwCertEncodingType, ...@@ -372,7 +372,7 @@ static BOOL WINAPI CRYPT_AsnEncodeValidity(DWORD dwCertEncodingType,
}; };
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded, ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded,
pcbEncoded); pcbEncoded);
return ret; return ret;
} }
...@@ -400,7 +400,7 @@ static BOOL WINAPI CRYPT_AsnEncodeAlgorithmIdWithNullParams( ...@@ -400,7 +400,7 @@ static BOOL WINAPI CRYPT_AsnEncodeAlgorithmIdWithNullParams(
else else
items[1].pvStructInfo = &nullBlob; items[1].pvStructInfo = &nullBlob;
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded, ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded,
pcbEncoded); pcbEncoded);
return ret; return ret;
} }
...@@ -417,7 +417,7 @@ static BOOL WINAPI CRYPT_AsnEncodeAlgorithmId(DWORD dwCertEncodingType, ...@@ -417,7 +417,7 @@ static BOOL WINAPI CRYPT_AsnEncodeAlgorithmId(DWORD dwCertEncodingType,
}; };
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded, ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded,
pcbEncoded); pcbEncoded);
return ret; return ret;
} }
...@@ -439,7 +439,7 @@ static BOOL WINAPI CRYPT_AsnEncodePubKeyInfo(DWORD dwCertEncodingType, ...@@ -439,7 +439,7 @@ static BOOL WINAPI CRYPT_AsnEncodePubKeyInfo(DWORD dwCertEncodingType,
TRACE("Encoding public key with OID %s\n", TRACE("Encoding public key with OID %s\n",
debugstr_a(info->Algorithm.pszObjId)); debugstr_a(info->Algorithm.pszObjId));
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded, ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded,
pcbEncoded); pcbEncoded);
} }
__EXCEPT_PAGE_FAULT __EXCEPT_PAGE_FAULT
...@@ -469,7 +469,7 @@ static BOOL WINAPI CRYPT_AsnEncodeCert(DWORD dwCertEncodingType, ...@@ -469,7 +469,7 @@ static BOOL WINAPI CRYPT_AsnEncodeCert(DWORD dwCertEncodingType,
if (dwFlags & CRYPT_ENCODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG) if (dwFlags & CRYPT_ENCODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG)
items[2].encodeFunc = CRYPT_AsnEncodeBits; items[2].encodeFunc = CRYPT_AsnEncodeBits;
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded, ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded,
pcbEncoded); pcbEncoded);
} }
__EXCEPT_PAGE_FAULT __EXCEPT_PAGE_FAULT
...@@ -495,7 +495,7 @@ BOOL WINAPI CRYPT_AsnEncodePubKeyInfoNoNull(DWORD dwCertEncodingType, ...@@ -495,7 +495,7 @@ BOOL WINAPI CRYPT_AsnEncodePubKeyInfoNoNull(DWORD dwCertEncodingType,
TRACE("Encoding public key with OID %s\n", TRACE("Encoding public key with OID %s\n",
debugstr_a(info->Algorithm.pszObjId)); debugstr_a(info->Algorithm.pszObjId));
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded, ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded,
pcbEncoded); pcbEncoded);
return ret; return ret;
} }
...@@ -1530,7 +1530,7 @@ static BOOL CRYPT_AsnEncodeCTLEntry(const CTL_ENTRY *entry, ...@@ -1530,7 +1530,7 @@ static BOOL CRYPT_AsnEncodeCTLEntry(const CTL_ENTRY *entry,
BOOL ret; BOOL ret;
ret = CRYPT_AsnEncodeSequence(X509_ASN_ENCODING, items, ret = CRYPT_AsnEncodeSequence(X509_ASN_ENCODING, items,
sizeof(items) / sizeof(items[0]), 0, NULL, pbEncoded, pcbEncoded); ARRAY_SIZE(items), 0, NULL, pbEncoded, pcbEncoded);
return ret; return ret;
} }
...@@ -1679,7 +1679,7 @@ static BOOL CRYPT_AsnEncodeSMIMECapability(DWORD dwCertEncodingType, ...@@ -1679,7 +1679,7 @@ static BOOL CRYPT_AsnEncodeSMIMECapability(DWORD dwCertEncodingType,
}; };
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded, ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded,
pcbEncoded); pcbEncoded);
} }
} }
...@@ -1822,7 +1822,7 @@ static BOOL WINAPI CRYPT_AsnEncodeNoticeReference(DWORD dwCertEncodingType, ...@@ -1822,7 +1822,7 @@ static BOOL WINAPI CRYPT_AsnEncodeNoticeReference(DWORD dwCertEncodingType,
}; };
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded, ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded,
pcbEncoded); pcbEncoded);
return ret; return ret;
} }
...@@ -1887,7 +1887,7 @@ static BOOL WINAPI CRYPT_AsnEncodePKCSAttribute(DWORD dwCertEncodingType, ...@@ -1887,7 +1887,7 @@ static BOOL WINAPI CRYPT_AsnEncodePKCSAttribute(DWORD dwCertEncodingType,
}; };
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded, ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded,
pcbEncoded); pcbEncoded);
} }
} }
...@@ -1960,8 +1960,7 @@ BOOL CRYPT_AsnEncodePKCSDigestedData(const CRYPT_DIGESTED_DATA *digestedData, ...@@ -1960,8 +1960,7 @@ BOOL CRYPT_AsnEncodePKCSDigestedData(const CRYPT_DIGESTED_DATA *digestedData,
{ &digestedData->hash, CRYPT_AsnEncodeOctets, 0 }, { &digestedData->hash, CRYPT_AsnEncodeOctets, 0 },
}; };
return CRYPT_AsnEncodeSequence(X509_ASN_ENCODING, items, return CRYPT_AsnEncodeSequence(X509_ASN_ENCODING, items, ARRAY_SIZE(items), 0, NULL, pvData, pcbData);
sizeof(items) / sizeof(items[0]), 0, NULL, pvData, pcbData);
} }
static BOOL WINAPI CRYPT_AsnEncodePKCSContentInfo(DWORD dwCertEncodingType, static BOOL WINAPI CRYPT_AsnEncodePKCSContentInfo(DWORD dwCertEncodingType,
...@@ -2708,8 +2707,7 @@ static BOOL CRYPT_AsnEncodeAccessDescription( ...@@ -2708,8 +2707,7 @@ static BOOL CRYPT_AsnEncodeAccessDescription(
SetLastError(E_INVALIDARG); SetLastError(E_INVALIDARG);
return FALSE; return FALSE;
} }
return CRYPT_AsnEncodeSequence(X509_ASN_ENCODING, items, return CRYPT_AsnEncodeSequence(X509_ASN_ENCODING, items, ARRAY_SIZE(items), 0, NULL, pbEncoded, pcbEncoded);
sizeof(items) / sizeof(items[0]), 0, NULL, pbEncoded, pcbEncoded);
} }
static BOOL WINAPI CRYPT_AsnEncodeAuthorityInfoAccess(DWORD dwCertEncodingType, static BOOL WINAPI CRYPT_AsnEncodeAuthorityInfoAccess(DWORD dwCertEncodingType,
...@@ -2877,8 +2875,7 @@ static BOOL WINAPI CRYPT_AsnEncodeCertPolicyQualifiers(DWORD dwCertEncodingType, ...@@ -2877,8 +2875,7 @@ static BOOL WINAPI CRYPT_AsnEncodeCertPolicyQualifiers(DWORD dwCertEncodingType,
items[0].pvStructInfo = items[0].pvStructInfo =
info->rgPolicyQualifier[i].pszPolicyQualifierId; info->rgPolicyQualifier[i].pszPolicyQualifierId;
items[1].pvStructInfo = &info->rgPolicyQualifier[i].Qualifier; items[1].pvStructInfo = &info->rgPolicyQualifier[i].Qualifier;
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, ARRAY_SIZE(items),
sizeof(items) / sizeof(items[0]),
dwFlags & ~CRYPT_ENCODE_ALLOC_FLAG, NULL, NULL, &size); dwFlags & ~CRYPT_ENCODE_ALLOC_FLAG, NULL, NULL, &size);
if (ret) if (ret)
bytesNeeded += size; bytesNeeded += size;
...@@ -2909,8 +2906,7 @@ static BOOL WINAPI CRYPT_AsnEncodeCertPolicyQualifiers(DWORD dwCertEncodingType, ...@@ -2909,8 +2906,7 @@ static BOOL WINAPI CRYPT_AsnEncodeCertPolicyQualifiers(DWORD dwCertEncodingType,
items[1].pvStructInfo = items[1].pvStructInfo =
&info->rgPolicyQualifier[i].Qualifier; &info->rgPolicyQualifier[i].Qualifier;
size = bytesNeeded; size = bytesNeeded;
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, ARRAY_SIZE(items),
sizeof(items) / sizeof(items[0]),
dwFlags & ~CRYPT_ENCODE_ALLOC_FLAG, NULL, out, &size); dwFlags & ~CRYPT_ENCODE_ALLOC_FLAG, NULL, out, &size);
if (ret) if (ret)
{ {
...@@ -2942,8 +2938,7 @@ static BOOL CRYPT_AsnEncodeCertPolicy(DWORD dwCertEncodingType, ...@@ -2942,8 +2938,7 @@ static BOOL CRYPT_AsnEncodeCertPolicy(DWORD dwCertEncodingType,
SetLastError(E_INVALIDARG); SetLastError(E_INVALIDARG);
return FALSE; return FALSE;
} }
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, ARRAY_SIZE(items), dwFlags, NULL, pbEncoded, pcbEncoded);
sizeof(items) / sizeof(items[0]), dwFlags, NULL, pbEncoded, pcbEncoded);
return ret; return ret;
} }
...@@ -3026,8 +3021,7 @@ static BOOL CRYPT_AsnEncodeCertPolicyMapping(DWORD dwCertEncodingType, ...@@ -3026,8 +3021,7 @@ static BOOL CRYPT_AsnEncodeCertPolicyMapping(DWORD dwCertEncodingType,
SetLastError(E_INVALIDARG); SetLastError(E_INVALIDARG);
return FALSE; return FALSE;
} }
return CRYPT_AsnEncodeSequence(dwCertEncodingType, items, return CRYPT_AsnEncodeSequence(dwCertEncodingType, items, ARRAY_SIZE(items), dwFlags, NULL, pbEncoded, pcbEncoded);
sizeof(items) / sizeof(items[0]), dwFlags, NULL, pbEncoded, pcbEncoded);
} }
static BOOL WINAPI CRYPT_AsnEncodeCertPolicyMappings(DWORD dwCertEncodingType, static BOOL WINAPI CRYPT_AsnEncodeCertPolicyMappings(DWORD dwCertEncodingType,
...@@ -3169,8 +3163,7 @@ static BOOL WINAPI CRYPT_AsnEncodeRsaPubKey(DWORD dwCertEncodingType, ...@@ -3169,8 +3163,7 @@ static BOOL WINAPI CRYPT_AsnEncodeRsaPubKey(DWORD dwCertEncodingType,
}; };
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded, ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded, pcbEncoded);
pcbEncoded);
} }
} }
__EXCEPT_PAGE_FAULT __EXCEPT_PAGE_FAULT
...@@ -4151,8 +4144,7 @@ static BOOL WINAPI CRYPT_AsnEncodeIssuerSerialNumber( ...@@ -4151,8 +4144,7 @@ static BOOL WINAPI CRYPT_AsnEncodeIssuerSerialNumber(
}; };
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded, ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded, pcbEncoded);
pcbEncoded);
return ret; return ret;
} }
...@@ -4402,8 +4394,7 @@ static BOOL WINAPI CRYPT_AsnEncodeRecipientInfo(DWORD dwCertEncodingType, ...@@ -4402,8 +4394,7 @@ static BOOL WINAPI CRYPT_AsnEncodeRecipientInfo(DWORD dwCertEncodingType,
}; };
return CRYPT_AsnEncodeSequence(dwCertEncodingType, items, return CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded, ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded, pcbEncoded);
pcbEncoded);
} }
static BOOL WINAPI CRYPT_AsnEncodeEncryptedContentInfo(DWORD dwCertEncodingType, static BOOL WINAPI CRYPT_AsnEncodeEncryptedContentInfo(DWORD dwCertEncodingType,
...@@ -4421,8 +4412,7 @@ static BOOL WINAPI CRYPT_AsnEncodeEncryptedContentInfo(DWORD dwCertEncodingType, ...@@ -4421,8 +4412,7 @@ static BOOL WINAPI CRYPT_AsnEncodeEncryptedContentInfo(DWORD dwCertEncodingType,
}; };
return CRYPT_AsnEncodeSequence(dwCertEncodingType, items, return CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded, ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded, pcbEncoded);
pcbEncoded);
} }
BOOL CRYPT_AsnEncodePKCSEnvelopedData(const CRYPT_ENVELOPED_DATA *envelopedData, BOOL CRYPT_AsnEncodePKCSEnvelopedData(const CRYPT_ENVELOPED_DATA *envelopedData,
...@@ -4439,7 +4429,7 @@ BOOL CRYPT_AsnEncodePKCSEnvelopedData(const CRYPT_ENVELOPED_DATA *envelopedData, ...@@ -4439,7 +4429,7 @@ BOOL CRYPT_AsnEncodePKCSEnvelopedData(const CRYPT_ENVELOPED_DATA *envelopedData,
}; };
return CRYPT_AsnEncodeSequence(X509_ASN_ENCODING, items, return CRYPT_AsnEncodeSequence(X509_ASN_ENCODING, items,
sizeof(items) / sizeof(items[0]), 0, NULL, pvData, pcbData); ARRAY_SIZE(items), 0, NULL, pvData, pcbData);
} }
static CryptEncodeObjectExFunc CRYPT_GetBuiltinEncoder(DWORD dwCertEncodingType, static CryptEncodeObjectExFunc CRYPT_GetBuiltinEncoder(DWORD dwCertEncodingType,
......
...@@ -231,8 +231,7 @@ static WINECRYPT_CERTSTORE *CRYPT_CreateFileStore(DWORD dwFlags, ...@@ -231,8 +231,7 @@ static WINECRYPT_CERTSTORE *CRYPT_CreateFileStore(DWORD dwFlags,
info->type = type; info->type = type;
info->dirty = FALSE; info->dirty = FALSE;
provInfo.cbSize = sizeof(provInfo); provInfo.cbSize = sizeof(provInfo);
provInfo.cStoreProvFunc = sizeof(fileProvFuncs) / provInfo.cStoreProvFunc = ARRAY_SIZE(fileProvFuncs);
sizeof(fileProvFuncs[0]);
provInfo.rgpvStoreProvFunc = fileProvFuncs; provInfo.rgpvStoreProvFunc = fileProvFuncs;
provInfo.hStoreProv = info; provInfo.hStoreProv = info;
store = CRYPT_ProvCreateStore(dwFlags, memStore, &provInfo); store = CRYPT_ProvCreateStore(dwFlags, memStore, &provInfo);
......
...@@ -175,7 +175,7 @@ static BOOL CRYPT_EncodeDataContentInfoHeader(const CDataEncodeMsg *msg, ...@@ -175,7 +175,7 @@ static BOOL CRYPT_EncodeDataContentInfoHeader(const CDataEncodeMsg *msg,
}; };
ret = CRYPT_AsnEncodeSequence(X509_ASN_ENCODING, items, ret = CRYPT_AsnEncodeSequence(X509_ASN_ENCODING, items,
sizeof(items) / sizeof(items[0]), CRYPT_ENCODE_ALLOC_FLAG, NULL, ARRAY_SIZE(items), CRYPT_ENCODE_ALLOC_FLAG, NULL,
(LPBYTE)&header->pbData, &header->cbData); (LPBYTE)&header->pbData, &header->cbData);
if (ret) if (ret)
{ {
......
...@@ -69,7 +69,7 @@ static const WCHAR ADDRESSBOOK[] = {'A','D','D','R','E','S','S','B','O','O','K', ...@@ -69,7 +69,7 @@ static const WCHAR ADDRESSBOOK[] = {'A','D','D','R','E','S','S','B','O','O','K',
static const WCHAR TRUSTEDPUBLISHER[] = {'T','r','u','s','t','e','d','P','u','b','l','i','s','h','e','r',0}; static const WCHAR TRUSTEDPUBLISHER[] = {'T','r','u','s','t','e','d','P','u','b','l','i','s','h','e','r',0};
static const WCHAR DISALLOWED[] = {'D','i','s','a','l','l','o','w','e','d',0}; static const WCHAR DISALLOWED[] = {'D','i','s','a','l','l','o','w','e','d',0};
static const LPCWSTR LocalizedKeys[] = {ROOT,MY,CA,ADDRESSBOOK,TRUSTEDPUBLISHER,DISALLOWED}; static const LPCWSTR LocalizedKeys[] = {ROOT,MY,CA,ADDRESSBOOK,TRUSTEDPUBLISHER,DISALLOWED};
static WCHAR LocalizedNames[sizeof(LocalizedKeys)/sizeof(LocalizedKeys[0])][256]; static WCHAR LocalizedNames[ARRAY_SIZE(LocalizedKeys)][256];
static void free_function_sets(void) static void free_function_sets(void)
{ {
...@@ -1006,7 +1006,7 @@ static void oid_init_localizednames(void) ...@@ -1006,7 +1006,7 @@ static void oid_init_localizednames(void)
{ {
unsigned int i; unsigned int i;
for(i = 0; i < sizeof(LocalizedKeys)/sizeof(LPCWSTR); i++) for(i = 0; i < ARRAY_SIZE(LocalizedKeys); i++)
{ {
LoadStringW(hInstance, IDS_LOCALIZEDNAME_ROOT+i, LocalizedNames[i], 256); LoadStringW(hInstance, IDS_LOCALIZEDNAME_ROOT+i, LocalizedNames[i], 256);
} }
...@@ -1019,7 +1019,7 @@ LPCWSTR WINAPI CryptFindLocalizedName(LPCWSTR pwszCryptName) ...@@ -1019,7 +1019,7 @@ LPCWSTR WINAPI CryptFindLocalizedName(LPCWSTR pwszCryptName)
{ {
unsigned int i; unsigned int i;
for(i = 0; i < sizeof(LocalizedKeys)/sizeof(LPCWSTR); i++) for(i = 0; i < ARRAY_SIZE(LocalizedKeys); i++)
{ {
if(!lstrcmpiW(LocalizedKeys[i], pwszCryptName)) if(!lstrcmpiW(LocalizedKeys[i], pwszCryptName))
{ {
...@@ -1399,8 +1399,7 @@ static void init_oid_info(void) ...@@ -1399,8 +1399,7 @@ static void init_oid_info(void)
DWORD i; DWORD i;
oid_init_localizednames(); oid_init_localizednames();
for (i = 0; i < sizeof(oidInfoConstructors) / for (i = 0; i < ARRAY_SIZE(oidInfoConstructors); i++)
sizeof(oidInfoConstructors[0]); i++)
{ {
if (!IS_INTRESOURCE(oidInfoConstructors[i].pwszName)) if (!IS_INTRESOURCE(oidInfoConstructors[i].pwszName))
{ {
......
...@@ -71,7 +71,7 @@ static void CRYPT_RegReadSerializedFromReg(HKEY key, DWORD contextType, ...@@ -71,7 +71,7 @@ static void CRYPT_RegReadSerializedFromReg(HKEY key, DWORD contextType,
WCHAR subKeyName[MAX_PATH]; WCHAR subKeyName[MAX_PATH];
do { do {
DWORD size = sizeof(subKeyName) / sizeof(WCHAR); DWORD size = ARRAY_SIZE(subKeyName);
rc = RegEnumKeyExW(key, index++, subKeyName, &size, NULL, NULL, NULL, rc = RegEnumKeyExW(key, index++, subKeyName, &size, NULL, NULL, NULL,
NULL); NULL);
...@@ -163,7 +163,7 @@ static void CRYPT_RegReadFromReg(HKEY key, HCERTSTORE store) ...@@ -163,7 +163,7 @@ static void CRYPT_RegReadFromReg(HKEY key, HCERTSTORE store)
CERT_STORE_CRL_CONTEXT_FLAG, CERT_STORE_CTL_CONTEXT_FLAG }; CERT_STORE_CRL_CONTEXT_FLAG, CERT_STORE_CTL_CONTEXT_FLAG };
DWORD i; DWORD i;
for (i = 0; i < sizeof(subKeys) / sizeof(subKeys[0]); i++) for (i = 0; i < ARRAY_SIZE(subKeys); i++)
{ {
HKEY hKey; HKEY hKey;
LONG rc; LONG rc;
...@@ -255,7 +255,7 @@ static BOOL CRYPT_RegWriteToReg(WINE_REGSTOREINFO *store) ...@@ -255,7 +255,7 @@ static BOOL CRYPT_RegWriteToReg(WINE_REGSTOREINFO *store)
BOOL ret = TRUE; BOOL ret = TRUE;
DWORD i; DWORD i;
for (i = 0; ret && i < sizeof(subKeys) / sizeof(subKeys[0]); i++) for (i = 0; ret && i < ARRAY_SIZE(subKeys); i++)
{ {
HKEY key; HKEY key;
LONG rc = RegCreateKeyExW(store->key, subKeys[i], 0, NULL, 0, LONG rc = RegCreateKeyExW(store->key, subKeys[i], 0, NULL, 0,
...@@ -561,8 +561,7 @@ WINECRYPT_CERTSTORE *CRYPT_RegOpenStore(HCRYPTPROV hCryptProv, DWORD dwFlags, ...@@ -561,8 +561,7 @@ WINECRYPT_CERTSTORE *CRYPT_RegOpenStore(HCRYPTPROV hCryptProv, DWORD dwFlags,
CRYPT_RegReadFromReg(regInfo->key, regInfo->memStore); CRYPT_RegReadFromReg(regInfo->key, regInfo->memStore);
regInfo->dirty = FALSE; regInfo->dirty = FALSE;
provInfo.cbSize = sizeof(provInfo); provInfo.cbSize = sizeof(provInfo);
provInfo.cStoreProvFunc = sizeof(regProvFuncs) / provInfo.cStoreProvFunc = ARRAY_SIZE(regProvFuncs);
sizeof(regProvFuncs[0]);
provInfo.rgpvStoreProvFunc = regProvFuncs; provInfo.rgpvStoreProvFunc = regProvFuncs;
provInfo.hStoreProv = regInfo; provInfo.hStoreProv = regInfo;
store = CRYPT_ProvCreateStore(dwFlags, memStore, &provInfo); store = CRYPT_ProvCreateStore(dwFlags, memStore, &provInfo);
......
...@@ -780,7 +780,7 @@ static void add_ms_root_certs(HCERTSTORE to) ...@@ -780,7 +780,7 @@ static void add_ms_root_certs(HCERTSTORE to)
TRACE("\n"); TRACE("\n");
for (i = 0; i < sizeof(msRootCerts) / sizeof(msRootCerts[0]); i++) for (i = 0; i < ARRAY_SIZE(msRootCerts); i++)
if (!CertAddEncodedCertificateToStore(to, X509_ASN_ENCODING, if (!CertAddEncodedCertificateToStore(to, X509_ASN_ENCODING,
msRootCerts[i].pb, msRootCerts[i].cb, CERT_STORE_ADD_NEW, NULL)) msRootCerts[i].pb, msRootCerts[i].cb, CERT_STORE_ADD_NEW, NULL))
WARN("adding root cert %d failed: %08x\n", i, GetLastError()); WARN("adding root cert %d failed: %08x\n", i, GetLastError());
...@@ -830,9 +830,7 @@ static void read_trusted_roots_from_known_locations(HCERTSTORE store) ...@@ -830,9 +830,7 @@ static void read_trusted_roots_from_known_locations(HCERTSTORE store)
} }
#endif #endif
for (i = 0; !ret && for (i = 0; !ret && i < ARRAY_SIZE(CRYPT_knownLocations); i++)
i < sizeof(CRYPT_knownLocations) / sizeof(CRYPT_knownLocations[0]);
i++)
ret = import_certs_from_path(CRYPT_knownLocations[i], from, TRUE); ret = import_certs_from_path(CRYPT_knownLocations[i], from, TRUE);
check_and_store_certs(from, store); check_and_store_certs(from, store);
} }
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "winnls.h" #include "winnls.h"
#include "mssip.h" #include "mssip.h"
#include "winuser.h" #include "winuser.h"
#include "crypt32_private.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/list.h" #include "wine/list.h"
...@@ -440,7 +441,7 @@ BOOL WINAPI CryptSIPRetrieveSubjectGuid ...@@ -440,7 +441,7 @@ BOOL WINAPI CryptSIPRetrieveSubjectGuid
WCHAR subKeyName[MAX_PATH]; WCHAR subKeyName[MAX_PATH];
do { do {
size = sizeof(subKeyName) / sizeof(subKeyName[0]); size = ARRAY_SIZE(subKeyName);
r = RegEnumKeyExW(key, index++, subKeyName, &size, NULL, NULL, r = RegEnumKeyExW(key, index++, subKeyName, &size, NULL, NULL,
NULL, NULL); NULL, NULL);
if (r == ERROR_SUCCESS) if (r == ERROR_SUCCESS)
...@@ -478,7 +479,7 @@ BOOL WINAPI CryptSIPRetrieveSubjectGuid ...@@ -478,7 +479,7 @@ BOOL WINAPI CryptSIPRetrieveSubjectGuid
WCHAR subKeyName[MAX_PATH]; WCHAR subKeyName[MAX_PATH];
do { do {
size = sizeof(subKeyName) / sizeof(subKeyName[0]); size = ARRAY_SIZE(subKeyName);
r = RegEnumKeyExW(key, index++, subKeyName, &size, NULL, NULL, r = RegEnumKeyExW(key, index++, subKeyName, &size, NULL, NULL,
NULL, NULL); NULL, NULL);
if (r == ERROR_SUCCESS) if (r == ERROR_SUCCESS)
......
...@@ -124,7 +124,7 @@ BOOL WINAPI I_CertUpdateStore(HCERTSTORE store1, HCERTSTORE store2, DWORD unk0, ...@@ -124,7 +124,7 @@ BOOL WINAPI I_CertUpdateStore(HCERTSTORE store1, HCERTSTORE store2, DWORD unk0,
/* Poor-man's resync: empty first store, then add everything from second /* Poor-man's resync: empty first store, then add everything from second
* store to it. * store to it.
*/ */
for (i = 0; i < sizeof(interfaces) / sizeof(interfaces[0]); i++) for (i = 0; i < ARRAY_SIZE(interfaces); i++)
{ {
const void *context; const void *context;
...@@ -717,8 +717,7 @@ static WINECRYPT_CERTSTORE *CRYPT_MsgOpenStore(HCRYPTPROV hCryptProv, ...@@ -717,8 +717,7 @@ static WINECRYPT_CERTSTORE *CRYPT_MsgOpenStore(HCRYPTPROV hCryptProv,
CERT_STORE_PROV_INFO provInfo = { 0 }; CERT_STORE_PROV_INFO provInfo = { 0 };
provInfo.cbSize = sizeof(provInfo); provInfo.cbSize = sizeof(provInfo);
provInfo.cStoreProvFunc = sizeof(msgProvFuncs) / provInfo.cStoreProvFunc = ARRAY_SIZE(msgProvFuncs);
sizeof(msgProvFuncs[0]);
provInfo.rgpvStoreProvFunc = msgProvFuncs; provInfo.rgpvStoreProvFunc = msgProvFuncs;
provInfo.hStoreProv = CryptMsgDuplicate(msg); provInfo.hStoreProv = CryptMsgDuplicate(msg);
store = CRYPT_ProvCreateStore(dwFlags, memStore, &provInfo); store = CRYPT_ProvCreateStore(dwFlags, memStore, &provInfo);
...@@ -1338,7 +1337,7 @@ BOOL WINAPI CertEnumSystemStore(DWORD dwFlags, void *pvSystemStoreLocationPara, ...@@ -1338,7 +1337,7 @@ BOOL WINAPI CertEnumSystemStore(DWORD dwFlags, void *pvSystemStoreLocationPara,
ret = TRUE; ret = TRUE;
do { do {
WCHAR name[MAX_PATH]; WCHAR name[MAX_PATH];
DWORD size = sizeof(name) / sizeof(name[0]); DWORD size = ARRAY_SIZE(name);
rc = RegEnumKeyExW(key, index++, name, &size, NULL, NULL, NULL, rc = RegEnumKeyExW(key, index++, name, &size, NULL, NULL, NULL,
NULL); NULL);
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "wincrypt.h" #include "wincrypt.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/unicode.h" #include "wine/unicode.h"
#include "crypt32_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(crypt); WINE_DEFAULT_DEBUG_CHANNEL(crypt);
...@@ -775,7 +776,7 @@ struct KeynameKeeper ...@@ -775,7 +776,7 @@ struct KeynameKeeper
static void CRYPT_InitializeKeynameKeeper(struct KeynameKeeper *keeper) static void CRYPT_InitializeKeynameKeeper(struct KeynameKeeper *keeper)
{ {
keeper->keyName = keeper->buf; keeper->keyName = keeper->buf;
keeper->keyLen = sizeof(keeper->buf) / sizeof(keeper->buf[0]); keeper->keyLen = ARRAY_SIZE(keeper->buf);
} }
static void CRYPT_FreeKeynameKeeper(struct KeynameKeeper *keeper) static void CRYPT_FreeKeynameKeeper(struct KeynameKeeper *keeper)
...@@ -1326,8 +1327,7 @@ DWORD WINAPI CertGetNameStringW(PCCERT_CONTEXT pCertContext, DWORD dwType, ...@@ -1326,8 +1327,7 @@ DWORD WINAPI CertGetNameStringW(PCCERT_CONTEXT pCertContext, DWORD dwType,
{ {
PCERT_RDN_ATTR nameAttr = NULL; PCERT_RDN_ATTR nameAttr = NULL;
for (i = 0; !nameAttr && i < sizeof(simpleAttributeOIDs) / for (i = 0; !nameAttr && i < ARRAY_SIZE(simpleAttributeOIDs); i++)
sizeof(simpleAttributeOIDs[0]); i++)
nameAttr = CertFindRDNAttr(simpleAttributeOIDs[i], nameInfo); nameAttr = CertFindRDNAttr(simpleAttributeOIDs[i], nameInfo);
if (nameAttr) if (nameAttr)
ret = CertRDNValueToStrW(nameAttr->dwValueType, ret = CertRDNValueToStrW(nameAttr->dwValueType,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment