Add installer hash check to packager
MODIFY
WalletWasabi.Packager/Program.cs
WalletWasabi.Packager/Program.cs
@@ -6,6 +6,7 @@ using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
+using System.Threading;
using System.Threading.Tasks;
using WalletWasabi.Helpers;
using WalletWasabi.Userfacing;
@@ -200,6 +201,9 @@ public static class Program
// Verify back the signature file.
await WasabiSignerHelpers.VerifySha256SumsFileAsync(sha256sumAscFilePath);
+ // Verify back Wasabi installer's hashes
+ await VerifyInstallerFileHashesAsync(finalFiles, sha256SumsFilePath);
+
IoHelpers.OpenFolderInFileExplorer(BinDistDirectory);
}
@@ -585,6 +589,26 @@ public static class Program
}
}
+ private static async Task VerifyInstallerFileHashesAsync(string[] finalFiles, string sha256SumsFilePath)
+ {
+ string[] lines = await File.ReadAllLinesAsync(sha256SumsFilePath).ConfigureAwait(false);
+ var hashWithFileNameLines = lines.Where(line => line.Contains("Wasabi-"));
+
+ foreach (var installerFilePath in finalFiles)
+ {
+ string installerName = Path.GetFileName(installerFilePath);
+ string installerExpectedHash = hashWithFileNameLines.Single(line => line.Contains(installerName)).Split(" ")[0];
+
+ var bytes = await WasabiSignerHelpers.GetShaComputedBytesOfFileAsync(installerFilePath).ConfigureAwait(false);
+ string installerRealHash = Convert.ToHexString(bytes).ToLower();
+
+ if (installerExpectedHash != installerRealHash)
+ {
+ throw new InvalidOperationException("Installer file's hash doesn't match expected hash.");
+ }
+ }
+ }
+
private static string? StartProcessAndWaitForExit(string command, string workingDirectory, string? writeToStandardInput = null, string? arguments = null, bool redirectStandardOutput = false)
{
var isWriteToStandardInput = !string.IsNullOrWhiteSpace(writeToStandardInput);

Add installer hash check to packager