crypt32: Simplify CRYPT_AsnDecodeSMIMECapabilities.

This commit is contained in:
Juan Lang 2009-10-14 12:46:53 -07:00 committed by Alexandre Julliard
parent 6ef1c3e09f
commit b8f696ff62
1 changed files with 9 additions and 22 deletions

View File

@ -2500,22 +2500,6 @@ static BOOL CRYPT_AsnDecodeSMIMECapability(const BYTE *pbEncoded,
return ret; return ret;
} }
static BOOL CRYPT_AsnDecodeSMIMECapabilitiesInternal(const BYTE *pbEncoded,
DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo,
DWORD *pcbDecoded)
{
struct AsnArrayDescriptor arrayDesc = { ASN_SEQUENCEOF,
CRYPT_AsnDecodeSMIMECapability, sizeof(CRYPT_SMIME_CAPABILITY), TRUE,
offsetof(CRYPT_SMIME_CAPABILITY, pszObjId) };
PCRYPT_SMIME_CAPABILITIES capabilities = pvStructInfo;
BOOL ret;
ret = CRYPT_AsnDecodeArray(&arrayDesc, pbEncoded, cbEncoded, dwFlags,
NULL, pvStructInfo, pcbStructInfo, pcbDecoded,
capabilities ? capabilities->rgCapability : NULL);
return ret;
}
static BOOL WINAPI CRYPT_AsnDecodeSMIMECapabilities(DWORD dwCertEncodingType, static BOOL WINAPI CRYPT_AsnDecodeSMIMECapabilities(DWORD dwCertEncodingType,
LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo)
@ -2528,11 +2512,14 @@ static BOOL WINAPI CRYPT_AsnDecodeSMIMECapabilities(DWORD dwCertEncodingType,
__TRY __TRY
{ {
DWORD bytesNeeded; DWORD bytesNeeded;
struct AsnArrayDescriptor arrayDesc = { ASN_SEQUENCEOF,
CRYPT_AsnDecodeSMIMECapability, sizeof(CRYPT_SMIME_CAPABILITY), TRUE,
offsetof(CRYPT_SMIME_CAPABILITY, pszObjId) };
if ((ret = CRYPT_AsnDecodeSMIMECapabilitiesInternal(pbEncoded, if ((ret = CRYPT_AsnDecodeArrayNoAlloc(&arrayDesc, pbEncoded, cbEncoded,
cbEncoded, dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, NULL, &bytesNeeded, NULL, NULL, &bytesNeeded, NULL)))
NULL)))
{ {
bytesNeeded += sizeof(CRYPT_SMIME_CAPABILITIES);
if (!pvStructInfo) if (!pvStructInfo)
*pcbStructInfo = bytesNeeded; *pcbStructInfo = bytesNeeded;
else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara,
@ -2546,9 +2533,9 @@ static BOOL WINAPI CRYPT_AsnDecodeSMIMECapabilities(DWORD dwCertEncodingType,
capabilities->rgCapability = capabilities->rgCapability =
(PCRYPT_SMIME_CAPABILITY)((BYTE *)pvStructInfo + (PCRYPT_SMIME_CAPABILITY)((BYTE *)pvStructInfo +
sizeof(CRYPT_SMIME_CAPABILITIES)); sizeof(CRYPT_SMIME_CAPABILITIES));
ret = CRYPT_AsnDecodeSMIMECapabilitiesInternal(pbEncoded, ret = CRYPT_AsnDecodeArrayNoAlloc(&arrayDesc,
cbEncoded, dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, pvStructInfo, pbEncoded, cbEncoded, &capabilities->cCapability,
&bytesNeeded, NULL); capabilities->rgCapability, pcbStructInfo, NULL);
} }
} }
} }