Closed Genbox closed 2 years ago
@Genbox The ICryptoTransform nature of HashAlgorithm is (for better or worse) has come back with netstandard2.0.
But I'm rather fond of the separated nature of the incremental and atomic hashes (though we did also fix the side effects of intermixing), so I'm happy to see IncrementalHash support other things. We'd just need an API proposal to discuss.
This is one piece of an overall "bring your own crypto stack" / 3rd party extensibility for our crypto stack.
Right now that's not a priority for us, and we'd really need to be partnering with someone to try to make sense out of it overall... a design without a concrete usage is bound to be inadequate.
Incremental/stateful hashing was refactored into its own class called IncrementalHash according to @bartonjs in issue dotnet/runtime#17621
I think this is a good change, however, the refactoring left out the possibility of integration with third-party stateful (incremental) hash algorithms. The IncrementalHash class is a simple wrapper for the real implementation HashProvider, but users can't implement HashProvider as it is internal, and the IncrementalHash wrapper is not extensible as well.
In good design, I'd want hash algorithms to be exchangeable in an API, which is possible with HashAlgorithm, but not with IncrementalHash or HashProvider. Arguably, most people could take in HashAlgorithmName and give it to IncrementalHash.Create(), but that does not support third party hash algorithm implementations.
I'd propose the API is refactored once more (while IncrementalHash is not widely used), to support integration of third party stateful/incremental hash algorithms.