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

17950 Hash Statics #39216

Merged
merged 18 commits into from
Jul 15, 2020
Merged

17950 Hash Statics #39216

merged 18 commits into from
Jul 15, 2020

Conversation

vcsjones
Copy link
Member

@vcsjones vcsjones commented Jul 13, 2020

A draft for hashing statics.

Looking for feedback on approach, particularly CNG's since all I did was end up re-using the existing hash mechanisms. Is it worth pooling instances of those with ThreadStatic or similar?

Work is done in native shims for macOS / Linux to cut down on p/invokes since in this particular case all we'd end up doing is passing around handles to native stuff anyway.

Things that still need to be addressed

  • Docs
  • Test coverage on all overloads

Contributes to #17590

@Dotnet-GitSync-Bot
Copy link
Collaborator

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@ghost
Copy link

ghost commented Jul 13, 2020

Tagging subscribers to this area: @bartonjs, @vcsjones, @krwq
Notify danmosemsft if you want to be subscribed.

HashAlgorithmNames.SHA384 => Interop.Crypto.EvpSha384(),
HashAlgorithmNames.SHA512 => Interop.Crypto.EvpSha512(),
HashAlgorithmNames.MD5 => Interop.Crypto.EvpMd5(),
_ => throw new CryptographicException(SR.Format(SR.Cryptography_UnknownHashAlgorithm, hashAlgorithmId))
Copy link
Member

Choose a reason for hiding this comment

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

Since these are shared handles we can probably gain some mild wins by memoizing the values in managed (and avoiding the P/Invoke every time to get a redundant answer).

@bartonjs
Copy link
Member

Looking for feedback on approach, particularly CNG's since all I did was end up re-using the existing hash mechanisms. Is it worth pooling instances of those with ThreadStatic or similar?

For just getting it working the current implementation is OK (especially if it lets the PR get merged before tomorrow morning), but it would definitely be good for the static method to just be a right answer, instead of "maybe not the best answer on Windows if allocations are currently a problem for you".

Using ThreadStatic or pooling or whatever (with the optional enhancement of using the Win10 one-shot calls) can be done as a followup.

@vcsjones
Copy link
Member Author

especially if it lets the PR get merged before tomorrow morning

Is there something interesting happening tomorrow morning?

@vcsjones vcsjones marked this pull request as ready for review July 14, 2020 22:42
@vcsjones
Copy link
Member Author

vcsjones commented Jul 14, 2020

Marking as ready for review, I should be able to address the Apple implementation and test coverage later this evening. For the rest, if there is a deadline we are trying to hit by tomorrow, I think I follow up PR makes sense. I'll mark this as non-closing the issue.

@bartonjs
Copy link
Member

Is there something interesting happening tomorrow morning?

If it's in tomorrow morning it's part of preview 8 😄.

@bartonjs
Copy link
Member

The failing legs seem to just be queue timeouts and the like.

@bartonjs bartonjs merged commit 7f53623 into dotnet:master Jul 15, 2020
@vcsjones vcsjones deleted the 17950-hash-statics branch July 15, 2020 14:01
@karelz karelz added this to the 5.0.0 milestone Aug 18, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants