- Timestamp:
- Dec 16, 2016 1:45:35 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/tools/RTSignTool.cpp
r64892 r64897 300 300 if (iPos >= 0) 301 301 { 302 if (cVerbosity >= 3) 303 RTMsgInfo("Adding UnauthenticatedAttribute #%u...", iPos); 304 Assert((uint32_t)iPos < pSignerInfo->UnauthenticatedAttributes.cItems); 305 302 306 PRTCRPKCS7ATTRIBUTE pAttr = pSignerInfo->UnauthenticatedAttributes.papItems[iPos]; 303 307 int rc = RTAsn1ObjId_InitFromString(&pAttr->Type, RTCR_PKCS9_ID_MS_NESTED_SIGNATURE, pAttr->Allocation.pAllocator); … … 316 320 { 317 321 iPos = RTCrPkcs7SetOfContentInfos_Append(pAttr->uValues.pContentInfos); 322 Assert(iPos == 0); 318 323 if (iPos >= 0) 319 324 { … … 324 329 if (cVerbosity > 0) 325 330 RTMsgInfo("Added nested signature"); 331 if (cVerbosity >= 3) 332 { 333 RTMsgInfo("SingerInfo dump after change:"); 334 RTAsn1Dump(RTCrPkcs7SignerInfo_GetAsn1Core(pSignerInfo), 0, 2, RTStrmDumpPrintfV, g_pStdOut); 335 } 336 326 337 return RTEXITCODE_SUCCESS; 327 338 } … … 581 592 * Write the header followed by the signature data. 582 593 */ 594 uint32_t const cbZeroPad = (uint32_t)(RT_ALIGN_Z(pThis->cbNewBuf, 8) - pThis->cbNewBuf); 583 595 pSecDir->VirtualAddress = (uint32_t)offCur; 584 pSecDir->Size = cbWinCert + (uint32_t)pThis->cbNewBuf ;596 pSecDir->Size = cbWinCert + (uint32_t)pThis->cbNewBuf + cbZeroPad; 585 597 if (cVerbosity >= 2) 586 598 RTMsgInfo("Writing %u (%#x) bytes of signature at %#x (%u).\n", … … 597 609 offCur += cbWinCert; 598 610 rc = RTFileWriteAt(hFile, offCur, pThis->pbNewBuf, pThis->cbNewBuf, NULL); 611 } 612 if (RT_SUCCESS(rc) && cbZeroPad) 613 { 614 offCur += pThis->cbNewBuf; 615 rc = RTFileWriteAt(hFile, offCur, g_abRTZero4K, cbZeroPad, NULL); 616 } 617 if (RT_SUCCESS(rc)) 618 { 619 /* 620 * Reset the checksum (sec dir updated already) and rewrite the header. 621 */ 622 uBuf.NtHdrs32.OptionalHeader.CheckSum = 0; 623 offCur = offNtHdrs; 624 rc = RTFileWriteAt(hFile, offNtHdrs, &uBuf, cbNtHdrs, NULL); 625 if (RT_SUCCESS(rc)) 626 rc = RTFileFlush(hFile); 599 627 if (RT_SUCCESS(rc)) 600 628 { 601 629 /* 602 * Reset the checksum (sec dir updated already) and rewrite the header.630 * Calc checksum and write out the header again. 603 631 */ 604 uBuf.NtHdrs32.OptionalHeader.CheckSum = 0; 605 offCur = offNtHdrs; 606 rc = RTFileWriteAt(hFile, offNtHdrs, &uBuf, cbNtHdrs, NULL); 607 if (RT_SUCCESS(rc)) 608 rc = RTFileFlush(hFile); 609 if (RT_SUCCESS(rc)) 632 uint32_t uCheckSum = UINT32_MAX; 633 if (SignToolPkcs7Exe_CalcPeCheckSum(pThis, hFile, &uCheckSum)) 610 634 { 611 /* 612 * Calc checksum and write out the header again. 613 */ 614 uint32_t uCheckSum = UINT32_MAX; 615 if (SignToolPkcs7Exe_CalcPeCheckSum(pThis, hFile, &uCheckSum)) 635 rc = RTFileWriteAt(hFile, offNtHdrs, &uBuf, cbNtHdrs, NULL); 636 if (RT_SUCCESS(rc)) 637 rc = RTFileFlush(hFile); 638 if (RT_SUCCESS(rc)) 616 639 { 617 rc = RTFile WriteAt(hFile, offNtHdrs, &uBuf, cbNtHdrs, NULL);640 rc = RTFileClose(hFile); 618 641 if (RT_SUCCESS(rc)) 619 rc = RTFileFlush(hFile); 620 if (RT_SUCCESS(rc)) 621 { 622 rc = RTFileClose(hFile); 623 if (RT_SUCCESS(rc)) 624 return RTEXITCODE_SUCCESS; 625 RTMsgError("RTFileClose failed: %Rrc\n", rc); 626 return RTEXITCODE_FAILURE; 627 } 642 return RTEXITCODE_SUCCESS; 643 RTMsgError("RTFileClose failed: %Rrc\n", rc); 644 return RTEXITCODE_FAILURE; 628 645 } 629 646 } … … 866 883 if (rcExit == RTEXITCODE_SUCCESS) 867 884 rcExit = SignToolPkcs7Exe_WriteSignatureToFile(&Dst, cVerbosity); 885 868 886 SignToolPkcs7Exe_Delete(&Dst); 869 887 } … … 1677 1695 */ 1678 1696 if (pSignedData->Certificates.cItems > 0) 1697 { 1679 1698 RTPrintf("%s Certificates: %u\n", pThis->szPrefix, pSignedData->Certificates.cItems); 1680 /** @todo display certificates. */ 1699 for (uint32_t i = 0; i < pSignedData->Certificates.cItems; i++) 1700 { 1701 if (i != 0) 1702 RTPrintf("\n"); 1703 RTPrintf("%s Certificate #%u:\n", pThis->szPrefix, i); 1704 RTAsn1Dump(RTCrPkcs7Cert_GetAsn1Core(pSignedData->Certificates.papItems[i]), 0, 1705 ((uint32_t)offPrefix + 9) / 2, RTStrmDumpPrintfV, g_pStdOut); 1706 } 1707 /** @todo display certificates properly. */ 1708 } 1681 1709 1682 1710 if (pSignedData->Crls.cb > 0)
Note:
See TracChangeset
for help on using the changeset viewer.