VirtualBox

vbox的更動 51862 路徑 trunk/src/VBox/Runtime/common


忽略:
時間撮記:
2014-7-3 下午11:51:54 (10 年 以前)
作者:
vboxsync
訊息:

page hash updates.

位置:
trunk/src/VBox/Runtime/common
檔案:
修改 4 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Runtime/common/crypto/spc-core.cpp

    r51770 r51862  
    3939
    4040
    41 RTDECL(int) RTCrSpcSerializedPageHashesV2_UpdateDerivedData(PRTCRSPCSERIALIZEDPAGEHASHESV2 pThis)
     41RTDECL(int) RTCrSpcSerializedPageHashes_UpdateDerivedData(PRTCRSPCSERIALIZEDPAGEHASHES pThis)
    4242{
    43     pThis->pData = (PCRTCRSPCPEIMAGEPAGEHASHESV2)pThis->RawData.Asn1Core.uData.pv;
     43    pThis->pData = (PCRTCRSPCPEIMAGEPAGEHASHES)pThis->RawData.Asn1Core.uData.pv;
    4444    return VINF_SUCCESS;
    4545}
     
    5050 */
    5151
    52 RTDECL(PCRTCRSPCSERIALIZEDOBJECTATTRIBUTE) RTCrSpcIndirectDataContent_GetPeImageHashesV2(PCRTCRSPCINDIRECTDATACONTENT pIndData)
     52RTDECL(PCRTCRSPCSERIALIZEDOBJECTATTRIBUTE)
     53RTCrSpcIndirectDataContent_GetPeImageObjAttrib(PCRTCRSPCINDIRECTDATACONTENT pThis,
     54                                               RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE enmType)
    5355{
    54     if (pIndData->Data.enmType == RTCRSPCAAOVTYPE_PE_IMAGE_DATA)
     56    if (pThis->Data.enmType == RTCRSPCAAOVTYPE_PE_IMAGE_DATA)
    5557    {
    56         Assert(RTAsn1ObjId_CompareWithString(&pIndData->Data.Type, RTCRSPCPEIMAGEDATA_OID) == 0);
     58        Assert(RTAsn1ObjId_CompareWithString(&pThis->Data.Type, RTCRSPCPEIMAGEDATA_OID) == 0);
    5759
    58         if (   pIndData->Data.uValue.pPeImage
    59             && pIndData->Data.uValue.pPeImage->T0.File.enmChoice == RTCRSPCLINKCHOICE_MONIKER
    60             && RTCrSpcSerializedObject_IsPresent(pIndData->Data.uValue.pPeImage->T0.File.u.pMoniker) )
     60        if (   pThis->Data.uValue.pPeImage
     61            && pThis->Data.uValue.pPeImage->T0.File.enmChoice == RTCRSPCLINKCHOICE_MONIKER
     62            && RTCrSpcSerializedObject_IsPresent(pThis->Data.uValue.pPeImage->T0.File.u.pMoniker) )
    6163        {
    62             if (pIndData->Data.uValue.pPeImage->T0.File.u.pMoniker->enmType == RTCRSPCSERIALIZEDOBJECTTYPE_ATTRIBUTES)
     64            if (pThis->Data.uValue.pPeImage->T0.File.u.pMoniker->enmType == RTCRSPCSERIALIZEDOBJECTTYPE_ATTRIBUTES)
    6365            {
    64                 Assert(RTUuidCompareStr(pIndData->Data.uValue.pPeImage->T0.File.u.pMoniker->Uuid.Asn1Core.uData.pUuid,
     66                Assert(RTUuidCompareStr(pThis->Data.uValue.pPeImage->T0.File.u.pMoniker->Uuid.Asn1Core.uData.pUuid,
    6567                                        RTCRSPCSERIALIZEDOBJECT_UUID_STR) == 0);
    66                 PCRTCRSPCSERIALIZEDOBJECTATTRIBUTES pData = pIndData->Data.uValue.pPeImage->T0.File.u.pMoniker->u.pData;
     68                PCRTCRSPCSERIALIZEDOBJECTATTRIBUTES pData = pThis->Data.uValue.pPeImage->T0.File.u.pMoniker->u.pData;
    6769                if (pData)
    68                 {
    6970                    for (uint32_t i = 0; i < pData->cItems; i++)
    70                     {
    71                         if (pData->paItems[i].enmType == RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE_PAGE_HASHES_V2)
    72                         {
    73                             Assert(RTAsn1ObjId_CompareWithString(&pData->paItems[i].Type, RTCRSPC_PE_IMAGE_HASHES_V2_OID) == 0);
     71                        if (pData->paItems[i].enmType == enmType)
    7472                            return &pData->paItems[i];
    75                         }
    76                     }
    77                 }
    7873            }
    7974        }
  • trunk/src/VBox/Runtime/common/crypto/spc-sanity.cpp

    r51770 r51862  
    123123                                    "SpcIndirectDataContent...pMoniker->pData is NULL.");
    124124
    125             uint32_t cPageHashV1 = 0;
    126             uint32_t cPageHashV2 = 0;
     125            uint32_t cPageHashTabs = 0;
    127126            for (uint32_t i = 0; i < pObj->u.pData->cItems; i++)
    128127            {
    129128                PCRTCRSPCSERIALIZEDOBJECTATTRIBUTE pAttr = &pObj->u.pData->paItems[i];
    130                 if (RTAsn1ObjId_CompareWithString(&pAttr->Type, RTCRSPC_PE_IMAGE_HASHES_V2_OID) == 0)
     129                if (   RTAsn1ObjId_CompareWithString(&pAttr->Type, RTCRSPC_PE_IMAGE_HASHES_V1_OID) == 0
     130                    || RTAsn1ObjId_CompareWithString(&pAttr->Type, RTCRSPC_PE_IMAGE_HASHES_V2_OID) == 0 )
    131131                {
    132                     if (cPageHashV2 > 0)
    133                         return RTErrInfoSetF(pErrInfo, VERR_CR_SPC_PEIMAGE_MULTIPLE_V2_HASH_TABS,
    134                                              "SpcIndirectDataContent...MonikerT1 multiple page hash v2 attributes (%u).", i);
    135                     cPageHashV2++;
    136                     AssertPtr(pAttr->u.pPageHashesV2->pData);
    137                 }
    138                 else if (RTAsn1ObjId_CompareWithString(&pAttr->Type, RTCRSPC_PE_IMAGE_HASHES_V1_OID) == 0)
    139                 {
    140 #if 1
    141                     return RTErrInfoSetF(pErrInfo, VERR_CR_SPC_PEIMAGE_V1_HASH_TABS_NOT_IMPL,
    142                                          "SpcIndirectDataContent...MonikerT1 implement page hash v1 attributes (%u).", i);
    143 #else
    144                     if (cPageHashV1 > 0)
    145                         return RTErrInfoSetF(pErrInfo, VERR_CR_SPC_PEIMAGE_MULTIPLE_V1_HASH_TABS,
    146                                              "SpcIndirectDataContent...MonikerT1 multiple page hash v1 attributes (%u).", i);
    147                     cPageHashV1++;
    148 #endif
     132                    cPageHashTabs++;
     133                    AssertPtr(pAttr->u.pPageHashes->pData);
    149134                }
    150135                else
     
    153138                                         i, pAttr->Type.szObjId);
    154139            }
     140            if (cPageHashTabs > 0)
     141                return RTErrInfoSetF(pErrInfo, VERR_CR_SPC_PEIMAGE_MULTIPLE_HASH_TABS,
     142                                     "SpcIndirectDataContent...MonikerT1 multiple page hash attributes (%u).", cPageHashTabs);
     143
    155144        }
    156145        else if (   pIndData->Data.uValue.pPeImage->T0.File.enmChoice == RTCRSPCLINKCHOICE_FILE
  • trunk/src/VBox/Runtime/common/crypto/spc-template.h

    r51770 r51862  
    3131 * One SPC Serialized Page Hashes V2 Object.
    3232 */
    33 #define RTASN1TMPL_TYPE         RTCRSPCSERIALIZEDPAGEHASHESV2
    34 #define RTASN1TMPL_EXT_NAME     RTCrSpcSerializedPageHashesV2
    35 #define RTASN1TMPL_INT_NAME     rtCrSpcSerializedPageHashesV2
     33#define RTASN1TMPL_TYPE         RTCRSPCSERIALIZEDPAGEHASHES
     34#define RTASN1TMPL_EXT_NAME     RTCrSpcSerializedPageHashes
     35#define RTASN1TMPL_INT_NAME     rtCrSpcSerializedPageHashes
    3636RTASN1TMPL_BEGIN_SETCORE();
    3737RTASN1TMPL_MEMBER(              RawData,               RTASN1OCTETSTRING,           RTAsn1OctetString);
    38 RTASN1TMPL_EXEC_DECODE(         rc = RTCrSpcSerializedPageHashesV2_UpdateDerivedData(pThis) ) /* no ; */
    39 RTASN1TMPL_EXEC_CLONE(          rc = RTCrSpcSerializedPageHashesV2_UpdateDerivedData(pThis) ) /* no ; */
     38RTASN1TMPL_EXEC_DECODE(         rc = RTCrSpcSerializedPageHashes_UpdateDerivedData(pThis) ) /* no ; */
     39RTASN1TMPL_EXEC_CLONE(          rc = RTCrSpcSerializedPageHashes_UpdateDerivedData(pThis) ) /* no ; */
    4040RTASN1TMPL_END_SETCORE();
    4141#undef RTASN1TMPL_TYPE
     
    5353RTASN1TMPL_MEMBER(              Type,               RTASN1OBJID,                    RTAsn1ObjId);
    5454RTASN1TMPL_MEMBER_DYN_BEGIN(    RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE, enmType, Allocation);
    55 RTASN1TMPL_MEMBER_DYN(          u, pPageHashesV2, RTCRSPCSERIALIZEDPAGEHASHESV2, RTCrSpcSerializedPageHashesV2, Allocation, enmType,
     55RTASN1TMPL_MEMBER_DYN(          u, pPageHashes, RTCRSPCSERIALIZEDPAGEHASHES, RTCrSpcSerializedPageHashes, Allocation, enmType,
     56    RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE_PAGE_HASHES_V1, RTAsn1ObjId_CompareWithString(&pThis->Type, RTCRSPC_PE_IMAGE_HASHES_V1_OID) == 0);
     57RTASN1TMPL_MEMBER_DYN(          u, pPageHashes, RTCRSPCSERIALIZEDPAGEHASHES, RTCrSpcSerializedPageHashes, Allocation, enmType,
    5658    RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE_PAGE_HASHES_V2, RTAsn1ObjId_CompareWithString(&pThis->Type, RTCRSPC_PE_IMAGE_HASHES_V2_OID) == 0);
    5759RTASN1TMPL_MEMBER_DYN_DEFAULT(  u, pCore, RTASN1CORE, RTAsn1Core, Allocation, enmType, RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE_UNKNOWN);
  • trunk/src/VBox/Runtime/common/ldr/ldrPE.cpp

    r51837 r51862  
    21362136
    21372137
    2138 static int rtldrPE_VerifyAllPageHashesV2(PRTLDRMODPE pModPe, PCRTCRSPCSERIALIZEDOBJECTATTRIBUTE pAttrib, RTDIGESTTYPE enmDigest,
    2139                                          void *pvScratch, size_t cbScratch, PRTERRINFO pErrInfo)
     2138static int rtldrPE_VerifyAllPageHashes(PRTLDRMODPE pModPe, PCRTCRSPCSERIALIZEDOBJECTATTRIBUTE pAttrib, RTDIGESTTYPE enmDigest,
     2139                                       void *pvScratch, size_t cbScratch, PRTERRINFO pErrInfo)
    21402140{
    21412141    AssertReturn(cbScratch >= _4K, VERR_INTERNAL_ERROR_3);
     
    21442144     * Calculate the special places.
    21452145     */
    2146     RTLDRPEHASHSPECIALS SpecialPlaces;
     2146    RTLDRPEHASHSPECIALS SpecialPlaces = { 0, 0, 0, 0, 0, 0 }; /* shut up gcc */
    21472147    int rc = rtldrPe_CalcSpecialHashPlaces(pModPe, &SpecialPlaces, pErrInfo);
    21482148    if (RT_FAILURE(rc))
     
    21502150
    21512151    uint32_t const cbHash = rtLdrPE_HashGetHashSize(enmDigest);
    2152     uint32_t const cPages = pAttrib->u.pPageHashesV2->RawData.Asn1Core.cb / (cbHash + 4);
    2153     if (cPages * (cbHash + 4) != pAttrib->u.pPageHashesV2->RawData.Asn1Core.cb)
     2152    uint32_t const cPages = pAttrib->u.pPageHashes->RawData.Asn1Core.cb / (cbHash + 4);
     2153    if (cPages * (cbHash + 4) != pAttrib->u.pPageHashes->RawData.Asn1Core.cb)
    21542154        return RTErrInfoSetF(pErrInfo, VERR_LDRVI_PAGE_HASH_TAB_SIZE_OVERFLOW,
    21552155                             "Page Hashes V2 size issue: cb=%#x cbHash=%#x",
    2156                              pAttrib->u.pPageHashesV2->RawData.Asn1Core.cb, cbHash);
     2156                             pAttrib->u.pPageHashes->RawData.Asn1Core.cb, cbHash);
    21572157
    21582158    /*
     
    21662166    uint32_t        offSectEnd = pModPe->cbHeaders;
    21672167    uint32_t        iSh        = UINT32_MAX;
    2168     uint8_t const  *pbHashTab  = pAttrib->u.pPageHashesV2->RawData.Asn1Core.uData.pu8;
     2168    uint8_t const  *pbHashTab  = pAttrib->u.pPageHashes->RawData.Asn1Core.uData.pu8;
    21692169    for (uint32_t iPage = 0; iPage < cPages; iPage++)
    21702170    {
     
    23572357            /*
    23582358             * Compare the page hashes if present.
     2359             *
     2360             * Seems the difference between V1 and V2 page hash attributes is
     2361             * that v1 uses SHA-1 while v2 uses SHA-256. The data structures to
     2362             * be identical otherwise.  Initially we assumed the digest
     2363             * algorithm was supposed to be RTCRSPCINDIRECTDATACONTENT::DigestInfo,
     2364             * i.e. the same as for the whole image hash.  The initial approach
     2365             * worked just fine, but this makes more sense.
     2366             *
     2367             * (See also comments in osslsigncode.c (google it).)
    23592368             */
    2360             PCRTCRSPCSERIALIZEDOBJECTATTRIBUTE pAttrib = RTCrSpcIndirectDataContent_GetPeImageHashesV2(pSignature->pIndData);
     2369            PCRTCRSPCSERIALIZEDOBJECTATTRIBUTE pAttrib;
     2370            pAttrib = RTCrSpcIndirectDataContent_GetPeImageObjAttrib(pSignature->pIndData,
     2371                                                                     RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE_PAGE_HASHES_V2);
    23612372            if (pAttrib)
    2362                 rc = rtldrPE_VerifyAllPageHashesV2(pModPe, pAttrib, pSignature->enmDigest, pvScratch, cbScratch, pErrInfo);
    2363 
     2373                rc = rtldrPE_VerifyAllPageHashes(pModPe, pAttrib, RTDIGESTTYPE_SHA256, pvScratch, cbScratch, pErrInfo);
     2374            else
     2375            {
     2376                pAttrib = RTCrSpcIndirectDataContent_GetPeImageObjAttrib(pSignature->pIndData,
     2377                                                                         RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE_PAGE_HASHES_V1);
     2378                if (pAttrib)
     2379                    rc = rtldrPE_VerifyAllPageHashes(pModPe, pAttrib, RTDIGESTTYPE_SHA1, pvScratch, cbScratch, pErrInfo);
     2380            }
    23642381            return rc;
    23652382        }
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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