Fixed #21253 -- PBKDF2 with cached HMAC key #1724

Closed
wants to merge 1 commit into
from

2 participants

@timgraham
Django member

This gives a 2x speed increase compared to the existing implementation.

rebased from #1638

https://code.djangoproject.com/ticket/21253

@timgraham
Django member

@dstufft or @PaulMcMillan could either of you review this?

@apollo13 apollo13 and 1 other commented on an outdated diff Oct 20, 2013
django/utils/crypto.py
@@ -116,18 +116,14 @@ def _long_to_bin(x, hex_format_string):
return binascii.unhexlify((hex_format_string % x).encode('ascii'))
-def _fast_hmac(key, msg, digest):
+def _cached_hmac(msg, inner, outer):
"""
A trimmed down version of Python's HMAC implementation.
@apollo13
Django member
apollo13 added a line comment Oct 20, 2013

I'd remove this docstring, it no longer has much to do with python's version at all

@apollo13
Django member
apollo13 added a line comment Oct 20, 2013

Personally I'd just completely inline it into the function, it's not that much code anymore…

@timgraham
Django member
timgraham added a line comment Oct 21, 2013

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Sc00bz Sc00bz Fixed #21253 -- PBKDF2 with cached HMAC key
This gives a 2x speed increase compared to the existing implementation.
41c92d7
@timgraham timgraham closed this Oct 21, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment