// SignedData.digestAlgorithms shall contain the digest algorithm used when preparing the\r
// signature. Only a digest algorithm of SHA-256 is accepted.\r
//\r
- // According to PKCS#7 Definition:\r
+ // According to PKCS#7 Definition (https://www.rfc-editor.org/rfc/rfc2315):\r
// SignedData ::= SEQUENCE {\r
// version Version,\r
// digestAlgorithms DigestAlgorithmIdentifiers,\r
// .... }\r
// The DigestAlgorithmIdentifiers can be used to determine the hash algorithm\r
// in VARIABLE_AUTHENTICATION_2 descriptor.\r
- // This field has the fixed offset (+13) and be calculated based on two bytes of length encoding.\r
+ // This field has the fixed offset (+13) or (+32) based on whether the DER-encoded\r
+ // ContentInfo structure is present or not, and can be calculated based on two\r
+ // bytes of length encoding.\r
+ //\r
+ // Both condition can be handled in WrapPkcs7Data() in CryptPkcs7VerifyCommon.c.\r
+ //\r
+ // See below examples:\r
+ //\r
+ // 1. Without ContentInfo\r
+ // 30 82 0c da // SEQUENCE (5 element) (3294 BYTES) -- SignedData\r
+ // 02 01 01 // INTEGER 1 -- Version\r
+ // 31 0f // SET (1 element) (15 BYTES) -- DigestAlgorithmIdentifiers\r
+ // 30 0d // SEQUENCE (2 element) (13 BYTES) -- AlgorithmIdentifier\r
+ // 06 09 // OBJECT-IDENTIFIER (9 BYTES) -- algorithm\r
+ // 60 86 48 01 65 03 04 02 01 // sha256 [2.16.840.1.101.3.4.2.1]\r
+ // 05 00 // NULL (0 BYTES) -- parameters\r
+ //\r
+ // Example from: https://uefi.org/revocationlistfile\r
+ //\r
+ // 2. With ContentInfo\r
+ // 30 82 05 90 // SEQUENCE (1424 BYTES) -- ContentInfo\r
+ // 06 09 // OBJECT-IDENTIFIER (9 BYTES) -- ContentType\r
+ // 2a 86 48 86 f7 0d 01 07 02 // signedData [1.2.840.113549.1.7.2]\r
+ // a0 82 05 81 // CONTEXT-SPECIFIC CONSTRUCTED TAG 0 (1409 BYTES) -- content\r
+ // 30 82 05 7d // SEQUENCE (1405 BYTES) -- SignedData\r
+ // 02 01 01 // INTEGER 1 -- Version\r
+ // 31 0f // SET (1 element) (15 BYTES) -- DigestAlgorithmIdentifiers\r
+ // 30 0d // SEQUENCE (13 BYTES) -- AlgorithmIdentifier\r
+ // 06 09 // OBJECT-IDENTIFIER (9 BYTES) -- algorithm\r
+ // 60 86 48 01 65 03 04 02 01 // sha256 [2.16.840.1.101.3.4.2.1]\r
+ // 05 00 // NULL (0 BYTES) -- parameters\r
+ //\r
+ // Example generated with: https://wiki.archlinux.org/title/Unified_Extensible_Firmware_Interface/Secure_Boot#Manual_process\r
//\r
if ((Attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) != 0) {\r
- if (SigDataSize >= (13 + sizeof (mSha256OidValue))) {\r
- if (((*(SigData + 1) & TWO_BYTE_ENCODE) != TWO_BYTE_ENCODE) ||\r
- (CompareMem (SigData + 13, &mSha256OidValue, sizeof (mSha256OidValue)) != 0))\r
- {\r
- return EFI_SECURITY_VIOLATION;\r
- }\r
+ if ( ( (SigDataSize >= (13 + sizeof (mSha256OidValue)))\r
+ && ( ((*(SigData + 1) & TWO_BYTE_ENCODE) != TWO_BYTE_ENCODE)\r
+ || (CompareMem (SigData + 13, &mSha256OidValue, sizeof (mSha256OidValue)) != 0)))\r
+ && ( (SigDataSize >= (32 + sizeof (mSha256OidValue)))\r
+ && ( ((*(SigData + 20) & TWO_BYTE_ENCODE) != TWO_BYTE_ENCODE)\r
+ || (CompareMem (SigData + 32, &mSha256OidValue, sizeof (mSha256OidValue)) != 0))))\r
+ {\r
+ return EFI_SECURITY_VIOLATION;\r
}\r
}\r
\r