Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It is a common pattern in this package to accept a
h func() hash.Hash
argument, callch := h()
, usech
to know the hash type being used and then discardch
without performing any hash. Cumbersome, but it's what it is to be compatible with the upstream boring API. For example from the HKDF implementation:This process is currently allocating one slice and and calling a cgo function that will not be used at all, which hurts the performance across the board.
This PR refactors how hashes are implemented so that
newHashX
only initialize what is really necessary to identify the hash algorithm, defering other steps to when it is really needed.While here, fix PBKDF2 benchmarks.