crypt32: Support CRYPT_DECODE_TO_BE_SIGNED_FLAG.

This commit is contained in:
Juan Lang 2007-09-10 16:02:52 -07:00 committed by Alexandre Julliard
parent 41d057837c
commit d7115ce33c

View File

@ -893,28 +893,32 @@ static BOOL WINAPI CRYPT_AsnDecodeCert(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)
{ {
BOOL ret = TRUE; BOOL ret = FALSE;
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);
__TRY __TRY
{ {
PCERT_SIGNED_CONTENT_INFO signedCert = NULL;
DWORD size = 0; DWORD size = 0;
/* First try to decode it as a signed cert. */ /* Unless told not to, first try to decode it as a signed cert. */
ret = CRYPT_AsnDecodeCertSignedContent(dwCertEncodingType, X509_CERT, if (!(dwFlags & CRYPT_DECODE_TO_BE_SIGNED_FLAG))
pbEncoded, cbEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL,
(BYTE *)&signedCert, &size);
if (ret)
{ {
size = 0; PCERT_SIGNED_CONTENT_INFO signedCert = NULL;
ret = CRYPT_AsnDecodeCertInfo(dwCertEncodingType,
X509_CERT_TO_BE_SIGNED, signedCert->ToBeSigned.pbData, ret = CRYPT_AsnDecodeCertSignedContent(dwCertEncodingType,
signedCert->ToBeSigned.cbData, dwFlags, pDecodePara, pvStructInfo, X509_CERT, pbEncoded, cbEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL,
pcbStructInfo); (BYTE *)&signedCert, &size);
LocalFree(signedCert); if (ret)
{
size = 0;
ret = CRYPT_AsnDecodeCertInfo(dwCertEncodingType,
X509_CERT_TO_BE_SIGNED, signedCert->ToBeSigned.pbData,
signedCert->ToBeSigned.cbData, dwFlags, pDecodePara,
pvStructInfo, pcbStructInfo);
LocalFree(signedCert);
}
} }
/* Failing that, try it as an unsigned cert */ /* Failing that, try it as an unsigned cert */
if (!ret) if (!ret)
@ -928,7 +932,6 @@ static BOOL WINAPI CRYPT_AsnDecodeCert(DWORD dwCertEncodingType,
__EXCEPT_PAGE_FAULT __EXCEPT_PAGE_FAULT
{ {
SetLastError(STATUS_ACCESS_VIOLATION); SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
} }
__ENDTRY __ENDTRY
@ -1026,28 +1029,32 @@ static BOOL WINAPI CRYPT_AsnDecodeCRL(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)
{ {
BOOL ret = TRUE; BOOL ret = FALSE;
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);
__TRY __TRY
{ {
PCERT_SIGNED_CONTENT_INFO signedCrl = NULL;
DWORD size = 0; DWORD size = 0;
/* First try to decode it as a signed crl. */ /* Unless told not to, first try to decode it as a signed crl. */
ret = CRYPT_AsnDecodeCertSignedContent(dwCertEncodingType, X509_CERT, if (!(dwFlags & CRYPT_DECODE_TO_BE_SIGNED_FLAG))
pbEncoded, cbEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL,
(BYTE *)&signedCrl, &size);
if (ret)
{ {
size = 0; PCERT_SIGNED_CONTENT_INFO signedCrl = NULL;
ret = CRYPT_AsnDecodeCRLInfo(dwCertEncodingType,
X509_CERT_CRL_TO_BE_SIGNED, signedCrl->ToBeSigned.pbData, ret = CRYPT_AsnDecodeCertSignedContent(dwCertEncodingType,
signedCrl->ToBeSigned.cbData, dwFlags, pDecodePara, X509_CERT, pbEncoded, cbEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL,
pvStructInfo, pcbStructInfo); (BYTE *)&signedCrl, &size);
LocalFree(signedCrl); if (ret)
{
size = 0;
ret = CRYPT_AsnDecodeCRLInfo(dwCertEncodingType,
X509_CERT_CRL_TO_BE_SIGNED, signedCrl->ToBeSigned.pbData,
signedCrl->ToBeSigned.cbData, dwFlags, pDecodePara,
pvStructInfo, pcbStructInfo);
LocalFree(signedCrl);
}
} }
/* Failing that, try it as an unsigned crl */ /* Failing that, try it as an unsigned crl */
if (!ret) if (!ret)
@ -1061,7 +1068,6 @@ static BOOL WINAPI CRYPT_AsnDecodeCRL(DWORD dwCertEncodingType,
__EXCEPT_PAGE_FAULT __EXCEPT_PAGE_FAULT
{ {
SetLastError(STATUS_ACCESS_VIOLATION); SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
} }
__ENDTRY __ENDTRY