Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9634085

Browse files
authored
gh-132388: Increase test coverage for HMAC (#132389)
- Correctly test missing `digestmod` and `digest` parameters. - Test when chunks of length > 2048 are passed to `update()`. - Test one-shot HMAC-BLAKE2.
1 parent 842ab81 commit 9634085

File tree

2 files changed

+156
-53
lines changed

2 files changed

+156
-53
lines changed

Lib/hmac.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ def __init(self, key, msg, digestmod):
8181
try:
8282
self._init_openssl_hmac(key, msg, digestmod)
8383
return
84-
except _hashopenssl.UnsupportedDigestmodError:
84+
except _hashopenssl.UnsupportedDigestmodError: # pragma: no cover
8585
pass
8686
if _hmac and isinstance(digestmod, str):
8787
try:
8888
self._init_builtin_hmac(key, msg, digestmod)
8989
return
90-
except _hmac.UnknownHashError:
90+
except _hmac.UnknownHashError: # pragma: no cover
9191
pass
9292
self._init_old(key, msg, digestmod)
9393

@@ -121,12 +121,12 @@ def _init_old(self, key, msg, digestmod):
121121
warnings.warn(f"block_size of {blocksize} seems too small; "
122122
f"using our default of {self.blocksize}.",
123123
RuntimeWarning, 2)
124-
blocksize = self.blocksize
124+
blocksize = self.blocksize # pragma: no cover
125125
else:
126126
warnings.warn("No block_size attribute on given digest object; "
127127
f"Assuming {self.blocksize}.",
128128
RuntimeWarning, 2)
129-
blocksize = self.blocksize
129+
blocksize = self.blocksize # pragma: no cover
130130

131131
if len(key) > blocksize:
132132
key = digest_cons(key).digest()

0 commit comments

Comments
 (0)