Skip to content

[CA5350] Scope-suppress weak-crypto warning for SHA1 file-integrity checks - #12347

Open
mauroa wants to merge 1 commit into
dotnet:mainfrom
mauroa:dev/maagno/3012464
Open

[CA5350] Scope-suppress weak-crypto warning for SHA1 file-integrity checks#12347
mauroa wants to merge 1 commit into
dotnet:mainfrom
mauroa:dev/maagno/3012464

Conversation

@mauroa

@mauroa mauroa commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Addresses CA5350 (Do Not Use Weak Cryptographic Algorithms) flagged by DevDiv work item 3012464 ([roslynanalyzers:Warning]) on CreateHashAlgorithm in DownloadUtils.cs.

Rationale

SHA1 here is not a security or authentication boundary. It is used only to:

  • verify externally-published file-integrity checksums (the Android SDK repository manifest publishes SHA1 checksums, see SdkManager.Manifest.cs), and
  • compute Android SDK license hashes that must match Google's on-disk licenses/ format (SdkManager.Licenses.cs ComputeLicenseHash).

Removing SHA1 would break checksum/license verification against Google-published data, so the algorithm is preserved and the warning is narrowly scope-suppressed to just the SHA1.Create() switch arm with a clear justification.

Originally scoped against the archived dotnet/android-tools; retargeted here since that source now lives in dotnet/android.

…hecks in DownloadUtils

Addresses CA5350 ("Do Not Use Weak Cryptographic Algorithms") flagged by
DevDiv work item 3012464 on CreateHashAlgorithm in DownloadUtils.cs.

SHA1 here is not a security or authentication boundary: it verifies
externally-published Android SDK file-integrity checksums (SdkManager.Manifest.cs)
and computes Android SDK license hashes matching Google's on-disk licenses/ format
(SdkManager.Licenses.cs ComputeLicenseHash). Removing SHA1 would break
checksum/license verification, so behavior is preserved and the warning is
scope-suppressed to just the SHA1.Create() switch arm.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@mauroa
mauroa marked this pull request as ready for review August 11, 2026 16:52
Copilot AI lite review requested due to automatic review settings August 11, 2026 16:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses CA5350 warnings around SHA1 usage in DownloadUtils.cs by adding a narrowly-scoped warning suppression and an in-code justification. This aligns with the Android SDK tooling needs where SHA1 is used for compatibility with Google-published checksum/license formats rather than as an authentication boundary.

Changes:

  • Adds a scoped #pragma warning disable/restore CA5350 around the SHA1.Create() switch arm in CreateHashAlgorithm.
  • Adds inline comments explaining why SHA1 is still required for checksum/license compatibility.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 99 to +106
static HashAlgorithm CreateHashAlgorithm (ChecksumType checksumType) => checksumType switch {
ChecksumType.Sha256 => (HashAlgorithm) SHA256.Create (),
// SHA1 is used only to verify externally-published file-integrity checksums (Android SDK
// repository manifests publish SHA1 checksums) and to match Google's on-disk license hashes,
// not as a security or authentication boundary. See ChecksumType / SdkManager.Manifest.cs.
#pragma warning disable CA5350 // Do Not Use Weak Cryptographic Algorithms
ChecksumType.Sha1 => SHA1.Create (),
#pragma warning restore CA5350

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you check if the NoWarn is really there and we wouldn't need this?

Comment on lines +101 to +103
// SHA1 is used only to verify externally-published file-integrity checksums (Android SDK
// repository manifests publish SHA1 checksums) and to match Google's on-disk license hashes,
// not as a security or authentication boundary. See ChecksumType / SdkManager.Manifest.cs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants