VirtualBox

Changeset 74707 in vbox for trunk


Ignore:
Timestamp:
Oct 9, 2018 8:36:39 AM (6 years ago)
Author:
vboxsync
Message:

IPRT/ldr: Started on Mach-O code signature verification. bugref:9232

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/ldr.h

    r74654 r74707  
    11811181 *
    11821182 */
    1183 typedef DECLCALLBACK(int) FNRTLDRVALIDATESIGNEDDATA(RTLDRMOD hLdrMod, RTLDRSIGNATURETYPE enmSignature, void const *pvSignature, size_t cbSignature,
     1183typedef DECLCALLBACK(int) FNRTLDRVALIDATESIGNEDDATA(RTLDRMOD hLdrMod, RTLDRSIGNATURETYPE enmSignature,
     1184                                                    void const *pvSignature, size_t cbSignature,
    11841185                                                    PRTERRINFO pErrInfo, void *pvUser);
    11851186/** Pointer to a signature verification callback. */
  • trunk/src/VBox/Runtime/common/ldr/ldrMachO.cpp

    r74676 r74707  
    39663966
    39673967/**
     3968 * @interface_method_impl{RTLDROPS,pfnVerifySignature}
     3969 */
     3970static DECLCALLBACK(int)
     3971rtldrMachO_VerifySignature(PRTLDRMODINTERNAL pMod, PFNRTLDRVALIDATESIGNEDDATA pfnCallback, void *pvUser, PRTERRINFO pErrInfo)
     3972{
     3973#ifndef IPRT_WITHOUT_LDR_VERIFY
     3974    PRTLDRMODMACHO pThis = RT_FROM_MEMBER(pMod, RTLDRMODMACHO, Core);
     3975
     3976    int rc = rtldrMachO_LoadSignatureBlob(pThis);
     3977    if (RT_SUCCESS(rc))
     3978    {
     3979        RT_NOREF(pfnCallback, pvUser, pErrInfo);
     3980#if 0
     3981        int rc = rtldrPE_VerifySignatureImagePrecoditions(pModPe, pErrInfo);
     3982        if (RT_SUCCESS(rc))
     3983        {
     3984            PRTLDRPESIGNATURE pSignature = NULL;
     3985            rc = rtldrPE_VerifySignatureRead(pModPe, &pSignature, pErrInfo);
     3986            if (RT_SUCCESS(rc))
     3987            {
     3988                rc = rtldrPE_VerifySignatureDecode(pModPe, pSignature, pErrInfo);
     3989                if (RT_SUCCESS(rc))
     3990                    rc = rtldrPE_VerifySignatureValidateHash(pModPe, pSignature, pErrInfo);
     3991                if (RT_SUCCESS(rc))
     3992                {
     3993                    rc = pfnCallback(&pModPe->Core, RTLDRSIGNATURETYPE_PKCS7_SIGNED_DATA,
     3994                                     &pSignature->ContentInfo, sizeof(pSignature->ContentInfo),
     3995                                     pErrInfo, pvUser);
     3996                }
     3997                rtldrPE_VerifySignatureDestroy(pModPe, pSignature);
     3998            }
     3999        }
     4000#endif
     4001    }
     4002    return rc;
     4003#else
     4004    RT_NOREF_PV(pMod); RT_NOREF_PV(pfnCallback); RT_NOREF_PV(pvUser); RT_NOREF_PV(pErrInfo);
     4005    return VERR_NOT_SUPPORTED;
     4006#endif
     4007}
     4008
     4009
     4010/**
    39684011 * Operations for a Mach-O module interpreter.
    39694012 */
     
    39894032    rtldrMachO_ReadDbgInfo,
    39904033    rtldrMachO_QueryProp,
    3991     NULL /*pfnVerifySignature*/,
     4034    rtldrMachO_VerifySignature,
    39924035    NULL /*pfnHashImage*/,
    39934036    NULL /*pfnUnwindFrame*/,
  • trunk/src/VBox/Runtime/common/ldr/ldrPE.cpp

    r74638 r74707  
    28402840             *
    28412841             * Seems the difference between V1 and V2 page hash attributes is
    2842              * that v1 uses SHA-1 while v2 uses SHA-256. The data structures to
    2843              * be identical otherwise.  Initially we assumed the digest
     2842             * that v1 uses SHA-1 while v2 uses SHA-256. The data structures
     2843             * seems to be identical otherwise.  Initially we assumed the digest
    28442844             * algorithm was supposed to be RTCRSPCINDIRECTDATACONTENT::DigestInfo,
    28452845             * i.e. the same as for the whole image hash.  The initial approach
  • trunk/src/VBox/Runtime/tools/RTSignTool.cpp

    r74692 r74707  
    14211421
    14221422
     1423    RTTIMESPEC Now;
     1424    bool       fTriedNow = false;
    14231425    rc = RTLdrQueryProp(hLdrMod, RTLDRPROP_TIMESTAMP_SECONDS, &pState->uTimestamp, sizeof(pState->uTimestamp));
     1426    if (rc == VERR_NOT_FOUND)
     1427    {
     1428        fTriedNow = true;
     1429        pState->uTimestamp = RTTimeSpecGetSeconds(RTTimeNow(&Now));
     1430        rc = VINF_SUCCESS;
     1431    }
    14241432    if (RT_SUCCESS(rc))
    14251433    {
     
    14271435        if (RT_SUCCESS(rc))
    14281436            RTMsgInfo("'%s' is valid.\n", pszFilename);
    1429         else if (rc == VERR_CR_X509_CPV_NOT_VALID_AT_TIME)
    1430         {
    1431             RTTIMESPEC Now;
     1437        else if (rc == VERR_CR_X509_CPV_NOT_VALID_AT_TIME && !fTriedNow)
     1438        {
    14321439            pState->uTimestamp = RTTimeSpecGetSeconds(RTTimeNow(&Now));
    14331440            rc = RTLdrVerifySignature(hLdrMod, VerifyExeCallback, pState, RTErrInfoInitStatic(pStaticErrInfo));
Note: See TracChangeset for help on using the changeset viewer.

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