VirtualBox

Changeset 52500 in vbox for trunk/src


Ignore:
Timestamp:
Aug 26, 2014 1:04:43 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
95730
Message:

supR3HardenedWinIsDesiredRootCA: Changed to blacklisting, added more logging.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/win/SUPHardenedVerifyImage-win.cpp

    r52487 r52500  
    16841684static bool supR3HardenedWinIsDesiredRootCA(PCRTCRX509CERTIFICATE pCert)
    16851685{
     1686    char szSubject[512];
     1687    szSubject[sizeof(szSubject) - 1] = '\0';
     1688    RTCrX509Name_FormatAsString(&pCert->TbsCertificate.Subject, szSubject, sizeof(szSubject) - 1, NULL);
     1689
    16861690    /*
    16871691     * Check that it's a plausible root certificate.
    16881692     */
    16891693    if (!RTCrX509Certificate_IsSelfSigned(pCert))
     1694    {
     1695        SUP_DPRINTF(("supR3HardenedWinIsDesiredRootCA: skipping - not-self-signed: %s\n", szSubject));
    16901696        return false;
     1697    }
     1698
    16911699    if (RTAsn1Integer_UnsignedCompareWithU32(&pCert->TbsCertificate.T0.Version, 3) > 0)
    16921700    {
    16931701        if (   !(pCert->TbsCertificate.T3.fExtKeyUsage & RTCRX509CERT_KEY_USAGE_F_KEY_CERT_SIGN)
    16941702            && (pCert->TbsCertificate.T3.fFlags & RTCRX509TBSCERTIFICATE_F_PRESENT_KEY_USAGE) )
     1703        {
     1704            SUP_DPRINTF(("supR3HardenedWinIsDesiredRootCA: skipping - non-cert-sign: %s\n", szSubject));
    16951705            return false;
     1706        }
    16961707        if (   pCert->TbsCertificate.T3.pBasicConstraints
    16971708            && !pCert->TbsCertificate.T3.pBasicConstraints->CA.fValue)
     1709        {
     1710            SUP_DPRINTF(("supR3HardenedWinIsDesiredRootCA: skipping - non-CA: %s\n", szSubject));
    16981711            return false;
     1712        }
    16991713    }
    17001714    if (pCert->TbsCertificate.SubjectPublicKeyInfo.SubjectPublicKey.cBits < 256) /* mostly for u64KeyId reading. */
     1715    {
     1716        SUP_DPRINTF(("supR3HardenedWinIsDesiredRootCA: skipping - key too small: %u bits %s\n",
     1717                     pCert->TbsCertificate.SubjectPublicKeyInfo.SubjectPublicKey.cBits, szSubject));
    17011718        return false;
    1702 
    1703     /*
    1704      * Array of names and key clues of the certificates we want.
     1719    }
     1720    uint64_t const u64KeyId = pCert->TbsCertificate.SubjectPublicKeyInfo.SubjectPublicKey.uBits.pu64[1];
     1721
     1722# if 0
     1723    /*
     1724     * Whitelist - Array of names and key clues of the certificates we want.
    17051725     */
    17061726    static struct
     
    17551775
    17561776
    1757     uint64_t const u64KeyId = pCert->TbsCertificate.SubjectPublicKeyInfo.SubjectPublicKey.uBits.pu64[1];
    17581777    uint32_t i = RT_ELEMENTS(s_aWanted);
    17591778    while (i-- > 0)
     
    17611780            || s_aWanted[i].u64KeyId == UINT64_MAX)
    17621781            if (RTCrX509Name_MatchWithString(&pCert->TbsCertificate.Subject, s_aWanted[i].pszName))
     1782            {
     1783                SUP_DPRINTF(("supR3HardenedWinIsDesiredRootCA: Adding %#llx %s\n", u64KeyId, szSubject));
    17631784                return true;
    1764 
    1765 #ifdef DEBUG_bird
    1766     char szTmp[512];
    1767     szTmp[sizeof(szTmp) - 1] = '\0';
    1768     RTCrX509Name_FormatAsString(&pCert->TbsCertificate.Issuer, szTmp, sizeof(szTmp) - 1, NULL);
    1769     SUP_DPRINTF(("supR3HardenedWinIsDesiredRootCA: %#llx %s\n", u64KeyId, szTmp));
    1770 #endif
     1785            }
     1786
     1787    SUP_DPRINTF(("supR3HardenedWinIsDesiredRootCA: skipping %#llx %s\n", u64KeyId, szSubject));
    17711788    return false;
     1789# else
     1790    /*
     1791     * Blacklist approach.
     1792     */
     1793    static struct
     1794    {
     1795        uint64_t    u64KeyId;
     1796        const char *pszName;
     1797    } const s_aUnwanted[] =
     1798    {
     1799        { UINT64_C(0xffffffffffffffff), "C=US, O=U.S. Robots and Mechanical Men, Inc., OU=V.I.K.I." }, /* dummy entry */
     1800    };
     1801
     1802    uint32_t i = RT_ELEMENTS(s_aUnwanted);
     1803    while (i-- > 0)
     1804        if (   s_aUnwanted[i].u64KeyId == u64KeyId
     1805            || s_aUnwanted[i].u64KeyId == UINT64_MAX)
     1806            if (RTCrX509Name_MatchWithString(&pCert->TbsCertificate.Subject, s_aUnwanted[i].pszName))
     1807            {
     1808                SUP_DPRINTF(("supR3HardenedWinIsDesiredRootCA: skipping - blacklisted: %#llx %s\n", u64KeyId, szSubject));
     1809                return false;
     1810            }
     1811
     1812    SUP_DPRINTF(("supR3HardenedWinIsDesiredRootCA: Adding %#llx %s\n", u64KeyId, szSubject));
     1813    return true;
     1814# endif
    17721815}
    17731816
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette