Changeset 64883 in vbox for trunk/src/VBox/Runtime/common/crypto/x509-certpaths.cpp
- Timestamp:
- Dec 15, 2016 3:26:20 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 112290
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/crypto/x509-certpaths.cpp
r64531 r64883 723 723 if (pThis->pUntrustedCertsSet) 724 724 { 725 uint32_t const cCerts= pThis->pUntrustedCertsSet->cItems;726 P CRTCRPKCS7CERT paCerts = pThis->pUntrustedCertsSet->paItems;725 uint32_t const cCerts = pThis->pUntrustedCertsSet->cItems; 726 PRTCRPKCS7CERT const *papCerts = pThis->pUntrustedCertsSet->papItems; 727 727 for (uint32_t i = 0; i < cCerts; i++) 728 if ( paCerts[i].enmChoice == RTCRPKCS7CERTCHOICE_X509 729 && RTCrX509Certificate_MatchSubjectOrAltSubjectByRfc5280(paCerts[i].u.pX509Cert, pIssuer)) 730 rtCrX509CertPathsAddIssuer(pThis, pNode, paCerts[i].u.pX509Cert, NULL, RTCRX509CERTPATHNODE_SRC_UNTRUSTED_SET); 728 { 729 PCRTCRPKCS7CERT pCert = papCerts[i]; 730 if ( pCert->enmChoice == RTCRPKCS7CERTCHOICE_X509 731 && RTCrX509Certificate_MatchSubjectOrAltSubjectByRfc5280(pCert->u.pX509Cert, pIssuer)) 732 rtCrX509CertPathsAddIssuer(pThis, pNode, pCert->u.pX509Cert, NULL, RTCRX509CERTPATHNODE_SRC_UNTRUSTED_SET); 733 } 731 734 } 732 735 } … … 1057 1060 { 1058 1061 for (uint32_t i = 0; i < pName->cItems; i++) 1059 for (uint32_t j = 0; j < pName->paItems[i].cItems; j++) 1060 { 1061 PRTCRX509ATTRIBUTETYPEANDVALUE pAttrib = &pName->paItems[i].paItems[j]; 1062 { 1063 PCRTCRX509RELATIVEDISTINGUISHEDNAME const pRdn = pName->papItems[i]; 1064 for (uint32_t j = 0; j < pRdn->cItems; j++) 1065 { 1066 PRTCRX509ATTRIBUTETYPEANDVALUE pAttrib = pRdn->papItems[j]; 1062 1067 1063 1068 const char *pszType = pAttrib->Type.szObjId; … … 1118 1123 rtDumpPrintf(pfnPrintfV, pvUser, "<not-string: uTag=%#x>", pAttrib->Value.u.Core.uTag); 1119 1124 } 1125 } 1120 1126 } 1121 1127 … … 1350 1356 * @param pThis The validator instance. 1351 1357 * @param cSubtrees The number of sub-trees to add. 1352 * @param paSubtrees Array of sub-trees to add. 1353 */ 1354 static bool rtCrX509CpvAddPermittedSubtrees(PRTCRX509CERTPATHSINT pThis, uint32_t cSubtrees, PCRTCRX509GENERALSUBTREE paSubtrees) 1358 * @param papSubtrees Array of sub-trees to add. 1359 */ 1360 static bool rtCrX509CpvAddPermittedSubtrees(PRTCRX509CERTPATHSINT pThis, uint32_t cSubtrees, 1361 PRTCRX509GENERALSUBTREE const *papSubtrees) 1355 1362 { 1356 1363 /* … … 1375 1382 for (uint32_t iSrc = 0; iSrc < cSubtrees; iSrc++) 1376 1383 { 1377 if (!rtCrX509CpvCheckSubtreeValidity(pThis, &paSubtrees[iSrc]))1384 if (!rtCrX509CpvCheckSubtreeValidity(pThis, papSubtrees[iSrc])) 1378 1385 return false; 1379 pThis->v.papPermittedSubtrees[iDst] = &paSubtrees[iSrc];1386 pThis->v.papPermittedSubtrees[iDst] = papSubtrees[iSrc]; 1380 1387 iDst++; 1381 1388 } … … 1383 1390 1384 1391 return true; 1392 } 1393 1394 1395 /** 1396 * Adds a one permitted sub-tree. 1397 * 1398 * We store reference to each individual sub-tree because we must support 1399 * intersection calculation. 1400 * 1401 * @returns success indiciator. 1402 * @param pThis The validator instance. 1403 * @param pSubtree Array of sub-trees to add. 1404 */ 1405 static bool rtCrX509CpvAddPermittedSubtree(PRTCRX509CERTPATHSINT pThis, PCRTCRX509GENERALSUBTREE pSubtree) 1406 { 1407 return rtCrX509CpvAddPermittedSubtrees(pThis, 1, (PRTCRX509GENERALSUBTREE const *)&pSubtree); 1385 1408 } 1386 1409 … … 1405 1428 } 1406 1429 1407 uint32_t cRight= pSubtrees->cItems;1408 P CRTCRX509GENERALSUBTREE paRight = pSubtrees->paItems;1430 uint32_t cRight = pSubtrees->cItems; 1431 PRTCRX509GENERALSUBTREE const *papRight = pSubtrees->papItems; 1409 1432 if (cRight == 0) 1410 1433 { … … 1417 1440 PCRTCRX509GENERALSUBTREE *papLeft = pThis->v.papPermittedSubtrees; 1418 1441 if (!cLeft) /* first name constraint, no initial constraint */ 1419 return rtCrX509CpvAddPermittedSubtrees(pThis, cRight, pa Right);1442 return rtCrX509CpvAddPermittedSubtrees(pThis, cRight, papRight); 1420 1443 1421 1444 /* … … 1431 1454 for (uint32_t iRight = 0; iRight < cRight; iRight++) 1432 1455 { 1433 if (!rtCrX509CpvCheckSubtreeValidity(pThis, &paRight[iRight]))1456 if (!rtCrX509CpvCheckSubtreeValidity(pThis, papRight[iRight])) 1434 1457 return false; 1435 1458 1436 RTCRX509GENERALNAMECHOICE const enmRightChoice = pa Right[iRight].Base.enmChoice;1459 RTCRX509GENERALNAMECHOICE const enmRightChoice = papRight[iRight]->Base.enmChoice; 1437 1460 afRightTags[enmRightChoice] = true; 1438 1461 … … 1441 1464 if (papLeft[iLeft]->Base.enmChoice == enmRightChoice) 1442 1465 { 1443 if (RTCrX509GeneralSubtree_Compare(papLeft[iLeft], &paRight[iRight]) == 0)1466 if (RTCrX509GeneralSubtree_Compare(papLeft[iLeft], papRight[iRight]) == 0) 1444 1467 { 1445 1468 if (!fHaveRight) 1446 1469 { 1447 1470 fHaveRight = true; 1448 rtCrX509CpvAddPermittedSubtree s(pThis, 1, papLeft[iLeft]);1471 rtCrX509CpvAddPermittedSubtree(pThis, papLeft[iLeft]); 1449 1472 } 1450 1473 } 1451 else if (RTCrX509GeneralSubtree_ConstraintMatch(papLeft[iLeft], &paRight[iRight]))1474 else if (RTCrX509GeneralSubtree_ConstraintMatch(papLeft[iLeft], papRight[iRight])) 1452 1475 { 1453 1476 if (!fHaveRight) 1454 1477 { 1455 1478 fHaveRight = true; 1456 rtCrX509CpvAddPermittedSubtree s(pThis, 1, &paRight[iRight]);1479 rtCrX509CpvAddPermittedSubtree(pThis, papRight[iRight]); 1457 1480 } 1458 1481 } 1459 else if (RTCrX509GeneralSubtree_ConstraintMatch( &paRight[iRight], papLeft[iLeft]))1460 rtCrX509CpvAddPermittedSubtree s(pThis, 1, papLeft[iLeft]);1482 else if (RTCrX509GeneralSubtree_ConstraintMatch(papRight[iRight], papLeft[iLeft])) 1483 rtCrX509CpvAddPermittedSubtree(pThis, papLeft[iLeft]); 1461 1484 } 1462 1485 } … … 1467 1490 for (uint32_t iLeft = 0; iLeft < cLeft; iLeft++) 1468 1491 if (!afRightTags[papLeft[iLeft]->Base.enmChoice]) 1469 rtCrX509CpvAddPermittedSubtree s(pThis, 1, papLeft[iLeft]);1492 rtCrX509CpvAddPermittedSubtree(pThis, papLeft[iLeft]); 1470 1493 1471 1494 /* … … 1541 1564 uint32_t j = pSubTrees->cItems; 1542 1565 while (j-- > 0) 1543 if ( RTCRX509GENERALNAME_IS_DIRECTORY_NAME(&pSubTrees->paItems[j].Base) 1544 && RTCrX509Name_ConstraintMatch(&pSubTrees->paItems[j].Base.u.pT4->DirectoryName, pName)) 1566 { 1567 PCRTCRX509GENERALSUBTREE const pSubTree = pSubTrees->papItems[j]; 1568 if ( RTCRX509GENERALNAME_IS_DIRECTORY_NAME(&pSubTree->Base) 1569 && RTCrX509Name_ConstraintMatch(&pSubTree->Base.u.pT4->DirectoryName, pName)) 1545 1570 return true; 1571 } 1546 1572 } 1547 1573 return false; … … 1566 1592 uint32_t j = pSubTrees->cItems; 1567 1593 while (j-- > 0) 1568 if (RTCrX509GeneralName_ConstraintMatch(&pSubTrees->pa Items[j].Base, pGeneralName))1594 if (RTCrX509GeneralName_ConstraintMatch(&pSubTrees->papItems[j]->Base, pGeneralName)) 1569 1595 return true; 1570 1596 } … … 1951 1977 if (pThis->pInitialPermittedSubtrees) 1952 1978 rtCrX509CpvAddPermittedSubtrees(pThis, pThis->pInitialPermittedSubtrees->cItems, 1953 pThis->pInitialPermittedSubtrees->pa Items);1979 pThis->pInitialPermittedSubtrees->papItems); 1954 1980 if (pThis->pInitialExcludedSubtrees) 1955 1981 rtCrX509CpvAddExcludedSubtrees(pThis, pThis->pInitialExcludedSubtrees); … … 2053 2079 uint32_t i = pAltSubjectName->cItems; 2054 2080 while (i-- > 0) 2055 if ( !rtCrX509CpvIsGeneralNamePermitted(pThis, &pAltSubjectName->paItems[i])2056 || rtCrX509CpvIsGeneralNameExcluded(pThis, &pAltSubjectName->paItems[i]))2081 if ( !rtCrX509CpvIsGeneralNamePermitted(pThis, pAltSubjectName->papItems[i]) 2082 || rtCrX509CpvIsGeneralNameExcluded(pThis, pAltSubjectName->papItems[i])) 2057 2083 return rtCrX509CpvFailed(pThis, VERR_CR_X509_CPV_ALT_NAME_NOT_PERMITTED, 2058 2084 "Alternative name #%u is is not permitted by current name constraints", i); … … 2081 2107 while (i-- > 0) 2082 2108 { 2083 PCRTCRX509POLICYQUALIFIERINFOS const pQualifiers = &pPolicies->pa Items[i].PolicyQualifiers;2084 PCRTASN1OBJID const pIdP = &pPolicies->pa Items[i].PolicyIdentifier;2109 PCRTCRX509POLICYQUALIFIERINFOS const pQualifiers = &pPolicies->papItems[i]->PolicyQualifiers; 2110 PCRTASN1OBJID const pIdP = &pPolicies->papItems[i]->PolicyIdentifier; 2085 2111 if (RTAsn1ObjId_CompareWithString(pIdP, RTCRX509_ID_CE_CP_ANY_POLICY_OID) == 0) 2086 2112 { … … 2132 2158 || (pNode->pParent && fSelfIssued) ) ) 2133 2159 { 2134 PCRTCRX509POLICYQUALIFIERINFOS pApQ = &pPolicies->pa Items[iAnyPolicy].PolicyQualifiers;2160 PCRTCRX509POLICYQUALIFIERINFOS pApQ = &pPolicies->papItems[iAnyPolicy]->PolicyQualifiers; 2135 2161 RTListForEach(pListAbove, pCur, RTCRX509CERTPATHSPOLICYNODE, DepthEntry) 2136 2162 { … … 2183 2209 while (i-- > 0) 2184 2210 { 2185 if (RTAsn1ObjId_CompareWithString(&pPolicyMappings->paItems[i].IssuerDomainPolicy, RTCRX509_ID_CE_CP_ANY_POLICY_OID) == 0) 2211 PCRTCRX509POLICYMAPPING const pOne = pPolicyMappings->papItems[i]; 2212 if (RTAsn1ObjId_CompareWithString(&pOne->IssuerDomainPolicy, RTCRX509_ID_CE_CP_ANY_POLICY_OID) == 0) 2186 2213 return rtCrX509CpvFailed(pThis, VERR_CR_X509_CPV_INVALID_POLICY_MAPPING, 2187 2214 "Invalid policy mapping %#u: IssuerDomainPolicy is anyPolicy.", i); 2188 2215 2189 if (RTAsn1ObjId_CompareWithString(&p PolicyMappings->paItems[i].SubjectDomainPolicy, RTCRX509_ID_CE_CP_ANY_POLICY_OID) == 0)2216 if (RTAsn1ObjId_CompareWithString(&pOne->SubjectDomainPolicy, RTCRX509_ID_CE_CP_ANY_POLICY_OID) == 0) 2190 2217 return rtCrX509CpvFailed(pThis, VERR_CR_X509_CPV_INVALID_POLICY_MAPPING, 2191 2218 "Invalid policy mapping %#u: SubjectDomainPolicy is anyPolicy.", i); … … 2201 2228 while (i-- > 0) 2202 2229 { 2230 PCRTCRX509POLICYMAPPING const pOne = pPolicyMappings->papItems[i]; 2231 2203 2232 uint32_t cFound = 0; 2204 2233 RTListForEach(&pThis->v.paValidPolicyDepthLists[iDepth], pCur, RTCRX509CERTPATHSPOLICYNODE, DepthEntry) 2205 2234 { 2206 if (RTAsn1ObjId_Compare(pCur->pValidPolicy, &p PolicyMappings->paItems[i].IssuerDomainPolicy))2235 if (RTAsn1ObjId_Compare(pCur->pValidPolicy, &pOne->IssuerDomainPolicy)) 2207 2236 { 2208 2237 if (!pCur->fAlreadyMapped) 2209 2238 { 2210 2239 pCur->fAlreadyMapped = true; 2211 pCur->pExpectedPolicyFirst = &p PolicyMappings->paItems[i].SubjectDomainPolicy;2240 pCur->pExpectedPolicyFirst = &pOne->SubjectDomainPolicy; 2212 2241 } 2213 2242 else … … 2221 2250 pCur->cMoreExpectedPolicySet, iDepth); 2222 2251 pCur->papMoreExpectedPolicySet = (PCRTASN1OBJID *)pvNew; 2223 pCur->papMoreExpectedPolicySet[iExpected] = &p PolicyMappings->paItems[i].SubjectDomainPolicy;2252 pCur->papMoreExpectedPolicySet[iExpected] = &pOne->SubjectDomainPolicy; 2224 2253 pCur->cMoreExpectedPolicySet = iExpected + 1; 2225 2254 } … … 2238 2267 { 2239 2268 if (!rtCrX509CpvPolicyTreeInsertNew(pThis, pCur->pParent, iDepth, 2240 &p PolicyMappings->paItems[i].IssuerDomainPolicy,2269 &pOne->IssuerDomainPolicy, 2241 2270 pCur->pPolicyQualifiers, 2242 &p PolicyMappings->paItems[i].SubjectDomainPolicy))2271 &pOne->SubjectDomainPolicy)) 2243 2272 return false; 2244 2273 break; … … 2258 2287 while (i-- > 0) 2259 2288 { 2289 PCRTCRX509POLICYMAPPING const pOne = pPolicyMappings->papItems[i]; 2260 2290 RTListForEachSafe(&pThis->v.paValidPolicyDepthLists[iDepth], pCur, pNext, RTCRX509CERTPATHSPOLICYNODE, DepthEntry) 2261 2291 { 2262 if (RTAsn1ObjId_Compare(pCur->pValidPolicy, &p PolicyMappings->paItems[i].IssuerDomainPolicy))2292 if (RTAsn1ObjId_Compare(pCur->pValidPolicy, &pOne->IssuerDomainPolicy)) 2263 2293 { 2264 2294 rtCrX509CpvPolicyTreeDestroyNode(pThis, pCur); … … 2410 2440 static bool rtCrX509CpvCheckCriticalExtensions(PRTCRX509CERTPATHSINT pThis, PRTCRX509CERTPATHNODE pNode) 2411 2441 { 2412 uint32_t cLeft = pNode->pCert->TbsCertificate.T3.Extensions.cItems;2413 P CRTCRX509EXTENSION pCur = pNode->pCert->TbsCertificate.T3.Extensions.paItems;2442 uint32_t cLeft = pNode->pCert->TbsCertificate.T3.Extensions.cItems; 2443 PRTCRX509EXTENSION const *ppCur = pNode->pCert->TbsCertificate.T3.Extensions.papItems; 2414 2444 while (cLeft-- > 0) 2415 2445 { 2446 PCRTCRX509EXTENSION const pCur = *ppCur; 2416 2447 if (pCur->Critical.fValue) 2417 2448 { … … 2431 2462 } 2432 2463 2433 p Cur++;2464 ppCur++; 2434 2465 } 2435 2466
Note:
See TracChangeset
for help on using the changeset viewer.