Changeset 95678 in vbox for trunk/src/VBox
- Timestamp:
- Jul 17, 2022 11:50:03 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/tools/RTSignTool.cpp
r95676 r95678 172 172 typedef struct SIGNTOOLPKCS7 173 173 { 174 /** The file type. */ 175 RTSIGNTOOLFILETYPE enmType; 174 176 /** The raw signature. */ 175 177 uint8_t *pbBuf; … … 908 910 RT_ZERO(*pThis); 909 911 pThis->pszFilename = pszFilename; 912 pThis->enmType = RTSIGNTOOLFILETYPE_CAT; 910 913 911 914 /* … … 1257 1260 */ 1258 1261 RT_ZERO(*pThis); 1259 pThis->hLdrMod = NIL_RTLDRMOD;1262 pThis->hLdrMod = NIL_RTLDRMOD; 1260 1263 pThis->pszFilename = pszFilename; 1264 pThis->enmType = RTSIGNTOOLFILETYPE_EXE; 1261 1265 1262 1266 /* … … 2196 2200 2197 2201 static 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, 2200 2204 SignToolKeyPair *pSigningCertKey, RTCRSTORE hAddCerts, 2201 2205 bool fTimestampTypeOld, RTTIMESPEC SigningTime, SignToolKeyPair *pTimestampCertKey) … … 2238 2242 /* 2239 2243 * 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.) 2240 2246 */ 2247 pToSignRoot = NULL; /* (may become invalid if replacing) */ 2241 2248 if (fReplaceExisting && pThis->pSignedData) 2242 2249 { … … 2251 2258 * Do the actual signing. 2252 2259 */ 2253 SIGNTOOLPKCS7 Src = { NULL, 0, NULL };2260 SIGNTOOLPKCS7 Src = { RTSIGNTOOLFILETYPE_DETECT, NULL, 0, NULL }; 2254 2261 PSIGNTOOLPKCS7 pSigDst = !pThis->pSignedData ? pThis : &Src; 2255 2262 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 ?? */, 2257 2264 pSigningCertKey, cVerbosity, 2258 2265 (void **)&pSigDst->pbBuf, &pSigDst->cbBuf, … … 2569 2576 if (rcExit == RTEXITCODE_SUCCESS) 2570 2577 rcExit = SignToolPkcs7_SignData(pThis, RTCrSpcIndirectDataContent_GetAsn1Core(&SpcIndData), 2571 kSignDataTweak_NoTweak, RTCRSPCINDIRECTDATACONTENT_OID, cVerbosity, 2578 kSignDataTweak_NoTweak, RTCRSPCINDIRECTDATACONTENT_OID, cVerbosity, 0, 2572 2579 enmSigType, fReplaceExisting, fNoSigningTime, pSigningCertKey, hAddCerts, 2573 2580 fTimestampTypeOld, SigningTime, pTimestampCertKey); … … 2601 2608 * Figure out what to sign first. 2602 2609 */ 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; 2605 2616 if (!fReplaceExisting) 2606 2617 { 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; 2616 2620 } 2617 2621 … … 2620 2624 */ 2621 2625 RTEXITCODE rcExit = SignToolPkcs7_SignData(pThis, pToSign, kSignDataTweak_RootIsParent, 2622 pszType, cVerbosity, enmSigType, fReplaceExisting,2626 pszType, cVerbosity, fExtraFlags, enmSigType, fReplaceExisting, 2623 2627 fNoSigningTime, pSigningCertKey, hAddCerts, 2624 2628 fTimestampTypeOld, SigningTime, pTimestampCertKey);
Note:
See TracChangeset
for help on using the changeset viewer.