@@ -99,11 +99,12 @@ static std::string CalculateFileSha256(HANDLE hFile) {
99
99
DWORD dwError = GetLastError ();
100
100
LogError (LOG_TAG " CalculateFileSha256.SetFilePointer failed. Error: %u" ,
101
101
dwError);
102
- return " " ; // Return empty string on failure
102
+ return " " ; // Return empty string on failure
103
103
}
104
104
105
105
// Acquire Crypto Provider.
106
- // Using CRYPT_VERIFYCONTEXT for operations that don't require private key access.
106
+ // Using CRYPT_VERIFYCONTEXT for operations that don't require private key
107
+ // access.
107
108
if (!CryptAcquireContextW (&hProv, NULL , NULL , PROV_RSA_AES,
108
109
CRYPT_VERIFYCONTEXT)) {
109
110
DWORD dwError = GetLastError ();
@@ -152,7 +153,8 @@ static std::string CalculateFileSha256(HANDLE hFile) {
152
153
// --- Get the binary hash value ---
153
154
DWORD cbHashValue = 0 ;
154
155
DWORD dwCount = sizeof (DWORD);
155
- if (!CryptGetHashParam (hHash, HP_HASHSIZE, (BYTE*)&cbHashValue, &dwCount, 0 )) {
156
+ if (!CryptGetHashParam (hHash, HP_HASHSIZE, (BYTE*)&cbHashValue, &dwCount,
157
+ 0 )) {
156
158
DWORD dwError = GetLastError ();
157
159
LogError (LOG_TAG
158
160
" CalculateFileSha256.CryptGetHashParam (HP_HASHSIZE) failed. "
@@ -179,12 +181,13 @@ static std::string CalculateFileSha256(HANDLE hFile) {
179
181
// --- Convert the binary hash to a hex string ---
180
182
DWORD hex_string_size = 0 ;
181
183
if (!CryptBinaryToStringA (binary_hash_value.data (), binary_hash_value.size (),
182
- CRYPT_STRING_HEXRAW | CRYPT_STRING_NOCRLF,
183
- NULL , &hex_string_size)) {
184
+ CRYPT_STRING_HEXRAW | CRYPT_STRING_NOCRLF, NULL ,
185
+ &hex_string_size)) {
184
186
DWORD dwError = GetLastError ();
185
- LogError (LOG_TAG
186
- " CalculateFileSha256.CryptBinaryToStringA (size) failed. Error: %u" ,
187
- dwError);
187
+ LogError (
188
+ LOG_TAG
189
+ " CalculateFileSha256.CryptBinaryToStringA (size) failed. Error: %u" ,
190
+ dwError);
188
191
CryptDestroyHash (hHash);
189
192
CryptReleaseContext (hProv, 0 );
190
193
return " " ;
@@ -196,7 +199,8 @@ static std::string CalculateFileSha256(HANDLE hFile) {
196
199
&hex_hash_string[0 ], &hex_string_size)) {
197
200
DWORD dwError = GetLastError ();
198
201
LogError (LOG_TAG
199
- " CalculateFileSha256.CryptBinaryToStringA (conversion) failed. Error: %u" ,
202
+ " CalculateFileSha256.CryptBinaryToStringA (conversion) failed. "
203
+ " Error: %u" ,
200
204
dwError);
201
205
CryptDestroyHash (hHash);
202
206
CryptReleaseContext (hProv, 0 );
@@ -286,9 +290,9 @@ HMODULE VerifyAndLoadAnalyticsLibrary(
286
290
if (calculated_hash == expected_hash) {
287
291
hash_matched = true ;
288
292
break ;
289
- }
290
- else {
291
- LogDebug (LOG_TAG " Hash mismatch: got %s expected %s " , calculated_hash.c_str (), expected_hash.c_str ());
293
+ } else {
294
+ LogDebug (LOG_TAG " Hash mismatch: got %s expected %s " ,
295
+ calculated_hash.c_str (), expected_hash.c_str ());
292
296
}
293
297
}
294
298
0 commit comments