crypt32: Implement encoding cert policy constraints.
This commit is contained in:
parent
ae32f7bffc
commit
32ad424972
|
@ -3048,6 +3048,53 @@ static BOOL WINAPI CRYPT_AsnEncodeCertPolicyMappings(DWORD dwCertEncodingType,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL WINAPI CRYPT_AsnEncodeCertPolicyConstraints(
|
||||||
|
DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo,
|
||||||
|
DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded,
|
||||||
|
DWORD *pcbEncoded)
|
||||||
|
{
|
||||||
|
BOOL ret = FALSE;
|
||||||
|
|
||||||
|
__TRY
|
||||||
|
{
|
||||||
|
const CERT_POLICY_CONSTRAINTS_INFO *info = pvStructInfo;
|
||||||
|
struct AsnEncodeSequenceItem items[2];
|
||||||
|
struct AsnEncodeTagSwappedItem swapped[2];
|
||||||
|
DWORD cItem = 0, cSwapped = 0;
|
||||||
|
|
||||||
|
if (info->fRequireExplicitPolicy)
|
||||||
|
{
|
||||||
|
swapped[cSwapped].tag = ASN_CONTEXT | 0;
|
||||||
|
swapped[cSwapped].pvStructInfo =
|
||||||
|
&info->dwRequireExplicitPolicySkipCerts;
|
||||||
|
swapped[cSwapped].encodeFunc = CRYPT_AsnEncodeInt;
|
||||||
|
items[cItem].pvStructInfo = &swapped[cSwapped];
|
||||||
|
items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
|
||||||
|
cSwapped++;
|
||||||
|
cItem++;
|
||||||
|
}
|
||||||
|
if (info->fInhibitPolicyMapping)
|
||||||
|
{
|
||||||
|
swapped[cSwapped].tag = ASN_CONTEXT | 1;
|
||||||
|
swapped[cSwapped].pvStructInfo =
|
||||||
|
&info->dwInhibitPolicyMappingSkipCerts;
|
||||||
|
swapped[cSwapped].encodeFunc = CRYPT_AsnEncodeInt;
|
||||||
|
items[cItem].pvStructInfo = &swapped[cSwapped];
|
||||||
|
items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
|
||||||
|
cSwapped++;
|
||||||
|
cItem++;
|
||||||
|
}
|
||||||
|
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, cItem,
|
||||||
|
dwFlags, NULL, pbEncoded, pcbEncoded);
|
||||||
|
}
|
||||||
|
__EXCEPT_PAGE_FAULT
|
||||||
|
{
|
||||||
|
SetLastError(STATUS_ACCESS_VIOLATION);
|
||||||
|
}
|
||||||
|
__ENDTRY
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static BOOL WINAPI CRYPT_AsnEncodeRsaPubKey(DWORD dwCertEncodingType,
|
static BOOL WINAPI CRYPT_AsnEncodeRsaPubKey(DWORD dwCertEncodingType,
|
||||||
LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags,
|
LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags,
|
||||||
PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
|
PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
|
||||||
|
@ -4413,6 +4460,9 @@ static CryptEncodeObjectExFunc CRYPT_GetBuiltinEncoder(DWORD dwCertEncodingType,
|
||||||
case LOWORD(X509_POLICY_MAPPINGS):
|
case LOWORD(X509_POLICY_MAPPINGS):
|
||||||
encodeFunc = CRYPT_AsnEncodeCertPolicyMappings;
|
encodeFunc = CRYPT_AsnEncodeCertPolicyMappings;
|
||||||
break;
|
break;
|
||||||
|
case LOWORD(X509_POLICY_CONSTRAINTS):
|
||||||
|
encodeFunc = CRYPT_AsnEncodeCertPolicyConstraints;
|
||||||
|
break;
|
||||||
case LOWORD(PKCS7_SIGNER_INFO):
|
case LOWORD(PKCS7_SIGNER_INFO):
|
||||||
encodeFunc = CRYPT_AsnEncodePKCSSignerInfo;
|
encodeFunc = CRYPT_AsnEncodePKCSSignerInfo;
|
||||||
break;
|
break;
|
||||||
|
@ -4459,6 +4509,8 @@ static CryptEncodeObjectExFunc CRYPT_GetBuiltinEncoder(DWORD dwCertEncodingType,
|
||||||
encodeFunc = CRYPT_AsnEncodeCertPolicies;
|
encodeFunc = CRYPT_AsnEncodeCertPolicies;
|
||||||
else if (!strcmp(lpszStructType, szOID_POLICY_MAPPINGS))
|
else if (!strcmp(lpszStructType, szOID_POLICY_MAPPINGS))
|
||||||
encodeFunc = CRYPT_AsnEncodeCertPolicyMappings;
|
encodeFunc = CRYPT_AsnEncodeCertPolicyMappings;
|
||||||
|
else if (!strcmp(lpszStructType, szOID_POLICY_CONSTRAINTS))
|
||||||
|
encodeFunc = CRYPT_AsnEncodeCertPolicyConstraints;
|
||||||
else if (!strcmp(lpszStructType, szOID_ENHANCED_KEY_USAGE))
|
else if (!strcmp(lpszStructType, szOID_ENHANCED_KEY_USAGE))
|
||||||
encodeFunc = CRYPT_AsnEncodeEnhancedKeyUsage;
|
encodeFunc = CRYPT_AsnEncodeEnhancedKeyUsage;
|
||||||
else if (!strcmp(lpszStructType, szOID_ISSUING_DIST_POINT))
|
else if (!strcmp(lpszStructType, szOID_ISSUING_DIST_POINT))
|
||||||
|
|
|
@ -7576,7 +7576,6 @@ static void test_encodeCertPolicyConstraints(DWORD dwEncoding)
|
||||||
*/
|
*/
|
||||||
ret = pCryptEncodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, &info,
|
ret = pCryptEncodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, &info,
|
||||||
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
|
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
|
||||||
todo_wine {
|
|
||||||
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
|
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
|
@ -7631,7 +7630,6 @@ static void test_encodeCertPolicyConstraints(DWORD dwEncoding)
|
||||||
LocalFree(buf);
|
LocalFree(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static void test_decodeCertPolicyConstraints(DWORD dwEncoding)
|
static void test_decodeCertPolicyConstraints(DWORD dwEncoding)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue