summaryrefslogtreecommitdiffstats
path: root/Lib/hmac.py
diff options
context:
space:
mode:
authorBénédikt Tran <10796600+picnixz@users.noreply.github.com>2025-04-12 17:43:11 (GMT)
committerGitHub <noreply@github.com>2025-04-12 17:43:11 (GMT)
commit9634085af3670b1eb654e3c7820aca66f358f39f (patch)
treeabd2125e2b5925ba649687ab4e22d909a8ec8204 /Lib/hmac.py
parent842ab815177549b9d4bec576d8f2c8f240b63506 (diff)
downloadcpython-9634085af3670b1eb654e3c7820aca66f358f39f.zip
cpython-9634085af3670b1eb654e3c7820aca66f358f39f.tar.gz
cpython-9634085af3670b1eb654e3c7820aca66f358f39f.tar.bz2
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.
Diffstat (limited to 'Lib/hmac.py')
-rw-r--r--Lib/hmac.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/hmac.py b/Lib/hmac.py
index 2af11c2..3683a4a 100644
--- a/Lib/hmac.py
+++ b/Lib/hmac.py
@@ -81,13 +81,13 @@ class HMAC:
try:
self._init_openssl_hmac(key, msg, digestmod)
return
- except _hashopenssl.UnsupportedDigestmodError:
+ except _hashopenssl.UnsupportedDigestmodError: # pragma: no cover
pass
if _hmac and isinstance(digestmod, str):
try:
self._init_builtin_hmac(key, msg, digestmod)
return
- except _hmac.UnknownHashError:
+ except _hmac.UnknownHashError: # pragma: no cover
pass
self._init_old(key, msg, digestmod)
@@ -121,12 +121,12 @@ class HMAC:
warnings.warn(f"block_size of {blocksize} seems too small; "
f"using our default of {self.blocksize}.",
RuntimeWarning, 2)
- blocksize = self.blocksize
+ blocksize = self.blocksize # pragma: no cover
else:
warnings.warn("No block_size attribute on given digest object; "
f"Assuming {self.blocksize}.",
RuntimeWarning, 2)
- blocksize = self.blocksize
+ blocksize = self.blocksize # pragma: no cover
if len(key) > blocksize:
key = digest_cons(key).digest()