VirtualBox

Changeset 95678 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jul 17, 2022 11:50:03 AM (2 years ago)
Author:
vboxsync
Message:

RTSignTool: Nested .cat file signatures. bugref:8691

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/tools/RTSignTool.cpp

    r95676 r95678  
    172172typedef struct SIGNTOOLPKCS7
    173173{
     174    /** The file type. */
     175    RTSIGNTOOLFILETYPE          enmType;
    174176    /** The raw signature. */
    175177    uint8_t                    *pbBuf;
     
    908910    RT_ZERO(*pThis);
    909911    pThis->pszFilename = pszFilename;
     912    pThis->enmType     = RTSIGNTOOLFILETYPE_CAT;
    910913
    911914    /*
     
    12571260     */
    12581261    RT_ZERO(*pThis);
    1259     pThis->hLdrMod = NIL_RTLDRMOD;
     1262    pThis->hLdrMod     = NIL_RTLDRMOD;
    12601263    pThis->pszFilename = pszFilename;
     1264    pThis->enmType     = RTSIGNTOOLFILETYPE_EXE;
    12611265
    12621266    /*
     
    21962200
    21972201static RTEXITCODE SignToolPkcs7_SignData(SIGNTOOLPKCS7 *pThis, PRTASN1CORE pToSignRoot, SIGNDATATWEAK enmTweak,
    2198                                          const char *pszContentTypeId, unsigned cVerbosity, RTDIGESTTYPE enmSigType,
    2199                                          bool fReplaceExisting, bool fNoSigningTime,
     2202                                         const char *pszContentTypeId, unsigned cVerbosity, uint32_t fExtraFlags,
     2203                                         RTDIGESTTYPE enmSigType, bool fReplaceExisting, bool fNoSigningTime,
    22002204                                         SignToolKeyPair *pSigningCertKey, RTCRSTORE hAddCerts,
    22012205                                         bool fTimestampTypeOld, RTTIMESPEC SigningTime, SignToolKeyPair *pTimestampCertKey)
     
    22382242                /*
    22392243                 * Ditch the old signature if so desired.
     2244                 * (It is okay to do this in the CAT case too, as we've already
     2245                 * encoded the data and won't touch pToSignRoot any more.)
    22402246                 */
     2247                pToSignRoot = NULL; /* (may become invalid if replacing) */
    22412248                if (fReplaceExisting && pThis->pSignedData)
    22422249                {
     
    22512258                 * Do the actual signing.
    22522259                 */
    2253                 SIGNTOOLPKCS7  Src     = { NULL, 0, NULL };
     2260                SIGNTOOLPKCS7  Src     = { RTSIGNTOOLFILETYPE_DETECT, NULL, 0, NULL };
    22542261                PSIGNTOOLPKCS7 pSigDst = !pThis->pSignedData ? pThis : &Src;
    22552262                rcExit = SignToolPkcs7_Pkcs7SignStuff("image", pvToSign, cbToSign, &AuthAttribs, hAddCerts,
    2256                                                       RTCRPKCS7SIGN_SD_F_NO_DATA_ENCAP, enmSigType /** @todo ?? */,
     2263                                                      fExtraFlags | RTCRPKCS7SIGN_SD_F_NO_DATA_ENCAP, enmSigType /** @todo ?? */,
    22572264                                                      pSigningCertKey, cVerbosity,
    22582265                                                      (void **)&pSigDst->pbBuf, &pSigDst->cbBuf,
     
    25692576                    if (rcExit == RTEXITCODE_SUCCESS)
    25702577                        rcExit = SignToolPkcs7_SignData(pThis, RTCrSpcIndirectDataContent_GetAsn1Core(&SpcIndData),
    2571                                                         kSignDataTweak_NoTweak, RTCRSPCINDIRECTDATACONTENT_OID, cVerbosity,
     2578                                                        kSignDataTweak_NoTweak, RTCRSPCINDIRECTDATACONTENT_OID, cVerbosity, 0,
    25722579                                                        enmSigType, fReplaceExisting, fNoSigningTime, pSigningCertKey, hAddCerts,
    25732580                                                        fTimestampTypeOld, SigningTime, pTimestampCertKey);
     
    26012608     * Figure out what to sign first.
    26022609     */
    2603     PRTASN1CORE pToSign = &pThis->pSignedData->ContentInfo.Content.Asn1Core;
    2604     const char *pszType = pThis->pSignedData->ContentInfo.ContentType.szObjId;
     2610    uint32_t    fExtraFlags = 0;
     2611    PRTASN1CORE pToSign     = &pThis->pSignedData->ContentInfo.Content.Asn1Core;
     2612    const char *pszType     = pThis->pSignedData->ContentInfo.ContentType.szObjId;
     2613
     2614    if (!fReplaceExisting && pThis->pSignedData->SignerInfos.cItems == 0)
     2615        fReplaceExisting = true;
    26052616    if (!fReplaceExisting)
    26062617    {
    2607         if (pThis->pSignedData->SignerInfos.cItems == 0)
    2608             fReplaceExisting = false;
    2609         else
    2610         {
    2611             /** @todo figure out nested catalog signatures... It's marked as
    2612              * pkcs7-data and seems to be empty, i.e. it's detached. */
    2613             //pszType = RTCR_PKCS7_SIGNED_DATA_OID;
    2614             AssertFailedReturn(RTMsgErrorExitFailure("nested cat signing not implemented"));
    2615         }
     2618        pszType      = RTCR_PKCS7_DATA_OID;
     2619        fExtraFlags |= RTCRPKCS7SIGN_SD_F_DEATCHED;
    26162620    }
    26172621
     
    26202624     */
    26212625    RTEXITCODE rcExit = SignToolPkcs7_SignData(pThis, pToSign, kSignDataTweak_RootIsParent,
    2622                                                pszType, cVerbosity, enmSigType, fReplaceExisting,
     2626                                               pszType, cVerbosity, fExtraFlags, enmSigType, fReplaceExisting,
    26232627                                               fNoSigningTime, pSigningCertKey, hAddCerts,
    26242628                                               fTimestampTypeOld, SigningTime, pTimestampCertKey);
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