Changeset 84330 in vbox
- Timestamp:
- May 18, 2020 1:37:00 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/crypto/pkcs7.h
r84310 r84330 527 527 * certificates chains at. Ignored for signatures 528 528 * with valid signing time attributes. 529 * When RTCRPKCS7VERIFY_SD_F_UPDATE_VALIDATION_TIME 530 * is set, this is updated to the actual validation 531 * time used. 529 532 * @param pfnVerifyCert Callback for checking that a certificate used 530 533 * for signing the data is suitable. … … 554 557 * certificates chains at. Ignored for signatures 555 558 * with valid signing time attributes. 559 * When RTCRPKCS7VERIFY_SD_F_UPDATE_VALIDATION_TIME 560 * is set, this is updated to the actual validation 561 * time used. 556 562 * @param pfnVerifyCert Callback for checking that a certificate used 557 563 * for signing the data is suitable. … … 597 603 * certificates to be trustworthy. */ 598 604 #define RTCRPKCS7VERIFY_SD_F_TRUST_ALL_CERTS RT_BIT_32(7) 605 /** Update @a pValidationTime with the actual validation time used. 606 * This requires RTCRPKCS7VERIFY_SD_F_HAS_SIGNER_INDEX to get a consistent 607 * result. And yeah, it unconst the parameter, which is patently ugly. */ 608 #define RTCRPKCS7VERIFY_SD_F_UPDATE_VALIDATION_TIME RT_BIT_32(8) 609 610 /** This can be used to only verify one given signer info. 611 * Max index value is 15. */ 612 #define RTCRPKCS7VERIFY_SD_F_SIGNER_INDEX(a_idxSignerInfo) \ 613 ( RTCRPKCS7VERIFY_SD_F_HAS_SIGNER_INDEX \ 614 | (((a_idxSignerInfo) & RTCRPKCS7VERIFY_SD_F_SIGNER_INDEX_MAX) << RTCRPKCS7VERIFY_SD_F_SIGNER_INDEX_SHIFT) ) 615 /** Has a valid value in RTCRPKCS7VERIFY_SD_F_SIGNER_INDEX_MASK. */ 616 #define RTCRPKCS7VERIFY_SD_F_HAS_SIGNER_INDEX RT_BIT_32(23) 617 /** Signer index shift value. */ 618 #define RTCRPKCS7VERIFY_SD_F_SIGNER_INDEX_SHIFT 24 619 /** Signer index mask. */ 620 #define RTCRPKCS7VERIFY_SD_F_SIGNER_INDEX_MASK UINT32_C(0x0f000000) 621 /** Max signer index value (inclusive). */ 622 #define RTCRPKCS7VERIFY_SD_F_SIGNER_INDEX_MAX \ 623 (RTCRPKCS7VERIFY_SD_F_SIGNER_INDEX_MASK >> RTCRPKCS7VERIFY_SD_F_SIGNER_INDEX_SHIFT) 599 624 600 625 /** Indicates internally that we're validating a counter signature and should -
trunk/src/VBox/Runtime/common/crypto/pkcs7-verify.cpp
r84310 r84330 441 441 int rc = VINF_SUCCESS; 442 442 if ( ( hSignerCertSrc == NIL_RTCRSTORE 443 || hSignerCertSrc != hTrustedCerts )443 || hSignerCertSrc != hTrustedCerts ) /** @todo 'hSignerCertSrc != hTrustedCerts' ain't making sense wrt pValidationTime */ 444 444 && !(fFlags & RTCRPKCS7VERIFY_SD_F_TRUST_ALL_CERTS) ) 445 445 { … … 659 659 { 660 660 /* 661 * Validate the signed infos. 661 * Validate the signed infos. The flags may select one particular entry. 662 662 */ 663 RTTIMESPEC const GivenValidationTime = *pValidationTime; 663 664 uint32_t fPrimaryVccFlags = !(fFlags & RTCRPKCS7VERIFY_SD_F_USAGE_TIMESTAMPING) 664 665 ? RTCRPKCS7VCC_F_SIGNED_DATA : RTCRPKCS7VCC_F_TIMESTAMP; 666 uint32_t cItems = pSignedData->SignerInfos.cItems; 667 i = 0; 668 if (fFlags & RTCRPKCS7VERIFY_SD_F_HAS_SIGNER_INDEX) 669 { 670 i = (fFlags & RTCRPKCS7VERIFY_SD_F_SIGNER_INDEX_MASK) >> RTCRPKCS7VERIFY_SD_F_SIGNER_INDEX_SHIFT; 671 cItems = RT_MIN(cItems, i + 1); 672 } 665 673 rc = VERR_CR_PKCS7_NO_SIGNER_INFOS; 666 for ( i = 0; i < pSignedData->SignerInfos.cItems; i++)674 for (; i < cItems; i++) 667 675 { 668 676 PCRTCRPKCS7SIGNERINFO pSignerInfo = pSignedData->SignerInfos.papItems[i]; … … 699 707 rc = VINF_SUCCESS; 700 708 if (!(fFlags & RTCRPKCS7VERIFY_SD_F_USE_SIGNING_TIME_UNVERIFIED)) 701 rc = rtCrPkcs7VerifyCounterSignerInfo(pSigningTimeSigner, pSignerInfo, pSignedData, fFlags, 709 rc = rtCrPkcs7VerifyCounterSignerInfo(pSigningTimeSigner, pSignerInfo, pSignedData, 710 fFlags & ~RTCRPKCS7VERIFY_SD_F_UPDATE_VALIDATION_TIME, 702 711 hAdditionalCerts, hTrustedCerts, &ThisValidationTime, 703 712 pfnVerifyCert, RTCRPKCS7VCC_F_TIMESTAMP, pvUser, pErrInfo); … … 709 718 fDone = RT_SUCCESS(rc) 710 719 || (fFlags & RTCRPKCS7VERIFY_SD_F_ALWAYS_USE_SIGNING_TIME_IF_PRESENT); 720 if ((fFlags & RTCRPKCS7VERIFY_SD_F_UPDATE_VALIDATION_TIME) && fDone) 721 *(PRTTIMESPEC)pValidationTime = ThisValidationTime; 711 722 } 712 723 else … … 743 754 fDone = RT_SUCCESS(rc) 744 755 || (fFlags & RTCRPKCS7VERIFY_SD_F_ALWAYS_USE_MS_TIMESTAMP_IF_PRESENT); 756 if ((fFlags & RTCRPKCS7VERIFY_SD_F_UPDATE_VALIDATION_TIME) && fDone) 757 *(PRTTIMESPEC)pValidationTime = ThisValidationTime; 745 758 } 746 759 else … … 758 771 if (!fDone) 759 772 rc = rtCrPkcs7VerifySignerInfo(pSignerInfo, pSignedData, hThisDigest, fFlags, hAdditionalCerts, hTrustedCerts, 760 pValidationTime, pfnVerifyCert, fPrimaryVccFlags, pvUser, pErrInfo);773 &GivenValidationTime, pfnVerifyCert, fPrimaryVccFlags, pvUser, pErrInfo); 761 774 RTCrDigestRelease(hThisDigest); 762 775 if (RT_FAILURE(rc)) … … 785 798 if (fFlags & RTCRPKCS7VERIFY_SD_F_USAGE_TIMESTAMPING) 786 799 return rc; 800 /** @todo figure out if we can verify just one signer info item using OpenSSL. */ 801 if (!(fFlags & RTCRPKCS7VERIFY_SD_F_HAS_SIGNER_INDEX) && pSignedData->SignerInfos.cItems > 1) 802 return rc; 803 787 804 int rcOssl = rtCrPkcs7VerifySignedDataUsingOpenSsl(pContentInfo, fFlags, hAdditionalCerts, hTrustedCerts, 788 805 pvContent, cbContent, RT_SUCCESS(rc) ? pErrInfo : NULL);
Note:
See TracChangeset
for help on using the changeset viewer.