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 HashAlgorithm Span-based APIs #22923

Closed
8 tasks
stephentoub opened this issue Jul 25, 2017 · 5 comments
Closed
8 tasks

Add HashAlgorithm Span-based APIs #22923

stephentoub opened this issue Jul 25, 2017 · 5 comments
Assignees
Labels
api-approved API was approved in API review, it can be implemented area-System.Security help wanted [up-for-grabs] Good issue for external contributors tenet-performance Performance related issue
Milestone

Comments

@stephentoub
Copy link
Member

Separated out of https://github.com/dotnet/corefx/issues/21281 for tracking purposes.

  • Implement in System.Security.Cryptography.Primitives in corefx
  • Expose from System.Security.Cryptography.Primitives contract in corefx
  • Add tests to System.Security.Cryptography.Primitives tests in corefx
namespace System.Security.Cryptography
{
    public abstract class HashAlgorithm
    {
        public bool TryComputeHash(ReadOnlySpan<byte> source, Span<byte> destination, out int bytesWritten);
        protected virtual void HashCore(ReadOnlySpan<byte> source);
        protected virtual bool TryHashFinal(Span<byte> destination, out int bytesWritten);}
}

These methods should then be overridden as-is appropriate on the implementations for:

  • MD5
  • SHA1
  • SHA256
  • SHA384
  • SHA512
@KrzysztofCwalina
Copy link
Member

Often the source bytes will not be in a single span. Maybe we should also expose these two protected members publicly?

@stephentoub
Copy link
Member Author

Often the source bytes will not be in a single span. Maybe we should also expose these two protected members publicly?

I believe the intent for such a case is to use IncrementalHash. @bartonjs?

@bartonjs
Copy link
Member

bartonjs commented Aug 8, 2017

Yup. HashAlgorithm is for one-shot, IncrementalHash is for cumulative/iterative.

@KrzysztofCwalina
Copy link
Member

OK, makes sense.

@stephentoub stephentoub self-assigned this Aug 8, 2017
@Tornhoof
Copy link
Contributor

Tornhoof commented Aug 9, 2017

Is Rfc2898DeriveBytes getting the Span Treatment too or is this rather dotnet/corefx#22615?

Dotnet-GitSync-Bot referenced this issue in Dotnet-GitSync-Bot/corefx Feb 15, 2019
…oat. (#22613)

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
jkotas referenced this issue in dotnet/corefx Feb 15, 2019
…oat. (#22613)

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 2.1.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-approved API was approved in API review, it can be implemented area-System.Security help wanted [up-for-grabs] Good issue for external contributors tenet-performance Performance related issue
Projects
None yet
Development

No branches or pull requests

5 participants