summaryrefslogtreecommitdiff
path: root/admin/benchmarks.py
diff options
context:
space:
mode:
authorEli Collins <elic@assurancetechnologies.com>2016-02-10 14:27:53 -0500
committerEli Collins <elic@assurancetechnologies.com>2016-02-10 14:27:53 -0500
commit7b598fe89d604ef91efd4f71253ffb9ab0aae7c5 (patch)
tree1f732aa6364a37e3e18e5d0788eda208f95219d1 /admin/benchmarks.py
parent590aef9ab3d872830ca27d95833e78c737fccd2d (diff)
downloadpasslib-7b598fe89d604ef91efd4f71253ffb9ab0aae7c5.tar.gz
relocated many of the crypto routes inside passlib.utils,
and moved them to a separate passlib.crypto subpackage. along with this move, made a few api cleanups: * unified all code that's looking up hashes to use new passlib.crypto.lookup_hash() wrapper, which takes care of hash name normalization, loading fallback implementations, and alg metadata inspection, all hidden behind a memoized function. * deprecated pbkdf2() in favor of pbkdf2_hmac() -- only real use, and new signature matches stdlib function. additionally, this version is a bit faster, due to some assumptions that can be made due to the PRF always being HMAC based. * added compile_hmac() helper which does an even more efficient job of pre-compiling a keyed HMAC function; this helped speed up pbkdf2 a bit more.
Diffstat (limited to 'admin/benchmarks.py')
-rw-r--r--admin/benchmarks.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/admin/benchmarks.py b/admin/benchmarks.py
index 1a01951..3a980c0 100644
--- a/admin/benchmarks.py
+++ b/admin/benchmarks.py
@@ -283,17 +283,17 @@ def test_sha1_crypt():
#=============================================================================
@benchmark.constructor()
def test_pbkdf2_sha1():
- from passlib.utils.pbkdf2 import pbkdf2
+ from passlib.crypto.digest import pbkdf2_hmac
def helper():
- result = hexlify(pbkdf2("abracadabra", "open sesame", 10240, 20, "hmac-sha1"))
+ result = hexlify(pbkdf2_hmac("sha1", "abracadabra", "open sesame", 10240, 20))
assert result == 'e45ce658e79b16107a418ad4634836f5f0601ad1', result
return helper
@benchmark.constructor()
def test_pbkdf2_sha256():
- from passlib.utils.pbkdf2 import pbkdf2
+ from passlib.crypto.digest import pbkdf2_hmac
def helper():
- result = hexlify(pbkdf2("abracadabra", "open sesame", 10240, 32, "hmac-sha256"))
+ result = hexlify(pbkdf2_hmac("sha256", "abracadabra", "open sesame", 10240, 32))
assert result == 'fadef97054306c93c55213cd57111d6c0791735dcdde8ac32f9f934b49c5af1e', result
return helper