summaryrefslogtreecommitdiffstats
path: root/Lib/hmac.py
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2013-11-20 16:35:06 (GMT)
committerChristian Heimes <christian@cheimes.de>2013-11-20 16:35:06 (GMT)
commitc4ab11050d3efa7dd409a96d006435d282d5815e (patch)
tree6ac7ac7dc3936425fdaca8bcab19c39ebeb50612 /Lib/hmac.py
parent634919a9fa1fffe3d36b13b4248f99508b5999ed (diff)
downloadcpython-c4ab11050d3efa7dd409a96d006435d282d5815e.zip
cpython-c4ab11050d3efa7dd409a96d006435d282d5815e.tar.gz
cpython-c4ab11050d3efa7dd409a96d006435d282d5815e.tar.bz2
Issue #18775: Add name and block_size attribute to HMAC object. They now
provide the same API elements as non-keyed cryptographic hash functions.
Diffstat (limited to 'Lib/hmac.py')
-rw-r--r--Lib/hmac.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/hmac.py b/Lib/hmac.py
index 873327b..77785a2 100644
--- a/Lib/hmac.py
+++ b/Lib/hmac.py
@@ -70,6 +70,10 @@ class HMAC:
RuntimeWarning, 2)
blocksize = self.blocksize
+ # self.blocksize is the default blocksize. self.block_size is
+ # effective block size as well as the public API attribute.
+ self.block_size = blocksize
+
if len(key) > blocksize:
key = self.digest_cons(key).digest()
@@ -79,6 +83,10 @@ class HMAC:
if msg is not None:
self.update(msg)
+ @property
+ def name(self):
+ return "hmac-" + self.inner.name
+
def update(self, msg):
"""Update this hashing object with the string msg.
"""