mirror of
https://github.com/python/cpython.git
synced 2025-11-01 14:11:41 +00:00
gh-130149: cleanup refactorization of test_hmac.py (#131318)
New features: * refactor `hashlib_helper.requires_hashdigest` in prevision of a future `hashlib_helper.requires_builtin_hashdigest` for built-in hashes only * add `hashlib_helper.requires_openssl_hashdigest` to request OpenSSL hashes, assuming that `_hashlib` exists. Refactoring: * split hmac.copy() test by implementation * update how algorithms are discovered for RFC test cases * simplify how OpenSSL hash digests are requested * refactor hexdigest tests for RFC test vectors * typo fix: `assert_hmac_hexdigest_by_new` -> `assert_hmac_hexdigest_by_name` Improvements: * strengthen contract on `hmac_new_by_name` and `hmac_digest_by_name` * rename mixin classes to better match their responsibility
This commit is contained in:
parent
85c04f80fd
commit
de8890f5ab
3 changed files with 263 additions and 147 deletions
|
|
@ -65,6 +65,7 @@ def __init__(self, key, msg=None, digestmod=''):
|
|||
|
||||
def _init_hmac(self, key, msg, digestmod):
|
||||
self._hmac = _hashopenssl.hmac_new(key, msg, digestmod=digestmod)
|
||||
self._inner = self._outer = None # because the slots are defined
|
||||
self.digest_size = self._hmac.digest_size
|
||||
self.block_size = self._hmac.block_size
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue