MCPcopy Create free account
hub / github.com/bailey27/cppcryptfs / VerifyEmbeddedSignature

Function VerifyEmbeddedSignature

cppcryptfs/ui/certutil.cpp:38–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36#pragma comment (lib, "wintrust")
37
38bool VerifyEmbeddedSignature(LPCWSTR pwszSourceFile)
39{
40 LONG lStatus;
41
42 // Initialize the WINTRUST_FILE_INFO structure.
43
44 WINTRUST_FILE_INFO FileData;
45 memset(&FileData, 0, sizeof(FileData));
46 FileData.cbStruct = sizeof(WINTRUST_FILE_INFO);
47 FileData.pcwszFilePath = pwszSourceFile;
48 FileData.hFile = NULL;
49 FileData.pgKnownSubject = NULL;
50
51 /*
52 WVTPolicyGUID specifies the policy to apply on the file
53 WINTRUST_ACTION_GENERIC_VERIFY_V2 policy checks:
54
55 1) The certificate used to sign the file chains up to a root
56 certificate located in the trusted root certificate store. This
57 implies that the identity of the publisher has been verified by
58 a certification authority.
59
60 2) In cases where user interface is displayed (which this example
61 does not do), WinVerifyTrust will check for whether the
62 end entity certificate is stored in the trusted publisher store,
63 implying that the user trusts content from this publisher.
64
65 3) The end entity certificate has sufficient permission to sign
66 code, as indicated by the presence of a code signing EKU or no
67 EKU.
68 */
69
70 GUID WVTPolicyGUID = WINTRUST_ACTION_GENERIC_VERIFY_V2;
71 WINTRUST_DATA WinTrustData;
72
73 // Initialize the WinVerifyTrust input data structure.
74
75 // Default all fields to 0.
76 memset(&WinTrustData, 0, sizeof(WinTrustData));
77
78 WinTrustData.cbStruct = sizeof(WinTrustData);
79
80 // Use default code signing EKU.
81 WinTrustData.pPolicyCallbackData = NULL;
82
83 // No data to pass to SIP.
84 WinTrustData.pSIPClientData = NULL;
85
86 // Disable WVT UI.
87 WinTrustData.dwUIChoice = WTD_UI_NONE;
88
89 // No revocation checking.
90 WinTrustData.fdwRevocationChecks = WTD_REVOKE_NONE;
91
92 // Verify an embedded signature on a file.
93 WinTrustData.dwUnionChoice = WTD_CHOICE_FILE;
94
95 // Verify action.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected