Skip to content

Commit

Permalink
Cut over to SHA256.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Aug 10, 2024
1 parent 77f4fdc commit 5b2a2e7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ControlR.Agent/Services/AgentUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public async Task CheckForUpdate(CancellationToken cancellationToken = default)
var downloadUrl = $"{serverOrigin}{downloadPath}";

using var fs = _fileSystem.OpenFileStream(_environmentHelper.StartupExePath, FileMode.Open, FileAccess.Read, FileShare.Read);
var exeHash = await MD5.HashDataAsync(fs, linkedCts.Token);
var exeHash = await SHA256.HashDataAsync(fs, linkedCts.Token);

_logger.LogInformation(
"Comparing local file hash {LocalFileHash} to latest file hash {ServerFileHash}",
Expand Down
2 changes: 1 addition & 1 deletion ControlR.Agent/Services/Windows/StreamerUpdaterWindows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private async Task<Result<bool>> IsRemoteHashDifferent(string zipPath)

using (var zipFs = _fileSystem.OpenFileStream(zipPath, FileMode.Open, FileAccess.Read, FileShare.Read))
{
localHash = await MD5.HashDataAsync(zipFs);
localHash = await SHA256.HashDataAsync(zipFs);
}

_logger.LogInformation("Checking streamer remote archive hash.");
Expand Down
7 changes: 1 addition & 6 deletions ControlR.Server/Middleware/ContentHashHeaderMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,8 @@ public async Task InvokeAsync(HttpContext context)
var sha256Hash = await SHA256.HashDataAsync(fs, _appLifetime.ApplicationStopping);
var hexHash = Convert.ToHexString(sha256Hash);
context.Response.Headers["Content-Hash"] = hexHash;
// TODO: Re-enable when MD5 is removed.
//_memoryCache.Set(filePath, hexHash, TimeSpan.FromMinutes(10));

// TODO: Remove next release.
var md5Hash = await MD5.HashDataAsync(fs, _appLifetime.ApplicationStopping);
var base64Hash = Convert.ToBase64String(md5Hash);
context.Response.Headers.ContentMD5 = base64Hash;
_memoryCache.Set(filePath, hexHash, TimeSpan.FromMinutes(10));

await _next(context);
}
Expand Down

0 comments on commit 5b2a2e7

Please sign in to comment.