Compare binary hashes
MODIFY
WalletWasabi/Helpers/IoHelpers.cs
WalletWasabi/Helpers/IoHelpers.cs
using System.Diagnostics;
using System.IO.Compression;
using System.Runtime.InteropServices;
+using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -247,6 +248,37 @@ namespace System.IO
}
}
+ public static byte[] GetHashFile(string filePath)
+ {
+ var bytes = File.ReadAllBytes(filePath);
+ using(var sha = new SHA256Managed())
+ {
+ return sha.ComputeHash(bytes, 0, bytes.Length);
+ }
+ }
+
+ public static bool CheckExpectedHash(string filePath, string sourceFolderPath)
+ {
+ var fileHash = GetHashFile(filePath);
+ try
+ {
+ var digests = File.ReadAllLines(Path.Combine(sourceFolderPath,"digests.txt"));
+ foreach(var digest in digests)
+ {
+ var expectedHash = ByteHelpers.FromHex(digest);
+ if(ByteHelpers.CompareFastUnsafe(fileHash, expectedHash))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+ catch(Exception)
+ {
+ return false;
+ }
+ }
+
public static void OpenFolderInFileExplorer(string dirPath)
{
if (Directory.Exists(dirPath))

MODIFY
WalletWasabi/Hwi/HwiProcessManager.cs
WalletWasabi/Hwi/HwiProcessManager.cs
@@ -191,7 +191,7 @@ namespace WalletWasabi.Hwi
Logger.LogInfo($"HWI instance NOT found at {hwiPath}. Attempting to acquire it...", nameof(HwiProcessManager));
await InstallHwiAsync(fullBaseDirectory, hwiDir);
}
- else if (new FileInfo(hwiPath).CreationTimeUtc < new DateTime(2019, 04, 13, 0, 0, 0, 0, DateTimeKind.Utc))
+ else if (!IoHelpers.CheckExpectedHash(hwiPath, Path.Combine(fullBaseDirectory, "Hwi", "Software")))
{
Logger.LogInfo($"Updating HWI...", nameof(HwiProcessManager));

ADD
WalletWasabi/Hwi/Software/digests.txt
+4d63ff6930dae6ae74a657110384a3812acb86613b7875e76a9cee13295cbca6
+98d62ff9b4637fc41f2ee5dfe56cc14de6c2f19b79a1b39486018972283e5f3d
+a9912911eed066b17d99ad28330f262ace4577a99cf835e6d7360763b09744dd

ADD
WalletWasabi/TorDaemons/digests.txt
+0b7682461dcd95490cb78835cbbe9bec30ba78564bd79f5339b41e09199664ac
+ace04f897c83164feb04c5cb365fb49541e2074c175c2eb1baa9d230f777abcc
+ca7c7f0018478edd002df9a7c624034729345852e6612c01c7304b23d212409f

MODIFY
WalletWasabi/TorSocks5/TorProcessManager.cs
WalletWasabi/TorSocks5/TorProcessManager.cs
@@ -90,7 +90,7 @@ namespace WalletWasabi.TorSocks5
Logger.LogInfo<TorProcessManager>($"Tor instance NOT found at {torPath}. Attempting to acquire it...");
InstallTor(fullBaseDirectory, torDir);
}
- else if (new FileInfo(torPath).CreationTimeUtc < new DateTime(2019, 01, 26, 0, 0, 0, 0, DateTimeKind.Utc))
+ else if (!IoHelpers.CheckExpectedHash(torPath, Path.Combine(fullBaseDirectory, "TorDaemons")))
{
Logger.LogInfo<TorProcessManager>($"Updating Tor...");

MODIFY
WalletWasabi/WalletWasabi.csproj
WalletWasabi/WalletWasabi.csproj
</ItemGroup>
<ItemGroup>
+ <None Update="Hwi\Software\digests.txt">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </None>
<None Update="Hwi\Software\hwi-linux64.zip">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Hwi\Software\hwi-win64.zip">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
+ <None Update="TorDaemons\digests.txt">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </None>
<None Update="TorDaemons\data-folder.zip">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>

Compare binary hashes