X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=CryptoPkg%2FLibrary%2FBaseCryptLib%2FPk%2FCryptAuthenticode.c;h=aa4a33364d9240fc2b245af4942e4577f209282e;hb=7c342378317039e632d9a1a5d4cf7c21aec8cb7a;hp=3c2d14a88bce2a3ac5cddf147c8b101c16b40eb4;hpb=2b16a4fb91b9b31c0d152588f5ac51080c6c0763;p=mirror_edk2.git diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptAuthenticode.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptAuthenticode.c index 3c2d14a88b..aa4a33364d 100644 --- a/CryptoPkg/Library/BaseCryptLib/Pk/CryptAuthenticode.c +++ b/CryptoPkg/Library/BaseCryptLib/Pk/CryptAuthenticode.c @@ -23,9 +23,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent // // OID ASN.1 Value for SPC_INDIRECT_DATA_OBJID // -UINT8 mSpcIndirectOidValue[] = { +UINT8 mSpcIndirectOidValue[] = { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x02, 0x01, 0x04 - }; +}; /** Verifies the validity of a PE/COFF Authenticode Signature as described in "Windows @@ -109,20 +109,20 @@ AuthenticodeVerify ( // some authenticode-specific structure. Use opaque ASN.1 string to retrieve // PKCS#7 ContentInfo here. // - SpcIndirectDataOid = OBJ_get0_data(Pkcs7->d.sign->contents->type); - if (OBJ_length(Pkcs7->d.sign->contents->type) != sizeof(mSpcIndirectOidValue) || - CompareMem ( - SpcIndirectDataOid, - mSpcIndirectOidValue, - sizeof (mSpcIndirectOidValue) - ) != 0) { + SpcIndirectDataOid = OBJ_get0_data (Pkcs7->d.sign->contents->type); + if ((OBJ_length (Pkcs7->d.sign->contents->type) != sizeof (mSpcIndirectOidValue)) || + (CompareMem ( + SpcIndirectDataOid, + mSpcIndirectOidValue, + sizeof (mSpcIndirectOidValue) + ) != 0)) + { // // Un-matched SPC_INDIRECT_DATA_OBJID. // goto _Exit; } - SpcIndirectDataContent = (UINT8 *)(Pkcs7->d.sign->contents->d.other->value.asn1_string->data); // @@ -134,33 +134,30 @@ AuthenticodeVerify ( // // Short Form of Length Encoding (Length < 128) // - ContentSize = (UINTN) (Asn1Byte & 0x7F); + ContentSize = (UINTN)(Asn1Byte & 0x7F); // // Skip the SEQUENCE Tag; // SpcIndirectDataContent += 2; - } else if ((Asn1Byte & 0x81) == 0x81) { // // Long Form of Length Encoding (128 <= Length < 255, Single Octet) // - ContentSize = (UINTN) (*(UINT8 *)(SpcIndirectDataContent + 2)); + ContentSize = (UINTN)(*(UINT8 *)(SpcIndirectDataContent + 2)); // // Skip the SEQUENCE Tag; // SpcIndirectDataContent += 3; - } else if ((Asn1Byte & 0x82) == 0x82) { // // Long Form of Length Encoding (Length > 255, Two Octet) // - ContentSize = (UINTN) (*(UINT8 *)(SpcIndirectDataContent + 2)); + ContentSize = (UINTN)(*(UINT8 *)(SpcIndirectDataContent + 2)); ContentSize = (ContentSize << 8) + (UINTN)(*(UINT8 *)(SpcIndirectDataContent + 3)); // // Skip the SEQUENCE Tag; // SpcIndirectDataContent += 4; - } else { goto _Exit; } @@ -180,7 +177,7 @@ AuthenticodeVerify ( // // Verifies the PKCS#7 Signed Data in PE/COFF Authenticode Signature // - Status = (BOOLEAN) Pkcs7Verify (OrigAuthData, DataSize, TrustedCert, CertSize, SpcIndirectDataContent, ContentSize); + Status = (BOOLEAN)Pkcs7Verify (OrigAuthData, DataSize, TrustedCert, CertSize, SpcIndirectDataContent, ContentSize); _Exit: //