[issue32433] Provide optimized HMAC digest

2018-01-27 Thread Christian Heimes

Change by Christian Heimes :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32433] Provide optimized HMAC digest

2018-01-27 Thread Christian Heimes

Christian Heimes  added the comment:


New changeset 2f050c7e1b36bf641e7023f7b28b451454c6b98a by Christian Heimes in 
branch 'master':
bpo-32433: Optimized HMAC digest (#5023)
https://github.com/python/cpython/commit/2f050c7e1b36bf641e7023f7b28b451454c6b98a


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32433] Provide optimized HMAC digest

2017-12-27 Thread Christian Heimes

Change by Christian Heimes :


--
keywords: +patch
pull_requests: +4913

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32433] Provide optimized HMAC digest

2017-12-27 Thread Christian Heimes

New submission from Christian Heimes :

hmac.HMAC's flexibility comes with a cost. To create the MAC of a message, it 
has to create between three and four hash instances (inner, outer, key for long 
keys, result), multiple bound method objects and other temporary objects. For 
short messages, memory allocation, object handling and GIL release/acquire 
operations dominate the performance.

I propose to provide a fast one-shot HMAC function: hmac.digest(key, msg, 
digstmod) -> bytes function. A PoC implementation based on OpenSSL's HMAC() 
function and a pure Python implementation as inlined HMAC showed promising 
performance improvements. The C implementation is 3 times faster.

Standard HMAC:
$ ./python -m timeit -n20 -s "import hmac" -- "hmac.HMAC(b'key', 
b'message', 'sha256').digest()"
20 loops, best of 5: 5.38 usec per loop

Optimized Python code:
$ ./python -m timeit -n 20 -s "import hmac; hmac._hashopenssl = None" -- 
"hmac.digest(b'key', b'message', 'sha256')"
20 loops, best of 5: 3.87 usec per loop

OpenSSL HMAC()
$ ./python -m timeit -n 20 -s "import hmac" -- "hmac.digest(b'key', 
b'message', 'sha256')"
20 loops, best of 5: 1.82 usec per loop

--
components: Extension Modules
messages: 309097
nosy: christian.heimes, gregory.p.smith
priority: normal
severity: normal
stage: patch review
status: open
title: Provide optimized HMAC digest
type: performance
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com