Issue #18775: Add name and block_size attribute to HMAC object. They now

provide the same API elements as non-keyed cryptographic hash functions.
This commit is contained in:
Christian Heimes 2013-11-20 17:35:06 +01:00
parent 634919a9fa
commit c4ab11050d
4 changed files with 59 additions and 6 deletions

View file

@ -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.
"""