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)
......
...@@ -890,7 +890,7 @@ static BOOL WINAPI CRYPT_AsnDecodeCertSignedContent(DWORD dwCertEncodingType, ...@@ -890,7 +890,7 @@ static BOOL WINAPI CRYPT_AsnDecodeCertSignedContent(DWORD dwCertEncodingType,
if (dwFlags & CRYPT_DECODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG) if (dwFlags & CRYPT_DECODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG)
items[2].decodeFunc = CRYPT_AsnDecodeBitsInternal; items[2].decodeFunc = CRYPT_AsnDecodeBitsInternal;
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo,
pcbStructInfo, NULL, NULL); pcbStructInfo, NULL, NULL);
} }
...@@ -935,7 +935,7 @@ static BOOL CRYPT_AsnDecodeValidity(const BYTE *pbEncoded, DWORD cbEncoded, ...@@ -935,7 +935,7 @@ static BOOL CRYPT_AsnDecodeValidity(const BYTE *pbEncoded, DWORD cbEncoded,
CRYPT_AsnDecodeChoiceOfTimeInternal, sizeof(FILETIME), FALSE, FALSE, 0 }, CRYPT_AsnDecodeChoiceOfTimeInternal, sizeof(FILETIME), FALSE, FALSE, 0 },
}; };
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo, pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, NULL); pcbDecoded, NULL);
return ret; return ret;
...@@ -1020,7 +1020,7 @@ static BOOL CRYPT_AsnDecodeCertInfo(DWORD dwCertEncodingType, ...@@ -1020,7 +1020,7 @@ static BOOL CRYPT_AsnDecodeCertInfo(DWORD dwCertEncodingType,
TRACE("%p, %d, %08x, %p, %p, %d\n", pbEncoded, cbEncoded, dwFlags, TRACE("%p, %d, %08x, %p, %p, %d\n", pbEncoded, cbEncoded, dwFlags,
pDecodePara, pvStructInfo, *pcbStructInfo); pDecodePara, pvStructInfo, *pcbStructInfo);
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pcbStructInfo, pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pcbStructInfo,
NULL, NULL); NULL, NULL);
if (ret && pvStructInfo) if (ret && pvStructInfo)
...@@ -1135,7 +1135,7 @@ static BOOL CRYPT_AsnDecodeCRLEntry(const BYTE *pbEncoded, DWORD cbEncoded, ...@@ -1135,7 +1135,7 @@ static BOOL CRYPT_AsnDecodeCRLEntry(const BYTE *pbEncoded, DWORD cbEncoded,
TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags, entry, TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags, entry,
*pcbStructInfo); *pcbStructInfo);
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, entry, pcbStructInfo, pcbDecoded, pbEncoded, cbEncoded, dwFlags, NULL, entry, pcbStructInfo, pcbDecoded,
entry ? entry->SerialNumber.pbData : NULL); entry ? entry->SerialNumber.pbData : NULL);
if (ret && entry && !entry->SerialNumber.cbData) if (ret && entry && !entry->SerialNumber.cbData)
...@@ -1236,9 +1236,8 @@ static BOOL CRYPT_AsnDecodeCRLInfo(DWORD dwCertEncodingType, ...@@ -1236,9 +1236,8 @@ static BOOL CRYPT_AsnDecodeCRLInfo(DWORD dwCertEncodingType,
TRACE("%p, %d, %08x, %p, %p, %d\n", pbEncoded, cbEncoded, dwFlags, TRACE("%p, %d, %08x, %p, %p, %d\n", pbEncoded, cbEncoded, dwFlags,
pDecodePara, pvStructInfo, *pcbStructInfo); pDecodePara, pvStructInfo, *pcbStructInfo);
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items), pbEncoded, cbEncoded, dwFlags,
pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pcbStructInfo, pDecodePara, pvStructInfo, pcbStructInfo, NULL, NULL);
NULL, NULL);
TRACE("Returning %d (%08x)\n", ret, GetLastError()); TRACE("Returning %d (%08x)\n", ret, GetLastError());
return ret; return ret;
...@@ -1433,7 +1432,7 @@ static BOOL CRYPT_AsnDecodeExtension(const BYTE *pbEncoded, DWORD cbEncoded, ...@@ -1433,7 +1432,7 @@ static BOOL CRYPT_AsnDecodeExtension(const BYTE *pbEncoded, DWORD cbEncoded,
if (ext) if (ext)
TRACE("ext->pszObjId is %p\n", ext->pszObjId); TRACE("ext->pszObjId is %p\n", ext->pszObjId);
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, ext, pcbStructInfo, pbEncoded, cbEncoded, dwFlags, NULL, ext, pcbStructInfo,
pcbDecoded, ext ? ext->pszObjId : NULL); pcbDecoded, ext ? ext->pszObjId : NULL);
if (ext) if (ext)
...@@ -1871,7 +1870,7 @@ static BOOL CRYPT_AsnDecodeRdnAttr(const BYTE *pbEncoded, DWORD cbEncoded, ...@@ -1871,7 +1870,7 @@ static BOOL CRYPT_AsnDecodeRdnAttr(const BYTE *pbEncoded, DWORD cbEncoded,
if (attr) if (attr)
TRACE("attr->pszObjId is %p\n", attr->pszObjId); TRACE("attr->pszObjId is %p\n", attr->pszObjId);
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, attr, pcbStructInfo, pcbDecoded, pbEncoded, cbEncoded, dwFlags, NULL, attr, pcbStructInfo, pcbDecoded,
attr ? attr->pszObjId : NULL); attr ? attr->pszObjId : NULL);
if (attr) if (attr)
...@@ -1968,7 +1967,7 @@ static BOOL CRYPT_AsnDecodeUnicodeRdnAttr(const BYTE *pbEncoded, ...@@ -1968,7 +1967,7 @@ static BOOL CRYPT_AsnDecodeUnicodeRdnAttr(const BYTE *pbEncoded,
if (attr) if (attr)
TRACE("attr->pszObjId is %p\n", attr->pszObjId); TRACE("attr->pszObjId is %p\n", attr->pszObjId);
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, attr, pcbStructInfo, pcbDecoded, pbEncoded, cbEncoded, dwFlags, NULL, attr, pcbStructInfo, pcbDecoded,
attr ? attr->pszObjId : NULL); attr ? attr->pszObjId : NULL);
if (attr) if (attr)
...@@ -2197,7 +2196,7 @@ static BOOL CRYPT_AsnDecodeCTLEntry(const BYTE *pbEncoded, DWORD cbEncoded, ...@@ -2197,7 +2196,7 @@ static BOOL CRYPT_AsnDecodeCTLEntry(const BYTE *pbEncoded, DWORD cbEncoded,
TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags, entry, TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags, entry,
*pcbStructInfo); *pcbStructInfo);
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, entry, pcbStructInfo, pbEncoded, cbEncoded, dwFlags, NULL, entry, pcbStructInfo,
pcbDecoded, entry ? entry->SubjectIdentifier.pbData : NULL); pcbDecoded, entry ? entry->SubjectIdentifier.pbData : NULL);
return ret; return ret;
...@@ -2300,7 +2299,7 @@ static BOOL WINAPI CRYPT_AsnDecodeCTL(DWORD dwCertEncodingType, ...@@ -2300,7 +2299,7 @@ static BOOL WINAPI CRYPT_AsnDecodeCTL(DWORD dwCertEncodingType,
TRUE, TRUE, offsetof(CTL_INFO, rgExtension), 0 }, TRUE, TRUE, offsetof(CTL_INFO, rgExtension), 0 },
}; };
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo,
pcbStructInfo, NULL, NULL); pcbStructInfo, NULL, NULL);
} }
...@@ -2330,7 +2329,7 @@ static BOOL CRYPT_AsnDecodeSMIMECapability(const BYTE *pbEncoded, ...@@ -2330,7 +2329,7 @@ static BOOL CRYPT_AsnDecodeSMIMECapability(const BYTE *pbEncoded,
TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags, TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, *pcbStructInfo); pvStructInfo, *pcbStructInfo);
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo, pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, capability ? capability->pszObjId : NULL); pcbDecoded, capability ? capability->pszObjId : NULL);
TRACE("returning %d\n", ret); TRACE("returning %d\n", ret);
...@@ -2460,7 +2459,7 @@ static BOOL CRYPT_AsnDecodeNoticeReference(const BYTE *pbEncoded, ...@@ -2460,7 +2459,7 @@ static BOOL CRYPT_AsnDecodeNoticeReference(const BYTE *pbEncoded,
TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags, TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, pvStructInfo ? *pcbStructInfo : 0); pvStructInfo, pvStructInfo ? *pcbStructInfo : 0);
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, NULL, &bytesNeeded, pcbDecoded, pbEncoded, cbEncoded, dwFlags, NULL, NULL, &bytesNeeded, pcbDecoded,
NULL); NULL);
if (ret) if (ret)
...@@ -2496,10 +2495,8 @@ static BOOL CRYPT_AsnDecodeNoticeReference(const BYTE *pbEncoded, ...@@ -2496,10 +2495,8 @@ static BOOL CRYPT_AsnDecodeNoticeReference(const BYTE *pbEncoded,
*(PCERT_POLICY_QUALIFIER_NOTICE_REFERENCE *)pvStructInfo; *(PCERT_POLICY_QUALIFIER_NOTICE_REFERENCE *)pvStructInfo;
noticeRef->pszOrganization = (LPSTR)((LPBYTE)noticeRef + noticeRef->pszOrganization = (LPSTR)((LPBYTE)noticeRef +
sizeof(CERT_POLICY_QUALIFIER_NOTICE_REFERENCE)); sizeof(CERT_POLICY_QUALIFIER_NOTICE_REFERENCE));
ret = CRYPT_AsnDecodeSequence(items, ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items), pbEncoded, cbEncoded, dwFlags,
sizeof(items) / sizeof(items[0]), pbEncoded, cbEncoded, dwFlags, NULL, noticeRef, &bytesNeeded, pcbDecoded, noticeRef->pszOrganization);
NULL, noticeRef, &bytesNeeded, pcbDecoded,
noticeRef->pszOrganization);
} }
} }
TRACE("returning %d\n", ret); TRACE("returning %d\n", ret);
...@@ -2653,7 +2650,7 @@ static BOOL CRYPT_AsnDecodePolicyQualifierUserNoticeInternal( ...@@ -2653,7 +2650,7 @@ static BOOL CRYPT_AsnDecodePolicyQualifierUserNoticeInternal(
TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags, TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, *pcbStructInfo); pvStructInfo, *pcbStructInfo);
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo, pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, notice ? notice->pNoticeReference : NULL); pcbDecoded, notice ? notice->pNoticeReference : NULL);
TRACE("returning %d\n", ret); TRACE("returning %d\n", ret);
...@@ -2748,7 +2745,7 @@ static BOOL CRYPT_AsnDecodePKCSAttributeInternal(const BYTE *pbEncoded, ...@@ -2748,7 +2745,7 @@ static BOOL CRYPT_AsnDecodePKCSAttributeInternal(const BYTE *pbEncoded,
TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags, TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, *pcbStructInfo); pvStructInfo, *pcbStructInfo);
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo, pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, attr ? attr->pszObjId : NULL); pcbDecoded, attr ? attr->pszObjId : NULL);
TRACE("returning %d\n", ret); TRACE("returning %d\n", ret);
...@@ -2866,7 +2863,7 @@ static BOOL CRYPT_AsnDecodeAlgorithmId(const BYTE *pbEncoded, DWORD cbEncoded, ...@@ -2866,7 +2863,7 @@ static BOOL CRYPT_AsnDecodeAlgorithmId(const BYTE *pbEncoded, DWORD cbEncoded,
TRACE("%p, %d, %08x, %p, %d, %p\n", pbEncoded, cbEncoded, dwFlags, TRACE("%p, %d, %08x, %p, %d, %p\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, *pcbStructInfo, pcbDecoded); pvStructInfo, *pcbStructInfo, pcbDecoded);
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo, pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, algo ? algo->pszObjId : NULL); pcbDecoded, algo ? algo->pszObjId : NULL);
if (ret && pvStructInfo) if (ret && pvStructInfo)
...@@ -2893,7 +2890,7 @@ static BOOL CRYPT_AsnDecodePubKeyInfoInternal(const BYTE *pbEncoded, ...@@ -2893,7 +2890,7 @@ static BOOL CRYPT_AsnDecodePubKeyInfoInternal(const BYTE *pbEncoded,
}; };
PCERT_PUBLIC_KEY_INFO info = pvStructInfo; PCERT_PUBLIC_KEY_INFO info = pvStructInfo;
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo, pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, info ? info->Algorithm.Parameters.pbData : NULL); pcbDecoded, info ? info->Algorithm.Parameters.pbData : NULL);
return ret; return ret;
...@@ -3150,7 +3147,7 @@ static BOOL WINAPI CRYPT_AsnDecodeAuthorityKeyId(DWORD dwCertEncodingType, ...@@ -3150,7 +3147,7 @@ static BOOL WINAPI CRYPT_AsnDecodeAuthorityKeyId(DWORD dwCertEncodingType,
offsetof(CERT_AUTHORITY_KEY_ID_INFO, CertSerialNumber.pbData), 0 }, offsetof(CERT_AUTHORITY_KEY_ID_INFO, CertSerialNumber.pbData), 0 },
}; };
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo,
pcbStructInfo, NULL, NULL); pcbStructInfo, NULL, NULL);
} }
...@@ -3187,7 +3184,7 @@ static BOOL WINAPI CRYPT_AsnDecodeAuthorityKeyId2(DWORD dwCertEncodingType, ...@@ -3187,7 +3184,7 @@ static BOOL WINAPI CRYPT_AsnDecodeAuthorityKeyId2(DWORD dwCertEncodingType,
AuthorityCertSerialNumber.pbData), 0 }, AuthorityCertSerialNumber.pbData), 0 },
}; };
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo,
pcbStructInfo, NULL, NULL); pcbStructInfo, NULL, NULL);
} }
...@@ -3214,7 +3211,7 @@ static BOOL CRYPT_AsnDecodeAccessDescription(const BYTE *pbEncoded, ...@@ -3214,7 +3211,7 @@ static BOOL CRYPT_AsnDecodeAccessDescription(const BYTE *pbEncoded,
}; };
CERT_ACCESS_DESCRIPTION *descr = pvStructInfo; CERT_ACCESS_DESCRIPTION *descr = pvStructInfo;
return CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), return CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo, pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, descr ? descr->pszAccessMethod : NULL); pcbDecoded, descr ? descr->pszAccessMethod : NULL);
} }
...@@ -3323,7 +3320,7 @@ static BOOL CRYPT_AsnDecodePKCSContentInfoInternal(const BYTE *pbEncoded, ...@@ -3323,7 +3320,7 @@ static BOOL CRYPT_AsnDecodePKCSContentInfoInternal(const BYTE *pbEncoded,
TRACE("%p, %d, %08x, %p, %d, %p\n", pbEncoded, cbEncoded, dwFlags, TRACE("%p, %d, %08x, %p, %d, %p\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, *pcbStructInfo, pcbDecoded); pvStructInfo, *pcbStructInfo, pcbDecoded);
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo, pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, info ? info->pszObjId : NULL); pcbDecoded, info ? info->pszObjId : NULL);
return ret; return ret;
...@@ -3392,7 +3389,7 @@ BOOL CRYPT_AsnDecodePKCSDigestedData(const BYTE *pbEncoded, DWORD cbEncoded, ...@@ -3392,7 +3389,7 @@ BOOL CRYPT_AsnDecodePKCSDigestedData(const BYTE *pbEncoded, DWORD cbEncoded,
offsetof(CRYPT_DIGESTED_DATA, hash.pbData), 0 }, offsetof(CRYPT_DIGESTED_DATA, hash.pbData), 0 },
}; };
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, pDecodePara, digestedData, pcbDigestedData, pbEncoded, cbEncoded, dwFlags, pDecodePara, digestedData, pcbDigestedData,
NULL, NULL); NULL, NULL);
return ret; return ret;
...@@ -3531,7 +3528,7 @@ static BOOL WINAPI CRYPT_AsnDecodeBasicConstraints(DWORD dwCertEncodingType, ...@@ -3531,7 +3528,7 @@ static BOOL WINAPI CRYPT_AsnDecodeBasicConstraints(DWORD dwCertEncodingType,
offsetof(CERT_BASIC_CONSTRAINTS_INFO, rgSubtreesConstraint), 0 }, offsetof(CERT_BASIC_CONSTRAINTS_INFO, rgSubtreesConstraint), 0 },
}; };
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo,
pcbStructInfo, NULL, NULL); pcbStructInfo, NULL, NULL);
} }
...@@ -3560,7 +3557,7 @@ static BOOL WINAPI CRYPT_AsnDecodeBasicConstraints2(DWORD dwCertEncodingType, ...@@ -3560,7 +3557,7 @@ static BOOL WINAPI CRYPT_AsnDecodeBasicConstraints2(DWORD dwCertEncodingType,
sizeof(struct PATH_LEN_CONSTRAINT), TRUE, FALSE, 0, 0 }, sizeof(struct PATH_LEN_CONSTRAINT), TRUE, FALSE, 0, 0 },
}; };
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo,
pcbStructInfo, NULL, NULL); pcbStructInfo, NULL, NULL);
} }
...@@ -3592,7 +3589,7 @@ static BOOL CRYPT_AsnDecodePolicyQualifier(const BYTE *pbEncoded, ...@@ -3592,7 +3589,7 @@ static BOOL CRYPT_AsnDecodePolicyQualifier(const BYTE *pbEncoded,
TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags, TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, pvStructInfo ? *pcbStructInfo : 0); pvStructInfo, pvStructInfo ? *pcbStructInfo : 0);
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo, pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, qualifier ? qualifier->pszPolicyQualifierId : NULL); pcbDecoded, qualifier ? qualifier->pszPolicyQualifierId : NULL);
return ret; return ret;
...@@ -3637,7 +3634,7 @@ static BOOL CRYPT_AsnDecodeCertPolicy(const BYTE *pbEncoded, DWORD cbEncoded, ...@@ -3637,7 +3634,7 @@ static BOOL CRYPT_AsnDecodeCertPolicy(const BYTE *pbEncoded, DWORD cbEncoded,
TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags, TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, pvStructInfo ? *pcbStructInfo : 0); pvStructInfo, pvStructInfo ? *pcbStructInfo : 0);
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo, pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, info ? info->pszPolicyIdentifier : NULL); pcbDecoded, info ? info->pszPolicyIdentifier : NULL);
return ret; return ret;
...@@ -3694,7 +3691,7 @@ static BOOL CRYPT_AsnDecodeCertPolicyMapping(const BYTE *pbEncoded, ...@@ -3694,7 +3691,7 @@ static BOOL CRYPT_AsnDecodeCertPolicyMapping(const BYTE *pbEncoded,
TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags, TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, pvStructInfo ? *pcbStructInfo : 0); pvStructInfo, pvStructInfo ? *pcbStructInfo : 0);
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo, pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, mapping ? mapping->pszIssuerDomainPolicy : NULL); pcbDecoded, mapping ? mapping->pszIssuerDomainPolicy : NULL);
return ret; return ret;
...@@ -3851,7 +3848,7 @@ static BOOL WINAPI CRYPT_AsnDecodeCertPolicyConstraints( ...@@ -3851,7 +3848,7 @@ static BOOL WINAPI CRYPT_AsnDecodeCertPolicyConstraints(
TRUE, FALSE, 0, 0 }, TRUE, FALSE, 0, 0 },
}; };
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo,
pcbStructInfo, NULL, NULL); pcbStructInfo, NULL, NULL);
} }
...@@ -3890,7 +3887,7 @@ static BOOL WINAPI CRYPT_AsnDecodeRsaPubKey(DWORD dwCertEncodingType, ...@@ -3890,7 +3887,7 @@ static BOOL WINAPI CRYPT_AsnDecodeRsaPubKey(DWORD dwCertEncodingType,
struct DECODED_RSA_PUB_KEY *decodedKey = NULL; struct DECODED_RSA_PUB_KEY *decodedKey = NULL;
DWORD size = 0; DWORD size = 0;
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL, &decodedKey, pbEncoded, cbEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL, &decodedKey,
&size, NULL, NULL); &size, NULL, NULL);
if (ret) if (ret)
...@@ -3998,7 +3995,7 @@ static BOOL WINAPI CRYPT_AsnDecodeRsaPrivKey(DWORD dwCertEncodingType, ...@@ -3998,7 +3995,7 @@ static BOOL WINAPI CRYPT_AsnDecodeRsaPrivKey(DWORD dwCertEncodingType,
struct DECODED_RSA_PRIV_KEY *decodedKey = NULL; struct DECODED_RSA_PRIV_KEY *decodedKey = NULL;
DWORD size = 0; DWORD size = 0;
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL, &decodedKey, pbEncoded, cbEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL, &decodedKey,
&size, NULL, NULL); &size, NULL, NULL);
if (ret) if (ret)
...@@ -5242,7 +5239,7 @@ static BOOL CRYPT_AsnDecodeDistPoint(const BYTE *pbEncoded, DWORD cbEncoded, ...@@ -5242,7 +5239,7 @@ static BOOL CRYPT_AsnDecodeDistPoint(const BYTE *pbEncoded, DWORD cbEncoded,
CRL_DIST_POINT *point = pvStructInfo; CRL_DIST_POINT *point = pvStructInfo;
BOOL ret; BOOL ret;
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo, pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, point ? point->DistPointName.u.FullName.rgAltEntry : NULL); pcbDecoded, point ? point->DistPointName.u.FullName.rgAltEntry : NULL);
return ret; return ret;
...@@ -5344,7 +5341,7 @@ static BOOL WINAPI CRYPT_AsnDecodeIssuingDistPoint(DWORD dwCertEncodingType, ...@@ -5344,7 +5341,7 @@ static BOOL WINAPI CRYPT_AsnDecodeIssuingDistPoint(DWORD dwCertEncodingType,
fIndirectCRL), CRYPT_AsnDecodeBool, sizeof(BOOL), TRUE, FALSE, 0 }, fIndirectCRL), CRYPT_AsnDecodeBool, sizeof(BOOL), TRUE, FALSE, 0 },
}; };
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo,
pcbStructInfo, NULL, NULL); pcbStructInfo, NULL, NULL);
} }
...@@ -5427,7 +5424,7 @@ static BOOL CRYPT_AsnDecodeSubtree(const BYTE *pbEncoded, ...@@ -5427,7 +5424,7 @@ static BOOL CRYPT_AsnDecodeSubtree(const BYTE *pbEncoded,
TRACE("%p, %d, %08x, %p, %d, %p\n", pbEncoded, cbEncoded, dwFlags, TRACE("%p, %d, %08x, %p, %d, %p\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, *pcbStructInfo, pcbDecoded); pvStructInfo, *pcbStructInfo, pcbDecoded);
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo, pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, subtree ? subtree->Base.u.pwszURL : NULL); pcbDecoded, subtree ? subtree->Base.u.pwszURL : NULL);
if (pcbDecoded) if (pcbDecoded)
...@@ -5508,7 +5505,7 @@ static BOOL WINAPI CRYPT_AsnDecodeNameConstraints(DWORD dwCertEncodingType, ...@@ -5508,7 +5505,7 @@ static BOOL WINAPI CRYPT_AsnDecodeNameConstraints(DWORD dwCertEncodingType,
offsetof(CERT_NAME_CONSTRAINTS_INFO, rgExcludedSubtree), 0 }, offsetof(CERT_NAME_CONSTRAINTS_INFO, rgExcludedSubtree), 0 },
}; };
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo,
pcbStructInfo, NULL, NULL); pcbStructInfo, NULL, NULL);
} }
...@@ -5538,7 +5535,7 @@ static BOOL CRYPT_AsnDecodeIssuerSerialNumber(const BYTE *pbEncoded, ...@@ -5538,7 +5535,7 @@ static BOOL CRYPT_AsnDecodeIssuerSerialNumber(const BYTE *pbEncoded,
TRACE("%p, %d, %08x, %p, %d, %p\n", pbEncoded, cbEncoded, dwFlags, TRACE("%p, %d, %08x, %p, %d, %p\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, *pcbStructInfo, pcbDecoded); pvStructInfo, *pcbStructInfo, pcbDecoded);
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo, pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, issuerSerial ? issuerSerial->Issuer.pbData : NULL); pcbDecoded, issuerSerial ? issuerSerial->Issuer.pbData : NULL);
if (ret && issuerSerial && !issuerSerial->SerialNumber.cbData) if (ret && issuerSerial && !issuerSerial->SerialNumber.cbData)
...@@ -5585,7 +5582,7 @@ static BOOL CRYPT_AsnDecodePKCSSignerInfoInternal(const BYTE *pbEncoded, ...@@ -5585,7 +5582,7 @@ static BOOL CRYPT_AsnDecodePKCSSignerInfoInternal(const BYTE *pbEncoded,
TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags, TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, *pcbStructInfo); pvStructInfo, *pcbStructInfo);
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo, pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, info ? info->Issuer.pbData : NULL); pcbDecoded, info ? info->Issuer.pbData : NULL);
return ret; return ret;
...@@ -5751,7 +5748,7 @@ static BOOL CRYPT_AsnDecodeCMSSignerInfoInternal(const BYTE *pbEncoded, ...@@ -5751,7 +5748,7 @@ static BOOL CRYPT_AsnDecodeCMSSignerInfoInternal(const BYTE *pbEncoded,
TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags, TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, *pcbStructInfo); pvStructInfo, *pcbStructInfo);
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo, pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, info ? info->SignerId.u.KeyId.pbData : NULL); pcbDecoded, info ? info->SignerId.u.KeyId.pbData : NULL);
return ret; return ret;
...@@ -5851,7 +5848,7 @@ BOOL CRYPT_AsnDecodeCMSSignedInfo(const BYTE *pbEncoded, DWORD cbEncoded, ...@@ -5851,7 +5848,7 @@ BOOL CRYPT_AsnDecodeCMSSignedInfo(const BYTE *pbEncoded, DWORD cbEncoded,
TRACE("%p, %d, %08x, %p, %p, %p\n", pbEncoded, cbEncoded, dwFlags, TRACE("%p, %d, %08x, %p, %p, %p\n", pbEncoded, cbEncoded, dwFlags,
pDecodePara, signedInfo, pcbSignedInfo); pDecodePara, signedInfo, pcbSignedInfo);
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, pDecodePara, signedInfo, pcbSignedInfo, pbEncoded, cbEncoded, dwFlags, pDecodePara, signedInfo, pcbSignedInfo,
NULL, NULL); NULL, NULL);
TRACE("returning %d\n", ret); TRACE("returning %d\n", ret);
...@@ -5884,7 +5881,7 @@ static BOOL CRYPT_AsnDecodeRecipientInfo(const BYTE *pbEncoded, DWORD cbEncoded, ...@@ -5884,7 +5881,7 @@ static BOOL CRYPT_AsnDecodeRecipientInfo(const BYTE *pbEncoded, DWORD cbEncoded,
TRACE("%p, %d, %08x, %p, %d, %p\n", pbEncoded, cbEncoded, dwFlags, TRACE("%p, %d, %08x, %p, %d, %p\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, *pcbStructInfo, pcbDecoded); pvStructInfo, *pcbStructInfo, pcbDecoded);
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo, pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, info ? info->RecipientId.u.IssuerSerialNumber.Issuer.pbData : pcbDecoded, info ? info->RecipientId.u.IssuerSerialNumber.Issuer.pbData :
NULL); NULL);
...@@ -5941,7 +5938,7 @@ static BOOL CRYPT_AsnDecodeEncryptedContentInfo(const BYTE *pbEncoded, ...@@ -5941,7 +5938,7 @@ static BOOL CRYPT_AsnDecodeEncryptedContentInfo(const BYTE *pbEncoded,
TRACE("%p, %d, %08x, %p, %d, %p\n", pbEncoded, cbEncoded, dwFlags, TRACE("%p, %d, %08x, %p, %d, %p\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, *pcbStructInfo, pcbDecoded); pvStructInfo, *pcbStructInfo, pcbDecoded);
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo, pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, info ? info->contentType : NULL); pcbDecoded, info ? info->contentType : NULL);
TRACE("returning %d\n", ret); TRACE("returning %d\n", ret);
...@@ -5969,7 +5966,7 @@ BOOL CRYPT_AsnDecodePKCSEnvelopedData(const BYTE *pbEncoded, DWORD cbEncoded, ...@@ -5969,7 +5966,7 @@ BOOL CRYPT_AsnDecodePKCSEnvelopedData(const BYTE *pbEncoded, DWORD cbEncoded,
TRACE("%p, %d, %08x, %p, %p, %p\n", pbEncoded, cbEncoded, dwFlags, TRACE("%p, %d, %08x, %p, %p, %p\n", pbEncoded, cbEncoded, dwFlags,
pDecodePara, envelopedData, pcbEnvelopedData); pDecodePara, envelopedData, pcbEnvelopedData);
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, pDecodePara, envelopedData, pbEncoded, cbEncoded, dwFlags, pDecodePara, envelopedData,
pcbEnvelopedData, NULL, NULL); pcbEnvelopedData, NULL, NULL);
TRACE("returning %d\n", ret); TRACE("returning %d\n", ret);
......
...@@ -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)
{ {
......
...@@ -929,8 +929,7 @@ static BOOL WINAPI CRYPT_FormatKeyUsage(DWORD dwCertEncodingType, ...@@ -929,8 +929,7 @@ static BOOL WINAPI CRYPT_FormatKeyUsage(DWORD dwCertEncodingType,
WCHAR infoNotAvailable[MAX_STRING_RESOURCE_LEN]; WCHAR infoNotAvailable[MAX_STRING_RESOURCE_LEN];
DWORD bytesNeeded = sizeof(WCHAR); DWORD bytesNeeded = sizeof(WCHAR);
LoadStringW(hInstance, IDS_INFO_NOT_AVAILABLE, infoNotAvailable, LoadStringW(hInstance, IDS_INFO_NOT_AVAILABLE, infoNotAvailable, ARRAY_SIZE(infoNotAvailable));
sizeof(infoNotAvailable) / sizeof(infoNotAvailable[0]));
if (!bits->cbData || bits->cbData > 2) if (!bits->cbData || bits->cbData > 2)
{ {
bytesNeeded += strlenW(infoNotAvailable) * sizeof(WCHAR); bytesNeeded += strlenW(infoNotAvailable) * sizeof(WCHAR);
...@@ -959,26 +958,18 @@ static BOOL WINAPI CRYPT_FormatKeyUsage(DWORD dwCertEncodingType, ...@@ -959,26 +958,18 @@ static BOOL WINAPI CRYPT_FormatKeyUsage(DWORD dwCertEncodingType,
if (!stringsLoaded) if (!stringsLoaded)
{ {
for (i = 0; for (i = 0; i < ARRAY_SIZE(keyUsageByte0Map); i++)
i < sizeof(keyUsageByte0Map) / sizeof(keyUsageByte0Map[0]); LoadStringW(hInstance, keyUsageByte0Map[i].id, keyUsageByte0Map[i].str, MAX_STRING_RESOURCE_LEN);
i++) for (i = 0; i < ARRAY_SIZE(keyUsageByte1Map); i++)
LoadStringW(hInstance, keyUsageByte0Map[i].id, LoadStringW(hInstance, keyUsageByte1Map[i].id, keyUsageByte1Map[i].str, MAX_STRING_RESOURCE_LEN);
keyUsageByte0Map[i].str, MAX_STRING_RESOURCE_LEN);
for (i = 0;
i < sizeof(keyUsageByte1Map) / sizeof(keyUsageByte1Map[0]);
i++)
LoadStringW(hInstance, keyUsageByte1Map[i].id,
keyUsageByte1Map[i].str, MAX_STRING_RESOURCE_LEN);
stringsLoaded = TRUE; stringsLoaded = TRUE;
} }
CRYPT_FormatBits(bits->pbData[0], keyUsageByte0Map, CRYPT_FormatBits(bits->pbData[0], keyUsageByte0Map, ARRAY_SIZE(keyUsageByte0Map),
sizeof(keyUsageByte0Map) / sizeof(keyUsageByte0Map[0]),
NULL, &bitStringLen, &first); NULL, &bitStringLen, &first);
bytesNeeded += bitStringLen; bytesNeeded += bitStringLen;
if (bits->cbData == 2) if (bits->cbData == 2)
{ {
CRYPT_FormatBits(bits->pbData[1], keyUsageByte1Map, CRYPT_FormatBits(bits->pbData[1], keyUsageByte1Map, ARRAY_SIZE(keyUsageByte1Map),
sizeof(keyUsageByte1Map) / sizeof(keyUsageByte1Map[0]),
NULL, &bitStringLen, &first); NULL, &bitStringLen, &first);
bytesNeeded += bitStringLen; bytesNeeded += bitStringLen;
} }
...@@ -1000,15 +991,13 @@ static BOOL WINAPI CRYPT_FormatKeyUsage(DWORD dwCertEncodingType, ...@@ -1000,15 +991,13 @@ static BOOL WINAPI CRYPT_FormatKeyUsage(DWORD dwCertEncodingType,
bitStringLen = bytesNeeded; bitStringLen = bytesNeeded;
first = TRUE; first = TRUE;
CRYPT_FormatBits(bits->pbData[0], keyUsageByte0Map, CRYPT_FormatBits(bits->pbData[0], keyUsageByte0Map, ARRAY_SIZE(keyUsageByte0Map),
sizeof(keyUsageByte0Map) / sizeof(keyUsageByte0Map[0]),
str, &bitStringLen, &first); str, &bitStringLen, &first);
str += bitStringLen / sizeof(WCHAR) - 1; str += bitStringLen / sizeof(WCHAR) - 1;
if (bits->cbData == 2) if (bits->cbData == 2)
{ {
bitStringLen = bytesNeeded; bitStringLen = bytesNeeded;
CRYPT_FormatBits(bits->pbData[1], keyUsageByte1Map, CRYPT_FormatBits(bits->pbData[1], keyUsageByte1Map, ARRAY_SIZE(keyUsageByte1Map),
sizeof(keyUsageByte1Map) / sizeof(keyUsageByte1Map[0]),
str, &bitStringLen, &first); str, &bitStringLen, &first);
str += bitStringLen / sizeof(WCHAR) - 1; str += bitStringLen / sizeof(WCHAR) - 1;
} }
...@@ -1070,15 +1059,10 @@ static BOOL WINAPI CRYPT_FormatBasicConstraints2(DWORD dwCertEncodingType, ...@@ -1070,15 +1059,10 @@ static BOOL WINAPI CRYPT_FormatBasicConstraints2(DWORD dwCertEncodingType,
if (!stringsLoaded) if (!stringsLoaded)
{ {
LoadStringW(hInstance, IDS_SUBJECT_TYPE, subjectTypeHeader, LoadStringW(hInstance, IDS_SUBJECT_TYPE, subjectTypeHeader, ARRAY_SIZE(subjectTypeHeader));
sizeof(subjectTypeHeader) / sizeof(subjectTypeHeader[0])); LoadStringW(hInstance, IDS_SUBJECT_TYPE_CA, subjectTypeCA, ARRAY_SIZE(subjectTypeCA));
LoadStringW(hInstance, IDS_SUBJECT_TYPE_CA, subjectTypeCA, LoadStringW(hInstance, IDS_SUBJECT_TYPE_END_CERT, subjectTypeEndCert, ARRAY_SIZE(subjectTypeEndCert));
sizeof(subjectTypeCA) / sizeof(subjectTypeCA[0])); LoadStringW(hInstance, IDS_PATH_LENGTH, pathLengthHeader, ARRAY_SIZE(pathLengthHeader));
LoadStringW(hInstance, IDS_SUBJECT_TYPE_END_CERT,
subjectTypeEndCert,
sizeof(subjectTypeEndCert) / sizeof(subjectTypeEndCert[0]));
LoadStringW(hInstance, IDS_PATH_LENGTH, pathLengthHeader,
sizeof(pathLengthHeader) / sizeof(pathLengthHeader[0]));
stringsLoaded = TRUE; stringsLoaded = TRUE;
} }
bytesNeeded += strlenW(subjectTypeHeader) * sizeof(WCHAR); bytesNeeded += strlenW(subjectTypeHeader) * sizeof(WCHAR);
...@@ -1092,8 +1076,7 @@ static BOOL WINAPI CRYPT_FormatBasicConstraints2(DWORD dwCertEncodingType, ...@@ -1092,8 +1076,7 @@ static BOOL WINAPI CRYPT_FormatBasicConstraints2(DWORD dwCertEncodingType,
if (info->fPathLenConstraint) if (info->fPathLenConstraint)
sprintfW(pathLength, pathFmt, info->dwPathLenConstraint); sprintfW(pathLength, pathFmt, info->dwPathLenConstraint);
else else
LoadStringW(hInstance, IDS_PATH_LENGTH_NONE, pathLength, LoadStringW(hInstance, IDS_PATH_LENGTH_NONE, pathLength, ARRAY_SIZE(pathLength));
sizeof(pathLength) / sizeof(pathLength[0]));
bytesNeeded += strlenW(pathLength) * sizeof(WCHAR); bytesNeeded += strlenW(pathLength) * sizeof(WCHAR);
if (!pbFormat) if (!pbFormat)
*pcbFormat = bytesNeeded; *pcbFormat = bytesNeeded;
...@@ -1130,7 +1113,7 @@ static BOOL CRYPT_FormatHexStringWithPrefix(const CRYPT_DATA_BLOB *blob, int id, ...@@ -1130,7 +1113,7 @@ static BOOL CRYPT_FormatHexStringWithPrefix(const CRYPT_DATA_BLOB *blob, int id,
DWORD bytesNeeded; DWORD bytesNeeded;
BOOL ret; BOOL ret;
LoadStringW(hInstance, id, buf, sizeof(buf) / sizeof(buf[0])); LoadStringW(hInstance, id, buf, ARRAY_SIZE(buf));
CRYPT_FormatHexString(X509_ASN_ENCODING, 0, 0, NULL, NULL, CRYPT_FormatHexString(X509_ASN_ENCODING, 0, 0, NULL, NULL,
blob->pbData, blob->cbData, NULL, &bytesNeeded); blob->pbData, blob->cbData, NULL, &bytesNeeded);
bytesNeeded += strlenW(buf) * sizeof(WCHAR); bytesNeeded += strlenW(buf) * sizeof(WCHAR);
...@@ -1189,14 +1172,12 @@ static BOOL CRYPT_FormatAltNameEntry(DWORD dwFormatStrType, DWORD indentLevel, ...@@ -1189,14 +1172,12 @@ static BOOL CRYPT_FormatAltNameEntry(DWORD dwFormatStrType, DWORD indentLevel,
switch (entry->dwAltNameChoice) switch (entry->dwAltNameChoice)
{ {
case CERT_ALT_NAME_RFC822_NAME: case CERT_ALT_NAME_RFC822_NAME:
LoadStringW(hInstance, IDS_ALT_NAME_RFC822_NAME, buf, LoadStringW(hInstance, IDS_ALT_NAME_RFC822_NAME, buf, ARRAY_SIZE(buf));
sizeof(buf) / sizeof(buf[0]));
bytesNeeded += strlenW(entry->u.pwszRfc822Name) * sizeof(WCHAR); bytesNeeded += strlenW(entry->u.pwszRfc822Name) * sizeof(WCHAR);
ret = TRUE; ret = TRUE;
break; break;
case CERT_ALT_NAME_DNS_NAME: case CERT_ALT_NAME_DNS_NAME:
LoadStringW(hInstance, IDS_ALT_NAME_DNS_NAME, buf, LoadStringW(hInstance, IDS_ALT_NAME_DNS_NAME, buf, ARRAY_SIZE(buf));
sizeof(buf) / sizeof(buf[0]));
bytesNeeded += strlenW(entry->u.pwszDNSName) * sizeof(WCHAR); bytesNeeded += strlenW(entry->u.pwszDNSName) * sizeof(WCHAR);
ret = TRUE; ret = TRUE;
break; break;
...@@ -1208,8 +1189,7 @@ static BOOL CRYPT_FormatAltNameEntry(DWORD dwFormatStrType, DWORD indentLevel, ...@@ -1208,8 +1189,7 @@ static BOOL CRYPT_FormatAltNameEntry(DWORD dwFormatStrType, DWORD indentLevel,
strType |= CERT_NAME_STR_CRLF_FLAG; strType |= CERT_NAME_STR_CRLF_FLAG;
directoryNameLen = cert_name_to_str_with_indent(X509_ASN_ENCODING, directoryNameLen = cert_name_to_str_with_indent(X509_ASN_ENCODING,
indentLevel + 1, &entry->u.DirectoryName, strType, NULL, 0); indentLevel + 1, &entry->u.DirectoryName, strType, NULL, 0);
LoadStringW(hInstance, IDS_ALT_NAME_DIRECTORY_NAME, buf, LoadStringW(hInstance, IDS_ALT_NAME_DIRECTORY_NAME, buf, ARRAY_SIZE(buf));
sizeof(buf) / sizeof(buf[0]));
bytesNeeded += (directoryNameLen - 1) * sizeof(WCHAR); bytesNeeded += (directoryNameLen - 1) * sizeof(WCHAR);
if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE) if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE)
bytesNeeded += strlenW(colonCrlf) * sizeof(WCHAR); bytesNeeded += strlenW(colonCrlf) * sizeof(WCHAR);
...@@ -1219,8 +1199,7 @@ static BOOL CRYPT_FormatAltNameEntry(DWORD dwFormatStrType, DWORD indentLevel, ...@@ -1219,8 +1199,7 @@ static BOOL CRYPT_FormatAltNameEntry(DWORD dwFormatStrType, DWORD indentLevel,
break; break;
} }
case CERT_ALT_NAME_URL: case CERT_ALT_NAME_URL:
LoadStringW(hInstance, IDS_ALT_NAME_URL, buf, LoadStringW(hInstance, IDS_ALT_NAME_URL, buf, ARRAY_SIZE(buf));
sizeof(buf) / sizeof(buf[0]));
bytesNeeded += strlenW(entry->u.pwszURL) * sizeof(WCHAR); bytesNeeded += strlenW(entry->u.pwszURL) * sizeof(WCHAR);
ret = TRUE; ret = TRUE;
break; break;
...@@ -1232,14 +1211,12 @@ static BOOL CRYPT_FormatAltNameEntry(DWORD dwFormatStrType, DWORD indentLevel, ...@@ -1232,14 +1211,12 @@ static BOOL CRYPT_FormatAltNameEntry(DWORD dwFormatStrType, DWORD indentLevel,
static const WCHAR ipAddrFmt[] = { '%','d','.','%','d','.','%','d', static const WCHAR ipAddrFmt[] = { '%','d','.','%','d','.','%','d',
'.','%','d',0 }; '.','%','d',0 };
LoadStringW(hInstance, IDS_ALT_NAME_IP_ADDRESS, buf, LoadStringW(hInstance, IDS_ALT_NAME_IP_ADDRESS, buf, ARRAY_SIZE(buf));
sizeof(buf) / sizeof(buf[0]));
if (entry->u.IPAddress.cbData == 8) if (entry->u.IPAddress.cbData == 8)
{ {
if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE) if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE)
{ {
LoadStringW(hInstance, IDS_ALT_NAME_MASK, mask, LoadStringW(hInstance, IDS_ALT_NAME_MASK, mask, ARRAY_SIZE(mask));
sizeof(mask) / sizeof(mask[0]));
bytesNeeded += strlenW(mask) * sizeof(WCHAR); bytesNeeded += strlenW(mask) * sizeof(WCHAR);
sprintfW(ipAddrBuf, ipAddrFmt, sprintfW(ipAddrBuf, ipAddrFmt,
entry->u.IPAddress.pbData[0], entry->u.IPAddress.pbData[0],
...@@ -1448,7 +1425,7 @@ static BOOL CRYPT_FormatCertIssuer(DWORD dwFormatStrType, ...@@ -1448,7 +1425,7 @@ static BOOL CRYPT_FormatCertIssuer(DWORD dwFormatStrType,
LPCWSTR sep; LPCWSTR sep;
BOOL ret; BOOL ret;
LoadStringW(hInstance, IDS_CERT_ISSUER, buf, sizeof(buf) / sizeof(buf[0])); LoadStringW(hInstance, IDS_CERT_ISSUER, buf, ARRAY_SIZE(buf));
ret = CRYPT_FormatAltNameInfo(dwFormatStrType, 1, issuer, NULL, ret = CRYPT_FormatAltNameInfo(dwFormatStrType, 1, issuer, NULL,
&bytesNeeded); &bytesNeeded);
bytesNeeded += strlenW(buf) * sizeof(WCHAR); bytesNeeded += strlenW(buf) * sizeof(WCHAR);
...@@ -1652,8 +1629,7 @@ static BOOL WINAPI CRYPT_FormatAuthorityInfoAccess(DWORD dwCertEncodingType, ...@@ -1652,8 +1629,7 @@ static BOOL WINAPI CRYPT_FormatAuthorityInfoAccess(DWORD dwCertEncodingType,
{ {
WCHAR infoNotAvailable[MAX_STRING_RESOURCE_LEN]; WCHAR infoNotAvailable[MAX_STRING_RESOURCE_LEN];
LoadStringW(hInstance, IDS_INFO_NOT_AVAILABLE, infoNotAvailable, LoadStringW(hInstance, IDS_INFO_NOT_AVAILABLE, infoNotAvailable, ARRAY_SIZE(infoNotAvailable));
sizeof(infoNotAvailable) / sizeof(infoNotAvailable[0]));
bytesNeeded += strlenW(infoNotAvailable) * sizeof(WCHAR); bytesNeeded += strlenW(infoNotAvailable) * sizeof(WCHAR);
if (!pbFormat) if (!pbFormat)
*pcbFormat = bytesNeeded; *pcbFormat = bytesNeeded;
...@@ -1680,18 +1656,12 @@ static BOOL WINAPI CRYPT_FormatAuthorityInfoAccess(DWORD dwCertEncodingType, ...@@ -1680,18 +1656,12 @@ static BOOL WINAPI CRYPT_FormatAuthorityInfoAccess(DWORD dwCertEncodingType,
if (!stringsLoaded) if (!stringsLoaded)
{ {
LoadStringW(hInstance, IDS_AIA, aia, LoadStringW(hInstance, IDS_AIA, aia, ARRAY_SIZE(aia));
sizeof(aia) / sizeof(aia[0])); LoadStringW(hInstance, IDS_ACCESS_METHOD, accessMethod, ARRAY_SIZE(accessMethod));
LoadStringW(hInstance, IDS_ACCESS_METHOD, accessMethod, LoadStringW(hInstance, IDS_ACCESS_METHOD_OCSP, ocsp, ARRAY_SIZE(ocsp));
sizeof(accessMethod) / sizeof(accessMethod[0])); LoadStringW(hInstance, IDS_ACCESS_METHOD_CA_ISSUERS, caIssuers, ARRAY_SIZE(caIssuers));
LoadStringW(hInstance, IDS_ACCESS_METHOD_OCSP, ocsp, LoadStringW(hInstance, IDS_ACCESS_METHOD_UNKNOWN, unknown, ARRAY_SIZE(unknown));
sizeof(ocsp) / sizeof(ocsp[0])); LoadStringW(hInstance, IDS_ACCESS_LOCATION, accessLocation, ARRAY_SIZE(accessLocation));
LoadStringW(hInstance, IDS_ACCESS_METHOD_CA_ISSUERS, caIssuers,
sizeof(caIssuers) / sizeof(caIssuers[0]));
LoadStringW(hInstance, IDS_ACCESS_METHOD_UNKNOWN, unknown,
sizeof(unknown) / sizeof(unknown[0]));
LoadStringW(hInstance, IDS_ACCESS_LOCATION, accessLocation,
sizeof(accessLocation) / sizeof(accessLocation[0]));
stringsLoaded = TRUE; stringsLoaded = TRUE;
} }
if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE) if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE)
...@@ -1879,7 +1849,7 @@ static BOOL CRYPT_FormatReason(DWORD dwFormatStrType, ...@@ -1879,7 +1849,7 @@ static BOOL CRYPT_FormatReason(DWORD dwFormatStrType,
if (!stringsLoaded) if (!stringsLoaded)
{ {
for (i = 0; i < sizeof(reason_map) / sizeof(reason_map[0]); i++) for (i = 0; i < ARRAY_SIZE(reason_map); i++)
LoadStringW(hInstance, reason_map[i].id, reason_map[i].reason, LoadStringW(hInstance, reason_map[i].id, reason_map[i].reason,
MAX_STRING_RESOURCE_LEN); MAX_STRING_RESOURCE_LEN);
stringsLoaded = TRUE; stringsLoaded = TRUE;
...@@ -1887,7 +1857,7 @@ static BOOL CRYPT_FormatReason(DWORD dwFormatStrType, ...@@ -1887,7 +1857,7 @@ static BOOL CRYPT_FormatReason(DWORD dwFormatStrType,
/* No need to check reasonFlags->cbData, we already know it's positive. /* No need to check reasonFlags->cbData, we already know it's positive.
* Ignore any other bytes, as they're for undefined bits. * Ignore any other bytes, as they're for undefined bits.
*/ */
for (i = 0; i < sizeof(reason_map) / sizeof(reason_map[0]); i++) for (i = 0; i < ARRAY_SIZE(reason_map); i++)
{ {
if (reasonFlags->pbData[0] & reason_map[i].reasonBit) if (reasonFlags->pbData[0] & reason_map[i].reasonBit)
{ {
...@@ -1909,14 +1879,13 @@ static BOOL CRYPT_FormatReason(DWORD dwFormatStrType, ...@@ -1909,14 +1879,13 @@ static BOOL CRYPT_FormatReason(DWORD dwFormatStrType,
else else
{ {
*pcbStr = bytesNeeded; *pcbStr = bytesNeeded;
for (i = 0; i < sizeof(reason_map) / sizeof(reason_map[0]); i++) for (i = 0; i < ARRAY_SIZE(reason_map); i++)
{ {
if (reasonFlags->pbData[0] & reason_map[i].reasonBit) if (reasonFlags->pbData[0] & reason_map[i].reasonBit)
{ {
strcpyW(str, reason_map[i].reason); strcpyW(str, reason_map[i].reason);
str += strlenW(reason_map[i].reason); str += strlenW(reason_map[i].reason);
if (i < sizeof(reason_map) / sizeof(reason_map[0]) - 1 && if (i < ARRAY_SIZE(reason_map) - 1 && numReasons)
numReasons)
{ {
strcpyW(str, sep); strcpyW(str, sep);
str += strlenW(sep); str += strlenW(sep);
...@@ -1963,18 +1932,12 @@ static BOOL WINAPI CRYPT_FormatCRLDistPoints(DWORD dwCertEncodingType, ...@@ -1963,18 +1932,12 @@ static BOOL WINAPI CRYPT_FormatCRLDistPoints(DWORD dwCertEncodingType,
if (!stringsLoaded) if (!stringsLoaded)
{ {
LoadStringW(hInstance, IDS_CRL_DIST_POINT, crlDistPoint, LoadStringW(hInstance, IDS_CRL_DIST_POINT, crlDistPoint, ARRAY_SIZE(crlDistPoint));
sizeof(crlDistPoint) / sizeof(crlDistPoint[0])); LoadStringW(hInstance, IDS_CRL_DIST_POINT_NAME, distPointName, ARRAY_SIZE(distPointName));
LoadStringW(hInstance, IDS_CRL_DIST_POINT_NAME, distPointName, LoadStringW(hInstance, IDS_CRL_DIST_POINT_FULL_NAME, fullName, ARRAY_SIZE(fullName));
sizeof(distPointName) / sizeof(distPointName[0])); LoadStringW(hInstance, IDS_CRL_DIST_POINT_RDN_NAME, rdnName, ARRAY_SIZE(rdnName));
LoadStringW(hInstance, IDS_CRL_DIST_POINT_FULL_NAME, fullName, LoadStringW(hInstance, IDS_CRL_DIST_POINT_REASON, reason, ARRAY_SIZE(reason));
sizeof(fullName) / sizeof(fullName[0])); LoadStringW(hInstance, IDS_CRL_DIST_POINT_ISSUER, issuer, ARRAY_SIZE(issuer));
LoadStringW(hInstance, IDS_CRL_DIST_POINT_RDN_NAME, rdnName,
sizeof(rdnName) / sizeof(rdnName[0]));
LoadStringW(hInstance, IDS_CRL_DIST_POINT_REASON, reason,
sizeof(reason) / sizeof(reason[0]));
LoadStringW(hInstance, IDS_CRL_DIST_POINT_ISSUER, issuer,
sizeof(issuer) / sizeof(issuer[0]));
stringsLoaded = TRUE; stringsLoaded = TRUE;
} }
if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE) if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE)
...@@ -2050,8 +2013,7 @@ static BOOL WINAPI CRYPT_FormatCRLDistPoints(DWORD dwCertEncodingType, ...@@ -2050,8 +2013,7 @@ static BOOL WINAPI CRYPT_FormatCRLDistPoints(DWORD dwCertEncodingType,
{ {
WCHAR infoNotAvailable[MAX_STRING_RESOURCE_LEN]; WCHAR infoNotAvailable[MAX_STRING_RESOURCE_LEN];
LoadStringW(hInstance, IDS_INFO_NOT_AVAILABLE, infoNotAvailable, LoadStringW(hInstance, IDS_INFO_NOT_AVAILABLE, infoNotAvailable, ARRAY_SIZE(infoNotAvailable));
sizeof(infoNotAvailable) / sizeof(infoNotAvailable[0]));
bytesNeeded += strlenW(infoNotAvailable) * sizeof(WCHAR); bytesNeeded += strlenW(infoNotAvailable) * sizeof(WCHAR);
if (!pbFormat) if (!pbFormat)
*pcbFormat = bytesNeeded; *pcbFormat = bytesNeeded;
...@@ -2202,8 +2164,7 @@ static BOOL WINAPI CRYPT_FormatEnhancedKeyUsage(DWORD dwCertEncodingType, ...@@ -2202,8 +2164,7 @@ static BOOL WINAPI CRYPT_FormatEnhancedKeyUsage(DWORD dwCertEncodingType,
sepLen = strlenW(commaSpace) * sizeof(WCHAR); sepLen = strlenW(commaSpace) * sizeof(WCHAR);
} }
LoadStringW(hInstance, IDS_USAGE_UNKNOWN, unknown, LoadStringW(hInstance, IDS_USAGE_UNKNOWN, unknown, ARRAY_SIZE(unknown));
sizeof(unknown) / sizeof(unknown[0]));
for (i = 0; i < usage->cUsageIdentifier; i++) for (i = 0; i < usage->cUsageIdentifier; i++)
{ {
PCCRYPT_OID_INFO info = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, PCCRYPT_OID_INFO info = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY,
...@@ -2299,8 +2260,7 @@ static BOOL WINAPI CRYPT_FormatNetscapeCertType(DWORD dwCertEncodingType, ...@@ -2299,8 +2260,7 @@ static BOOL WINAPI CRYPT_FormatNetscapeCertType(DWORD dwCertEncodingType,
WCHAR infoNotAvailable[MAX_STRING_RESOURCE_LEN]; WCHAR infoNotAvailable[MAX_STRING_RESOURCE_LEN];
DWORD bytesNeeded = sizeof(WCHAR); DWORD bytesNeeded = sizeof(WCHAR);
LoadStringW(hInstance, IDS_INFO_NOT_AVAILABLE, infoNotAvailable, LoadStringW(hInstance, IDS_INFO_NOT_AVAILABLE, infoNotAvailable, ARRAY_SIZE(infoNotAvailable));
sizeof(infoNotAvailable) / sizeof(infoNotAvailable[0]));
if (!bits->cbData || bits->cbData > 1) if (!bits->cbData || bits->cbData > 1)
{ {
bytesNeeded += strlenW(infoNotAvailable) * sizeof(WCHAR); bytesNeeded += strlenW(infoNotAvailable) * sizeof(WCHAR);
...@@ -2329,14 +2289,12 @@ static BOOL WINAPI CRYPT_FormatNetscapeCertType(DWORD dwCertEncodingType, ...@@ -2329,14 +2289,12 @@ static BOOL WINAPI CRYPT_FormatNetscapeCertType(DWORD dwCertEncodingType,
if (!stringsLoaded) if (!stringsLoaded)
{ {
for (i = 0; i < sizeof(netscapeCertTypeMap) / for (i = 0; i < ARRAY_SIZE(netscapeCertTypeMap); i++)
sizeof(netscapeCertTypeMap[0]); i++)
LoadStringW(hInstance, netscapeCertTypeMap[i].id, LoadStringW(hInstance, netscapeCertTypeMap[i].id,
netscapeCertTypeMap[i].str, MAX_STRING_RESOURCE_LEN); netscapeCertTypeMap[i].str, MAX_STRING_RESOURCE_LEN);
stringsLoaded = TRUE; stringsLoaded = TRUE;
} }
CRYPT_FormatBits(bits->pbData[0], netscapeCertTypeMap, CRYPT_FormatBits(bits->pbData[0], netscapeCertTypeMap, ARRAY_SIZE(netscapeCertTypeMap),
sizeof(netscapeCertTypeMap) / sizeof(netscapeCertTypeMap[0]),
NULL, &bitStringLen, &first); NULL, &bitStringLen, &first);
bytesNeeded += bitStringLen; bytesNeeded += bitStringLen;
bytesNeeded += 3 * sizeof(WCHAR); /* " (" + ")" */ bytesNeeded += 3 * sizeof(WCHAR); /* " (" + ")" */
...@@ -2357,8 +2315,7 @@ static BOOL WINAPI CRYPT_FormatNetscapeCertType(DWORD dwCertEncodingType, ...@@ -2357,8 +2315,7 @@ static BOOL WINAPI CRYPT_FormatNetscapeCertType(DWORD dwCertEncodingType,
bitStringLen = bytesNeeded; bitStringLen = bytesNeeded;
first = TRUE; first = TRUE;
CRYPT_FormatBits(bits->pbData[0], netscapeCertTypeMap, CRYPT_FormatBits(bits->pbData[0], netscapeCertTypeMap, ARRAY_SIZE(netscapeCertTypeMap),
sizeof(netscapeCertTypeMap) / sizeof(netscapeCertTypeMap[0]),
str, &bitStringLen, &first); str, &bitStringLen, &first);
str += bitStringLen / sizeof(WCHAR) - 1; str += bitStringLen / sizeof(WCHAR) - 1;
*str++ = ' '; *str++ = ' ';
...@@ -2407,16 +2364,12 @@ static BOOL WINAPI CRYPT_FormatSpcFinancialCriteria(DWORD dwCertEncodingType, ...@@ -2407,16 +2364,12 @@ static BOOL WINAPI CRYPT_FormatSpcFinancialCriteria(DWORD dwCertEncodingType,
if (!stringsLoaded) if (!stringsLoaded)
{ {
LoadStringW(hInstance, IDS_FINANCIAL_CRITERIA, financialCriteria, LoadStringW(hInstance, IDS_FINANCIAL_CRITERIA, financialCriteria, ARRAY_SIZE(financialCriteria));
sizeof(financialCriteria) / sizeof(financialCriteria[0])); LoadStringW(hInstance, IDS_FINANCIAL_CRITERIA_AVAILABLE, available, ARRAY_SIZE(available));
LoadStringW(hInstance, IDS_FINANCIAL_CRITERIA_AVAILABLE, available, LoadStringW(hInstance, IDS_FINANCIAL_CRITERIA_NOT_AVAILABLE, notAvailable, ARRAY_SIZE(notAvailable));
sizeof(available) / sizeof(available[0])); LoadStringW(hInstance, IDS_FINANCIAL_CRITERIA_MEETS_CRITERIA, meetsCriteria, ARRAY_SIZE(meetsCriteria));
LoadStringW(hInstance, IDS_FINANCIAL_CRITERIA_NOT_AVAILABLE, LoadStringW(hInstance, IDS_YES, yes, ARRAY_SIZE(yes));
notAvailable, sizeof(notAvailable) / sizeof(notAvailable[0])); LoadStringW(hInstance, IDS_NO, no, ARRAY_SIZE(no));
LoadStringW(hInstance, IDS_FINANCIAL_CRITERIA_MEETS_CRITERIA,
meetsCriteria, sizeof(meetsCriteria) / sizeof(meetsCriteria[0]));
LoadStringW(hInstance, IDS_YES, yes, sizeof(yes) / sizeof(yes[0]));
LoadStringW(hInstance, IDS_NO, no, sizeof(no) / sizeof(no[0]));
stringsLoaded = TRUE; stringsLoaded = TRUE;
} }
if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE) if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE)
......
...@@ -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