summaryrefslogtreecommitdiff
path: root/onlineupdate/source/service/certificatecheck.cxx
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-12-27 02:45:55 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2017-05-19 03:43:26 +0200
commit7eca4fa00fc383a40b9957ff3c4b038ac02c2eef (patch)
treed96d62304f2a6e87336e85551ceeb2b73f80f809 /onlineupdate/source/service/certificatecheck.cxx
parent19066cafbb3a5a4013277f62b0e577294534a70b (diff)
get the update service working
Change-Id: I25921090083f20c4bb416f9cfdd5ec6400a27a21
Diffstat (limited to 'onlineupdate/source/service/certificatecheck.cxx')
-rw-r--r--onlineupdate/source/service/certificatecheck.cxx36
1 files changed, 18 insertions, 18 deletions
diff --git a/onlineupdate/source/service/certificatecheck.cxx b/onlineupdate/source/service/certificatecheck.cxx
index c756f2c7a945..3a9eba020ccb 100644
--- a/onlineupdate/source/service/certificatecheck.cxx
+++ b/onlineupdate/source/service/certificatecheck.cxx
@@ -21,15 +21,15 @@ static const int ENCODING = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING;
*
* @param filePath The PE file path to check
* @param infoToMatch The acceptable information to match
- * @return ERROR_SUCCESS if successful, ERROR_NOT_FOUND if the info
+ * @return ERROR_SUCCESS if successful, ERROR_NOT_FOUND if the info
* does not match, or the last error otherwise.
*/
DWORD
-CheckCertificateForPEFile(LPCWSTR filePath,
+CheckCertificateForPEFile(LPCWSTR filePath,
CertificateCheckInfo &infoToMatch)
{
HCERTSTORE certStore = nullptr;
- HCRYPTMSG cryptMsg = nullptr;
+ HCRYPTMSG cryptMsg = nullptr;
PCCERT_CONTEXT certContext = nullptr;
PCMSG_SIGNER_INFO signerInfo = nullptr;
DWORD lastError = ERROR_SUCCESS;
@@ -37,9 +37,9 @@ CheckCertificateForPEFile(LPCWSTR filePath,
// Get the HCERTSTORE and HCRYPTMSG from the signed file.
DWORD encoding, contentType, formatType;
BOOL result = CryptQueryObject(CERT_QUERY_OBJECT_FILE,
- filePath,
+ filePath,
CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED,
- CERT_QUERY_CONTENT_FLAG_ALL,
+ CERT_QUERY_CONTENT_FLAG_ALL,
0, &encoding, &contentType,
&formatType, &certStore, &cryptMsg, nullptr);
if (!result) {
@@ -50,7 +50,7 @@ CheckCertificateForPEFile(LPCWSTR filePath,
// Pass in nullptr to get the needed signer information size.
DWORD signerInfoSize;
- result = CryptMsgGetParam(cryptMsg, CMSG_SIGNER_INFO_PARAM, 0,
+ result = CryptMsgGetParam(cryptMsg, CMSG_SIGNER_INFO_PARAM, 0,
nullptr, &signerInfoSize);
if (!result) {
lastError = GetLastError();
@@ -68,7 +68,7 @@ CheckCertificateForPEFile(LPCWSTR filePath,
// Get the signer information (PCMSG_SIGNER_INFO).
// In particular we want the issuer and serial number.
- result = CryptMsgGetParam(cryptMsg, CMSG_SIGNER_INFO_PARAM, 0,
+ result = CryptMsgGetParam(cryptMsg, CMSG_SIGNER_INFO_PARAM, 0,
(PVOID)signerInfo, &signerInfoSize);
if (!result) {
lastError = GetLastError();
@@ -77,10 +77,10 @@ CheckCertificateForPEFile(LPCWSTR filePath,
}
// Search for the signer certificate in the certificate store.
- CERT_INFO certInfo;
+ CERT_INFO certInfo;
certInfo.Issuer = signerInfo->Issuer;
certInfo.SerialNumber = signerInfo->SerialNumber;
- certContext = CertFindCertificateInStore(certStore, ENCODING, 0,
+ certContext = CertFindCertificateInStore(certStore, ENCODING, 0,
CERT_FIND_SUBJECT_CERT,
(PVOID)&certInfo, nullptr);
if (!certContext) {
@@ -102,10 +102,10 @@ cleanup:
if (certContext) {
CertFreeCertificateContext(certContext);
}
- if (certStore) {
+ if (certStore) {
CertCloseStore(certStore, 0);
}
- if (cryptMsg) {
+ if (cryptMsg) {
CryptMsgClose(cryptMsg);
}
return lastError;
@@ -118,8 +118,8 @@ cleanup:
* @param infoToMatch The acceptable information to match
* @return FALSE if the info does not match or if any error occurs in the check
*/
-BOOL
-DoCertificateAttributesMatch(PCCERT_CONTEXT certContext,
+BOOL
+DoCertificateAttributesMatch(PCCERT_CONTEXT certContext,
CertificateCheckInfo &infoToMatch)
{
DWORD dwData;
@@ -127,7 +127,7 @@ DoCertificateAttributesMatch(PCCERT_CONTEXT certContext,
if (infoToMatch.issuer) {
// Pass in nullptr to get the needed size of the issuer buffer.
- dwData = CertGetNameString(certContext,
+ dwData = CertGetNameString(certContext,
CERT_NAME_SIMPLE_DISPLAY_TYPE,
CERT_NAME_ISSUER_FLAG, nullptr,
nullptr, 0);
@@ -190,7 +190,7 @@ DoCertificateAttributesMatch(PCCERT_CONTEXT certContext,
}
// If the issuer does not match, return a failure.
- if (!infoToMatch.name ||
+ if (!infoToMatch.name ||
wcscmp(szName, infoToMatch.name)) {
LocalFree(szName);
return FALSE;
@@ -210,10 +210,10 @@ DoCertificateAttributesMatch(PCCERT_CONTEXT certContext,
* @param inputString The string to duplicate
* @return The duplicated string which should be freed by the caller.
*/
-LPWSTR
+LPWSTR
AllocateAndCopyWideString(LPCWSTR inputString)
{
- LPWSTR outputString =
+ LPWSTR outputString =
(LPWSTR)LocalAlloc(LPTR, (wcslen(inputString) + 1) * sizeof(WCHAR));
if (outputString) {
lstrcpyW(outputString, inputString);
@@ -243,7 +243,7 @@ VerifyCertificateTrustForFile(LPCWSTR filePath)
trustData.pPolicyCallbackData = nullptr;
trustData.pSIPClientData = nullptr;
trustData.dwUIChoice = WTD_UI_NONE;
- trustData.fdwRevocationChecks = WTD_REVOKE_NONE;
+ trustData.fdwRevocationChecks = WTD_REVOKE_NONE;
trustData.dwUnionChoice = WTD_CHOICE_FILE;
trustData.dwStateAction = 0;
trustData.hWVTStateData = nullptr;