// ntfill.h
// rev
typedef // routine: CiCheckSignedFile (before 6.1.7601.18519)
_Function_class_(CI_CHECK_SIGNED_FILE_LEGACY)
_IRQL_requires_max_(PASSIVE_LEVEL)
_Must_inspect_result_
NTSTATUS
NTAPI
CI_CHECK_SIGNED_FILE_LEGACY(
_In_bytecount_(MINCRYPT_SHA1_HASH_LEN) PBYTE Hash,
_In_bytecount_(SignatureSize) PBYTE Signature,
_In_ ULONG SignatureSize,
_Inout_opt_ PMINCRYPT_POLICY_INFO PolicyInfo,
_Out_opt_ PLARGE_INTEGER SigningTime,
_Inout_opt_ PMINCRYPT_POLICY_INFO TimeStampPolicyInfo
);
View code on GitHub// ntfill.h
// rev
typedef // routine: CiCheckSignedFile (6.1.7601.18519 and later)
_Function_class_(CI_CHECK_SIGNED_FILE)
_IRQL_requires_max_(PASSIVE_LEVEL)
_Must_inspect_result_
NTSTATUS
NTAPI
CI_CHECK_SIGNED_FILE(
_In_bytecount_(HashSize) PBYTE Hash,
_In_ ULONG HashSize,
_In_ ALG_ID AlgorithmId,
_In_bytecount_(SignatureSize) PBYTE Signature,
_In_ ULONG SignatureSize,
_Inout_opt_ PMINCRYPT_POLICY_INFO PolicyInfo,
_Out_opt_ PLARGE_INTEGER SigningTime,
_Inout_opt_ PMINCRYPT_POLICY_INFO TimeStampPolicyInfo
);
View code on GitHubFor an input Authenticode file digest and an Authenticode signature, verifies that the digest is in the signature and that the signature validates. Optionally returns information about the signature. The caller is responsible for mapping the image, parsing its PE headers, locating the WIN_CERTIFICATE in the security directory, and computing the Authenticode digest.
Hash - a pointer to the Authenticode digest of the file being verified.HashSize - the size of the digest in bytes.AlgorithmId - the algorithm that was used to compute the digest, such as CALG_SHA1 or CALG_SHA_256. The verifier iterates over the signatures embedded in the WIN_CERTIFICATE blob and selects the one whose digest algorithm matches this value.Signature - a pointer to the raw WIN_CERTIFICATE bytes read from the PE security directory.SignatureSize - the size of the signature blob, in bytes.PolicyInfo - an optional pointer to a MINCRYPT_POLICY_INFO structure that receives information about the signer, including the certificate chain. The caller must release it with CiFreePolicyInfo when it is no longer needed.SigningTime - an optional pointer that receives the time of signing, when available.TimeStampPolicyInfo - an optional pointer to a MINCRYPT_POLICY_INFO structure that receives information about the timestamping authority, with the same ownership and release rules as PolicyInfo.This function is exported from ci.dll. It is suitable for drivers that have already mapped and hashed the target image themselves. CiValidateFileObject provides a higher-level alternative that performs the mapping and hashing for the caller but applies a stricter policy.
Prior to build 6.1.7601.18519, the function had a legacy prototype that only accepted SHA-1 hashes and did not take explicit size and algorithm parameters.
For more details, see Code Integrity in the Kernel: A Look Into ci.dll by Liron Zuarets and Ido Moshe.