mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
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:
parent
634919a9fa
commit
c4ab11050d
4 changed files with 59 additions and 6 deletions
|
@ -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.
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue