Changeset 95668 in vbox for trunk/src/VBox/Runtime/common/crypto
- Timestamp:
- Jul 16, 2022 3:43:25 AM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 152317
- Location:
- trunk/src/VBox/Runtime/common/crypto
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/crypto/pkcs7-core.cpp
r93115 r95668 33 33 34 34 #include <iprt/errcore.h> 35 #include <iprt/mem.h> 35 36 #include <iprt/string.h> 37 #include <iprt/crypto/digest.h> 36 38 #include <iprt/crypto/tsp.h> 37 39 38 40 #include "pkcs7-internal.h" 39 41 40 41 /* 42 * PCKS #7 SignerInfo 42 /* 43 * PKCS #7 Attributes 44 */ 45 46 RTDECL(int) RTCrPkcs7Attributes_HashAttributes(PRTCRPKCS7ATTRIBUTES pAttributes, RTCRDIGEST hDigest, PRTERRINFO pErrInfo) 47 { 48 /* ASSUMES that the attributes are encoded according to DER. */ 49 uint8_t const *pbData; 50 uint32_t cbData; 51 void *pvFree = NULL; 52 int rc = RTAsn1EncodeQueryRawBits(RTCrPkcs7Attributes_GetAsn1Core(pAttributes), 53 &pbData, &cbData, &pvFree, pErrInfo); 54 if (RT_SUCCESS(rc)) 55 { 56 uint8_t bSetOfTag = ASN1_TAG_SET | ASN1_TAGCLASS_UNIVERSAL | ASN1_TAGFLAG_CONSTRUCTED; 57 rc = RTCrDigestUpdate(hDigest, &bSetOfTag, sizeof(bSetOfTag)); /* Replace the implict tag with a SET-OF tag. */ 58 if (RT_SUCCESS(rc)) 59 rc = RTCrDigestUpdate(hDigest, pbData + sizeof(bSetOfTag), cbData - sizeof(bSetOfTag)); /* Skip the implicit tag. */ 60 if (RT_SUCCESS(rc)) 61 rc = RTCrDigestFinal(hDigest, NULL, 0); 62 else 63 RTErrInfoSet(pErrInfo, rc, "RTCrDigestUpdate failed"); 64 RTMemTmpFree(pvFree); 65 } 66 return rc; 67 } 68 69 70 /* 71 * PKCS #7 SignerInfo 43 72 */ 44 73 … … 177 206 178 207 /* 179 * P CKS #7 ContentInfo.208 * PKCS #7 ContentInfo. 180 209 */ 181 210 -
trunk/src/VBox/Runtime/common/crypto/pkcs7-verify.cpp
r94157 r95668 328 328 *phDigest = hDigest; 329 329 330 /* ASSUMES that the attributes are encoded according to DER. */ 331 uint8_t const *pbData; 332 uint32_t cbData; 333 void *pvFree = NULL; 334 rc = RTAsn1EncodeQueryRawBits(RTCrPkcs7Attributes_GetAsn1Core(&pSignerInfo->AuthenticatedAttributes), 335 &pbData, &cbData, &pvFree, pErrInfo); 336 if (RT_SUCCESS(rc)) 337 { 338 uint8_t bSetOfTag = ASN1_TAG_SET | ASN1_TAGCLASS_UNIVERSAL | ASN1_TAGFLAG_CONSTRUCTED; 339 rc = RTCrDigestUpdate(hDigest, &bSetOfTag, sizeof(bSetOfTag)); /* Replace the implict tag with a SET-OF tag. */ 340 if (RT_SUCCESS(rc)) 341 rc = RTCrDigestUpdate(hDigest, pbData + sizeof(bSetOfTag), cbData - sizeof(bSetOfTag)); /* Skip the implicit tag. */ 342 if (RT_SUCCESS(rc)) 343 rc = RTCrDigestFinal(hDigest, NULL, 0); 344 RTMemTmpFree(pvFree); 345 } 330 /** @todo The encoding step modifies the data, contradicting the const-ness 331 * of the parameter. */ 332 rc = RTCrPkcs7Attributes_HashAttributes((PRTCRPKCS7ATTRIBUTES)&pSignerInfo->AuthenticatedAttributes, hDigest, pErrInfo); 346 333 } 347 334 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.