/** @file
Authenticode Portable Executable Signature Verification over OpenSSL.
Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "InternalCryptLib.h"
/**
Authenticode Portable Executable Signature Format".
If AuthData is NULL, then return FALSE.
If ImageHash is NULL, then return FALSE.
@param[in] AuthData Pointer to the Authenticode Signature retrieved from signed
@param[in] DataSize Size of the Authenticode Signature in bytes.
is used for certificate chain verification.
@param[in] CertSize Size of the trusted certificate in bytes.
@param[in] ImageHash Pointer to the original image file hash value. The procudure
for calculating the image hash value is described in Authenticode
specification.
@param[in] HashSize Size of Image hash value in bytes.
@retval TRUE The specified Authenticode Signature is valid.
@retval FALSE Invalid Authenticode Signature.
**/
)
{
//
// Check input parameters.
//
return FALSE;
}
return FALSE;
}
//
// Retrieve & Parse PKCS#7 Data (DER encoding) from Authenticode Signature
//
goto _Exit;
}
//
// Check if it's PKCS#7 Signed Data (for Authenticode Scenario)
//
if (!PKCS7_type_is_signed (Pkcs7)) {
goto _Exit;
}
//
// NOTE: OpenSSL PKCS7 Decoder didn't work for Authenticode-format signed data due to
// some authenticode-specific structure. Use opaque ASN.1 string to retrieve
// PKCS#7 ContentInfo here.
//
//
// Retrieve the SEQUENCE data size from ASN.1-encoded SpcIndirectDataContent.
//
if ((Asn1Byte & 0x80) == 0) {
//
// Short Form of Length Encoding
//
//
// Skip the SEQUENCE Tag;
//
SpcIndirectDataContent += 2;
//
// Long Form of Length Encoding, only support two bytes.
//
//
// Skip the SEQUENCE Tag;
//
SpcIndirectDataContent += 4;
} else {
goto _Exit;
}
//
// Compare the original file hash value to the digest retrieve from SpcIndirectDataContent
// defined in Authenticode
// NOTE: Need to double-check HashLength here!
//
//
//
goto _Exit;
}
//
//
Status = (BOOLEAN) Pkcs7Verify (OrigAuthData, DataSize, TrustedCert, CertSize, SpcIndirectDataContent, ContentSize);
//
// Release Resources
//
PKCS7_free (Pkcs7);
return Status;
}