Skip to content

Add HashAlgorithm Span-based APIs #22923

@stephentoub

Description

@stephentoub

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

Metadata

Metadata

Assignees

Labels

api-approvedAPI was approved in API review, it can be implementedarea-System.Securityhelp wanted[up-for-grabs] Good issue for external contributorstenet-performancePerformance related issue

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions