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

Function GetCommonName

libipc/common_name.cpp:56–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54 PCMSG_SIGNER_INFO* pCounterSignerInfo);
55
56int GetCommonName(LPCWSTR szFileName, std::wstring& common_name)
57{
58
59 HCERTSTORE hStore = NULL;
60 HCRYPTMSG hMsg = NULL;
61 PCCERT_CONTEXT pCertContext = NULL;
62 BOOL fResult;
63 DWORD dwEncoding, dwContentType, dwFormatType;
64 PCMSG_SIGNER_INFO pSignerInfo = NULL;
65 PCMSG_SIGNER_INFO pCounterSignerInfo = NULL;
66 DWORD dwSignerInfo;
67 CERT_INFO CertInfo;
68 SPROG_PUBLISHERINFO ProgPubInfo;
69 //SYSTEMTIME st;
70
71 int ret = 0;
72
73 ZeroMemory(&ProgPubInfo, sizeof(ProgPubInfo));
74 __try
75 {
76
77 // Get message handle and store handle from the signed file.
78 fResult = CryptQueryObject(CERT_QUERY_OBJECT_FILE,
79 szFileName,
80 CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED,
81 CERT_QUERY_FORMAT_FLAG_BINARY,
82 0,
83 &dwEncoding,
84 &dwContentType,
85 &dwFormatType,
86 &hStore,
87 &hMsg,
88 NULL);
89 if (!fResult)
90 {
91 //_tprintf(_T("CryptQueryObject failed with %x\n"), GetLastError());
92 ret = -1;
93 __leave;
94 }
95
96 // Get signer information size.
97 fResult = CryptMsgGetParam(hMsg,
98 CMSG_SIGNER_INFO_PARAM,
99 0,
100 NULL,
101 &dwSignerInfo);
102 if (!fResult)
103 {
104 //_tprintf(_T("CryptMsgGetParam failed with %x\n"), GetLastError());
105 ret = -1;
106 __leave;
107 }
108
109 // Allocate memory for signer information.
110 pSignerInfo = (PCMSG_SIGNER_INFO)LocalAlloc(LPTR, dwSignerInfo);
111 if (!pSignerInfo)
112 {
113 //_tprintf(_T("Unable to allocate memory for Signer Info.\n"));

Callers 1

Calls 5

GetProgAndPublisherInfoFunction · 0.85
GetCertificateInfoFunction · 0.85
GetTimeStampSignerInfoFunction · 0.85
GetDateOfTimeStampFunction · 0.85
sizeMethod · 0.80

Tested by

no test coverage detected