Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing SHA3 helpers in HashAlgorithmNames #87237

Closed
wants to merge 2 commits into from

Conversation

IDisposable
Copy link
Contributor

@IDisposable IDisposable commented Jun 7, 2023

In PR #84132, the addition of SHA3 variants to the HashAlgorithmNames was incomplete, leaving out the explicit handling of the SHA3 variants from the two helper methods:

  • ToUpper() - Would just return the name unchanged (which is likely wrong as it would allow sha3-256 through instead of uppercasing to SHA3-256. That's probably wrong.
  • ToAlgorithmName() - Would return the ToString() on the supplied hashAlgorithm instance, which would be the classname of the argument hashAlgorithm (e.g. "System.Security.Cryptography.SHA3_256"). That would not match the expectation of "SHA3-256" based on the other instances.

I am not sure how important these are, or if they should be wrapped in a #if NET8_0_OR_GREATER wrapper like only some of the new SHA3 stuff was wrapped in that PR.

In PR dotnet#84132, the addition of SHA3 variants to the HashAlgorithmNames was incomplete, leaving out the explicit handling of the SHA3 variants from the two helper methods:
  - `ToUpper()` - Would just return the name **unchanged** (which is likely wrong as it would allow _sha3-256_ through instead of uppercasing to _SHA3-256_. That's probably wrong.
- `ToAlgorithmName()` - Would return the `ToString()` on the supplied `hashAlgorithm` instance, which would be the classname of the argument `hashAlgorithm` (e.g. `"System.Security.Cryptography.SHA3_256"`). That would not match the expectation of `"SHA3-256"` based on the other instances.
I am not sure how important these are, or if they should be wrapped in a `#if NET8_0_OR_GREATER` wrapper (only some of the new SHA3 stuff was wrapped in that PR)
@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Jun 7, 2023
@ghost
Copy link

ghost commented Jun 7, 2023

Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones
See info in area-owners.md if you want to be subscribed.

Issue Details

null

Author: IDisposable
Assignees: -
Labels:

area-System.Security, community-contribution

Milestone: -

@IDisposable IDisposable changed the title Add missing SHA3 support helpers Add missing SHA3 helpers in HashAlgorithmNames Jun 7, 2023
@IDisposable
Copy link
Contributor Author

Looking for comments from @vcsjones and @steveharter

@IDisposable
Copy link
Contributor Author

IDisposable commented Jun 7, 2023

Also I checked in unit tests for the HashAlgorithmNames before realizing it was an internal struct. I am not sure if there is any precedent for exposing those for testing... but had there been tests before we wouldn't have missed this... sigh

@IDisposable IDisposable marked this pull request as ready for review June 7, 2023 23:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Security community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants