crypt32: Implement authority info access decoding.

This commit is contained in:
Juan Lang 2008-08-27 10:56:56 -07:00 committed by Alexandre Julliard
parent 7e848b6cdc
commit e594d24006
2 changed files with 51 additions and 3 deletions

View File

@ -2640,6 +2640,52 @@ static BOOL WINAPI CRYPT_AsnDecodeAuthorityKeyId2(DWORD dwCertEncodingType,
return ret; return ret;
} }
static BOOL CRYPT_AsnDecodeAccessDescription(const BYTE *pbEncoded,
DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo,
DWORD *pcbDecoded)
{
struct AsnDecodeSequenceItem items[] = {
{ 0, offsetof(CERT_ACCESS_DESCRIPTION, pszAccessMethod),
CRYPT_AsnDecodeOidInternal, sizeof(LPSTR), FALSE, TRUE,
offsetof(CERT_ACCESS_DESCRIPTION, pszAccessMethod), 0 },
{ 0, offsetof(CERT_ACCESS_DESCRIPTION, AccessLocation),
CRYPT_AsnDecodeAltNameEntry, sizeof(CERT_ALT_NAME_ENTRY), FALSE,
TRUE, offsetof(CERT_ACCESS_DESCRIPTION, AccessLocation.u.pwszURL), 0 },
};
CERT_ACCESS_DESCRIPTION *descr = (CERT_ACCESS_DESCRIPTION *)pvStructInfo;
return CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, descr ? descr->pszAccessMethod : NULL);
}
static BOOL WINAPI CRYPT_AsnDecodeAuthorityInfoAccess(DWORD dwCertEncodingType,
LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo)
{
BOOL ret;
TRACE("%p, %d, %08x, %p, %p, %d\n", pbEncoded, cbEncoded, dwFlags,
pDecodePara, pvStructInfo, *pcbStructInfo);
__TRY
{
struct AsnArrayDescriptor arrayDesc = { ASN_SEQUENCEOF,
CRYPT_AsnDecodeAccessDescription, sizeof(CERT_ACCESS_DESCRIPTION),
TRUE, offsetof(CERT_ACCESS_DESCRIPTION, pszAccessMethod) };
ret = CRYPT_AsnDecodeArray(&arrayDesc, pbEncoded, cbEncoded, dwFlags,
pDecodePara, pvStructInfo, pcbStructInfo, NULL, NULL);
}
__EXCEPT_PAGE_FAULT
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
__ENDTRY
return ret;
}
static BOOL CRYPT_AsnDecodePKCSContent(const BYTE *pbEncoded, DWORD cbEncoded, static BOOL CRYPT_AsnDecodePKCSContent(const BYTE *pbEncoded, DWORD cbEncoded,
DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo, DWORD *pcbDecoded) DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo, DWORD *pcbDecoded)
{ {
@ -4686,6 +4732,9 @@ static CryptDecodeObjectExFunc CRYPT_GetBuiltinDecoder(DWORD dwCertEncodingType,
case LOWORD(X509_AUTHORITY_KEY_ID2): case LOWORD(X509_AUTHORITY_KEY_ID2):
decodeFunc = CRYPT_AsnDecodeAuthorityKeyId2; decodeFunc = CRYPT_AsnDecodeAuthorityKeyId2;
break; break;
case LOWORD(X509_AUTHORITY_INFO_ACCESS):
decodeFunc = CRYPT_AsnDecodeAuthorityInfoAccess;
break;
case LOWORD(PKCS_CONTENT_INFO): case LOWORD(PKCS_CONTENT_INFO):
decodeFunc = CRYPT_AsnDecodePKCSContentInfo; decodeFunc = CRYPT_AsnDecodePKCSContentInfo;
break; break;
@ -4759,6 +4808,8 @@ static CryptDecodeObjectExFunc CRYPT_GetBuiltinDecoder(DWORD dwCertEncodingType,
decodeFunc = CRYPT_AsnDecodeIssuingDistPoint; decodeFunc = CRYPT_AsnDecodeIssuingDistPoint;
else if (!strcmp(lpszStructType, szOID_NAME_CONSTRAINTS)) else if (!strcmp(lpszStructType, szOID_NAME_CONSTRAINTS))
decodeFunc = CRYPT_AsnDecodeNameConstraints; decodeFunc = CRYPT_AsnDecodeNameConstraints;
else if (!strcmp(lpszStructType, szOID_AUTHORITY_INFO_ACCESS))
decodeFunc = CRYPT_AsnDecodeAuthorityInfoAccess;
return decodeFunc; return decodeFunc;
} }

View File

@ -4888,7 +4888,6 @@ static void test_decodeAuthorityInfoAccess(DWORD dwEncoding)
ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS,
emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL, emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL,
(BYTE *)&buf, &size); (BYTE *)&buf, &size);
todo_wine
ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
if (buf) if (buf)
{ {
@ -4902,7 +4901,6 @@ static void test_decodeAuthorityInfoAccess(DWORD dwEncoding)
ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS,
authorityInfoAccessWithUrl, sizeof(authorityInfoAccessWithUrl), authorityInfoAccessWithUrl, sizeof(authorityInfoAccessWithUrl),
CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size);
todo_wine
ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
if (buf) if (buf)
{ {
@ -4923,7 +4921,6 @@ static void test_decodeAuthorityInfoAccess(DWORD dwEncoding)
authorityInfoAccessWithUrlAndIPAddr, authorityInfoAccessWithUrlAndIPAddr,
sizeof(authorityInfoAccessWithUrlAndIPAddr), CRYPT_DECODE_ALLOC_FLAG, sizeof(authorityInfoAccessWithUrlAndIPAddr), CRYPT_DECODE_ALLOC_FLAG,
NULL, (BYTE *)&buf, &size); NULL, (BYTE *)&buf, &size);
todo_wine
ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
if (buf) if (buf)
{ {