[New-bugs-announce] [issue28384] hmac cannot be used with shake algorithms

Min RK report at bugs.python.org
Fri Oct 7 07:50:44 EDT 2016


New submission from Min RK:

HMAC digest methods call inner.digest() with no arguments, but new-in-3.6 shake algorithms require a length argument.

possible solutions:

1. add optional length argument to HMAC.[hex]digest, and pass through to inner hash object
2. set hmac.digest_size, and use that to pass through to inner hash object if inner hash object has digest_size == 0
3. give shake hashers a default value for `length` in digest methods (logically 32 for shake_256, 16 for shake_128, I think)

test:

import hmac, hashlib

h = hmac.HMAC(b'secret', digestmod=hashlib.shake_256)
h.hexdigest() # raises on self.inner.digest() requires length argument

----------
messages: 278235
nosy: minrk
priority: normal
severity: normal
status: open
title: hmac cannot be used with shake algorithms
versions: Python 3.6, Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28384>
_______________________________________


More information about the New-bugs-announce mailing list