hmac: Rewrite of the HMAC module to use uhashlib #82
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.
This PR is for a rewrite of the HMAC module to use uhashlib instead of the pure Python hashlib implementations of the hash functions. This was motivated by the tight RAM requirements of operating on the ESP8266. This work removes both the dependency on hashlib as well as warnings to make it simple to add as a standalone module as frozen bytecode.
Additionally it provides a safe digest_compare implementation that uses two techniques to thwart timing side channel attacks. This implementation optionally relies on uos to provide access to urandom.
It includes a test suite from upstream Python 3.5 which uncovered a bug in the translate method of this module, which meant that when some forms of keys were used HMAC's were being computed incorrectly. Using this test suite provides confidence in the correctness and parity between this implementation and the upstream.
This test suite has been run on the ESP8266 port only.
A big thank you to @slush0 who graciously ported over this module originally.
This is more first contribution to the micropython-lib, I have read the guidelines for contributing and tried to follow them. Finally, I welcome any additional feedback and appreciate your review.