/** @file\r
Authenticode Portable Executable Signature Verification over OpenSSL.\r
\r
-Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
Verifies the validility of a PE/COFF Authenticode Signature as described in "Windows\r
Authenticode Portable Executable Signature Format".\r
\r
- If AuthData is NULL, then ASSERT().\r
- If ImageHash is NULL, then ASSERT().\r
+ If AuthData is NULL, then return FALSE.\r
+ If ImageHash is NULL, then return FALSE.\r
\r
@param[in] AuthData Pointer to the Authenticode Signature retrieved from signed\r
PE/COFF image to be verified.\r
UINTN ContentSize;\r
\r
//\r
- // ASSERT if Authenticode Signature Data or PE Image Hash is NULL.\r
+ // Check input parameters.\r
//\r
- ASSERT (AuthData != NULL);\r
- ASSERT (ImageHash != NULL);\r
- ASSERT (DataSize <= INT_MAX);\r
+ if ((AuthData == NULL) || (TrustedCert == NULL) || (ImageHash == NULL)) {\r
+ return FALSE;\r
+ }\r
+\r
+ if ((DataSize > INT_MAX) || (CertSize > INT_MAX) || (HashSize > INT_MAX)) {\r
+ return FALSE;\r
+ }\r
\r
Status = FALSE;\r
Pkcs7 = NULL;\r
// Retrieve the SEQUENCE data size from ASN.1-encoded SpcIndirectDataContent.\r
//\r
Asn1Byte = *(SpcIndirectDataContent + 1);\r
+\r
if ((Asn1Byte & 0x80) == 0) {\r
//\r
// Short Form of Length Encoding\r
// Skip the SEQUENCE Tag;\r
//\r
SpcIndirectDataContent += 2;\r
- } else {\r
+ } else if ((Asn1Byte & 0x82) == 0x82) {\r
//\r
- // Long Form of Length Encoding (Assume Only two bytes here)\r
+ // Long Form of Length Encoding, only support two bytes.\r
//\r
ContentSize = (UINTN) (*(SpcIndirectDataContent + 2));\r
ContentSize = (ContentSize << 8) + (UINTN)(*(SpcIndirectDataContent + 3));\r
// Skip the SEQUENCE Tag;\r
//\r
SpcIndirectDataContent += 4;\r
+ } else {\r
+ goto _Exit;\r
}\r
\r
//\r