refactor: cleanup hash to better support multiple implementations #5258
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.
Release Summary:
Resolved issues:
related to #5257
Description of changes:
See #5257 for a high-level description of why I need to touch the hashing code.
Handling both hashes and raw input interchangeably requires a new hash implementation. However, our current hash code isn't organized in a way that makes it easy to get consistent behavior between implementations. Before I add the new implementation, I want to reorganize the existing code: the "s2n_hash_" methods should handle the fields shared between all implementations, and the specific "s2n_evp_hash_" methods should only handle the fields in the "digest" union that are specific to the EVP hashing implementation.
Testing:
There should be no behavior changes here, so existing tests should be sufficient. I'm just moving code around.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.